lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 25 Jul 2022 14:20:23 +0200
From:   Jules Maselbas <jmaselbas@...ray.eu>
To:     Jakub Kicinski <kuba@...nel.org>
Cc:     Claudiu Manoil <claudiu.manoil@....com>,
        "David S. Miller" <davem@...emloft.net>, netdev@...r.kernel.org
Subject: Re: ethtool generate a buffer overflow in strlen

On Fri, Jul 22, 2022 at 02:29:42PM -0700, Jakub Kicinski wrote:
> On Fri, 22 Jul 2022 19:37:46 +0200 Jules Maselbas wrote:
> > There is suspicious lines in the file drivers/net/ethernet/freescale/enetc/enetc_ethtool.c:
> >    { ENETC_PM0_R1523X, "MAC rx 1523 to max-octet packets" },
> > and:
> >    { ENETC_PM0_T1523X, "MAC tx 1523 to max-octet packets" },
> > 
> > Where the string length is actually greater than 32 bytes which is more
> > than the reserved space for the name. This structure is defined as
> > follow:
> >     static const struct {
> >         int reg;
> >         char name[ETH_GSTRING_LEN];
> >     } enetc_port_counters[] = { ...
> > 
> > In the function enetc_get_strings(), there is a strlcpy call on the
> > counters names which in turns calls strlen on the src string, causing
> > an out-of-bound read, at least out-of the string.
> > 
> > I am not sure that's what caused the BUG, as I don't really know how
> > fortify works but I thinks this might only be visible when fortify is
> > enabled.
> > 
> > I am not sure on how to fix this issue, maybe use `char *` instead of
> > an byte array.
> 
> Thanks for the report!
Thanks for the replie :)

> I'd suggest to just delete the RMON stats in the unstructured API
> in this driver and report them via
>  
> 	ethtool -S eth0 --groups rmon
I am not familiar with ethtool: I don't understand what you're
suggesting. Would you mind giving some hints/links to what RMON stats
are?


> No point trying to figure out a way to make the old API more
> resilient IMO when we have an alternative.
I was not thinking of changing the API but simply the structure to use
a string pointer instead of an array, this will make strings in the
enetc_port_counters properly nul terminated.
However the name will still be truncated when copied by the _get_strings
function... but it will not BUG on strlen.

Best,
Jules




Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ