Hi,

On Sun, Feb 26, 2023 at 03:10:07PM +0100, Arne Schwabe wrote:
> > struct ifaddr {
> >          struct  sockaddr *ifa_addr;     /* address of interface */
> >          struct  sockaddr *ifa_dstaddr;  /* other end of p-to-p link */
> >          struct  sockaddr *ifa_netmask;  /* used to determine subnet */
> >
> > ... so the first memcpy() isn't actually copying the MAC address around,
> > just a bunch of pointers, and then we dereference the first of them
> > for the second memcpy(), using the dereferencing macro for a
> > "sockaddr_dl" structure.
> 
> The problem is that LLVM ASAN does not like access to an unaligned 
> struct. Even if it just accessing a member to deference it. So you are 
> right that it is just copying a bunch of pointers, to not triggers the 
> warning, we have to do this nonsense. The compiler will even optimise 
> this then away again on platforms that have no problem with unaligned 
> accesses.

With ifr being a structure now, it is aligned just fine - I'm not objecting
to that part, just to the intermediate "sdl" thing, and the double
memcpy(), and 10 lines of comments.

> > FreeBSD also has
> >
> > #define IF_LLADDR(ifp)                                                  \
> >      LLADDR((struct sockaddr_dl *)((ifp)->if_addr->ifa_addr))
> >
> > which sounds like "feed in an *ifr, out comes a pointer for the
> > memcpy() to rgi->addr".
> 
> Yes but you will still get warning about casting a smaller struct to a 
> larger struct and that being a bad idea.

This is not casting a struct, just casting a pointer.  Does it still
warn?

gert

-- 
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             g...@greenie.muc.de

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to