| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0013265 | CentOS-7 | kernel | public | 2017-05-17 05:16 | 2017-06-13 04:47 | ||||||||
| Reporter | hallyn | ||||||||||||
| Priority | normal | Severity | major | Reproducibility | always | ||||||||
| Status | assigned | Resolution | open | ||||||||||
| Platform | All | OS | OS Version | ||||||||||
| Product Version | |||||||||||||
| Target Version | Fixed in Version | ||||||||||||
| Summary | 0013265: PTRACE_GETEVENTMSG broken for pids in pidnamespaces | ||||||||||||
| Description | If you fork a child, which unshares CLONE_NEWPID, ptrace-attach to it, set PTRACE_O_TRACEFORK, then have the child fork, the ptrace eventmsg you receive will be the pid in the child's namespace, not yours. This is fixed by commit 4e52365f279564cef0ddd41db5237f0471381093 from 2014 which applies cleanly to the 3.10 kernel. It was suggested on irc that i might ask for toracat to cherrypick the patch into the centosplus kernel, | ||||||||||||
| Steps To Reproduce | I can provide a test program, but the above desribes how to do it. | ||||||||||||
| Tags | No tags attached. | ||||||||||||
| abrt_hash | |||||||||||||
| URL | |||||||||||||
| Attached Files |
| ||||||||||||
Notes |
|
|
toracat (manager) 2017-05-17 21:07 |
I will try applying the patch in the next plus kernel update. |
|
toracat (manager) 2017-05-30 16:55 |
Turns out, unfortunately, applying the patch causes a kABI breakage. So we cannot fulfill the request. |
|
hallyn (reporter) 2017-05-30 17:03 |
Sorry, can you elaborate? No function definition is changed, so I wouldn't think this would qualify as a kABI break. I'm probably overlooking something, but just want to make sure... |
|
toracat (manager) 2017-05-30 17:57 |
I have uploaded a file that shows the actual error. Perhaps you can figure out what's happening. |
|
hallyn (reporter) 2017-06-04 18:36 |
Hi, Sadly I have no idea what is happening. However if I replace the patch with one which only adds the #include <linux/pid_namespace.h> to include/linux/ptrace.h, I get the exact same abi breakage. Does that ring any bells? I can't fathom why including pid_namespace.h should change the signatures of those functions. (If I take an ubuntu kernel and *revert* that patch, the ubuntu kabi check does not trigger.) |
|
kabe (reporter) 2017-06-09 08:10 |
I tried to see what changes when just adding #include <linux/pid_namespace.h> in include/linux/ptrace.h does to kABI. Patch scripts/Makefile.build to invoke "genksyms -d -D" : ====== diff -up ./scripts/Makefile.build.dist ./scripts/Makefile.build --- ./scripts/Makefile.build.dist 2017-04-22 15:17:16.000000000 +0900 +++ ./scripts/Makefile.build 2017-06-09 16:13:28.625041035 +0900 @@ -211,7 +211,7 @@ $(obj)/%.i: $(src)/%.c FORCE cmd_gensymtypes = \ $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ - $(GENKSYMS) $(if $(1), -T $(2)) \ + $(GENKSYMS) -d -D $(if $(1), -T $(2)) \ $(patsubst y,-s _,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX)) \ $(if $(KBUILD_PRESERVE),-p) \ -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) ====== then the build will spit out Export definitions like >> Defn for type0 unregister_netdevice_queue == <void unregister_netdevice_queue ( s#net_device * , s#list_head * ) > >> Export unregister_netdevice_queue == <void unregister_netdevice_queue ( struct net_device { char name [ 16 ] ; >> ... Is it correct that genksyms do a CRC on this output to calculate kABI signature? Assuming yes, for instance, unregister_netdevice_queue() definition changes like ===== < struct pid_namespace { UNKNOWN } * ns ; --- > struct pid_namespace { struct kref kref ; > struct pidmap { atomic_t nr_free ; ... > } * ns ; ===== that is, the added #include makes opaque struct now visible. Actual ABI didn't change, but kABI signature will be considered different. |
|
kabe (reporter) 2017-06-12 03:10 |
I made up a preliminary patch to apply the upstream commit without breaking the kABI: https://bugs.centos.org/file_download.php?file_id=20761&type=bug This patch declares "extern struct pid_namespace *task_active_pid_ns()" outside <linux/pid_namespace.h>. It's very unlikely that this function's API would change, but nontheless this is a dangerous game. @hallyn, can you provide a test program? It's not trivial for me to test it out. |
|
hallyn (reporter) 2017-06-12 17:25 |
A testcase is attached. |
|
kabe (reporter) 2017-06-13 04:47 |
Thanks for the test program. I confirmed that with stock kernel-3.10.0-514.21.1, the test fails, and kernel with patch-13265-PTRACE_GETEVENTMSG.patch https://bugs.centos.org/file_download.php?file_id=20761&type=bug fixes the problem: >> # ./a.out >> 2 9078 >> PASS - returned event included pid in correct namespace It's very unlikely that declaration of "task_active_pid_ns()" will ever change in RHEL 7's lifetime, so I consider the patch relatively safe to apply. @toracat, what would you say? In unlikely event that upstream diverged the declaration, compile will correctly detect conflict and compile will fail early as below. Falls on safe side. >> from init/main.c:18: >> include/linux/pid_namespace.h:96:30: error: conflicting types for 'task_active_pid_ns'include/linux/pid_namespace.h:96:30: error: conflicting types for 'task_active_pid_ns' (you have to semantic-patch (spatch) if the API changes; unlikely in RHEL) |
Issue History |
|||
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2017-05-17 05:16 | hallyn | New Issue | |
| 2017-05-17 21:02 | toracat | Status | new => assigned |
| 2017-05-17 21:07 | toracat | Note Added: 0029292 | |
| 2017-05-30 16:55 | toracat | Note Added: 0029354 | |
| 2017-05-30 17:03 | hallyn | Note Added: 0029356 | |
| 2017-05-30 17:56 | toracat | File Added: kabibreakageerror.txt | |
| 2017-05-30 17:57 | toracat | File Added: kabibreakageerror-2.txt | |
| 2017-05-30 17:57 | toracat | Note Added: 0029357 | |
| 2017-05-30 18:00 | toracat | File Deleted: kabibreakageerror-2.txt | |
| 2017-06-04 18:36 | hallyn | Note Added: 0029397 | |
| 2017-06-09 08:10 | kabe | Note Added: 0029422 | |
| 2017-06-12 03:03 | kabe | File Added: patch-13265-PTRACE_GETEVENTMSG.patch | |
| 2017-06-12 03:10 | kabe | Note Added: 0029441 | |
| 2017-06-12 17:25 | hallyn | File Added: test_event_pidns.c | |
| 2017-06-12 17:25 | hallyn | Note Added: 0029452 | |
| 2017-06-13 04:47 | kabe | Note Added: 0029454 | |


