Received: by 10.192.165.148 with SMTP id m20csp81164imm; Thu, 19 Apr 2018 13:24:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx48sVloOBG7OAw6uI+NPZhgXLGiVxTFdrxmOGnQRvcIBEu6HX6lmkmrEbE3/z+d3qtgTCGjD X-Received: by 2002:a17:902:9a48:: with SMTP id x8-v6mr7403862plv.135.1524169489902; Thu, 19 Apr 2018 13:24:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524169489; cv=none; d=google.com; s=arc-20160816; b=qYIAbrUWitekwqoEubaLlzX/3t9w9ahkYmENjglpAN0o7WzSgU6dtH8Ry/+e75up/Y fCV9mexuNwbDSUrlJ1LebSpnUWoIgDomIqzObbC8WLi6RltII8fax1TxEO4V6MhBmr9d QRpAxyu/zYPxw04uIVhCW3PJvaOHHmeVUlNxL2vcRFFcm2CtdBFTn9tpNo7QRz3puh48 Rd0bvOlswXSRnWj4EOQ36dNknCC6vxeeTNXAv0U6xMbzUI0KsJc7RTZOc5GXXdnhtf2P VhVOJ9pAFnoYgSxI+FyntkA8lYnUvZuBSPBq6AkjueP78aLP3Vv4DN3C5OqDptv9fDov 3eoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=VJ1AXaiMOe4jdOO1NNmy1r8Y/qQcPfBx+fIAC8LCeTc=; b=bjWK/Kk1v7mmDnxwbh4L2n2UH9dOvEIv+8d7GfPXvrJRlgRJiHOXMhOCPVPphv7c21 5YGK3sRaaOJMqihpqfFgxhjlO1jw3Bt+ayOYr1/RYtRuzv9ofOQg3HC2JtsQwAKuUYMc weX6UYR7OjcL9uSI1UaUbYXyhRw948FjUQ+xZQ4GgDAnAzWSvVTYDKAY/Y4VhfCtjqzn 72hYKp8pGardx/D0YE1t1bvrgipNX9EveQeigrhaH8dh9q4eppf1yQ8tDGRXxQVwh/jt 4m7kC6T44i+CnO1Tx0DvaGHEMmpBFtUheC8PpVeq0AHYBixreNifdS/pK17PB6IAIZET shdw== 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 l15si175126pgu.659.2018.04.19.13.24.30; Thu, 19 Apr 2018 13:24:49 -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 S1753346AbeDSUXG (ORCPT + 99 others); Thu, 19 Apr 2018 16:23:06 -0400 Received: from mx2.suse.de ([195.135.220.15]:40652 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752962AbeDSUXE (ORCPT ); Thu, 19 Apr 2018 16:23:04 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D80A5AFCE; Thu, 19 Apr 2018 20:23:02 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 977991E0AEA; Thu, 19 Apr 2018 22:23:02 +0200 (CEST) Date: Thu, 19 Apr 2018 22:23:02 +0200 From: Jan Kara To: Pavlos Parissis Cc: Jan Kara , Guillaume Morin , stable@vger.kernel.org, decui@microsoft.com, jack@suse.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, mszeredi@redhat.com, Robert Kolchmeyer Subject: Re: kernel panics with 4.14.X versions Message-ID: <20180419202302.vj2eu43hy77g5mv7@quack2.suse.cz> References: <20180416132550.d25jtdntdvpy55l3@bender.morinfr.org> <20180416144041.t2mt7ugzwqr56ka3@quack2.suse.cz> <9b11cfba-4bdc-8a3e-cd33-2f7e8d513bdf@gmail.com> <20180417121207.cs7eijrndovbplgz@quack2.suse.cz> <9cb08428-66ed-2306-d2f2-ae734863c68d@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="hhioe36qsbsvo2cy" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9cb08428-66ed-2306-d2f2-ae734863c68d@gmail.com> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --hhioe36qsbsvo2cy Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Wed 18-04-18 10:32:21, Pavlos Parissis wrote: > On 17/04/2018 02:12 μμ, Jan Kara wrote: > > On Tue 17-04-18 01:31:24, Pavlos Parissis wrote: > >> On 16/04/2018 04:40 μμ, Jan Kara wrote: > > > > > > > >>> How easily can you hit this? > >> > >> Very easily, I only need to wait 1-2 days for a crash to occur. > > > > I wouldn't call that very easily but opinions may differ :). Anyway it's > > good (at least for debugging) that it's reproducible. > > > > Unfortunately, I can't reproduce it, so waiting 1-2 days is the only > option I have. Good news guys, Robert has just spotted a bug which looks like what I'd expect can cause your lockups / crashes. I've merged his patch to my tree and will push it to Linus for -rc3 so eventually it should land in appropriate stable trees as well. If you are too eager to test it out, it is attached for you to try. Honza -- Jan Kara SUSE Labs, CR --hhioe36qsbsvo2cy Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="0001-fsnotify-Fix-fsnotify_mark_connector-race.patch" From d90a10e2444ba5a351fa695917258ff4c5709fa5 Mon Sep 17 00:00:00 2001 From: Robert Kolchmeyer Date: Thu, 19 Apr 2018 10:44:33 -0700 Subject: [PATCH] fsnotify: Fix fsnotify_mark_connector race fsnotify() acquires a reference to a fsnotify_mark_connector through the SRCU-protected pointer to_tell->i_fsnotify_marks. However, it appears that no precautions are taken in fsnotify_put_mark() to ensure that fsnotify() drops its reference to this fsnotify_mark_connector before assigning a value to its 'destroy_next' field. This can result in fsnotify_put_mark() assigning a value to a connector's 'destroy_next' field right before fsnotify() tries to traverse the linked list referenced by the connector's 'list' field. Since these two fields are members of the same union, this behavior results in a kernel panic. This issue is resolved by moving the connector's 'destroy_next' field into the object pointer union. This should work since the object pointer access is protected by both a spinlock and the value of the 'flags' field, and the 'flags' field is cleared while holding the spinlock in fsnotify_put_mark() before 'destroy_next' is updated. It shouldn't be possible for another thread to accidentally read from the object pointer after the 'destroy_next' field is updated. The offending behavior here is extremely unlikely; since fsnotify_put_mark() removes references to a connector (specifically, it ensures that the connector is unreachable from the inode it was formerly attached to) before updating its 'destroy_next' field, a sizeable chunk of code in fsnotify_put_mark() has to execute in the short window between when fsnotify() acquires the connector reference and saves the value of its 'list' field. On the HEAD kernel, I've only been able to reproduce this by inserting a udelay(1) in fsnotify(). However, I've been able to reproduce this issue without inserting a udelay(1) anywhere on older unmodified release kernels, so I believe it's worth fixing at HEAD. References: https://bugzilla.kernel.org/show_bug.cgi?id=199437 Fixes: 08991e83b7286635167bab40927665a90fb00d81 CC: stable@vger.kernel.org Signed-off-by: Robert Kolchmeyer Signed-off-by: Jan Kara --- include/linux/fsnotify_backend.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index 9f1edb92c97e..a3d13d874fd1 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h @@ -217,12 +217,10 @@ struct fsnotify_mark_connector { union { /* Object pointer [lock] */ struct inode *inode; struct vfsmount *mnt; - }; - union { - struct hlist_head list; /* Used listing heads to free after srcu period expires */ struct fsnotify_mark_connector *destroy_next; }; + struct hlist_head list; }; /* -- 2.13.6 --hhioe36qsbsvo2cy--