Re: [ulogd2 PATCH 15/26] input: UNIXSOCK: prevent unaligned pointer access.

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

 



On Saturday 2021-10-30 18:44, Jeremy Sowden wrote:

>`struct ulogd_unixsock_packet_t` is packed, so taking the address of its
>`struct iphdr payload` member may yield an unaligned pointer value.

That may not be a problem. Dereferencing through a pointer to
a packed struct generates very pessimistic code even when there is no
padding internally:

» cat >>x.cpp <<-EOF
struct ethhdr { unsigned long long a, b; } __attribute__((packed));
unsigned long f(const struct ethhdr *p) { return p->b; }
EOF
» sparc64-linux-gcc -c x.cpp -O2
» objdump -d x.o
_Z1fPK6ethhdr:
        save %sp, -144, %sp
        stx %i0, [%fp+2039]
        ldx [%fp+2039], %i0
        ldub [%i0+15], %i2
        ldub [%i0+14], %i1
        sllx %i1, 8, %i1
        or %i1, %i2, %i2
        ldub [%i0+13], %i3
...




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux