Patch series: overlayfs: check CAP_DAC_READ_SEARCH before issuing exportfs_decode_fh Add flags option to get xattr method paired to __vfs_getxattr overlayfs: handle XATTR_NOSECURITY flag for get xattr method overlayfs: internal getxattr operations without sepolicy checking overlayfs: override_creds=off option bypass creator_cred
The first four patches address fundamental security issues that should be solved regardless of the override_creds=off feature. on them). The fifth adds the feature depends on these other fixes. By default, all access to the upper, lower and work directories is the recorded mounter's MAC and DAC credentials. The incoming accesses are checked against the caller's credentials. If the principles of least privilege are applied for sepolicy, the mounter's credentials might not overlap the credentials of the caller's when accessing the overlayfs filesystem. For example, a file that a lower DAC privileged caller can execute, is MAC denied to the generally higher DAC privileged mounter, to prevent an attack vector. We add the option to turn off override_creds in the mount options; all subsequent operations after mount on the filesystem will be only the caller's credentials. The module boolean parameter and mount option override_creds is also added as a presence check for this "feature", existence of /sys/module/overlay/parameters/overlay_creds Signed-off-by: Mark Salyzyn <saly...@android.com> Cc: Miklos Szeredi <mik...@szeredi.hu> Cc: Jonathan Corbet <cor...@lwn.net> Cc: Vivek Goyal <vgo...@redhat.com> Cc: Eric W. Biederman <ebied...@xmission.com> Cc: Amir Goldstein <amir7...@gmail.com> Cc: Randy Dunlap <rdun...@infradead.org> Cc: Stephen Smalley <s...@tycho.nsa.gov> Cc: linux-unio...@vger.kernel.org Cc: linux-...@vger.kernel.org Cc: linux-ker...@vger.kernel.org Cc: Eric Van Hensbergen <eri...@gmail.com> Cc: Latchesar Ionkov <lu...@ionkov.net> Cc: Dominique Martinet <asmad...@codewreck.org> Cc: David Howells <dhowe...@redhat.com> Cc: Chris Mason <c...@fb.com> Cc: Josef Bacik <jo...@toxicpanda.com> Cc: David Sterba <dste...@suse.com> Cc: Jeff Layton <jlay...@kernel.org> Cc: Sage Weil <s...@redhat.com> Cc: Ilya Dryomov <idryo...@gmail.com> Cc: Steve French <sfre...@samba.org> Cc: Tyler Hicks <tyhi...@canonical.com> Cc: Jan Kara <j...@suse.com> Cc: Theodore Ts'o <ty...@mit.edu> Cc: Andreas Dilger <adilger.ker...@dilger.ca> Cc: Jaegeuk Kim <jaeg...@kernel.org> Cc: Chao Yu <yuch...@huawei.com> Cc: Bob Peterson <rpete...@redhat.com> Cc: Andreas Gruenbacher <agrue...@redhat.com> Cc: David Woodhouse <dw...@infradead.org> Cc: Richard Weinberger <rich...@nod.at> Cc: Dave Kleikamp <sha...@kernel.org> Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org> Cc: Tejun Heo <t...@kernel.org> Cc: Trond Myklebust <trond.mykleb...@hammerspace.com> Cc: Anna Schumaker <anna.schuma...@netapp.com> Cc: Mark Fasheh <m...@fasheh.com> Cc: Joel Becker <jl...@evilplan.org> Cc: Joseph Qi <joseph...@linux.alibaba.com> Cc: Mike Marshall <hub...@omnibond.com> Cc: Martin Brandenburg <mar...@omnibond.com> Cc: Alexander Viro <v...@zeniv.linux.org.uk> Cc: Phillip Lougher <phil...@squashfs.org.uk> Cc: Darrick J. Wong <darrick.w...@oracle.com> Cc: linux-...@vger.kernel.org Cc: Hugh Dickins <hu...@google.com> Cc: David S. Miller <da...@davemloft.net> Cc: Andrew Morton <a...@linux-foundation.org> Cc: Mathieu Malaterre <ma...@debian.org> Cc: Ernesto A. Fernandez <ernesto.mnd.fernan...@gmail.com> Cc: Vyacheslav Dubeyko <sl...@dubeyko.com> Cc: v9fs-develo...@lists.sourceforge.net Cc: linux-...@lists.infradead.org Cc: linux-bt...@vger.kernel.org Cc: ceph-de...@vger.kernel.org Cc: linux-c...@vger.kernel.org Cc: samba-techni...@lists.samba.org Cc: ecryp...@vger.kernel.org Cc: linux-e...@vger.kernel.org Cc: linux-f2fs-de...@lists.sourceforge.net Cc: linux-fsde...@vger.kernel.org Cc: cluster-devel@redhat.com Cc: linux-...@lists.infradead.org Cc: jfs-discuss...@lists.sourceforge.net Cc: linux-...@vger.kernel.org Cc: ocfs2-de...@oss.oracle.com Cc: de...@lists.orangefs.org Cc: reiserfs-de...@vger.kernel.org Cc: linux...@kvack.org Cc: net...@vger.kernel.org Cc: linux-security-mod...@vger.kernel.org Cc: sta...@vger.kernel.org # 4.4, 4.9, 4.14 & 4.19 --- v13: - add flags argument to __vfs_getxattr - drop GFP_NOFS side-effect v12: - Restore squished out patch 2 and 3 in the series, then change algorithm to add flags argument. Per-thread flag is a large security surface. v11: - Squish out v10 introduced patch 2 and 3 in the series, then and use per-thread flag instead for nesting. - Switch name to ovl_do_vds_getxattr for __vds_getxattr wrapper. - Add sb argument to ovl_revert_creds to match future work. v10: - Return NULL on CAP_DAC_READ_SEARCH - Add __get xattr method to solve sepolicy logging issue - Drop unnecessary sys_admin sepolicy checking for administrative driver internal xattr functions. v6: - Drop CONFIG_OVERLAY_FS_OVERRIDE_CREDS. - Do better with the documentation, drop rationalizations. - pr_warn message adjusted to report consequences. v5: - beefed up the caveats in the Documentation - Is dependent on "overlayfs: check CAP_DAC_READ_SEARCH before issuing exportfs_decode_fh" "overlayfs: check CAP_MKNOD before issuing vfs_whiteout" - Added prwarn when override_creds=off v4: - spelling and grammar errors in text v3: - Change name from caller_credentials / creator_credentials to the boolean override_creds. - Changed from creator to mounter credentials. - Updated and fortified the documentation. - Added CONFIG_OVERLAY_FS_OVERRIDE_CREDS v2: - Forward port changed attr to stat, resulting in a build error. - altered commit message.