Received: by 10.192.165.156 with SMTP id m28csp1147207imm; Wed, 11 Apr 2018 13:19:18 -0700 (PDT) X-Google-Smtp-Source: AIpwx49XmHCxpS/wPmuIy/ck8tzWVGXXv15UjayC7JXjNxSaGibuJ6OTvm9DhGlELyYdFTEGtpSd X-Received: by 2002:a17:902:8d82:: with SMTP id v2-v6mr6645956plo.101.1523477958109; Wed, 11 Apr 2018 13:19:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523477958; cv=none; d=google.com; s=arc-20160816; b=jDUrffXOPy/4b00DCqgwBOPO3lExdoSWol6xBuLIY7nGPSSU4hcx+D7Mcsk5iwbfZq FYJQ/t1JYRKxL1egr2C62VlUtRAfhuiJVb/ZwTfwknORTwQXeqmQyYCq1t9aNejDFXfe JQSlQN6t6uF8gsQLal9zGzhWJFuNaluQjF30H7mfWmSY+GM8vastxzHkhiAKInkz6ExK nRtAkeqa0v6iubdUci04Qv4l57VDLBfH/5/9EBAutfjK1Wzvhsmm8nQzFqniHOMlyCeA S2Bn+Q4lZhF1dQOm6esK+NV1iAUdT7R6e6o21aaUUJsmpPs6Q8WNjTEXUpyU5QTpprzD baqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=4giLyN1ztE2Xhok6dk7y+26g9Jrr8j7m4wNtvbHZB68=; b=b6pVNR6miA5ZzcLbqRwQNcZrJydEgynPiaxho7rA2gyBz0imCRMPXPNPL5ZMII/85R lI388iKxx7fZ3uBzXll4ObRdCpTkjpddb6zoCXQV+0q7jysoUpZAGE5McgNnVs4HkMKv GWN0UoD7IDxh4/jQrhZGEXa891hUFgy/hBz/6n7HhJcp5iGHv1boSxBQEUennurbsFet MoJuo0BHu/DAEF7t7KfUirCBRbRNmx3oIs4HZbgTEK4uipml1B0pmlQlQPUydUVaNb5n 2La+9TsX623ckYm9E56WQ64ktwweWQ51jwEZCX0hF7O1h5zYyvvWXnj9By21Qi5b75hQ JoZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t3si1183436pgs.763.2018.04.11.13.18.41; Wed, 11 Apr 2018 13:19:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933329AbeDKSxm (ORCPT + 99 others); Wed, 11 Apr 2018 14:53:42 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33900 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933299AbeDKSxi (ORCPT ); Wed, 11 Apr 2018 14:53:38 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id CC7B0E70; Wed, 11 Apr 2018 18:53:37 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rabin Vincent , Pavel Shilovsky , Steve French , Sasha Levin Subject: [PATCH 4.9 027/310] CIFS: silence lockdep splat in cifs_relock_file() Date: Wed, 11 Apr 2018 20:32:46 +0200 Message-Id: <20180411183623.461438905@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Rabin Vincent [ Upstream commit 560d388950ceda5e7c7cdef7f3d9a8ff297bbf9d ] cifs_relock_file() can perform a down_write() on the inode's lock_sem even though it was already performed in cifs_strict_readv(). Lockdep complains about this. AFAICS, there is no problem here, and lockdep just needs to be told that this nesting is OK. ============================================= [ INFO: possible recursive locking detected ] 4.11.0+ #20 Not tainted --------------------------------------------- cat/701 is trying to acquire lock: (&cifsi->lock_sem){++++.+}, at: cifs_reopen_file+0x7a7/0xc00 but task is already holding lock: (&cifsi->lock_sem){++++.+}, at: cifs_strict_readv+0x177/0x310 other info that might help us debug this: Possible unsafe locking scenario: CPU0 ---- lock(&cifsi->lock_sem); lock(&cifsi->lock_sem); *** DEADLOCK *** May be due to missing lock nesting notation 1 lock held by cat/701: #0: (&cifsi->lock_sem){++++.+}, at: cifs_strict_readv+0x177/0x310 stack backtrace: CPU: 0 PID: 701 Comm: cat Not tainted 4.11.0+ #20 Call Trace: dump_stack+0x85/0xc2 __lock_acquire+0x17dd/0x2260 ? trace_hardirqs_on_thunk+0x1a/0x1c ? preempt_schedule_irq+0x6b/0x80 lock_acquire+0xcc/0x260 ? lock_acquire+0xcc/0x260 ? cifs_reopen_file+0x7a7/0xc00 down_read+0x2d/0x70 ? cifs_reopen_file+0x7a7/0xc00 cifs_reopen_file+0x7a7/0xc00 ? printk+0x43/0x4b cifs_readpage_worker+0x327/0x8a0 cifs_readpage+0x8c/0x2a0 generic_file_read_iter+0x692/0xd00 cifs_strict_readv+0x29f/0x310 generic_file_splice_read+0x11c/0x1c0 do_splice_to+0xa5/0xc0 splice_direct_to_actor+0xfa/0x350 ? generic_pipe_buf_nosteal+0x10/0x10 do_splice_direct+0xb5/0xe0 do_sendfile+0x278/0x3a0 SyS_sendfile64+0xc4/0xe0 entry_SYSCALL_64_fastpath+0x1f/0xbe Signed-off-by: Rabin Vincent Acked-by: Pavel Shilovsky Signed-off-by: Steve French Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/cifs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -589,7 +589,7 @@ cifs_relock_file(struct cifsFileInfo *cf struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); int rc = 0; - down_read(&cinode->lock_sem); + down_read_nested(&cinode->lock_sem, SINGLE_DEPTH_NESTING); if (cinode->can_cache_brlcks) { /* can cache locks - no need to relock */ up_read(&cinode->lock_sem);