David Rientjes
830e0fc967
fs, proc: truncate /proc/pid/comm writes to first TASK_COMM_LEN bytes
...
Currently, a write to a procfs file will return the number of bytes
successfully written. If the actual string is longer than this, the
remainder of the string will not be be written and userspace will
complete the operation by issuing additional write()s.
Hence
$ echo -n "abcdefghijklmnopqrs" > /proc/self/comm
results in
$ cat /proc/$$/comm
pqrs
since the final four bytes were written with a second write() since
TASK_COMM_LEN == 16. This is obviously an undesired result and not
equivalent to prctl(PR_SET_NAME). The implementation should not need to
know the definition of TASK_COMM_LEN.
This patch truncates the string to the first TASK_COMM_LEN bytes and
returns the bytes written as the length of the string written so the
second write() is suppressed.
$ cat /proc/$$/comm
abcdefghijklmno
Signed-off-by: David Rientjes <rientjes@google.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-04-30 17:04:07 -07:00
..
array.c
kthread: Prevent unpark race which puts threads on the wrong cpu
2013-04-12 14:18:43 +02:00
base.c
fs, proc: truncate /proc/pid/comm writes to first TASK_COMM_LEN bytes
2013-04-30 17:04:07 -07:00
cmdline.c
proc: switch /proc/cmdline to seq_file
2008-10-23 14:29:04 +04:00
consoles.c
console: rename acquire/release_console_sem() to console_lock/unlock()
2011-01-26 10:50:06 +10:00
cpuinfo.c
proc: move /proc/cpuinfo code to fs/proc/cpuinfo.c
2008-10-23 15:05:11 +04:00
devices.c
proc: use seq_puts()/seq_putc() where possible
2011-01-13 08:03:16 -08:00
fd.c
procfs: add ability to plug in auxiliary fdinfo providers
2012-12-17 17:15:27 -08:00
fd.h
procfs: Move /proc/pid/fd[info] handling code to fd.[ch]
2012-09-26 21:10:01 -04:00
generic.c
procfs: add proc_remove_subtree()
2013-04-09 14:09:17 -04:00
inode.c
vfs,proc: guarantee unique inodes in /proc
2013-03-22 11:44:04 -07:00
internal.h
mm, vmalloc: move get_vmalloc_info() to vmalloc.c
2013-04-29 15:54:33 -07:00
interrupts.c
proc: move /proc/interrupts boilerplate code to fs/proc/interrupts.c
2008-10-23 15:15:46 +04:00
Kconfig
kconfig: rename CONFIG_EMBEDDED to CONFIG_EXPERT
2011-01-20 17:02:05 -08:00
kcore.c
fs/proc/kcore.c: use register_hotmemory_notifier()
2013-04-29 15:54:36 -07:00
kmsg.c
procfs: Use generic_file_llseek in /proc/kmsg
2010-04-09 16:35:41 +02:00
loadavg.c
sched, timers: cleanup avenrun users
2009-05-15 15:32:45 +02:00
Makefile
mm, vmalloc: move get_vmalloc_info() to vmalloc.c
2013-04-29 15:54:33 -07:00
meminfo.c
mm, vmalloc: move get_vmalloc_info() to vmalloc.c
2013-04-29 15:54:33 -07:00
namespaces.c
proc: Use nd_jump_link in proc_ns_follow_link
2013-03-09 00:14:45 -08:00
nommu.c
new helper: file_inode(file)
2013-02-22 23:31:31 -05:00
page.c
kpageflags: fix wrong KPF_THP on non-huge compound pages
2012-10-09 16:23:00 +09:00
proc_devtree.c
fs/proc: clean up printks
2013-02-27 19:10:11 -08:00
proc_net.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2013-02-26 20:16:07 -08:00
proc_sysctl.c
fs/proc: clean up printks
2013-02-27 19:10:11 -08:00
proc_tty.c
proc: use seq_puts()/seq_putc() where possible
2011-01-13 08:03:16 -08:00
root.c
userns: Restrict when proc and sysfs can be mounted
2013-03-27 07:50:08 -07:00
self.c
procfs: Use the proc generic infrastructure for proc/self.
2012-11-19 03:09:34 -08:00
softirqs.c
proc: use seq_puts()/seq_putc() where possible
2011-01-13 08:03:16 -08:00
stat.c
nohz: Fix idle ticks in cpu summary line of /proc/stat
2012-10-10 14:05:21 +02:00
task_mmu.c
new helper: file_inode(file)
2013-02-22 23:31:31 -05:00
task_nommu.c
new helper: file_inode(file)
2013-02-22 23:31:31 -05:00
uptime.c
Merge branch 'sched/core' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip into cputime-tip
2011-12-19 19:23:15 +01:00
version.c
proc: switch /proc/version to seq_file
2008-10-23 14:19:58 +04:00
vmcore.c
fs/proc/vmcore.c: put if tests in the top of the while loop to reduce duplication
2013-02-27 19:10:11 -08:00