forked fromtorvalds/linux
- Notifications
You must be signed in to change notification settings - Fork0
Commit488dac0
libfs: fix error cast of negative value in simple_attr_write()
The attr->set() receive a value of u64, but simple_strtoll() is used fordoing the conversion. It will lead to the error cast if user inputs anegative value.Use kstrtoull() instead of simple_strtoll() to convert a string got fromthe user to an unsigned value. The former will return '-EINVAL' if itgets a negetive value, but the latter can't handle the situationcorrectly. Make 'val' unsigned long long as what kstrtoull() takes,this will eliminate the compile warning on no 64-bit architectures.Fixes:f7b8863 ("fs/libfs.c: fix simple_attr_write() on 32bit machines")Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>Signed-off-by: Andrew Morton <akpm@linux-foundation.org>Cc: Al Viro <viro@zeniv.linux.org.uk>Link:https://lkml.kernel.org/r/1605341356-11872-1-git-send-email-yangyicong@hisilicon.comSigned-off-by: Linus Torvalds <torvalds@linux-foundation.org>1 parentbfe8cc1 commit488dac0
1 file changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
959 | 959 | | |
960 | 960 | | |
961 | 961 | | |
962 | | - | |
| 962 | + | |
963 | 963 | | |
964 | 964 | | |
965 | 965 | | |
| |||
977 | 977 | | |
978 | 978 | | |
979 | 979 | | |
980 | | - | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
981 | 983 | | |
982 | 984 | | |
983 | 985 | | |
| |||
0 commit comments
Comments
(0)