tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Patches fixing unaligned access in the networking code



On 28.05.2019 09:07, Robert Elz wrote:
>     Date:        Tue, 28 May 2019 05:31:54 -0000 (UTC)
>     From:        mlelstv%serpens.de@localhost (Michael van Elst)
>     Message-ID:  <qcih49$9tq$1%serpens.de@localhost>
> 
> 
>   | >http://netbsd.org/~kamil/patch-00115-tcp_input.2.txt
> 
>   | Why would the first be obvious? The TCP header is already aligned
>   | and so is the first option value. I am pretty sure that worse things
>   | will happen if that assumption were broken.
> 
> Upon reflection, and really looking at the code, I agree.
> 
>   | The patch therefore exists to work around a false positive.
> 
> Yes.
> 
> No changes are needed for this one.  th is aligned (there is a KASSERT).
> Therefore th + 40 is aligned (both to 32 bit boundaries).   I hadn't
> noticed this was in the fast path "only timestamp option" handling code
> (as that option exists, usually alone, in almost every packet).
> 
> kre
> 

This assert is dummy on x86.

     46 #ifdef __NO_STRICT_ALIGNMENT
     47 #define	TCP_HDR_ALIGNED_P(th)	1
     48 #else
     49 #define	TCP_HDR_ALIGNED_P(th)	((((vaddr_t)(th)) & 3) == 0)
     50 #endif /* __NO_STRICT_ALIGNMENT */

https://nxr.netbsd.org/xref/src/sys/netinet/tcp_private.h#49

As mentioned in the logs [1], the address is misaligned.

[1] http://netbsd.org/~kamil/patch-00115-tcp_input.2.txt

Attachment: signature.asc
Description: OpenPGP digital signature



Home | Main Index | Thread Index | Old Index