~apparmor-dev/apparmor/2_3

« back to all changes in this revision

Viewing changes to kernel-patches/for-mainline/nfs-nameidata-check.diff

  • Committer: jrjohansen
  • Date: 2008-05-27 12:04:33 UTC
  • Revision ID: svn-v4:40609528-9d10-0410-9bd8-e926d5471da9:branches/2_3:1265
remove for-mainline dir from kernel patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
From: Andreas Gruenbacher <agruen@suse.de>
2
 
Subject: nfs NULL nameidata check?
3
 
 
4
 
nfs_lookup() checks for NULL nameidata in one place, but not in another. In 
5
 
nfs_sillyrename() it calls lookup_one_len() -> __lookup_hash(), which passes 
6
 
in a NULL nameidata to nfs_lookup(). Unless I'm overlooking something, 
7
 
fs/nfs/dir.c:923 will dereference this NULL pointer if the sillyrenamed file 
8
 
exists?
9
 
 
10
 
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
11
 
 
12
 
---
13
 
 fs/nfs/dir.c |   12 ++++++------
14
 
 1 file changed, 6 insertions(+), 6 deletions(-)
15
 
 
16
 
--- a/fs/nfs/dir.c
17
 
+++ b/fs/nfs/dir.c
18
 
@@ -896,15 +896,15 @@ int nfs_is_exclusive_create(struct inode
19
 
        return (nd->intent.open.flags & O_EXCL) != 0;
20
 
 }
21
 
 
22
 
-static inline int nfs_reval_fsid(struct vfsmount *mnt, struct inode *dir,
23
 
+static inline int nfs_reval_fsid(struct nameidata *nd, struct inode *dir,
24
 
                                 struct nfs_fh *fh, struct nfs_fattr *fattr)
25
 
 {
26
 
        struct nfs_server *server = NFS_SERVER(dir);
27
 
 
28
 
-       if (!nfs_fsid_equal(&server->fsid, &fattr->fsid))
29
 
-               /* Revalidate fsid on root dir */
30
 
-               return __nfs_revalidate_inode(server, mnt->mnt_root->d_inode);
31
 
-       return 0;
32
 
+       if (nd == NULL || nfs_fsid_equal(&server->fsid, &fattr->fsid))
33
 
+               return 0;
34
 
+       /* Revalidate fsid on root dir */
35
 
+       return __nfs_revalidate_inode(server, nd->mnt->mnt_root->d_inode);
36
 
 }
37
 
 
38
 
 static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, struct nameidata2 *nd)
39
 
@@ -945,7 +945,7 @@ static struct dentry *nfs_lookup(struct 
40
 
                res = ERR_PTR(error);
41
 
                goto out_unlock;
42
 
        }
43
 
-       error = nfs_reval_fsid(nd->mnt, dir, &fhandle, &fattr);
44
 
+       error = nfs_reval_fsid(nd, dir, &fhandle, &fattr);
45
 
        if (error < 0) {
46
 
                res = ERR_PTR(error);
47
 
                goto out_unlock;