Re: [PATCH net] e1000e: Fix out-of-bounds MMIO access by validating BAR0 size

From: Andrew Lunn

Date: Mon Jul 20 2026 - 11:34:19 EST


On Mon, Jul 20, 2026 at 05:53:37AM -0700, Breno Leitao wrote:
> On Mon, Jul 20, 2026 at 07:56:20PM +0800, Pu Lehui wrote:
> >
> > On 2026/7/20 17:47, Breno Leitao wrote:
> > > On Wed, Jul 15, 2026 at 03:58:50AM +0000, Pu Lehui wrote:
> > > > +/* Minimum MMIO (BAR0) len, the largest offset is lower than 64K */
> > >
> > > Why "the largest" in this case?
> >
> > Hi Breno,
> >
> > Thanks for pointing that out. I meant the maximum register offset accessed
> > by the driver.
> >
> > IIUC, common e1000e NIC usually have a 128K BAR0. But since I'm not 100%
> > sure if older NIC might be smaller, I picked 64K as a safe lower limit
> > because it covers the largest register offset used in the driver's codebase.
> > If my assumption here is off, I'd really appreciate any corrections!
> >
> > And for this comment, how about the follow?
> > /* Minimum MMIO (BAR0) length to safely cover the maximum register offset
> > accessed by the driver */
>
> Thanks, Would something like this be a bit better?
>
> /*
> * Smallest BAR0 that covers every register the driver accesses
> */

I would actually reference the highest register. It then becomes
exactly clear where this number comes from. Better still, use the
register #define in the test, along with this comment.

Andrew