public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Maninder Singh' <maninder1.s@samsung.com>,
	"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>,
	"keescook@chromium.org" <keescook@chromium.org>,
	"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>,
	"wedsonaf@google.com" <wedsonaf@google.com>
Cc: "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.com>
Subject: RE: [PATCH 1/2] hexagon/traps.c: use KSYM_NAME_LEN in array size
Date: Tue, 30 May 2023 13:42:13 +0000	[thread overview]
Message-ID: <439575eda6b24261aef4c8c7e4c078cb@AcuMS.aculab.com> (raw)
In-Reply-To: <20230529111337.352990-1-maninder1.s@samsung.com>

From: Maninder Singh
> Sent: 29 May 2023 12:14
> 
> kallsyms_lookup which in turn calls for kallsyms_lookup_buildid()
> writes on index "KSYM_NAME_LEN - 1".
> 
> Thus array size should be KSYM_NAME_LEN.
> 
> for hexagon it was defined as "128" directly.
> and commit '61968dbc2d5d' changed define value to 512,
> So both were missed to update with new size.

The only safe way to pass a fixed size string is to embed the char[] in
a structure and pass the structure address.

Pretty much anything else is doomed to be buggy.

Whether is it actually sane to require the caller allocate
such a large buffer (hi rust) is another matter entirely.

	David

> 
> Fixes: 61968dbc2d5d ("kallsyms: increase maximum kernel symbol length to 512")
> 
> Co-developed-by: Onkarnath <onkarnath.1@samsung.com>
> Signed-off-by: Onkarnath <onkarnath.1@samsung.com>
> Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
> ---
>  arch/hexagon/kernel/traps.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/hexagon/kernel/traps.c b/arch/hexagon/kernel/traps.c
> index 6447763ce5a9..65b30b6ea226 100644
> --- a/arch/hexagon/kernel/traps.c
> +++ b/arch/hexagon/kernel/traps.c
> @@ -82,7 +82,7 @@ static void do_show_stack(struct task_struct *task, unsigned long *fp,
>  	const char *name = NULL;
>  	unsigned long *newfp;
>  	unsigned long low, high;
> -	char tmpstr[128];
> +	char tmpstr[KSYM_NAME_LEN];
>  	char *modname;
>  	int i;
> 
> --
> 2.17.1

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  parent reply	other threads:[~2023-05-30 13:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230529111350epcas5p46a1fa16ffb2a39008c26d03c5c63f109@epcas5p4.samsung.com>
2023-05-29 11:13 ` [PATCH 1/2] hexagon/traps.c: use KSYM_NAME_LEN in array size Maninder Singh
2023-05-29 11:13   ` [PATCH 2/2] powerpc/xmon: " Maninder Singh
2023-05-30  6:45     ` Michael Ellerman
2023-05-30 12:54     ` Miguel Ojeda
2023-06-01  2:02       ` Michael Ellerman
2023-06-01 10:27         ` Miguel Ojeda
2023-06-01 12:54           ` Michael Ellerman
2023-08-03  5:46       ` Benjamin Gray
2023-05-30  8:59   ` [PATCH 1/2] hexagon/traps.c: " Petr Mladek
2023-05-30 12:59   ` Miguel Ojeda
2023-05-30 13:42   ` David Laight [this message]
2023-07-03  4:02   ` Michael Ellerman

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=439575eda6b24261aef4c8c7e4c078cb@AcuMS.aculab.com \
    --to=david.laight@aculab.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=mpe@ellerman.id.au \
    --cc=nathanl@linux.ibm.com \
    --cc=npiggin@gmail.com \
    --cc=ojeda@kernel.org \
    --cc=onkarnath.1@samsung.com \
    --cc=pmladek@suse.com \
    --cc=ustavoars@kernel.org \
    --cc=wedsonaf@google.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