net: Fix data-races around sysctl_[rw]mem(_offset)?.
[ Upstream commit 02739545951ad4c1215160db7fbf9b7a918d3c0b ]
While reading these sysctl variables, they can be changed concurrently.
Thus, we need to add READ_ONCE() to their readers.
- .sysctl_rmem
- .sysctl_rwmem
- .sysctl_rmem_offset
- .sysctl_wmem_offset
- sysctl_tcp_rmem[1, 2]
- sysctl_tcp_wmem[1, 2]
- sysctl_decnet_rmem[1]
- sysctl_decnet_wmem[1]
- sysctl_tipc_rmem[1]
Fixes: 1da177e4c3
("Linux-2.6.12-rc2")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
e73a29554f
commit
613fd02620
@@ -2678,18 +2678,18 @@ static inline int sk_get_wmem0(const struct sock *sk, const struct proto *proto)
|
||||
{
|
||||
/* Does this proto have per netns sysctl_wmem ? */
|
||||
if (proto->sysctl_wmem_offset)
|
||||
return *(int *)((void *)sock_net(sk) + proto->sysctl_wmem_offset);
|
||||
return READ_ONCE(*(int *)((void *)sock_net(sk) + proto->sysctl_wmem_offset));
|
||||
|
||||
return *proto->sysctl_wmem;
|
||||
return READ_ONCE(*proto->sysctl_wmem);
|
||||
}
|
||||
|
||||
static inline int sk_get_rmem0(const struct sock *sk, const struct proto *proto)
|
||||
{
|
||||
/* Does this proto have per netns sysctl_rmem ? */
|
||||
if (proto->sysctl_rmem_offset)
|
||||
return *(int *)((void *)sock_net(sk) + proto->sysctl_rmem_offset);
|
||||
return READ_ONCE(*(int *)((void *)sock_net(sk) + proto->sysctl_rmem_offset));
|
||||
|
||||
return *proto->sysctl_rmem;
|
||||
return READ_ONCE(*proto->sysctl_rmem);
|
||||
}
|
||||
|
||||
/* Default TCP Small queue budget is ~1 ms of data (1sec >> 10)
|
||||
|
Reference in New Issue
Block a user