lkml.org 
[lkml]   [2018]   [Jun]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: regression: /proc/$pid/cmdline lacks trailing '\0' in 4.18-rc1
On Tue, Jun 19, 2018 at 08:07:55AM +0200, Michal Kubecek wrote:
> In v4.18-rc1, /proc/$pid/cmdline is missing final null byte which used
> to be there in v4.17 and older kernels:
>
> 4.17.1:
> tweed:~ # cat /proc/self/cmdline | od -t c
> 0000000 c a t \0 / p r o c / s e l f / c
> 0000020 m d l i n e \0
> 0000027
>
> 4.18-rc1:
> lion:~ # cat /proc/self/cmdline | od -t c
> 0000000 c a t \0 / p r o c / s e l f / c
> 0000020 m d l i n e
> 0000026
>
> The code has been rewritten quite a lot in 4.18-rc1 so I didn't find yet
> where exactly does the change come from. Still looking.

The issue was introduced by commit 5ab827189965 ("fs/proc: simplify and
clarify get_mm_cmdline() function"). The problem is that when looking
for the null character at or after args_end, strnlen() is used and it
returns the length _without_ the null character (if there is one) so
that we don't copy it.

I'll submit a patch once I test it.

Michal Kubecek

\
 
 \ /
  Last update: 2018-06-19 11:23    [W:0.109 / U:0.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site