diff --git a/trunk/PKGBUILD b/trunk/PKGBUILD index 8a49d16..7004072 100644 --- a/trunk/PKGBUILD +++ b/trunk/PKGBUILD @@ -21,7 +21,10 @@ source=("https://www.kernel.org/pub/linux/kernel/v4.x/${_srcname}.tar.xz" # pacman hook for initramfs regeneration '90-linux.hook' # standard config files for mkinitcpio ramdisk - 'linux.preset') + 'linux.preset' + # Patch for ptrace on Linux 4.11.2 so Enlightenment works + 'linux-4.11.2-ptrace.patch' + ) sha256sums=('b67ecafd0a42b3383bf4d82f0850cbff92a7e72a215a6d02f42ddbafcf42a7d6' 'SKIP' @@ -30,7 +33,8 @@ sha256sums=('b67ecafd0a42b3383bf4d82f0850cbff92a7e72a215a6d02f42ddbafcf42a7d6' 'e4e928488d35ba2b4049bd224dee87be9eb574ed3c1882f22c8fd5d8674c9abd' '2e38528bd2f1be712f5a274b66882c41d2a9cf996b3a05b4a772c8ba7309b261' '834bd254b56ab71d73f59b3221f056c72f559553c04718e350ab2a3e2991afe0' - 'ad6344badc91ad0630caacde83f7f9b97276f80d26a20619a87952be65492c65') + 'ad6344badc91ad0630caacde83f7f9b97276f80d26a20619a87952be65492c65' + 'f76aa9ebefa25b17e0262b076ea0c524adb01da12c3c7f91f7481cb418a26aaf') validpgpkeys=( 'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman @@ -44,6 +48,9 @@ prepare() { # add upstream patch patch -p1 -i "${srcdir}/patch-${pkgver}" + # Add ptrace patch + patch -p1 -i "${srcdir}/linux-4.11.2-ptrace.patch" + # add latest fixes from stable queue, if needed # http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git diff --git a/trunk/linux-4.11.2-ptrace.patch b/trunk/linux-4.11.2-ptrace.patch new file mode 100644 index 0000000..7d9995f --- /dev/null +++ b/trunk/linux-4.11.2-ptrace.patch @@ -0,0 +1,113 @@ +From: "Eric W. Biederman" +Date: Mon, 22 May 2017 16:04:48 -0500 +Subject: [PATCH] ptrace: Properly initialize ptracer_cred on fork +Message-ID: <877f18txfz.fsf_-_@xmission.com> +Patch-mainline: Submitted, LKML +References: bsc#1040041 + +When I introduced ptracer_cred I failed to consider the weirdness of +fork where the task_struct copies the old value by default. This +winds up leaving ptracer_cred set even when a process forks and +the child process does not wind up being ptraced. + +Because ptracer_cred is not set on non-ptraced processes whose +parents were ptraced this has broken the ability of the enlightenment +window manager to start setuid children. + +Fix this by properly initializing ptracer_cred in ptrace_init_task + +This must be done with a little bit of care to preserve the current value +of ptracer_cred when ptrace carries through fork. Re-reading the +ptracer_cred from the ptracing process at this point is inconsistent +with how PT_PTRACE_CAP has been maintained all of these years. + +Fixes: 64b875f7ac8a ("ptrace: Capture the ptracer's creds not PT_PTRACE_CAP") +Signed-off-by: "Eric W. Biederman" +Signed-off-by: Takashi Iwai + +--- + include/linux/ptrace.h | 7 +++++-- + kernel/ptrace.c | 20 +++++++++++++------- + 2 files changed, 18 insertions(+), 9 deletions(-) + +--- a/include/linux/ptrace.h ++++ b/include/linux/ptrace.h +@@ -54,7 +54,8 @@ extern int ptrace_request(struct task_st + unsigned long addr, unsigned long data); + extern void ptrace_notify(int exit_code); + extern void __ptrace_link(struct task_struct *child, +- struct task_struct *new_parent); ++ struct task_struct *new_parent, ++ const struct cred *ptracer_cred); + extern void __ptrace_unlink(struct task_struct *child); + extern void exit_ptrace(struct task_struct *tracer, struct list_head *dead); + #define PTRACE_MODE_READ 0x01 +@@ -206,7 +207,7 @@ static inline void ptrace_init_task(stru + + if (unlikely(ptrace) && current->ptrace) { + child->ptrace = current->ptrace; +- __ptrace_link(child, current->parent); ++ __ptrace_link(child, current->parent, current->ptracer_cred); + + if (child->ptrace & PT_SEIZED) + task_set_jobctl_pending(child, JOBCTL_TRAP_STOP); +@@ -215,6 +216,8 @@ static inline void ptrace_init_task(stru + + set_tsk_thread_flag(child, TIF_SIGPENDING); + } ++ else ++ child->ptracer_cred = NULL; + } + + /** +--- a/kernel/ptrace.c ++++ b/kernel/ptrace.c +@@ -60,19 +60,25 @@ int ptrace_access_vm(struct task_struct + } + + ++void __ptrace_link(struct task_struct *child, struct task_struct *new_parent, ++ const struct cred *ptracer_cred) ++{ ++ BUG_ON(!list_empty(&child->ptrace_entry)); ++ list_add(&child->ptrace_entry, &new_parent->ptraced); ++ child->parent = new_parent; ++ child->ptracer_cred = get_cred(ptracer_cred); ++} ++ + /* + * ptrace a task: make the debugger its new parent and + * move it to the ptrace list. + * + * Must be called with the tasklist lock write-held. + */ +-void __ptrace_link(struct task_struct *child, struct task_struct *new_parent) ++static void ptrace_link(struct task_struct *child, struct task_struct *new_parent) + { +- BUG_ON(!list_empty(&child->ptrace_entry)); +- list_add(&child->ptrace_entry, &new_parent->ptraced); +- child->parent = new_parent; + rcu_read_lock(); +- child->ptracer_cred = get_cred(__task_cred(new_parent)); ++ __ptrace_link(child, new_parent, __task_cred(new_parent)); + rcu_read_unlock(); + } + +@@ -386,7 +392,7 @@ static int ptrace_attach(struct task_str + flags |= PT_SEIZED; + task->ptrace = flags; + +- __ptrace_link(task, current); ++ ptrace_link(task, current); + + /* SEIZE doesn't trap tracee on attach */ + if (!seize) +@@ -459,7 +465,7 @@ static int ptrace_traceme(void) + */ + if (!ret && !(current->real_parent->flags & PF_EXITING)) { + current->ptrace = PT_PTRACED; +- __ptrace_link(current, current->real_parent); ++ ptrace_link(current, current->real_parent); + } + } + write_unlock_irq(&tasklist_lock);