Skip to content

Commit ed42989

Browse files
congwangkuba-moo
authored andcommitted
tipc: fix the skb_unshare() in tipc_buf_append()
skb_unshare() drops a reference count on the old skb unconditionally, so in the failure case, we end up freeing the skb twice here. And because the skb is allocated in fclone and cloned by caller tipc_msg_reassemble(), the consequence is actually freeing the original skb too, thus triggered the UAF by syzbot. Fix this by replacing this skb_unshare() with skb_cloned()+skb_copy(). Fixes: ff48b62 ("tipc: use skb_unshare() instead in tipc_buf_append()") Reported-and-tested-by: syzbot+e96a7ba46281824cc46a@syzkaller.appspotmail.com Cc: Jon Maloy <jmaloy@redhat.com> Cc: Ying Xue <ying.xue@windriver.com> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Reviewed-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 923527d commit ed42989

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎net/tipc/msg.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf)
150150
if (fragid == FIRST_FRAGMENT) {
151151
if (unlikely(head))
152152
goto err;
153-
frag = skb_unshare(frag, GFP_ATOMIC);
153+
if (skb_cloned(frag))
154+
frag = skb_copy(frag, GFP_ATOMIC);
154155
if (unlikely(!frag))
155156
goto err;
156157
head = *headbuf = frag;

0 commit comments

Comments
 (0)