mqueue: sys_mq_open: do not call mnt_drop_write() if read-only
PATCH 1/1 mqueue: sys_mq_open: do not call mnt_drop_write() if read-only
mnt_drop_write() must be called only if mnt_want_write() succeeded, otherwise the mnt_writers counter will diverge.
--- ipc/mqueue.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
ipc/mqueue.c +2 -1
@@ -840,7 +840,8 @@ out_putfd: fd = error; }mutex_unlock (&root->d_inode->i_mutex); -mnt_drop_write (mnt); +if (!ro) +mnt_drop_write (mnt); out_putname:putname (name);return fd;
Signature · 1 line
1.7.1
Quoted 8 lines · On Tue, 19 Mar 2013 13:31:18 +0400 Vladimir Davydov <[email protected]>…
mnt_drop_write()must be called only ifmnt_want_write()succeeded, otherwise themnt_writerscounter will diverge....
ipc/mqueue.c out_putfd: · line 847
Quoted 9 lines
ipc/mqueue.c +2
-1@@ -840,7 +840,8 @@ out_putfd: fd = error; }mutex_unlock (&root->d_inode->i_mutex); -mnt_drop_write (mnt); +if (!ro) +mnt_drop_write (mnt); out_putname:putname (name);return fd;
huh, that's been there for a while. What were the runtime-visible effects of the bug?
Quoted 7 lines · Andrew Morton
Quoted 5 lines · On Tue, 19 Mar 2013 13:31:18 +0400 Vladimir Davydov <[email protected]>…
mnt_drop_write()must be called only ifmnt_want_write()succeeded, otherwise themnt_writerscounter will diverge....
Quoted 15 lines
Quoted 10 lines
ipc/mqueue.c +2
-1@@ -840,7 +840,8 @@ out_putfd: fd = error; }mutex_unlock (&root->d_inode->i_mutex); -mnt_drop_write (mnt); +if (!ro) +mnt_drop_write (mnt);
out_putname:Quoted 2 lines
putname(name); return fd;huh, that's been there for a while. What were the runtime-visible effects of the bug?
mnt_writers counters are used to check if remounting FS as read-only is OK, so after an extra mnt_drop_write() call, it would be impossible to remount mqueue FS as read-only. Besides, on umount a warning would be printed like this one:
[ 194.714880] ===================================== [ 194.719680] [ BUG: bad unlock balance detected! ] [ 194.724488] 3.9.0-rc3 #5 Not tainted [ 194.728159] ------------------------------------- [ 194.732958] a.out/12486 is trying to release lock (sb_writers) at: [ 194.739355] [<ffffffff811b177f>] mnt_drop_write+0x1f/0x30 [ 194.744851] but there are no more locks to release!