From patchwork Tue Oct 24 08:52:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 157307 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1805531vqx; Tue, 24 Oct 2023 01:53:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGlknTtzDrfkTOL0c0UxYEeCvbVBXI6bM9huv2kTcrS1scRA2jYpJJHa2vgbwV4TA++hnNo X-Received: by 2002:a05:6a00:a0b:b0:6bd:9281:9453 with SMTP id p11-20020a056a000a0b00b006bd92819453mr10800315pfh.9.1698137603551; Tue, 24 Oct 2023 01:53:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698137603; cv=none; d=google.com; s=arc-20160816; b=y1q3deSCOf3WLhBBqI0dPo6MCirhCv15StX43xBpds93gDPDDQjRlyRTIZzEkRV8Mr FvWkKrhj8LoJC/q6KOEn3bJYO4pkvvKSngSyDn5nLFaS0Yg8ntfN0HWRSs+t5vms6CGu qD05xfkwRonH7WAUBtF1XfgnszxQ2vP+O06Wf+aD02aXxgjLIsGpoJrs1w3FVTY1xS0N tLMo2VX0l/bPDcB5s0IBpT7HtriiV8ucuSiubMB0wMUq3/92jUMz0FMIaBqqtKlXx4/F TFlZRJr0OxkbruTyZc4ZuRQqBeDXPluMJdi5sJKies+yB4tZDoiLjQRA5TWzee3X7lWq KxNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=Torrz4DvFgyBpq5YRoDhNiX3Xla+aWY17z7TTn3BOUk=; fh=Ss9aHFYxoks5hmE4AcxF0JK9jjHQKcamnQywq3nEuQw=; b=XNR1qFzPEzlns26+Wz01mdJXcb0/c/qcjuWjYBffLSjoYoOJWkKb0TsxKTh14dp1d6 1gNsJanVJ+k/cEOMkdYGIuYuNPKCwu9A44Z39uEsSbLbcxAwkguMXB0v6i4f8AumPyfq IkVpciOuD8ZRhHxz2w2h+gzrDhyTSRmyFtwNmZo/sYLJD5HT146CYyfWYJ8uOaCij5Ce 9cY48JTz54LRPBfEfBc9KKzWLsslwa0yA05ncyUE/6o/LQHD7xdIjLsneIrI4Hpyomeq x2toj5y2kgH75zJQV10xiTdTFYt2cU0EPr4YsECUnsND8eQetRB1JY+YKY+kAKIE7cY4 Db6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=gN3hWjQ8; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=dT+Y99vv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id e9-20020aa798c9000000b00690f74dd2ccsi8003341pfm.69.2023.10.24.01.53.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 01:53:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=gN3hWjQ8; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=dT+Y99vv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 9EAA28030B4B; Tue, 24 Oct 2023 01:53:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233965AbjJXIxO (ORCPT + 26 others); Tue, 24 Oct 2023 04:53:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234082AbjJXIxD (ORCPT ); Tue, 24 Oct 2023 04:53:03 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7051C1728; Tue, 24 Oct 2023 01:52:47 -0700 (PDT) Date: Tue, 24 Oct 2023 08:52:45 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1698137565; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Torrz4DvFgyBpq5YRoDhNiX3Xla+aWY17z7TTn3BOUk=; b=gN3hWjQ8uNrPg9zL/Ihrn6OfWaFP+kZjiB9wduB7Bu/SXjZ3kXCqiAHgPjk/sQ2WnYE6ju r12SxDe2QmpWJugvlFzLpvwXQm27AtjnuizFnqGTU6a08K74duD7vqSZj3ZM+dLUm2ijq8 U1MuaqH2vSVGRPvjK/Owev4bPqHMQgiOBCdMu9BrxsHOGW0qiq3WXjMcmdIFKaLwjvXQP+ 9iOWNA2H/zJFYFpUsAuCpOVMwF5Ab1T9zJm5oh0+0YFJOW7xxUJadnaFVur6LpXBFbj3XU 36d05TpmyJH8hJKonpSik1GnfW2eTtN+6C6uBZtTYq/TqCxzftnfeRp+kReh+Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1698137565; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Torrz4DvFgyBpq5YRoDhNiX3Xla+aWY17z7TTn3BOUk=; b=dT+Y99vvD5XKo0i8vK1/GecOHgzv9LjYnx9exm9geXH55/sR9IIV4X5VNTLBN/lRqNnSaK gUWvkrsfnm2CY/AA== From: "tip-bot2 for Aaron Plattner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: objtool/core] objtool: Remove max symbol name length limitation Cc: Aaron Plattner , Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: =?utf-8?q?=3C41e94cfea1d9131b758dd637fecdeacd459d4584=2E1696355?= =?utf-8?q?111=2Egit=2Eaplattner=40nvidia=2Ecom=3E?= References: =?utf-8?q?=3C41e94cfea1d9131b758dd637fecdeacd459d4584=2E16963551?= =?utf-8?q?11=2Egit=2Eaplattner=40nvidia=2Ecom=3E?= MIME-Version: 1.0 Message-ID: <169813756504.3135.9831690835814050444.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 24 Oct 2023 01:53:22 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780626335664564550 X-GMAIL-MSGID: 1780626335664564550 The following commit has been merged into the objtool/core branch of tip: Commit-ID: f404a58dcf0c862b05602f641ce5fdd8b98fbc3a Gitweb: https://git.kernel.org/tip/f404a58dcf0c862b05602f641ce5fdd8b98fbc3a Author: Aaron Plattner AuthorDate: Wed, 04 Oct 2023 17:08:19 -07:00 Committer: Josh Poimboeuf CommitterDate: Thu, 05 Oct 2023 17:01:28 -07:00 objtool: Remove max symbol name length limitation If one of the symbols processed by read_symbols() happens to have a .cold variant with a name longer than objtool's MAX_NAME_LEN limit, the build fails. Avoid this problem by just using strndup() to copy the parent function's name, rather than strncpy()ing it onto the stack. Signed-off-by: Aaron Plattner Link: https://lore.kernel.org/r/41e94cfea1d9131b758dd637fecdeacd459d4584.1696355111.git.aplattner@nvidia.com Signed-off-by: Josh Poimboeuf --- tools/objtool/elf.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 081befa..3d27983 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -22,8 +22,6 @@ #include #include -#define MAX_NAME_LEN 128 - static inline u32 str_hash(const char *str) { return jhash(str, strlen(str), 0); @@ -515,7 +513,7 @@ static int read_symbols(struct elf *elf) /* Create parent/child links for any cold subfunctions */ list_for_each_entry(sec, &elf->sections, list) { sec_for_each_sym(sec, sym) { - char pname[MAX_NAME_LEN + 1]; + char *pname; size_t pnamelen; if (sym->type != STT_FUNC) continue; @@ -531,15 +529,15 @@ static int read_symbols(struct elf *elf) continue; pnamelen = coldstr - sym->name; - if (pnamelen > MAX_NAME_LEN) { - WARN("%s(): parent function name exceeds maximum length of %d characters", - sym->name, MAX_NAME_LEN); + pname = strndup(sym->name, pnamelen); + if (!pname) { + WARN("%s(): failed to allocate memory", + sym->name); return -1; } - strncpy(pname, sym->name, pnamelen); - pname[pnamelen] = '\0'; pfunc = find_symbol_by_name(elf, pname); + free(pname); if (!pfunc) { WARN("%s(): can't find parent function",