diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2013-03-28 13:30:23 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-04-09 14:08:16 -0400 |
| commit | 52f21999c7b921a0390708b66ed286282c2e4bee (patch) | |
| tree | ff7cfd9652e1e0384a17615b21dc37ffc0c3a5c5 /fs/ecryptfs | |
| parent | de55eb1d60d2ed0f1ba5e13226d91b3bfbe1c108 (diff) | |
ecryptfs: close rmmod race
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ecryptfs')
| -rw-r--r-- | fs/ecryptfs/miscdev.c | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c index 412e6eda25f8..e4141f257495 100644 --- a/fs/ecryptfs/miscdev.c +++ b/fs/ecryptfs/miscdev.c | |||
| @@ -80,13 +80,6 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file) | |||
| 80 | int rc; | 80 | int rc; |
| 81 | 81 | ||
| 82 | mutex_lock(&ecryptfs_daemon_hash_mux); | 82 | mutex_lock(&ecryptfs_daemon_hash_mux); |
| 83 | rc = try_module_get(THIS_MODULE); | ||
| 84 | if (rc == 0) { | ||
| 85 | rc = -EIO; | ||
| 86 | printk(KERN_ERR "%s: Error attempting to increment module use " | ||
| 87 | "count; rc = [%d]\n", __func__, rc); | ||
| 88 | goto out_unlock_daemon_list; | ||
| 89 | } | ||
| 90 | rc = ecryptfs_find_daemon_by_euid(&daemon); | 83 | rc = ecryptfs_find_daemon_by_euid(&daemon); |
| 91 | if (!rc) { | 84 | if (!rc) { |
| 92 | rc = -EINVAL; | 85 | rc = -EINVAL; |
| @@ -96,7 +89,7 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file) | |||
| 96 | if (rc) { | 89 | if (rc) { |
| 97 | printk(KERN_ERR "%s: Error attempting to spawn daemon; " | 90 | printk(KERN_ERR "%s: Error attempting to spawn daemon; " |
| 98 | "rc = [%d]\n", __func__, rc); | 91 | "rc = [%d]\n", __func__, rc); |
| 99 | goto out_module_put_unlock_daemon_list; | 92 | goto out_unlock_daemon_list; |
| 100 | } | 93 | } |
| 101 | mutex_lock(&daemon->mux); | 94 | mutex_lock(&daemon->mux); |
| 102 | if (daemon->flags & ECRYPTFS_DAEMON_MISCDEV_OPEN) { | 95 | if (daemon->flags & ECRYPTFS_DAEMON_MISCDEV_OPEN) { |
| @@ -108,9 +101,6 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file) | |||
| 108 | atomic_inc(&ecryptfs_num_miscdev_opens); | 101 | atomic_inc(&ecryptfs_num_miscdev_opens); |
| 109 | out_unlock_daemon: | 102 | out_unlock_daemon: |
| 110 | mutex_unlock(&daemon->mux); | 103 | mutex_unlock(&daemon->mux); |
| 111 | out_module_put_unlock_daemon_list: | ||
| 112 | if (rc) | ||
| 113 | module_put(THIS_MODULE); | ||
| 114 | out_unlock_daemon_list: | 104 | out_unlock_daemon_list: |
| 115 | mutex_unlock(&ecryptfs_daemon_hash_mux); | 105 | mutex_unlock(&ecryptfs_daemon_hash_mux); |
| 116 | return rc; | 106 | return rc; |
| @@ -147,7 +137,6 @@ ecryptfs_miscdev_release(struct inode *inode, struct file *file) | |||
| 147 | "bug.\n", __func__, rc); | 137 | "bug.\n", __func__, rc); |
| 148 | BUG(); | 138 | BUG(); |
| 149 | } | 139 | } |
| 150 | module_put(THIS_MODULE); | ||
| 151 | return rc; | 140 | return rc; |
| 152 | } | 141 | } |
| 153 | 142 | ||
| @@ -471,6 +460,7 @@ out_free: | |||
| 471 | 460 | ||
| 472 | 461 | ||
| 473 | static const struct file_operations ecryptfs_miscdev_fops = { | 462 | static const struct file_operations ecryptfs_miscdev_fops = { |
| 463 | .owner = THIS_MODULE, | ||
| 474 | .open = ecryptfs_miscdev_open, | 464 | .open = ecryptfs_miscdev_open, |
| 475 | .poll = ecryptfs_miscdev_poll, | 465 | .poll = ecryptfs_miscdev_poll, |
| 476 | .read = ecryptfs_miscdev_read, | 466 | .read = ecryptfs_miscdev_read, |
