From: Andrew Lunn <andrew@lunn.ch>
To: 王明煜 <25181214217@stu.xidian.edu.cn>
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, tglx@kernel.org,
mingo@kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: Re: [PATCH] net: hamachi: fix divide by zero in hamachi_init_one
Date: Mon, 20 Apr 2026 14:46:03 +0200 [thread overview]
Message-ID: <ea469046-79dd-4a6e-905e-ea2251ff303b@lunn.ch> (raw)
In-Reply-To: <2543c18f.5194.19da8c3b8d1.Coremail.25181214217@stu.xidian.edu.cn>
So what is your security model here? How did i get the hacked card
into the machine? If i have physical access, isn't it already too
late?
As far as i can see, this devices does not load firmware. Even if it
did load firmware from /lib/firmware, i need root to put a hacked
version there.
The PacketEngine Hamachi was in use around year 2000. It needs a PCI
slot. Not PCIe but PCI. Do they even exist any more? Both the card and
a machine with a PCI slot?
Maybe, rather than fix this /0, you should look around and see if you
can find any indication this hardware is still in use, and if not,
submit a patch removing the whole driver?
> +++ b/drivers/net/ethernet/packetengines/hamachi.c
> @@ -745,6 +745,14 @@ static int hamachi_init_one(struct pci_dev *pdev,
> dev->name, chip_tbl[chip_id].name, readl(ioaddr + ChipRev),
> ioaddr, dev->dev_addr, irq);
> i = readb(ioaddr + PCIClkMeas);
> +
> + if ((i & 0x80) && !(i & 0x7f)) {
> + dev_err(&pdev->dev, "Invalid PCIClkMeas value (0x%02x), hardware untrusted.\n", i);
> + unregister_netdev(dev);
> + ret = -EIO;
> + goto err_out_unmap_rx;
> + }
> +
> printk(KERN_INFO "%s: %d-bit %d Mhz PCI bus (%d), Virtual Jumpers "
> "%2.2x, LPA %4.4x.\n",
> dev->name, readw(ioaddr + MiscStatus) & 1 ? 64 : 32,
If you do decide it is worth keeping the driver, please add another
label at the end of the function, and do the unregister_netdev there.
Could i also suggest you consider more likely scenarios. It is much
easier to produce a hacked USB dongle than a PCI card. Users plug in
USB dongles without thinking, where as few users plug in a PCI
card. You are more likely to fix security problems which affect real
systems if you look at USB devices. I would also suggest that / 0 is
not that important. But can you trigger a buffer overrun?
Andrew
---
pw-bot: cr
prev parent reply other threads:[~2026-04-20 12:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-18 12:18 [PATCH] net: hamachi: fix divide by zero in hamachi_init_one Mingyu Wang
2026-04-18 15:34 ` Andrew Lunn
2026-04-20 2:41 ` 王明煜
2026-04-20 12:46 ` Andrew Lunn [this message]
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=ea469046-79dd-4a6e-905e-ea2251ff303b@lunn.ch \
--to=andrew@lunn.ch \
--cc=25181214217@stu.xidian.edu.cn \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tglx@kernel.org \
/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