From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932367AbcHKPNF (ORCPT ); Thu, 11 Aug 2016 11:13:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48788 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752224AbcHKPNC (ORCPT ); Thu, 11 Aug 2016 11:13:02 -0400 Date: Thu, 11 Aug 2016 17:12:51 +0200 From: Oleg Nesterov To: Kees Cook Cc: linux-kernel@vger.kernel.org, Kyle Huey , "Robert O'Callahan" , Andy Lutomirski , Will Drewry Subject: Re: [PATCH] seccomp: Fix tracer exit notifications during fatal signals Message-ID: <20160811151250.GA21519@redhat.com> References: <20160810233725.GA23704@www.outflux.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160810233725.GA23704@www.outflux.net> 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.25]); Thu, 11 Aug 2016 15:13:01 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/10, Kees Cook wrote: > > This fixes a ptrace vs fatal pending signals bug as manifested in seccomp > now that ptrace was reordered to happen after ptrace. The short version is > that seccomp should not attempt to call do_exit() while fatal signals are > pending under a tracer. This was needlessly paranoid. Instead, the syscall > can just be skipped and normal signal handling, tracer notification, and > process death can happen. ACK. I think this change is fine in any case, but... > The bug happens because when __seccomp_filter() detects > fatal_signal_pending(), it calls do_exit() without dequeuing the fatal > signal. When do_exit() sends the PTRACE_EVENT_EXIT I _never_ understood what PTRACE_EVENT_EXIT should actually do. I mean, when it should actually stop. This was never defined. > notification and > that task is descheduled, __schedule() notices that there is a fatal > signal pending and changes its state from TASK_TRACED to TASK_RUNNING. And this can happen anyway, with or without this change, with or without seccomp. Because another fatal signal can be pending. So PTRACE_EVENT_EXIT actually depends on /dev/random. Perhaps we should finally define what it should do. Say, it should only stop if SIGKILL was sent "implicitely" by exit/exec. But as for exec, there are more (off-topic) complications, not sure we actually want this... Nevermind, the main problem is that _any_ change in this area can break something. This code is sooooooo old. But let me repeat, I think this change is fine anyway. Acked-by: Oleg Nesterov