From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
To: Kees Cook <keescook@chromium.org>
Cc: maninder1.s@samsung.com, Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
"bcain@quicinc.com" <bcain@quicinc.com>,
"mpe@ellerman.id.au" <mpe@ellerman.id.au>,
"npiggin@gmail.com" <npiggin@gmail.com>,
"christophe.leroy@csgroup.eu" <christophe.leroy@csgroup.eu>,
"nathanl@linux.ibm.com" <nathanl@linux.ibm.com>,
"ustavoars@kernel.org" <ustavoars@kernel.org>,
"alex.gaynor@gmail.com" <alex.gaynor@gmail.com>,
"gary@garyguo.net" <gary@garyguo.net>,
"ojeda@kernel.org" <ojeda@kernel.org>,
"pmladek@suse.com" <pmladek@suse.com>,
"linux-hexagon@vger.kernel.org" <linux-hexagon@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
Onkarnath <onkarnath.1@samsung.c>
Subject: Re: [PATCH 1/1] arch:hexagon/powerpc: use KSYM_NAME_LEN in array size
Date: Sun, 18 Jun 2023 16:20:14 +0200 [thread overview]
Message-ID: <CANiq72=K1sXz=TjBSjx+7JuTueH6vjbz9--Q2dGDYj3naKvroQ@mail.gmail.com> (raw)
In-Reply-To: <202305301611.34F0A680A2@keescook>
On Wed, May 31, 2023 at 1:14 AM Kees Cook <keescook@chromium.org> wrote:
>
> 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?)
Yeah, I would say so (i.e. I meant it as a good thing).
> > 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.
That would be nice!
Cheers,
Miguel
prev parent reply other threads:[~2023-06-18 14:20 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
[not found] ` <CGME20230529052832epcas5p4fa1b8cf25d9810d32bd2ccf012086fb3@epcms5p1>
2023-05-29 10:57 ` Maninder Singh
2023-05-29 14:50 ` Miguel Ojeda
2023-05-30 8:06 ` Petr Mladek
[not found] ` <CGME20230529052832epcas5p4fa1b8cf25d9810d32bd2ccf012086fb3@epcms5p8>
2023-05-30 8:14 ` Maninder Singh
2023-05-30 23:14 ` Kees Cook
2023-06-18 14:20 ` Miguel Ojeda [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='CANiq72=K1sXz=TjBSjx+7JuTueH6vjbz9--Q2dGDYj3naKvroQ@mail.gmail.com' \
--to=miguel.ojeda.sandonis@gmail.com \
--cc=alex.gaynor@gmail.com \
--cc=bcain@quicinc.com \
--cc=christophe.leroy@csgroup.eu \
--cc=gary@garyguo.net \
--cc=keescook@chromium.org \
--cc=linux-hexagon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maninder1.s@samsung.com \
--cc=mhiramat@kernel.org \
--cc=mpe@ellerman.id.au \
--cc=nathanl@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=ojeda@kernel.org \
--cc=onkarnath.1@samsung.c \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=ustavoars@kernel.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 read-only IMAP folder(s) and NNTP newsgroup(s).