Skip to content

Commit

Permalink
hfsplus: fix BKL leak in hfsplus_ioctl
Browse files Browse the repository at this point in the history
Currenly the HFSPLUS_IOC_EXT2_GETFLAGS case never unlocks the BKL, which
can lead to easily reproduced lockups when doing multiple GETFLAGS ioctls.

Fix this by only taking the BKL for the HFSPLUS_IOC_EXT2_SETFLAGS case
as neither HFSPLUS_IOC_EXT2_GETFLAGS not the default error case needs it.

Signed-off-by: Christoph Hellwig <hch@tuxera.com>
  • Loading branch information
Christoph Hellwig committed Oct 1, 2010
1 parent 0f44fbd commit 249e635
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/hfsplus/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ long hfsplus_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
struct inode *inode = filp->f_path.dentry->d_inode;
unsigned int flags;

lock_kernel();
switch (cmd) {
case HFSPLUS_IOC_EXT2_GETFLAGS:
flags = 0;
Expand All @@ -39,6 +38,8 @@ long hfsplus_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
return put_user(flags, (int __user *)arg);
case HFSPLUS_IOC_EXT2_SETFLAGS: {
int err = 0;

lock_kernel();
err = mnt_want_write(filp->f_path.mnt);
if (err) {
unlock_kernel();
Expand Down Expand Up @@ -93,7 +94,6 @@ long hfsplus_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
return err;
}
default:
unlock_kernel();
return -ENOTTY;
}
}
Expand Down

0 comments on commit 249e635

Please sign in to comment.