lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 8 Aug 2014 20:57:47 +0200
From:	Oleg Nesterov <oleg@...hat.com>
To:	Alexander Viro <viro@...iv.linux.org.uk>,
	Alexey Dobriyan <adobriyan@...il.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Cyrill Gorcunov <gorcunov@...nvz.org>,
	David Howells <dhowells@...hat.com>,
	"David S. Miller" <davem@...emloft.net>,
	"Eric W. Biederman" <ebiederm@...ssion.com>,
	"Kirill A. Shutemov" <kirill@...temov.name>,
	Peter Zijlstra <peterz@...radead.org>,
	Sasha Levin <levinsasha928@...il.com>
Cc:	linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [RFC PATCH 1/5] proc: intoduce proc_inode->pid_entry and
	is_tgid_pid_entry()

Add the new "struct pid_entry *" member into struct proc_inode, and
the new helper, is_tgid_pid_entry(), it can be used by *base_stuff
to figure out whether we need tgid or tid info.

Note: this obviously blows struct proc_inode, but I think it is
simple to put ->fd, ->sysctl/sysctl_entry, and the new member in
the union, the only complication is that proc_evict_inode() should
be carefull with ->sysctl.

Signed-off-by: Oleg Nesterov <oleg@...hat.com>
---
 fs/proc/base.c     |   16 +++++++++++++++-
 fs/proc/inode.c    |    1 +
 fs/proc/internal.h |    4 ++++
 3 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index 9aef9ac..ea11bf1 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2124,6 +2124,9 @@ static int proc_pident_instantiate(struct inode *dir,
 		goto out;
 
 	ei = PROC_I(inode);
+	ei->pid_entry = p;
+	ei->op = p->op;
+
 	inode->i_mode = p->mode;
 	if (S_ISDIR(inode->i_mode))
 		set_nlink(inode, 2);	/* Use getattr to fix if necessary */
@@ -2131,7 +2134,7 @@ static int proc_pident_instantiate(struct inode *dir,
 		inode->i_op = p->iop;
 	if (p->fop)
 		inode->i_fop = p->fop;
-	ei->op = p->op;
+
 	d_set_d_op(dentry, &pid_dentry_operations);
 	d_add(dentry, inode);
 	/* Close the race of the process dying before we return the dentry */
@@ -2978,6 +2981,17 @@ static const struct pid_entry tid_base_stuff[] = {
 #endif
 };
 
+bool is_tgid_pid_entry(const struct pid_entry *p)
+{
+	if (p >= tgid_base_stuff &&
+	    p <  tgid_base_stuff + ARRAY_SIZE(tgid_base_stuff))
+		return true;
+	if (p >= tid_base_stuff &&
+	    p <  tid_base_stuff + ARRAY_SIZE(tid_base_stuff))
+		return false;
+	BUG();
+}
+
 static int proc_tid_base_readdir(struct file *file, struct dir_context *ctx)
 {
 	return proc_pident_readdir(file, ctx,
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 0adbc02..45ad621 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -73,6 +73,7 @@ static struct inode *proc_alloc_inode(struct super_block *sb)
 	ei->pde = NULL;
 	ei->sysctl = NULL;
 	ei->sysctl_entry = NULL;
+	ei->pid_entry = NULL;
 	ei->ns.ns = NULL;
 	ei->ns.ns_ops = NULL;
 	inode = &ei->vfs_inode;
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index 78784cd..2e310b6 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -15,6 +15,7 @@
 #include <linux/atomic.h>
 #include <linux/binfmts.h>
 
+struct pid_entry;
 struct ctl_table_header;
 struct mempolicy;
 
@@ -65,6 +66,7 @@ struct proc_inode {
 	struct proc_dir_entry *pde;
 	struct ctl_table_header *sysctl;
 	struct ctl_table *sysctl_entry;
+	const struct pid_entry *pid_entry;
 	struct proc_ns ns;
 	struct inode vfs_inode;
 };
@@ -147,6 +149,8 @@ out:
  */
 extern const struct file_operations proc_tid_children_operations;
 
+extern bool is_tgid_pid_entry(const struct pid_entry *p);
+
 extern int proc_tid_stat(struct seq_file *, struct pid_namespace *,
 			 struct pid *, struct task_struct *);
 extern int proc_tgid_stat(struct seq_file *, struct pid_namespace *,
-- 
1.5.5.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists