* [PATCH net-next] tcp: fix signed/unsigned comparison
@ 2022-04-17 17:10 Eric Dumazet
2022-04-17 18:24 ` Andreas Schwab
0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2022-04-17 17:10 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: netdev, Eric Dumazet, Eric Dumazet, kernel test robot
From: Eric Dumazet <edumazet@google.com>
Kernel test robot reported:
smatch warnings:
net/ipv4/tcp_input.c:5966 tcp_rcv_established() warn: unsigned 'reason' is never less than zero.
I actually had one packetdrill failing because of this bug,
and was about to send the fix :)
Fixes: 4b506af9c5b8 ("tcp: add two drop reasons for tcp_ack()")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: kernel test robot <lkp@intel.com>
---
net/ipv4/tcp_input.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index cf2dc19bb8c766c1d33406053fd61c0873f15489..0d88984e071531fb727bdee178b0c01fd087fe5f 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -5959,7 +5959,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb)
step5:
reason = tcp_ack(sk, skb, FLAG_SLOWPATH | FLAG_UPDATE_TS_RECENT);
- if (reason < 0)
+ if ((int)reason < 0)
goto discard;
tcp_rcv_rtt_measure_ts(sk, skb);
--
2.36.0.rc0.470.gd361397f0d-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] tcp: fix signed/unsigned comparison
2022-04-17 17:10 [PATCH net-next] tcp: fix signed/unsigned comparison Eric Dumazet
@ 2022-04-17 18:24 ` Andreas Schwab
2022-04-17 18:28 ` Eric Dumazet
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2022-04-17 18:24 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, netdev,
Eric Dumazet, kernel test robot
On Apr 17 2022, Eric Dumazet wrote:
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index cf2dc19bb8c766c1d33406053fd61c0873f15489..0d88984e071531fb727bdee178b0c01fd087fe5f 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -5959,7 +5959,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb)
>
> step5:
> reason = tcp_ack(sk, skb, FLAG_SLOWPATH | FLAG_UPDATE_TS_RECENT);
> - if (reason < 0)
> + if ((int)reason < 0)
> goto discard;
>
> tcp_rcv_rtt_measure_ts(sk, skb);
Shouldn't reason be negated before passing it to tcp_drop_reason?
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] tcp: fix signed/unsigned comparison
2022-04-17 18:24 ` Andreas Schwab
@ 2022-04-17 18:28 ` Eric Dumazet
0 siblings, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2022-04-17 18:28 UTC (permalink / raw)
To: Andreas Schwab
Cc: Eric Dumazet, David S . Miller, Jakub Kicinski, Paolo Abeni,
netdev, kernel test robot
On Sun, Apr 17, 2022 at 11:24 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
>
> On Apr 17 2022, Eric Dumazet wrote:
>
> > diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> > index cf2dc19bb8c766c1d33406053fd61c0873f15489..0d88984e071531fb727bdee178b0c01fd087fe5f 100644
> > --- a/net/ipv4/tcp_input.c
> > +++ b/net/ipv4/tcp_input.c
> > @@ -5959,7 +5959,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb)
> >
> > step5:
> > reason = tcp_ack(sk, skb, FLAG_SLOWPATH | FLAG_UPDATE_TS_RECENT);
> > - if (reason < 0)
> > + if ((int)reason < 0)
> > goto discard;
> >
> > tcp_rcv_rtt_measure_ts(sk, skb);
>
> Shouldn't reason be negated before passing it to tcp_drop_reason?
Good catch, thanks !
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-17 18:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-17 17:10 [PATCH net-next] tcp: fix signed/unsigned comparison Eric Dumazet
2022-04-17 18:24 ` Andreas Schwab
2022-04-17 18:28 ` Eric Dumazet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox