From: Petr Mladek <pmladek@suse.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: maninder1.s@samsung.com,
"keescook@chromium.org" <keescook@chromium.org>,
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>,
"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 <onk>
Subject: Re: [PATCH 1/1] arch:hexagon/powerpc: use KSYM_NAME_LEN in array size
Date: Tue, 30 May 2023 10:06:07 +0200 [thread overview]
Message-ID: <ZHWub0ibU7etLnXK@alley> (raw)
In-Reply-To: <CANiq72n_eso7_pgna8ukmEnuCQPsKYPr0NU-Ss9Nwv0VzX=etg@mail.gmail.com>
On Mon 2023-05-29 16:50:45, Miguel Ojeda wrote:
> On Mon, May 29, 2023 at 1:08 PM Maninder Singh <maninder1.s@samsung.com> wrote:
> >
> > I Will add co-developed-by` tag.
> > because this change was identified while we were working on kallsyms some time back.
> > https://lore.kernel.org/lkml/YonTOL4zC4CytVrn@infradead.org/t/
> >
> > this patch set is pending and we will start working on that again, so i thought better
> > to send bugfix first.
>
> Sounds good to me!
>
> (Fixed Wedson's email address)
>
> > Yes, I think second buffer was not related to kallsyms, so I have not touched that.
>
> 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]);
> ^ ~~~~~~~~~~~~~~~~~~~~~~
>
> 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?.
>
> Also, I went through the other callers to `kallsyms_lookup` to see
> other issues -- one I am not sure about is `fetch_store_symstring` in
> `kernel/trace/trace_probe_tmpl.h`. Steven/Masami: is that "with max
> length" in the function docs enough? Is it 0xffff?
The best solution would be to pass the buffer size as an extra
parameter. Especially when some code passes buffers that are
allocated/reserved dynamically.
Sigh, I am not sure how many changes it would require in kallsyms
API and all the callers. But it would be really appreciated, IMHO.
Best Regards,
Petr
next prev parent reply other threads:[~2023-05-30 8:06 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 [this message]
2023-05-30 8:14 ` Maninder Singh
2023-05-30 23:14 ` Kees Cook
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=ZHWub0ibU7etLnXK@alley \
--to=pmladek@suse.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=miguel.ojeda.sandonis@gmail.com \
--cc=mpe@ellerman.id.au \
--cc=nathanl@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=ojeda@kernel.org \
--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