Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4797801ooa; Tue, 14 Aug 2018 10:41:29 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzsfejhOb4h5lyuSudLDAPZ2iGtyndlrslua3tMcP7UsTDscis6Mos58VVSTNuVevjMXJgn X-Received: by 2002:a65:5144:: with SMTP id g4-v6mr21880950pgq.21.1534268489451; Tue, 14 Aug 2018 10:41:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534268489; cv=none; d=google.com; s=arc-20160816; b=roPAw3bNRHhT04b4hTh4f1nkRT1Cp1xd7OAMBE6lZLvRjIWFy28/ShKbo5Bh/r9Z8e dnRXPAX9EWztTw6w/wR+rmmFZYDLdmsX+3PqGtxonnj3xmDKltQLyUd/pf0bG5nTHqWa OIWphbgY9RhdZdSarAqpfNMFEnT45i5ken7494DAV9wTEAOQadyp5Kjyw2Z8mSks3bMx tNMp3UfOntxgkKqUuAEDTVD20Kh6melWxAFjnbes4BloTOLc5h64MnKRX9L+LnvjMaVu QaeeFQUkdSpyXNqVl4suRJ3i0up/qtCjf33hjcm8Sh12th0BlCZMFE5AdC8T+Xt/Y+Y8 DpnQ== 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=JJMelxQVlO5+T3Eb/2wAbmgxPiao9YYW3w4C3f8A6dM=; b=p88rusn0k/Gg0hobK/aLT1Y4mqdBaKTn4Et106mZv2aFGelYfyUU6jX/VeM5HrvmwI +epe15SwS6TALMu94IVu7Fe8mi+C8DSwSGV/lg5X56BgEwoOs5gCMguvM+mRwhcP5jXz kL9KUA4MyQ4cc0i6zd7HFFeMYJ62jvIN7X6fpmMgx02KbystokmqNd5vZ0VitCb+iMFB ASLDiQGZh+v7ZD5iVRFz+FOMFqrTeTlBDXa6vpFEWIxY0mXO+XNJtTyTyZcvDmqbREey Oa4ry8dvnnFu0stZwWOfEYSq13QOAj5Pva/lkypDJ9JTh4LonBSSXnc9j2XEbmTPwnB5 2zVA== 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 w14-v6si17335383pgv.462.2018.08.14.10.41.14; Tue, 14 Aug 2018 10:41:29 -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 S2389746AbeHNU2h (ORCPT + 99 others); Tue, 14 Aug 2018 16:28:37 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58784 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729758AbeHNU2g (ORCPT ); Tue, 14 Aug 2018 16:28:36 -0400 Received: from localhost (unknown [194.244.16.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 49112DF2; Tue, 14 Aug 2018 17:40:26 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Dae R. Jeong" , Al Viro Subject: [PATCH 4.9 012/107] make sure that __dentry_kill() always invalidates d_seq, unhashed or not Date: Tue, 14 Aug 2018 19:16:35 +0200 Message-Id: <20180814171521.521706424@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180814171520.883143803@linuxfoundation.org> References: <20180814171520.883143803@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: Al Viro commit 4c0d7cd5c8416b1ef41534d19163cb07ffaa03ab upstream. RCU pathwalk relies upon the assumption that anything that changes ->d_inode of a dentry will invalidate its ->d_seq. That's almost true - the one exception is that the final dput() of already unhashed dentry does *not* touch ->d_seq at all. Unhashing does, though, so for anything we'd found by RCU dcache lookup we are fine. Unfortunately, we can *start* with an unhashed dentry or jump into it. We could try and be careful in the (few) places where that could happen. Or we could just make the final dput() invalidate the damn thing, unhashed or not. The latter is much simpler and easier to backport, so let's do it that way. Reported-by: "Dae R. Jeong" Cc: stable@vger.kernel.org Signed-off-by: Al Viro Signed-off-by: Greg Kroah-Hartman --- fs/dcache.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) --- a/fs/dcache.c +++ b/fs/dcache.c @@ -352,14 +352,11 @@ static void dentry_unlink_inode(struct d __releases(dentry->d_inode->i_lock) { struct inode *inode = dentry->d_inode; - bool hashed = !d_unhashed(dentry); - if (hashed) - raw_write_seqcount_begin(&dentry->d_seq); + raw_write_seqcount_begin(&dentry->d_seq); __d_clear_type_and_inode(dentry); hlist_del_init(&dentry->d_u.d_alias); - if (hashed) - raw_write_seqcount_end(&dentry->d_seq); + raw_write_seqcount_end(&dentry->d_seq); spin_unlock(&dentry->d_lock); spin_unlock(&inode->i_lock); if (!inode->i_nlink)