2021-02-25 05:18:45

by Ivan Babrou

[permalink] [raw]
Subject: Memory allocation issues after "sysctl: Convert to iter interfaces"

Hello,

We started seeing allocation failures on procfs reads after
commit 4bd6a7353ee1 "sysctl: Convert to iter interfaces".

I haven't done a full bisect, but the decoded stacks point
squarely at the following piece of code which was introduced:

kbuf = kzalloc(count + 1, GFP_KERNEL);

Previously reading /proc/sys/net/core/somaxconn required order 1
and order 3 allocations from the kernel, which can be seen from:

$ sudo perf record -g -e kmem:mm_page_alloc_zone_locked -- \
cat /proc/sys/net/core/somaxconn

Now we see order 6 + order 6 allocations from cat, and even:

read(3, 0x7f8d9d3f3000, 131072) = -1 ENOMEM (Cannot allocate memory)

See the following gist for full allocation stacks on 5.4 and 5.10:

* https://gist.github.com/bobrik/dd03cce0aaeef5acd5faecc32bd44530

This seems like a regression, and unprivileged users being
able to force order 6 allocations onto the kernel doesn't feel good.


2021-02-25 05:29:34

by Matthew Wilcox

[permalink] [raw]
Subject: Re: Memory allocation issues after "sysctl: Convert to iter interfaces"

On Wed, Feb 24, 2021 at 05:02:09PM -0800, Ivan Babrou wrote:
> Hello,
>
> We started seeing allocation failures on procfs reads after
> commit 4bd6a7353ee1 "sysctl: Convert to iter interfaces".

https://lore.kernel.org/linux-fsdevel/6345270a2c1160b89dd5e6715461f388176899d1.1612972413.git.josef@toxicpanda.com/