public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium•org>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail•com>
Cc: "nathanl@linux•ibm.com" <nathanl@linux•ibm.com>,
	"bcain@quicinc•com" <bcain@quicinc•com>,
	Wedson Almeida Filho <wedsonaf@gmail•com>,
	"gary@garyguo•net" <gary@garyguo•net>,
	"pmladek@suse•com" <pmladek@suse•com>,
	"ustavoars@kernel•org" <ustavoars@kernel•org>,
	"linux-kernel@vger•kernel.org" <linux-kernel@vger•kernel.org>,
	"npiggin@gmail•com" <npiggin@gmail•com>,
	"ojeda@kernel•org" <ojeda@kernel•org>,
	Steven Rostedt <rostedt@goodmis•org>,
	Masami Hiramatsu <mhiramat@kernel•org>,
	"alex.gaynor@gmail•com" <alex.gaynor@gmail•com>,
	"linux-hexagon@vger•kernel.org" <linux-hexagon@vger•kernel.org>,
	maninder1.s@samsung•com, Onkarnath <onkarnath.1@samsung•com>,
	"linuxppc-dev@lists•ozlabs.org" <linuxppc-dev@lists•ozlabs.org>
Subject: Re: [PATCH 1/1] arch:hexagon/powerpc: use KSYM_NAME_LEN in array size
Date: Tue, 30 May 2023 16:14:01 -0700	[thread overview]
Message-ID: <202305301611.34F0A680A2@keescook> (raw)
In-Reply-To: <CANiq72n_eso7_pgna8ukmEnuCQPsKYPr0NU-Ss9Nwv0VzX=etg@mail.gmail.com>

On Mon, May 29, 2023 at 04:50:45PM +0200, Miguel Ojeda wrote:
> Kees: what is the current stance on `[static N]` parameters? Something like:
> 
>     const char *kallsyms_lookup(unsigned long addr,
>                                 unsigned long *symbolsize,
>                                 unsigned long *offset,
>     -                           char **modname, char *namebuf);
>     +                           char **modname, char namebuf[static KSYM_NAME_LEN]);
> 
> makes the compiler complain about cases like these (even if trivial):
> 
>     arch/powerpc/xmon/xmon.c:1711:10: error: array argument is too small;
>         contains 128 elements, callee requires at least 512
> [-Werror,-Warray-bounds]
>             name = kallsyms_lookup(pc, &size, &offset, NULL, tmpstr);
>                  ^                                           ~~~~~~
>     ./include/linux/kallsyms.h:86:29: note: callee declares array
> parameter as static here
>             char **modname, char namebuf[static KSYM_NAME_LEN]);
>                                  ^      ~~~~~~~~~~~~~~~~~~~~~~

Wouldn't that be a good thing? (I.e. complain about the size mismatch?)

> But I only see 2 files in the kernel using `[static N]` (from 2020 and
> 2021). Should something else be used instead (e.g. `__counted_by`),
> even if constexpr-sized?.

Yeah, it seems pretty uncommon. I'd say traditionally arrays aren't
based too often, rather structs containing them.

But ultimately, yeah, everything could gain __counted_by and friends in
the future.

-- 
Kees Cook

  parent reply	other threads:[~2023-05-30 23:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230529052832epcas5p4fa1b8cf25d9810d32bd2ccf012086fb3@epcas5p4.samsung.com>
2023-05-29  5:28 ` [PATCH 1/1] arch:hexagon/powerpc: use KSYM_NAME_LEN in array size Maninder Singh
2023-05-29 10:45   ` Miguel Ojeda
2023-05-29 10:57     ` Maninder Singh
2023-05-29 14:50       ` Miguel Ojeda
2023-05-30  8:06         ` Petr Mladek
2023-05-30  8:14           ` Maninder Singh
2023-05-30 23:14         ` Kees Cook [this message]
2023-06-18 14:20           ` Miguel Ojeda

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=202305301611.34F0A680A2@keescook \
    --to=keescook@chromium$(echo .)org \
    --cc=alex.gaynor@gmail$(echo .)com \
    --cc=bcain@quicinc$(echo .)com \
    --cc=gary@garyguo$(echo .)net \
    --cc=linux-hexagon@vger$(echo .)kernel.org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=linuxppc-dev@lists$(echo .)ozlabs.org \
    --cc=maninder1.s@samsung$(echo .)com \
    --cc=mhiramat@kernel$(echo .)org \
    --cc=miguel.ojeda.sandonis@gmail$(echo .)com \
    --cc=nathanl@linux$(echo .)ibm.com \
    --cc=npiggin@gmail$(echo .)com \
    --cc=ojeda@kernel$(echo .)org \
    --cc=onkarnath.1@samsung$(echo .)com \
    --cc=pmladek@suse$(echo .)com \
    --cc=rostedt@goodmis$(echo .)org \
    --cc=ustavoars@kernel$(echo .)org \
    --cc=wedsonaf@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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