From owner-dev-commits-src-branches@freebsd.org Thu Jun 10 09:31:05 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BCB29646030; Thu, 10 Jun 2021 09:31:05 +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 4G0zHY4F9Sz3lWn; Thu, 10 Jun 2021 09:31:05 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 55BCD4EDF; Thu, 10 Jun 2021 09:31:05 +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 15A9V5pv030564; Thu, 10 Jun 2021 09:31:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15A9V5Re030563; Thu, 10 Jun 2021 09:31:05 GMT (envelope-from git) Date: Thu, 10 Jun 2021 09:31:05 GMT Message-Id: <202106100931.15A9V5Re030563@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: 4d0dc71a7bf0 - stable/12 - linux_renameat2: improve flag checks 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/12 X-Git-Reftype: branch X-Git-Commit: 4d0dc71a7bf0e5ffd2a4a60244f915642d3d2899 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Jun 2021 09:31:05 -0000 The branch stable/12 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=4d0dc71a7bf0e5ffd2a4a60244f915642d3d2899 commit 4d0dc71a7bf0e5ffd2a4a60244f915642d3d2899 Author: Ed Maste AuthorDate: 2019-11-07 15:51:44 +0000 Commit: Dmitry Chagin CommitDate: 2021-06-10 09:27:45 +0000 linux_renameat2: improve flag checks In the cases where Linux returns an error (e.g. passing in an undefined flag) there's no need for us to emit a message. (The target of this message is a developer working on the linuxulatorm, not the author of presumably broken Linux software). Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21606 (cherry picked from commit 01b9ee4c509e2882147af35eea4772d06ecd4150) --- sys/compat/linux/linux_file.c | 7 +++++++ sys/compat/linux/linux_file.h | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c index dfa428e714d7..0b7efb6fa964 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -708,6 +708,13 @@ linux_renameat2(struct thread *td, struct linux_renameat2_args *args) int error, olddfd, newdfd; if (args->flags != 0) { + if (args->flags & ~(LINUX_RENAME_EXCHANGE | + LINUX_RENAME_NOREPLACE | LINUX_RENAME_WHITEOUT)) + return (EINVAL); + if (args->flags & LINUX_RENAME_EXCHANGE && + args->flags & (LINUX_RENAME_NOREPLACE | + LINUX_RENAME_WHITEOUT)) + return (EINVAL); linux_msg(td, "renameat2 unsupported flags 0x%x", args->flags); return (EINVAL); diff --git a/sys/compat/linux/linux_file.h b/sys/compat/linux/linux_file.h index 756a3b2be3e2..c3b1eeb8d7f4 100644 --- a/sys/compat/linux/linux_file.h +++ b/sys/compat/linux/linux_file.h @@ -127,6 +127,13 @@ #define LINUX_F_UNLCK 2 #endif +/* + * renameat2 flags + */ +#define LINUX_RENAME_NOREPLACE 0x00000001 +#define LINUX_RENAME_EXCHANGE 0x00000002 +#define LINUX_RENAME_WHITEOUT 0x00000004 + /* * sync_file_range flags */