]> git.itanic.dy.fi Git - linux-stable/commit
tipc: do not write skb_shinfo frags when doing decrytion
authorXin Long <lucien.xin@gmail.com>
Fri, 23 Jul 2021 22:46:01 +0000 (18:46 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Aug 2021 10:46:43 +0000 (12:46 +0200)
commit4951ffa3fac8892949a09b630191ff12f35f4b72
treeca42d6c8d427d99084574df1eeb632685998d621
parent7eefa0b74f3e55dec85edfe5f5270c6f8b598155
tipc: do not write skb_shinfo frags when doing decrytion

[ Upstream commit 3cf4375a090473d240281a0d2b04a3a5aaeac34b ]

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: fc1b6d6de220 ("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>
net/tipc/crypto.c