Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs: fix adding security options to statmount.mnt_opt

Prepending security options was made conditional on sb->s_op->show_options,
but security options are independent of sb options.

Fixes: 056d33137bf9 ("fs: prepend statmount.mnt_opts string with security_sb_mnt_opts()")
Fixes: f9af549d1fd3 ("fs: export mount options via statmount()")
Cc: stable@vger.kernel.org # v6.11
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Link: https://lore.kernel.org/r/20250129151253.33241-1-mszeredi@redhat.com
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Miklos Szeredi and committed by
Christian Brauner
5eb98710 b06ddfee

+16 -17
+16 -17
fs/namespace.c
··· 5087 5087 { 5088 5088 struct vfsmount *mnt = s->mnt; 5089 5089 struct super_block *sb = mnt->mnt_sb; 5090 + size_t start = seq->count; 5090 5091 int err; 5091 5092 5093 + err = security_sb_show_options(seq, sb); 5094 + if (err) 5095 + return err; 5096 + 5092 5097 if (sb->s_op->show_options) { 5093 - size_t start = seq->count; 5094 - 5095 - err = security_sb_show_options(seq, sb); 5096 - if (err) 5097 - return err; 5098 - 5099 5098 err = sb->s_op->show_options(seq, mnt->mnt_root); 5100 5099 if (err) 5101 5100 return err; 5102 - 5103 - if (unlikely(seq_has_overflowed(seq))) 5104 - return -EAGAIN; 5105 - 5106 - if (seq->count == start) 5107 - return 0; 5108 - 5109 - /* skip leading comma */ 5110 - memmove(seq->buf + start, seq->buf + start + 1, 5111 - seq->count - start - 1); 5112 - seq->count--; 5113 5101 } 5102 + 5103 + if (unlikely(seq_has_overflowed(seq))) 5104 + return -EAGAIN; 5105 + 5106 + if (seq->count == start) 5107 + return 0; 5108 + 5109 + /* skip leading comma */ 5110 + memmove(seq->buf + start, seq->buf + start + 1, 5111 + seq->count - start - 1); 5112 + seq->count--; 5114 5113 5115 5114 return 0; 5116 5115 }