lkml.org 
[lkml]   [2022]   [May]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 1/5] kallsyms: pass buffer size in sprint_* APIs
From
On 5/20/22 04:36, Maninder Singh wrote:
> As of now sprint_* APIs don't pass buffer size as an argument
> and use sprintf directly.
>
> To replace dangerous sprintf API to scnprintf,
> buffer size is required in arguments.
>
> 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/s390/lib/test_unwind.c | 2 +-
> drivers/scsi/fnic/fnic_trace.c | 8 ++++----
> include/linux/kallsyms.h | 20 ++++++++++----------
> init/main.c | 2 +-
> kernel/kallsyms.c | 27 ++++++++++++++++-----------
> kernel/trace/trace_output.c | 2 +-
> lib/vsprintf.c | 10 +++++-----
> 7 files changed, 38 insertions(+), 33 deletions(-)
>
> diff --git a/arch/s390/lib/test_unwind.c b/arch/s390/lib/test_unwind.c
> index 5a053b393d5c..adbc2b53db16 100644
> --- a/arch/s390/lib/test_unwind.c
> +++ b/arch/s390/lib/test_unwind.c
> @@ -75,7 +75,7 @@ static noinline int test_unwind(struct task_struct *task, struct pt_regs *regs,
> ret = -EINVAL;
> break;
> }
> - sprint_symbol(sym, addr);
> + sprint_symbol(sym, KSYM_SYMBOL_LEN, addr);

Instead of hardcoding KSYM_SYMBOL_LEN everywhere, will it better to hide
it like this:

        extern int __sprint_symbol(char *buffer, size_t size, unsigned
long address);
        #define sprint_symbol(buf, addr)        __sprint_symbol(buf,
sizeof(buf), addr)

Or you can use sizeof(buf) directly instead of KSYM_SYMBOL_LEN.

Cheers,
Longman

\
 
 \ /
  Last update: 2022-05-20 21:52    [W:0.079 / U:0.200 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site