~ubuntu-branches/ubuntu/lucid/apparmor/lucid-security

« back to all changes in this revision

Viewing changes to kernel-patches/2.6.28/vfs-notify_change.diff

  • Committer: Bazaar Package Importer
  • Author(s): Jamie Strandboge
  • Date: 2011-01-05 12:15:29 UTC
  • mfrom: (99.2.1 lucid-proposed)
  • Revision ID: james.westby@ubuntu.com-20110105121529-qvi6irilvlth8419
Tags: 2.5.1-0ubuntu0.10.04.2
* Fix for apparmor_parser not generating correct policy when mixing exec
  transitions with and without unconfined fallback transitions.
  - debian/patches/0013-lp693082.patch: adjust dfa match flag table size
    and fix index calculation for pux and cux.
  - LP: #693082

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
From: Tony Jones <tonyj@suse.de>
2
 
Subject: Add a vfsmount parameter to notify_change()
3
 
 
4
 
The vfsmount parameter must be set appropriately for files visibile
5
 
outside the kernel. Files that are only used in a filesystem (e.g.,
6
 
reiserfs xattr files) will have a NULL vfsmount.
7
 
 
8
 
Signed-off-by: Tony Jones <tonyj@suse.de>
9
 
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
10
 
Signed-off-by: John Johansen <jjohansen@suse.de>
11
 
 
12
 
---
13
 
 fs/attr.c           |    3 ++-
14
 
 fs/ecryptfs/inode.c |    4 +++-
15
 
 fs/exec.c           |    3 ++-
16
 
 fs/hpfs/namei.c     |    2 +-
17
 
 fs/namei.c          |    2 +-
18
 
 fs/nfsd/vfs.c       |    8 ++++----
19
 
 fs/open.c           |   28 +++++++++++++++-------------
20
 
 fs/reiserfs/xattr.c |    6 +++---
21
 
 fs/utimes.c         |    2 +-
22
 
 include/linux/fs.h  |    6 +++---
23
 
 mm/filemap.c        |    2 +-
24
 
 11 files changed, 36 insertions(+), 30 deletions(-)
25
 
 
26
 
--- a/fs/attr.c
27
 
+++ b/fs/attr.c
28
 
@@ -100,7 +100,8 @@ int inode_setattr(struct inode * inode,
29
 
 }
30
 
 EXPORT_SYMBOL(inode_setattr);
31
 
 
32
 
-int notify_change(struct dentry * dentry, struct iattr * attr)
33
 
+int notify_change(struct dentry *dentry, struct vfsmount *mnt,
34
 
+                 struct iattr *attr)
35
 
 {
36
 
        struct inode *inode = dentry->d_inode;
37
 
        mode_t mode = inode->i_mode;
38
 
--- a/fs/ecryptfs/inode.c
39
 
+++ b/fs/ecryptfs/inode.c
40
 
@@ -849,6 +849,7 @@ static int ecryptfs_setattr(struct dentr
41
 
 {
42
 
        int rc = 0;
43
 
        struct dentry *lower_dentry;
44
 
+       struct vfsmount *lower_mnt;
45
 
        struct inode *inode;
46
 
        struct inode *lower_inode;
47
 
        struct ecryptfs_crypt_stat *crypt_stat;
48
 
@@ -859,6 +860,7 @@ static int ecryptfs_setattr(struct dentr
49
 
        inode = dentry->d_inode;
50
 
        lower_inode = ecryptfs_inode_to_lower(inode);
51
 
        lower_dentry = ecryptfs_dentry_to_lower(dentry);
52
 
+       lower_mnt = ecryptfs_dentry_to_lower_mnt(dentry);
53
 
        mutex_lock(&crypt_stat->cs_mutex);
54
 
        if (S_ISDIR(dentry->d_inode->i_mode))
55
 
                crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED);
56
 
@@ -910,7 +912,7 @@ static int ecryptfs_setattr(struct dentr
57
 
                ia->ia_valid &= ~ATTR_MODE;
58
 
 
59
 
        mutex_lock(&lower_dentry->d_inode->i_mutex);
60
 
-       rc = notify_change(lower_dentry, ia);
61
 
+       rc = notify_change(lower_dentry, lower_mnt, ia);
62
 
        mutex_unlock(&lower_dentry->d_inode->i_mutex);
63
 
 out:
64
 
        fsstack_copy_attr_all(inode, lower_inode, NULL);
65
 
--- a/fs/exec.c
66
 
+++ b/fs/exec.c
67
 
@@ -1821,7 +1821,8 @@ int do_coredump(long signr, int exit_cod
68
 
                goto close_fail;
69
 
        if (!file->f_op->write)
70
 
                goto close_fail;
71
 
-       if (!ispipe && do_truncate(file->f_path.dentry, 0, 0, file) != 0)
72
 
+       if (!ispipe &&
73
 
+           do_truncate(file->f_path.dentry, file->f_path.mnt, 0, 0, file) != 0)
74
 
                goto close_fail;
75
 
 
76
 
        retval = binfmt->core_dump(signr, regs, file, core_limit);
77
 
--- a/fs/hpfs/namei.c
78
 
+++ b/fs/hpfs/namei.c
79
 
@@ -426,7 +426,7 @@ again:
80
 
                        /*printk("HPFS: truncating file before delete.\n");*/
81
 
                        newattrs.ia_size = 0;
82
 
                        newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
83
 
-                       err = notify_change(dentry, &newattrs);
84
 
+                       err = notify_change(dentry, NULL, &newattrs);
85
 
                        put_write_access(inode);
86
 
                        if (!err)
87
 
                                goto again;
88
 
--- a/fs/namei.c
89
 
+++ b/fs/namei.c
90
 
@@ -1557,7 +1557,7 @@ int may_open(struct nameidata *nd, int a
91
 
                if (!error) {
92
 
                        DQUOT_INIT(inode);
93
 
 
94
 
-                       error = do_truncate(dentry, 0,
95
 
+                       error = do_truncate(dentry, nd->path.mnt, 0,
96
 
                                            ATTR_MTIME|ATTR_CTIME|ATTR_OPEN,
97
 
                                            NULL);
98
 
                }
99
 
--- a/fs/nfsd/vfs.c
100
 
+++ b/fs/nfsd/vfs.c
101
 
@@ -387,7 +387,7 @@ nfsd_setattr(struct svc_rqst *rqstp, str
102
 
        err = nfserr_notsync;
103
 
        if (!check_guard || guardtime == inode->i_ctime.tv_sec) {
104
 
                fh_lock(fhp);
105
 
-               host_err = notify_change(dentry, iap);
106
 
+               host_err = notify_change(dentry, fhp->fh_export->ex_path.mnt, iap);
107
 
                err = nfserrno(host_err);
108
 
                fh_unlock(fhp);
109
 
        }
110
 
@@ -947,13 +947,13 @@ out:
111
 
        return err;
112
 
 }
113
 
 
114
 
-static void kill_suid(struct dentry *dentry)
115
 
+static void kill_suid(struct dentry *dentry, struct vfsmount *mnt)
116
 
 {
117
 
        struct iattr    ia;
118
 
        ia.ia_valid = ATTR_KILL_SUID | ATTR_KILL_SGID | ATTR_KILL_PRIV;
119
 
 
120
 
        mutex_lock(&dentry->d_inode->i_mutex);
121
 
-       notify_change(dentry, &ia);
122
 
+       notify_change(dentry, mnt, &ia);
123
 
        mutex_unlock(&dentry->d_inode->i_mutex);
124
 
 }
125
 
 
126
 
@@ -1012,7 +1012,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, s
127
 
 
128
 
        /* clear setuid/setgid flag after write */
129
 
        if (host_err >= 0 && (inode->i_mode & (S_ISUID | S_ISGID)))
130
 
-               kill_suid(dentry);
131
 
+               kill_suid(dentry, exp->ex_path.mnt);
132
 
 
133
 
        if (host_err >= 0 && stable) {
134
 
                static ino_t    last_ino;
135
 
--- a/fs/open.c
136
 
+++ b/fs/open.c
137
 
@@ -197,8 +197,8 @@ out:
138
 
        return error;
139
 
 }
140
 
 
141
 
-int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
142
 
-       struct file *filp)
143
 
+int do_truncate(struct dentry *dentry, struct vfsmount *mnt, loff_t length,
144
 
+               unsigned int time_attrs, struct file *filp)
145
 
 {
146
 
        int err;
147
 
        struct iattr newattrs;
148
 
@@ -218,7 +218,7 @@ int do_truncate(struct dentry *dentry, l
149
 
        newattrs.ia_valid |= should_remove_suid(dentry);
150
 
 
151
 
        mutex_lock(&dentry->d_inode->i_mutex);
152
 
-       err = notify_change(dentry, &newattrs);
153
 
+       err = notify_change(dentry, mnt, &newattrs);
154
 
        mutex_unlock(&dentry->d_inode->i_mutex);
155
 
        return err;
156
 
 }
157
 
@@ -274,7 +274,7 @@ static long do_sys_truncate(const char _
158
 
        error = locks_verify_truncate(inode, NULL, length);
159
 
        if (!error) {
160
 
                DQUOT_INIT(inode);
161
 
-               error = do_truncate(path.dentry, length, 0, NULL);
162
 
+               error = do_truncate(path.dentry, path.mnt, length, 0, NULL);
163
 
        }
164
 
 
165
 
 put_write_and_out:
166
 
@@ -329,7 +329,8 @@ static long do_sys_ftruncate(unsigned in
167
 
 
168
 
        error = locks_verify_truncate(inode, file, length);
169
 
        if (!error)
170
 
-               error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);
171
 
+               error = do_truncate(dentry, file->f_path.mnt, length,
172
 
+                                   ATTR_MTIME|ATTR_CTIME, file);
173
 
 out_putf:
174
 
        fput(file);
175
 
 out:
176
 
@@ -605,7 +606,7 @@ asmlinkage long sys_fchmod(unsigned int
177
 
                mode = inode->i_mode;
178
 
        newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
179
 
        newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
180
 
-       err = notify_change(dentry, &newattrs);
181
 
+       err = notify_change(dentry, file->f_path.mnt, &newattrs);
182
 
        mutex_unlock(&inode->i_mutex);
183
 
        mnt_drop_write(file->f_path.mnt);
184
 
 out_putf:
185
 
@@ -635,7 +636,7 @@ asmlinkage long sys_fchmodat(int dfd, co
186
 
                mode = inode->i_mode;
187
 
        newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
188
 
        newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
189
 
-       error = notify_change(path.dentry, &newattrs);
190
 
+       error = notify_change(path.dentry, path.mnt, &newattrs);
191
 
        mutex_unlock(&inode->i_mutex);
192
 
        mnt_drop_write(path.mnt);
193
 
 dput_and_out:
194
 
@@ -649,7 +650,8 @@ asmlinkage long sys_chmod(const char __u
195
 
        return sys_fchmodat(AT_FDCWD, filename, mode);
196
 
 }
197
 
 
198
 
-static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
199
 
+static int chown_common(struct dentry * dentry, struct vfsmount *mnt,
200
 
+                       uid_t user, gid_t group)
201
 
 {
202
 
        struct inode *inode = dentry->d_inode;
203
 
        int error;
204
 
@@ -668,7 +670,7 @@ static int chown_common(struct dentry *
205
 
                newattrs.ia_valid |=
206
 
                        ATTR_KILL_SUID | ATTR_KILL_SGID | ATTR_KILL_PRIV;
207
 
        mutex_lock(&inode->i_mutex);
208
 
-       error = notify_change(dentry, &newattrs);
209
 
+       error = notify_change(dentry, mnt, &newattrs);
210
 
        mutex_unlock(&inode->i_mutex);
211
 
 
212
 
        return error;
213
 
@@ -685,7 +687,7 @@ asmlinkage long sys_chown(const char __u
214
 
        error = mnt_want_write(path.mnt);
215
 
        if (error)
216
 
                goto out_release;
217
 
-       error = chown_common(path.dentry, user, group);
218
 
+       error = chown_common(path.dentry, path.mnt, user, group);
219
 
        mnt_drop_write(path.mnt);
220
 
 out_release:
221
 
        path_put(&path);
222
 
@@ -710,7 +712,7 @@ asmlinkage long sys_fchownat(int dfd, co
223
 
        error = mnt_want_write(path.mnt);
224
 
        if (error)
225
 
                goto out_release;
226
 
-       error = chown_common(path.dentry, user, group);
227
 
+       error = chown_common(path.dentry, path.mnt, user, group);
228
 
        mnt_drop_write(path.mnt);
229
 
 out_release:
230
 
        path_put(&path);
231
 
@@ -729,7 +731,7 @@ asmlinkage long sys_lchown(const char __
232
 
        error = mnt_want_write(path.mnt);
233
 
        if (error)
234
 
                goto out_release;
235
 
-       error = chown_common(path.dentry, user, group);
236
 
+       error = chown_common(path.dentry, path.mnt, user, group);
237
 
        mnt_drop_write(path.mnt);
238
 
 out_release:
239
 
        path_put(&path);
240
 
@@ -753,7 +755,7 @@ asmlinkage long sys_fchown(unsigned int
241
 
                goto out_fput;
242
 
        dentry = file->f_path.dentry;
243
 
        audit_inode(NULL, dentry);
244
 
-       error = chown_common(dentry, user, group);
245
 
+       error = chown_common(dentry, file->f_path.mnt, user, group);
246
 
        mnt_drop_write(file->f_path.mnt);
247
 
 out_fput:
248
 
        fput(file);
249
 
--- a/fs/reiserfs/xattr.c
250
 
+++ b/fs/reiserfs/xattr.c
251
 
@@ -459,7 +459,7 @@ reiserfs_xattr_set(struct inode *inode,
252
 
        newattrs.ia_size = buffer_size;
253
 
        newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
254
 
        mutex_lock_nested(&xinode->i_mutex, I_MUTEX_XATTR);
255
 
-       err = notify_change(dentry, &newattrs);
256
 
+       err = notify_change(dentry, NULL, &newattrs);
257
 
        if (err)
258
 
                goto out_filp;
259
 
 
260
 
@@ -790,7 +790,7 @@ reiserfs_chown_xattrs_filler(void *buf,
261
 
        }
262
 
 
263
 
        if (!S_ISDIR(xafile->d_inode->i_mode))
264
 
-               err = notify_change(xafile, attrs);
265
 
+           err = notify_change(xafile, NULL, attrs);
266
 
        dput(xafile);
267
 
 
268
 
        return err;
269
 
@@ -834,7 +834,7 @@ int reiserfs_chown_xattrs(struct inode *
270
 
                goto out_dir;
271
 
        }
272
 
 
273
 
-       err = notify_change(dir, attrs);
274
 
+       err = notify_change(dir, NULL, attrs);
275
 
        unlock_kernel();
276
 
 
277
 
       out_dir:
278
 
--- a/fs/utimes.c
279
 
+++ b/fs/utimes.c
280
 
@@ -102,7 +102,7 @@ static int utimes_common(struct path *pa
281
 
                }
282
 
        }
283
 
        mutex_lock(&inode->i_mutex);
284
 
-       error = notify_change(path->dentry, &newattrs);
285
 
+       error = notify_change(path->dentry, path->mnt, &newattrs);
286
 
        mutex_unlock(&inode->i_mutex);
287
 
 
288
 
 mnt_drop_write_and_out:
289
 
--- a/include/linux/fs.h
290
 
+++ b/include/linux/fs.h
291
 
@@ -1669,8 +1669,8 @@ static inline int break_lease(struct ino
292
 
 
293
 
 /* fs/open.c */
294
 
 
295
 
-extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs,
296
 
-                      struct file *filp);
297
 
+extern int do_truncate(struct dentry *, struct vfsmount *, loff_t start,
298
 
+                      unsigned int time_attrs, struct file *filp);
299
 
 extern long do_sys_open(int dfd, const char __user *filename, int flags,
300
 
                        int mode);
301
 
 extern struct file *filp_open(const char *, int, int);
302
 
@@ -1830,7 +1830,7 @@ extern int do_remount_sb(struct super_bl
303
 
 #ifdef CONFIG_BLOCK
304
 
 extern sector_t bmap(struct inode *, sector_t);
305
 
 #endif
306
 
-extern int notify_change(struct dentry *, struct iattr *);
307
 
+extern int notify_change(struct dentry *, struct vfsmount *, struct iattr *);
308
 
 extern int inode_permission(struct inode *, int);
309
 
 extern int generic_permission(struct inode *, int,
310
 
                int (*check_acl)(struct inode *, int));
311
 
--- a/mm/filemap.c
312
 
+++ b/mm/filemap.c
313
 
@@ -1778,7 +1778,7 @@ static int __remove_suid(struct path *pa
314
 
        struct iattr newattrs;
315
 
 
316
 
        newattrs.ia_valid = ATTR_FORCE | kill;
317
 
-       return notify_change(path->dentry, &newattrs);
318
 
+       return notify_change(path->dentry, path->mnt, &newattrs);
319
 
 }
320
 
 
321
 
 int file_remove_suid(struct file *file)