diff options
Diffstat (limited to 'fs/proc/base.c')
-rw-r--r-- | fs/proc/base.c | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index 808cbdc193d3..3b455371e7ff 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -127,6 +127,25 @@ struct pid_entry { | |||
127 | NULL, &proc_single_file_operations, \ | 127 | NULL, &proc_single_file_operations, \ |
128 | { .proc_show = &proc_##OTYPE } ) | 128 | { .proc_show = &proc_##OTYPE } ) |
129 | 129 | ||
130 | /* | ||
131 | * Count the number of hardlinks for the pid_entry table, excluding the . | ||
132 | * and .. links. | ||
133 | */ | ||
134 | static unsigned int pid_entry_count_dirs(const struct pid_entry *entries, | ||
135 | unsigned int n) | ||
136 | { | ||
137 | unsigned int i; | ||
138 | unsigned int count; | ||
139 | |||
140 | count = 0; | ||
141 | for (i = 0; i < n; ++i) { | ||
142 | if (S_ISDIR(entries[i].mode)) | ||
143 | ++count; | ||
144 | } | ||
145 | |||
146 | return count; | ||
147 | } | ||
148 | |||
130 | int maps_protect; | 149 | int maps_protect; |
131 | EXPORT_SYMBOL(maps_protect); | 150 | EXPORT_SYMBOL(maps_protect); |
132 | 151 | ||
@@ -2441,7 +2460,7 @@ static const struct pid_entry tgid_base_stuff[] = { | |||
2441 | REG("oom_adj", S_IRUGO|S_IWUSR, oom_adjust), | 2460 | REG("oom_adj", S_IRUGO|S_IWUSR, oom_adjust), |
2442 | #ifdef CONFIG_AUDITSYSCALL | 2461 | #ifdef CONFIG_AUDITSYSCALL |
2443 | REG("loginuid", S_IWUSR|S_IRUGO, loginuid), | 2462 | REG("loginuid", S_IWUSR|S_IRUGO, loginuid), |
2444 | REG("sessionid", S_IRUSR, sessionid), | 2463 | REG("sessionid", S_IRUGO, sessionid), |
2445 | #endif | 2464 | #endif |
2446 | #ifdef CONFIG_FAULT_INJECTION | 2465 | #ifdef CONFIG_FAULT_INJECTION |
2447 | REG("make-it-fail", S_IRUGO|S_IWUSR, fault_inject), | 2466 | REG("make-it-fail", S_IRUGO|S_IWUSR, fault_inject), |
@@ -2585,10 +2604,9 @@ static struct dentry *proc_pid_instantiate(struct inode *dir, | |||
2585 | inode->i_op = &proc_tgid_base_inode_operations; | 2604 | inode->i_op = &proc_tgid_base_inode_operations; |
2586 | inode->i_fop = &proc_tgid_base_operations; | 2605 | inode->i_fop = &proc_tgid_base_operations; |
2587 | inode->i_flags|=S_IMMUTABLE; | 2606 | inode->i_flags|=S_IMMUTABLE; |
2588 | inode->i_nlink = 5; | 2607 | |
2589 | #ifdef CONFIG_SECURITY | 2608 | inode->i_nlink = 2 + pid_entry_count_dirs(tgid_base_stuff, |
2590 | inode->i_nlink += 1; | 2609 | ARRAY_SIZE(tgid_base_stuff)); |
2591 | #endif | ||
2592 | 2610 | ||
2593 | dentry->d_op = &pid_dentry_operations; | 2611 | dentry->d_op = &pid_dentry_operations; |
2594 | 2612 | ||
@@ -2816,10 +2834,9 @@ static struct dentry *proc_task_instantiate(struct inode *dir, | |||
2816 | inode->i_op = &proc_tid_base_inode_operations; | 2834 | inode->i_op = &proc_tid_base_inode_operations; |
2817 | inode->i_fop = &proc_tid_base_operations; | 2835 | inode->i_fop = &proc_tid_base_operations; |
2818 | inode->i_flags|=S_IMMUTABLE; | 2836 | inode->i_flags|=S_IMMUTABLE; |
2819 | inode->i_nlink = 4; | 2837 | |
2820 | #ifdef CONFIG_SECURITY | 2838 | inode->i_nlink = 2 + pid_entry_count_dirs(tid_base_stuff, |
2821 | inode->i_nlink += 1; | 2839 | ARRAY_SIZE(tid_base_stuff)); |
2822 | #endif | ||
2823 | 2840 | ||
2824 | dentry->d_op = &pid_dentry_operations; | 2841 | dentry->d_op = &pid_dentry_operations; |
2825 | 2842 | ||