mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
To: Kees Cook <kees@kernel.org>
Cc: Andy Shevchenko <andy@kernel.org>,
	Justin Stitt <justinstitt@google.com>,
	 Luc Van Oostenryck <luc.vanoostenryck@gmail.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	 Miguel Ojeda <ojeda@kernel.org>, Marco Elver <elver@google.com>,
	 Nathan Chancellor <nathan@kernel.org>,
	Hao Luo <haoluo@google.com>,
	 Przemek Kitszel <przemyslaw.kitszel@intel.com>,
	linux-sparse@vger.kernel.org,  linux-hardening@vger.kernel.org,
	Bill Wendling <morbo@google.com>,
	 Mark Rutland <mark.rutland@arm.com>,
	Jakub Kicinski <kuba@kernel.org>,
	 Alexander Lobakin <aleksander.lobakin@intel.com>,
	Tony Ambardar <tony.ambardar@gmail.com>,
	 Petr Pavlu <petr.pavlu@suse.com>,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH] string: Check for "nonstring" attribute on strscpy() arguments
Date: Tue, 6 Aug 2024 12:46:50 +0200	[thread overview]
Message-ID: <CANiq72mifyQZ_13ZWYi2_cdcx9G3dOSVVtywC++6s0P_6JKAGQ@mail.gmail.com> (raw)
In-Reply-To: <20240805214340.work.339-kees@kernel.org>

On Mon, Aug 5, 2024 at 11:43 PM Kees Cook <kees@kernel.org> wrote:
>
> +/* Determine if an attribute has been applied to a variable. */
> +#if __has_builtin(__builtin_has_attribute)
> +#define __annotated(var, attr) __builtin_has_attribute(var, attr)
> +#else
> +#define __annotated(var, attr) (false)
> +#endif

`__annotated` is obviously best-effort given this definition, and we
do similar things elsewhere, and it has a double-underscore. However,
I wonder if this being a "query" (vs. something like an attribute) may
imply that it has a greater risk of someone thinking it will always
reply with the right answer... (if e.g. they copy-paste another use).
Perhaps there is a more explicit name to let users recall that.

Anyway, it looks sensible to me: more compile-time checking seldomly
hurts (apart from complexity in these definitions :). So:

Reviewed-by: Miguel Ojeda <ojeda@kernel.org>

I also introduced a mistake on purpose and I got the expected build error, so:

Tested-by: Miguel Ojeda <ojeda@kernel.org>

Cheers,
Miguel

  parent reply	other threads:[~2024-08-06 10:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-05 21:43 Kees Cook
2024-08-06 10:29 ` Przemek Kitszel
2024-08-23  0:04   ` Kees Cook
2024-08-06 10:46 ` Miguel Ojeda [this message]
2024-08-23  0:05 ` 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=CANiq72mifyQZ_13ZWYi2_cdcx9G3dOSVVtywC++6s0P_6JKAGQ@mail.gmail.com \
    --to=miguel.ojeda.sandonis@gmail.com \
    --cc=aleksander.lobakin@intel.com \
    --cc=andy@kernel.org \
    --cc=elver@google.com \
    --cc=haoluo@google.com \
    --cc=justinstitt@google.com \
    --cc=kees@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=luc.vanoostenryck@gmail.com \
    --cc=mark.rutland@arm.com \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=ojeda@kernel.org \
    --cc=petr.pavlu@suse.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=tony.ambardar@gmail.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®