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]
Message-ID: <e9d546ac-dbcb-272e-f4c0-4ecd61f65c78@kernel.org>
Date: Wed, 6 Dec 2023 16:59:58 -0800 (PST)
From: Mat Martineau <martineau@...nel.org>
To: David Laight <David.Laight@...lab.com>
cc: "netdev@...r.kernel.org" <netdev@...r.kernel.org>, 
    Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, 
    "David S. Miller" <davem@...emloft.net>, 
    Stephen Hemminger <stephen@...workplumber.org>, 
    David Ahern <dsahern@...nel.org>, 
    "jakub@...udflare.com" <jakub@...udflare.com>, 
    Eric Dumazet <edumazet@...gle.com>
Subject: Re: [PATCH net-next v2] Use READ/WRITE_ONCE() for IP
 local_port_range.

On Wed, 6 Dec 2023, David Laight wrote:

> Commit 227b60f5102cd added a seqlock to ensure that the low and high
> port numbers were always updated together.
> This is overkill because the two 16bit port numbers can be held in
> a u32 and read/written in a single instruction.
>
> More recently 91d0b78c5177f added support for finer per-socket limits.
> The user-supplied value is 'high << 16 | low' but they are held
> separately and the socket options protected by the socket lock.
>
> Use a u32 containing 'high << 16 | low' for both the 'net' and 'sk'
> fields and use READ_ONCE()/WRITE_ONCE() to ensure both values are
> always updated together.
>
> Change (the now trival) inet_get_local_port_range() to a static inline
> to optimise the calling code.
> (In particular avoiding returning integers by reference.)
>
> Signed-off-by: David Laight <david.laight@...lab.com>
> ---
> Changes for v2:
> - minor layout changes.
> - remove unlikely() from comparisons when per-socket range set.
> - avoid shifts of signed values that generate unsigned 32bit results.
> I fiddled with the code that validates the argument to IP_LOCAL_PORT_RANGE
> then decided to leave it (mostly) unchanged because it is also moved.
> (There is a 'u16 x = int_val >> 16' which is required to move bit 31 to
> bit 15 and is probably undefined behaviour - but will be ok on all sane cpu.)
>

The unsigned bit shift fixes look good to me, thanks David.

Acked-by: Mat Martineau <martineau@...nel.org>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ