Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp118435ioo; Fri, 20 May 2022 15:42:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDwF9/KLY6tnTNXJyV01Evc52AxYey2zkjWs1kGc7mBZ6E4XBpv+xbpDoYWxDl9riKe6g6 X-Received: by 2002:a05:6402:50d2:b0:42b:2bf0:4dbe with SMTP id h18-20020a05640250d200b0042b2bf04dbemr5914096edb.309.1653086566042; Fri, 20 May 2022 15:42:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653086566; cv=none; d=google.com; s=arc-20160816; b=RpFcPxwb+Zh+IdaXdUQBqzhJ+C9jjvPFM4Io7cS2axVyi73uFjGnxi7vunTPAmozf0 wswH6/ee8sAyKzmBVFXEG/QD62yjcOo2PtD0AZhx0qcTeA8SUjWE/bHzlOuRXa9BKOAE UrVHWNYqLAd2XJK8An/Ctn8E47k8y8kj4MDfgAszuNFwLDwz0UUl1MnO5T3B5EKkeCxO fltNhb9jnyMxk5vVNOPMMH0Gd+7ZCsvggrtnYEt0b0uwlnK7uqkhsLY+SiYv8tEWNByc PNJnrYsbCezZfU2UtCWNIwxrwflRZtiT2hSC1hRADWdgKgukajJeu8UPbCRnXZ5Xk1D4 47JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dkim-filter; bh=oZhGlLI83t5qJYIpB4tYvwEL1hnzUFffSLhokei+vZw=; b=NzcOe+y5tws0+4J18LN3c9AZFAft0itYws4blwOERjgeXU2QIcPz5FhWWdgI8rgcfh XNrr20MnOft3gjC8T9e1RJEX+6+fMkotO8ueRM83SCM8Jp5JrJjSqefgbfZd6iAXG7S0 MquEx0OKUHz/dKH0oW1zzY3ETOAq6wqkEzPPq5lE5GO/QCkc3pV7ywtx4qo++53/3tL8 GedW9O1ZIHuu4i0QJbSpx6tAvnYKEwSwjg9CNfiHxJrROaZOGLLroyYDIySi0Mfzdagn yueF4zem6Rce7MEjzbqDrwu48NzQApTEozPwY0BHZkgHe/i3/+vElDNWBajC4eReej/P AieA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=ipd4KLW4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nc29-20020a1709071c1d00b006f469baffaesi9630070ejc.16.2022.05.20.15.42.18; Fri, 20 May 2022 15:42:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=ipd4KLW4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347215AbiETIjB (ORCPT + 99 others); Fri, 20 May 2022 04:39:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347207AbiETIi7 (ORCPT ); Fri, 20 May 2022 04:38:59 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 793E69D4CF; Fri, 20 May 2022 01:38:57 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20220520083855epoutp016fa069d66602b42f61964cb062d9f8d5~ww2zHyyO_2633026330epoutp013; Fri, 20 May 2022 08:38:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20220520083855epoutp016fa069d66602b42f61964cb062d9f8d5~ww2zHyyO_2633026330epoutp013 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1653035935; bh=oZhGlLI83t5qJYIpB4tYvwEL1hnzUFffSLhokei+vZw=; h=From:To:Cc:Subject:Date:References:From; b=ipd4KLW4NM9s1EshcHiVYcOCkwPMINX24v6Ff8vxhss0aRvGT3BAM+Z2tgxqYcKw0 qNjaNJkTm0uxpL6ti92DZ17Gaf4U+g4fYaLnhavWvPgve8gXKSklZoHPvBd1TT+SfT rBmVRrBfDNF483ylhq7Vc+97bXV0LRsjU1ieKMag= Received: from epsmges5p3new.samsung.com (unknown [182.195.42.75]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20220520083854epcas5p3cf9401d13a42a8134d2a52391dcc4d89~ww2yiZHpG2034420344epcas5p37; Fri, 20 May 2022 08:38:54 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 73.83.09762.E9357826; Fri, 20 May 2022 17:38:54 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220520083715epcas5p400b11adef4d540756c985feb20ba29bc~ww1WSNe9p1594815948epcas5p4w; Fri, 20 May 2022 08:37:15 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220520083715epsmtrp2a62dfe8d18384a72c2a4ccacc969621e~ww1WQg0-r1034110341epsmtrp2B; Fri, 20 May 2022 08:37:15 +0000 (GMT) X-AuditID: b6c32a4b-1fdff70000002622-1d-6287539e2b57 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 72.F7.08924.B3357826; Fri, 20 May 2022 17:37:15 +0900 (KST) Received: from localhost.localdomain (unknown [107.109.224.44]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220520083707epsmtip27d956809dfd1d7b7f768b3f968c214b2~ww1O1WuqV2442924429epsmtip2f; Fri, 20 May 2022 08:37:07 +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 0/5] kallsyms: make kallsym APIs more safe with scnprintf Date: Fri, 20 May 2022 14:06:56 +0530 Message-Id: <20220520083701.2610975-1-maninder1.s@samsung.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA01Ta0xTVxzPuff2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RZ0iE3h1PFq7kjKWxo2Xc4p1NwFTbw8LlndhHaf JJO1IYdlWe5EGB85Ec3HpQFCpNbHioVKxbcZrDb5rPaCiuWcSMInpAeFd/NcZ8WieEUqm8Sy Kaz2f4rxBYE6TBl5JrQn8mQdZWprHjC3Ty6EasaehECG6StBbnhvgHtx9TPFAc9c+gcZf2oT PzpVfzizgpWlBX33IuH9N4bbyAx/r7l1X/XKUPIrYWOPrsdc/PW0pyri/ds9Xw5FbWUeXYsw qCA+XIGtPohOiEqUBzTT549dsv5mnZIIOv85IWny339R15hl/VFqn7xXHjZofElX9H19SFrt 9vmbcX2HX9uOyf89KnY4+0FWZVK1UvJqyy230fJFanZqy0bInLJL8nGkI/rdqL/nlsf3BZsT CxqiPaPcMHdKQNYeaHyGvo4rnnYczD0jJGzFI/NrKlN6X1GoLjj6p6TMCRfjJ2vFI65ICS5B cUSGaznFfwD17ma4AwAA X-CMS-MailID: 20220520083715epcas5p400b11adef4d540756c985feb20ba29bc X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-CMS-RootMailID: 20220520083715epcas5p400b11adef4d540756c985feb20ba29bc References: X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kallsyms functionality depends on KSYM_NAME_LEN directly. but if user passed array length lesser than it, sprintf can cause issues of buffer overflow attack. So changing *sprint* and *lookup* APIs in this patch set to have buffer size as an argument and replacing sprintf with scnprintf. patch 1 and 2 can be clubbed, but then it will be difficult to review, so patch 1 changes prototype only and patch 2 includes passed argument usage. Patch 3 and patch 5 are bug fixes. Patch 1, 2 and 4 are changing prorotypes. Tried build and kallsyms test on ARM64 environment. APIs are called at multiple places. So build can be failed if updation missed at any place. lets see if autobot reports any build failure with any config combination. [ 12.247313] ps function_check [crash] [ 12.247906] pS function_check+0x4/0x40 [crash] [ 12.247999] pSb function_check+0x4/0x40 [crash df48d71893b7fb2688ac9739346449e89e8a76ca] [ 12.248092] pB function_check+0x4/0x40 [crash] [ 12.248190] pBb function_check+0x4/0x40 [crash df48d71893b7fb2688ac9739346449e89e8a76ca] ... [ 12.261175] Call trace: [ 12.261361] function_2+0x74/0x88 [crash df48d71893b7fb2688ac9739346449e89e8a76ca] [ 12.261859] function_1+0x10/0x1c [crash df48d71893b7fb2688ac9739346449e89e8a76ca] [ 12.262237] hello_init+0x24/0x34 [crash df48d71893b7fb2688ac9739346449e89e8a76ca] [ 12.262603] do_one_initcall+0x54/0x1c8 [ 12.262803] do_init_module+0x44/0x1d0 [ 12.262992] load_module+0x1688/0x19f0 [ 12.263179] __do_sys_init_module+0x1a0/0x210 [ 12.263387] __arm64_sys_init_module+0x1c/0x28 [ 12.263596] invoke_syscall+0x44/0x108 [ 12.263788] el0_svc_common.constprop.0+0x44/0xf0 [ 12.264014] do_el0_svc_compat+0x1c/0x50 [ 12.264209] el0_svc_compat+0x2c/0x88 [ 12.264397] el0t_32_sync_handler+0x90/0x140 [ 12.264600] el0t_32_sync+0x190/0x194 Maninder Singh, Onkarnath (5): kallsyms: pass buffer size in sprint_* APIs kallsyms: replace sprintf with scprintf arch:hexagon/powerpc: use KSYM_NAME_LEN as array size kallsyms: pass buffer size argument in *lookup* APIs kallsyms: remove unsed API lookup_symbol_attrs arch/hexagon/kernel/traps.c | 4 +- arch/powerpc/xmon/xmon.c | 6 +- arch/s390/lib/test_unwind.c | 2 +- drivers/scsi/fnic/fnic_trace.c | 8 +-- fs/proc/base.c | 2 +- include/linux/kallsyms.h | 34 +++++------ include/linux/module.h | 14 ++--- init/main.c | 2 +- kernel/debug/kdb/kdb_support.c | 2 +- kernel/kallsyms.c | 92 ++++++++++++------------------ 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 | 36 ++---------- kernel/trace/ftrace.c | 9 +-- kernel/trace/trace_kprobe.c | 2 +- kernel/trace/trace_output.c | 4 +- kernel/trace/trace_syscalls.c | 2 +- lib/vsprintf.c | 10 ++-- 20 files changed, 93 insertions(+), 154 deletions(-) -- 2.17.1