From: Miklos Szeredi Date: Mon, 14 Dec 2020 14:26:14 +0000 (+0100) Subject: ovl: do not fail because of O_NOATIME X-Git-Tag: submit/tizen/20220208.074352~45 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c263f3ac8e5a92778c1c4c02716d5a3dc70dee2f;p=platform%2Fkernel%2Flinux-rpi.git ovl: do not fail because of O_NOATIME 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 [sw0312.kim: backport v5.11 mainline commit b6650dab404c to resolve overlayfs file open EPERM fail issue in v5.10] Signed-off-by: Seung-Woo Kim Change-Id: I9c0c74747bb4a208fc68ca561f740281b2b553fe --- diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index b019f27..7101981 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -54,9 +54,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; + realfile = open_with_fake_path(&file->f_path, flags, realinode, current_cred()); } @@ -76,12 +77,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))