Skip to content

Commit 1a10993

Browse files
Miklos Szerediksacilotto
authored andcommitted
ovl: do not fail because of O_NOATIME
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 b6650da) Signed-off-by: Seth Forshee <seth.forshee@canonical.com> Acked-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com> Acked-by: William Breathitt Gray <william.gray@canonical.com> Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
1 parent ab6181b commit 1a10993

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

fs/overlayfs/file.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ static struct file *ovl_open_realfile(const struct file *file,
4343
err = inode_permission(realinode, MAY_OPEN | acc_mode);
4444
if (err) {
4545
realfile = ERR_PTR(err);
46-
} else if (!inode_owner_or_capable(realinode)) {
47-
realfile = ERR_PTR(-EPERM);
4846
} else {
47+
if (!inode_owner_or_capable(realinode))
48+
flags &= ~O_NOATIME;
49+
4950
ovl_path_real(file->f_path.dentry, &realpath);
5051
realfile = open_with_fake_path(&realpath, flags, realinode,
5152
current_cred());
@@ -66,12 +67,6 @@ static int ovl_change_flags(struct file *file, unsigned int flags)
6667
struct inode *inode = file_inode(file);
6768
int err;
6869

69-
flags |= OVL_OPEN_FLAGS;
70-
71-
/* If some flag changed that cannot be changed then something's amiss */
72-
if (WARN_ON((file->f_flags ^ flags) & ~OVL_SETFL_MASK))
73-
return -EIO;
74-
7570
flags &= OVL_SETFL_MASK;
7671

7772
if (((flags ^ file->f_flags) & O_APPEND) && IS_APPEND(inode))

0 commit comments

Comments
 (0)