|
@@ -104,6 +104,9 @@
|
|
|
* in /proc for a task before it execs a suid executable.
|
|
|
*/
|
|
|
|
|
|
+static u8 nlink_tid;
|
|
|
+static u8 nlink_tgid;
|
|
|
+
|
|
|
struct pid_entry {
|
|
|
const char *name;
|
|
|
unsigned int len;
|
|
@@ -139,13 +142,13 @@ struct pid_entry {
|
|
|
* Count the number of hardlinks for the pid_entry table, excluding the .
|
|
|
* and .. links.
|
|
|
*/
|
|
|
-static unsigned int pid_entry_count_dirs(const struct pid_entry *entries,
|
|
|
+static unsigned int __init pid_entry_nlink(const struct pid_entry *entries,
|
|
|
unsigned int n)
|
|
|
{
|
|
|
unsigned int i;
|
|
|
unsigned int count;
|
|
|
|
|
|
- count = 0;
|
|
|
+ count = 2;
|
|
|
for (i = 0; i < n; ++i) {
|
|
|
if (S_ISDIR(entries[i].mode))
|
|
|
++count;
|
|
@@ -3068,8 +3071,7 @@ static int proc_pid_instantiate(struct inode *dir,
|
|
|
inode->i_fop = &proc_tgid_base_operations;
|
|
|
inode->i_flags|=S_IMMUTABLE;
|
|
|
|
|
|
- set_nlink(inode, 2 + pid_entry_count_dirs(tgid_base_stuff,
|
|
|
- ARRAY_SIZE(tgid_base_stuff)));
|
|
|
+ set_nlink(inode, nlink_tgid);
|
|
|
|
|
|
d_set_d_op(dentry, &pid_dentry_operations);
|
|
|
|
|
@@ -3361,8 +3363,7 @@ static int proc_task_instantiate(struct inode *dir,
|
|
|
inode->i_fop = &proc_tid_base_operations;
|
|
|
inode->i_flags|=S_IMMUTABLE;
|
|
|
|
|
|
- set_nlink(inode, 2 + pid_entry_count_dirs(tid_base_stuff,
|
|
|
- ARRAY_SIZE(tid_base_stuff)));
|
|
|
+ set_nlink(inode, nlink_tid);
|
|
|
|
|
|
d_set_d_op(dentry, &pid_dentry_operations);
|
|
|
|
|
@@ -3552,3 +3553,9 @@ static const struct file_operations proc_task_operations = {
|
|
|
.iterate_shared = proc_task_readdir,
|
|
|
.llseek = generic_file_llseek,
|
|
|
};
|
|
|
+
|
|
|
+void __init set_proc_pid_nlink(void)
|
|
|
+{
|
|
|
+ nlink_tid = pid_entry_nlink(tid_base_stuff, ARRAY_SIZE(tid_base_stuff));
|
|
|
+ nlink_tgid = pid_entry_nlink(tgid_base_stuff, ARRAY_SIZE(tgid_base_stuff));
|
|
|
+}
|