From patchwork Thu Mar 21 20:57:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Johansen X-Patchwork-Id: 229837 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 891642C00A5 for ; Fri, 22 Mar 2013 07:57:34 +1100 (EST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1UImY7-0000wa-N0; Thu, 21 Mar 2013 20:57:23 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1UImY6-0000wV-3M for kernel-team@lists.ubuntu.com; Thu, 21 Mar 2013 20:57:22 +0000 Received: from static-50-53-34-211.bvtn.or.frontiernet.net ([50.53.34.211] helo=[192.168.192.110]) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1UImY5-00046e-QU for kernel-team@lists.ubuntu.com; Thu, 21 Mar 2013 20:57:21 +0000 Message-ID: <514B742E.3010304@canonical.com> Date: Thu, 21 Mar 2013 13:57:18 -0700 From: John Johansen Organization: Canonical User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130311 Thunderbird/17.0.4 MIME-Version: 1.0 To: Kernel team list Subject: [Lucid] [Patch 1/1] Fix ptrace when task is in task_is_stopped(), state X-Enigmail-Version: 1.4.6 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From d6a1da349c76ac2ebe4774d1da9fb7e660df01d3 Mon Sep 17 00:00:00 2001 From: John Johansen Date: Thu, 21 Mar 2013 05:04:13 -0700 Subject: [PATCH] UBUNTU: SAUCE: Fix ptrace when task is in task_is_stopped() state This patch fixes a regression in ptrace, introduced by commit 9e74eb39 (backport of 9899d11f) which makes assumptions about ptrace behavior which are not true in the 2.6.32 kernel. BugLink: http://bugs.launchpad.net/bugs/1145234 9899d11f makes the assumption that task_is_stopped() is not a valid state in ptrace because it is built on top of a series of patches which change how the TASK_STOPPED state is tracked (321fb561 which requires d79fdd6d and several other patches). Because Lucid does not have the set of patches that make task_is_stopped() an invalid state in ptrace_check_attach, partially revert 9e74eb39 so that ptrace_check_attach() correctly handles task_is_stopped(). However we must replace the assignment of TASK_TRACED with __TASK_TRACED to ensure TASK_WAKEKILL is cleared. Signed-off-by: John Johansen Acked-by: Colin Ian King --- kernel/ptrace.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/kernel/ptrace.c b/kernel/ptrace.c index d0036f0..d9c8c47 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -81,14 +81,18 @@ void __ptrace_unlink(struct task_struct *child) } /* Ensure that nothing can wake it up, even SIGKILL */ -static bool ptrace_freeze_traced(struct task_struct *task) +static bool ptrace_freeze_traced(struct task_struct *task, int kill) { - bool ret = false; + bool ret = true; spin_lock_irq(&task->sighand->siglock); - if (task_is_traced(task) && !__fatal_signal_pending(task)) { + if (task_is_stopped(task) && !__fatal_signal_pending(task)) task->state = __TASK_TRACED; - ret = true; + else if (!kill) { + if (task_is_traced(task) && !__fatal_signal_pending(task)) + task->state = __TASK_TRACED; + else + ret = false; } spin_unlock_irq(&task->sighand->siglock); @@ -131,7 +135,7 @@ int ptrace_check_attach(struct task_struct *child, int kill) * child->sighand can't be NULL, release_task() * does ptrace_unlink() before __exit_signal(). */ - if (kill || ptrace_freeze_traced(child)) + if (ptrace_freeze_traced(child, kill)) ret = 0; } read_unlock(&tasklist_lock);