Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1627830pxp; Thu, 17 Mar 2022 13:04:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWn/3DFO9u2vbY1mfEh4+7DmlKwvTiD+w990EZaMsxggKx6G1kQFmkCyri+5dbWY7xUhae X-Received: by 2002:aca:b01:0:b0:2ee:f5d0:b16b with SMTP id 1-20020aca0b01000000b002eef5d0b16bmr4832555oil.184.1647547475646; Thu, 17 Mar 2022 13:04:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647547475; cv=none; d=google.com; s=arc-20160816; b=06Y0lRkes7SXf10G1buuUP8wKUqK7KSF6wUq6MrcBx4qwhP3KtfC1YH4xu77Ffoc9L crhpQpJLhHQYsgcJvbDogLe4ryuICuSbIrYU+R+6rMnJZ9iUY3p1bcE0VuYhCgrVWmi6 L53PoUnATyLJ7Haw+oTs+Gz+UD31sHE9gJg9O1He7tAKB7eaGAFeWfyok8aJVtz7Y+ta fq1ySwH/lGwKDM/izwkdC2KgOVtWcIKF6yw/MnmBMzFAjcmJKS+EGEZitrAVZpxtev3A tB21eyWT6067I7eTwzo89Otc+6yLpKZU1hyZueUHv33XPQhIcXesHpg3sg/SC8zGCfJB wwyg== 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=tcxp3mT3PRX62YPph5swb2gcPkLMUlF/HQOdjbnb9PhNlNiW0oz5dRlNyOrG2B6bzb UFo+WHJUj5nPoMx9cgN53D5IT2jk9214Oq8jHd++MQ5A6TwkeaiAIlYaqxffcKTHtMQO h1kvjRJZPfOUIhk/3z4LOgwoF1h0wNR9hMrvsZrSRzllSeMUZHI49raiVluD0DQwR53j +nCymZB+SF/n17jSySe0nsxDXgN0KtHwIXjR2Bb0neeVI6bqVdP39RgYHsu2tmvXUb9z v3JIlvEnb8UT3pmaf2h01BxXUjYV7KIM+0NLdQGSzjIoUJrzqGMNABEN8Bfh5AzaptW1 IL6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FCHi9vdd; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id x17-20020a4a3951000000b003244bc5df35si7599oog.49.2022.03.17.13.04.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Mar 2022 13:04:35 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FCHi9vdd; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D251EF9546; Thu, 17 Mar 2022 12:53:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237270AbiCQSNC (ORCPT + 99 others); Thu, 17 Mar 2022 14:13:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237265AbiCQSMq (ORCPT ); Thu, 17 Mar 2022 14:12:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9587D21F757; Thu, 17 Mar 2022 11:11:26 -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 ams.source.kernel.org (Postfix) with ESMTPS id 3EEA6B81F78; Thu, 17 Mar 2022 18:11:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FD0DC340E9; Thu, 17 Mar 2022 18:11:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647540683; bh=cwX42oNMILb31uWuwrX4DLWMJYJsQrZZhHdeJy/mlH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FCHi9vddFiA9Gh/t6oPZ7hZ2LU8FoK1X+j3EpcZKyMUuDCc984pNBCvyZZRiuyFCE ChuMQQX5nTW45uawJhFSXICR5Mg2jKa4KGO87/AmJesnfMlr8p4egho29otiwDScMZ 3E9bBZcmde2Et/SIH1S/iq6CD9n88cY8GfLeLTZcYh3c50QebybYTbJzJ4RhfSlF64 3XgPwt+aJuyGOz3KN0OT78HyZfaz2+daoyjzgs0z+DC5ApgmAE6pgS3PcOsTGyE/qy 5UkIU4ZyGqC3NDoFAYsVksFWdhedx2rsL+haBHIB5aNFnuN5T5huFNR/tNguw4zUep G0KnORtEBJekA== 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 v5 03/20] kallsyms: use the correct buffer size for symbols Date: Thu, 17 Mar 2022 19:09:51 +0100 Message-Id: <20220317181032.15436-4-ojeda@kernel.org> In-Reply-To: <20220317181032.15436-1-ojeda@kernel.org> References: <20220317181032.15436-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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