linux-kernel.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: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Michael Grzeschik" <m.grzeschik@pengutronix.de>,
	"David S . Miller" <davem@davemloft.net>,
	"Sasha Levin" <sashal@kernel.org>,
	netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 4.19 28/43] arcnet: provide a buffer big enough to actually receive packets
Date: Tue,  1 Oct 2019 12:42:56 -0400	[thread overview]
Message-ID: <20191001164311.15993-28-sashal@kernel.org> (raw)
In-Reply-To: <20191001164311.15993-1-sashal@kernel.org>

From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

[ Upstream commit 02a07046834e64970f3bcd87a422ac2b0adb80de ]

struct archdr is only big enough to hold the header of various types of
arcnet packets. So to provide enough space to hold the data read from
hardware provide a buffer large enough to hold a packet with maximal
size.

The problem was noticed by the stack protector which makes the kernel
oops.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/arcnet/arcnet.c | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 8459115d9d4e5..553776cc1d29d 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -1063,31 +1063,34 @@ EXPORT_SYMBOL(arcnet_interrupt);
 static void arcnet_rx(struct net_device *dev, int bufnum)
 {
 	struct arcnet_local *lp = netdev_priv(dev);
-	struct archdr pkt;
+	union {
+		struct archdr pkt;
+		char buf[512];
+	} rxdata;
 	struct arc_rfc1201 *soft;
 	int length, ofs;
 
-	soft = &pkt.soft.rfc1201;
+	soft = &rxdata.pkt.soft.rfc1201;
 
-	lp->hw.copy_from_card(dev, bufnum, 0, &pkt, ARC_HDR_SIZE);
-	if (pkt.hard.offset[0]) {
-		ofs = pkt.hard.offset[0];
+	lp->hw.copy_from_card(dev, bufnum, 0, &rxdata.pkt, ARC_HDR_SIZE);
+	if (rxdata.pkt.hard.offset[0]) {
+		ofs = rxdata.pkt.hard.offset[0];
 		length = 256 - ofs;
 	} else {
-		ofs = pkt.hard.offset[1];
+		ofs = rxdata.pkt.hard.offset[1];
 		length = 512 - ofs;
 	}
 
 	/* get the full header, if possible */
-	if (sizeof(pkt.soft) <= length) {
-		lp->hw.copy_from_card(dev, bufnum, ofs, soft, sizeof(pkt.soft));
+	if (sizeof(rxdata.pkt.soft) <= length) {
+		lp->hw.copy_from_card(dev, bufnum, ofs, soft, sizeof(rxdata.pkt.soft));
 	} else {
-		memset(&pkt.soft, 0, sizeof(pkt.soft));
+		memset(&rxdata.pkt.soft, 0, sizeof(rxdata.pkt.soft));
 		lp->hw.copy_from_card(dev, bufnum, ofs, soft, length);
 	}
 
 	arc_printk(D_DURING, dev, "Buffer #%d: received packet from %02Xh to %02Xh (%d+4 bytes)\n",
-		   bufnum, pkt.hard.source, pkt.hard.dest, length);
+		   bufnum, rxdata.pkt.hard.source, rxdata.pkt.hard.dest, length);
 
 	dev->stats.rx_packets++;
 	dev->stats.rx_bytes += length + ARC_HDR_SIZE;
@@ -1096,13 +1099,13 @@ static void arcnet_rx(struct net_device *dev, int bufnum)
 	if (arc_proto_map[soft->proto]->is_ip) {
 		if (BUGLVL(D_PROTO)) {
 			struct ArcProto
-			*oldp = arc_proto_map[lp->default_proto[pkt.hard.source]],
+			*oldp = arc_proto_map[lp->default_proto[rxdata.pkt.hard.source]],
 			*newp = arc_proto_map[soft->proto];
 
 			if (oldp != newp) {
 				arc_printk(D_PROTO, dev,
 					   "got protocol %02Xh; encap for host %02Xh is now '%c' (was '%c')\n",
-					   soft->proto, pkt.hard.source,
+					   soft->proto, rxdata.pkt.hard.source,
 					   newp->suffix, oldp->suffix);
 			}
 		}
@@ -1111,10 +1114,10 @@ static void arcnet_rx(struct net_device *dev, int bufnum)
 		lp->default_proto[0] = soft->proto;
 
 		/* in striking contrast, the following isn't a hack. */
-		lp->default_proto[pkt.hard.source] = soft->proto;
+		lp->default_proto[rxdata.pkt.hard.source] = soft->proto;
 	}
 	/* call the protocol-specific receiver. */
-	arc_proto_map[soft->proto]->rx(dev, bufnum, &pkt, length);
+	arc_proto_map[soft->proto]->rx(dev, bufnum, &rxdata.pkt, length);
 }
 
 static void null_rx(struct net_device *dev, int bufnum,
-- 
2.20.1


  parent reply	other threads:[~2019-10-01 16:51 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-01 16:42 [PATCH AUTOSEL 4.19 01/43] ima: always return negative code for error Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 02/43] ima: fix freeing ongoing ahash_request Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 03/43] fs: nfs: Fix possible null-pointer dereferences in encode_attrs() Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 04/43] 9p: Transport error uninitialized Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 05/43] 9p: avoid attaching writeback_fid on mmap with type PRIVATE Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 06/43] 9p/cache.c: Fix memory leak in v9fs_cache_session_get_cookie Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 07/43] xen/pci: reserve MCFG areas earlier Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 08/43] ceph: fix directories inode i_blkbits initialization Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 09/43] ceph: reconnect connection if session hang in opening state Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 10/43] rbd: fix response length parameter for encoded strings Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 11/43] watchdog: aspeed: Add support for AST2600 Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 12/43] netfilter: nf_tables: allow lookups in dynamic sets Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 13/43] drm/amdgpu: Fix KFD-related kernel oops on Hawaii Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 14/43] drm/amdgpu: Check for valid number of registers to read Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 15/43] pNFS: Ensure we do clear the return-on-close layout stateid on fatal errors Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 16/43] net/sched: act_sample: don't push mac header on ip6gre ingress Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 17/43] pwm: stm32-lp: Add check in case requested period cannot be achieved Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 18/43] cdc_ncm: fix divide-by-zero caused by invalid wMaxPacketSize Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 19/43] usbnet: ignore endpoints with " Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 20/43] net/phy: fix DP83865 10 Mbps HDX loopback disable function Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 21/43] net_sched: add max len check for TCA_KIND Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 22/43] x86/purgatory: Disable the stackleak GCC plugin for the purgatory Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 23/43] ntb: point to right memory window index Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 24/43] thermal: Fix use-after-free when unregistering thermal zone device Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 25/43] thermal_hwmon: Sanitize thermal_zone type Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 26/43] libnvdimm/region: Initialize bad block for volatile namespaces Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 27/43] fuse: fix memleak in cuse_channel_open Sasha Levin
2019-10-01 16:42 ` Sasha Levin [this message]
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 29/43] libnvdimm/nfit_test: Fix acpi_handle redefinition Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 30/43] ppp: Fix memory leak in ppp_write Sasha Levin
2019-10-01 16:42 ` [PATCH AUTOSEL 4.19 31/43] sched/membarrier: Call sync_core only before usermode for same mm Sasha Levin
2019-10-01 16:43 ` [PATCH AUTOSEL 4.19 32/43] sched/membarrier: Fix private expedited registration check Sasha Levin
2019-10-01 16:43 ` [PATCH AUTOSEL 4.19 33/43] sched/core: Fix migration to invalid CPU in __set_cpus_allowed_ptr() Sasha Levin
2019-10-01 16:43 ` [PATCH AUTOSEL 4.19 34/43] perf build: Add detection of java-11-openjdk-devel package Sasha Levin
2019-10-01 16:43 ` [PATCH AUTOSEL 4.19 35/43] kernel/elfcore.c: include proper prototypes Sasha Levin
2019-10-01 16:43 ` [PATCH AUTOSEL 4.19 36/43] kexec: bail out upon SIGKILL when allocating memory Sasha Levin
2019-10-01 16:43 ` [PATCH AUTOSEL 4.19 37/43] macsec: drop skb sk before calling gro_cells_receive Sasha Levin
2019-10-01 16:43 ` [PATCH AUTOSEL 4.19 38/43] perf unwind: Fix libunwind build failure on i386 systems Sasha Levin
2019-10-01 16:43 ` [PATCH AUTOSEL 4.19 39/43] nfp: flower: fix memory leak in nfp_flower_spawn_vnic_reprs Sasha Levin
2019-10-01 16:43 ` [PATCH AUTOSEL 4.19 40/43] nfp: flower: prevent memory leak in nfp_flower_spawn_phy_reprs Sasha Levin
2019-10-01 16:43 ` [PATCH AUTOSEL 4.19 41/43] drm/radeon: Bail earlier when radeon.cik_/si_support=0 is passed Sasha Levin
2019-10-01 16:43 ` [PATCH AUTOSEL 4.19 42/43] usbnet: sanity checking of packet sizes and device mtu Sasha Levin
2019-10-01 16:43 ` [PATCH AUTOSEL 4.19 43/43] sch_netem: fix a divide by zero in tabledist() Sasha Levin

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=20191001164311.15993-28-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.grzeschik@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --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).