Messages in this thread | | | Date | Thu, 19 Oct 2000 12:48:34 -0700 (PDT) | From | Linus Torvalds <> | Subject | Re: mapping user space buffer to kernel address space |
| |
On Wed, 18 Oct 2000, Jeff Garzik wrote: > > Well coolio. Would somebody be up for sanity checking my audio mmap > code (attached)? It doesn't look too hard at all to get the audio > drivers doing the correct thing.
Looks reasonable - although your "max_size" checks are wrong at mmap time. You should check for something like
if (size > max_size) goto out; if (offset > max_size - size) goto out;
instead of your current (offset >= max_size) check. As it stands, I think you can mmap past the end by just having size and offset < max_size, but the _sum_ being bigger..
> Since this code works in my local tests, my two concerns at this point > are correct vma->vm_pgoff treatment, and correct vm_flags/vm_file usage.
You should drop the
vma->vm_file = file;
as the VM layer will have done that already.
Also, the VM_LOCKED | VM_SHM thing is wrong, because it will cause mis-calulcation of the mm->vm_locked fields, and it's also unnecessary. Sure, it will cause the VM layer to not swap, but the no-op "swapping" shouldn't much hurt anyway, as it's easy enough to re-populate the page again.
So either just drop it, or make sure that the locked page count doesn't get corrupted.
Linus
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org Please read the FAQ at http://www.tux.org/lkml/
| |