The patch titled Subject: proc: more "unsigned int" in /proc/*/cmdline has been added to the -mm tree. Its filename is proc-more-unsigned-int-in-proc-cmdline.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/proc-more-unsigned-int-in-proc-cmdline.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/proc-more-unsigned-int-in-proc-cmdline.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Alexey Dobriyan <adobriyan@xxxxxxxxx> Subject: proc: more "unsigned int" in /proc/*/cmdline access_remote_vm() doesn't return negative errors, it returns number of bytes read/written (0 if error occurs). This allows to delete some comparisons which never trigger. Reuse "nr_read" variable while I'm at it. Link: http://lkml.kernel.org/r/20180221192605.GB28548@avx2 Signed-off-by: Alexey Dobriyan <adobriyan@xxxxxxxxx> Reviewed-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Cc: Andy Shevchenko <andy.shevchenko@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- fs/proc/base.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff -puN fs/proc/base.c~proc-more-unsigned-int-in-proc-cmdline fs/proc/base.c --- a/fs/proc/base.c~proc-more-unsigned-int-in-proc-cmdline +++ a/fs/proc/base.c @@ -277,9 +277,10 @@ static ssize_t proc_pid_cmdline_read(str * Inherently racy -- command line shares address space * with code and data. */ - rv = access_remote_vm(mm, arg_end - 1, &c, 1, 0); - if (rv <= 0) + if (access_remote_vm(mm, arg_end - 1, &c, 1, 0) != 1) { + rv = 0; goto out_free_page; + } rv = 0; @@ -291,14 +292,11 @@ static ssize_t proc_pid_cmdline_read(str p = arg_start + *pos; len = len1 - *pos; while (count > 0 && len > 0) { - unsigned int _count; - int nr_read; + unsigned int nr_read; - _count = min3(count, len, PAGE_SIZE); - nr_read = access_remote_vm(mm, p, page, _count, 0); - if (nr_read < 0) - rv = nr_read; - if (nr_read <= 0) + nr_read = min3(count, len, PAGE_SIZE); + nr_read = access_remote_vm(mm, p, page, nr_read, 0); + if (nr_read == 0) goto out_free_page; if (copy_to_user(buf, page, nr_read)) { @@ -336,15 +334,12 @@ static ssize_t proc_pid_cmdline_read(str p = cmdline[i].p + pos1; len = cmdline[i].len - pos1; while (count > 0 && len > 0) { - unsigned int _count, l; - int nr_read; + unsigned int nr_read, l; bool final; - _count = min3(count, len, PAGE_SIZE); - nr_read = access_remote_vm(mm, p, page, _count, 0); - if (nr_read < 0) - rv = nr_read; - if (nr_read <= 0) + nr_read = min3(count, len, PAGE_SIZE); + nr_read = access_remote_vm(mm, p, page, nr_read, 0); + if (nr_read == 0) goto out_free_page; /* _ Patches currently in -mm which might be from adobriyan@xxxxxxxxx are proc-revalidate-kernel-thread-inodes-to-root-root.patch proc-fix-proc-loadavg-regression.patch proc-make-proc-cmdline-go-through-lsm.patch proc-more-unsigned-int-in-proc-cmdline.patch proc-somewhat-simpler-code-for-proc-cmdline.patch proc-simpler-iterations-for-proc-cmdline.patch proc-deduplicate-proc-cmdline-implementation.patch coredump-fix-spam-with-zero-vma-process.patch seq_file-delete-small-value-optimization.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html