Commit 361fc7ad authored by Dan Carpenter's avatar Dan Carpenter Committed by Yue Haibing
Browse files

hsr: Prevent use after free in prp_create_tagged_frame()

stable inclusion
from stable-v5.10.201
commit ddf4e04e946aaa6c458b8b6829617cc44af2bffd
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I9DFT4
CVE: CVE-2023-52846

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



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

[ Upstream commit 876f8ab52363f649bcc74072157dfd7adfbabc0d ]

The prp_fill_rct() function can fail.  In that situation, it frees the
skb and returns NULL.  Meanwhile on the success path, it returns the
original skb.  So it's straight forward to fix bug by using the returned
value.

Fixes: 451d8123 ("net: prp: add packet handling support")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Acked-by: default avatarPaolo Abeni <pabeni@redhat.com>
Link: https://lore.kernel.org/r/57af1f28-7f57-4a96-bcd3-b7a0f2340845@moroto.mountain


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarsanglipeng <sanglipeng1@jd.com>
Signed-off-by: default avatarYue Haibing <yuehaibing@huawei.com>
parent 9901ab29
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -294,9 +294,7 @@ struct sk_buff *prp_create_tagged_frame(struct hsr_frame_info *frame,
	skb = skb_copy_expand(frame->skb_std, 0,
			      skb_tailroom(frame->skb_std) + HSR_HLEN,
			      GFP_ATOMIC);
	prp_fill_rct(skb, frame, port);

	return skb;
	return prp_fill_rct(skb, frame, port);
}

static void hsr_deliver_master(struct sk_buff *skb, struct net_device *dev,