diff options
author | Dan Carpenter <dan.carpenter@linaro.org> | 2023-10-27 15:19:01 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-11-20 11:59:34 +0100 |
commit | d103fb6726904e353b4773188ee3d3acb4078363 (patch) | |
tree | c3b3c41b3531ab2938ed4043e2d40f5984ac5b07 /net/hsr | |
parent | ff5cb6a4f0c6d7fbdc84858323fb4b7af32cfd79 (diff) | |
download | linux-stable-d103fb6726904e353b4773188ee3d3acb4078363.tar.gz linux-stable-d103fb6726904e353b4773188ee3d3acb4078363.tar.bz2 linux-stable-d103fb6726904e353b4773188ee3d3acb4078363.zip |
hsr: Prevent use after free in prp_create_tagged_frame()
[ 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: 451d8123f897 ("net: prp: add packet handling support")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Acked-by: Paolo Abeni <pabeni@redhat.com>
Link: https://lore.kernel.org/r/57af1f28-7f57-4a96-bcd3-b7a0f2340845@moroto.mountain
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/hsr')
-rw-r--r-- | net/hsr/hsr_forward.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c index b71dab630a87..80cdc6f6b34c 100644 --- a/net/hsr/hsr_forward.c +++ b/net/hsr/hsr_forward.c @@ -342,9 +342,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, |