Message ID | 20211103234911.4073969-1-eric.dumazet@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | d00c8ee31729248ba40b4ab25cd3b3b580c6f87c |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net] net: fix possible NULL deref in sock_reserve_memory | expand |
Hello: This patch was applied to netdev/net.git (master) by David S. Miller <davem@davemloft.net>: On Wed, 3 Nov 2021 16:49:11 -0700 you wrote: > From: Eric Dumazet <edumazet@google.com> > > Sanity check in sock_reserve_memory() was not enough to prevent malicious > user to trigger a NULL deref. > > In this case, the isse is that sk_prot->memory_allocated is NULL. > > [...] Here is the summary with links: - [net] net: fix possible NULL deref in sock_reserve_memory https://git.kernel.org/netdev/net/c/d00c8ee31729 You are awesome, thank you!
diff --git a/net/core/sock.c b/net/core/sock.c index 9862eefce21ede8644f84c99c539643ec31c7908..8f2b2f2c0e7b1decdb4a5c8d86327ed7caa62c99 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -976,7 +976,7 @@ static int sock_reserve_memory(struct sock *sk, int bytes) bool charged; int pages; - if (!mem_cgroup_sockets_enabled || !sk->sk_memcg) + if (!mem_cgroup_sockets_enabled || !sk->sk_memcg || !sk_has_account(sk)) return -EOPNOTSUPP; if (!bytes)