diff mbox series

[1/1,SRU,F/G] ovl: do not fail because of O_NOATIME

Message ID 20210106211515.80586-2-seth.forshee@canonical.com
State New
Headers show
Series Fix regression opening some files in overlayfs | expand

Commit Message

Seth Forshee Jan. 6, 2021, 9:15 p.m. UTC
From: Miklos Szeredi <mszeredi@redhat.com>

BugLink: https://bugs.launchpad.net/bugs/1900141

In case the file cannot be opened with O_NOATIME because of lack of
capabilities, then clear O_NOATIME instead of failing.

Remove WARN_ON(), since it would now trigger if O_NOATIME was cleared.
Noticed by Amir Goldstein.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
(backported from commit b6650dab404c701d7fe08a108b746542a934da84)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
---
 fs/overlayfs/file.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

Comments

Thadeu Lima de Souza Cascardo Jan. 6, 2021, 9:25 p.m. UTC | #1
Acked-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
diff mbox series

Patch

diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
index 87a399b74f69..0d3ea0cf3e98 100644
--- a/fs/overlayfs/file.c
+++ b/fs/overlayfs/file.c
@@ -43,9 +43,10 @@  static struct file *ovl_open_realfile(const struct file *file,
 	err = inode_permission(realinode, MAY_OPEN | acc_mode);
 	if (err) {
 		realfile = ERR_PTR(err);
-	} else if (!inode_owner_or_capable(realinode)) {
-		realfile = ERR_PTR(-EPERM);
 	} else {
+		if (!inode_owner_or_capable(realinode))
+			flags &= ~O_NOATIME;
+
 		ovl_path_real(file->f_path.dentry, &realpath);
 		realfile = open_with_fake_path(&realpath, flags, realinode,
 					       current_cred());
@@ -66,12 +67,6 @@  static int ovl_change_flags(struct file *file, unsigned int flags)
 	struct inode *inode = file_inode(file);
 	int err;
 
-	flags |= OVL_OPEN_FLAGS;
-
-	/* If some flag changed that cannot be changed then something's amiss */
-	if (WARN_ON((file->f_flags ^ flags) & ~OVL_SETFL_MASK))
-		return -EIO;
-
 	flags &= OVL_SETFL_MASK;
 
 	if (((flags ^ file->f_flags) & O_APPEND) && IS_APPEND(inode))