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] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 25 Oct 2022 12:25:52 +0000
From:   "Starke, Daniel" <daniel.starke@...mens.com>
To:     Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
CC:     linux-serial <linux-serial@...r.kernel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Jiri Slaby <jirislaby@...nel.org>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 3/3] tty: n_gsm: add parameter negotiation support

> > > > +	n1 = FIELD_GET(PN_N_FIELD_N1, le16_to_cpu(params->n_bits));
> > > 
> > > Should this be using get_unaligned...()?
> > 
> > Is this really necessary if the structure is already __packed? I did not
> > receive any warning by the compiler.
> 
> It would be arch dependent to begin with. But honestly, I'm not entirely 
> certain here myself.

I have checked the code in include/asm-generic/unaligned.h.
An extract:

#define __get_unaligned_t(type, ptr) ({						\
	const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr);	\
	__pptr->x;								\
})

#define get_unaligned(ptr)	__get_unaligned_t(typeof(*(ptr)), (ptr))

static inline u16 get_unaligned_le16(const void *p)
{
	return le16_to_cpu(__get_unaligned_t(__le16, p));
}

Looking at this I would assume that the use of get_unaligned_le16() makes
no difference compared to the current implementation. My assumption is
that the compiler makes sure the 16-bit value is accessed at the correct
address and le16_to_cpu() converts the intermediate value correctly.

> static_assert(sizeof(struct gsm_dlci_param_bits) == 8);
> 
> If lkp builds all its current archs fine with that static_assert(), I'd be 
> pretty sure the struct that the unpacked struct is ok on all archs. Would 
> it ever stop being true on any arch/compiler setting, the assert would 
> catch it right away.

That is an uncertainty I would like to avoid. And what should be the
solution if the assertion fails? Nevertheless, I do not mind implementing
it in this way to move forward.

Best regards,
Daniel Starke

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ