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]
Message-ID: <YNBJwnwaS6w9A0x4@unreal>
Date:   Mon, 21 Jun 2021 11:11:46 +0300
From:   Leon Romanovsky <leon@...nel.org>
To:     Kees Cook <keescook@...omium.org>
Cc:     Jack Morgenstein <jackm@...dia.com>,
        Jason Gunthorpe <jgg@...pe.ca>,
        Yishai Hadas <yishaih@...dia.com>,
        Doug Ledford <dledford@...hat.com>,
        linux-kernel@...r.kernel.org, linux-rdma@...r.kernel.org,
        linux-hardening@...r.kernel.org
Subject: Re: [PATCH] IB/mlx4: Avoid field-overflowing memcpy()

On Thu, Jun 17, 2021 at 12:46:43PM -0700, Kees Cook wrote:
> On Thu, Jun 17, 2021 at 10:24:58AM +0300, Leon Romanovsky wrote:
> > On Wed, Jun 16, 2021 at 01:37:44PM -0700, Kees Cook wrote:
> > > In preparation for FORTIFY_SOURCE performing compile-time and run-time
> > > field bounds checking for memcpy(), memmove(), and memset(), avoid
> > > intentionally writing across neighboring array fields.
> > > 
> > > Use the ether_addr_copy() helper instead, as already done for smac.
> > > 
> > > Signed-off-by: Kees Cook <keescook@...omium.org>
> > > ---
> > >  drivers/infiniband/hw/mlx4/qp.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
> > > index 2ae22bf50016..4a2ef7daaded 100644
> > > --- a/drivers/infiniband/hw/mlx4/qp.c
> > > +++ b/drivers/infiniband/hw/mlx4/qp.c
> > > @@ -3144,7 +3144,7 @@ static int build_mlx_header(struct mlx4_ib_qp *qp, const struct ib_ud_wr *wr,
> > >  		mlx->sched_prio = cpu_to_be16(pcp);
> > >  
> > >  		ether_addr_copy(sqp->ud_header.eth.smac_h, ah->av.eth.s_mac);
> > > -		memcpy(sqp->ud_header.eth.dmac_h, ah->av.eth.mac, 6);
> > > +		ether_addr_copy(sqp->ud_header.eth.dmac_h, ah->av.eth.mac);
> > >  		memcpy(&ctrl->srcrb_flags16[0], ah->av.eth.mac, 2);
> > >  		memcpy(&ctrl->imm, ah->av.eth.mac + 2, 4);
> > 
> > I don't understand the last three lines. We are copying 6 bytes to
> > ah->av.eth.mac and immediately after that overwriting them.
> 
> I'm not following (the memcpy() is replaced by ether_addr_copy()).

Forget it, it was me who mixed src with dst in the memcpy() signature.

Thanks,
Reviewed-by: Leon Romanovsky <leonro@...dia.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ