diff options
author | Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk> | 2004-07-13 19:37:04 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-07-13 19:37:04 -0700 |
commit | 790d43fd412fbb30bfb61504250e88ece790f485 (patch) | |
tree | d129747d615470a10c45d2ada3386f593e66b5dd /mm | |
parent | c659d1a85a24500b775390a0d5f6a2fe06d6cbf4 (diff) | |
download | history-790d43fd412fbb30bfb61504250e88ece790f485.tar.gz |
[PATCH] sparse: read_descriptor_t annotation
We have a fun situation with read_descriptor_t - all its instances end
up passed to some actor; these actors use desc->buf as their private
data; there are 5 of them and they expect resp:
struct lo_read_data *
struct svc_rqst *
struct file *
struct rpc_xprt *
char __user *
IOW, there is no type safety whatsoever; the field is essentially untyped,
we rely on the fact that actor is chosen by the same code that sets ->buf
and expect it to put something of the right type there.
Right now desc->buf is declared as char __user *. Moreover, the last
argument of ->sendfile() (what should be stored in ->buf) is void __user *,
even though it's actually _never_ a userland pointer.
If nothing else, ->sendfile() should take void * instead; that alone removes
a bunch of bogus warnings. I went further and replaced desc->buf with a
union of void * and char __user *.
Diffstat (limited to 'mm')
-rw-r--r-- | mm/filemap.c | 16 | ||||
-rw-r--r-- | mm/shmem.c | 6 |
2 files changed, 11 insertions, 11 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index 087e0525b967d7..cb3a40145c8634 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -836,9 +836,9 @@ int file_read_actor(read_descriptor_t *desc, struct page *page, * Faults on the destination of a read are common, so do it before * taking the kmap. */ - if (!fault_in_pages_writeable(desc->buf, size)) { + if (!fault_in_pages_writeable(desc->arg.buf, size)) { kaddr = kmap_atomic(page, KM_USER0); - left = __copy_to_user(desc->buf, kaddr + offset, size); + left = __copy_to_user(desc->arg.buf, kaddr + offset, size); kunmap_atomic(kaddr, KM_USER0); if (left == 0) goto success; @@ -846,7 +846,7 @@ int file_read_actor(read_descriptor_t *desc, struct page *page, /* Do it the slow way */ kaddr = kmap(page); - left = __copy_to_user(desc->buf, kaddr + offset, size); + left = __copy_to_user(desc->arg.buf, kaddr + offset, size); kunmap(page); if (left) { @@ -856,7 +856,7 @@ int file_read_actor(read_descriptor_t *desc, struct page *page, success: desc->count = count - size; desc->written += size; - desc->buf += size; + desc->arg.buf += size; return size; } @@ -923,7 +923,7 @@ __generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov, read_descriptor_t desc; desc.written = 0; - desc.buf = iov[seg].iov_base; + desc.arg.buf = iov[seg].iov_base; desc.count = iov[seg].iov_len; if (desc.count == 0) continue; @@ -973,7 +973,7 @@ int file_send_actor(read_descriptor_t * desc, struct page *page, unsigned long o { ssize_t written; unsigned long count = desc->count; - struct file *file = (struct file *) desc->buf; + struct file *file = desc->arg.data; if (size > count) size = count; @@ -990,7 +990,7 @@ int file_send_actor(read_descriptor_t * desc, struct page *page, unsigned long o } ssize_t generic_file_sendfile(struct file *in_file, loff_t *ppos, - size_t count, read_actor_t actor, void __user *target) + size_t count, read_actor_t actor, void *target) { read_descriptor_t desc; @@ -999,7 +999,7 @@ ssize_t generic_file_sendfile(struct file *in_file, loff_t *ppos, desc.written = 0; desc.count = count; - desc.buf = target; + desc.arg.data = target; desc.error = 0; do_generic_file_read(in_file, ppos, &desc, actor); diff --git a/mm/shmem.c b/mm/shmem.c index 6581c5d6e4f239..ee0d0e77469534 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1474,7 +1474,7 @@ static ssize_t shmem_file_read(struct file *filp, char __user *buf, size_t count desc.written = 0; desc.count = count; - desc.buf = buf; + desc.arg.buf = buf; desc.error = 0; do_shmem_file_read(filp, ppos, &desc, file_read_actor); @@ -1484,7 +1484,7 @@ static ssize_t shmem_file_read(struct file *filp, char __user *buf, size_t count } static ssize_t shmem_file_sendfile(struct file *in_file, loff_t *ppos, - size_t count, read_actor_t actor, void __user *target) + size_t count, read_actor_t actor, void *target) { read_descriptor_t desc; @@ -1493,7 +1493,7 @@ static ssize_t shmem_file_sendfile(struct file *in_file, loff_t *ppos, desc.written = 0; desc.count = count; - desc.buf = target; + desc.arg.data = target; desc.error = 0; do_shmem_file_read(in_file, ppos, &desc, actor); |