Skip to content

Commit

Permalink
sysctl: report EINVAL if value is larger than UINT_MAX for proc_douin…
Browse files Browse the repository at this point in the history
…tvec

Currently, inputting the following command will succeed but actually the
value will be truncated:

  # echo 0x12ffffffff > /proc/sys/net/ipv4/tcp_notsent_lowat

This is not friendly to the user, so instead, we should report error
when the value is larger than UINT_MAX.

Fixes: e7d316a ("sysctl: handle error writing UINT_MAX to u32 fields")
Signed-off-by: Liping Zhang <[email protected]>
Cc: Subash Abhinov Kasiviswanathan <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Eric W. Biederman <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Liping Zhang authored and torvalds committed Apr 8, 2017
1 parent 8b65bb5 commit 425fffd
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions kernel/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2133,6 +2133,8 @@ static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
if (write) {
if (*negp)
return -EINVAL;
if (*lvalp > UINT_MAX)
return -EINVAL;
*valp = *lvalp;
} else {
unsigned int val = *valp;
Expand Down

0 comments on commit 425fffd

Please sign in to comment.