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:   Thu, 21 Nov 2019 15:53:50 -0800
From:   Jeff Kirsher <jeffrey.t.kirsher@...el.com>
To:     Pavel Machek <pavel@...x.de>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     linux-kernel@...r.kernel.org, stable@...r.kernel.org,
        Mitch Williams <mitch.a.williams@...el.com>,
        Andrew Bowers <andrewx.bowers@...el.com>,
        Sasha Levin <sashal@...nel.org>
Subject: Re: [PATCH 4.19 079/422] i40e: use correct length for strncpy

On Thu, 2019-11-21 at 11:35 +0100, Pavel Machek wrote:
> > From: Mitch Williams <mitch.a.williams@...el.com>
> > 
> > [ Upstream commit 7eb74ff891b4e94b8bac48f648a21e4b94ddee64 ]
> > 
> > Caught by GCC 8. When we provide a length for strncpy, we should not
> > include the terminating null. So we must tell it one less than the size
> > of the destination buffer.
> 
> > +++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
> > @@ -694,7 +694,8 @@ static long i40e_ptp_create_clock(struct i40e_pf
> *pf)
> >       if (!IS_ERR_OR_NULL(pf->ptp_clock))
> >               return 0;
> >  
> > -     strncpy(pf->ptp_caps.name, i40e_driver_name, sizeof(pf-
> >ptp_caps.name));
> > +     strncpy(pf->ptp_caps.name, i40e_driver_name,
> > +             sizeof(pf->ptp_caps.name) - 1);
> >       pf->ptp_caps.owner = THIS_MODULE;
> >       pf->ptp_caps.max_adj = 999999999;
> >       pf->ptp_caps.n_ext_ts = 0;
> 
> So... pf is allocated with kzalloc, which will provide the null
> termination... so the code is okay.
> 
> On the other hand, the = 0 below is unneeded by the same logic, so
> this is a bit confusing.

Thanks for the catch, we are putting together a follow-on patch to cleanup
up the unneeded code.

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ