New: renameat2 rename_noreplace
https://bugzilla.kernel.org/show_bug.cgi?id=197045
Bug ID: 197045
Summary: renameat2 rename_noreplace
Product: File System
Version: 2.5
Kernel Version: 4.4.0, 4.11.0
Hardware: All
OS: Linux
Tree: Mainline
Status: NEW
Severity: normal
Priority: P1
Component: ext4
Assignee: [email protected]
Reporter: [email protected]
Regression: Noon ext4 renameat2 fails in conjunction with RENAME_NOREPLACE, if the target file is not present
renameat2(AT_FDCWD, "rename-test-a", AT_FDCWD, "rename-test-c", RENAME_NOREPLACE) = -1 EINVAL (Invalid argument)
if the target file is present, functionality is ok
Signature · 2 lines
You are receiving this mail because: You are watching the assignee of the bug.
[Bug 197045] renameat2 rename_noreplace
https://bugzilla.kernel.org/show_bug.cgi?id=197045
--- Comment #1 from Martin Salbba ([email protected]) --- works with brtfs and xfs
Signature · 2 lines
You are receiving this mail because: You are watching the assignee of the bug.
[Bug 197045] renameat2 rename_noreplace
In reply to [email protected]https://bugzilla.kernel.org/show_bug.cgi?id=197045
Elvis Stansvik ([email protected]) changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |[email protected]
--- Comment #2 from Elvis Stansvik ([email protected]) --- Created attachment 260359
--> https://bugzilla.kernel.org/attachment.cgi?id=260359&action=edit
Test case showing the problem
A test case, run with a.out <srcfile> <dstfile>
Signature · 2 lines
You are receiving this mail because: You are watching the assignee of the bug.
[Bug 197045] renameat2 rename_noreplace
In reply to [email protected]https://bugzilla.kernel.org/show_bug.cgi?id=197045
--- Comment #3 from Elvis Stansvik ([email protected]) --- I'm hit by this on 4.10 a well (the default kernel on Ubuntu 16.04).
I attached a full test case showing.
Example run:
Quoted 9 lines
[estan@newton renameat2tc]$ gcc
renameat2.c
[estan@newton renameat2tc]$ touch foo
[estan@newton renameat2tc]$ ./a.out foo bar
Invalid argument
[estan@newton renameat2tc]$ uname -a
Linux newton 4.10.0-37-generic #41~16.04.1-Ubuntu SMP Fri Oct 6 22:42:59 UTC 2017x86_64x86_64x86_64GNU/Linux
[estan@newton renameat2tc]$ mount | grep " / "/dev/sda1on / type ext4 (rw,noatime,discard,errors=remount-ro,data=ordered)
The reason I discovered it was that Qt recently started using this syscall, which in turn made Qt Creator (a Qt application) fail to write its config files.
Signature · 2 lines
You are receiving this mail because: You are watching the assignee of the bug.
[Bug 197045] renameat2 rename_noreplace
In reply to [email protected]https://bugzilla.kernel.org/show_bug.cgi?id=197045
Thiago Macieira ([email protected]) changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |[email protected]
--- Comment #4 from Thiago Macieira ([email protected]) ---
Martin: can you confirm you did see these issues on 4.4 and 4.11? Elvis is reporting he did not see the issue on 4.4.
By any chance, are you also on Ubuntu?
Signature · 2 lines
You are receiving this mail because: You are watching the assignee of the bug.
[Bug 197045] renameat2 rename_noreplace
In reply to [email protected]https://bugzilla.kernel.org/show_bug.cgi?id=197045
--- Comment #5 from Elvis Stansvik ([email protected]) ---
Martin: I've just discovered that I only see this problem when on my eCryptfs encrypted home directory, not when testing in e.g. /tmp (unencrypted). Are you also using eCryptfs?
Signature · 2 lines
You are receiving this mail because: You are watching the assignee of the bug.
[Bug 197045] renameat2 rename_noreplace
In reply to [email protected]https://bugzilla.kernel.org/show_bug.cgi?id=197045
--- Comment #6 from Elvis Stansvik ([email protected]) --- So I guess I'm hitting this:
https://github.com/torvalds/linux/blob/master/fs/ecryptfs/inode.c#L592
Seems rename flags are not supported on ecryptfs, plain and simple?
Signature · 2 lines
You are receiving this mail because: You are watching the assignee of the bug.
[Bug 197045] renameat2 rename_noreplace
In reply to [email protected]https://bugzilla.kernel.org/show_bug.cgi?id=197045
--- Comment #7 from Elvis Stansvik ([email protected]) --- Here's the patch that added the if (flags) return EINVAL; for ecryptfs:
https://patchwork.kernel.org/patch/9295699/
So I guess it's just expected that it won't work on ecryptfs.
Signature · 2 lines
You are receiving this mail because: You are watching the assignee of the bug.
[Bug 197045] renameat2 rename_noreplace
In reply to [email protected]https://bugzilla.kernel.org/show_bug.cgi?id=197045
--- Comment #8 from Elvis Stansvik ([email protected]) --- Though I wonder if that is correct, or if it was hastily added by mistake for ecryptfs as part of that mass porting to rename2.. Maybe it would just work if ecryptfs_rename simply forwarded the flags to vfs_rename without checking them..? Someone who knows the code will have to answer.
Signature · 2 lines
You are receiving this mail because: You are watching the assignee of the bug.
[Bug 197045] renameat2 rename_noreplace
In reply to [email protected]https://bugzilla.kernel.org/show_bug.cgi?id=197045
--- Comment #9 from Elvis Stansvik ([email protected]) --- Scratch that, it's obviously not that easy.
Signature · 2 lines
You are receiving this mail because: You are watching the assignee of the bug.
[Bug 197045] renameat2 rename_noreplace
In reply to [email protected]https://bugzilla.kernel.org/show_bug.cgi?id=197045
--- Comment #10 from Thiago Macieira ([email protected]) --- No, it seems that non-local filesystems need specific code to guarante RENAME_NOREPLACE, so the EINVAL error is legitimate.
Signature · 2 lines
You are receiving this mail because: You are watching the assignee of the bug.
[Bug 197045] renameat2 rename_noreplace
In reply to [email protected]https://bugzilla.kernel.org/show_bug.cgi?id=197045
Theodore Tso ([email protected]) changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |[email protected]
Resolution|--- |INVALID--- Comment #11 from Theodore Tso ([email protected]) ---
I've confirmed that the test case works just fine on plain ext4, using the 4.13 based kernel. I've also confirmed that it works just fine if you use ext4 encryption. (I suggest that Ubuntu users file a feature request bug to Ubuntu to ditch ecryptfs and switch to ext4 encryption.)
I can also confirm that ecryptfs != ext4, and that discussing this here has approximately zero chance of it being noticed by the ecryptfs maintainer. Since Tyler works at Canonical, filing a Launchpad bug is most likely to get someone to look at it.
Signature · 2 lines
You are receiving this mail because: You are watching the assignee of the bug.
[Bug 197045] renameat2 rename_noreplace
In reply to [email protected]https://bugzilla.kernel.org/show_bug.cgi?id=197045
--- Comment #12 from Thiago Macieira ([email protected]) --- Thanks Ted.
For the record, I'm applying a fix to the Qt code, since the error is legitimate for non-local fs: https://codereview.qt-project.org/209385
Signature · 2 lines
You are receiving this mail because: You are watching the assignee of the bug.
[Bug 197045] renameat2 rename_noreplace
In reply to [email protected]https://bugzilla.kernel.org/show_bug.cgi?id=197045
--- Comment #13 from Elvis Stansvik ([email protected]) --- Indeed, I'll file an LP bug and try to ping Tyler. Who knows, perhaps they're already planning to switch to encrypted ext4 (thanks for testing that Ted).
And thanks to Thiago for being so quick with the Qt fix (I ran into this behavior by way of Qt).
Signature · 2 lines
You are receiving this mail because: You are watching the assignee of the bug.
[Bug 197045] renameat2 rename_noreplace
In reply to [email protected]https://bugzilla.kernel.org/show_bug.cgi?id=197045
--- Comment #14 from Theodore Tso ([email protected]) ---
Michael Halcrow (the original author of ecryptfs, and who has jokingly referred to his work on ext4 encryption as his apology for ecryptfs :-) and I have
talked to Tyler about Ubuntu switching to ext4 encryption. This is really
going to be a matter of prioritizing work at Canonical; so user feature requests (especially requests from paying users :-) would be helpful.
Signature · 2 lines
You are receiving this mail because: You are watching the assignee of the bug.