Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5159664pxb; Sun, 13 Feb 2022 09:53:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJwwvro0MeT+tsME9vq/xdG5UHgwJ40G/93L+T5vU5RKp5oyhTsHsTaR2qzhvtw2ucuy0knD X-Received: by 2002:a17:903:228b:: with SMTP id b11mr5200807plh.104.1644774802618; Sun, 13 Feb 2022 09:53:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644774802; cv=none; d=google.com; s=arc-20160816; b=l9RTPzfxzZItqZ2qVnCoh04mqThCevHf2Ss/xwIcZDd0FS09zcPdYGEfk0dDxhcCQ1 V0D2caAYGjYqCgvBP79TnTorVap2YHbFXQDKc3zDzZhGuokjhKd5ETR2Mn1WGaQMegei OO8a8LjopKl290y/np7soovKWY1YSa3mJH/r/hsAv7qtWeEcitITQ/3DESnL0A6FM+2N sVu1QlE4VCWy6NiS/SXeJTmJy9jQoCHq9XQIU7OwmYcBu1PwKTYUWSYUXxC8WjlHZZQB ng01uXkfYkSNM5Ea6bG4H3uG3/UeN95f0npH58ChVweKi0xtSYVdxFsz9o7324rogvjv bvBw== 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=F0k0LChXbYje/VbrKzUxqlRuNJiAagRvRaFT0bWL6U8=; b=oo0TtYJ45YOzHJKYGZ8fyivkiPVg3zdDSYIo52FbytHu/b0WmgUx7Fgi0ye49BERUW rjElTLTCFENgjsZ0sSy1Pzx2AFnxNskijMzixhQP4D3RXIgdbR2LQ1SvzrgsFXWAsoWR Tqth8646RfwN5QflVafJ5dnpbrxbJjYlexICO3oJ690HoF+IPB39mE6gJeLroMewVlzk 4H+zs3WkxcXsAsaJvsanicf7q74JjIzBiD/S8leedClWjf91Cc2XdG2oNuz8hIwGD2oW 5afvSeXZIOMnFF5wUDcJ5IMWmjCofRNALoIee7FWXCVtAARXDMv3jTZnQnZ7XJlwL4vU q4vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="mhO/w6v8"; 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 be3si10007011pgb.421.2022.02.13.09.53.04; Sun, 13 Feb 2022 09:53:22 -0800 (PST) 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="mhO/w6v8"; 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 S235246AbiBLNFX (ORCPT + 99 others); Sat, 12 Feb 2022 08:05:23 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:55304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235266AbiBLNFS (ORCPT ); Sat, 12 Feb 2022 08:05:18 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90E6526AD9; Sat, 12 Feb 2022 05:05:15 -0800 (PST) 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 1586E60E95; Sat, 12 Feb 2022 13:05:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3384C340F0; Sat, 12 Feb 2022 13:05:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644671114; bh=cwX42oNMILb31uWuwrX4DLWMJYJsQrZZhHdeJy/mlH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mhO/w6v8ZL8faymWYCvfeDXtQoTxudEa7D0e47kctaHuXEED2LpfLv+UhfXO5HPr0 lWim1GWtHRdjgyskaq7FCbQSOg96Y4tDq80nmCbvZTkEmlK+jqlzSiKfYvpaD6G1mn ivT7d530nSaLp4CClmX2BwY39QgVaVa+1E9W4MRjgQr0G25F0Leg8C92bcpoHbXp/l vUTvNw6j6wznOqSjj1toLajhcLhZ2CpIFvTY9vZ3QX49e08kMzAcmL0xjWIYZTKrSD Z6zihXdNSSth2gwXbBOErvMfcM8m7F+LxhmBYibdKcTf/HeY8ImIeBiLJeALPLIn4y qYUuRHgP/ECXQ== From: Miguel Ojeda To: Linus Torvalds , Greg Kroah-Hartman Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Miguel Ojeda , Boqun Feng Subject: [PATCH v4 03/20] kallsyms: use the correct buffer size for symbols Date: Sat, 12 Feb 2022 14:03:29 +0100 Message-Id: <20220212130410.6901-4-ojeda@kernel.org> In-Reply-To: <20220212130410.6901-1-ojeda@kernel.org> References: <20220212130410.6901-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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,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 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.35.1