* [PATCH] rxrpc: sendmsg: Fix variable overwrite in rxrpc_queue_packet
@ 2017-11-27 18:02 Gustavo A. R. Silva
2017-11-27 18:55 ` David Howells
0 siblings, 1 reply; 5+ messages in thread
From: Gustavo A. R. Silva @ 2017-11-27 18:02 UTC (permalink / raw)
To: David Howells, David S. Miller; +Cc: netdev, linux-kernel, Gustavo A. R. Silva
Value assigned to variable resend_at is overwritten before it can be used.
Fix this by removing the value overwrite as it seems that this is a
leftover code.
Addresses-Coverity-ID: 1462262
Fixes: beb8e5e4f38c ("rxrpc: Express protocol timeouts in terms of RTT")
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
net/rxrpc/sendmsg.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c
index a1c53ac..42060dd 100644
--- a/net/rxrpc/sendmsg.c
+++ b/net/rxrpc/sendmsg.c
@@ -233,7 +233,6 @@ static void rxrpc_queue_packet(struct rxrpc_sock *rx, struct rxrpc_call *call,
if (resend_at < 1)
resend_at = 1;
- resend_at = now + rxrpc_resend_timeout;
WRITE_ONCE(call->resend_at, resend_at);
rxrpc_reduce_call_timer(call, resend_at, now,
rxrpc_timer_set_for_send);
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] rxrpc: sendmsg: Fix variable overwrite in rxrpc_queue_packet
2017-11-27 18:02 [PATCH] rxrpc: sendmsg: Fix variable overwrite in rxrpc_queue_packet Gustavo A. R. Silva
@ 2017-11-27 18:55 ` David Howells
2017-11-27 20:36 ` Gustavo A. R. Silva
2017-11-27 20:51 ` David Howells
0 siblings, 2 replies; 5+ messages in thread
From: David Howells @ 2017-11-27 18:55 UTC (permalink / raw)
To: Gustavo A. R. Silva; +Cc: dhowells, David S. Miller, netdev, linux-kernel
Gustavo A. R. Silva <garsilva@embeddedor.com> wrote:
> Value assigned to variable resend_at is overwritten before it can be used.
>
> Fix this by removing the value overwrite as it seems that this is a
> leftover code.
NAK. Your fix will actually cause the code to break.
The resend_at value used for the timer must be based on the current time
(ie. jiffies in this case), so we can't simply remove that line as the
previously calculated resend_at value is a duration, not a time.
What you need to do is to instead modify the line you wanted to remove to add
'now' to the previously-computed value.
David
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] rxrpc: sendmsg: Fix variable overwrite in rxrpc_queue_packet
2017-11-27 18:55 ` David Howells
@ 2017-11-27 20:36 ` Gustavo A. R. Silva
2017-11-27 20:51 ` David Howells
1 sibling, 0 replies; 5+ messages in thread
From: Gustavo A. R. Silva @ 2017-11-27 20:36 UTC (permalink / raw)
To: David Howells; +Cc: David S. Miller, netdev, linux-kernel
Hi David,
Quoting David Howells <dhowells@redhat.com>:
> Gustavo A. R. Silva <garsilva@embeddedor.com> wrote:
>
>> Value assigned to variable resend_at is overwritten before it can be used.
>>
>> Fix this by removing the value overwrite as it seems that this is a
>> leftover code.
>
> NAK. Your fix will actually cause the code to break.
>
> The resend_at value used for the timer must be based on the current time
> (ie. jiffies in this case), so we can't simply remove that line as the
> previously calculated resend_at value is a duration, not a time.
>
> What you need to do is to instead modify the line you wanted to remove to add
> 'now' to the previously-computed value.
>
You mean something like the following?
--- a/net/rxrpc/sendmsg.c
+++ b/net/rxrpc/sendmsg.c
@@ -233,7 +233,7 @@ static void rxrpc_queue_packet(struct rxrpc_sock
*rx, struct rxrpc_call *call,
if (resend_at < 1)
resend_at = 1;
- resend_at = now + rxrpc_resend_timeout;
+ resend_at += now;
WRITE_ONCE(call->resend_at, resend_at);
rxrpc_reduce_call_timer(call, resend_at, now,
rxrpc_timer_set_for_send);
Thanks
--
Gustavo A. R. Silva
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] rxrpc: sendmsg: Fix variable overwrite in rxrpc_queue_packet
2017-11-27 18:55 ` David Howells
2017-11-27 20:36 ` Gustavo A. R. Silva
@ 2017-11-27 20:51 ` David Howells
2017-11-27 21:51 ` Gustavo A. R. Silva
1 sibling, 1 reply; 5+ messages in thread
From: David Howells @ 2017-11-27 20:51 UTC (permalink / raw)
To: Gustavo A. R. Silva; +Cc: dhowells, David S. Miller, netdev, linux-kernel
Gustavo A. R. Silva <garsilva@embeddedor.com> wrote:
> - resend_at = now + rxrpc_resend_timeout;
> + resend_at += now;
Yep. :-)
David
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-11-27 21:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-27 18:02 [PATCH] rxrpc: sendmsg: Fix variable overwrite in rxrpc_queue_packet Gustavo A. R. Silva
2017-11-27 18:55 ` David Howells
2017-11-27 20:36 ` Gustavo A. R. Silva
2017-11-27 20:51 ` David Howells
2017-11-27 21:51 ` Gustavo A. R. Silva
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).