From patchwork Fri May 1 20:11:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Weinberger X-Patchwork-Id: 6312961 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 23F17BEEE1 for ; Fri, 1 May 2015 20:12:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 493A7203F1 for ; Fri, 1 May 2015 20:12:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6DFAA203EB for ; Fri, 1 May 2015 20:12:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751388AbbEAULn (ORCPT ); Fri, 1 May 2015 16:11:43 -0400 Received: from mail-vn0-f48.google.com ([209.85.216.48]:42572 "EHLO mail-vn0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750737AbbEAULl (ORCPT ); Fri, 1 May 2015 16:11:41 -0400 Received: by vnbf129 with SMTP id f129so10896950vnb.9; Fri, 01 May 2015 13:11:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=acy+yNyfEDQVSngd06fRWSJk2nWPgDbMpkakdzKq910=; b=W/EYQPAnLKFsQefZpEnJeP4EKunQ6XOEBcCSjIAsy2AqfHvcGK+wH1p2RvrVHzQZW2 Y16GciY4p/Y1BSMPjp/JABpLQy7UEvtFR99G0SjJJIgMjXyaQkHv3WzxvggR87scBBoa B+z6h1xgfsOqmjq4F01MUTCMxuylX0NaT0R8DMmoPuf5xWALbtpP5zyLXSScIk9LrWH4 DQX5cCx1PkaXATjSV7lRMB4HdbFogFG2JgsF0FOBCSFG6KvoQQ1RfcoG3Gx4A76LLg5T UB6YrXzZ8/4UpMrtHQ5evGsOYOoXKuRSSO7muyvnN+TQT37IYjqljYDVH8X20SmOl7Qm 041w== MIME-Version: 1.0 X-Received: by 10.52.180.102 with SMTP id dn6mr14545086vdc.17.1430511100470; Fri, 01 May 2015 13:11:40 -0700 (PDT) Received: by 10.52.145.10 with HTTP; Fri, 1 May 2015 13:11:40 -0700 (PDT) In-Reply-To: References: <1430502057.4472.255.camel@redhat.com> Date: Fri, 1 May 2015 22:11:40 +0200 Message-ID: Subject: Re: [GIT PULL] VFIO fixes for v4.1-rc2 From: Richard Weinberger To: Linus Torvalds Cc: Alex Williamson , Oleg Nesterov , linux-kernel , kvm Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Fri, May 1, 2015 at 8:37 PM, Linus Torvalds wrote: > "flush_signals()" is only for kernel threads, where it's a hacky > alternative to actually handling them (since kernel threads never > rreturn to user space and cannot really "handle" a signal). But you're > doing it in the ->remove handler for the device, which can be called > by arbitrary system processes. This is not a kernel thread thing, as > far as I can see. > > If you cannot handle signals, you damn well shouldn't be using > "wait_event_interruptible_timeout()" to begin with. Get rid of the > "interruptible", since it apparently *isn't* interruptible. > > So I'm not pulling this. > > Now I'm worried that other drivers do insane things like this. I > wonder if we should add some sanity test to flush_signals() to make > sure that it can only ever get called from a kernel thread. Hmm, a quick grep exposes some questionable users. At least w1 looks fishy. drivers/w1/w1_family.c:w1_unregister_family drivers/w1/w1_int.c:__w1_remove_master_device What do you think about a WARN_ON like: diff --git a/kernel/signal.c b/kernel/signal.c index d51c5dd..b4079c3 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -427,6 +427,8 @@ void flush_signals(struct task_struct *t) { unsigned long flags; + WARN_ON((current->flags & PF_KTHREAD) == 0); + spin_lock_irqsave(&t->sighand->siglock, flags); __flush_signals(t); spin_unlock_irqrestore(&t->sighand->siglock, flags);