Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7377824rwp; Tue, 18 Jul 2023 14:31:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlGCbbgYP08JVq9HRkJQK1WxRPSaIn4/KFjKvHE+ru3G279OtQr0beokGViGdHVjCvBjdxGG X-Received: by 2002:a05:6a20:e685:b0:132:cb65:b47c with SMTP id mz5-20020a056a20e68500b00132cb65b47cmr13243006pzb.43.1689715911849; Tue, 18 Jul 2023 14:31:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689715911; cv=none; d=google.com; s=arc-20160816; b=a3+Wjhn6qf/FrGDgBZfZ67DFbT8QCzOVlax/7rujYhjZeDC+T0q+iYnPDRWKyUW+I1 jTA3QwmxzUHX05rnHrMFfzH0E/sbEDAGlh1z5+0Y74fAhbzv+yCnVmjyoqMPbZHnX7hV z3o5q6Y6+x+5LDzS2PEwSBDdFhUhxf49mUfsQpjkpqWyd7yTEF/68aeUdNR8bgIDoOPv qJ4lKu18fSXM3yB8U24M03cqgNL12x+YRLBHUbOxuPjeVJkwWOKEzwQjyj4HJaTDruAL sJkFWSLd41B4XiIyMErz7l4kkq2+IZmHez12NM3WuQcgmGDI+2m8wb4TVMTnBM4KYAS2 EujA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=BNmey0qZr97jeo30G5U3uLZrj89rJCidj/kyhI65D0c=; fh=56BxDnuqSjJLb82NVXA8ggk+LQCG2aE93wvPoUefepI=; b=a5NDuD94J0YxY0w96gsMwKYfpXPiQI6OKeg9O+SJiAdd9m8OCWTiZnpNpLIccMliat jmZDBhFxgIK02rdM7QTyyp07/zHgLWALF878MRWe6u5itSAuIBJUJ9MmCU8EVqpKLswZ KQ4z/iCdzluTvJHtgaTwDvd8QogHkZCbhTDVafD1ppa38+0yZmVoIAws5oChkVv+I94Z X8PzLCxjtXSkwkdYqLaygehyCabccNFTrMXp+TGlsFQAXSDWC+jHHzuI61wG7DiDVjfN miPhQDLAlAYqI+ESXM5DbIFrlSZFewWorV4hQZZ/nUA55ZX9sxVzFq1TxrtpLNiAt0/D SgpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TGWyCWuG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m37-20020a635825000000b0055373328de5si2078861pgb.204.2023.07.18.14.31.39; Tue, 18 Jul 2023 14:31:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TGWyCWuG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229752AbjGRVUd (ORCPT + 99 others); Tue, 18 Jul 2023 17:20:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229511AbjGRVUc (ORCPT ); Tue, 18 Jul 2023 17:20:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B04EEC0 for ; Tue, 18 Jul 2023 14:20:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4340760F16 for ; Tue, 18 Jul 2023 21:20:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DD7EC433C7; Tue, 18 Jul 2023 21:20:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689715230; bh=BNmey0qZr97jeo30G5U3uLZrj89rJCidj/kyhI65D0c=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=TGWyCWuGfwtm6RzVbBADCVL+Df6SgXsQAt+sY2GZ+UUNUYViUg2f1lYNlB/eGUrdO RH/HcOzcrTsE0N/Tw5jkh4WY25SiL8MRai4bDMvUZsexYR2yD5/6i+EzDhOjUA8Lrp lzIXLiKv5AN5SBXcwkHtHeAX0I6R/uRqV+X/hiH95oOBEpaJR5ETbAfu/3x2X7Ap2d ALLQigK3dQLYLoNdWOheg3FzlKRpVsX0CgSIHwv0PcS4fblkvvpPf+sMPOdGertzcf aLweMUgexBgjEliPFo4UFccw0FIM8ms1I5MNxMBvmKqInVsOagLjJdFwJf3m1XDQ9v 7Ax5DB6X7c24A== From: =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= To: Celeste Liu , Palmer Dabbelt , Paul Walmsley , Albert Ou , Guo Ren , =?utf-8?B?QmrDtnJu?= =?utf-8?B?IFTDtnBlbA==?= , Conor Dooley , linux-riscv@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Celeste Liu , Felix Yan , Ruizhe Pan , Shiqi Zhang Subject: Re: [PATCH v3] riscv: entry: set a0 = -ENOSYS only when syscall != -1 In-Reply-To: <20230718210037.250665-1-CoelacanthusHex@gmail.com> References: <20230718210037.250665-1-CoelacanthusHex@gmail.com> Date: Tue, 18 Jul 2023 23:20:27 +0200 Message-ID: <871qh4lxwk.fsf@all.your.base.are.belong.to.us> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Celeste Liu writes: > When we test seccomp with 6.4 kernel, we found errno has wrong value. > If we deny NETLINK_AUDIT with EAFNOSUPPORT, after f0bddf50586d, we will > get ENOSYS instead. We got same result with commit 9c2598d43510 ("riscv: = entry: > Save a0 prior syscall_enter_from_user_mode()"). > > After analysing code, we think that regs->a0 =3D -ENOSYS should only be e= xecuted > when syscall !=3D -1 In __seccomp_filter, when seccomp rejected this sysc= all with > specified errno, they will set a0 to return number as syscall ABI, and th= en > return -1. This return number is finally pass as return number of > syscall_enter_from_user_mode, and then is compared with NR_syscalls after > converted to ulong (so it will be ULONG_MAX). The condition > syscall < NR_syscalls will always be false, so regs->a0 =3D -ENOSYS is al= ways > executed. It covered a0 set by seccomp, so we always get ENOSYS when match > seccomp RET_ERRNO rule. > > Fixes: f0bddf50586d ("riscv: entry: Convert to generic entry") > Reported-by: Felix Yan > Co-developed-by: Ruizhe Pan > Signed-off-by: Ruizhe Pan > Co-developed-by: Shiqi Zhang > Signed-off-by: Shiqi Zhang > Signed-off-by: Celeste Liu > Tested-by: Felix Yan Reviewed-by: Bj=C3=B6rn T=C3=B6pel