Skip to contentSkip to conversation

tcp: do not overshoot window_clamp in tcp_rcv_space_adjust()

PATCH In review Guenter Roeck 2 participants 3 messages Jun 18, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tcp: do not overshoot window_clamp in tcp_rcv_space_adjust()

From: Eric Dumazet <[email protected]>

commit 02db55718d53f9d426cee504c27fb768e9ed4ffe upstream.

While rcvbuf is properly clamped by tcp_rmem[2], rcvwin is left to a potentially too big value.

It has no serious effect, since :
1) tcp_grow_window() has very strict checks.
2) window_clamp can be mangled by user space to any value anyway.

tcp_init_buffer_space() and companions use tcp_full_space(), we use tcp_win_from_space() to avoid reloading sk->sk_rcvbuf

---
 net/ipv4/tcp_input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_input.c +1 -1
index 125b49c166a4..f0caff3139ed 100644
@@ -647,7 +647,7 @@ void tcp_rcv_space_adjust(struct sock *sk)
 			sk->sk_rcvbuf = rcvbuf;
 
 			/* Make the window clamp follow along.  */
-			tp->window_clamp = rcvwin;
+			tp->window_clamp = tcp_win_from_space(rcvbuf);
 		}
 	}
 	tp->rcvq_space.space = copied;
Signature · 1 line
2.7.4
#1 lore raw

This is supposed to be a backport for v4.14.y and older. Sorry for the confusion.

Guenter

Quoted 38 lines · Guenter Roeck

From: Eric Dumazet <[email protected]>

commit 02db55718d53f9d426cee504c27fb768e9ed4ffe upstream.

While rcvbuf is properly clamped by tcp_rmem[2], rcvwin is left to a potentially too big value.

It has no serious effect, since :
1) tcp_grow_window() has very strict checks.
2) window_clamp can be mangled by user space to any value anyway.

tcp_init_buffer_space() and companions use tcp_full_space(), we use tcp_win_from_space() to avoid reloading sk->sk_rcvbuf

---
  net/ipv4/tcp_input.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_input.c +1 -1
index 125b49c166a4..f0caff3139ed 100644
@@ -647,7 +647,7 @@ void tcp_rcv_space_adjust(struct sock *sk)
  			sk->sk_rcvbuf = rcvbuf;
 
  			/* Make the window clamp follow along.  */
-			tp->window_clamp = rcvwin;
+			tp->window_clamp = tcp_win_from_space(rcvbuf);
  		}
  	}
  	tp->rcvq_space.space = copied;
maintainer
#2 lore raw
Quoted 1 line · Guenter Roeck

This is supposed to be a backport for v4.14.y and older. Sorry for the confusion.

Not a problem, thanks for the patch, now queued up.

greg k-h