git: 4d0dc71a7bf0 - stable/12 - linux_renameat2: improve flag checks

Dmitry Chagin dchagin at FreeBSD.org
Thu Jun 10 09:31:06 UTC 2021


The branch stable/12 has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=4d0dc71a7bf0e5ffd2a4a60244f915642d3d2899

commit 4d0dc71a7bf0e5ffd2a4a60244f915642d3d2899
Author:     Ed Maste <emaste at FreeBSD.org>
AuthorDate: 2019-11-07 15:51:44 +0000
Commit:     Dmitry Chagin <dchagin at FreeBSD.org>
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
  */


More information about the dev-commits-src-all mailing list