ovl: verify permissions in ovl_path_open()
authorMiklos Szeredi <mszeredi@redhat.com>
Tue, 2 Jun 2020 20:20:26 +0000 (22:20 +0200)
committerMiklos Szeredi <mszeredi@redhat.com>
Tue, 2 Jun 2020 20:20:26 +0000 (22:20 +0200)
commit56230d956739b9cb1cbde439d76227d77979a04d
treef8697c302a2226793cff22debe17afbcaaec8b98
parent48bd024b8a40d73ad6b086de2615738da0c7004f
ovl: verify permissions in ovl_path_open()

Check permission before opening a real file.

ovl_path_open() is used by readdir and copy-up routines.

ovl_permission() theoretically already checked copy up permissions, but it
doesn't hurt to re-do these checks during the actual copy-up.

For directory reading ovl_permission() only checks access to topmost
underlying layer.  Readdir on a merged directory accesses layers below the
topmost one as well.  Permission wasn't checked for these layers.

Note: modifying ovl_permission() to perform this check would be far more
complex and hence more bug prone.  The result is less precise permissions
returned in access(2).  If this turns out to be an issue, we can revisit
this bug.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/overlayfs/util.c