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] [day] [month] [year] [list]
Date:   Tue, 2 Nov 2021 17:59:01 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     Martin Kaiser <lists@...ser.cx>
Cc:     Michael Straube <straube.linux@...il.com>,
        Phillip Potter <phil@...lpotter.co.uk>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Larry Finger <Larry.Finger@...inger.net>,
        linux-staging@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/5] staging: r8188eu: use helper to check for broadcast
 address

On Fri, Oct 22, 2021 at 11:21:10AM +0200, Martin Kaiser wrote:
> Thus wrote Michael Straube (straube.linux@...il.com):
> 
> > > > +		    !is_broadcast_ether_addr(GetAddr1Ptr(pframe)))
> 
> > Hi Martin,
> 
> > I'm not an expert regarding alignment. Is GetAddr1Ptr(pframe) always
> > __aligned(2) as required by is_broadcast_ether_addr?
> 
> Hi Michael,
> 
> thanks for spotting this. To be honest, I didn't look at this in much
> detail when I wrote the patch.
> 
> I suppose the pframe comes from recvbuf2recvframe().
> precvframe = rtw_alloc_recvframe(pfree_recv_queue);
> with
> struct __queue *pfree_recv_queue = &precvpriv->free_recv_queue; 
> 
> This should be initialised in _rtw_init_recv_priv().
> rtw_init_queue(&precvpriv->free_recv_queue);
> ...
> precvpriv->precv_frame_buf = (u8 *)N_BYTE_ALIGMENT((size_t)(precvpriv->pallocated_frame_buf), RXFRAME_ALIGN_SZ);
> precvframe = (struct recv_frame *)precvpriv->precv_frame_buf;
> and the frames are added to the free_recv_queue.
> RXFRAME_ALIGN_SZ is 1<<8.
> 
> So pframe should be 256-byte aligned.
> GetAddr1Ptr adds 4 to the start of pframe.
> 
> I guess we're safe here.

Greg already applied this patch.

I'm not sure why you're looking at precvpriv->precv_frame_buf instead of
"precv_frame->rx_data"?  Am I missing something?  This is actually a bit
tricky for me to analyze because it gets set in two places:

drivers/staging/r8188eu/core/rtw_recv.c | recvframe_pull | (struct recv_frame)->rx_data | 0-u64max
drivers/staging/r8188eu/hal/usb_ops_linux.c | recvbuf2recvframe | (struct recv_frame)->rx_data | 0-u64max

But the fact that we're using GetAddr1Ptr() on it at all suggests that
it must be aligned and hopefully we've verified that the ->rx_data has
enough data etc...  ?  This code is much trickier than I like it to be.
Anyway, this patch doesn't introduce bugs that weren't present in the
original.

> 
> > > > @@ -841,7 +840,7 @@ void odm_RSSIMonitorCheck(struct odm_dm_struct *pDM_Odm)
> > > >   		psta = pDM_Odm->pODM_StaInfo[i];
> > > >   		if (IS_STA_VALID(psta) &&
> > > >   		    (psta->state & WIFI_ASOC_STATE) &&
> > > > -		    memcmp(psta->hwaddr, bcast_addr, ETH_ALEN) &&
> > > > +		    !is_broadcast_ether_addr(psta->hwaddr) &&
> 
> > Perhaps we should add __aligned(2) to the hwaddr variable in struct
> > sta_info to be safe?
> 
> > u8	hwaddr[ETH_ALEN] __aligned(2);
> 
> Hmm, some of those arrays in other parts of the kernel have
> __aligned(2), others don't...
> 
> Can anyone else give some guidance?

This array comes after a u32 and it's not packed so it's going to
__aligned(4) already.

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ