netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Jerry Ray <jerry.ray@microchip.com>,
	"David S . Miller" <davem@davemloft.net>,
	Sasha Levin <sashal@kernel.org>,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	u.kleine-koenig@pengutronix.de, mkl@pengutronix.de,
	miquel.raynal@bootlin.com, broonie@kernel.org,
	bigeasy@linutronix.de, netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 5.10 07/34] micrel: ksz8851: fixes struct pointer issue
Date: Sun,  9 Oct 2022 18:21:01 -0400	[thread overview]
Message-ID: <20221009222129.1218277-7-sashal@kernel.org> (raw)
In-Reply-To: <20221009222129.1218277-1-sashal@kernel.org>

From: Jerry Ray <jerry.ray@microchip.com>

[ Upstream commit fef5de753ff01887cfa50990532c3890fccb9338 ]

Issue found during code review. This bug has no impact as long as the
ks8851_net structure is the first element of the ks8851_net_spi structure.
As long as the offset to the ks8851_net struct is zero, the container_of()
macro is subtracting 0 and therefore no damage done. But if the
ks8851_net_spi struct is ever modified such that the ks8851_net struct
within it is no longer the first element of the struct, then the bug would
manifest itself and cause problems.

struct ks8851_net is contained within ks8851_net_spi.
ks is contained within kss.
kss is the priv_data of the netdev structure.

Signed-off-by: Jerry Ray <jerry.ray@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/micrel/ks8851_spi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/micrel/ks8851_spi.c b/drivers/net/ethernet/micrel/ks8851_spi.c
index 4ec7f1615977..8327e7f30476 100644
--- a/drivers/net/ethernet/micrel/ks8851_spi.c
+++ b/drivers/net/ethernet/micrel/ks8851_spi.c
@@ -415,7 +415,8 @@ static int ks8851_probe_spi(struct spi_device *spi)
 
 	spi->bits_per_word = 8;
 
-	ks = netdev_priv(netdev);
+	kss = netdev_priv(netdev);
+	ks = &kss->ks8851;
 
 	ks->lock = ks8851_lock_spi;
 	ks->unlock = ks8851_unlock_spi;
@@ -435,8 +436,6 @@ static int ks8851_probe_spi(struct spi_device *spi)
 		 IRQ_RXPSI)	/* RX process stop */
 	ks->rc_ier = STD_IRQ;
 
-	kss = to_ks8851_spi(ks);
-
 	kss->spidev = spi;
 	mutex_init(&kss->lock);
 	INIT_WORK(&kss->tx_work, ks8851_tx_work);
-- 
2.35.1


  parent reply	other threads:[~2022-10-09 22:42 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-09 22:20 [PATCH AUTOSEL 5.10 01/34] wifi: rtw88: phy: fix warning of possible buffer overflow Sasha Levin
2022-10-09 22:20 ` [PATCH AUTOSEL 5.10 02/34] wifi: brcmfmac: fix invalid address access when enabling SCAN log level Sasha Levin
2022-10-09 22:20 ` [PATCH AUTOSEL 5.10 04/34] openvswitch: Fix double reporting of drops in dropwatch Sasha Levin
2022-10-09 22:20 ` [PATCH AUTOSEL 5.10 05/34] openvswitch: Fix overreporting " Sasha Levin
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 06/34] tcp: annotate data-race around tcp_md5sig_pool_populated Sasha Levin
2022-10-09 22:21 ` Sasha Levin [this message]
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 08/34] wifi: ath9k: avoid uninit memory read in ath9k_htc_rx_msg() Sasha Levin
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 09/34] xfrm: Update ipcomp_scratches with NULL when freed Sasha Levin
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 10/34] net: xscale: Fix return type for implementation of ndo_start_xmit Sasha Levin
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 11/34] net: lantiq_etop: " Sasha Levin
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 12/34] net: ftmac100: fix endianness-related issues from 'sparse' Sasha Levin
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 13/34] wifi: brcmfmac: fix use-after-free bug in brcmf_netdev_start_xmit() Sasha Levin
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 15/34] Bluetooth: L2CAP: initialize delayed works at l2cap_chan_create() Sasha Levin
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 16/34] net: davicom: Fix return type of dm9000_start_xmit Sasha Levin
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 17/34] net: ethernet: ti: davinci_emac: Fix return type of emac_dev_xmit Sasha Levin
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 18/34] net: korina: Fix return type of korina_send_packet Sasha Levin
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 19/34] net: sfp: re-implement soft state polling setup Sasha Levin
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 20/34] net: sfp: move quirk handling into sfp.c Sasha Levin
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 21/34] net: sfp: move Alcatel Lucent 3FE46541AA fixup Sasha Levin
2022-10-18  9:43   ` Pavel Machek
2022-10-18 10:24     ` Russell King (Oracle)
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 22/34] net/sched: taprio: taprio_dump and taprio_change are protected by rtnl_mutex Sasha Levin
2022-10-10 13:33   ` Vladimir Oltean
2022-10-18  9:44   ` Pavel Machek
2022-10-18  9:46     ` Vladimir Oltean
2022-10-18 10:03       ` Vladimir Oltean
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 23/34] Bluetooth: hci_sysfs: Fix attempting to call device_add multiple times Sasha Levin
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 24/34] wifi: ath10k: reset pointer after memory free to avoid potential use-after-free Sasha Levin
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 25/34] can: bcm: check the result of can_send() in bcm_can_tx() Sasha Levin
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 26/34] wifi: rt2x00: don't run Rt5592 IQ calibration on MT7620 Sasha Levin
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 27/34] wifi: rt2x00: set correct TX_SW_CFG1 MAC register for MT7620 Sasha Levin
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 28/34] wifi: rt2x00: set VGC gain for both chains of MT7620 Sasha Levin
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 29/34] wifi: rt2x00: set SoC wmac clock register Sasha Levin
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 30/34] wifi: rt2x00: correctly set BBP register 86 for MT7620 Sasha Levin
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 31/34] net: If sock is dead don't access sock's sk_wq in sk_stream_wait_memory Sasha Levin
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 32/34] Bluetooth: L2CAP: Fix user-after-free Sasha Levin
2022-10-09 22:21 ` [PATCH AUTOSEL 5.10 34/34] r8152: Rate limit overflow messages Sasha Levin
2022-10-18  9:39 ` [PATCH AUTOSEL 5.10 01/34] wifi: rtw88: phy: fix warning of possible buffer overflow Pavel Machek

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=20221009222129.1218277-7-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=bigeasy@linutronix.de \
    --cc=broonie@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jerry.ray@microchip.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=u.kleine-koenig@pengutronix.de \
    /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).