From: Dan Carpenter <dan.carpenter@oracle.com>
To: Martin Kaiser <lists@kaiser.cx>
Cc: Michael Straube <straube.linux@gmail.com>,
Phillip Potter <phil@philpotter.co.uk>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Larry Finger <Larry.Finger@lwfinger.net>,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/5] staging: r8188eu: use helper to check for broadcast address
Date: Tue, 2 Nov 2021 17:59:01 +0300 [thread overview]
Message-ID: <20211102145901.GH2914@kadam> (raw)
In-Reply-To: <20211022092110.d2mcmf2qe2jtkld4@viti.kaiser.cx>
On Fri, Oct 22, 2021 at 11:21:10AM +0200, Martin Kaiser wrote:
> Thus wrote Michael Straube (straube.linux@gmail.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
next prev parent reply other threads:[~2021-11-02 14:59 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-20 19:53 [PATCH 1/5] staging: r8188eu: remove unused dm_priv components Martin Kaiser
2021-10-20 19:53 ` [PATCH 2/5] staging: r8188eu: odm_rate_adapt Type is constant Martin Kaiser
2021-10-20 21:06 ` Phillip Potter
2021-10-21 10:18 ` Michael Straube
2021-10-20 19:53 ` [PATCH 3/5] staging: r8188eu: use helper to check for broadcast address Martin Kaiser
2021-10-20 21:07 ` Phillip Potter
2021-10-21 10:12 ` Michael Straube
2021-10-22 9:21 ` Martin Kaiser
2021-11-02 14:59 ` Dan Carpenter [this message]
2021-10-20 19:54 ` [PATCH 4/5] staging: r8188eu: use helper to set " Martin Kaiser
2021-10-20 21:08 ` Phillip Potter
2021-10-21 10:20 ` Michael Straube
2021-10-20 19:54 ` [PATCH 5/5] staging: r8188eu: remove unused defines and enums Martin Kaiser
2021-10-20 21:10 ` Phillip Potter
2021-10-21 10:21 ` Michael Straube
2021-10-20 21:05 ` [PATCH 1/5] staging: r8188eu: remove unused dm_priv components Phillip Potter
2021-10-21 10:17 ` Michael Straube
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211102145901.GH2914@kadam \
--to=dan.carpenter@oracle.com \
--cc=Larry.Finger@lwfinger.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=lists@kaiser.cx \
--cc=phil@philpotter.co.uk \
--cc=straube.linux@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).