linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Kees Cook <kees@kernel.org>, LKML <linux-kernel@vger.kernel.org>,
	linux-hardening@vger.kernel.org,
	Linux Trace Kernel <linux-trace-kernel@vger.kernel.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>
Subject: Re: [PATCH] overflow: Introduce struct_offset() to get offset of member
Date: Fri, 28 Nov 2025 12:19:19 -0500	[thread overview]
Message-ID: <20251128121919.521ec9bf@robin> (raw)
In-Reply-To: <CAHk-=wiF9-vf3zW8vXoFGk+bo0=dSoJMm_nmVzsTDCerZzhGaw@mail.gmail.com>

On Thu, 27 Nov 2025 21:35:35 -0800
Linus Torvalds <torvalds@linux-foundation.org> wrote:

> So that 'xyz_t()' version then gets used for things where you
> explicitly state the type, and it all looks fairly obvious, eg:
> 
>         len = struct_size_t(struct pid, numbers, level + 1);
> 
> doesn't get that "WHAA?!??!" kind of reaction.
> 
> [ And so I actually think it's good that it only takes an explicit
> type - if you really have an instance, I think it's better to use just
> "struct_size(&instance, ...)" even if we _could_ easily make syntax
> like "struct_size_t(instance, ...)" work. ]

I was thinking about adding a struct_offset_t() but then I noticed that
struct_size_t() requires adding the type as it is for just getting the
size of the struct without using a variable. Whereas, I would have
preferred the struct_offset_t() to use a variable that's not a pointer
where typeof() is used.

But for my use cases, I can just add a '&' to struct_offset(), as if
struct_offset_t() were to take a type, it is no different than
offsetof().

-- Steve



      reply	other threads:[~2025-11-28 17:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-26 19:52 [PATCH] overflow: Introduce struct_offset() to get offset of member Steven Rostedt
2025-11-26 20:08 ` Steven Rostedt
2025-11-27  7:58 ` Kees Cook
2025-11-28  1:43   ` Steven Rostedt
2025-11-28  2:00     ` Kees Cook
2025-11-28  3:27       ` Steven Rostedt
2025-11-28  5:35         ` Linus Torvalds
2025-11-28 17:19           ` Steven Rostedt [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=20251128121919.521ec9bf@robin \
    --to=rostedt@goodmis.org \
    --cc=gustavoars@kernel.org \
    --cc=kees@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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).