~ubuntu-branches/ubuntu/lucid/linux-lts-backport-natty/lucid-proposed

« back to all changes in this revision

Viewing changes to fs/ecryptfs/miscdev.c

  • Committer: Package Import Robot
  • Author(s): Luis Henriques, Luis Henriques, Upstream Kernel Changes
  • Date: 2012-08-15 09:46:38 UTC
  • Revision ID: package-import@ubuntu.com-20120815094638-n6urjpliowtih76d
Tags: 2.6.38-15.66~lucid1
[Luis Henriques]

* Release Tracking Bug
  - LP: #1036914

[ Upstream Kernel Changes ]

* udf: Fortify loading of sparing table
  - LP: #1024497
  - CVE-2012-3400
* udf: Avoid run away loop when partition table length is corrupted
  - LP: #1024497
  - CVE-2012-3400
* eCryptfs: Gracefully refuse miscdev file ops on inherited/passed files
* eCryptfs: Copy up POSIX ACL and read-only flags from lower mount
  - LP: #1009207

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
        mutex_lock(&ecryptfs_daemon_hash_mux);
50
50
        /* TODO: Just use file->private_data? */
51
51
        rc = ecryptfs_find_daemon_by_euid(&daemon, euid, current_user_ns());
52
 
        BUG_ON(rc || !daemon);
 
52
        if (rc || !daemon) {
 
53
                mutex_unlock(&ecryptfs_daemon_hash_mux);
 
54
                return -EINVAL;
 
55
        }
53
56
        mutex_lock(&daemon->mux);
54
57
        mutex_unlock(&ecryptfs_daemon_hash_mux);
55
58
        if (daemon->flags & ECRYPTFS_DAEMON_ZOMBIE) {
122
125
                goto out_unlock_daemon;
123
126
        }
124
127
        daemon->flags |= ECRYPTFS_DAEMON_MISCDEV_OPEN;
 
128
        file->private_data = daemon;
125
129
        atomic_inc(&ecryptfs_num_miscdev_opens);
126
130
out_unlock_daemon:
127
131
        mutex_unlock(&daemon->mux);
152
156
 
153
157
        mutex_lock(&ecryptfs_daemon_hash_mux);
154
158
        rc = ecryptfs_find_daemon_by_euid(&daemon, euid, current_user_ns());
155
 
        BUG_ON(rc || !daemon);
 
159
        if (rc || !daemon)
 
160
                daemon = file->private_data;
156
161
        mutex_lock(&daemon->mux);
157
 
        BUG_ON(daemon->pid != task_pid(current));
158
162
        BUG_ON(!(daemon->flags & ECRYPTFS_DAEMON_MISCDEV_OPEN));
159
163
        daemon->flags &= ~ECRYPTFS_DAEMON_MISCDEV_OPEN;
160
164
        atomic_dec(&ecryptfs_num_miscdev_opens);
246
250
        mutex_lock(&ecryptfs_daemon_hash_mux);
247
251
        /* TODO: Just use file->private_data? */
248
252
        rc = ecryptfs_find_daemon_by_euid(&daemon, euid, current_user_ns());
249
 
        BUG_ON(rc || !daemon);
 
253
        if (rc || !daemon) {
 
254
                mutex_unlock(&ecryptfs_daemon_hash_mux);
 
255
                return -EINVAL;
 
256
        }
250
257
        mutex_lock(&daemon->mux);
 
258
        if (task_pid(current) != daemon->pid) {
 
259
                mutex_unlock(&daemon->mux);
 
260
                mutex_unlock(&ecryptfs_daemon_hash_mux);
 
261
                return -EPERM;
 
262
        }
251
263
        if (daemon->flags & ECRYPTFS_DAEMON_ZOMBIE) {
252
264
                rc = 0;
253
265
                mutex_unlock(&ecryptfs_daemon_hash_mux);
284
296
                 * message from the queue; try again */
285
297
                goto check_list;
286
298
        }
287
 
        BUG_ON(euid != daemon->euid);
288
 
        BUG_ON(current_user_ns() != daemon->user_ns);
289
 
        BUG_ON(task_pid(current) != daemon->pid);
290
299
        msg_ctx = list_first_entry(&daemon->msg_ctx_out_queue,
291
300
                                   struct ecryptfs_msg_ctx, daemon_out_list);
292
301
        BUG_ON(!msg_ctx);