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.
Fixes: 61968dbc2d5d ("kallsyms: increase maximum kernel symbol length to 512")
Co-developed-by: Onkarnath <redacted>
Signed-off-by: Onkarnath <redacted>
Signed-off-by: Maninder Singh <redacted>
---
arch/hexagon/kernel/traps.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 powerpc it was defined as "128" directly.
and commit '61968dbc2d5d' changed define value to 512,
So both were missed to update with new size.
Fixes: 61968dbc2d5d ("kallsyms: increase maximum kernel symbol length to 512")
Co-developed-by: Onkarnath <redacted>
Signed-off-by: Onkarnath <redacted>
Signed-off-by: Maninder Singh <redacted>
---
arch/powerpc/xmon/xmon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2023-05-30 06:45:54
Maninder Singh [off-list ref] writes:
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 powerpc it was defined as "128" directly.
and commit '61968dbc2d5d' changed define value to 512,
So both were missed to update with new size.
Fixes: 61968dbc2d5d ("kallsyms: increase maximum kernel symbol length to 512")
AFAICS that's the wrong sha.
That commit appears in linux-next, but the commit that actually went
into mainline is:
b8a94bfb3395 ("kallsyms: increase maximum kernel symbol length to 512")
So I'll update the change log to refer to that.
cheers
From: Petr Mladek <pmladek@suse.com> Date: 2023-05-30 08:59:51
On Mon 2023-05-29 16:43:36, Maninder Singh wrote:
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.
Fixes: 61968dbc2d5d ("kallsyms: increase maximum kernel symbol length to 512")
As mentioned by Michael Ellerman for the 2nd patch, the right upstream
commit is:
b8a94bfb3395 ("kallsyms: increase maximum kernel symbol length to 512")
From: Miguel Ojeda <hidden> Date: 2023-05-30 12:56:08
On Mon, May 29, 2023 at 1:14 PM Maninder Singh [off-list ref] wrote:
+static char tmpstr[KSYM_NAME_LEN];
Reviewed-by: Miguel Ojeda <ojeda@kernel.org>
Side-note: in `get_function_bounds()`, I see `kallsyms_lookup()` being
used, but the name seems discarded? Can
`kallsyms_lookup_size_offset()` be used instead, thus avoiding the
usage of the buffer there to begin with?
Side-note 2: in `scanhex()`, I see a loop `i<63` using `tmpstr` which
then is used to do a `kallsyms_lookup_name()`, so I guess symbols
larger than 64 couldn't be found. I have no idea about what are the
external constraints here, but perhaps it is possible to increase the
`line` buffer etc. to then allow for bigger symbols to be found.
Cheers,
Miguel
From: Miguel Ojeda <hidden> Date: 2023-05-30 13:00:09
On Mon, May 29, 2023 at 1:14 PM Maninder Singh [off-list ref] wrote:
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.
Fixes: 61968dbc2d5d ("kallsyms: increase maximum kernel symbol length to 512")
Co-developed-by: Onkarnath <redacted>
Signed-off-by: Onkarnath <redacted>
Signed-off-by: Maninder Singh <redacted>
With the updated commit hash:
Reviewed-by: Miguel Ojeda <ojeda@kernel.org>
Cheers,
Miguel
From: David Laight <hidden> Date: 2023-05-30 13:42:25
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
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2023-06-01 02:02:30
Miguel Ojeda [off-list ref] writes:
On Mon, May 29, 2023 at 1:14 PM Maninder Singh [off-list ref] wrote:
quoted
+static char tmpstr[KSYM_NAME_LEN];
Reviewed-by: Miguel Ojeda <ojeda@kernel.org>
Side-note: in `get_function_bounds()`, I see `kallsyms_lookup()` being
used, but the name seems discarded? Can
`kallsyms_lookup_size_offset()` be used instead, thus avoiding the
usage of the buffer there to begin with?
A few lines below it uses the modname, and AFAICS there's no (easy) way
to lookup the modname without also looking up the name.
Side-note 2: in `scanhex()`, I see a loop `i<63` using `tmpstr` which
then is used to do a `kallsyms_lookup_name()`, so I guess symbols
larger than 64 couldn't be found. I have no idea about what are the
external constraints here, but perhaps it is possible to increase the
`line` buffer etc. to then allow for bigger symbols to be found.
Yeah that looks wrong. I don't see any symbols that long in current
kernels, but we should fix it.
Thanks for looking.
cheers
From: Miguel Ojeda <hidden> Date: 2023-06-01 10:28:49
On Thu, Jun 1, 2023 at 4:02 AM Michael Ellerman [off-list ref] wrote:
quoted
Side-note: in `get_function_bounds()`, I see `kallsyms_lookup()` being
used, but the name seems discarded? Can
`kallsyms_lookup_size_offset()` be used instead, thus avoiding the
usage of the buffer there to begin with?
A few lines below it uses the modname, and AFAICS there's no (easy) way
to lookup the modname without also looking up the name.
Hmm... I think you are looking at the `xmon_print_symbol()` one? I was
referring to the `get_function_bounds()` one, where the `modname`
parameter is `NULL` (and the `name` contents are not used, only
whether it was found or not).
quoted
Side-note 2: in `scanhex()`, I see a loop `i<63` using `tmpstr` which
then is used to do a `kallsyms_lookup_name()`, so I guess symbols
larger than 64 couldn't be found. I have no idea about what are the
external constraints here, but perhaps it is possible to increase the
`line` buffer etc. to then allow for bigger symbols to be found.
Yeah that looks wrong. I don't see any symbols that long in current
kernels, but we should fix it.
Thanks for looking.
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2023-06-01 12:55:03
Miguel Ojeda [off-list ref] writes:
On Thu, Jun 1, 2023 at 4:02 AM Michael Ellerman [off-list ref] wrote:
quoted
quoted
Side-note: in `get_function_bounds()`, I see `kallsyms_lookup()` being
used, but the name seems discarded? Can
`kallsyms_lookup_size_offset()` be used instead, thus avoiding the
usage of the buffer there to begin with?
A few lines below it uses the modname, and AFAICS there's no (easy) way
to lookup the modname without also looking up the name.
Hmm... I think you are looking at the `xmon_print_symbol()` one? I was
referring to the `get_function_bounds()` one, where the `modname`
parameter is `NULL` (and the `name` contents are not used, only
whether it was found or not).
Yes you're right, apparently I can't read :}
cheers
From: Michael Ellerman <hidden> Date: 2023-07-03 05:17:25
On Mon, 29 May 2023 16:43:36 +0530, Maninder Singh wrote:
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.
[...]
From: Benjamin Gray <hidden> Date: 2023-08-03 05:47:05
On 30/5/23 10:54 pm, Miguel Ojeda wrote:
Side-note: in `get_function_bounds()`, I see `kallsyms_lookup()` being
used, but the name seems discarded? Can
`kallsyms_lookup_size_offset()` be used instead, thus avoiding the
usage of the buffer there to begin with?
I'm not familiar with the kallsyms infrastructure, but looking over the
implementations of kallsyms_lookup() and kallsyms_lookup_size_offset()
it looks like the existing kallsyms_lookup()
handles an extra case over kallsyms_lookup_size_offset()?
kallsyms_lookup_buildid() (the implementation of kallsyms_lookup()) has
/* See if it's in a module or a BPF JITed image. */
ret = module_address_lookup(addr, symbolsize, offset,
modname, modbuildid, namebuf);
if (!ret)
ret = bpf_address_lookup(addr, symbolsize,
offset, modname, namebuf);
if (!ret)
ret = ftrace_mod_address_lookup(addr, symbolsize,
offset, modname, namebuf);
while kallsyms_lookup_size_offset() is missing the ftrace case
return !!module_address_lookup(addr, symbolsize, offset,
NULL, NULL, namebuf) ||
!!__bpf_address_lookup(addr, symbolsize, offset, namebuf);
Might this be a concern for xmon?