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: <2100617.1714117250@warthog.procyon.org.uk>
Date: Fri, 26 Apr 2024 08:40:50 +0100
From: David Howells <dhowells@...hat.com>
To: Kees Cook <keescook@...omium.org>
Cc: dhowells@...hat.com, Mark Rutland <mark.rutland@....com>,
    Will Deacon <will@...nel.org>, Peter Zijlstra <peterz@...radead.org>,
    Boqun Feng <boqun.feng@...il.com>,
    Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
    Borislav Petkov <bp@...en8.de>,
    Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
    "H. Peter Anvin" <hpa@...or.com>, Jakub Kicinski <kuba@...nel.org>,
    Catalin Marinas <catalin.marinas@....com>,
    Arnd Bergmann <arnd@...db.de>,
    Andrew Morton <akpm@...ux-foundation.org>,
    "David S. Miller" <davem@...emloft.net>,
    David Ahern <dsahern@...nel.org>, Eric Dumazet <edumazet@...gle.com>,
    Paolo Abeni <pabeni@...hat.com>,
    "Paul E. McKenney" <paulmck@...nel.org>,
    Uros Bizjak <ubizjak@...il.com>, linux-kernel@...r.kernel.org,
    linux-arm-kernel@...ts.infradead.org, linux-arch@...r.kernel.org,
    netdev@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH 1/4] locking/atomic/x86: Silence intentional wrapping addition

Kees Cook <keescook@...omium.org> wrote:

> -	return i + xadd(&v->counter, i);
> +	return wrapping_add(int, i, xadd(&v->counter, i));

Ewww.  Can't you just mark the variable as wrapping in some way, either by:

	unsigned int __cyclic counter;

or, to use rxrpc packet sequence numbers as an example:

	typedef unsigned int __cyclic rxrpc_seq_t;

	rxrpc_seq_t	tx_top;

Then you can get the compiler to spit out a warning if you use <, <=, > or >=
on the numbers as an added bonus.  (You should use before() and after()
instead).

David


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ