* [crypto-chtls] Supicious code in chtls_io
@ 2018-04-03 21:46 Gustavo A. R. Silva
2018-04-04 10:01 ` Atul Gupta
0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2018-04-03 21:46 UTC (permalink / raw)
To: Atul Gupta, Harsh Jain, Herbert Xu, David S. Miller
Cc: linux-crypto, linux-kernel, Gustavo A. R. Silva
Hi all,
While doing some static analysis I came across the following piece of code at drivers/crypto/chelsio/chtls/chtls_io.c:1203:
1203 if (!size)
1204 break;
1205
1206 if (unlikely(ULP_SKB_CB(skb)->flags & ULPCB_FLAG_NO_APPEND))
1207 push_frames_if_head(sk);
1208 continue;
1209
1210 set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
1211 }
The issue is that in the code above, set_bit is never reached due to the 'continue' statement at line 1208.
I wonder if the actual intention of the code was something like this:
diff --git a/drivers/crypto/chelsio/chtls/chtls_io.c b/drivers/crypto/chelsio/chtls/chtls_io.c
index 5a75be4..a949a6c 100644
--- a/drivers/crypto/chelsio/chtls/chtls_io.c
+++ b/drivers/crypto/chelsio/chtls/chtls_io.c
@@ -1203,9 +1203,10 @@ int chtls_sendpage(struct sock *sk, struct page *page,
if (!size)
break;
- if (unlikely(ULP_SKB_CB(skb)->flags & ULPCB_FLAG_NO_APPEND))
+ if (unlikely(ULP_SKB_CB(skb)->flags & ULPCB_FLAG_NO_APPEND)) {
push_frames_if_head(sk);
- continue;
+ continue;
+ }
set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
}
What do you think?
I can send a proper patch for this.
Thanks
--
Gustavo
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [crypto-chtls] Supicious code in chtls_io
2018-04-03 21:46 [crypto-chtls] Supicious code in chtls_io Gustavo A. R. Silva
@ 2018-04-04 10:01 ` Atul Gupta
0 siblings, 0 replies; 2+ messages in thread
From: Atul Gupta @ 2018-04-04 10:01 UTC (permalink / raw)
To: Gustavo A. R. Silva, Harsh Jain, Herbert Xu, David S. Miller
Cc: linux-crypto, linux-kernel
On 4/4/2018 3:16 AM, Gustavo A. R. Silva wrote:
> Hi all,
>
> While doing some static analysis I came across the following piece of code at drivers/crypto/chelsio/chtls/chtls_io.c:1203:
>
> 1203 if (!size)
> 1204 break;
> 1205
> 1206 if (unlikely(ULP_SKB_CB(skb)->flags & ULPCB_FLAG_NO_APPEND))
> 1207 push_frames_if_head(sk);
> 1208 continue;
> 1209
> 1210 set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
> 1211 }
>
>
> The issue is that in the code above, set_bit is never reached due to the 'continue' statement at line 1208.
>
> I wonder if the actual intention of the code was something like this:
>
> diff --git a/drivers/crypto/chelsio/chtls/chtls_io.c b/drivers/crypto/chelsio/chtls/chtls_io.c
> index 5a75be4..a949a6c 100644
> --- a/drivers/crypto/chelsio/chtls/chtls_io.c
> +++ b/drivers/crypto/chelsio/chtls/chtls_io.c
> @@ -1203,9 +1203,10 @@ int chtls_sendpage(struct sock *sk, struct page *page,
> if (!size)
> break;
>
> - if (unlikely(ULP_SKB_CB(skb)->flags & ULPCB_FLAG_NO_APPEND))
> + if (unlikely(ULP_SKB_CB(skb)->flags & ULPCB_FLAG_NO_APPEND)) {
> push_frames_if_head(sk);
> - continue;
> + continue;
> + }
>
> set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
> }
>
>
> What do you think?
Thanks for pointing, there is additional change required. I will send the patch once the window opens.
>
> I can send a proper patch for this.
>
> Thanks
> --
> Gustavo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-04-04 10:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-03 21:46 [crypto-chtls] Supicious code in chtls_io Gustavo A. R. Silva
2018-04-04 10:01 ` Atul Gupta
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox