Commit 3e063114 authored by Toke Høiland-Jørgensen's avatar Toke Høiland-Jørgensen Committed by Wang Liang
Browse files

wifi: ath9k_htc: Use __skb_set_length() for resetting urb before resubmit

stable inclusion
from stable-v5.10.227
commit b02eb7c86ff2ef1411c3095ec8a52b13f68db04f
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IAYRA2
CVE: CVE-2024-49938

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=b02eb7c86ff2ef1411c3095ec8a52b13f68db04f



--------------------------------

[ Upstream commit 94745807f3ebd379f23865e6dab196f220664179 ]

Syzbot points out that skb_trim() has a sanity check on the existing length of
the skb, which can be uninitialised in some error paths. The intent here is
clearly just to reset the length to zero before resubmitting, so switch to
calling __skb_set_length(skb, 0) directly. In addition, __skb_set_length()
already contains a call to skb_reset_tail_pointer(), so remove the redundant
call.

The syzbot report came from ath9k_hif_usb_reg_in_cb(), but there's a similar
usage of skb_trim() in ath9k_hif_usb_rx_cb(), change both while we're at it.

Reported-by: default avatar <syzbot+98afa303be379af6cdb2@syzkaller.appspotmail.com>
Signed-off-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: default avatarKalle Valo <quic_kvalo@quicinc.com>
Link: https://patch.msgid.link/20240812142447.12328-1-toke@toke.dk


Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarWang Liang <wangliang74@huawei.com>
parent 1a47bbfa
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -718,8 +718,7 @@ static void ath9k_hif_usb_rx_cb(struct urb *urb)
	}

resubmit:
	skb_reset_tail_pointer(skb);
	skb_trim(skb, 0);
	__skb_set_length(skb, 0);

	usb_anchor_urb(urb, &hif_dev->rx_submitted);
	ret = usb_submit_urb(urb, GFP_ATOMIC);
@@ -756,8 +755,7 @@ static void ath9k_hif_usb_reg_in_cb(struct urb *urb)
	case -ESHUTDOWN:
		goto free_skb;
	default:
		skb_reset_tail_pointer(skb);
		skb_trim(skb, 0);
		__skb_set_length(skb, 0);

		goto resubmit;
	}