Search Linux Wireless

Re: [PATCH] wifi: iwlegacy: Fix "field-spanning write" warning in il_enqueue_hcmd()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



to 12. syysk. 2024 klo 11.40 Stanislaw Gruszka (stf_xl@xxxxx) kirjoitti:
>
> On Thu, Sep 12, 2024 at 01:01:21AM +0200, Ben Hutchings wrote:
> > iwlegacy uses command buffers with a payload size of 320
> > bytes (default) or 4092 bytes (huge).  The struct il_device_cmd type
> > describes the default buffers and there is no separate type describing
> > the huge buffers.
> >
> > The il_enqueue_hcmd() function works with both default and huge
> > buffers, and has a memcpy() to the buffer payload.  The size of
> > this copy may exceed 320 bytes when using a huge buffer, which
> > now results in a run-time warning:
> >
> >     memcpy: detected field-spanning write (size 1014) of single field "&out_cmd->cmd.payload" at drivers/net/wireless/intel/iwlegacy/common.c:3170 (size 320)
> >
> > To fix this:
> >
> > - Define a new struct type for huge buffers, with a correctly sized
> >   payload field
> > - When using a huge buffer in il_enqueue_hcmd(), cast the command
> >   buffer pointer to that type when looking up the payload field
> >
> > Reported-by: Martin-Éric Racine <martin-eric.racine@xxxxxx>
> > References: https://bugs.debian.org/1062421
> > References: https://bugzilla.kernel.org/show_bug.cgi?id=219124
> > Signed-off-by: Ben Hutchings <ben@xxxxxxxxxxxxxxx>
> > Fixes: 54d9469bc515 ("fortify: Add run-time WARN for cross-field memcpy()")
> > Tested-by: Martin-Éric Racine <martin-eric.racine@xxxxxx>
> > Tested-by: Brandon Nielsen <nielsenb@xxxxxxxxxxx>
>
> I proposed diffrent fix for this here:
> https://lore.kernel.org/linux-wireless/20240520073210.GA693073@xxxxx/
> but never get feedback if it works on real HW.

I submitted bug reports about this at Debian and on kernel.org's
Bugzilla, but never saw this patch, so obviously could not provide
feedback.

> So I prefer this one, sice it was tested.
>
> Acked-by: Stanislaw Gruszka <stf_xl@xxxxx>

Thanks.

> Martin-Éric and Brandon, could you plase also test patch from
> https://lore.kernel.org/linux-wireless/Zr2gxERA3RL3EwRe@elsanto/
> if it does not break the driver?

I am not currently in a position to test this. I will trust Brandon's
results on this one.

Meanwhile, an entirely unrelated bug crept into the kernel. See
attachments on the above bugzilla report.

Martin-Éric





[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux