Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2414321imn; Tue, 2 Aug 2022 01:43:30 -0700 (PDT) X-Google-Smtp-Source: AA6agR5gBXGTRUuSJDCvp7/B2eKEnWpY9iHbokUFSsisSae6KBjn+B5M+F7WQcnPqeBzXytDcjYa X-Received: by 2002:a17:907:7f11:b0:730:6f6f:e444 with SMTP id qf17-20020a1709077f1100b007306f6fe444mr7772324ejc.657.1659429810633; Tue, 02 Aug 2022 01:43:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659429810; cv=none; d=google.com; s=arc-20160816; b=gjVT1VPhu/wC0uU5fpSAzHyoA1vcAFob2MrEHd0rKm3OOGlAxUpCpFQvNRfasOIfgG aKAi08mm2EBNWUoqCezG/44f2bxWC8w7dAQK0VjAga8P+eGcVKrlY+x7uhfbpo9gLo7s XK4ZIJtUFP9M2yzxDtSwOIJbLeg15CPSuYWVwaiW3gVBhrI7JNR2UQXmCZj7eltPPWRQ pIChPY2PneEM6WtLM9jmNKvufO43Ss7uUnYdIepD8f/93RMnPugV3QekuRn98KuknwOG n6dYNasrAs3twYZrMfRCE1uy+7OGv0R2TEwDpNP5H4zXSHZMHIz7hN37AqTfat1iwAVI V8Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=CQZPiYirzc6WYku8xO2F0w6AjaIpE6aBN/LcoShCHoI=; b=f3fNNqPK1tQoUrxYtnI6r4tk3kff2ltso19Vro1CEZQmp90NluCpYXIOjfYT7NH0Ki IACqnwDu1TxY6eAWudUVt5EH5QnPOnzkRNYQc1li3yvG7qZfVsVVi3+M7CDTJsHSogof njk6qcqfnZfD/z/Toi+CFGakKmRpiSF03i7NcmiKeJLywNKMi0Azci7CE3knOP+wF/YU r7JAEEFqnuf9kqYIBYNfDyMs9SMA1Et58iCYId5146+QuUFoFJQf8DgAWzKcaCZ4zaLW jV5lE1JvNg9BD17avK6FWUMxFJGjSMLBb8bAjQ2hetLsIqMxLBjZVhTEKk0sspCX8cHK ULhA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wv6-20020a170907080600b00722f74fff57si13559154ejb.313.2022.08.02.01.43.05; Tue, 02 Aug 2022 01:43:30 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235811AbiHBIaH convert rfc822-to-8bit (ORCPT + 99 others); Tue, 2 Aug 2022 04:30:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232747AbiHBIaF (ORCPT ); Tue, 2 Aug 2022 04:30:05 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1B56825C68 for ; Tue, 2 Aug 2022 01:30:03 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-48-LJ-MnU9LMyyehVzQxMP1Kg-1; Tue, 02 Aug 2022 09:29:59 +0100 X-MC-Unique: LJ-MnU9LMyyehVzQxMP1Kg-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.36; Tue, 2 Aug 2022 09:29:58 +0100 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.036; Tue, 2 Aug 2022 09:29:58 +0100 From: David Laight To: 'Miguel Ojeda' , Linus Torvalds , Greg Kroah-Hartman CC: "rust-for-linux@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Jarkko Sakkinen" , Boqun Feng Subject: RE: [PATCH v8 02/31] kallsyms: avoid hardcoding buffer size Thread-Topic: [PATCH v8 02/31] kallsyms: avoid hardcoding buffer size Thread-Index: AQHYphJye/tEVINqhkC+eCkeMuTkcq2bR13g Date: Tue, 2 Aug 2022 08:29:58 +0000 Message-ID: References: <20220802015052.10452-1-ojeda@kernel.org> <20220802015052.10452-3-ojeda@kernel.org> In-Reply-To: <20220802015052.10452-3-ojeda@kernel.org> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS 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 From: Miguel Ojeda > Sent: 02 August 2022 02:50 > > From: Boqun Feng > > This introduces `KSYM_NAME_LEN_BUFFER` in place of the previously > hardcoded size of the input buffer. > > It will also make it easier to update the size in a single place > in a later patch. > > Signed-off-by: Boqun Feng > Co-developed-by: Miguel Ojeda > Signed-off-by: Miguel Ojeda > --- > scripts/kallsyms.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c > index 52f5488c61bc..f3c5a2623f71 100644 > --- a/scripts/kallsyms.c > +++ b/scripts/kallsyms.c > @@ -27,8 +27,14 @@ > > #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) > > +#define _stringify_1(x) #x > +#define _stringify(x) _stringify_1(x) > + > #define KSYM_NAME_LEN 128 > > +/* A substantially bigger size than the current maximum. */ > +#define KSYM_NAME_LEN_BUFFER 499 > + > struct sym_entry { > unsigned long long addr; > unsigned int len; > @@ -198,13 +204,13 @@ static void check_symbol_range(const char *sym, unsigned long long addr, > > static struct sym_entry *read_symbol(FILE *in) > { > - char name[500], type; > + char name[KSYM_NAME_LEN_BUFFER+1], type; > unsigned long long addr; > unsigned int len; > struct sym_entry *sym; > int rc; > > - rc = fscanf(in, "%llx %c %499s\n", &addr, &type, name); > + rc = fscanf(in, "%llx %c %" _stringify(KSYM_NAME_LEN_BUFFER) "s\n", &addr, &type, name); Think I'd use "%*s" - simpler. Although I normally completely avoid scanf() - too easy to get wrong. David > if (rc != 3) { > if (rc != EOF && fgets(name, sizeof(name), in) == NULL) > fprintf(stderr, "Read error or end of file.\n"); > -- > 2.37.1 - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)