On Fri, Sep 16, 2022 at 11:23:25AM +0300, Dan Carpenter wrote: > [...] > net/ipv6/mcast.c:450 ip6_mc_source() saving 'size_add' to type 'int' Interesting! Are you able to report the consumer? e.g. I think a bunch of these would be fixed by: diff --git a/net/core/sock.c b/net/core/sock.c index 4cb957d934a2..f004c4d411e3 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -2552,10 +2552,11 @@ struct sk_buff *sock_omalloc(struct sock *sk, unsigned long size, /* * Allocate a memory block from the socket's option memory buffer. */ -void *sock_kmalloc(struct sock *sk, int size, gfp_t priority) +void *sock_kmalloc(struct sock *sk, size_t size, gfp_t priority) { - if ((unsigned int)size <= sysctl_optmem_max && - atomic_read(&sk->sk_omem_alloc) + size < sysctl_optmem_max) { + if (size > INT_MAX || size > sysctl_optmem_max) + return NULL; + if (atomic_read(&sk->sk_omem_alloc) < sysctl_optmem_max - size) { void *mem; /* First do the add, to avoid the race if kmalloc * might sleep. -- Kees Cook