Skip to content

Commit cba9f33

Browse files
Bart SamwelLinus Torvalds
authored andcommitted
[PATCH] Range checking in do_proc_dointvec_(userhz_)jiffies_conv
When (integer) sysctl values are in either seconds or centiseconds, but represented internally as jiffies, the allowable value range is decreased. This patch adds range checks to the conversion routines. For values in seconds: maximum LONG_MAX / HZ. For values in centiseconds: maximum (LONG_MAX / HZ) * USER_HZ. (BTW, does anyone else feel that an interface in seconds should not be accepting negative values?) Signed-off-by: Bart Samwel <bart@samwel.tk> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent ed5b43f commit cba9f33

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎kernel/sysctl.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,6 +2053,8 @@ static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
20532053
int write, void *data)
20542054
{
20552055
if (write) {
2056+
if (*lvalp > LONG_MAX / HZ)
2057+
return 1;
20562058
*valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
20572059
} else {
20582060
int val = *valp;
@@ -2074,6 +2076,8 @@ static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
20742076
int write, void *data)
20752077
{
20762078
if (write) {
2079+
if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2080+
return 1;
20772081
*valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
20782082
} else {
20792083
int val = *valp;

0 commit comments

Comments
 (0)