From nobody Fri Sep 1 08:14:43 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RcW6C3nFhz4sDc0; Fri, 1 Sep 2023 08:14:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RcW6C2rN3z3K8q; Fri, 1 Sep 2023 08:14:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1693556083; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NxxjKJ4OMMMvGj67gKkJw6Vasom8Jgn8wGm1tNYrZ7c=; b=haxY9R4RPQF7SM22sQCHcpTXGt2P7COCpTHgPZLTB6BOVhU/fIsYF4HYbnySiOtAvyg3a+ XbcAtmYfyu/dgRZgRyr0VFswmWmwCj1NWj+oJuoMGoRcpJSIOIquL9gTIEPVOnbCOm2dG6 6aLCiDdIxvcWTytS4Zp+A4DJ5A0lrX7kEdnkxYkDCUiv3/T/JZ4t0fnZWe2m4sfSJDxTPM 48tJlY6BSrBh3gN0HgVAH8lWKt8rDZgh22B+ATKNlffIdMHljLYnFxfccnkfw5y67nCMl5 JnK7fI5Ae7e2kZ5lKTnf2qig8/UNmLHEu+yzir4T1HzU3v12XlYGt4/u8SPayg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1693556083; a=rsa-sha256; cv=none; b=NODQHTWGVM2YjOktRZ65Iw5GvDHR/m2TIVFW15J66y3XMoyHjcMU9yn+dmGu1i/MAh5kOI PBloiE2gRQg+nTaSUQ1eD85mXr/ifkHyqj0gP1LNyFGsk0y0QwzYpNF7pZgQTQ5IuWiFRT CtrahEEGNyMven+mkmAFff7c0xYF5NMQQisgfPqRoowxTpqzgQleAeAltnaKkC2Wj7vTSP Fq1hz95x9mn83CG1P+DRXaAm6aHTstRkg4bymAdwQvMmrx8D8bS4GsMCwdjj3yo5Bxab4i Z4GbABv4BQ6C2ieCkuZh1Q1qlGuR/qU54cw80URqvLj7ZqbRhd3N9mUDkbNQSA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1693556083; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NxxjKJ4OMMMvGj67gKkJw6Vasom8Jgn8wGm1tNYrZ7c=; b=vubEYIcqUcZFK0hVBmHuPu/plY4nNdY4xecTEGlFeNuh7XORlYC5A5k8SUFDbHnrACrHKM jef7EsKMHmquFklrb1xFQi0S0QOI09h69k5CHQRyeVK/clkJlEBVIkb53TM9bqrEZ+CwZD tAtuIGv0q1Hbiv7yOY4lItITMLY2tPaMUaHvaWNQpgYwj9K0tCGxgpkKXtvYSxjHo8Zalx Uano2OdjHbntvdeZPHZZSKFAm2aSTlDlIo/iwiQxjeOScwrMQ1rfiey1yXifl59cpndulW zuOYDyyJLdFmMNawnFZvHukm+A9TC/v84lr2wL7RPRevtsjqcLvGbljQCj7kJw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RcW6C1ZjTztJR; Fri, 1 Sep 2023 08:14:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3818Ehxe008433; Fri, 1 Sep 2023 08:14:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3818EhNl008430; Fri, 1 Sep 2023 08:14:43 GMT (envelope-from git) Date: Fri, 1 Sep 2023 08:14:43 GMT Message-Id: <202309010814.3818EhNl008430@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 1bfc4574f786 - main - linux(4): Return ENOTSUP from xattr syscalls instead of EPERM List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1bfc4574f78653e4b64ac9dd31518c96a17fe52b Auto-Submitted: auto-generated The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=1bfc4574f78653e4b64ac9dd31518c96a17fe52b commit 1bfc4574f78653e4b64ac9dd31518c96a17fe52b Author: Dmitry Chagin AuthorDate: 2023-09-01 08:11:02 +0000 Commit: Dmitry Chagin CommitDate: 2023-09-01 08:11:02 +0000 linux(4): Return ENOTSUP from xattr syscalls instead of EPERM FreeBSD does not permits manipulating extended attributes in the system namespace by unprivileged accounts, even if account has appropriate privileges to access filesystem object. In Linux the system namespace is used to preserve posix acls. Some Gnu coreutils binaries uses posix acls, eg, install, ls. And fails if we unexpectedly return EPERM error from xattr system calls. In the other hands, in Linux read and write access to the system namespace depend on the policy implemented for each filesystem, so we'll mimics we're a filesystem that prohibits this for unpriveleged accounts. Reported by: zirias Tested by: zirias MFC after: 1 week --- sys/compat/linux/linux_xattr.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/sys/compat/linux/linux_xattr.c b/sys/compat/linux/linux_xattr.c index 2b46cf708c7d..74b47f1cbaec 100644 --- a/sys/compat/linux/linux_xattr.c +++ b/sys/compat/linux/linux_xattr.c @@ -87,6 +87,16 @@ struct removexattr_args { static char *extattr_namespace_names[] = EXTATTR_NAMESPACE_NAMES; +static int +error_to_xattrerror(int attrnamespace, int error) +{ + + if (attrnamespace == EXTATTR_NAMESPACE_SYSTEM && error == EPERM) + return (ENOTSUP); + else + return (error); +} + static int xatrr_to_extattr(const char *uattrname, int *attrnamespace, char *attrname) { @@ -188,7 +198,7 @@ listxattr(struct thread *td, struct listxattr_args *args) if (error == 0) td->td_retval[0] = cnt; free(data, M_LINUX); - return (error); + return (error_to_xattrerror(attrnamespace, error)); } int @@ -248,7 +258,7 @@ removexattr(struct thread *td, struct removexattr_args *args) else error = kern_extattr_delete_fd(td, args->fd, attrnamespace, attrname); - return (error); + return (error_to_xattrerror(attrnamespace, error)); } int @@ -392,7 +402,7 @@ setxattr(struct thread *td, struct setxattr_args *args) attrname, args->value, args->size); out: td->td_retval[0] = 0; - return (error); + return (error_to_xattrerror(attrnamespace, error)); } int