tcp: Fix data-races around sysctl_max_syn_backlog.
[ Upstream commit79539f3474] While reading sysctl_max_syn_backlog, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. 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:
parent
b6c189aa80
commit
b3ce32e33a
1 changed files with 4 additions and 2 deletions
|
|
@ -6847,10 +6847,12 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,
|
||||||
goto drop_and_free;
|
goto drop_and_free;
|
||||||
|
|
||||||
if (!want_cookie && !isn) {
|
if (!want_cookie && !isn) {
|
||||||
|
int max_syn_backlog = READ_ONCE(net->ipv4.sysctl_max_syn_backlog);
|
||||||
|
|
||||||
/* Kill the following clause, if you dislike this way. */
|
/* Kill the following clause, if you dislike this way. */
|
||||||
if (!syncookies &&
|
if (!syncookies &&
|
||||||
(net->ipv4.sysctl_max_syn_backlog - inet_csk_reqsk_queue_len(sk) <
|
(max_syn_backlog - inet_csk_reqsk_queue_len(sk) <
|
||||||
(net->ipv4.sysctl_max_syn_backlog >> 2)) &&
|
(max_syn_backlog >> 2)) &&
|
||||||
!tcp_peer_is_proven(req, dst)) {
|
!tcp_peer_is_proven(req, dst)) {
|
||||||
/* Without syncookies last quarter of
|
/* Without syncookies last quarter of
|
||||||
* backlog is filled with destinations,
|
* backlog is filled with destinations,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue