From nobody Fri Apr 3 16:01:36 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 069D637187C for ; Tue, 24 Mar 2026 09:49:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774345775; cv=none; b=GUv17WH9YT+m9RzNn98o73PWLiekIQBi775ECeAcLcB5VxIHdr4VQNw9H39WbDlKaih1cjGftNfDarn8ATFPa8p/+n++6LKf383YK0NIhAPCZORcc/y141tltMk4pbT8ZGnnRkCqOuVlPQi5iS8DL9rUyLiek8mxnYRVKf5fMjI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774345775; c=relaxed/simple; bh=Sv5tdIqdM9tfRNVlMP90CjpmuQ5qdZ9fHuZUzU14wrk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DgS2NuGqdGsDSc5PjOFZ7a6tLzOor5bE90j3ttJ+GtOzwbNW86tQAHnmtDo/+1hLfaLjsQd8VL0E88XUEN+tdCyu/BxPdfalzvL9iaB7gDbGaj6E2dVB6wOMlLjNEaLNCHWnXRZRKcIFG49ISs45J0fs0HhlRJpEBnGfoGC1G2A= 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=bLfcN7Lc; arc=none smtp.client-ip=170.10.129.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="bLfcN7Lc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774345773; 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=GVAdBf/4VOwMJGhw64JQ9TCrIsoGFX1EbfapY7OUslA=; b=bLfcN7LcNrM3Pgv4lH4mjzDNIYOhGLvpmc3h69qAho/zGPM3opwy3WurqvNuC3l5mKAYIJ 09IPEt/mjRLGWl3u20tev2ROTswYE0Ck6xxpx4GuSk1qbglIlhNvTO4kV3yQdki1H6TfMX B0s6SRs+V4G9GBmuZhgVnWDGWWxRc3A= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-615-jysL9BghPfWrhe26ZbG_ag-1; Tue, 24 Mar 2026 05:49:29 -0400 X-MC-Unique: jysL9BghPfWrhe26ZbG_ag-1 X-Mimecast-MFC-AGG-ID: jysL9BghPfWrhe26ZbG_ag_1774345765 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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 297341800281; Tue, 24 Mar 2026 09:49:25 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.44.34.246]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B0EDC30001BB; Tue, 24 Mar 2026 09:49:12 +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: [RFC PATCH v8 03/10] objtool: Always pass a section to validate_unwind_hints() Date: Tue, 24 Mar 2026 10:47:54 +0100 Message-ID: <20260324094801.3092968-4-vschneid@redhat.com> In-Reply-To: <20260324094801.3092968-1-vschneid@redhat.com> References: <20260324094801.3092968-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: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" 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 418dce921e48d..b6e63d5beecc3 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -4064,13 +4064,8 @@ static int validate_unwind_hints(struct objtool_file= *file, struct section *sec) =20 init_insn_state(file, &state, sec); =20 - if (sec) { - sec_for_each_insn(file, sec, insn) - warnings +=3D validate_unwind_hint(file, insn, &state); - } else { - for_each_insn(file, insn) - warnings +=3D validate_unwind_hint(file, insn, &state); - } + sec_for_each_insn(file, sec, insn) + warnings +=3D validate_unwind_hint(file, insn, &state); =20 return warnings; } @@ -4567,6 +4562,21 @@ static int validate_functions(struct objtool_file *f= ile) return warnings; } =20 +static int validate_file_unwind_hints(struct objtool_file *file) +{ + struct section *sec; + int warnings =3D 0; + + for_each_sec(file->elf, sec) { + if (!is_text_sec(sec)) + continue; + + warnings +=3D validate_unwind_hints(file, sec); + } + + return warnings; +} + static void mark_endbr_used(struct instruction *insn) { if (!list_empty(&insn->call_node)) @@ -4976,7 +4986,8 @@ int check(struct objtool_file *file) int w =3D 0; =20 w +=3D validate_functions(file); - w +=3D validate_unwind_hints(file, NULL); + w +=3D validate_file_unwind_hints(file); + if (!w) w +=3D validate_reachable_instructions(file); =20 --=20 2.52.0