* [PATCH] net: tulip: xircom_cb: drop runt frames before skb copy
@ 2026-07-31 18:33 Pablo Vallespín Aranguren
2026-07-31 19:26 ` David Laight
0 siblings, 1 reply; 3+ messages in thread
From: Pablo Vallespín Aranguren @ 2026-07-31 18:33 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, open list:TULIP NETWORK DRIVERS,
open list:TULIP NETWORK DRIVERS, open list
Cc: Greg KH
investigate_read_descriptor() takes the 11-bit packet length straight
from the device-written descriptor and subtracts 4 for the CRC. A
length below 4 underflows pkt_len to a negative value, which is then
passed to skb_put_data() as a huge unsigned length and corrupts memory
past the end of the freshly allocated skb.
Drop the frame as a length error if pkt_len is negative after CRC
removal.
Signed-off-by: Pablo Vallespín Aranguren <pablopva014@gmail.com>
Assisted-by: gkh_clanker_t1000
---
drivers/net/ethernet/dec/tulip/xircom_cb.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/ethernet/dec/tulip/xircom_cb.c b/drivers/net/ethernet/dec/tulip/xircom_cb.c
index e5d2ede13845..62c64da1c8fa 100644
--- a/drivers/net/ethernet/dec/tulip/xircom_cb.c
+++ b/drivers/net/ethernet/dec/tulip/xircom_cb.c
@@ -1110,6 +1110,11 @@ investigate_read_descriptor(struct net_device *dev, struct xircom_private *card,
/* minus 4, we don't want the CRC */
struct sk_buff *skb;
+ if (pkt_len < 0) {
+ dev->stats.rx_length_errors++;
+ goto out;
+ }
+
if (pkt_len > 1518) {
netdev_err(dev, "Packet length %i is bogus\n", pkt_len);
pkt_len = 1518;
--
2.55.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] net: tulip: xircom_cb: drop runt frames before skb copy
2026-07-31 18:33 [PATCH] net: tulip: xircom_cb: drop runt frames before skb copy Pablo Vallespín Aranguren
@ 2026-07-31 19:26 ` David Laight
2026-07-31 20:56 ` Pablo Vallespín Aranguren
0 siblings, 1 reply; 3+ messages in thread
From: David Laight @ 2026-07-31 19:26 UTC (permalink / raw)
To: Pablo Vallespín Aranguren
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, open list:TULIP NETWORK DRIVERS,
open list:TULIP NETWORK DRIVERS, open list, Greg KH
On Fri, 31 Jul 2026 20:33:34 +0200
Pablo Vallespín Aranguren <pablopva014@gmail.com> wrote:
> investigate_read_descriptor() takes the 11-bit packet length straight
> from the device-written descriptor and subtracts 4 for the CRC. A
> length below 4 underflows pkt_len to a negative value, which is then
> passed to skb_put_data() as a huge unsigned length and corrupts memory
> past the end of the freshly allocated skb.
Have you checked that that hardware can actually set a short value?
I'd expect that packets shorter than 64 bytes (including the crc) are
dropped as 'runts' and probably don't even use a ring entry.
Of course, if you think the device might lie all bets are off.
(Without an iommu is can write anywhere in host memory...)
David
>
> Drop the frame as a length error if pkt_len is negative after CRC
> removal.
>
> Signed-off-by: Pablo Vallespín Aranguren <pablopva014@gmail.com>
> Assisted-by: gkh_clanker_t1000
> ---
> drivers/net/ethernet/dec/tulip/xircom_cb.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/net/ethernet/dec/tulip/xircom_cb.c b/drivers/net/ethernet/dec/tulip/xircom_cb.c
> index e5d2ede13845..62c64da1c8fa 100644
> --- a/drivers/net/ethernet/dec/tulip/xircom_cb.c
> +++ b/drivers/net/ethernet/dec/tulip/xircom_cb.c
> @@ -1110,6 +1110,11 @@ investigate_read_descriptor(struct net_device *dev, struct xircom_private *card,
> /* minus 4, we don't want the CRC */
> struct sk_buff *skb;
>
> + if (pkt_len < 0) {
> + dev->stats.rx_length_errors++;
> + goto out;
> + }
> +
> if (pkt_len > 1518) {
> netdev_err(dev, "Packet length %i is bogus\n", pkt_len);
> pkt_len = 1518;
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] net: tulip: xircom_cb: drop runt frames before skb copy
2026-07-31 19:26 ` David Laight
@ 2026-07-31 20:56 ` Pablo Vallespín Aranguren
0 siblings, 0 replies; 3+ messages in thread
From: Pablo Vallespín Aranguren @ 2026-07-31 20:56 UTC (permalink / raw)
To: David Laight
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, open list:TULIP NETWORK DRIVERS,
open list:TULIP NETWORK DRIVERS, open list, Greg KH
On Fri, Jul 31, 2026 at 08:26:29PM +0100, David Laight wrote:
> On Fri, 31 Jul 2026 20:33:34 +0200
> Pablo Vallespín Aranguren <pablopva014@gmail.com> wrote:
>
> Have you checked that that hardware can actually set a short value?
> I'd expect that packets shorter than 64 bytes (including the crc) are
> dropped as 'runts' and probably don't even use a ring entry.
I haven't verified how the real Xircom firmware handles runt frames (I
don't own this hardware). I tested with Qemu's emulated NIC, the device
itself does validate and reject negative-size values before sending them
to the driver.
> Of course, if you think the device might lie all bets are off.
> (Without an iommu is can write anywhere in host memory...)
I took into account that the hardware could glitch or a misbehaving/fake
card could be used. I modified the emulated NIC to mimic this behaviour,
and given that the driver does not perform a check on its own (to
validate that pkt_len is not negative) it does lead to a kernel panic.
Best,
Pablo
> > Signed-off-by: Pablo Vallespín Aranguren <pablopva014@gmail.com>
> > Assisted-by: gkh_clanker_t1000
> > ---
> > drivers/net/ethernet/dec/tulip/xircom_cb.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/dec/tulip/xircom_cb.c b/drivers/net/ethernet/dec/tulip/xircom_cb.c
> > index e5d2ede13845..62c64da1c8fa 100644
> > --- a/drivers/net/ethernet/dec/tulip/xircom_cb.c
> > +++ b/drivers/net/ethernet/dec/tulip/xircom_cb.c
> > @@ -1110,6 +1110,11 @@ investigate_read_descriptor(struct net_device *dev, struct xircom_private *card,
> > /* minus 4, we don't want the CRC */
> > struct sk_buff *skb;
> >
> > + if (pkt_len < 0) {
> > + dev->stats.rx_length_errors++;
> > + goto out;
> > + }
> > +
> > if (pkt_len > 1518) {
> > netdev_err(dev, "Packet length %i is bogus\n", pkt_len);
> > pkt_len = 1518;
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-31 20:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-31 18:33 [PATCH] net: tulip: xircom_cb: drop runt frames before skb copy Pablo Vallespín Aranguren
2026-07-31 19:26 ` David Laight
2026-07-31 20:56 ` Pablo Vallespín Aranguren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox