Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2281697imn; Mon, 1 Aug 2022 18:52:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR6No10FwzCVTh8YNnt5RfjCOIG9gE5qD32n1d7D94FG4ckblJ8diKTQJUWQiw3A31SmB+Ie X-Received: by 2002:a17:90b:4c87:b0:1f2:cf1d:c906 with SMTP id my7-20020a17090b4c8700b001f2cf1dc906mr21826810pjb.119.1659405179170; Mon, 01 Aug 2022 18:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659405179; cv=none; d=google.com; s=arc-20160816; b=RSpLs3s0DqmlXK7jqQJzDD51DzatSlBiNDS6mRCXyLD3S8j1WsS0EA9FdHIJU1iM1l vsfmRFmpH2yZH3pl3bDeleT9m/ytVvaSaifhw09EXjaynlKL1NtNvJZE1bAoksgyRGjx DGlJcFxMdaR3zqGKnCwbVhGppnPPtwIjJt+Oi06dKVPmjChTyZdFMS3HXLl2QDTRUZI5 H7JAEWKdcWjQGV6JgG1O4oPqcMBKDhyIeEHlzLoBa3a/yH/2fmoyt1BFLJBwFTIh5udx 70Zu2/m7R2SDfLOQx9xBZBfWl9rkhAeijCbW6I5YJCKmkcLhRu69nL8zmz4E9oPClHIg t19Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tsFUBfph03lu0w8KkJ01ehFv603LtZmmyEJ3STB4tE8=; b=LQFRJ4scBGqMei/ByoUXdGSZIEej9Z3krUWgmN23Q8WiMxa43EZRWafDMQDAZ0E0Ue xDVcRKKrZhnS0Sbrm6kQu99yj1bxV9OZJlVDwSwltdYoSt9KkgDYaGM8qtOrKqGzAsZs gEn2uGtvAsyggwHfdEN1E8MhJVglOld+xH4AxWYi2Sb4PFvDm/Gxnh1GOyGrTgj3KM1d aedlaFb12S/56PrFWLcG83zBoWVv/t/b9/KKyKBsGATAwRWUyDweBfaEblEfZ8QxU8DW 3pzXyXgb0Vyh0EJhnj74Sinrsu2Ekjfd1eHabwSAzVb/Vn9qjc/HdMOUNZbR8dnpYVYR E8yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nYleW1na; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x11-20020a170902a38b00b0016dc4217314si13026617pla.150.2022.08.01.18.52.45; Mon, 01 Aug 2022 18:52:59 -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=@kernel.org header.s=k20201202 header.b=nYleW1na; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235511AbiHBBvr (ORCPT + 99 others); Mon, 1 Aug 2022 21:51:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231529AbiHBBvi (ORCPT ); Mon, 1 Aug 2022 21:51:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B112E19292; Mon, 1 Aug 2022 18:51:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 577CC6104E; Tue, 2 Aug 2022 01:51:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 068F5C433D6; Tue, 2 Aug 2022 01:51:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659405094; bh=klVt3yCrvBHhkydJiycgq8KSkSxzwlLwoeN/vGNg5Z0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nYleW1naIKYbh7memj3rI1mFWrsIeQMIDLrIVKFvPBDLKD0lCpBk/2GLc/A7PiITM m18OP5f8rZAHZqNBrx8TWiITJ1OWLgzScDHyKJ7+a8yqVyMNZtPyCFqkQFoIfHJ0rr InWbA4nwM/Xef3Y3AKPUkfE9aL3eESEk63vVaKYmc+eB6tBRnBmc6dvm7MwuaVXsXE cUA7/PjUUBdo3Wc0R1+1rvPBXOlg5huWIw2t98XvCFOvKxRX/+G2+LmT+JQdfKxdP8 +Fnar3yX8N5/rhXT+xYo56gQTYvzvFOPEf1v/pzRuigQu7qvXFz6Z07bveEcVIIPDR BqRBLeQTsLIHw== From: Miguel Ojeda To: Linus Torvalds , Greg Kroah-Hartman Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Jarkko Sakkinen , Miguel Ojeda , Boqun Feng Subject: [PATCH v8 02/31] kallsyms: avoid hardcoding buffer size Date: Tue, 2 Aug 2022 03:49:49 +0200 Message-Id: <20220802015052.10452-3-ojeda@kernel.org> In-Reply-To: <20220802015052.10452-1-ojeda@kernel.org> References: <20220802015052.10452-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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: 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); if (rc != 3) { if (rc != EOF && fgets(name, sizeof(name), in) == NULL) fprintf(stderr, "Read error or end of file.\n"); -- 2.37.1