fix a race in release_task when flushing the dentry
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest posting 2/210 patches 5 repliesIn review
- v2 posting 1/20 of 10 patches 0 repliesSuperseded
- v110 patches 8 repliesSuperseded
Patches in v2 posting 2/2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/10 | clone: add CLONE_PIDFDinclude/ include/ kernel/ | +103 | 0 replies | |
| 2/10 | pidfd: add polling supportinclude/ kernel/ kernel/ +1 more | +42 | 0 replies | |
| 3/10 | proc: Pass file mode to proc_pid_make_inodefs/ fs/ fs/ +2 more | +14 | 0 replies | |
| 4/10 | proc: Better ownership of files for non-dumpable tasks in user namespacesfs/ fs/ fs/ | +61 | 0 replies | |
| 5/10 | proc: use %u for pid printing and slightly less stackfs/ fs/ fs/ +1 more | +14 | 0 replies | |
| 6/10 | proc: Rename in proc_inode rename sysctl_inodes sibling_inodesfs/ fs/ fs/ | +6 | 0 replies | |
| 7/10 | proc: Generalize proc_sys_prune_dcache into proc_prune_siblings_dcachefs/ fs/ fs/ | +40 | 0 replies | |
| 8/10 | proc: Clear the pieces of proc_inode that proc_evict_inode cares aboutfs/ | +11 | 0 replies | |
| 9/10 | proc: Use d_invalidate in proc_prune_siblings_dcachefs/ fs/ fs/ | +19 | 0 replies | |
| 10/10 | proc: Use a list of inodes to flush from procfs/ fs/ fs/ +4 more | +45 | 0 replies |
Reviews trailers per patch
2 of 10 patches have a Reviewed-by or Acked-by.
| Patch | Oleg Nesterov |
|---|---|
| 1/10 | R-b |
| 2/10 | R-b |
| 3/10 | |
| 4/10 | |
| 5/10 | |
| 6/10 | |
| 7/10 | |
| 8/10 | |
| 9/10 | |
| 10/10 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v2 4.9 00/10] fix a race in release_task when flushing the dentry
The dentries such as /proc/<pid>/ns/ have the DCACHE_OP_DELETE flag, they should be deleted when the process exits.
Suppose the following race appears:
release_task dput
-> proc_flush_task
-> dentry->d_op->d_delete(dentry)
-> __exit_signal
-> dentry->d_lockref.count-- and return. In the proc_flush_task(), if another process is using this dentry, it will not be deleted. At the same time, in dput(), d_op->d_delete() can be executed before __exit_signal(pid has not been hashed), d_delete returns false, so this dentry still cannot be deleted.
This dentry will always be cached (although its count is 0 and the DCACHE_OP_DELETE flag is set), its parent denry will also be cached too, and these dentries can only be deleted when drop_caches is manually triggered.
This will result in wasted memory. What's more troublesome is that these dentries reference pid, according to the commit f333c700c610 ("pidns: Add a limit on the number of pid namespaces"), if the pid cannot be released, it may result in the inability to create a new pid_ns.
This issue was introduced by 60347f6716aa ("pid namespaces: prepare proc_flust_task() to flush entries from multiple proc trees"), exposed by f333c700c610 ("pidns: Add a limit on the number of pid namespaces"), and then fixed by 7bc3e6e55acf ("proc: Use a list of inodes to flush from proc").
Alexey Dobriyan (1):
proc: use %u for pid printing and slightly less stack
Andreas Gruenbacher (1):
proc: Pass file mode to proc_pid_make_inode
Christian Brauner (1):
clone: add CLONE_PIDFD
Eric W. Biederman (6):
proc: Better ownership of files for non-dumpable tasks in user
namespaces
proc: Rename in proc_inode rename sysctl_inodes sibling_inodes
proc: Generalize proc_sys_prune_dcache into proc_prune_siblings_dcache
proc: Clear the pieces of proc_inode that proc_evict_inode cares about
proc: Use d_invalidate in proc_prune_siblings_dcache
proc: Use a list of inodes to flush from proc
Joel Fernandes (Google) (1):
pidfd: add polling support
fs/proc/base.c | 242 ++++++++++++++++++++------------------------- fs/proc/fd.c | 20 +--- fs/proc/inode.c | 67 ++++++++++++- fs/proc/internal.h | 22 ++--- fs/proc/namespaces.c | 3 +- fs/proc/proc_sysctl.c | 45 ++------- fs/proc/self.c | 6 +- fs/proc/thread_self.c | 5 +- include/linux/pid.h | 5 + include/linux/proc_fs.h | 4 +- include/uapi/linux/sched.h | 1 + kernel/exit.c | 5 +- kernel/fork.c | 131 +++++++++++++++++++++++- kernel/pid.c | 3 + kernel/signal.c | 11 +++ security/selinux/hooks.c | 1 + 16 files changed, 343 insertions(+), 228 deletions(-)
Signature · 1 line
1.8.3.1