From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B6551EDA0F for ; Wed, 24 Jun 2026 17:44:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782323052; cv=none; b=TQqLUilKaqSxtrlf2LqeqdowwBE2DdThpMIe7oM5UbUeh9Rjlk2u+E4QNvDX6xA2h05O/gsO3k/VKfMSRXx5cXUS+A1ppfl3aRMiCbUbN6n94BFDrNAdIFik7y8BPUrlc9HKrHAXGSc1i99ZkQ0nvv0yaG6vVaLvPJcRIDv0RrM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782323052; c=relaxed/simple; bh=YNtUB5BCKTmedqCvwqzGaZfdW0wobs3B3hlIDa0jzVk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=G+wrtwlJBHa48/7b8qHZxEyY6owRlcd8w/u3hsGDcNCEuoa3bLWISUdwEfxU+79NL7/0LlyHP2eBopvaDqMtM7jaukLHePJhLjWHXvc5y43ZlRXEc9PARIK/I0SL0qktfmuAlzi99qEwzRuZOoWLcOtoD3Yzhged6qR2K30aDp4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=XlVdGCyx; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=0Ky3Tq8v; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=cYpPQfA9; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=xcUg5teN; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="XlVdGCyx"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="0Ky3Tq8v"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="cYpPQfA9"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="xcUg5teN" Received: from kunlun.suse.cz (unknown [IPv6:2a07:de40:b306:2000::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6C9166DBAA; Wed, 24 Jun 2026 17:44:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1782323049; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ftf6Cq+TeoEfMJbZKCvjkjFrgBlmmaoTuiEBwRaU3NY=; b=XlVdGCyxDPIohzZiucH0EPeqwmtM3wiwb1povF/9D6sWmJoep4Yc99n0XWBbLH/2dI2qEb P51vPdHrMnAUdi9KtOLCo0URN/sGIa44Eitp/fC2u5mRbwET7/GEurMBwOEv+dYOBgoxks 7SsLHmjR4g/xqQ2cO+7h7Qb4v4y3nmM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1782323049; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ftf6Cq+TeoEfMJbZKCvjkjFrgBlmmaoTuiEBwRaU3NY=; b=0Ky3Tq8vNMV9f2BlGQ/97An1FqFDlAGhM18iKq96LQZCohBDuWxuPLUECWE4x6jpicHVaw txaVOLDAZmiQJBBg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=cYpPQfA9; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=xcUg5teN DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1782323048; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ftf6Cq+TeoEfMJbZKCvjkjFrgBlmmaoTuiEBwRaU3NY=; b=cYpPQfA96PA1mDfUsAi0R/IFAvbwHvSitp0eICs623v2p6P5FjYNg6q4S0KEfWpStKYDtc gyEj3u/uND4Jqq1YoISs5Fh22r4szt7TPdxyQ6uQmK64KiDABgNBbLJs6bKgrHAQ5ml9DA L3x7+sg3tlHv1pVn6atNO4coOPk4qC0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1782323048; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ftf6Cq+TeoEfMJbZKCvjkjFrgBlmmaoTuiEBwRaU3NY=; b=xcUg5teN2oHQkwDJ0GXIrRMRqI2aPETl4r/mJqj5u4Xb1AftO/xnjeNiBvaWwm7ulyXYz3 uTntGJBwkOf9SpDQ== Date: Wed, 24 Jun 2026 19:44:07 +0200 From: Michal =?iso-8859-1?Q?Such=E1nek?= To: "Mukesh Kumar Chaurasiya (IBM)" Cc: maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com, chleroy@kernel.org, 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 Subject: Re: [PATCH] powerpc/syscall: Fix seccomp errno handling with GENERIC_ENTRY Message-ID: References: <20260624171520.772408-1-mkchauras@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260624171520.772408-1-mkchauras@gmail.com> X-Spamd-Bar: ++ X-Rspamd-Queue-Id: 6C9166DBAA X-Spam-Flag: NO X-Spam-Score: 2.49 X-Spam-Level: ** X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spamd-Result: default: False [2.49 / 50.00]; BAYES_HAM(-3.00)[100.00%]; HFILTER_HOSTNAME_UNKNOWN(2.50)[]; RDNS_NONE(2.00)[]; ONCE_RECEIVED(1.20)[]; HFILTER_HELO_IP_A(1.00)[kunlun.suse.cz]; NEURAL_HAM_LONG(-1.00)[-1.000]; HFILTER_HELO_NORES_A_OR_MX(0.30)[kunlun.suse.cz]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b306:2000::2:from]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_TWELVE(0.00)[12]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; ARC_NA(0.00)[]; FREEMAIL_TO(0.00)[gmail.com]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; FREEMAIL_CC(0.00)[linux.ibm.com,ellerman.id.au,gmail.com,kernel.org,arm.com,lists.ozlabs.org,vger.kernel.org]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[kunlun.suse.cz:mid,kunlun.suse.cz:helo,suse.de:email,suse.de:dkim]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DWL_DNSWL_BLOCKED(0.00)[suse.de:dkim]; MISSING_XM_UA(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; DKIM_TRACE(0.00)[suse.de:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b306:2000::2:from] On Wed, Jun 24, 2026 at 10:45:20PM +0530, Mukesh Kumar Chaurasiya (IBM) wrote: > 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 Tested-by: Michal Suchánek Thanks Michal > 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)) > + return regs->gpr[3]; > + > if (unlikely(r0 >= NR_syscalls)) { > if (unlikely(trap_is_unsupported_scv(regs))) { > /* Unsupported scv vector */ > -- > 2.54.0 >