linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] sysctl: cap file-max value at ULONG_MAX
@ 2018-10-14 13:25 Christian Brauner
  2018-10-14 13:25 ` [PATCH 1/2] sysctl: add overflow detection to proc_get_long() Christian Brauner
  2018-10-14 13:25 ` [PATCH 2/2] sysctl: handle overflow for file-max Christian Brauner
  0 siblings, 2 replies; 9+ messages in thread
From: Christian Brauner @ 2018-10-14 13:25 UTC (permalink / raw)
  To: keescook, linux-kernel
  Cc: ebiederm, mcgrof, akpm, joe.lawrence, longman, Christian Brauner

Hey,

Currently, when writing

echo 18446744073709551616 > /proc/sys/fs/file-max

/proc/sys/fs/file-max will overflow and be set to 0. That quickly
crashes the system. Let's detect the overflow and set to ULONG_MAX in
this case effectively capping the value.

The patch tries to ensure that there is no other user visible change in
behavior for other values. Only when a maximum value is set for a
specific sysctl will it be capped on overflow. The details are outlined
in the commit message of the first commit.

(This patchset is in reference to https://lkml.org/lkml/2018/10/11/585.)

Thanks!
Christian

Christian Brauner (2):
  sysctl: add overflow detection to proc_get_long()
  sysctl: handle overflow for file-max

 kernel/sysctl.c | 54 ++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 42 insertions(+), 12 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] sysctl: add overflow detection to proc_get_long()
@ 2018-10-14 22:13 Alexey Dobriyan
  2018-10-14 22:43 ` Christian Brauner
  0 siblings, 1 reply; 9+ messages in thread
From: Alexey Dobriyan @ 2018-10-14 22:13 UTC (permalink / raw)
  To: christian; +Cc: linux-kernel, viro

> > Yecchh...  First of all, the cast back to unsigned long long is completely
> > pointless.  What's more,
> 
> Sorry, seriously asking: why?

In C everything is casted to the same type before doing an operation,
in this case comparison

> This was meant to handle the case where
> sizeof(unsigned long long) != sizeof(unsigned long) and I just looked at
> _kstrtoul() which does the same:

Second cast is unnecessary. I don't remember why I did 2 casts.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-10-15  4:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-14 13:25 [PATCH 0/2] sysctl: cap file-max value at ULONG_MAX Christian Brauner
2018-10-14 13:25 ` [PATCH 1/2] sysctl: add overflow detection to proc_get_long() Christian Brauner
2018-10-14 17:18   ` Al Viro
2018-10-14 18:53     ` Christian Brauner
2018-10-15  0:03       ` Al Viro
2018-10-15  4:47         ` Christian Brauner
2018-10-14 13:25 ` [PATCH 2/2] sysctl: handle overflow for file-max Christian Brauner
2018-10-14 22:13 [PATCH 1/2] sysctl: add overflow detection to proc_get_long() Alexey Dobriyan
2018-10-14 22:43 ` Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).