Re: [RFC] Warn the user when they could overflow mapcount

2018-02-08 Thread Daniel Micay
I think there are likely legitimate programs mapping something a bunch of times. Falling back to a global object -> count mapping (an rbtree / radix trie or whatever) with a lock once it hits saturation wouldn't risk breaking something. It would permanently leave the inline count saturated and jus

Re: [RFC] Warn the user when they could overflow mapcount

2018-02-08 Thread Matthew Wilcox
On Thu, Feb 08, 2018 at 02:48:52PM -0500, Daniel Micay wrote: > I guess it could saturate and then switch to tracking the count via an > object pointer -> count mapping with a global lock? Whatever the > solution is should probably be a generic one since it's a recurring > issue. I was thinking of

Re: [RFC] Warn the user when they could overflow mapcount

2018-02-08 Thread Daniel Micay
I guess it could saturate and then switch to tracking the count via an object pointer -> count mapping with a global lock? Whatever the solution is should probably be a generic one since it's a recurring issue.

Re: [RFC] Warn the user when they could overflow mapcount

2018-02-08 Thread Matthew Wilcox
On Thu, Feb 08, 2018 at 02:33:58PM -0500, Daniel Micay wrote: > I don't think the kernel can get away with the current approach. > Object sizes and counts on 64-bit should be 64-bit unless there's a > verifiable reason they can get away with 32-bit. Having it use leak > memory isn't okay, just much

Re: [RFC] Warn the user when they could overflow mapcount

2018-02-08 Thread Daniel Micay
I don't think the kernel can get away with the current approach. Object sizes and counts on 64-bit should be 64-bit unless there's a verifiable reason they can get away with 32-bit. Having it use leak memory isn't okay, just much less bad than vulnerabilities exploitable beyond just denial of servi

Re: [RFC] Warn the user when they could overflow mapcount

2018-02-08 Thread Matthew Wilcox
On Thu, Feb 08, 2018 at 01:05:33PM -0500, Daniel Micay wrote: > The standard map_max_count / pid_max are very low and there are many > situations where either or both need to be raised. [snip good reasons] > I do think the default value in the documentation should be fixed but > if there's a clea

Re: [RFC] Warn the user when they could overflow mapcount

2018-02-08 Thread Daniel Micay
>> That seems pretty bad. So here's a patch which adds documentation to the >> two sysctls that a sysadmin could use to shoot themselves in the foot, >> and adds a warning if they change either of them to a dangerous value. > > I have negative feelings about this patch, mostly because AFAICS: > >

Re: [RFC] Warn the user when they could overflow mapcount

2018-02-08 Thread valdis . kletnieks
On Thu, 08 Feb 2018 03:56:26 +0100, Jann Horn said: > I wouldn't be too surprised if there are more 32-bit overflows that > start being realistic once you put something on the order of terabytes > of memory into one machine, given that refcount_t is 32 bits wide - > for example, the i_count. See >

Re: [RFC] Warn the user when they could overflow mapcount

2018-02-07 Thread Matthew Wilcox
On Thu, Feb 08, 2018 at 02:18:04PM +1100, Tobin C. Harding wrote: > > +++ b/Documentation/sysctl/vm.txt > > @@ -379,7 +379,8 @@ While most applications need less than a thousand maps, > > certain > > programs, particularly malloc debuggers, may consume lots of them, > > e.g., up to one or two ma

Re: [RFC] Warn the user when they could overflow mapcount

2018-02-07 Thread Matthew Wilcox
On Thu, Feb 08, 2018 at 03:56:26AM +0100, Jann Horn wrote: > How much memory would you need to trigger this? You need one > vm_area_struct per increment, and those are 200 bytes? So at least > 800GiB of memory for the vm_area_structs, and maybe more for other > data structures? That's a good point

Re: [RFC] Warn the user when they could overflow mapcount

2018-02-07 Thread Tobin C. Harding
On Wed, Feb 07, 2018 at 06:11:12PM -0800, Matthew Wilcox wrote: > > Kirill and I were talking about trying to overflow page->_mapcount > the other day and realised that the default settings of pid_max and > max_map_count prevent it [1]. But there isn't even documentation to > warn a sysadmin that

Re: [RFC] Warn the user when they could overflow mapcount

2018-02-07 Thread Jann Horn
On Thu, Feb 8, 2018 at 3:11 AM, Matthew Wilcox wrote: > Kirill and I were talking about trying to overflow page->_mapcount > the other day and realised that the default settings of pid_max and > max_map_count prevent it [1]. But there isn't even documentation to > warn a sysadmin that they've jus

[RFC] Warn the user when they could overflow mapcount

2018-02-07 Thread Matthew Wilcox
Kirill and I were talking about trying to overflow page->_mapcount the other day and realised that the default settings of pid_max and max_map_count prevent it [1]. But there isn't even documentation to warn a sysadmin that they've just opened themselves up to the possibility that they've opened