From: Marc Kleine-Budde <mkl@pengutronix.de>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, linux-can@vger.kernel.org,
kernel@pengutronix.de,
Ziyang Xuan <william.xuanziyang@huawei.com>,
Max Staudt <max@enpas.org>,
stable@vger.kernel.org, Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [PATCH net 1/8] can: can327: can327_feed_frame_to_netdev(): fix potential skb leak when netdev is down
Date: Thu, 24 Nov 2022 20:57:01 +0100 [thread overview]
Message-ID: <20221124195708.1473369-2-mkl@pengutronix.de> (raw)
In-Reply-To: <20221124195708.1473369-1-mkl@pengutronix.de>
From: Ziyang Xuan <william.xuanziyang@huawei.com>
In can327_feed_frame_to_netdev(), it did not free the skb when netdev
is down, and all callers of can327_feed_frame_to_netdev() did not free
allocated skb too. That would trigger skb leak.
Fix it by adding kfree_skb() in can327_feed_frame_to_netdev() when netdev
is down. Not tested, just compiled.
Fixes: 43da2f07622f ("can: can327: CAN/ldisc driver for ELM327 based OBD-II adapters")
Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
Link: https://lore.kernel.org/all/20221110061437.411525-1-william.xuanziyang@huawei.com
Reviewed-by: Max Staudt <max@enpas.org>
Cc: stable@vger.kernel.org
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/can327.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/can/can327.c b/drivers/net/can/can327.c
index 094197780776..ed3d0b8989a0 100644
--- a/drivers/net/can/can327.c
+++ b/drivers/net/can/can327.c
@@ -263,8 +263,10 @@ static void can327_feed_frame_to_netdev(struct can327 *elm, struct sk_buff *skb)
{
lockdep_assert_held(&elm->lock);
- if (!netif_running(elm->dev))
+ if (!netif_running(elm->dev)) {
+ kfree_skb(skb);
return;
+ }
/* Queue for NAPI pickup.
* rx-offload will update stats and LEDs for us.
base-commit: ad17c2a3f11b0f6b122e7842d8f7d9a5fcc7ac63
--
2.35.1
next prev parent reply other threads:[~2022-11-24 19:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-24 19:57 [PATCH net 0/8] pull-request: can 2022-11-24 Marc Kleine-Budde
2022-11-24 19:57 ` Marc Kleine-Budde [this message]
2022-11-25 8:00 ` [PATCH net 1/8] can: can327: can327_feed_frame_to_netdev(): fix potential skb leak when netdev is down patchwork-bot+netdevbpf
2022-11-24 19:57 ` [PATCH net 2/8] can: sja1000: fix size of OCR_MODE_MASK define Marc Kleine-Budde
2022-11-24 19:57 ` [PATCH net 3/8] can: sja1000_isa: sja1000_isa_probe(): add missing free_sja1000dev() Marc Kleine-Budde
2022-11-24 19:57 ` [PATCH net 4/8] can: cc770: cc770_isa_probe(): add missing free_cc770dev() Marc Kleine-Budde
2022-11-24 19:57 ` [PATCH net 5/8] can: etas_es58x: es58x_init_netdev(): free netdev when register_candev() Marc Kleine-Budde
2022-11-24 19:57 ` [PATCH net 6/8] can: m_can: pci: add missing m_can_class_free_dev() in probe/remove methods Marc Kleine-Budde
2022-11-24 19:57 ` [PATCH net 7/8] can: m_can: Add check for devm_clk_get Marc Kleine-Budde
2022-11-24 19:57 ` [PATCH net 8/8] can: mcba_usb: Fix termination command argument Marc Kleine-Budde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221124195708.1473369-2-mkl@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=davem@davemloft.net \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=max@enpas.org \
--cc=netdev@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=william.xuanziyang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).