Skip to content

Commit

Permalink
mqueue: sys_mq_open: do not call mnt_drop_write() if read-only
Browse files Browse the repository at this point in the history
commit 38d78e5 upstream.

mnt_drop_write() must be called only if mnt_want_write() succeeded,
otherwise the mnt_writers counter will diverge.

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:

  =====================================
  [ BUG: bad unlock balance detected! ]
  3.9.0-rc3 #5 Not tainted
  -------------------------------------
  a.out/12486 is trying to release lock (sb_writers) at:
  mnt_drop_write+0x1f/0x30
  but there are no more locks to release!

Signed-off-by: Vladimir Davydov <[email protected]>
Cc: Doug Ledford <[email protected]>
Cc: KOSAKI Motohiro <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Cc: Al Viro <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Vladimir Davydov authored and gregkh committed Mar 28, 2013
1 parent 463675f commit 6ad6c40
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ipc/mqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,8 @@ SYSCALL_DEFINE4(mq_open, const char __user *, u_name, int, oflag, umode_t, mode,
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;
Expand Down

0 comments on commit 6ad6c40

Please sign in to comment.