From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C7F22FCC17; Wed, 17 Sep 2025 16:04:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758125067; cv=none; b=PXDolvOqcy61AnZEc6CL8mDGJXYCWThj+2QGYRrJKejabAvUSxKgVsRRxLQOWmjTw14HW4IDa8HYRLfRTXNjc0WgIZp0HNpKzGw/ab/hyuIOpO7ryqDrGRENo68yNAl1/bELzUfPBKFuCq/FIUQpiiFzPulq4yfrpvtIy40jXAU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758125067; c=relaxed/simple; bh=FEuGGqp7EQ+m4KSpW2oWnEg7GiC0+WGYaWwZBkAbIPw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gotF6JB75wFx5O+uoYirW1rDOpJBxYaG0OWdUvsJ4kEgc1YLvc3nwYmWmR8oi/Pq3pAIvrqIu7I/kzRhJ8vT7xmUGhAJFO/YYXgAZCR5k5h3PFCHYwghOsxvUkfVrXZxt/Jh3auvsJRmwWU82Or0XRAw1Mq7rX1sKl8bEurS0N0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ush6UBoG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ush6UBoG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BD87C4CEF7; Wed, 17 Sep 2025 16:04:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758125066; bh=FEuGGqp7EQ+m4KSpW2oWnEg7GiC0+WGYaWwZBkAbIPw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ush6UBoGzqYsE2nkRhe5CZsEZL/xz1nT68MTTu+fsmIkPQsJqnvq4n9KOPs9J40El JTE1NSJJ1eY8UyUzAiQoRbNgyyTryELMmlqrngtOQJo1cAh/NqctQO7MDk3T7FDO+p jwwfjDZpeMY9ibG+s+xUyn4ImGLlOOGVJq3JABcs0dwtdtPSiJ1iGaGA6PDkAmaaIO 26HXRlPNCAJQR9EQqG1peCtLf7j0/vkWeRQaC+ga81Und4rt+mBsDIk08MOagoYOyp UsFppbAlwB9VmUr+oGT3a2TPZiiIfTEsMHbSKzRNJUSLwajSGZKz/MTXEEdAccTdAy eBbI8fmxLIfsQ== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Petr Mladek , Miroslav Benes , Joe Lawrence , live-patching@vger.kernel.org, Song Liu , laokz , Jiri Kosina , Marcos Paulo de Souza , Weinan Liu , Fazla Mehrab , Chen Zhongjin , Puranjay Mohan , Dylan Hatch , Peter Zijlstra Subject: [PATCH v4 15/63] objtool: Propagate elf_truncate_section() error in elf_write() Date: Wed, 17 Sep 2025 09:03:23 -0700 Message-ID: <306f67f2f6762f80c9ff72afd363f97535b1a4b5.1758067942.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Properly check and propagate the return value of elf_truncate_section() to avoid silent failures. Signed-off-by: Josh Poimboeuf --- tools/objtool/elf.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index b009d9feed760..19e249f4783cf 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -1307,7 +1307,6 @@ static int elf_truncate_section(struct elf *elf, struct section *sec) for (;;) { /* get next data descriptor for the relevant section */ data = elf_getdata(s, data); - if (!data) { if (size) { ERROR("end of section data but non-zero size left\n"); @@ -1343,8 +1342,8 @@ int elf_write(struct elf *elf) /* Update changed relocation sections and section headers: */ list_for_each_entry(sec, &elf->sections, list) { - if (sec->truncate) - elf_truncate_section(elf, sec); + if (sec->truncate && elf_truncate_section(elf, sec)) + return -1; if (sec_changed(sec)) { s = elf_getscn(elf->elf, sec->idx); -- 2.50.0