diff options
| author | Kuniyuki Iwashima <kuniyu@google.com> | 2026-11-05 21:29:00 +0000 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2026-11-10 15:34:32 -0800 |
| commit | 8012eec76b7e6c0d9fb338fe8e3db6ca1b419da4 (patch) | |
| tree | 96752e54cf1098c12de2a6a7286c49711a17fc5f /tools/perf/scripts/python | |
| parent | 6c81715d9f854822d59d22629dcc626da8740862 (diff) | |
net: Fix memory_allocated leak in __sk_mem_raise_allocated().
__sk_mem_raise_allocated() calls sk_memory_allocated_add() and
reuses the return value to check if it was called.
However, sk_memory_allocated_{add,sub}() cache a value in per-cpu
counter, sk->sk_prot->per_cpu_fw_alloc, up to sysctl_mem_pcpu_rsv
before reflecting it to sk->sk_prot->memory_allocated.
Thus, sk->sk_prot->memory_allocated could have a negative value,
and proto_memory_allocated() returns 0 in such a case.
Then, if mem_cgroup_sk_charge() succeeds, sk_prot_mem_limits()
checks are bypassed, and if mem_cgroup_sk_charge() fails,
sk_memory_allocated_sub() is not called, leaking counters.
Let's use sk->sk_bypass_prot_mem instead of allocated.
Fixes: 7c268eaeec63 ("net: Allow opt-out from global protocol memory accounting.")
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20261105212905.3122712-1-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions
