Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752064AbdFHWw6 (ORCPT ); Thu, 8 Jun 2017 18:52:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39494 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751475AbdFHWwy (ORCPT ); Thu, 8 Jun 2017 18:52:54 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4469923E6C6 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mpatocka@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4469923E6C6 Date: Thu, 8 Jun 2017 18:52:50 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: NeilBrown cc: Shaohua Li , linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra Subject: Re: [PATCH] md: don't use flush_signals in userspace processes In-Reply-To: <87h8zrart4.fsf@notabene.neil.brown.name> Message-ID: References: <87h8zrart4.fsf@notabene.neil.brown.name> User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 08 Jun 2017 22:52:54 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1218 Lines: 34 On Thu, 8 Jun 2017, NeilBrown wrote: > On Wed, Jun 07 2017, Mikulas Patocka wrote: > > > The function flush_signals clears all pending signals for the process. It > > may be used by kernel threads when we need to prepare a kernel thread for > > responding to signals. However using this function for an userspaces > > processes is incorrect - clearing signals without the program expecting it > > can cause misbehavior. > > > > The raid1 and raid5 code uses flush_signals in its request routine because > > it wants to prepare for an interruptible wait. This patch drops > > flush_signals and uses sigprocmask instead to block all signals (including > > SIGKILL) around the schedule() call. The signals are not lost, but the > > schedule() call won't respond to them. > > > > Signed-off-by: Mikulas Patocka > > Cc: stable@vger.kernel.org > > Thanks for catching that! > > Acked-by: NeilBrown > > NeilBrown BTW. why does md_thread do "allow_signal(SIGKILL)" and then "if (signal_pending(current)) flush_signals(current)"? Does userspace really send SIGKILL to MD kernel threads? The SIGKILL will be lost when flush_signals is called, so it looks quite dubious. Mikulas