[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zh1eDU1L1FbFwZzT@kernel.org>
Date: Mon, 15 Apr 2024 20:04:13 +0300
From: Mike Rapoport <rppt@...nel.org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: linux-kernel@...r.kernel.org, Andrew Morton <akpm@...ux-foundation.org>,
Andy Lutomirski <luto@...nel.org>, Arnd Bergmann <arnd@...db.de>,
Catalin Marinas <catalin.marinas@....com>,
Christoph Hellwig <hch@...radead.org>, Helge Deller <deller@....de>,
Lorenzo Stoakes <lstoakes@...il.com>,
Luis Chamberlain <mcgrof@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Masami Hiramatsu <mhiramat@...nel.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Michael Ellerman <mpe@...erman.id.au>,
Palmer Dabbelt <palmer@...belt.com>,
Russell King <linux@...linux.org.uk>, Song Liu <song@...nel.org>,
Steven Rostedt <rostedt@...dmis.org>,
Thomas Gleixner <tglx@...utronix.de>,
Uladzislau Rezki <urezki@...il.com>, Will Deacon <will@...nel.org>,
bpf@...r.kernel.org, linux-arch@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-mm@...ck.org,
linux-modules@...r.kernel.org, linux-parisc@...r.kernel.org,
linux-riscv@...ts.infradead.org, linux-trace-kernel@...r.kernel.org,
linuxppc-dev@...ts.ozlabs.org, x86@...nel.org
Subject: Re: [RFC PATCH 5/7] x86/module: perpare module loading for ROX
allocations of text
On Mon, Apr 15, 2024 at 12:43:16PM +0200, Peter Zijlstra wrote:
> On Thu, Apr 11, 2024 at 07:05:24PM +0300, Mike Rapoport wrote:
> > diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
> > index 45a280f2161c..b4d6868df573 100644
> > --- a/arch/x86/kernel/alternative.c
> > +++ b/arch/x86/kernel/alternative.c
>
> > @@ -504,17 +513,17 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start,
> > * patch if feature is *NOT* present.
> > */
> > if (!boot_cpu_has(a->cpuid) == !(a->flags & ALT_FLAG_NOT)) {
> > - optimize_nops_inplace(instr, a->instrlen);
> > + optimize_nops_inplace(wr_instr, a->instrlen);
> > continue;
> > }
> >
> > - DPRINTK(ALT, "feat: %d*32+%d, old: (%pS (%px) len: %d), repl: (%px, len: %d) flags: 0x%x",
> > + DPRINTK(ALT, "feat: %d*32+%d, old: (%px (%px) len: %d), repl: (%px (%px), len: %d) flags: 0x%x",
> > a->cpuid >> 5,
> > a->cpuid & 0x1f,
> > - instr, instr, a->instrlen,
> > - replacement, a->replacementlen, a->flags);
> > + instr, wr_instr, a->instrlen,
> > + replacement, wr_replacement, a->replacementlen, a->flags);
>
> I think this, and
I've found printing both address handy when I debugged it, but no strong
feelings here.
> >
> > - memcpy(insn_buff, replacement, a->replacementlen);
> > + memcpy(insn_buff, wr_replacement, a->replacementlen);
> > insn_buff_sz = a->replacementlen;
> >
> > if (a->flags & ALT_FLAG_DIRECT_CALL) {
> > @@ -528,11 +537,11 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start,
> >
> > apply_relocation(insn_buff, a->instrlen, instr, replacement, a->replacementlen);
> >
> > - DUMP_BYTES(ALT, instr, a->instrlen, "%px: old_insn: ", instr);
> > + DUMP_BYTES(ALT, wr_instr, a->instrlen, "%px: old_insn: ", instr);
>
> this, want to remain as is.
here wr_instr is the buffer to dump:
DUMP_BYTES(type, buf, len, fmt, args...)
rather than an address, which remained 'instr'.
> > DUMP_BYTES(ALT, replacement, a->replacementlen, "%px: rpl_insn: ", replacement);
> > DUMP_BYTES(ALT, insn_buff, insn_buff_sz, "%px: final_insn: ", instr);
> >
> > - text_poke_early(instr, insn_buff, insn_buff_sz);
> > + text_poke_early(wr_instr, insn_buff, insn_buff_sz);
> > }
> >
> > kasan_enable_current();
>
> The rationale being that we then print an address that can be correlated
> to the kernel image (provided one either kills kaslr or adjusts for it).
--
Sincerely yours,
Mike.
Powered by blists - more mailing lists