Bug 107321 - Writing to /proc/[pid]/coredump_filter always fails with ESRCH
Summary: Writing to /proc/[pid]/coredump_filter always fails with ESRCH
Status: NEW
Alias: None
Product: File System
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: fs_other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-05 18:44 UTC by Joshua Baergen
Modified: 2016-03-20 09:56 UTC (History)
2 users (show)

See Also:
Kernel Version: 4.3
Subsystem:
Regression: Yes
Bisected commit-id:


Attachments
Patch for fs/proc/base.c (668 bytes, patch)
2015-11-06 16:53 UTC, Joshua Baergen
Details | Diff
Patch for fs/proc/base.c (661 bytes, patch)
2015-11-06 18:04 UTC, Joshua Baergen
Details | Diff

Description Joshua Baergen 2015-11-05 18:44:35 UTC
proc_coredump_filter_write() goes as follows:

"""
ret = -ESRCH;
<find task - goto out if fails>

<set bits>
out_no_task:
          if (ret < 0)
                  return ret;
          return count;
"""

So, even if successful, the default value of -ESRCH is used. The simplest fix is probably:

--- fs/proc/base.c.orig 2015-11-05 11:41:18.094788845 -0700
+++ fs/proc/base.c      2015-11-05 11:41:51.212157299 -0700
@@ -2488,6 +2488,7 @@
        if (!mm)
                goto out_no_mm;
 
+       ret = 0;
        for (i = 0, mask = 1; i < MMF_DUMP_FILTER_BITS; i++, mask <<= 1) {
                if (val & mask)
                        set_bit(i + MMF_DUMP_FILTER_SHIFT, &mm->flags);

Sorry, I don't have a git checkout at work so I can't tell you when this regression occurred. However, based on the behaviour of my system, I suspect that it's new to 4.3 - I was running 4.2.5 previously without issue.
Comment 1 Joshua Baergen 2015-11-06 15:26:02 UTC
Looks like this was broken by 774636e19ed514cdf560006813c0473409616de8, "proc: convert to kstrto*()/kstrto*_from_user()", which went in Sep 9ish.
Comment 2 Joshua Baergen 2015-11-06 16:53:06 UTC
Created attachment 192251 [details]
Patch for fs/proc/base.c
Comment 3 Joshua Baergen 2015-11-06 16:53:30 UTC
Better patch has been attached.
Comment 4 Joshua Baergen 2015-11-06 18:04:10 UTC
Created attachment 192271 [details]
Patch for fs/proc/base.c

Fixed tabs vs. spaces.
Comment 5 Alexey Dobriyan 2015-11-06 18:38:58 UTC
You're correct, it's a regression.
Comment 6 Joshua Baergen 2015-11-06 19:09:42 UTC
Thanks for the confirmation. Is this something that you'd like to fix, or should I submit the patch? I've never done that before, so I'd have to learn how. :P
Comment 7 Joshua Baergen 2016-01-11 14:59:34 UTC
Looks like this was fixed in 4.4 by 41a0c249cb8706a2efa1ab3d59466b23a27d0c8b.

Note You need to log in before you can comment on or make changes to this bug.