mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Josh Poimboeuf <jpoimboe@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>,
	Julien Thierry <jthierry@redhat.com>,
	Miroslav Benes <mbenes@suse.cz>,
	Raphael Gault <raphael.gault@arm.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Nicholas Piggin <npiggin@gmail.com>,
	Naveen N Rao <naveen@kernel.org>,
	Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>,
	linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	llvm@lists.linux.dev
Subject: [PATCH v5 00/15] powerpc/objtool: uaccess validation for PPC32 (v5)
Date: Wed, 15 Jan 2025 23:42:40 +0100	[thread overview]
Message-ID: <cover.1736955567.git.christophe.leroy@csgroup.eu> (raw)

This series adds UACCESS validation for PPC32. It includes
a dozen of changes to objtool core.

It applies on top of series "Cleanup/Optimise KUAP (v3)"
https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=363368&state=*

It is almost mature, performs code analysis for all PPC32.

In this version objtool switch table lookup has been enhanced to
handle nested switch tables.

Most object files are correctly decoded, only a few
'unreachable instruction' warnings remain due to more complex
fonctions which include back and forth jumps or branches. Two types
of switch tables are missed at the time being:
- When switch table address is temporarily saved in the stack before
being used.
- When there are backwards jumps in the path.

It allowed to detect some UACCESS mess in a few files. They've been
fixed through other patches.

Changes in v5:
- Rebased on top of https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git branch tip/objtool/core
- Use generic annotation infrastructure to annotate uaccess begin and end instructions

Changes in v4:
- Split series in two parts, the powerpc uaccess rework is submitted
separately, see https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=363368&state=*
- Support of UACCESS on all PPC32 including book3s/32 which was missing in v3.
- More elaborated switch tables lookup.
- Patches 2, 7, 8, 9, 10, 11 are new
- Patch 11 in series v3 is now removed.

Changes in v3:
- Rebased on top of a merge of powerpc tree and tip/objtool/core tree
- Simplified support for relative switch tables based on relocation type
- Taken comments from Peter


Christophe Leroy (15):
  objtool: Fix generic annotation infrastructure cross build
  objtool: Move back misplaced comment
  objtool: Allow an architecture to disable objtool on ASM files
  objtool: Fix JUMP_ENTRY_SIZE for bi-arch like powerpc
  objtool: Add INSN_RETURN_CONDITIONAL
  objtool: Add support for relative switch tables
  objtool: Merge mark_func_jump_tables() and add_func_jump_tables()
  objtool: Track general purpose register used for switch table base
  objtool: Find end of switch table directly
  objtool: When looking for switch tables also follow conditional and
    dynamic jumps
  objtool: .rodata.cst{2/4/8/16} are not switch tables
  objtool: Add support for more complex UACCESS control
  objtool: Prepare noreturns.h for more architectures
  powerpc/bug: Annotate reachable after warning trap
  powerpc: Implement UACCESS validation on PPC32

 arch/Kconfig                                  |   5 +
 arch/powerpc/Kconfig                          |   2 +
 arch/powerpc/include/asm/book3s/32/kup.h      |   2 +
 arch/powerpc/include/asm/bug.h                |  14 +-
 arch/powerpc/include/asm/nohash/32/kup-8xx.h  |   4 +-
 arch/powerpc/include/asm/nohash/kup-booke.h   |   4 +-
 arch/powerpc/kexec/core_32.c                  |   4 +-
 arch/powerpc/mm/nohash/kup.c                  |   2 +
 include/linux/objtool.h                       |   3 +
 include/linux/objtool_types.h                 |   2 +
 scripts/Makefile.lib                          |   4 +
 tools/include/linux/objtool_types.h           |   2 +
 tools/objtool/arch/powerpc/decode.c           | 150 +++++++++++++++++-
 .../arch/powerpc/include/arch/noreturns.h     |  11 ++
 .../arch/powerpc/include/arch/special.h       |  11 +-
 tools/objtool/arch/powerpc/special.c          |  40 ++++-
 .../objtool/arch/x86/include/arch/noreturns.h |  20 +++
 tools/objtool/arch/x86/special.c              |   8 +-
 tools/objtool/check.c                         | 129 ++++++++++-----
 tools/objtool/include/objtool/arch.h          |   1 +
 tools/objtool/include/objtool/check.h         |   6 +-
 tools/objtool/include/objtool/special.h       |   3 +-
 tools/objtool/noreturns.h                     |  14 +-
 tools/objtool/special.c                       |  55 ++++---
 24 files changed, 386 insertions(+), 110 deletions(-)
 create mode 100644 tools/objtool/arch/powerpc/include/arch/noreturns.h
 create mode 100644 tools/objtool/arch/x86/include/arch/noreturns.h

-- 
2.47.0


             reply	other threads:[~2025-01-15 22:50 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-15 22:42 Christophe Leroy [this message]
2025-01-15 22:42 ` [PATCH v5 01/15] objtool: Fix generic annotation infrastructure cross build Christophe Leroy
2025-01-15 22:42 ` [PATCH v5 02/15] objtool: Move back misplaced comment Christophe Leroy
2025-01-15 22:42 ` [PATCH v5 03/15] objtool: Allow an architecture to disable objtool on ASM files Christophe Leroy
2025-01-15 22:42 ` [PATCH v5 04/15] objtool: Fix JUMP_ENTRY_SIZE for bi-arch like powerpc Christophe Leroy
2025-01-15 22:42 ` [PATCH v5 05/15] objtool: Add INSN_RETURN_CONDITIONAL Christophe Leroy
2025-01-15 22:42 ` [PATCH v5 06/15] objtool: Add support for relative switch tables Christophe Leroy
2025-01-15 22:42 ` [PATCH v5 07/15] objtool: Merge mark_func_jump_tables() and add_func_jump_tables() Christophe Leroy
2025-01-15 22:42 ` [PATCH v5 08/15] objtool: Track general purpose register used for switch table base Christophe Leroy
2025-01-15 22:42 ` [PATCH v5 09/15] objtool: Find end of switch table directly Christophe Leroy
2025-01-15 22:42 ` [PATCH v5 10/15] objtool: When looking for switch tables also follow conditional and dynamic jumps Christophe Leroy
2025-01-15 22:42 ` [PATCH v5 11/15] objtool: .rodata.cst{2/4/8/16} are not switch tables Christophe Leroy
2025-01-15 22:42 ` [PATCH v5 12/15] objtool: Add support for more complex UACCESS control Christophe Leroy
2025-01-16  9:28   ` Peter Zijlstra
2025-01-15 22:42 ` [PATCH v5 13/15] objtool: Prepare noreturns.h for more architectures Christophe Leroy
2025-01-15 22:42 ` [PATCH v5 14/15] powerpc/bug: Annotate reachable after warning trap Christophe Leroy
2025-01-15 22:42 ` [PATCH v5 15/15] powerpc: Implement UACCESS validation on PPC32 Christophe Leroy
2025-01-16  6:25 ` [PATCH v5 00/15] powerpc/objtool: uaccess validation for PPC32 (v5) Christophe Leroy
2025-01-16  9:38 ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1736955567.git.christophe.leroy@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=jpoimboe@kernel.org \
    --cc=jthierry@redhat.com \
    --cc=justinstitt@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=llvm@lists.linux.dev \
    --cc=maddy@linux.ibm.com \
    --cc=mbenes@suse.cz \
    --cc=morbo@google.com \
    --cc=mpe@ellerman.id.au \
    --cc=nathan@kernel.org \
    --cc=naveen@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=npiggin@gmail.com \
    --cc=peterz@infradead.org \
    --cc=raphael.gault@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®