diff options
author | Andi Kleen <andi@firstfloor.org> | 2010-01-15 20:01:15 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-01-16 15:15:38 -0500 |
commit | 64ce1037c5434b1d036cd99ecaee6e00496bc2e9 (patch) | |
tree | 37a8c8f1dccdcdb3d00bf07d36d86fe6ea05f3f9 /include/linux/kfifo.h | |
parent | 8ecc2951534af10e04ddb5e5ff5c6d217b79f5c2 (diff) |
kfifo: sanitize *_user error handling
Right now for kfifo_*_user it's not easily possible to distingush between
a user copy failing and the FIFO not containing enough data. The problem
is that both conditions are multiplexed into the same return code.
Avoid this by moving the "copy length" into a separate output parameter
and only return 0/-EFAULT in the main return value.
I didn't fully adapt the weird "record" variants, those seem
to be unused anyways and were rather messy (should they be just removed?)
I would appreciate some double checking if I did all the conversions
correctly.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Cc: Stefani Seibold <stefani@seibold.net>
Cc: Roland Dreier <rdreier@cisco.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Andy Walls <awalls@radix.net>
Cc: Vikram Dhillon <dhillonv10@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/kfifo.h')
-rw-r--r-- | include/linux/kfifo.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h index 6fb495ea956a..86ad50a900c8 100644 --- a/include/linux/kfifo.h +++ b/include/linux/kfifo.h | |||
@@ -235,11 +235,11 @@ static inline __must_check unsigned int kfifo_out_locked(struct kfifo *fifo, | |||
235 | 235 | ||
236 | extern void kfifo_skip(struct kfifo *fifo, unsigned int len); | 236 | extern void kfifo_skip(struct kfifo *fifo, unsigned int len); |
237 | 237 | ||
238 | extern __must_check unsigned int kfifo_from_user(struct kfifo *fifo, | 238 | extern __must_check int kfifo_from_user(struct kfifo *fifo, |
239 | const void __user *from, unsigned int n); | 239 | const void __user *from, unsigned int n, unsigned *lenout); |
240 | 240 | ||
241 | extern __must_check unsigned int kfifo_to_user(struct kfifo *fifo, | 241 | extern __must_check int kfifo_to_user(struct kfifo *fifo, |
242 | void __user *to, unsigned int n); | 242 | void __user *to, unsigned int n, unsigned *lenout); |
243 | 243 | ||
244 | /* | 244 | /* |
245 | * __kfifo_add_out internal helper function for updating the out offset | 245 | * __kfifo_add_out internal helper function for updating the out offset |