From: Kees Cook <kees@kernel.org>
To: Nick Desaulniers <ndesaulniers@google.com>,
Kees Cook <keescook@chromium.org>
Cc: Jakub Kicinski <kuba@kernel.org>,
Andy Shevchenko <andy@kernel.org>,
Masahiro Yamada <masahiroy@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nicolas@fjasle.eu>, Tom Rix <trix@redhat.com>,
Josh Poimboeuf <jpoimboe@kernel.org>,
Miroslav Benes <mbenes@suse.cz>, Marco Elver <elver@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Linus Walleij <linus.walleij@linaro.org>,
Cezary Rojewski <cezary.rojewski@intel.com>,
Mark Brown <broonie@kernel.org>, Puyou Lu <puyou.lu@gmail.com>,
linux-hardening@vger.kernel.org, linux-kbuild@vger.kernel.org,
llvm@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fortify: Improve buffer overflow reporting
Date: Thu, 02 Mar 2023 17:37:51 -0800 [thread overview]
Message-ID: <35F16A63-E946-4467-AD4D-D5E1331EA4D5@kernel.org> (raw)
In-Reply-To: <CAKwvOdkfCQJcpx3zh0pwHfnBP2v2ieqxqTUzOUyW14s3Xsaf-w@mail.gmail.com>
On March 2, 2023 3:21:11 PM PST, Nick Desaulniers <ndesaulniers@google.com> wrote:
>On Thu, Mar 2, 2023 at 2:58 PM Kees Cook <keescook@chromium.org> wrote:
>>
>> diff --git a/include/linux/fortify-string.h b/include/linux/fortify-string.h
>> index c9de1f59ee80..981e2838f99a 100644
>> --- a/include/linux/fortify-string.h
>> +++ b/include/linux/fortify-string.h
>> @@ -170,11 +170,13 @@ __FORTIFY_INLINE __diagnose_as(__builtin_strcat, 1, 2)
>> char *strcat(char * const POS p, const char *q)
>> {
>> size_t p_size = __member_size(p);
>> + size_t size;
>>
>> if (p_size == SIZE_MAX)
>> return __underlying_strcat(p, q);
>> - if (strlcat(p, q, p_size) >= p_size)
>> - fortify_panic(__func__);
>> + size = strlcat(p, q, p_size);
>> + if (p_size < size)
>
>What happens when they're equal? I think this patch changes
>behavior...? Intentional?
>
>Did flipping this conditional drop what should be `<=`?
>
>Was there an off by one, or is this version of this patch potentially
>introducing one? Or am I misremembering my boolean algebra?
Whoops! Thanks for catching that. I was going too fast. And I'm bothered that my regression tests missed it. :|
I will send a v2...
-Kees
--
Kees Cook
prev parent reply other threads:[~2023-03-03 1:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-02 22:58 Kees Cook
2023-03-02 23:21 ` Nick Desaulniers
2023-03-03 1:37 ` Kees Cook [this message]
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=35F16A63-E946-4467-AD4D-D5E1331EA4D5@kernel.org \
--to=kees@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=andy@kernel.org \
--cc=broonie@kernel.org \
--cc=cezary.rojewski@intel.com \
--cc=elver@google.com \
--cc=jpoimboe@kernel.org \
--cc=keescook@chromium.org \
--cc=kuba@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=masahiroy@kernel.org \
--cc=mbenes@suse.cz \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=nicolas@fjasle.eu \
--cc=puyou.lu@gmail.com \
--cc=trix@redhat.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
all inboxes | Powered by JetHome®