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: <20251215021822.GA141785@chenghao-pc>
Date: Mon, 15 Dec 2025 10:18:22 +0800
From: Chenghao Duan <duanchenghao@...inos.cn>
To: Huacai Chen <chenhuacai@...nel.org>
Cc: yangtiezhu@...ngson.cn, hengqi.chen@...il.com, kernel@...0n.name,
	zhangtianyang@...ngson.cn, masahiroy@...nel.org,
	linux-kernel@...r.kernel.org, loongarch@...ts.linux.dev,
	bpf@...r.kernel.org, youling.tang@...ux.dev, jianghaoran@...inos.cn,
	vincent.mc.li@...il.com
Subject: Re: [PATCH v2 4/4] LoongArch: BPF: Enable BPF exception fixup for
 specific ADE subcode

On Sat, Dec 13, 2025 at 09:16:00PM +0800, Huacai Chen wrote:
> Hi, Chenghao,
> 
> On Fri, Dec 12, 2025 at 5:11 PM Chenghao Duan <duanchenghao@...inos.cn> wrote:
> >
> > This patch allows the LoongArch BPF JIT to handle recoverable memory
> > access errors generated by BPF_PROBE_MEM* instructions.
> >
> > When a BPF program performs memory access operations, the instructions
> > it executes may trigger ADEM exceptions. The kernel’s built-in BPF
> > exception table mechanism (EX_TYPE_BPF) will generate corresponding
> > exception fixup entries in the JIT compilation phase; however, the
> > architecture-specific trap handling function needs to proactively call
> > the common fixup routine to achieve exception recovery.
> >
> > do_ade(): fix EX_TYPE_BPF memory access exceptions for BPF programs,
> > ensure safe execution.
> >
> > Signed-off-by: Chenghao Duan <duanchenghao@...inos.cn>
> > ---
> >  arch/loongarch/kernel/traps.c | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/loongarch/kernel/traps.c b/arch/loongarch/kernel/traps.c
> > index da5926fead4a..4cf72e0af6a3 100644
> > --- a/arch/loongarch/kernel/traps.c
> > +++ b/arch/loongarch/kernel/traps.c
> > @@ -534,7 +534,13 @@ asmlinkage void noinstr do_fpe(struct pt_regs *regs, unsigned long fcsr)
> >
> >  asmlinkage void noinstr do_ade(struct pt_regs *regs)
> >  {
> > -       irqentry_state_t state = irqentry_enter(regs);
> > +       irqentry_state_t state;
> > +       unsigned int esubcode = FIELD_GET(CSR_ESTAT_ESUBCODE, regs->csr_estat);
> > +
> > +       if ((esubcode == EXSUBCODE_ADEM) && fixup_exception(regs))
> > +               return;
> No chance for ADEF? And I don't think ixup_exception() can be done out
> of irqentry_enter().

At present, exception fixes are only applied to memory-type BPF programs,
with no handling implemented for ADEF.

In the next version, fixup_exception will be processed internally within
irqentry_enter()/irqentry_exit, and the title will be revised with
reference to your suggestions.

Chenghao

> 
> This patch is needed by BPF but not part of BPF, so I think the
> subject should be:
> LoongArch: Enable exception fixup for specific ADE subcode
> 
> Huacai
> 
> > +
> > +       state = irqentry_enter(regs);
> >
> >         die_if_kernel("Kernel ade access", regs);
> >         force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *)regs->csr_badvaddr);
> > --
> > 2.25.1
> >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ