Skip to content

Commit 4951ffa

Browse files
lxingregkh
authored andcommitted
tipc: do not write skb_shinfo frags when doing decrytion
[ Upstream commit 3cf4375 ] One skb's skb_shinfo frags are not writable, and they can be shared with other skbs' like by pskb_copy(). To write the frags may cause other skb's data crash. So before doing en/decryption, skb_cow_data() should always be called for a cloned or nonlinear skb if req dst is using the same sg as req src. While at it, the likely branch can be removed, as it will be covered by skb_cow_data(). Note that esp_input() has the same issue, and I will fix it in another patch. tipc_aead_encrypt() doesn't have this issue, as it only processes linear data in the unlikely branch. Fixes: fc1b6d6 ("tipc: introduce TIPC encryption & authentication") Reported-by: Shuang Li <shuali@redhat.com> Signed-off-by: Xin Long <lucien.xin@gmail.com> Acked-by: Jon Maloy <jmaloy@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 7eefa0b commit 4951ffa

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

‎net/tipc/crypto.c‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -891,16 +891,10 @@ static int tipc_aead_decrypt(struct net *net, struct tipc_aead *aead,
891891
if (unlikely(!aead))
892892
return -ENOKEY;
893893

894-
/* Cow skb data if needed */
895-
if (likely(!skb_cloned(skb) &&
896-
(!skb_is_nonlinear(skb) || !skb_has_frag_list(skb)))) {
897-
nsg = 1 + skb_shinfo(skb)->nr_frags;
898-
} else {
899-
nsg = skb_cow_data(skb, 0, &unused);
900-
if (unlikely(nsg < 0)) {
901-
pr_err("RX: skb_cow_data() returned %d\n", nsg);
902-
return nsg;
903-
}
894+
nsg = skb_cow_data(skb, 0, &unused);
895+
if (unlikely(nsg < 0)) {
896+
pr_err("RX: skb_cow_data() returned %d\n", nsg);
897+
return nsg;
904898
}
905899

906900
/* Allocate memory for the AEAD operation */

0 commit comments

Comments
 (0)