From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 9A2D73E8C75 for ; Tue, 5 May 2026 08:25:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777969540; cv=none; b=KAOJC/S0dd6YhtKNoVwbrsu9IH+eqZ5FhniAWQrpgdRAhqnnTfLZ/q6QV+ev4LUG8rh6Dliyof6sQru0qQTUTLX+/TZ4DGfu7Njx1EpMP5HEMOuYCR2Z4bF5cZBdGAoOSEyYigDX5gYPiuLjf5vaV35WUmmKxCResmHm971gB70= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777969540; c=relaxed/simple; bh=truef8g1a1uN242gToC7q9tmLH49te3MnGnyXyQ7SlE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Do9TLs2EmWzK7dAunW52Wr862V2+yBVbcoxuJvnRugwb8O02s87M9KDxTUjcdnFfZP99AfE8mvd7JUUKw9UPGKd2BUwctTPWsgZ8UeRGbo5C7eyYJ2odtLdwBaNjRSd31ZqABz1pSF2v/pNL48eI/j1EEnemVAGoaxEZoSkiTdI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=CZI2N3zy; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CZI2N3zy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1777969538; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yTD/RbwiOAEe90IRytAtcXzZ3OEY5xYld5NZyJdjp8w=; b=CZI2N3zypOCeFwNYHKgElhsOeEfwFfSIOM0NqOfby2hbw1nRIro414FMsbbv8wOgY+LWlL KCz7+Pa2nRiVW34ow1D5D3g8gpV9GSnc+/WJfhRyRwADssg0T/ZPBIEXqCTgfuvNJEtuWe UROjTAU2TYeMSxoZjOQmf8nvdVzLKdc= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-346-2ibne06SNhSevaGiIhCsqQ-1; Tue, 05 May 2026 04:25:32 -0400 X-MC-Unique: 2ibne06SNhSevaGiIhCsqQ-1 X-Mimecast-MFC-AGG-ID: 2ibne06SNhSevaGiIhCsqQ_1777969526 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4AD0019560B4; Tue, 5 May 2026 08:25:26 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.44.48.109]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9184530001A1; Tue, 5 May 2026 08:25:11 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , Arnaldo Carvalho de Melo , Josh Poimboeuf , Paolo Bonzini , Arnd Bergmann , Frederic Weisbecker , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Sami Tolvanen , "David S. Miller" , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Mel Gorman , Andrew Morton , Masahiro Yamada , Han Shen , Rik van Riel , Jann Horn , Dan Carpenter , Oleg Nesterov , Juri Lelli , Clark Williams , Tomas Glozar , Yair Podemsky , Marcelo Tosatti , Daniel Wagner , Petr Tesarik , Shrikanth Hegde Subject: [PATCH v9 03/10] objtool: Always pass a section to validate_unwind_hints() Date: Tue, 5 May 2026 10:23:48 +0200 Message-ID: <20260505082355.1982003-4-vschneid@redhat.com> In-Reply-To: <20260505082355.1982003-1-vschneid@redhat.com> References: <20260505082355.1982003-1-vschneid@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 When passing a NULL @sec to validate_unwind_hints(), it is unable to properly initialize the insn_state->noinstr passed down during validation. This means we lose noinstr validation of the hints. That validation currently happens when 'opts.noinstr' is true but 'validate_branch_enabled()' isn't. In other words, this will run noinstr validation of hints: $ objtool --noinstr --link [...] but this won't: $ objtool --noinstr --link --uaccess [...] Always pass a valid section to validate_unwind_hints(), so that noinstr validation of hints happens regardless of the value of validate_branch_enabled(). Signed-off-by: Valentin Schneider --- tools/objtool/check.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index ba943bbbc51db..2bb927aa34047 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -4118,13 +4118,8 @@ static int validate_unwind_hints(struct objtool_file *file, struct section *sec) init_insn_state(file, &state, sec); - if (sec) { - sec_for_each_insn(file, sec, insn) - warnings += validate_unwind_hint(file, insn, &state); - } else { - for_each_insn(file, insn) - warnings += validate_unwind_hint(file, insn, &state); - } + sec_for_each_insn(file, sec, insn) + warnings += validate_unwind_hint(file, insn, &state); return warnings; } @@ -4621,6 +4616,21 @@ static int validate_functions(struct objtool_file *file) return warnings; } +static int validate_file_unwind_hints(struct objtool_file *file) +{ + struct section *sec; + int warnings = 0; + + for_each_sec(file->elf, sec) { + if (!is_text_sec(sec)) + continue; + + warnings += validate_unwind_hints(file, sec); + } + + return warnings; +} + static void mark_endbr_used(struct instruction *insn) { if (!list_empty(&insn->call_node)) @@ -5030,7 +5040,8 @@ int check(struct objtool_file *file) int w = 0; w += validate_functions(file); - w += validate_unwind_hints(file, NULL); + w += validate_file_unwind_hints(file); + if (!w) w += validate_reachable_instructions(file); -- 2.52.0