Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2732652pxb; Mon, 17 Jan 2022 04:48:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzPG+hHP3nVUzEk0WA/JgpVONKDVPNKaxEGmJFjiczOZzMmllYaXMQWawhvIQew59OPB2D0 X-Received: by 2002:a63:2b03:: with SMTP id r3mr18846888pgr.201.1642423697594; Mon, 17 Jan 2022 04:48:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642423697; cv=none; d=google.com; s=arc-20160816; b=ppkF6pJyGL8Bm+hUl/yUs29KT1T7I3FSlKNYgj0IxKM6KrNbdGb1hIoAprUZTVNk/M QNRBeVVQBMrSq74O2XTI/+yY6S6fOmcz5/PFO4A0iYzeX45bwB8xzhpg5WegfbTIzLop c5kFc/hPs4o03pQrjqS+3YhPQRVRW46z0lwD+rHNSe09RWuwF9GoUKKyeV3/bv40zVxN jxa5GreYfTYkExPnk/d4kO4+fbUGaQJmQIi3qkeoaN/TGKBFCI4yug7DgshtrBaYU9ST gzR0MDzTwphSgbQHYkDYeDjv9obacPCrQeF/OWTR2+wKYvK7Uqi9qajH+RZQLhnz6EZD Yhbw== 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=FOqqeDSsC4rjUbeEgRJyLfp+rLGRM91H0f3uzaB8v9M=; b=J1I8I9AmHEi3cniZzm3HpiDeXgOGsiYXn2gYSK3jZ5FSyACol8Rvhhh6RXiTLtjO4P 1ROrT5iDtkaeNM3K0xTmIpqMRH4u3qLaFk7Q/6g3/tBzMJgu8H83A263bph4HBd68/aA 6ItqNab8PPS/pavttdyr+PsFbedlT+rYl5qd4aQr69ZWNUTA6iXjWgZ8sCAQzLh9cAXD dVeqzIx1bl9DqwjuJvnh+n0r/tqjUkaR+88FbFhSO4CQ8hJ2TzYdOzqADp3DUfjXVrmT LbD9+v9K97EhewGajOU7GwjNTXo+E/V3H1jwGzHEl/OWJXLNqTCGCsof2q7utQ03NLN1 visQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OtURDb6P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t5si12702017plr.280.2022.01.17.04.48.05; Mon, 17 Jan 2022 04:48:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OtURDb6P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S232853AbiAQFeW (ORCPT + 99 others); Mon, 17 Jan 2022 00:34:22 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:40390 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232067AbiAQFeP (ORCPT ); Mon, 17 Jan 2022 00:34:15 -0500 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 976F760DFE; Mon, 17 Jan 2022 05:34:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62E02C36AEF; Mon, 17 Jan 2022 05:34:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642397654; bh=kWktUvUlCwi/4bf68o/bwuJIQH3GPpyvsrJ7wnMnoBE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OtURDb6PW59utsE8hVr0/79W62ePNUA4tQVjY3nMVFl5CxvKTXufJfhUoVXxqT/BG 8V57TANBlkg7PhVq7dPIXfIq3L90f7y2Blgbaei4b0LxjOnjd/L4AlZyAgMQVCTovY 6TO4ZFPHSAPkWpLhU/ksEt5PMzsWYjpqqp3Xm8jrxfhdA6kSi2ksPWRw/pwSsgWGGR vW+HgPtkHI6+fgClNP+1SbNda4W3tlqB4w/uMTVGLbNaojfNmzAONo0293YY3YTXjp mSW0I4Oq64sy7zkipeYL7iNKL9RV3QcFf3JFhYnVbjJqNJN1Wo+5PvuWsXw8K1dHqf 9CcFwzb9+R76Q== From: Miguel Ojeda To: Linus Torvalds , Greg Kroah-Hartman Cc: rust-for-linux@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Miguel Ojeda , Boqun Feng Subject: [PATCH v3 03/19] kallsyms: use the correct buffer size for symbols Date: Mon, 17 Jan 2022 06:33:33 +0100 Message-Id: <20220117053349.6804-4-ojeda@kernel.org> In-Reply-To: <20220117053349.6804-1-ojeda@kernel.org> References: <20220117053349.6804-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Boqun Feng The buffered name size should be larger than `KSYM_NAME_LEN`, otherwise we cannot tell whether the size of a symbol name is too long. Signed-off-by: Boqun Feng Signed-off-by: Miguel Ojeda --- scripts/kallsyms.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 72ba0fe4e43b..0e37c19d84af 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -27,6 +27,9 @@ #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) +#define _stringify_1(x) #x +#define _stringify(x) _stringify_1(x) + #define KSYM_NAME_LEN 512 struct sym_entry { @@ -197,15 +200,15 @@ 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+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) "s\n", &addr, &type, name); if (rc != 3) { - if (rc != EOF && fgets(name, 500, in) == NULL) + if (rc != EOF && fgets(name, KSYM_NAME_LEN + 1, in) == NULL) fprintf(stderr, "Read error or end of file.\n"); return NULL; } -- 2.34.1