Skip to content

Commit 310731e

Browse files
q2vendavem330
authored andcommitted
net: Fix data-races around sysctl_mem.
While reading .sysctl_mem, it can be changed concurrently. So, we need to add READ_ONCE() to avoid data-races. Fixes: 1da177e ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3d32edf commit 310731e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/net/sock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1529,7 +1529,7 @@ void __sk_mem_reclaim(struct sock *sk, int amount);
15291529
/* sysctl_mem values are in pages, we convert them in SK_MEM_QUANTUM units */
15301530
static inline long sk_prot_mem_limits(const struct sock *sk, int index)
15311531
{
1532-
long val = sk->sk_prot->sysctl_mem[index];
1532+
long val = READ_ONCE(sk->sk_prot->sysctl_mem[index]);
15331533

15341534
#if PAGE_SIZE > SK_MEM_QUANTUM
15351535
val <<= PAGE_SHIFT - SK_MEM_QUANTUM_SHIFT;

0 commit comments

Comments
 (0)