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 D6690C25B08 for ; Wed, 17 Aug 2022 19:51:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232010AbiHQTvO (ORCPT ); Wed, 17 Aug 2022 15:51:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbiHQTvN (ORCPT ); Wed, 17 Aug 2022 15:51:13 -0400 Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BD3A33372; Wed, 17 Aug 2022 12:51:13 -0700 (PDT) Received: by mail-qk1-x72d.google.com with SMTP id g16so8967116qkl.11; Wed, 17 Aug 2022 12:51:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:from:to:cc; bh=v60uqYnukgjgZARXe5JJGms8uUUgUv8wpc53hUaJ67A=; b=JpefC9piThWn37ij83JUtU+fue08Tl6ykry7XnZ14DBKoDxePAQOK80AdrWAJ279px kcgkEXwRKcLiaoyNzJ+EI8n/tRYjvAaM9OA7ppJ7pFSusEicOlrDJYE3QaNMH8MqGMvR CWn5MzWzsDJ2Dxxk7lgkhTfQgInX9V3QLa6O79NTCAJjFXUFZQ0sMrsDc7E4fMJXjUDq WlAoyYbgC0IwfQBba7Lm7EukhyIjpr69eObpAhLbBvLWU1D5n6EBBus9KJmVX+aUmzFc +cP1U8QaRpaFqJEb4LRC7qIqK8SklFDGaEWG0AtZ2Jo3D7A18NK3Go4b1h7/xMs89cKr o/tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:x-gm-message-state:from:to:cc; bh=v60uqYnukgjgZARXe5JJGms8uUUgUv8wpc53hUaJ67A=; b=ISpvETzHxxVIsLoeHRMBpoxAYlmNAJzmXZ5TrxrZBFGt9/ahtgbcb6nVjP9Jgfr2fn 9ed65MmJl8eiHnWOsc1h55uz5RN4+pL4vi8OffOTUxqKM68TsmL54do4m4L5E/CtiWJV 6ZZfQT2aIKfN2p7LbG1BFuWYoz/ooqbnyzDhiTrbqIQW69FZDxWLHqwHDa4S70cevP+M 9VKt48UDZVYkbKTQHXFdvGIlB9MhSVm8+WHnNEosgkFlGWAFf1ZuqnJ8uvo0KzCDmHKh FkGRSPYY40A6Htk4R9gzPC5ZPE6uTJ61UckmmJGcu8in1JWyaZn9PrAgqdnzfdPmMjQV YRFQ== X-Gm-Message-State: ACgBeo325+r1gvaKoCg7gN91V6mrtNc+77f9L17E/UEb0MvZRu2pAIaQ j3SPzykYwesj0qSLCUIIFCo= X-Google-Smtp-Source: AA6agR4wb0hTyertW8x0U44XlUWC9UESZJzGxucrMzv60iW2eQI+SjAZa4eaPq87PCkVEUq6UypKmw== X-Received: by 2002:a05:620a:1a9a:b0:69c:4a99:ea50 with SMTP id bl26-20020a05620a1a9a00b0069c4a99ea50mr20031342qkb.632.1660765871901; Wed, 17 Aug 2022 12:51:11 -0700 (PDT) Received: from auth2-smtp.messagingengine.com (auth2-smtp.messagingengine.com. [66.111.4.228]) by smtp.gmail.com with ESMTPSA id b8-20020ae9eb08000000b006b8f4ade2c9sm13759099qkg.19.2022.08.17.12.51.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 12:51:11 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailauth.nyi.internal (Postfix) with ESMTP id 9E9A927C0054; Wed, 17 Aug 2022 15:51:10 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 17 Aug 2022 15:51:10 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdehiedgudegfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeeuohhq uhhnucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrf grthhtvghrnhephedugfduffffteeutddvheeuveelvdfhleelieevtdeguefhgeeuveei udffiedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epsghoqhhunhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqieelvdeghedt ieegqddujeejkeehheehvddqsghoqhhunhdrfhgvnhhgpeepghhmrghilhdrtghomhesfh higihmvgdrnhgrmhgv X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 17 Aug 2022 15:51:09 -0400 (EDT) Date: Wed, 17 Aug 2022 12:50:50 -0700 From: Boqun Feng To: Kees Cook Cc: Miguel Ojeda , Linus Torvalds , Greg Kroah-Hartman , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, patches@lists.linux.dev, Jarkko Sakkinen Subject: Re: [PATCH v9 03/27] kallsyms: add static relationship between `KSYM_NAME_LEN{,_BUFFER}` Message-ID: References: <20220805154231.31257-1-ojeda@kernel.org> <20220805154231.31257-4-ojeda@kernel.org> <202208171238.80053F8C@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202208171238.80053F8C@keescook> Precedence: bulk List-ID: X-Mailing-List: rust-for-linux@vger.kernel.org On Wed, Aug 17, 2022 at 12:39:48PM -0700, Kees Cook wrote: > On Fri, Aug 05, 2022 at 05:41:48PM +0200, Miguel Ojeda wrote: > > This adds a static assert to ensure `KSYM_NAME_LEN_BUFFER` > > gets updated when `KSYM_NAME_LEN` changes. > > > > The relationship used is one that keeps the new size (512+1) > > close to the original buffer size (500). > > > > Co-developed-by: Boqun Feng > > Signed-off-by: Boqun Feng > > Signed-off-by: Miguel Ojeda > > --- > > scripts/kallsyms.c | 6 +++++- > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > > diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c > > index f3c5a2623f71..f543b1c4f99f 100644 > > --- a/scripts/kallsyms.c > > +++ b/scripts/kallsyms.c > > @@ -33,7 +33,11 @@ > > #define KSYM_NAME_LEN 128 > > > > /* A substantially bigger size than the current maximum. */ > > -#define KSYM_NAME_LEN_BUFFER 499 > > +#define KSYM_NAME_LEN_BUFFER 512 > > +_Static_assert( > > + KSYM_NAME_LEN_BUFFER == KSYM_NAME_LEN * 4, > > + "Please keep KSYM_NAME_LEN_BUFFER in sync with KSYM_NAME_LEN" > > +); > > Why not just make this define: > > #define KSYM_NAME_LEN_BUFFER (KSYM_NAME_LEN * 4) > > ? If there's a good reason not it, please put it in the commit log. > Because KSYM_NAME_LEN_BUFFER is used as a string by stringify() in fscanf(), defining it as (KSYM_NAME_LEN * 4) will produce a string "128 * 4" after stringify() and that doesn't work with fscanf(). Miguel, maybe we can add something below in the commit log? `KSYM_NAME_LEN_BUFFER` cannot be defined as an expression, because it gets stringified in the fscanf() format. Therefore a _Static_assert() is needed. Thoughts? Regards, Boqun > -Kees > > -- > Kees Cook