Skip to contentSkip to conversation

sysctl: cap to ULONG_MAX in proc_get_long()

PATCH Alexey Dobriyan 3 participants 3 messages Oct 15, 2018

lore
Share & tools
lore
#0 lore raw
Quoted 2 lines

int kstrtoul_bounded(const char *s, unsigned int base, char **trailing, unsigned long long *res)

NO! The whole point is not have million variants of slightly different integer parsing functions.
Cap it in the sysctl -- noone would care.

#1 lore raw
Quoted 7 lines · Alexey Dobriyan
Quoted 3 lines

int kstrtoul_bounded(const char *s, unsigned int base, char **trailing, unsigned long long *res)

NO! The whole point is not have million variants of slightly different integer parsing functions.
Cap it in the sysctl -- noone would care.

(Please keep the CC list when replying.)

Whatever works; I prefer the local strtoul_cap_erange() in kernel/sysctl.c as well.

Reviewed-by
#2 lore raw
Quoted 5 lines · Christian Brauner
Quoted 4 lines · Alexey Dobriyan
Quoted 3 lines

int kstrtoul_bounded(const char *s, unsigned int base, char **trailing, unsigned long long *res)

Quoted 8 lines
Quoted 3 lines

NO! The whole point is not have million variants of slightly different integer parsing functions.
Cap it in the sysctl -- noone would care.

(Please keep the CC list when replying.)

Whatever works; I prefer the local strtoul_cap_erange() in kernel/sysctl.c as well.

This does match the standard of "evolution" for the kernel: there is only one user currently, so keep it a static in sysctl.c. If we grow a greater need, we can move it into lib/.

-Kees

Signature · 2 lines
Kees Cook
Pixel Security