* [PATCH] xfs: disallow ro->rw remount on norecovery mount
@ 2015-03-26 20:03 Eric Sandeen
2015-03-26 20:59 ` Dave Chinner
0 siblings, 1 reply; 3+ messages in thread
From: Eric Sandeen @ 2015-03-26 20:03 UTC (permalink / raw)
To: xfs-oss
There's a bit of a loophole in norecovery mount handling right
now: an initial mount must be readonly, but nothing prevents
a mount -o remount,rw from producing a writable, unrecovered
xfs filesystem.
It might be possible to try to perform a log recovery when this
is requested, but I'm not sure it's worth the effort. For now,
simply disallow this sort of transition.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 8fcc4cc..a6cc7a9 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1256,6 +1256,12 @@ xfs_fs_remount(
/* ro -> rw */
if ((mp->m_flags & XFS_MOUNT_RDONLY) && !(*flags & MS_RDONLY)) {
+ if (mp->m_flags & XFS_MOUNT_NORECOVERY) {
+ xfs_warn(mp,
+ "ro->rw transition prohibited on norecovery mount");
+ return -EINVAL;
+ }
+
mp->m_flags &= ~XFS_MOUNT_RDONLY;
/*
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] xfs: disallow ro->rw remount on norecovery mount
2015-03-26 20:03 [PATCH] xfs: disallow ro->rw remount on norecovery mount Eric Sandeen
@ 2015-03-26 20:59 ` Dave Chinner
2015-03-26 21:13 ` Eric Sandeen
0 siblings, 1 reply; 3+ messages in thread
From: Dave Chinner @ 2015-03-26 20:59 UTC (permalink / raw)
To: Eric Sandeen; +Cc: xfs-oss
On Thu, Mar 26, 2015 at 03:03:30PM -0500, Eric Sandeen wrote:
> There's a bit of a loophole in norecovery mount handling right
> now: an initial mount must be readonly, but nothing prevents
> a mount -o remount,rw from producing a writable, unrecovered
> xfs filesystem.
>
> It might be possible to try to perform a log recovery when this
> is requested, but I'm not sure it's worth the effort. For now,
> simply disallow this sort of transition.
>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Good catch.
Shouldn't this also check for a ro block device, and disallow the
rw remount if the block dev is ro?
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xfs: disallow ro->rw remount on norecovery mount
2015-03-26 20:59 ` Dave Chinner
@ 2015-03-26 21:13 ` Eric Sandeen
0 siblings, 0 replies; 3+ messages in thread
From: Eric Sandeen @ 2015-03-26 21:13 UTC (permalink / raw)
To: Dave Chinner, Eric Sandeen; +Cc: xfs-oss
On 3/26/15 3:59 PM, Dave Chinner wrote:
> On Thu, Mar 26, 2015 at 03:03:30PM -0500, Eric Sandeen wrote:
>> There's a bit of a loophole in norecovery mount handling right
>> now: an initial mount must be readonly, but nothing prevents
>> a mount -o remount,rw from producing a writable, unrecovered
>> xfs filesystem.
>>
>> It might be possible to try to perform a log recovery when this
>> is requested, but I'm not sure it's worth the effort. For now,
>> simply disallow this sort of transition.
>>
>> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
>
> Good catch.
>
> Shouldn't this also check for a ro block device, and disallow the
> rw remount if the block dev is ro?
Seems to be covered already:
# blockdev --setro /dev/sdb1
# mount /dev/sdb1 /mnt/test
mount: block device /dev/sdb1 is write-protected, mounting read-only
# grep sdb1 /proc/mounts
/dev/sdb1 /mnt/test xfs ro,seclabel,relatime,attr2,inode64,noquota 0 0
# mount -o remount,rw /mnt/test
mount: cannot remount block device /dev/sdb1 read-write, is write-protected
from strace:
mount("/dev/sdb1", "/mnt/test", 0x7ff230271d90, MS_MGC_VAL|MS_REMOUNT, NULL) = -1 EACCES (Permission denied)
Ah, from fs/super.c:
do_remount_sb()
...
#ifdef CONFIG_BLOCK
if (!(flags & MS_RDONLY) && bdev_read_only(sb->s_bdev))
return -EACCES;
#endif
-Eric
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-26 21:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-26 20:03 [PATCH] xfs: disallow ro->rw remount on norecovery mount Eric Sandeen
2015-03-26 20:59 ` Dave Chinner
2015-03-26 21:13 ` Eric Sandeen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox