From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932807AbdBVQ5Y (ORCPT ); Wed, 22 Feb 2017 11:57:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53154 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932675AbdBVQ5P (ORCPT ); Wed, 22 Feb 2017 11:57:15 -0500 Date: Wed, 22 Feb 2017 17:55:39 +0100 From: Oleg Nesterov To: bsegall@google.com Cc: linux-kernel@vger.kernel.org, Roland McGrath Subject: Re: [PATCH] ptrace: fix PTRACE_LISTEN race corrupting task->state Message-ID: <20170222165538.GA15968@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 22 Feb 2017 16:57:15 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/21, bsegall@google.com wrote: > > In PT_SEIZED + LISTEN mode SIGSTOP/SIGCONT signals cause a wakeup > against __TASK_TRACED. If this races with the ptrace_unfreeze_traced at > the end of a PTRACE_LISTEN, this can wake the task /after/ the check > against __TASK_TRACED, but before the reset of state to TASK_TRACED. Oh, thanks... note also that PTRACE_LISTEN itself can do ptrace_signal_wake_up(true), > This causes it to instead clobber TASK_WAKING, even if it is already TASK_RUNNING it is simply wrong to set TASK_TRACED in both cases, right? Thanks. The patch looks good at first glance, but let me think a bit... perhaps we should change PTRACE_LISTEN instead, not sure. Oleg.