Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2224737ioo; Mon, 23 May 2022 13:09:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6MdPD/f6zTtqiNDAVXhVNIRfG5xWKrUEHaNAmQ4mQ6CwYGXsE8l9Rr3V5crib2+OMxOLo X-Received: by 2002:a17:907:7b88:b0:6fe:8c1e:ca1f with SMTP id ne8-20020a1709077b8800b006fe8c1eca1fmr20653346ejc.52.1653336597391; Mon, 23 May 2022 13:09:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653336597; cv=none; d=google.com; s=arc-20160816; b=QkunDboynQ95fpuJEMjcG+yfJ0m0RJL8DNSVje/bNPk62/fH1DMFNc5GYRb9F7Sy/I eBe8vaKI/FeKjj7QoX/QSf5vMoL57wRyRLpjKaHvDcAeHXmVzT8k5YtptqxhyY90g8kv X8RbZrWfsVv5lVraNfSA+nvJvzZXnIgWfoq5wHNRsgycMdU1SovkBCPL29X4yFkPNjuO ba8wtWG2CoXsQ3XrBFpqoBWu7QSBuDrQFyPPSyOh4XRhJ0Y4oDnwtfSYO/rtyCjYaBSK a83MA/gOhPIfGazqSIlTPpEozUlmYMoFY5RlfhtmpgonNRakSMMyG+lbobT2GkQy0dPh N1aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=9i0mf5EWjId+dJhDG42zI0t8gO1U5xR/fPTtg8h/guQ=; b=yWV5jIRg+QUnA/65OHG+9VKP+bOjNcQU2PD0s7+tysOlQJV1AILYLnnF9XdA75jcCZ wqilzPuvKbDaHoHSHFYuFYwCssmLLy67cW07D03jPAZtuoeM/O/63LYs0TRzJXWutR+3 y/DV649KmVyAUwI1mia58Sl6LPwcTyqRAsE4hP+1x204HMkdwdVOgz2E07psoRPM6SMP pueUdT2PVhNRAfSvPIm9eW5VMdv1xRJspXIDLs2MA4zEPNEcHfL3jYHMF/JV3fitl4by hz2arKcoWfYrEYKvh00kakZ19uMXYC2f9zl6lgqPEwPyXILcEkkAyI+tSJYWAHEZf9Es L0fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=G67mgEOc; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dp8-20020a170906c14800b006fea4101e47si11269877ejc.233.2022.05.23.13.09.30; Mon, 23 May 2022 13:09:57 -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=@chromium.org header.s=google header.b=G67mgEOc; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231664AbiEWTnr (ORCPT + 99 others); Mon, 23 May 2022 15:43:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233999AbiEWTmT (ORCPT ); Mon, 23 May 2022 15:42:19 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D64C711A18 for ; Mon, 23 May 2022 12:39:15 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d22so13981392plr.9 for ; Mon, 23 May 2022 12:39:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=9i0mf5EWjId+dJhDG42zI0t8gO1U5xR/fPTtg8h/guQ=; b=G67mgEOcbKAzzfRqWT2tyqM6K9pitcq9pbTVcwT0LjmKZNi0oiqVsX8V97hEFwl2hf AMnpF3tfbp0thJvNCE4CX5dI4O8ELTGwmxs1K5fhCNP737yCqZGbfIr/xW9c33Xf+LOK scdJ+18kS7hWnfRSUS9ItgijmeteaopgZF3uU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=9i0mf5EWjId+dJhDG42zI0t8gO1U5xR/fPTtg8h/guQ=; b=PaF8FlnIAnr8dIxtRr0O97CjHd0qMxWCQVYK0lW6ukO9Rea2z1qQs85bJX+chTy27d 53vFFZrDsf71yIwirUxTJsopDC2y/mGtEzxtdEcprRXAeVIBsHXOYuDXMPLtVSzm7gIl evQx6q/9fF4R/JdnG2+2Vi3sL7s/bK3ymyOdkFKtE7F5VYYttxCBzJ/3g/tROdqqJx1u qG9SpjVOFc1VfXyt2Lffa3JE53rLpi52Nh47RVeLELKYf3DpcFyvPKamtJydFDEJXx4L Cs/oO+A9OEyiPe9NuSR7euYHC7VheCPgCT1vOuiKrH7sIuTxdJdQ+vc7gWeaO0popd4b kLxQ== X-Gm-Message-State: AOAM530Ply5dzJpjc5/kOMkCKQHd+U14wZxMAWMa/7CMqWAClximN0/T JdgLIz99MVw9af2MyPQPFKlUoA== X-Received: by 2002:a17:902:f605:b0:14d:9e11:c864 with SMTP id n5-20020a170902f60500b0014d9e11c864mr24236615plg.54.1653334755308; Mon, 23 May 2022 12:39:15 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id a9-20020a62bd09000000b0051827128aeasm7543246pff.131.2022.05.23.12.39.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 12:39:14 -0700 (PDT) Date: Mon, 23 May 2022 12:39:12 -0700 From: Kees Cook To: Christoph Hellwig Cc: Maninder Singh , 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, 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 Subject: Re: [PATCH 0/5] kallsyms: make kallsym APIs more safe with scnprintf Message-ID: <202205231238.FAF6D28@keescook> References: <20220520083701.2610975-1-maninder1.s@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,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 On Sat, May 21, 2022 at 11:07:52PM -0700, Christoph Hellwig wrote: > On Fri, May 20, 2022 at 02:06:56PM +0530, Maninder Singh wrote: > > 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. > > This is still a pretty horrible API. Passing something like > a struct seq_buf seems like the much better API here. Also with > the amount of arguments and by reference passing it might be worth > to pass them as a structure while you're at it. Yeah, I agree. It really seems like seq_buf would be nicer. -- Kees Cook