From patchwork Fri May 20 08:36:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maninder Singh X-Patchwork-Id: 12856508 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 345FDC433F5 for ; Fri, 20 May 2022 08:39:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347247AbiETIjN (ORCPT ); Fri, 20 May 2022 04:39:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347242AbiETIjC (ORCPT ); Fri, 20 May 2022 04:39:02 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F5F69D4F3; Fri, 20 May 2022 01:39:00 -0700 (PDT) Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20220520083858epoutp01f63876db122f22a254f3048e34e755eb~ww22eq2bc2582325823epoutp01I; Fri, 20 May 2022 08:38:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20220520083858epoutp01f63876db122f22a254f3048e34e755eb~ww22eq2bc2582325823epoutp01I DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1653035938; bh=tGQbcADDC9Fa03PFlfhjPFDOHvT6aH+E1Jkc3ryxF7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tsu5EaV+kpXXRtq0bfaZOYjgr0vXVUkPsQah8PfwSdBSUlscRsrKfxiOlZlTcz7Tv CwUHypFtFHa9ibH3iF4X64NQKQWCL6SyK/HY5lChVqIgO1OdJpnxbO7Ky/Lsy5MKQb 9q6CTX8IXnAQO8jwstpIeAldIC7fTvS1kmwIy4JE= Received: from epsmges5p3new.samsung.com (unknown [182.195.42.75]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20220520083858epcas5p3b3b9c0bac758e8667d9ce6aaf1cf413f~ww22B7AA20239702397epcas5p3D; Fri, 20 May 2022 08:38:58 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 47.83.09762.2A357826; Fri, 20 May 2022 17:38:58 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20220520083725epcas5p1c3e2989c991e50603a40c81ccc4982e0~ww1fHeaQi0616006160epcas5p1U; Fri, 20 May 2022 08:37:25 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220520083724epsmtrp2c9780becbc7d0a832da74153df35b414~ww1fF2Byh1034110341epsmtrp2M; Fri, 20 May 2022 08:37:24 +0000 (GMT) X-AuditID: b6c32a4b-1fdff70000002622-27-628753a219df Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id E6.F7.08924.44357826; Fri, 20 May 2022 17:37:24 +0900 (KST) Received: from localhost.localdomain (unknown [107.109.224.44]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220520083716epsmtip24bdb8c10deccb8563372f2c9e2f53548~ww1XlR8I13055130551epsmtip2Q; Fri, 20 May 2022 08:37:16 +0000 (GMT) From: Maninder Singh To: keescook@chromium.org, pmladek@suse.com, bcain@quicinc.com, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, satishkh@cisco.com, sebaddel@cisco.com, kartilak@cisco.com, jejb@linux.ibm.com, martin.petersen@oracle.com, mcgrof@kernel.org, jason.wessel@windriver.com, daniel.thompson@linaro.org, dianders@chromium.org, naveen.n.rao@linux.ibm.com, anil.s.keshavamurthy@intel.com, davem@davemloft.net, mhiramat@kernel.org, peterz@infradead.org, mingo@redhat.com, will@kernel.org, longman@redhat.com, boqun.feng@gmail.com, rostedt@goodmis.org, senozhatsky@chromium.org, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, akpm@linux-foundation.org, arnd@arndb.de Cc: linux-hexagon@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-modules@vger.kernel.org, kgdb-bugreport@lists.sourceforge.net, v.narang@samsung.com, onkarnath.1@samsung.com, Maninder Singh Subject: [PATCH 1/5] kallsyms: pass buffer size in sprint_* APIs Date: Fri, 20 May 2022 14:06:57 +0530 Message-Id: <20220520083701.2610975-2-maninder1.s@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220520083701.2610975-1-maninder1.s@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA02TfVBUVRjGOXfvvbuss3UBzSNU1BKSNGFmO3MaHbCGhjuWjSmZ4xS6xB0g Plx3BYx/WGCLYNkGEIRdvkE+WvluQdhF4xsWcQiYVkAoBCpBwgUEDATaD5j873fe93nP8z5n 5nBY9nK2Iyc4/DIjDheG8kku3tB+wO3totMJ/u/cHOSh2jszJMqpriCRIi4TQ7qH93G0kdbF Rg90MhwZ475joQpNLIamNtpI1Dc3zkY5/abG3dJWEv2qWiHQozw1QFNdGgwVDTdgaOSGBPXJ w5CsdoBAzbf0OHosayTRkDaHRNLsVQKlFMazkPyeqTalyiPR+uomge509eCoPf97HJV1b2Jo OOVPgIrL9qPBlgIMaaQm5xvpG2xUnmwkUEVHMRt1K1owtDW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8P3mLWnP3rxIsz9u6EurYDf8R/rW9v8aU+HrVu6Depfe6t/oU3vwHTyZiiU8K5 o4oq7770NBWWtK7T6vQI8nZ8TBpGkxW/b3IfVWx8r9Nrsuftisg+Fa8kGhy5igIk1j0nT0jM mW9qmPdivg+mVe8L8A/DXDuFuCxNFBPJkcpE/wKKLVJUzwMAAA== X-CMS-MailID: 20220520083725epcas5p1c3e2989c991e50603a40c81ccc4982e0 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-CMS-RootMailID: 20220520083725epcas5p1c3e2989c991e50603a40c81ccc4982e0 References: <20220520083701.2610975-1-maninder1.s@samsung.com> Precedence: bulk List-ID: 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 Signed-off-by: Onkarnath Signed-off-by: Maninder Singh --- 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); if (bt_pos < BT_BUF_SIZE) { bt_pos += snprintf(bt + bt_pos, BT_BUF_SIZE - bt_pos, state.reliable ? " [%-7s%px] %pSR\n" : diff --git a/drivers/scsi/fnic/fnic_trace.c b/drivers/scsi/fnic/fnic_trace.c index 4a7536bb0ab3..33acaa9bb4ba 100644 --- a/drivers/scsi/fnic/fnic_trace.c +++ b/drivers/scsi/fnic/fnic_trace.c @@ -128,10 +128,10 @@ int fnic_get_trace_data(fnic_dbgfs_t *fnic_dbgfs_prt) } /* Convert function pointer to function name */ if (sizeof(unsigned long) < 8) { - sprint_symbol(str, tbp->fnaddr.low); + sprint_symbol(str, KSYM_SYMBOL_LEN, tbp->fnaddr.low); jiffies_to_timespec64(tbp->timestamp.low, &val); } else { - sprint_symbol(str, tbp->fnaddr.val); + sprint_symbol(str, KSYM_SYMBOL_LEN, tbp->fnaddr.val); jiffies_to_timespec64(tbp->timestamp.val, &val); } /* @@ -170,10 +170,10 @@ int fnic_get_trace_data(fnic_dbgfs_t *fnic_dbgfs_prt) } /* Convert function pointer to function name */ if (sizeof(unsigned long) < 8) { - sprint_symbol(str, tbp->fnaddr.low); + sprint_symbol(str, KSYM_SYMBOL_LEN, tbp->fnaddr.low); jiffies_to_timespec64(tbp->timestamp.low, &val); } else { - sprint_symbol(str, tbp->fnaddr.val); + sprint_symbol(str, KSYM_SYMBOL_LEN, tbp->fnaddr.val); jiffies_to_timespec64(tbp->timestamp.val, &val); } /* diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h index 649faac31ddb..598ff08c72d6 100644 --- a/include/linux/kallsyms.h +++ b/include/linux/kallsyms.h @@ -84,11 +84,11 @@ const char *kallsyms_lookup(unsigned long addr, char **modname, char *namebuf); /* Look up a kernel symbol and return it in a text buffer. */ -extern int sprint_symbol(char *buffer, unsigned long address); -extern int sprint_symbol_build_id(char *buffer, unsigned long address); -extern int sprint_symbol_no_offset(char *buffer, unsigned long address); -extern int sprint_backtrace(char *buffer, unsigned long address); -extern int sprint_backtrace_build_id(char *buffer, unsigned long address); +extern int sprint_symbol(char *buffer, size_t size, unsigned long address); +extern int sprint_symbol_build_id(char *buffer, size_t size, unsigned long address); +extern int sprint_symbol_no_offset(char *buffer, size_t size, unsigned long address); +extern int sprint_backtrace(char *buffer, size_t size, unsigned long address); +extern int sprint_backtrace_build_id(char *buffer, size_t size, unsigned long address); int lookup_symbol_name(unsigned long addr, char *symname); int lookup_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name); @@ -118,31 +118,31 @@ static inline const char *kallsyms_lookup(unsigned long addr, return NULL; } -static inline int sprint_symbol(char *buffer, unsigned long addr) +static inline int sprint_symbol(char *buffer, size_t size, unsigned long addr) { *buffer = '\0'; return 0; } -static inline int sprint_symbol_build_id(char *buffer, unsigned long address) +static inline int sprint_symbol_build_id(char *buffer, size_t size, unsigned long address) { *buffer = '\0'; return 0; } -static inline int sprint_symbol_no_offset(char *buffer, unsigned long addr) +static inline int sprint_symbol_no_offset(char *buffer, size_t size, unsigned long addr) { *buffer = '\0'; return 0; } -static inline int sprint_backtrace(char *buffer, unsigned long addr) +static inline int sprint_backtrace(char *buffer, size_t size, unsigned long addr) { *buffer = '\0'; return 0; } -static inline int sprint_backtrace_build_id(char *buffer, unsigned long addr) +static inline int sprint_backtrace_build_id(char *buffer, size_t size, unsigned long addr) { *buffer = '\0'; return 0; diff --git a/init/main.c b/init/main.c index 40255f110885..399a15857bf9 100644 --- a/init/main.c +++ b/init/main.c @@ -1207,7 +1207,7 @@ static bool __init_or_module initcall_blacklisted(initcall_t fn) return false; addr = (unsigned long) dereference_function_descriptor(fn); - sprint_symbol_no_offset(fn_name, addr); + sprint_symbol_no_offset(fn_name, KSYM_SYMBOL_LEN, addr); /* * fn will be "function_name [module_name]" where [module_name] is not diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index 87e2b1638115..f354378e241f 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c @@ -459,7 +459,7 @@ int lookup_symbol_attrs(unsigned long addr, unsigned long *size, } /* Look up a kernel symbol and return it in a text buffer. */ -static int __sprint_symbol(char *buffer, unsigned long address, +static int __sprint_symbol(char *buffer, size_t buf_size, unsigned long address, int symbol_offset, int add_offset, int add_buildid) { char *modname; @@ -502,6 +502,7 @@ static int __sprint_symbol(char *buffer, unsigned long address, /** * sprint_symbol - Look up a kernel symbol and return it in a text buffer * @buffer: buffer to be stored + * @size: size of buffer * @address: address to lookup * * This function looks up a kernel symbol with @address and stores its name, @@ -510,15 +511,16 @@ static int __sprint_symbol(char *buffer, unsigned long address, * * This function returns the number of bytes stored in @buffer. */ -int sprint_symbol(char *buffer, unsigned long address) +int sprint_symbol(char *buffer, size_t size, unsigned long address) { - return __sprint_symbol(buffer, address, 0, 1, 0); + return __sprint_symbol(buffer, size, address, 0, 1, 0); } EXPORT_SYMBOL_GPL(sprint_symbol); /** * sprint_symbol_build_id - Look up a kernel symbol and return it in a text buffer * @buffer: buffer to be stored + * @size: size of buffer * @address: address to lookup * * This function looks up a kernel symbol with @address and stores its name, @@ -527,15 +529,16 @@ EXPORT_SYMBOL_GPL(sprint_symbol); * * This function returns the number of bytes stored in @buffer. */ -int sprint_symbol_build_id(char *buffer, unsigned long address) +int sprint_symbol_build_id(char *buffer, size_t size, unsigned long address) { - return __sprint_symbol(buffer, address, 0, 1, 1); + return __sprint_symbol(buffer, size, address, 0, 1, 1); } EXPORT_SYMBOL_GPL(sprint_symbol_build_id); /** * sprint_symbol_no_offset - Look up a kernel symbol and return it in a text buffer * @buffer: buffer to be stored + * @size: size of buffer * @address: address to lookup * * This function looks up a kernel symbol with @address and stores its name @@ -544,15 +547,16 @@ EXPORT_SYMBOL_GPL(sprint_symbol_build_id); * * This function returns the number of bytes stored in @buffer. */ -int sprint_symbol_no_offset(char *buffer, unsigned long address) +int sprint_symbol_no_offset(char *buffer, size_t size, unsigned long address) { - return __sprint_symbol(buffer, address, 0, 0, 0); + return __sprint_symbol(buffer, size, address, 0, 0, 0); } EXPORT_SYMBOL_GPL(sprint_symbol_no_offset); /** * sprint_backtrace - Look up a backtrace symbol and return it in a text buffer * @buffer: buffer to be stored + * @size: size of buffer * @address: address to lookup * * This function is for stack backtrace and does the same thing as @@ -564,14 +568,15 @@ EXPORT_SYMBOL_GPL(sprint_symbol_no_offset); * * This function returns the number of bytes stored in @buffer. */ -int sprint_backtrace(char *buffer, unsigned long address) +int sprint_backtrace(char *buffer, size_t size, unsigned long address) { - return __sprint_symbol(buffer, address, -1, 1, 0); + return __sprint_symbol(buffer, size, address, -1, 1, 0); } /** * sprint_backtrace_build_id - Look up a backtrace symbol and return it in a text buffer * @buffer: buffer to be stored + * @size: size of buffer * @address: address to lookup * * This function is for stack backtrace and does the same thing as @@ -584,9 +589,9 @@ int sprint_backtrace(char *buffer, unsigned long address) * * This function returns the number of bytes stored in @buffer. */ -int sprint_backtrace_build_id(char *buffer, unsigned long address) +int sprint_backtrace_build_id(char *buffer, size_t size, unsigned long address) { - return __sprint_symbol(buffer, address, -1, 1, 1); + return __sprint_symbol(buffer, size, address, -1, 1, 1); } /* To avoid using get_symbol_offset for every symbol, we carry prefix along. */ diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c index 8aa493d25c73..2a6ec049cab5 100644 --- a/kernel/trace/trace_output.c +++ b/kernel/trace/trace_output.c @@ -362,7 +362,7 @@ trace_seq_print_sym(struct trace_seq *s, unsigned long address, bool offset) const char *name; if (offset) - sprint_symbol(str, address); + sprint_symbol(str, KSYM_SYMBOL_LEN, address); else kallsyms_lookup(address, NULL, NULL, NULL, str); name = kretprobed(str, address); diff --git a/lib/vsprintf.c b/lib/vsprintf.c index f8ff861ef24a..cb241b63c967 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -991,15 +991,15 @@ char *symbol_string(char *buf, char *end, void *ptr, #ifdef CONFIG_KALLSYMS if (*fmt == 'B' && fmt[1] == 'b') - sprint_backtrace_build_id(sym, value); + sprint_backtrace_build_id(sym, KSYM_SYMBOL_LEN, value); else if (*fmt == 'B') - sprint_backtrace(sym, value); + sprint_backtrace(sym, KSYM_SYMBOL_LEN, value); else if (*fmt == 'S' && (fmt[1] == 'b' || (fmt[1] == 'R' && fmt[2] == 'b'))) - sprint_symbol_build_id(sym, value); + sprint_symbol_build_id(sym, KSYM_SYMBOL_LEN, value); else if (*fmt != 's') - sprint_symbol(sym, value); + sprint_symbol(sym, KSYM_SYMBOL_LEN, value); else - sprint_symbol_no_offset(sym, value); + sprint_symbol_no_offset(sym, KSYM_SYMBOL_LEN, value); return string_nocheck(buf, end, sym, spec); #else From patchwork Fri May 20 08:36:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maninder Singh X-Patchwork-Id: 12856512 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F3C4C433F5 for ; Fri, 20 May 2022 08:40:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347363AbiETIkA (ORCPT ); Fri, 20 May 2022 04:40:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347278AbiETIjM (ORCPT ); Fri, 20 May 2022 04:39:12 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8B059E9F7; Fri, 20 May 2022 01:39:05 -0700 (PDT) Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20220520083904epoutp01d633c5bcdcb6da73271b21c597906494~ww27ZggBF2627726277epoutp01N; Fri, 20 May 2022 08:39:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20220520083904epoutp01d633c5bcdcb6da73271b21c597906494~ww27ZggBF2627726277epoutp01N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1653035944; bh=2237/Ofuxqe67/VYFRa9P3BISgr2hp9724ybcz8E9F4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u8EuLCU4damLDZX89+GSfa5zldk34IKUPwDaK6R19ZlesjN7mpBhJsbdnTTWC3qDM fObGoLvRtp1uMLJfVvZnPfccUAhB8mogz6NlgreqwZCLKObcXlegTji+lQFr2s3Flw pokB64aAUXpFmH+syf18ARawGRcf2nl2fHB5465I= Received: from epsmges5p2new.samsung.com (unknown [182.195.42.74]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20220520083903epcas5p3adf18f19c5ed99372f394308244c18ae~ww26m8o2E0240402404epcas5p3-; Fri, 20 May 2022 08:39:03 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 3F.B5.09827.7A357826; Fri, 20 May 2022 17:39:03 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220520083733epcas5p4ff2414309bf128f40b0bbd3adde52297~ww1nQxUww1594815948epcas5p4M; Fri, 20 May 2022 08:37:33 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220520083733epsmtrp1ebe1d16f82b71ff5466e4767a66bb9a8~ww1nPCU0l0237202372epsmtrp1R; Fri, 20 May 2022 08:37:33 +0000 (GMT) X-AuditID: b6c32a4a-b3bff70000002663-8c-628753a72e5d Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 12.FB.11276.D4357826; Fri, 20 May 2022 17:37:33 +0900 (KST) Received: from localhost.localdomain (unknown [107.109.224.44]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220520083725epsmtip23ee302e3ef5a51c52121b1c30ddb4167~ww1f26llB3055130551epsmtip2R; Fri, 20 May 2022 08:37:25 +0000 (GMT) From: Maninder Singh To: keescook@chromium.org, pmladek@suse.com, bcain@quicinc.com, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, satishkh@cisco.com, sebaddel@cisco.com, kartilak@cisco.com, jejb@linux.ibm.com, martin.petersen@oracle.com, mcgrof@kernel.org, jason.wessel@windriver.com, daniel.thompson@linaro.org, dianders@chromium.org, naveen.n.rao@linux.ibm.com, anil.s.keshavamurthy@intel.com, davem@davemloft.net, mhiramat@kernel.org, peterz@infradead.org, mingo@redhat.com, will@kernel.org, longman@redhat.com, boqun.feng@gmail.com, rostedt@goodmis.org, senozhatsky@chromium.org, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, akpm@linux-foundation.org, arnd@arndb.de Cc: linux-hexagon@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-modules@vger.kernel.org, kgdb-bugreport@lists.sourceforge.net, v.narang@samsung.com, onkarnath.1@samsung.com, Maninder Singh Subject: [PATCH 2/5] kallsyms: replace sprintf with scnprintf Date: Fri, 20 May 2022 14:06:58 +0530 Message-Id: <20220520083701.2610975-3-maninder1.s@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220520083701.2610975-1-maninder1.s@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA02Te0xTVxzHd27vo9QUr4jxDHQCGWwwrejEnS0oc/i4sGzBOI1blsyiN8Cg wKiKM1lWoPJGkeGAUgoFZ+VVBAtDWpSH8hglrEjkMZhgwcE0Gy9BaZBRLmb+9znfR37nd5LD 59klUQ78kPDTbFS4OMyFFOA1ze4e2zRHEgI9R7NtUGXHBImUFWUkSovNwpB+/A8cLWa0UGhE L8fRZOwFHirTxWDIvNhEIuPTIQopu5aNzmuNJPpdMUegJ6oSgMwtOgwV9tVgqL9UiowpEiSv NBHIUN+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q1akmZtqThscocthOShHOdrd3rtebrN ou+bFW9tPWu78GnsNOGwzm1sMDhu4gV4fNDh6B0vx6QOvH4geiziK0t1+6Hcr9v6FCneTc9F t71rjY29lBKhN20IqjLL+9dP/rQ9bVwe4B3ZuquJyd5b/+KJnZJiZ8njlOrbBnzykM/SR2X7 T0ddbYMGRn/ElpravGu2OGSiP3o2wcjHHUw+tzvspXGv7nHVm0ytfNtFxzbzlPTD34LL0J5/ Y2Ka72dYr8fttL5v/3KdmFAfk4WH4iq17D/cxLrazgMAAA== X-CMS-MailID: 20220520083733epcas5p4ff2414309bf128f40b0bbd3adde52297 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-CMS-RootMailID: 20220520083733epcas5p4ff2414309bf128f40b0bbd3adde52297 References: <20220520083701.2610975-1-maninder1.s@samsung.com> Precedence: bulk List-ID: replace sprintf API with scnprintf which prevents buffer overflow. Co-developed-by: Onkarnath Signed-off-by: Onkarnath Signed-off-by: Maninder Singh --- kernel/kallsyms.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index f354378e241f..9e4316fe0ba1 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c @@ -472,28 +472,29 @@ static int __sprint_symbol(char *buffer, size_t buf_size, unsigned long address, name = kallsyms_lookup_buildid(address, &size, &offset, &modname, &buildid, buffer); if (!name) - return sprintf(buffer, "0x%lx", address - symbol_offset); + return scnprintf(buffer, buf_size, "0x%lx", address - symbol_offset); if (name != buffer) - strcpy(buffer, name); + strncpy(buffer, name, buf_size); + len = strlen(buffer); offset -= symbol_offset; if (add_offset) - len += sprintf(buffer + len, "+%#lx/%#lx", offset, size); + len += scnprintf(buffer + len, buf_size - len, "+%#lx/%#lx", offset, size); if (modname) { - len += sprintf(buffer + len, " [%s", modname); + len += scnprintf(buffer + len, buf_size - len, " [%s", modname); #if IS_ENABLED(CONFIG_STACKTRACE_BUILD_ID) if (add_buildid && buildid) { /* build ID should match length of sprintf */ #if IS_ENABLED(CONFIG_MODULES) static_assert(sizeof(typeof_member(struct module, build_id)) == 20); #endif - len += sprintf(buffer + len, " %20phN", buildid); + len += scnprintf(buffer + len, buf_size - len, " %20phN", buildid); } #endif - len += sprintf(buffer + len, "]"); + len += scnprintf(buffer + len, buf_size - len, "]"); } return len; From patchwork Fri May 20 08:36:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maninder Singh X-Patchwork-Id: 12856511 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D4D0C433F5 for ; Fri, 20 May 2022 08:39:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347326AbiETIjs (ORCPT ); Fri, 20 May 2022 04:39:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347316AbiETIjU (ORCPT ); Fri, 20 May 2022 04:39:20 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED3C39D4EB; Fri, 20 May 2022 01:39:11 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220520083908epoutp04e5d832cdb53a09d97a5302b58812c15f~ww2-NMO6u0301803018epoutp04d; Fri, 20 May 2022 08:39:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220520083908epoutp04e5d832cdb53a09d97a5302b58812c15f~ww2-NMO6u0301803018epoutp04d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1653035948; bh=AhwgzerEVuyodIt2V4RrrdlfDM0bzVilGZy8x4sycs0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rB9mGpJKv/QU7ikLSrehieGW0N7+ipKkLWILLN4Zb0gO5zeQhvV3Lsj2fREzYqJK3 prI85zw5E82ahobCBB0BJAYfUdGfxlsOELX73Lsa+Ne51+tE707SQOVtbKtJQrj3pi 5SV4iFkm9nG1zthB/ni2KOBTr9exXbsxtV0zAu7c= Received: from epsmges5p2new.samsung.com (unknown [182.195.42.74]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20220520083907epcas5p12ad73903879b0f71f319779b8d6c69dc~ww2_kPNVf2141921419epcas5p1a; Fri, 20 May 2022 08:39:07 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id E4.C5.09827.BA357826; Fri, 20 May 2022 17:39:07 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220520083742epcas5p4fa741caf7079a1305ef99cf00a07054a~ww1vXeOUf0679106791epcas5p4y; Fri, 20 May 2022 08:37:42 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220520083742epsmtrp29ba296b9455ba9da4f8688efb4724e3e~ww1vUWa821034110341epsmtrp2e; Fri, 20 May 2022 08:37:42 +0000 (GMT) X-AuditID: b6c32a4a-b51ff70000002663-9b-628753ab2940 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id DD.F7.08924.65357826; Fri, 20 May 2022 17:37:42 +0900 (KST) Received: from localhost.localdomain (unknown [107.109.224.44]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220520083734epsmtip22c4d3ea9b7cead988478e126befdfaea~ww1n_Xarw2680526805epsmtip2X; Fri, 20 May 2022 08:37:34 +0000 (GMT) From: Maninder Singh To: keescook@chromium.org, pmladek@suse.com, bcain@quicinc.com, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, satishkh@cisco.com, sebaddel@cisco.com, kartilak@cisco.com, jejb@linux.ibm.com, martin.petersen@oracle.com, mcgrof@kernel.org, jason.wessel@windriver.com, daniel.thompson@linaro.org, dianders@chromium.org, naveen.n.rao@linux.ibm.com, anil.s.keshavamurthy@intel.com, davem@davemloft.net, mhiramat@kernel.org, peterz@infradead.org, mingo@redhat.com, will@kernel.org, longman@redhat.com, boqun.feng@gmail.com, rostedt@goodmis.org, senozhatsky@chromium.org, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, akpm@linux-foundation.org, arnd@arndb.de Cc: linux-hexagon@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-modules@vger.kernel.org, kgdb-bugreport@lists.sourceforge.net, v.narang@samsung.com, onkarnath.1@samsung.com, Maninder Singh Subject: [PATCH 3/5] arch:hexagon/powerpc: use KSYM_NAME_LEN as array size Date: Fri, 20 May 2022 14:06:59 +0530 Message-Id: <20220520083701.2610975-4-maninder1.s@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220520083701.2610975-1-maninder1.s@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA02Te0xTVxzHPffe3hZM3aWYcIabLmRdAmrd3CQnZPLYnF7IHrJlDxbHLHID jGdaGGyJsWAFeW0NgkBbK48IyNNqFWwLw7KUhyivbIA8BlISmAiF8thogNEWM//7/s738833 /E5yODgvi+3OiYpLZERxwhgP0pm41+bpebjmi4ywt8euQ6R+OEsiZUMtiXLTC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HsNOvPJBS0HhRVtyiU+6dd4gTzhD7ta9UWLd Y1CqK17vmNsYdiWuNPrh04elfE0Wvu9U3A7GlPhn7+5c+23D/Bkp9rIlasP3nYYTd76ZfTiq yhg6aPPpUjP9h4Qjybpj7HkqbENavrXcUsG9Orn00hXNMzyVMSLOGKPRO4s1e3qefEvj+Mw7 mpLQexjei97uyUv2pWpyXRtVP4QMxFf0xaRs8+hDrhLJbRH+I1uPSztjNk9GpXTX7c3xFXzY eG/aROvGJU9t35eUd6jhgPNeetrOanHU2Yk4O0Z/qsynmoaTaJG+JQE3PVKHFosLCwpDbD7L /l0xi/eLxOkNt1Hbjkicz1TExwq0vOI/7edTGNEDAAA= X-CMS-MailID: 20220520083742epcas5p4fa741caf7079a1305ef99cf00a07054a X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-CMS-RootMailID: 20220520083742epcas5p4fa741caf7079a1305ef99cf00a07054a References: <20220520083701.2610975-1-maninder1.s@samsung.com> Precedence: bulk List-ID: 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 and 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") Signed-off-by: Maninder Singh --- arch/hexagon/kernel/traps.c | 2 +- arch/powerpc/xmon/xmon.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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; diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c index afc827c65ff2..3441fc70ac92 100644 --- a/arch/powerpc/xmon/xmon.c +++ b/arch/powerpc/xmon/xmon.c @@ -91,7 +91,7 @@ static unsigned long ndump = 64; static unsigned long nidump = 16; static unsigned long ncsum = 4096; static int termch; -static char tmpstr[128]; +static char tmpstr[KSYM_NAME_LEN]; static int tracing_enabled; static long bus_error_jmp[JMP_BUF_LEN]; From patchwork Fri May 20 08:37:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maninder Singh X-Patchwork-Id: 12856510 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 054D7C433FE for ; Fri, 20 May 2022 08:39:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344602AbiETIjr (ORCPT ); Fri, 20 May 2022 04:39:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347327AbiETIjV (ORCPT ); Fri, 20 May 2022 04:39:21 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1031FB0A5F; Fri, 20 May 2022 01:39:13 -0700 (PDT) Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220520083912epoutp04475d86947c29a6a873fdc8406b40b7e1~ww3C0Uw8c0301803018epoutp04f; Fri, 20 May 2022 08:39:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220520083912epoutp04475d86947c29a6a873fdc8406b40b7e1~ww3C0Uw8c0301803018epoutp04f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1653035952; bh=DWp8DOllJXXACHeuxZYMqjT1Q6GxgVAt1nlrOcuuYKs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aqyOA/9F/aqly1EbRo/oFIoK5BewuquEYc8yevnVyWmIy4ccuH79VM09FPBLBPWvv G6FDEkjOuWZ7lM0zHsWizBeUsLzdtuOoCwqI0i8QOiNP+CQ8tV3ISWpFd5+LvDglJL 8tFpQfttPl2SFb3NDSCYJF4qkDQJvuc95FAVkpsU= Received: from epsmges5p1new.samsung.com (unknown [182.195.42.73]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20220520083911epcas5p238389a60a0a4934fe1a985838830625b~ww3B0v7li2019220192epcas5p2r; Fri, 20 May 2022 08:39:11 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id C5.40.10063.EA357826; Fri, 20 May 2022 17:39:10 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220520083755epcas5p454d450935fb427fd270295e967b0cbe8~ww17gzPkq1594815948epcas5p4s; Fri, 20 May 2022 08:37:55 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220520083755epsmtrp120d9f1f2072e0aacf3e6792cce6989f9~ww17d_Udb0237202372epsmtrp1b; Fri, 20 May 2022 08:37:55 +0000 (GMT) X-AuditID: b6c32a49-4cbff7000000274f-06-628753ae135c Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 8A.FB.11276.36357826; Fri, 20 May 2022 17:37:55 +0900 (KST) Received: from localhost.localdomain (unknown [107.109.224.44]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220520083747epsmtip215081bd0146d158931317d338b0869db~ww10EHZ-M3025030250epsmtip2w; Fri, 20 May 2022 08:37:47 +0000 (GMT) From: Maninder Singh To: keescook@chromium.org, pmladek@suse.com, bcain@quicinc.com, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, satishkh@cisco.com, sebaddel@cisco.com, kartilak@cisco.com, jejb@linux.ibm.com, martin.petersen@oracle.com, mcgrof@kernel.org, jason.wessel@windriver.com, daniel.thompson@linaro.org, dianders@chromium.org, naveen.n.rao@linux.ibm.com, anil.s.keshavamurthy@intel.com, davem@davemloft.net, mhiramat@kernel.org, peterz@infradead.org, mingo@redhat.com, will@kernel.org, longman@redhat.com, boqun.feng@gmail.com, rostedt@goodmis.org, senozhatsky@chromium.org, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, akpm@linux-foundation.org, arnd@arndb.de Cc: linux-hexagon@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-modules@vger.kernel.org, kgdb-bugreport@lists.sourceforge.net, v.narang@samsung.com, onkarnath.1@samsung.com, Maninder Singh Subject: [PATCH 4/5] kallsyms: pass buffer size argument in *lookup* APIs Date: Fri, 20 May 2022 14:07:00 +0530 Message-Id: <20220520083701.2610975-5-maninder1.s@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220520083701.2610975-1-maninder1.s@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA02Te0yTZxTG9379+vWSdftWXHgBNw2KEcyqzDHeZUbcYshHyBYW3ZwmGxZs QKFYW4FtMdJixyaloVaMpXTcOpHbioWCSAsCdVwEkUvGRS4y6YRq54ANyCCFtRQy//udc54n zzlv8jJpXCXDl3k66bxAnMRP9CfYeJ01MPAdw5EfYvbV1IYiY5edQLqq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uQtDKd4T0ftIhJOCVvEjSbJyHTBTfc0kzMk/Ktp Z1T43ZVy845npfWulC5Dx92t/ZuMheJ94Yptu7y7nR5109vLlD4/Tvq0+ghrzX1ZM9j9ZLr7 suDD8Kx/0qJte9OJyeXGVXmZ9sS9uITNeh9t7i/IX70RnSbbkrFaFvHi0U0Di8aVraqmW0ym 2PZv6kzE6fnnEvaGUf1tjaizLXWyoWZg4czlN6nZ22N9umtxHy0ankpyzA68tEe8Pe1bPNQP R/Pe31ei/D2y89095i+PDb3ly/aU2Ba2vWLl76diSVHjj2nlx1Jej2LbNW8c+vhBmXX+fHNR 7+Pv9CZ/MfaqQ6GOIVQHJImxuFIl+Q+u8EN70gMAAA== X-CMS-MailID: 20220520083755epcas5p454d450935fb427fd270295e967b0cbe8 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-CMS-RootMailID: 20220520083755epcas5p454d450935fb427fd270295e967b0cbe8 References: <20220520083701.2610975-1-maninder1.s@samsung.com> Precedence: bulk List-ID: Although *lookup* APIs are safe, but better to pass size as an argument rather than using define KSYM_NAME_LEN. Because it can cause issue if called with lesser array size. Co-developed-by: Onkarnath Signed-off-by: Onkarnath Signed-off-by: Maninder Singh --- arch/hexagon/kernel/traps.c | 2 +- arch/powerpc/xmon/xmon.c | 4 ++-- fs/proc/base.c | 2 +- include/linux/kallsyms.h | 8 ++++---- include/linux/module.h | 8 ++++---- kernel/debug/kdb/kdb_support.c | 2 +- kernel/kallsyms.c | 24 ++++++++++++------------ kernel/kprobes.c | 4 ++-- kernel/locking/lockdep.c | 8 ++++---- kernel/locking/lockdep_internals.h | 2 +- kernel/locking/lockdep_proc.c | 4 ++-- kernel/module/kallsyms.c | 8 ++++---- kernel/trace/ftrace.c | 9 +++++---- kernel/trace/trace_kprobe.c | 2 +- kernel/trace/trace_output.c | 2 +- kernel/trace/trace_syscalls.c | 2 +- 16 files changed, 46 insertions(+), 45 deletions(-) diff --git a/arch/hexagon/kernel/traps.c b/arch/hexagon/kernel/traps.c index 65b30b6ea226..a0306e96e82c 100644 --- a/arch/hexagon/kernel/traps.c +++ b/arch/hexagon/kernel/traps.c @@ -118,7 +118,7 @@ static void do_show_stack(struct task_struct *task, unsigned long *fp, for (i = 0; i < kstack_depth_to_print; i++) { - name = kallsyms_lookup(ip, &size, &offset, &modname, tmpstr); + name = kallsyms_lookup(ip, &size, &offset, &modname, tmpstr, KSYM_NAME_LEN); printk("%s[%p] 0x%lx: %s + 0x%lx", loglvl, fp, ip, name, offset); if (((unsigned long) fp < low) || (high < (unsigned long) fp)) diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c index 3441fc70ac92..183e2a55ba5c 100644 --- a/arch/powerpc/xmon/xmon.c +++ b/arch/powerpc/xmon/xmon.c @@ -1710,7 +1710,7 @@ static void get_function_bounds(unsigned long pc, unsigned long *startp, if (setjmp(bus_error_jmp) == 0) { catch_memory_errors = 1; sync(); - name = kallsyms_lookup(pc, &size, &offset, NULL, tmpstr); + name = kallsyms_lookup(pc, &size, &offset, NULL, tmpstr, KSYM_NAME_LEN); if (name != NULL) { *startp = pc - offset; *endp = pc - offset + size; @@ -3730,7 +3730,7 @@ static void xmon_print_symbol(unsigned long address, const char *mid, catch_memory_errors = 1; sync(); name = kallsyms_lookup(address, &size, &offset, &modname, - tmpstr); + tmpstr, KSYM_NAME_LEN); sync(); /* wait a little while to see if we get a machine check */ __delay(200); diff --git a/fs/proc/base.c b/fs/proc/base.c index 617816168748..939006f3b2b0 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -392,7 +392,7 @@ static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns, goto print0; wchan = get_wchan(task); - if (wchan && !lookup_symbol_name(wchan, symname)) { + if (wchan && !lookup_symbol_name(wchan, symname, KSYM_NAME_LEN)) { seq_puts(m, symname); return 0; } diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h index 598ff08c72d6..8fe535fd848a 100644 --- a/include/linux/kallsyms.h +++ b/include/linux/kallsyms.h @@ -81,7 +81,7 @@ extern int kallsyms_lookup_size_offset(unsigned long addr, const char *kallsyms_lookup(unsigned long addr, unsigned long *symbolsize, unsigned long *offset, - char **modname, char *namebuf); + char **modname, char *namebuf, size_t size); /* Look up a kernel symbol and return it in a text buffer. */ extern int sprint_symbol(char *buffer, size_t size, unsigned long address); @@ -90,7 +90,7 @@ extern int sprint_symbol_no_offset(char *buffer, size_t size, unsigned long addr extern int sprint_backtrace(char *buffer, size_t size, unsigned long address); extern int sprint_backtrace_build_id(char *buffer, size_t size, unsigned long address); -int lookup_symbol_name(unsigned long addr, char *symname); +int lookup_symbol_name(unsigned long addr, char *symname, size_t size); int lookup_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name); /* How and when do we show kallsyms values? */ @@ -113,7 +113,7 @@ static inline int kallsyms_lookup_size_offset(unsigned long addr, static inline const char *kallsyms_lookup(unsigned long addr, unsigned long *symbolsize, unsigned long *offset, - char **modname, char *namebuf) + char **modname, char *namebuf, size_t size) { return NULL; } @@ -148,7 +148,7 @@ static inline int sprint_backtrace_build_id(char *buffer, size_t size, unsigned return 0; } -static inline int lookup_symbol_name(unsigned long addr, char *symname) +static inline int lookup_symbol_name(unsigned long addr, char *symname, size_t size) { return -ERANGE; } diff --git a/include/linux/module.h b/include/linux/module.h index abd9fa916b7d..9b91209d615f 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -656,8 +656,8 @@ const char *module_address_lookup(unsigned long addr, unsigned long *symbolsize, unsigned long *offset, char **modname, const unsigned char **modbuildid, - char *namebuf); -int lookup_module_symbol_name(unsigned long addr, char *symname); + char *namebuf, size_t buf_size); +int lookup_module_symbol_name(unsigned long addr, char *symname, size_t size); int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name); int register_module_notifier(struct notifier_block *nb); @@ -756,12 +756,12 @@ static inline const char *module_address_lookup(unsigned long addr, unsigned long *offset, char **modname, const unsigned char **modbuildid, - char *namebuf) + char *namebuf, size_t buf_size) { return NULL; } -static inline int lookup_module_symbol_name(unsigned long addr, char *symname) +static inline int lookup_module_symbol_name(unsigned long addr, char *symname, size_t size) { return -ERANGE; } diff --git a/kernel/debug/kdb/kdb_support.c b/kernel/debug/kdb/kdb_support.c index 0a39497140bf..bf19e9587c23 100644 --- a/kernel/debug/kdb/kdb_support.c +++ b/kernel/debug/kdb/kdb_support.c @@ -92,7 +92,7 @@ int kdbnearsym(unsigned long addr, kdb_symtab_t *symtab) goto out; symtab->sym_name = kallsyms_lookup(addr, &symbolsize , &offset, - (char **)(&symtab->mod_name), namebuf); + (char **)(&symtab->mod_name), namebuf, KSYM_NAME_LEN); if (offset > 8*1024*1024) { symtab->sym_name = NULL; addr = offset = symbolsize = 0; diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index 9e4316fe0ba1..d6efce28505d 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c @@ -342,18 +342,18 @@ int kallsyms_lookup_size_offset(unsigned long addr, unsigned long *symbolsize, get_symbol_pos(addr, symbolsize, offset); return 1; } - return !!module_address_lookup(addr, symbolsize, offset, NULL, NULL, namebuf) || + return !!module_address_lookup(addr, symbolsize, offset, NULL, NULL, namebuf, KSYM_NAME_LEN) || !!__bpf_address_lookup(addr, symbolsize, offset, namebuf); } static const char *kallsyms_lookup_buildid(unsigned long addr, unsigned long *symbolsize, unsigned long *offset, char **modname, - const unsigned char **modbuildid, char *namebuf) + const unsigned char **modbuildid, char *namebuf, size_t size) { const char *ret; - namebuf[KSYM_NAME_LEN - 1] = 0; + namebuf[size - 1] = 0; namebuf[0] = 0; if (is_ksym_addr(addr)) { @@ -362,7 +362,7 @@ static const char *kallsyms_lookup_buildid(unsigned long addr, pos = get_symbol_pos(addr, symbolsize, offset); /* Grab name */ kallsyms_expand_symbol(get_symbol_offset(pos), - namebuf, KSYM_NAME_LEN); + namebuf, size); if (modname) *modname = NULL; if (modbuildid) @@ -374,7 +374,7 @@ static const char *kallsyms_lookup_buildid(unsigned long addr, /* See if it's in a module or a BPF JITed image. */ ret = module_address_lookup(addr, symbolsize, offset, - modname, modbuildid, namebuf); + modname, modbuildid, namebuf, size); if (!ret) ret = bpf_address_lookup(addr, symbolsize, offset, modname, namebuf); @@ -398,18 +398,18 @@ static const char *kallsyms_lookup_buildid(unsigned long addr, const char *kallsyms_lookup(unsigned long addr, unsigned long *symbolsize, unsigned long *offset, - char **modname, char *namebuf) + char **modname, char *namebuf, size_t size) { return kallsyms_lookup_buildid(addr, symbolsize, offset, modname, - NULL, namebuf); + NULL, namebuf, size); } -int lookup_symbol_name(unsigned long addr, char *symname) +int lookup_symbol_name(unsigned long addr, char *symname, size_t size) { int res; symname[0] = '\0'; - symname[KSYM_NAME_LEN - 1] = '\0'; + symname[size - 1] = '\0'; if (is_ksym_addr(addr)) { unsigned long pos; @@ -417,11 +417,11 @@ int lookup_symbol_name(unsigned long addr, char *symname) pos = get_symbol_pos(addr, NULL, NULL); /* Grab name */ kallsyms_expand_symbol(get_symbol_offset(pos), - symname, KSYM_NAME_LEN); + symname, size); goto found; } /* See if it's in a module. */ - res = lookup_module_symbol_name(addr, symname); + res = lookup_module_symbol_name(addr, symname, size); if (res) return res; @@ -470,7 +470,7 @@ static int __sprint_symbol(char *buffer, size_t buf_size, unsigned long address, address += symbol_offset; name = kallsyms_lookup_buildid(address, &size, &offset, &modname, &buildid, - buffer); + buffer, buf_size); if (!name) return scnprintf(buffer, buf_size, "0x%lx", address - symbol_offset); diff --git a/kernel/kprobes.c b/kernel/kprobes.c index dd58c0be9ce2..3b362b70e72b 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -1478,7 +1478,7 @@ bool within_kprobe_blacklist(unsigned long addr) return true; /* Check if the address is on a suffixed-symbol */ - if (!lookup_symbol_name(addr, symname)) { + if (!lookup_symbol_name(addr, symname, KSYM_NAME_LEN)) { p = strchr(symname, '.'); if (!p) return false; @@ -2806,7 +2806,7 @@ static int show_kprobe_addr(struct seq_file *pi, void *v) preempt_disable(); hlist_for_each_entry_rcu(p, head, hlist) { sym = kallsyms_lookup((unsigned long)p->addr, NULL, - &offset, &modname, namebuf); + &offset, &modname, namebuf, KSYM_NAME_LEN); if (kprobe_aggrprobe(p)) { list_for_each_entry_rcu(kp, &p->list, list) report_probe(pi, kp, sym, offset, modname, p); diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 81e87280513e..c74bbf90fdfb 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -659,9 +659,9 @@ static const char *usage_str[] = }; #endif -const char *__get_key_name(const struct lockdep_subclass_key *key, char *str) +const char *__get_key_name(const struct lockdep_subclass_key *key, char *str, size_t size) { - return kallsyms_lookup((unsigned long)key, NULL, NULL, NULL, str); + return kallsyms_lookup((unsigned long)key, NULL, NULL, NULL, str, size); } static inline unsigned long lock_flag(enum lock_usage_bit bit) @@ -715,7 +715,7 @@ static void __print_lock_name(struct lock_class *class) name = class->name; if (!name) { - name = __get_key_name(class->key, str); + name = __get_key_name(class->key, str, KSYM_NAME_LEN); printk(KERN_CONT "%s", name); } else { printk(KERN_CONT "%s", name); @@ -746,7 +746,7 @@ static void print_lockdep_cache(struct lockdep_map *lock) name = lock->name; if (!name) - name = __get_key_name(lock->key->subkeys, str); + name = __get_key_name(lock->key->subkeys, str, KSYM_NAME_LEN); printk(KERN_CONT "%s", name); } diff --git a/kernel/locking/lockdep_internals.h b/kernel/locking/lockdep_internals.h index bbe9000260d0..ab32ee6a0c87 100644 --- a/kernel/locking/lockdep_internals.h +++ b/kernel/locking/lockdep_internals.h @@ -129,7 +129,7 @@ extern void get_usage_chars(struct lock_class *class, char usage[LOCK_USAGE_CHARS]); extern const char *__get_key_name(const struct lockdep_subclass_key *key, - char *str); + char *str, size_t size); struct lock_class *lock_chain_get_class(struct lock_chain *chain, int i); diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c index 15fdc7fa5c68..bf4ca5ec109e 100644 --- a/kernel/locking/lockdep_proc.c +++ b/kernel/locking/lockdep_proc.c @@ -63,7 +63,7 @@ static void print_name(struct seq_file *m, struct lock_class *class) const char *name = class->name; if (!name) { - name = __get_key_name(class->key, str); + name = __get_key_name(class->key, str, KSYM_NAME_LEN); seq_printf(m, "%s", name); } else{ seq_printf(m, "%s", name); @@ -485,7 +485,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data) char str[KSYM_NAME_LEN]; const char *key_name; - key_name = __get_key_name(ckey, str); + key_name = __get_key_name(ckey, str, KSYM_NAME_LEN); snprintf(name, namelen, "%s", key_name); } else { snprintf(name, namelen, "%s", cname); diff --git a/kernel/module/kallsyms.c b/kernel/module/kallsyms.c index 3e11523bc6f6..c982860405c6 100644 --- a/kernel/module/kallsyms.c +++ b/kernel/module/kallsyms.c @@ -320,7 +320,7 @@ const char *module_address_lookup(unsigned long addr, unsigned long *offset, char **modname, const unsigned char **modbuildid, - char *namebuf) + char *namebuf, size_t buf_size) { const char *ret = NULL; struct module *mod; @@ -342,7 +342,7 @@ const char *module_address_lookup(unsigned long addr, } /* Make a copy in here where it's safe */ if (ret) { - strncpy(namebuf, ret, KSYM_NAME_LEN - 1); + strncpy(namebuf, ret, buf_size - 1); ret = namebuf; } preempt_enable(); @@ -350,7 +350,7 @@ const char *module_address_lookup(unsigned long addr, return ret; } -int lookup_module_symbol_name(unsigned long addr, char *symname) +int lookup_module_symbol_name(unsigned long addr, char *symname, size_t size) { struct module *mod; @@ -365,7 +365,7 @@ int lookup_module_symbol_name(unsigned long addr, char *symname) if (!sym) goto out; - strscpy(symname, sym, KSYM_NAME_LEN); + strscpy(symname, sym, size); preempt_enable(); return 0; } diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index c12bcd26cb17..4d9a8621eaac 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -520,7 +520,7 @@ static int function_stat_show(struct seq_file *m, void *v) goto out; #endif - kallsyms_lookup(rec->ip, NULL, NULL, NULL, str); + kallsyms_lookup(rec->ip, NULL, NULL, NULL, str, KSYM_SYMBOL_LEN); seq_printf(m, " %-30.30s %10lu", str, rec->counter); #ifdef CONFIG_FUNCTION_GRAPH_TRACER @@ -3980,7 +3980,7 @@ ftrace_match_record(struct dyn_ftrace *rec, struct ftrace_glob *func_g, char str[KSYM_SYMBOL_LEN]; char *modname; - kallsyms_lookup(rec->ip, NULL, NULL, &modname, str); + kallsyms_lookup(rec->ip, NULL, NULL, &modname, str, KSYM_SYMBOL_LEN); if (mod_g) { int mod_matches = (modname) ? ftrace_match(modname, mod_g) : 0; @@ -4738,7 +4738,7 @@ unregister_ftrace_function_probe_func(char *glob, struct trace_array *tr, if (func_g.search) { kallsyms_lookup(entry->ip, NULL, NULL, - NULL, str); + NULL, str, KSYM_SYMBOL_LEN); if (!ftrace_match(str, &func_g)) continue; } @@ -6846,7 +6846,8 @@ static void save_ftrace_mod_rec(struct ftrace_mod_map *mod_map, char *modname; const char *ret; - ret = kallsyms_lookup(rec->ip, &symsize, &offset, &modname, str); + ret = kallsyms_lookup(rec->ip, &symsize, &offset, &modname, + str, KSYM_SYMBOL_LEN); if (!ret) return; diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 47cebef78532..8a1d2a0dc2dc 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -456,7 +456,7 @@ static bool within_notrace_func(struct trace_kprobe *tk) return false; /* Check if the address is on a suffixed-symbol */ - if (!lookup_symbol_name(addr, symname)) { + if (!lookup_symbol_name(addr, symname, KSYM_NAME_LEN)) { p = strchr(symname, '.'); if (!p) return true; diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c index 2a6ec049cab5..0d3e1c9b59fb 100644 --- a/kernel/trace/trace_output.c +++ b/kernel/trace/trace_output.c @@ -364,7 +364,7 @@ trace_seq_print_sym(struct trace_seq *s, unsigned long address, bool offset) if (offset) sprint_symbol(str, KSYM_SYMBOL_LEN, address); else - kallsyms_lookup(address, NULL, NULL, NULL, str); + kallsyms_lookup(address, NULL, NULL, NULL, str, KSYM_SYMBOL_LEN); name = kretprobed(str, address); if (name && strlen(name)) { diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c index f755bde42fd0..3a67877ce658 100644 --- a/kernel/trace/trace_syscalls.c +++ b/kernel/trace/trace_syscalls.c @@ -89,7 +89,7 @@ find_syscall_meta(unsigned long syscall) start = __start_syscalls_metadata; stop = __stop_syscalls_metadata; - kallsyms_lookup(syscall, NULL, NULL, NULL, str); + kallsyms_lookup(syscall, NULL, NULL, NULL, str, KSYM_SYMBOL_LEN); if (arch_syscall_match_sym_name(str, "sys_ni_syscall")) return NULL; From patchwork Fri May 20 08:37:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maninder Singh X-Patchwork-Id: 12856509 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 455DEC433EF for ; Fri, 20 May 2022 08:39:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347328AbiETIjb (ORCPT ); Fri, 20 May 2022 04:39:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344602AbiETIjZ (ORCPT ); Fri, 20 May 2022 04:39:25 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 146F7AFAED; Fri, 20 May 2022 01:39:19 -0700 (PDT) Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220520083916epoutp023cb1a42d725b95d6d8f1594f01295d96~ww3GiYS5L1883218832epoutp02L; Fri, 20 May 2022 08:39:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220520083916epoutp023cb1a42d725b95d6d8f1594f01295d96~ww3GiYS5L1883218832epoutp02L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1653035956; bh=UsfrS4UvuS4dFM05SqF8Ta7tbBY/QrlkptYTWqQNH+E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aia/QyHkPpm/zR9tj4Cj7Hno19svunmYHyHwsInquziQDKY6IlXghgdpNSmRLJkwO rMMgMNRRTwdODovo4wXmgmRKS2FfG2tsdIrmOBUT4Rusv/VF9vkaCQC3zAi4lJgly2 CJZrPhtTbfKzpzk8glBclSgx019w9KpRKn0+ZccE= Received: from epsmges5p3new.samsung.com (unknown [182.195.42.75]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20220520083915epcas5p4ec28bb7c4b401490d717d8b028e47e93~ww3FwITUq1733217332epcas5p44; Fri, 20 May 2022 08:39:15 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 5B.93.09762.3B357826; Fri, 20 May 2022 17:39:15 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220520083805epcas5p40642f5a7f9844c61792cd3ac41ac01d3~ww2E389Eb1223812238epcas5p4E; Fri, 20 May 2022 08:38:05 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220520083805epsmtrp14fa161785f4b8b8d2ec9823b3eae2ad9~ww2E2p3KN0239102391epsmtrp1b; Fri, 20 May 2022 08:38:05 +0000 (GMT) X-AuditID: b6c32a4b-1fdff70000002622-65-628753b319ca Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 25.08.08924.D6357826; Fri, 20 May 2022 17:38:05 +0900 (KST) Received: from localhost.localdomain (unknown [107.109.224.44]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220520083757epsmtip233116cea119605d9acfdc1abbb98de9a~ww19d5gaj3055430554epsmtip28; Fri, 20 May 2022 08:37:57 +0000 (GMT) From: Maninder Singh To: keescook@chromium.org, pmladek@suse.com, bcain@quicinc.com, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, satishkh@cisco.com, sebaddel@cisco.com, kartilak@cisco.com, jejb@linux.ibm.com, martin.petersen@oracle.com, mcgrof@kernel.org, jason.wessel@windriver.com, daniel.thompson@linaro.org, dianders@chromium.org, naveen.n.rao@linux.ibm.com, anil.s.keshavamurthy@intel.com, davem@davemloft.net, mhiramat@kernel.org, peterz@infradead.org, mingo@redhat.com, will@kernel.org, longman@redhat.com, boqun.feng@gmail.com, rostedt@goodmis.org, senozhatsky@chromium.org, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, akpm@linux-foundation.org, arnd@arndb.de Cc: linux-hexagon@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-modules@vger.kernel.org, kgdb-bugreport@lists.sourceforge.net, v.narang@samsung.com, onkarnath.1@samsung.com, Maninder Singh Subject: [PATCH 5/5] kallsyms: remove unsed API lookup_symbol_attrs Date: Fri, 20 May 2022 14:07:01 +0530 Message-Id: <20220520083701.2610975-6-maninder1.s@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220520083701.2610975-1-maninder1.s@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAA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Te6xF1jPvUe Pe5zhHZhsLFUN5Lr/Su0re7v0M4J9hdvazlViNK8oDQvqAaE6dGrbJ5Cmi1V7Mx7S8Z+laiQ SBX5suzEz09Kb6HQi4nF3cikX0w0I4yHzIjmcUSRYUiqyhKGHZMUnGXlJzPl+bmswoxieLho Y9hwmS1TSGVLTrFfsGweK//fYjx+tBI7YTQmGeJnde6MidSi0iTVmQGXzukLXw0Pm9k6mbDP 942sfLfk7a9lfv/RykPuHe5DHanTFbrph0eYp+fTV9Rfnk+98rtNkHM6OS7jWUG/Y/cd/i+F aV6zs9k6S+79fv8ndm3xhN7kOMHJlFrISiYeb4lq5be0PUpfeGfTOZ5hxZMp9tcMHNjy6eEN +qRsdUTlk4Vau2BMNnw7P6Fkv3nznrqX5g98cLREXdKtvhp12X/zp8dpvr9Syy6oLTHuubMH 7wtmz/25a+z5+60bVWmvf7jJLrNu8bhFrqjtkckb3hgZSv+uaC78tcMfCzQJj1MiJrcuZhkL 4t3e5SPvGl/uUsVtFuGKHMlOMUeukPwLrdBORtEDAAA= X-CMS-MailID: 20220520083805epcas5p40642f5a7f9844c61792cd3ac41ac01d3 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-CMS-RootMailID: 20220520083805epcas5p40642f5a7f9844c61792cd3ac41ac01d3 References: <20220520083701.2610975-1-maninder1.s@samsung.com> Precedence: bulk List-ID: with commit '7878c231dae0 ("slab: remove /proc/slab_allocators")' lookup_symbol_attrs usage is removed. Thus removing redundant API. Signed-off-by: Maninder Singh --- include/linux/kallsyms.h | 6 ------ include/linux/module.h | 6 ------ kernel/kallsyms.c | 28 ---------------------------- kernel/module/kallsyms.c | 28 ---------------------------- 4 files changed, 68 deletions(-) diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h index 8fe535fd848a..b78e9d942a77 100644 --- a/include/linux/kallsyms.h +++ b/include/linux/kallsyms.h @@ -91,7 +91,6 @@ extern int sprint_backtrace(char *buffer, size_t size, unsigned long address); extern int sprint_backtrace_build_id(char *buffer, size_t size, unsigned long address); int lookup_symbol_name(unsigned long addr, char *symname, size_t size); -int lookup_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name); /* How and when do we show kallsyms values? */ extern bool kallsyms_show_value(const struct cred *cred); @@ -153,11 +152,6 @@ static inline int lookup_symbol_name(unsigned long addr, char *symname, size_t s return -ERANGE; } -static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name) -{ - return -ERANGE; -} - static inline bool kallsyms_show_value(const struct cred *cred) { return false; diff --git a/include/linux/module.h b/include/linux/module.h index 9b91209d615f..4c5f8f99a252 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -658,7 +658,6 @@ const char *module_address_lookup(unsigned long addr, char **modname, const unsigned char **modbuildid, char *namebuf, size_t buf_size); int lookup_module_symbol_name(unsigned long addr, char *symname, size_t size); -int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name); int register_module_notifier(struct notifier_block *nb); int unregister_module_notifier(struct notifier_block *nb); @@ -766,11 +765,6 @@ static inline int lookup_module_symbol_name(unsigned long addr, char *symname, s return -ERANGE; } -static inline int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name) -{ - return -ERANGE; -} - static inline int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, char *name, char *module_name, int *exported) diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index d6efce28505d..96ad59b5b2fd 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c @@ -430,34 +430,6 @@ int lookup_symbol_name(unsigned long addr, char *symname, size_t size) return 0; } -int lookup_symbol_attrs(unsigned long addr, unsigned long *size, - unsigned long *offset, char *modname, char *name) -{ - int res; - - name[0] = '\0'; - name[KSYM_NAME_LEN - 1] = '\0'; - - if (is_ksym_addr(addr)) { - unsigned long pos; - - pos = get_symbol_pos(addr, size, offset); - /* Grab name */ - kallsyms_expand_symbol(get_symbol_offset(pos), - name, KSYM_NAME_LEN); - modname[0] = '\0'; - goto found; - } - /* See if it's in a module. */ - res = lookup_module_symbol_attrs(addr, size, offset, modname, name); - if (res) - return res; - -found: - cleanup_symbol_name(name); - return 0; -} - /* Look up a kernel symbol and return it in a text buffer. */ static int __sprint_symbol(char *buffer, size_t buf_size, unsigned long address, int symbol_offset, int add_offset, int add_buildid) diff --git a/kernel/module/kallsyms.c b/kernel/module/kallsyms.c index c982860405c6..e6f16c62a888 100644 --- a/kernel/module/kallsyms.c +++ b/kernel/module/kallsyms.c @@ -375,34 +375,6 @@ int lookup_module_symbol_name(unsigned long addr, char *symname, size_t size) return -ERANGE; } -int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, - unsigned long *offset, char *modname, char *name) -{ - struct module *mod; - - preempt_disable(); - list_for_each_entry_rcu(mod, &modules, list) { - if (mod->state == MODULE_STATE_UNFORMED) - continue; - if (within_module(addr, mod)) { - const char *sym; - - sym = find_kallsyms_symbol(mod, addr, size, offset); - if (!sym) - goto out; - if (modname) - strscpy(modname, mod->name, MODULE_NAME_LEN); - if (name) - strscpy(name, sym, KSYM_NAME_LEN); - preempt_enable(); - return 0; - } - } -out: - preempt_enable(); - return -ERANGE; -} - int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, char *name, char *module_name, int *exported) {