lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200110121234.GA31707@lakrids.cambridge.arm.com>
Date:   Fri, 10 Jan 2020 12:12:35 +0000
From:   Mark Rutland <mark.rutland@....com>
To:     "chengjian (D)" <cj.chengjian@...wei.com>
Cc:     linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
        xiexiuqi@...wei.com, huawei.libin@...wei.com,
        bobo.shaobowang@...wei.com, catalin.marinas@....com, duwe@....de
Subject: Re: [RFC PATCH] arm64/ftrace: support dynamically allocated
 trampolines

On Fri, Jan 10, 2020 at 07:28:17PM +0800, chengjian (D) wrote:
> On 2020/1/10 0:48, Mark Rutland wrote:
> > On Thu, Jan 09, 2020 at 02:27:36PM +0000, Cheng Jian wrote:
> > > +	/*
> > > +	 * Update the trampoline ops REF
> > > +	 *
> > > +	 * OLD INSNS : ldr_l x2, function_trace_op
> > > +	 *	adrp	x2, sym
> > > +	 *	ldr	x2, [x2, :lo12:\sym]
> > > +	 *
> > > +	 * NEW INSNS:
> > > +	 *	nop
> > > +	 *	ldr x2, <ftrace_ops>
> > > +	 */
> > > +	op_offset -= start_offset_common;
> > > +	ip = (unsigned long)trampoline + caller_size + op_offset;
> > > +	nop = aarch64_insn_gen_nop();
> > > +	memcpy((void *)ip, &nop, AARCH64_INSN_SIZE);
> > > +
> > > +	op_offset += AARCH64_INSN_SIZE;
> > > +	ip = (unsigned long)trampoline + caller_size + op_offset;
> > > +	offset = (unsigned long)ptr - ip;
> > > +	if (WARN_ON(offset % AARCH64_INSN_SIZE != 0))
> > > +		goto free;
> > > +	offset = offset / AARCH64_INSN_SIZE;
> > > +	pc_ldr |= (offset & mask) << shift;
> > > +	memcpy((void *)ip, &pc_ldr, AARCH64_INSN_SIZE);
> > I think it would be much better to have a separate template for the
> > trampoline which we don't have to patch in this way. It can even be
> > placed into a non-executable RO section, since the template shouldn't be
> > executed directly.
> 
> A separate template !
> 
> This may be a good way, and I think the patching here is very HACK too(Not
> very friendly).
> 
> I had thought of other ways before, similar to the method on X86_64,
> remove the ftrace_common(), directly modifying
> ftrace_caller/ftrace_reg_caller, We will only need to copy the code
> once in this way, and these is no need to modify call ftrace_common to
> NOP.
> 
> Using a trampoline template sounds great. but this also means that we
> need to aintain a template(or maybe two templates: one for caller,
> another for regs_caller).
> 
> Hi, Mark, what do you think about it ?

I think that having two templates is fine. We can factor
ftrace_common_return into a macro mirroring ftrace_regs_entry, and I
suspect we can probably figure out some way to factor the common
portion.

Thanks,
Mark.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ