From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 2C64C26A08F for ; Fri, 26 Jun 2026 14:31:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782484313; cv=none; b=tJikyUNxu+Drfhy8kKNOrPJE0RcNDeES/IgY0Uu34v6uoPRlT639MmbFnOyjyQ0w9baZm1Q0ouRoijUrqnWWTVnu/QTegpYgMaGXZ01EcIYlAJKUz3M+btULvNhz4FYGJwUqC31eCh0PPZ3Y6eVMhqabmCDYcCqRLHuCcv56lZw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782484313; c=relaxed/simple; bh=yHO9lIWGfD+suLSmrQ8ITxtmnA98AOY5GBHGDkeoz0U=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=pHakHNTjT6CIV4/XIDIiqWJtxjQsrgFKeH87Z6uUnAe4NnceeErZusucxAY21uixcwtSzpPZ17lZyifdt6UABAbGYq2DsMJK3PM6tIY9yDmoPkoTXaKBv3bqTNhRsa39tAcBKIisRV9AwAiKmtGNDMC8YtkQzmDf6Nf7VZ8q+Yk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Fn1SIcXU; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Fn1SIcXU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD02A1F000E9; Fri, 26 Jun 2026 14:31:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1782484311; bh=i0wu8Q+145AvrvTbKuoqi8x8L/c1FZs+98nHo/LrncA=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=Fn1SIcXUvaCc2WIKpXFJng++cv0dJioTlTBlat5BSRME4QAgFkka7Jc04AA17TrCa qI1TkECYX0juNllZKBq9kan+sZgIilcFAmgp+4D7cdZ8UZoENHSShJT2+55Y+EV+3J LVLELPV5GgszkctmNXzPFgxsylZD8+wsGeoxCxZeJTHlD3Adh4EYvAf8oHv3Rxzoed YgSwBX7k9dVjKANDZ+63FdSZAbOmI8gDnulKcLtInVHU5UjafDrKCRVPGE/0tVy+Bu EYvLQyV5yW34+CD521wlj194xfqlxaWrdvv6LE/Ynb3iB2ZpDb2S6y9FW3+RqXwLHJ BNU/XEj/izWBw== Message-ID: <17eecc4d-ae7b-4c32-9edc-d3b8e131549c@kernel.org> Date: Fri, 26 Jun 2026 16:31:47 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] powerpc/syscall: Fix seccomp errno handling with GENERIC_ENTRY To: "Mukesh Kumar Chaurasiya (IBM)" , maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com, sshegde@linux.ibm.com, mkchauras@linux.ibm.com, kees@kernel.org, mark.rutland@arm.com, ryan.roberts@arm.com, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?Q?Michal_Such=C3=A1nek?= References: <20260624171520.772408-1-mkchauras@gmail.com> Content-Language: fr-FR From: "Christophe Leroy (CS GROUP)" In-Reply-To: <20260624171520.772408-1-mkchauras@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Le 24/06/2026 à 19:15, Mukesh Kumar Chaurasiya (IBM) a écrit : > After enabling GENERIC_ENTRY on PowerPC, seccomp filters using > SCMP_ACT_ERRNO without an explicit errnoRet value return ENOSYS > (Function not implemented) instead of the expected EPERM (Operation > not permitted). > > The issue occurs in system_call_exception() when syscall_enter_from_user_mode() > returns -1 to indicate the syscall should be skipped (e.g., blocked by seccomp). > The current code treats this -1 as a syscall number and compares it against > NR_syscalls. Since -1 (when cast to unsigned long) is greater than NR_syscalls, > the code incorrectly returns -ENOSYS, overwriting the errno that seccomp > already set via syscall_set_return_value(). > > The generic entry code in syscall_trace_enter() calls __secure_computing(), > which sets the appropriate errno in regs->gpr[3] and returns -1 to signal > that the syscall should be skipped. However, the PowerPC syscall handler > was not checking for this -1 return value before validating the syscall > number. > > Fix this by explicitly checking if syscall_enter_from_user_mode() returns > -1 and returning the value already set in regs->gpr[3] (the errno from > seccomp) before performing the syscall number validation. > > This aligns PowerPC's behavior with other architectures using GENERIC_ENTRY > and restores correct seccomp errno handling. > > Fixes: bee25f97ad24 ("powerpc: Enable GENERIC_ENTRY feature") > Reported-by: Michal Suchánek Closes: https://lore.kernel.org/all/ajpp-_XnbF3UTM_E@kunlun.suse.cz/ > Signed-off-by: Mukesh Kumar Chaurasiya (IBM) > --- > arch/powerpc/kernel/syscall.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/arch/powerpc/kernel/syscall.c b/arch/powerpc/kernel/syscall.c > index a9da2af6efa8..5b58c8d396c8 100644 > --- a/arch/powerpc/kernel/syscall.c > +++ b/arch/powerpc/kernel/syscall.c > @@ -22,6 +22,10 @@ notrace long system_call_exception(struct pt_regs *regs, unsigned long r0) > add_random_kstack_offset(); > r0 = syscall_enter_from_user_mode(regs, r0); > > + /* Seccomp or ptrace may have set return value, skip syscall */ > + if (unlikely(r0 == -1L)) Is it really needed to add the L after 1 ? > + return regs->gpr[3]; > + > if (unlikely(r0 >= NR_syscalls)) { > if (unlikely(trap_is_unsupported_scv(regs))) { > /* Unsupported scv vector */