From: Kees Cook <keescook@chromium.org>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Kees Cook <keescook@chromium.org>,
Nick Desaulniers <ndesaulniers@google.com>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>,
Keith Busch <kbusch@kernel.org>, Len Baker <len.baker@gmx.com>,
Jonathan Corbet <corbet@lwn.net>,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: [PATCH v2 0/2] overflow: Implement size_t saturating arithmetic helpers
Date: Mon, 24 Jan 2022 15:23:40 -0800 [thread overview]
Message-ID: <20220124232342.3113350-1-keescook@chromium.org> (raw)
Hi,
While doing more array_size() scans on the kernel, and reviewing recent[1]
struct_size() work[2], it became clear we needed helpers to perform
composed saturating adds and multiplies. This creates those helpers and
updates the self tests to check them.
v1: https://lore.kernel.org/lkml/20210920180853.1825195-1-keescook@chromium.org/
v2:
- use static inlines instead of macros (Rasmus)
- undef local helpers defs in selftest (Rasmus)
- Make sure to keep saturation for size_sub() arguments
- update selftests for size_sub() behavior
- Add reviews
Thanks,
-Kees
[1] https://lore.kernel.org/linux-hardening/202201241213.82E7D9F598@keescook/
[2] https://lore.kernel.org/lkml/?q=%22open-coded+arithmetic%22
Kees Cook (2):
test_overflow: Regularize test reporting output
overflow: Implement size_t saturating arithmetic helpers
Documentation/process/deprecated.rst | 20 +++-
include/linux/overflow.h | 110 +++++++++++--------
lib/test_overflow.c | 152 ++++++++++++++++++++++-----
3 files changed, 214 insertions(+), 68 deletions(-)
--
2.30.2
next reply other threads:[~2022-01-25 3:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-24 23:23 Kees Cook [this message]
2022-01-24 23:23 ` [PATCH v2 1/2] test_overflow: Regularize test reporting output Kees Cook
2022-01-24 23:23 ` [PATCH v2 2/2] overflow: Implement size_t saturating arithmetic helpers Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220124232342.3113350-1-keescook@chromium.org \
--to=keescook@chromium.org \
--cc=corbet@lwn.net \
--cc=gustavoars@kernel.org \
--cc=jgg@ziepe.ca \
--cc=kbusch@kernel.org \
--cc=len.baker@gmx.com \
--cc=leon@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).