From nobody Fri Jun 17 19:37:54 2022 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 26C4185ACEE; Fri, 17 Jun 2022 19:37:55 +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 4LPq8245Hwz3Q7s; Fri, 17 Jun 2022 19:37:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494674; 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=Z8vCIFUdwVIQOqzONBhPCSWeObM6txmDerjFEYe8d9U=; b=JTZFyVVcZVR6bxebZ6bwd5Q7ORrUkqY2RxNGH48BFt3YEufzzeZwuW8WV4mGIt0o/lszeM bqlzcf17N+LOxkrxW3AArWdeb5ux4RyiXtcPECC8xZq43CwV488GJCSdBJzhFcSZ2CDoPq mOvGIk468mxo4ieJWEfcL6kQkPPYEU2O6DhFLXmqHKvY9Mc9pdc/renm/4wPH8+waTkncH 0n5WV9yVUntrX7qrbKdnu6em3gloyP6zQEkA++8f5OUvAgttpVsTJv7CVmbgnYFlfS64S/ ktY7CZAEFMGp5Nwll0cfNnFflcV9I8/Wrx8i/0DZEIpGhxXHf2NCZhwnx0aDOQ== 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 3A02525C8B; Fri, 17 Jun 2022 19:37:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25HJbsKx013965; Fri, 17 Jun 2022 19:37:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25HJbstR013964; Fri, 17 Jun 2022 19:37:54 GMT (envelope-from git) Date: Fri, 17 Jun 2022 19:37:54 GMT Message-Id: <202206171937.25HJbstR013964@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: 15e715fe7c0b - stable/13 - linux(4): Implement faccessat2 system call. 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 15e715fe7c0bb495787a1fec9de8aecd732304ed Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494674; 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=Z8vCIFUdwVIQOqzONBhPCSWeObM6txmDerjFEYe8d9U=; b=sDYMtbCwwjtTDAyMZSe7+kSJdVJ9RTyYGwBKrLEE8C4CMI2OypXu6iFbBJrZ24t8V2kbHo dj2lwGL7XA5aU30Yi+OP/p4Z338Ud+bYcBjtuCzn/87Snj5HdlP+Bn3dvMMu3O/Buifn2K TE7EFZHe0k3SpgeChkpOEuNxVt5ichjp+0J8P2lB7j3qBrZwp/v1EbNxha4fv5kxaQvCoj dO2JoQ6pp6OQuvCLobMMOWgzO3FGivW27N7/dEH+UESVoqg9TO7e6hmenRLy+YVSsSctLs YslRXLeRLycRVD9kgCvP5pw3Pgdolu8+g1csL2c/E7+wJZGnsGE3zuEhcRoyWQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655494674; a=rsa-sha256; cv=none; b=r+AjrhLNcuO+gXu36tlHj7RwvISVu2BbxgkTGWIWO/GJmfL8ttrLcpGjyDBv1CyzHh/TTR n0SaWJdvTAkAi+c1rEhiFa0zQU4T7SSPFbQjeb9IjkJgnref+KqxZ9eVFzo9oTAcN7DX6C d/GzbFPLKX67X58gNkRKFErDj4Wb/6qIgi8Xy1Y5voUvdVYURzHDnwZfM5rqFuXEtSB24X tAmSwfxmq6VfLk/Mwqi4vTSGwp37GYU/Mw14+i1DEmfDi78KgDf6JKHCJ+dYUBS5GEo47C M81tjpdKhN6dIWwUFuU2S1UxZ4qspjFxxntw6qH6hlWUW7A4QPpzzwduspds6A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=15e715fe7c0bb495787a1fec9de8aecd732304ed commit 15e715fe7c0bb495787a1fec9de8aecd732304ed Author: Dmitry Chagin AuthorDate: 2021-08-12 08:40:42 +0000 Commit: Dmitry Chagin CommitDate: 2022-06-17 19:33:26 +0000 linux(4): Implement faccessat2 system call. It's used by bash on arm64 with glibc-2.32. Reviewed by: trasz Differential Revision: https://reviews.freebsd.org/D31345 MFC after: 2 weeks (cherry picked from commit 13d79be9950dd820628906dcad4f4f1365b307b9) --- sys/amd64/linux/syscalls.master | 7 +++++- sys/amd64/linux32/syscalls.master | 7 +++++- sys/arm64/linux/syscalls.master | 7 +++++- sys/compat/linux/linux_file.c | 45 +++++++++++++++++++++++++++++++++------ sys/i386/linux/syscalls.master | 7 +++++- 5 files changed, 62 insertions(+), 11 deletions(-) diff --git a/sys/amd64/linux/syscalls.master b/sys/amd64/linux/syscalls.master index 4762a2ccc6a5..b9b88a036e61 100644 --- a/sys/amd64/linux/syscalls.master +++ b/sys/amd64/linux/syscalls.master @@ -2094,7 +2094,12 @@ int linux_pidfd_getfd(void); } 439 AUE_NULL STD { - int linux_faccessat2(void); + int linux_faccessat2( + l_int dfd, + const char *filename, + l_int amode, + l_int flags + ); } 440 AUE_NULL STD { int linux_process_madvise(void); diff --git a/sys/amd64/linux32/syscalls.master b/sys/amd64/linux32/syscalls.master index be6c150eebfa..60f227142f01 100644 --- a/sys/amd64/linux32/syscalls.master +++ b/sys/amd64/linux32/syscalls.master @@ -2496,7 +2496,12 @@ int linux_pidfd_getfd(void); } 439 AUE_NULL STD { - int linux_faccessat2(void); + int linux_faccessat2( + l_int dfd, + const char *filename, + l_int amode, + l_int flags + ); } 440 AUE_NULL STD { int linux_process_madvise(void); diff --git a/sys/arm64/linux/syscalls.master b/sys/arm64/linux/syscalls.master index ca45e33d4190..7b4ebbb2c2e9 100644 --- a/sys/arm64/linux/syscalls.master +++ b/sys/arm64/linux/syscalls.master @@ -1743,7 +1743,12 @@ int linux_pidfd_getfd(void); } 439 AUE_NULL STD { - int linux_faccessat2(void); + int linux_faccessat2( + l_int dfd, + const char *filename, + l_int amode, + l_int flags + ); } 440 AUE_NULL STD { int linux_process_madvise(void); diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c index 013c435756fb..a1146c6a195a 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$"); static int linux_common_open(struct thread *, int, const char *, int, int, enum uio_seg); +static int linux_do_accessat(struct thread *t, int, const char *, int, int); static int linux_getdents_error(struct thread *, int, int); static struct bsd_to_linux_bitmap seal_bitmap[] = { @@ -675,28 +676,58 @@ linux_access(struct thread *td, struct linux_access_args *args) } #endif -int -linux_faccessat(struct thread *td, struct linux_faccessat_args *args) +static int +linux_do_accessat(struct thread *td, int ldfd, const char *filename, + int amode, int flags) { char *path; int error, dfd; /* Linux convention. */ - if (args->amode & ~(F_OK | X_OK | W_OK | R_OK)) + if (amode & ~(F_OK | X_OK | W_OK | R_OK)) return (EINVAL); - dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; + dfd = (ldfd == LINUX_AT_FDCWD) ? AT_FDCWD : ldfd; if (!LUSECONVPATH(td)) { - error = kern_accessat(td, dfd, args->filename, UIO_USERSPACE, 0, args->amode); + error = kern_accessat(td, dfd, filename, UIO_USERSPACE, flags, amode); } else { - LCONVPATHEXIST_AT(td, args->filename, &path, dfd); - error = kern_accessat(td, dfd, path, UIO_SYSSPACE, 0, args->amode); + LCONVPATHEXIST_AT(td, filename, &path, dfd); + error = kern_accessat(td, dfd, path, UIO_SYSSPACE, flags, amode); LFREEPATH(path); } return (error); } +int +linux_faccessat(struct thread *td, struct linux_faccessat_args *args) +{ + + return (linux_do_accessat(td, args->dfd, args->filename, args->amode, + 0)); +} + +int +linux_faccessat2(struct thread *td, struct linux_faccessat2_args *args) +{ + int flags, unsupported; + + /* XXX. AT_SYMLINK_NOFOLLOW is not supported by kern_accessat */ + unsupported = args->flags & ~(LINUX_AT_EACCESS | LINUX_AT_EMPTY_PATH); + if (unsupported != 0) { + linux_msg(td, "faccessat2 unsupported flag 0x%x", unsupported); + return (EINVAL); + } + + flags = (args->flags & LINUX_AT_EACCESS) == 0 ? 0 : + AT_EACCESS; + flags |= (args->flags & LINUX_AT_EMPTY_PATH) == 0 ? 0 : + AT_EMPTY_PATH; + return (linux_do_accessat(td, args->dfd, args->filename, args->amode, + flags)); +} + + #ifdef LINUX_LEGACY_SYSCALLS int linux_unlink(struct thread *td, struct linux_unlink_args *args) diff --git a/sys/i386/linux/syscalls.master b/sys/i386/linux/syscalls.master index acbe5628e7ce..3a70c1352b44 100644 --- a/sys/i386/linux/syscalls.master +++ b/sys/i386/linux/syscalls.master @@ -2514,7 +2514,12 @@ int linux_pidfd_getfd(void); } 439 AUE_NULL STD { - int linux_faccessat2(void); + int linux_faccessat2( + l_int dfd, + const char *filename, + l_int amode, + l_int flags + ); } 440 AUE_NULL STD { int linux_process_madvise(void);