First published: Mon Jun 02 2008(Updated: )
Description of problem: Alexei Dobryanov has reported the following kernel utrace related issue (<a class="bz_bug_link bz_secure " title="" href="show_bug.cgi?id=245735">BZ#245735</a>): 1. late ptrace_may_attach() check static int ptrace_attach(struct task_struct *task) { ... engine = utrace_attach(task, (UTRACE_ATTACH_CREATE | UTRACE_ATTACH_EXCLUSIVE | UTRACE_ATTACH_MATCH_OPS), &ptrace_utrace_ops, 0); [error checking] if (ptrace_may_attach(task)) { [more attaching process] Doing may attach check there is asking for trouble, because utrace_attach() will happily create and modify "struct utrace *" and create and attach engines to it on task you don't have permissions. Order should be reverted. That's easy. 2. race around &dead_engine_ops setting... I originally thought #1 would lead to memory leaks, however, written dumb PTRACE_ATTACH'er gave much more amazing results. The following program quickly (1 sec) oopses kernel when run against process you normally can't attach to (like normal user to getty processes) #include <stdlib.h> #include <sys/ptrace.h> int main(int argc, char *argv[]) { pid_t pid = atoi(argv[1]); while (1) ptrace(PTRACE_ATTACH, pid, NULL, NULL); return 0; } Unable to handle kernel NULL pointer dereference at 0000000000000000 RIP: [<0000000000000000>] [<ffffffff8005f1cd>] report_quiescent+0x36/0x154 [<ffffffff8005f316>] utrace_quiescent+0x2b/0x238 [<ffffffff800601e9>] utrace_get_signal+0x45d/0x4c0 [<ffffffff80039c6f>] get_signal_to_deliver+0x169/0x47a [<ffffffff80008f5a>] do_notify_resume+0xd0/0x7e2 [<ffffffff80203673>] _spin_unlock_irqrestore+0x3f/0x45 [<ffffffff80051d71>] trace_hardirqs_on+0x11b/0x13f [<ffffffff801400c0>] tty_read+0x81/0xc7 [<ffffffff80202ede>] trace_hardirqs_on_thunk+0x35/0x37 [<ffffffff80051d71>] trace_hardirqs_on+0x11b/0x13f [<ffffffff80009b43>] sysret_signal+0x21/0x31 [<ffffffff80009deb>] ptregscall_common+0x67/0xac This is a race we chatted with Roland about: <a href="http://marc.info/?l=linux-kernel&m=117863520707703&w=2">http://marc.info/?l=linux-kernel&m=117863520707703&w=2</a> <span class="quote">> engine's flags and ops settings in utrace_detach() and acting on them in > report_quiescent():</span> <span class="quote">> utrace_detach() report_quiescent() > --------------- ------------------ > [utrace lock held] [utrace lock is not held]</span> <span class="quote">> engine->flags = > UTRACE_EVENT(QUIESCE) | UTRACE_ACTION_QUIESCE;</span> <span class="quote">> if (engine->flags & UTRACE_EVENT(QUIESCE)) > REPORT(report_quiesce);</span> <span class="quote">> rcu_assign_pointer(engine->ops, &dead_engine_ops);</span> <span class="quote">> At the moment of REPORT call engine's ops are still "live" ptrace ops > which do not have ->report_quiesce callback. So, there will oops while > calling function at NULL address. "Dead" ptrace engine ops do have dummy > callback but it wasn't yet glued.</span> Obviously, patch #1 won't fix this. 3. Looks like nobody filed double free at utrace aka oops at __rcu_process_callbacks() against RHEL5 kernel. It's bug <a href="https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=207002">https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=207002</a> against FC6, but, hey, every utrace version has it. Test program attached. Every user can trigger it.
Credit: secalert@redhat.com secalert@redhat.com
Affected Software | Affected Version | How to fix |
---|---|---|
Linux Linux kernel | =2.6.11-rc3 | |
Linux Linux kernel | =2.6.20.9 | |
Linux Linux kernel | =2.6.11 | |
Linux Linux kernel | =2.6.23.4 | |
Linux Linux kernel | =2.6.22.15 | |
Linux Linux kernel | =2.6.17.12 | |
Linux Linux kernel | =2.6.21 | |
Linux Linux kernel | =2.6.16.9 | |
Linux Linux kernel | =2.6.12-rc1 | |
Linux Linux kernel | =2.6.12-rc4 | |
Linux Linux kernel | =2.6.12.12 | |
Linux Linux kernel | =2.6.19-rc4 | |
Linux Linux kernel | =2.6.14-rc2 | |
Linux Linux kernel | =2.6.15.3 | |
Linux Linux kernel | =2.6.20.13 | |
Linux Linux kernel | =2.6.21-rc5 | |
Linux Linux kernel | =2.6.22.4 | |
Linux Linux kernel | =2.6.16-rc1 | |
Linux Linux kernel | =2.6.13 | |
Linux Linux kernel | =2.6.17.2 | |
Linux Linux kernel | =2.6.13.3 | |
Linux Linux kernel | =2.6.11.8 | |
Linux Linux kernel | =2.6.24.2 | |
Linux Linux kernel | =2.6.21-rc4 | |
Linux Linux kernel | =2.6.23.7 | |
Linux Linux kernel | =2.6.17.8 | |
Linux Linux kernel | =2.6.14.4 | |
Linux Linux kernel | =2.6.14 | |
Linux Linux kernel | =2.6.25.5 | |
Linux Linux kernel | =2.6.17.14 | |
Linux Linux kernel | =2.6.10 | |
Linux Linux kernel | =2.6.13-rc1 | |
Linux Linux kernel | =2.6.22.12 | |
Linux Linux kernel | =2.6.14.3 | |
Linux Linux kernel | =2.6.13-rc6 | |
Linux Linux kernel | =2.6.24-rc3 | |
Linux Linux kernel | =2.6.18.3 | |
Linux Linux kernel | =2.6.11.6 | |
Linux Linux kernel | =2.6.11.11 | |
Linux Linux kernel | =2.6.16.13 | |
Linux Linux kernel | =2.6.13-rc7 | |
Linux Linux kernel | =2.6.21.6 | |
Linux Linux kernel | =2.6.22.1 | |
Linux Linux kernel | =2.6.17.3 | |
Linux Linux kernel | =2.6.24.1 | |
Linux Linux kernel | =2.6.20.5 | |
Linux Linux kernel | =2.6.22 | |
Linux Linux kernel | =2.6.15.1 | |
Linux Linux kernel | =2.6.11.5 | |
Linux Linux kernel | =2.6.19.1 | |
Linux Linux kernel | =2.6.18.4 | |
Linux Linux kernel | =2.6.16.1 | |
Linux Linux kernel | =2.6.18.1 | |
Linux Linux kernel | =2.6.23.1 | |
Linux Linux kernel | =2.6.14.5 | |
Linux Linux kernel | =2.6.13.2 | |
Linux Linux kernel | =2.6.12-rc5 | |
Linux Linux kernel | =2.6.17.5 | |
Linux Linux kernel | =2.6.14-rc3 | |
Linux Linux kernel | =2.6.21.1 | |
Linux Linux kernel | =2.6.25.3 | |
Linux Linux kernel | =2.6.17 | |
Linux Linux kernel | =2.6.24 | |
Linux Linux kernel | =2.6.19.2 | |
Linux Linux kernel | =2.6.21.4 | |
Linux Linux kernel | =2.6.11-rc4 | |
Linux Linux kernel | =2.6.16.11 | |
Linux Linux kernel | =2.6.15-rc3 | |
Linux Linux kernel | =2.6.17.10 | |
Linux Linux kernel | =2.6.15.11 | |
Linux Linux kernel | =2.6.24_rc4 | |
Linux Linux kernel | =2.6.14.1 | |
Linux Linux kernel | =2.6.19-rc1 | |
Linux Linux kernel | =2.6.16.23 | |
Linux Linux kernel | =2.6.12.5 | |
Linux Linux kernel | =2.6.20 | |
Linux Linux kernel | =2.6.23.10 | |
Linux Linux kernel | =2.6.22.7 | |
Linux Linux kernel | =2.6.15-rc2 | |
Linux Linux kernel | =2.6.12.1 | |
Linux Linux kernel | =2.6.10-rc2 | |
Linux Linux kernel | =2.6.17.1 | |
Linux Linux kernel | =2.6.20.8 | |
Linux Linux kernel | =2.6.21-rc6 | |
Linux Linux kernel | =2.6.20.15 | |
Linux Linux kernel | =2.6.13.4 | |
Linux Linux kernel | =2.6.23.9 | |
Linux Linux kernel | =2.6.22.6 | |
Linux Linux kernel | =2.6.23.3 | |
Linux Linux kernel | =2.6.22.3 | |
Linux Linux kernel | =2.6.12.2 | |
Linux Linux kernel | =2.6.23-rc1 | |
Linux Linux kernel | =2.6.14-rc1 | |
Linux Linux kernel | =2.6.20.11 | |
Linux Linux kernel | =2.6.19 | |
Linux Linux kernel | =2.6.20.3 | |
Linux Linux kernel | =2.6.16 | |
Linux Linux kernel | =2.6.22.13 | |
Linux Linux kernel | =2.6.15.2 | |
Linux Linux kernel | =2.6.22.17 | |
Linux Linux kernel | =2.6.23.14 | |
Linux Linux kernel | =2.6.17.11 | |
Linux Linux kernel | =2.6.12.4 | |
Linux Linux kernel | =2.6.22.11 | |
Linux Linux kernel | =2.6.23 | |
Linux Linux kernel | =2.6.12.3 | |
Linux Linux kernel | =2.6.13-rc4 | |
Linux Linux kernel | =2.6.23.2 | |
Linux Linux kernel | =2.6.25.1 | |
Linux Linux kernel | =2.6.25.4 | |
Linux Linux kernel | =2.6.11-rc2 | |
Linux Linux kernel | =2.6.21.7 | |
Linux Linux kernel | =2.6.21.2 | |
Linux Linux kernel | =2.6.15.4 | |
Linux Linux kernel | =2.6.23_rc1 | |
Linux Linux kernel | =2.6.24-rc2 | |
Linux Linux kernel | =2.6.20.2 | |
Linux Linux kernel | =2.6.16.12 | |
Linux Linux kernel | =2.6.16.27 | |
Linux Linux kernel | =2.6.12.6 | |
Linux Linux kernel | =2.6.17.7 | |
Linux Linux kernel | =2.6.20.1 | |
Linux Linux kernel | =2.6.11.7 | |
Linux Linux kernel | =2.6.24.6 | |
Linux Linux kernel | =2.6.15 | |
Linux Linux kernel | =2.6.12.22 | |
Linux Linux kernel | =2.6.24_rc5 | |
Linux Linux kernel | =2.6.15-rc1 | |
Redhat Enterprise Linux Desktop | =4.0 | |
Linux Linux kernel | =2.6.23.5 | |
Linux Linux kernel | =2.6.22.8 | |
Linux Linux kernel | =2.6.14.2 | |
Linux Linux kernel | =2.6.14-rc4 | |
Linux Linux kernel | =2.6.18 | |
Linux Linux kernel | =2.6.19-rc2 | |
Linux Linux kernel | =2.6.20.4 | |
Linux Linux kernel | =2.6.17.6 | |
Linux Linux kernel | =2.6.23.6 | |
Linux Linux kernel | =2.6.16.7 | |
Linux Linux kernel | =2.6.17.13 | |
Redhat Enterprise Linux | =4.0 | |
Linux Linux kernel | =2.6.19-rc3 | |
Linux Linux kernel | =2.6.25 | |
Redhat Enterprise Linux | =4.0 | |
Linux Linux kernel | =2.6.25.2 | |
Linux Linux kernel | =2.6.22.5 | |
Linux Linux kernel | =2.6.21-rc3 | |
Linux Linux kernel | =2.6.11.4 | |
Linux Linux kernel | =2.6.16.19 | |
Linux Linux kernel | =2.6.11.12 | |
Redhat Enterprise Linux | =4.0 | |
Linux Linux kernel | =2.6.22.16 | |
Linux Linux kernel | =2.6.9 | |
Linux Linux kernel | =2.6.13.1 | |
Linux Linux kernel | =2.6.17-rc5 | |
Linux Linux kernel | =2.6.22.14 | |
Linux Linux kernel | =2.6.12 |
Sign up to SecAlerts for real-time vulnerability data matched to your software, aggregated from hundreds of sources.