Skip to contentSkip to conversation

Supicious code in chtls_io

crypto-chtls Gustavo A. R. Silva 2 participants 2 messages Apr 3, 2018 – Apr 4, 2018

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

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:

drivers/crypto/chelsio/chtls/chtls_io.c +3 -2
index 5a75be4..a949a6c 100644
@@ -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

#1 lore raw
Quoted 38 lines · 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:

drivers/crypto/chelsio/chtls/chtls_io.c +3 -2
index 5a75be4..a949a6c 100644
@@ -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);
        }
Quoted 1 line

What do you think?

Thanks for pointing, there is additional change required. I will send the patch once the window opens.

Quoted 6 lines

I can send a proper patch for this.

Thanks
--
Gustavo