From mboxrd@z Thu Jan 1 00:00:00 1970 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 75490C433EF for ; Fri, 20 May 2022 19:52:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353329AbiETTwV (ORCPT ); Fri, 20 May 2022 15:52:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347012AbiETTwN (ORCPT ); Fri, 20 May 2022 15:52:13 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7A438196698 for ; Fri, 20 May 2022 12:52:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653076331; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QC4HhoSa5ax5VuJxdudrkP+hQQcM6Ir26+NRsLLyTuA=; b=aVtD4MNkr5/hZNC4UNopXeVdvrGLRksvO2x+el9yARnUlcMFyLoJNjiC9bqZiCAApioGpY yk5TvBeN+y85nKkXIzdi2ieUzTn1EQUibpiTGnJ3bT4ei6bQ5XFRUwfhLFKNQTHF5+WfqG CzNtKEyR6O6K9vf8cxoBYDlR44RCRRU= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-644-4t-3E9E5PQGx31S7cEd1eQ-1; Fri, 20 May 2022 15:52:06 -0400 X-MC-Unique: 4t-3E9E5PQGx31S7cEd1eQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5AC1829AB3FB; Fri, 20 May 2022 19:52:04 +0000 (UTC) Received: from [10.22.32.226] (unknown [10.22.32.226]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED99440D2821; Fri, 20 May 2022 19:52:01 +0000 (UTC) Message-ID: Date: Fri, 20 May 2022 15:52:01 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH 1/5] kallsyms: pass buffer size in sprint_* APIs Content-Language: en-US To: Maninder Singh , 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, 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 References: <20220520083701.2610975-1-maninder1.s@samsung.com> <20220520083701.2610975-2-maninder1.s@samsung.com> From: Waiman Long In-Reply-To: <20220520083701.2610975-2-maninder1.s@samsung.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Precedence: bulk List-ID: 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 > 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); 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