From patchwork Tue May 7 17:52:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Cross X-Patchwork-Id: 242429 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 462882C0171 for ; Wed, 8 May 2013 03:52:55 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759595Ab3EGRwY (ORCPT ); Tue, 7 May 2013 13:52:24 -0400 Received: from mail-yh0-f74.google.com ([209.85.213.74]:46100 "EHLO mail-yh0-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759573Ab3EGRwV (ORCPT ); Tue, 7 May 2013 13:52:21 -0400 Received: by mail-yh0-f74.google.com with SMTP id t59so86492yho.5 for ; Tue, 07 May 2013 10:52:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=xuHLTRU97r9CajkJbcwCRkitx7kHHGhZ4m8Ypz/NZoE=; b=m6D78PJmjhuNACRkMmNMDWnEL/i8EOTsdiLGGhCqqH7TSqLhOu2O7rt1qjF6fbFOgB Mk65dBb9mUk5gXUHVEBwmyVxf/u0n8lKDhiI0LOp8KJAInX3tiY8YbBQ/vYXtO0qNiLW bzS05pzIBhU2VZbKlUiPPGB6LRpQeI2TO027yWjP85TScrKf5t2FryjEhCsfXvbm705e ZiARRAn8371vpt98em3sZ6wCVjkAG26Az8fAktZ4qgh42xoSCzUld87PnZ/W2xY2nlKZ x1+xUjA9zzQc3NaKZllefnfAu3sxP50m7Y9Xy54+U8diR5F5eYowY7EpRuzJ9gltFO7P ev+w== X-Received: by 10.236.203.134 with SMTP id f6mr1865624yho.46.1367949140897; Tue, 07 May 2013 10:52:20 -0700 (PDT) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id o42si3052115yhe.5.2013.05.07.10.52.20 for (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Tue, 07 May 2013 10:52:20 -0700 (PDT) Received: from walnut.mtv.corp.google.com (walnut.mtv.corp.google.com [172.18.105.48]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id B1DD15A4111; Tue, 7 May 2013 10:52:20 -0700 (PDT) Received: by walnut.mtv.corp.google.com (Postfix, from userid 99897) id 522E3160DAD; Tue, 7 May 2013 10:52:20 -0700 (PDT) From: Colin Cross To: linux-kernel@vger.kernel.org Cc: Pavel Machek , "Rafael J. Wysocki" , Peter Zijlstra , Ingo Molnar , Andrew Morton , Mandeep Singh Baines , Colin Cross , Oleg Nesterov , linux-nfs@vger.kernel.org, linux-pm@vger.kernel.org, netdev@vger.kernel.org, Linus Torvalds , Tejun Heo , Steve French , Len Brown , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org Subject: Re: [PATCH v4 02/16] freezer: add unsafe versions of freezable helpers for CIFS Date: Tue, 7 May 2013 10:52:05 -0700 Message-Id: <1367949125-21809-1-git-send-email-ccross@android.com> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: References: X-Gm-Message-State: ALoCoQm0MQkcUAzGh/luwkkUvBzQGC+r7IZskYdBVBrZEtbf2nU6yejWkQ/CA6FMpw3zHSX4cR7Nl/kH/ahwr4Aet00kQmtwz70NREIIWwtoVE0l2nzJTy7uH0meoz9x2ZGHb514AsIZHo/K/bKO0Q74Fb/jsWdiO5sMwt6lRTEmV4HyO7oNvjMZ8n2v/paRz9jMUp0sX44u Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org CIFS calls wait_event_freezekillable_unsafe with a VFS lock held, which is unsafe and will cause lockdep warnings when 6aa9707 "lockdep: check that no locks held at freeze time" is reapplied (it was reverted in dbf520a). CIFS shouldn't be doing this, but it has long-running syscalls that must hold a lock but also shouldn't block suspend. Until CIFS freeze handling is rewritten to use a signal to exit out of the critical section, add a new wait_event_freezekillable_unsafe helper that will not run the lockdep test when 6aa9707 is reapplied, and call it from CIFS. In practice the likley result of holding the lock while freezing is that a second task blocked on the lock will never freeze, aborting suspend, but it is possible to manufacture a case using the cgroup freezer, the lock, and the suspend freezer to create a deadlock. Silencing the lockdep warning here will allow problems to be found in other drivers that may have a more serious deadlock risk, and prevent new problems from being added. Acked-by: Pavel Machek Signed-off-by: Colin Cross Reviewed-by: Jeff Layton --- v4: Corrected to include CIFS wait_for_response hunk. The rest of this series is still at v3. fs/cifs/transport.c | 2 +- include/linux/freezer.h | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 1a52868..e7f22f8 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c @@ -452,7 +452,7 @@ wait_for_response(struct TCP_Server_Info *server, struct mid_q_entry *midQ) { int error; - error = wait_event_freezekillable(server->response_q, + error = wait_event_freezekillable_unsafe(server->response_q, midQ->mid_state != MID_REQUEST_SUBMITTED); if (error < 0) return -ERESTARTSYS; diff --git a/include/linux/freezer.h b/include/linux/freezer.h index 5b31e21c..d3c038e 100644 --- a/include/linux/freezer.h +++ b/include/linux/freezer.h @@ -212,6 +212,16 @@ static inline bool freezer_should_skip(struct task_struct *p) __retval; \ }) +/* DO NOT ADD ANY NEW CALLERS OF THIS FUNCTION */ +#define wait_event_freezekillable_unsafe(wq, condition) \ +({ \ + int __retval; \ + freezer_do_not_count(); \ + __retval = wait_event_killable(wq, (condition)); \ + freezer_count_unsafe(); \ + __retval; \ +}) + #define wait_event_freezable(wq, condition) \ ({ \ int __retval; \ @@ -277,6 +287,9 @@ static inline void set_freezable(void) {} #define wait_event_freezekillable(wq, condition) \ wait_event_killable(wq, condition) +#define wait_event_freezekillable_unsafe(wq, condition) \ + wait_event_killable(wq, condition) + #endif /* !CONFIG_FREEZER */ #endif /* FREEZER_H_INCLUDED */