On Wed, Feb 09, 2005 at 08:19:30AM -0800, Srdjan Sobajic hit keys to express the following: > Hi, > > In the 2.4 kernel series, is the following code correct? > > copy_to_user(user_buffer, kernel_buffer_a, kernel_buf_a_size); > copy_to_user(user_buffer + kernel_buf_a_size, buffer_b, buf_b_size); > > The point is calling copy_to_user twice to copy two kernel mode blobs > into the same user mode buffer, while _incrementing_ the user mode > buffer pointer. This is correct as far as the kernel is concerned. Before doing copy_{to,from}_user, kernel will check the access permissions (access_ok() ). But the functionality of access_ok() is limited to checking whether the address has reasonable permissions (i.e, the page belonging to memory is legitimately allocated to the process). say the code, char *str = malloc(10); succeeds. Internally glibc may allocate 1 page for the process as a result of this request. if you pass str to kernel and try kbuffer = kmalloc (100, GFP_KERNEL); copy_from_user ( str, kbuffer, 100); /* this call will succeed, but produce unsavoury results). Hope this helps. Om. -- Excellent day for putting Slinkies on an escalator. -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/