UPSTREAM: procfs: fix pthread cross-thread naming if !PR_DUMPABLE

The PR_DUMPABLE flag causes the pid related paths of the proc file
system to be owned by ROOT.

The implementation of pthread_set/getname_np however needs access to
/proc/<pid>/task/<tid>/comm.  If PR_DUMPABLE is false this
implementation is locked out.

This patch installs a special permission function for the file "comm"
that grants read and write access to all threads of the same group
regardless of the ownership of the inode.  For all other threads the
function falls back to the generic inode permission check.

[ fix spello in comment]
Signed-off-by: Janis Danisevskis <>
Acked-by: Kees Cook <>
Cc: Al Viro <>
Cc: Cyrill Gorcunov <>
Cc: Alexey Dobriyan <>
Cc: Colin Ian King <>
Cc: David Rientjes <>
Cc: Minfei Huang <>
Cc: John Stultz <>
Cc: Calvin Owens <>
Cc: Jann Horn <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>

Bug: None
Patchset: procfs-cross-thread-naming

(cherry-picked from 1b3044e39a89cb1d4d5313da477e8dfea2b5232d)
Signed-off-by: Mattias Nissler <>

Change-Id: Ib4a1d8532561cd87eed1e1c820155d97c0149dfe
1 file changed