linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mimi Zohar <zohar@linux.vnet.ibm.com>
To: linux-security-module@vger.kernel.org
Cc: Mimi Zohar <zohar@linux.vnet.ibm.com>,
	viro@ZenIV.linux.org.uk, Josh Boyer <jwboyer@redhat.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	linux-fsdevel@vger.kernel.org, Mimi Zohar <zohar@us.ibm.com>
Subject: [RFC][PATCH] lockdep: annotate proc and other filesystems
Date: Mon, 12 Dec 2011 07:33:15 -0500	[thread overview]
Message-ID: <1323693195-3004-1-git-send-email-zohar@linux.vnet.ibm.com> (raw)

Using lockdep_annotate_inode_mutex_key() to annotate proc and other
filesystems, resolves the lockdep messages as described in 
http://www.spinics.net/lists/linux-fsdevel/msg49879.html.

Commit "e096d0c lockdep: Add helper function for dir vs file i_mutex
annotation" defined lockdep_annotate_inode_mutex_key(), a helper function,
but only updated hugetlbfs to call this function.

This patch annotates proc and other filesystems, which call new_inode()
directly.

Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
---
 fs/debugfs/inode.c           |    1 +
 fs/devpts/inode.c            |    4 +++-
 fs/proc/base.c               |    4 ++++
 fs/proc/namespaces.c         |    1 +
 fs/proc/proc_sysctl.c        |    1 +
 fs/ramfs/inode.c             |    1 +
 mm/shmem.c                   |    1 +
 security/inode.c             |    1 +
 security/selinux/selinuxfs.c |    1 +
 9 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index f3a257d..707c14a 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -63,6 +63,7 @@ static struct inode *debugfs_get_inode(struct super_block *sb, int mode, dev_t d
 			inc_nlink(inode);
 			break;
 		}
+		lockdep_annotate_inode_mutex_key(inode);
 	}
 	return inode; 
 }
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index d5d5297..11a0cc1 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -310,8 +310,10 @@ devpts_fill_super(struct super_block *s, void *data, int silent)
 	set_nlink(inode, 2);
 
 	s->s_root = d_alloc_root(inode);
-	if (s->s_root)
+	if (s->s_root) {
+		lockdep_annotate_inode_mutex_key(inode);
 		return 0;
+	}
 
 	printk(KERN_ERR "devpts: get root dentry failed\n");
 	iput(inode);
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 851ba3d..44d60ce 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2259,6 +2259,7 @@ static struct dentry *proc_pident_instantiate(struct inode *dir,
 	/* Close the race of the process dying before we return the dentry */
 	if (pid_revalidate(dentry, NULL))
 		error = NULL;
+	lockdep_annotate_inode_mutex_key(inode);
 out:
 	return error;
 }
@@ -2652,6 +2653,7 @@ static struct dentry *proc_base_instantiate(struct inode *dir,
 	ei->op = p->op;
 	d_add(dentry, inode);
 	error = NULL;
+	lockdep_annotate_inode_mutex_key(inode);
 out:
 	return error;
 out_iput:
@@ -2990,6 +2992,7 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
 	/* Close the race of the process dying before we return the dentry */
 	if (pid_revalidate(dentry, NULL))
 		error = NULL;
+	lockdep_annotate_inode_mutex_key(inode);
 out:
 	return error;
 }
@@ -3242,6 +3245,7 @@ static struct dentry *proc_task_instantiate(struct inode *dir,
 	/* Close the race of the process dying before we return the dentry */
 	if (pid_revalidate(dentry, NULL))
 		error = NULL;
+	lockdep_annotate_inode_mutex_key(inode);
 out:
 	return error;
 }
diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c
index be177f7..e366ab9 100644
--- a/fs/proc/namespaces.c
+++ b/fs/proc/namespaces.c
@@ -59,6 +59,7 @@ static struct dentry *proc_ns_instantiate(struct inode *dir,
 	/* Close the race of the process dying before we return the dentry */
 	if (pid_revalidate(dentry, NULL))
 		error = NULL;
+	lockdep_annotate_inode_mutex_key(inode);
 out:
 	return error;
 out_iput:
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index a6b6217..096572f 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -53,6 +53,7 @@ static struct inode *proc_sys_make_inode(struct super_block *sb,
 		inode->i_op = &proc_sys_dir_operations;
 		inode->i_fop = &proc_sys_dir_file_operations;
 	}
+	lockdep_annotate_inode_mutex_key(inode);
 out:
 	return inode;
 }
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index 462ceb3..7fb2f56 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -83,6 +83,7 @@ struct inode *ramfs_get_inode(struct super_block *sb,
 			inode->i_op = &page_symlink_inode_operations;
 			break;
 		}
+		lockdep_annotate_inode_mutex_key(inode);
 	}
 	return inode;
 }
diff --git a/mm/shmem.c b/mm/shmem.c
index d672250..addd5a8 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1144,6 +1144,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode
 			mpol_shared_policy_init(&info->policy, NULL);
 			break;
 		}
+		lockdep_annotate_inode_mutex_key(inode);
 	} else
 		shmem_free_inode(sb);
 	return inode;
diff --git a/security/inode.c b/security/inode.c
index c4df2fb..fd61a3d 100644
--- a/security/inode.c
+++ b/security/inode.c
@@ -79,6 +79,7 @@ static struct inode *get_inode(struct super_block *sb, int mode, dev_t dev)
 			inc_nlink(inode);
 			break;
 		}
+		lockdep_annotate_inode_mutex_key(inode);
 	}
 	return inode;
 }
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index 48a7d00..7997840 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -1030,6 +1030,7 @@ static struct inode *sel_make_inode(struct super_block *sb, int mode)
 	if (ret) {
 		ret->i_mode = mode;
 		ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
+		lockdep_annotate_inode_mutex_key(ret);
 	}
 	return ret;
 }
-- 
1.7.6.4


                 reply	other threads:[~2011-12-12 12:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1323693195-3004-1-git-send-email-zohar@linux.vnet.ibm.com \
    --to=zohar@linux.vnet.ibm.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=jwboyer@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    --cc=zohar@us.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).