--- v1
+++ v2
@@ -1,22 +1,35 @@
-This series attempts to clean up part of the mess that has grown around
-the LSM mount option handling across different subsystems.
+This series fixes two bugs:
+1. A bug with BTRFS where LSM options are ignored when BTRFS is mounted
+ via the new fsconfig(2) API. (fixed by patch 1)
+2. A bug with NFS + SELinux where an attempt to do the same mount twice
+ might incidentally turn off LSM labeling, making any fresh inode
+ show up as unlabeled. (fixed by patch 2, with patch 1 as a prereq)
-The original motivation was to fix a NFS+SELinux bug that I found while
-trying to get the NFS part of the selinux-testsuite [1] to work, which
-is fixed by patch 2.
+For bug (1.) I previously posted a different patch [1], which is no
+longer needed if these patches are applied.
-The first patch paves the way for the second one by eliminating the
-special case workaround in selinux_set_mnt_opts(), while also
-simplifying BTRFS's LSM mount option handling.
+While these patches do add a new fs_type flag (which seems to be frowned
+upon), they also reduce the semantics of FS_BINARY_MOUNT_DATA flag to
+*only* the mount data being binary, while before it was also (ab)used
+to skip mount option processing in SELinux for NFS and BTRFS. The result
+is perhaps still not perfect, but it seems to be the only non-invasive
+solution for these bugs in the short term. Once BTRFS is finally
+converted to the new mount API, a lot of the ugliness can likely be
+refactored to something nicer (and these patches do not really make that
+any harder to do, IMHO).
I tested the patches by running the NFS part of the SELinux testsuite
-(which is now fully passing). I also added the pending patch for
-broken BTRFS LSM options support with fsconfig(2) [2] and ran the
-proposed BTRFS SELinux tests for selinux-testsuite [3] (still passing
-with all patches).
+[2] (which is now fully passing). I also ran the proposed BTRFS SELinux
+test coverage for selinux-testsuite [3], which is now passing.
-[1] https://github.com/SELinuxProject/selinux-testsuite/
-[2] https://lore.kernel.org/selinux/20210401065403.GA1363493@infradead.org/T/
+Changes since v1:
+- in BTRFS, move the FS_HANDLES_LSM_OPTS flag to btrfs_root_fs_type, and
+ remove FS_BINARY_MOUNTDATA from both fs_types now
+
+v1: https://lore.kernel.org/selinux/20210409111254.271800-1-omosnace@redhat.com/T/
+
+[1] https://lore.kernel.org/selinux/20210401065403.GA1363493@infradead.org/T/
+[2] https://github.com/SELinuxProject/selinux-testsuite/
[3] https://lore.kernel.org/selinux/20201103110121.53919-2-richard_c_haines@btinternet.com/
^^ the original patch no longer applies - a rebased version is here:
https://github.com/WOnder93/selinux-testsuite/commit/212e76b5bd0775c7507c1996bd172de3bcbff139.patch
@@ -25,13 +38,13 @@
vfs,LSM: introduce the FS_HANDLES_LSM_OPTS flag
selinux: fix SECURITY_LSM_NATIVE_LABELS flag handling on double mount
- fs/btrfs/super.c | 35 ++++++-----------------------------
+ fs/btrfs/super.c | 34 +++++-----------------------------
fs/nfs/fs_context.c | 6 ++++--
fs/super.c | 10 ++++++----
include/linux/fs.h | 3 ++-
security/selinux/hooks.c | 32 +++++++++++++++++---------------
- 5 files changed, 35 insertions(+), 51 deletions(-)
+ 5 files changed, 34 insertions(+), 51 deletions(-)
--
-2.30.2
+2.31.1