From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23003C04E53 for ; Wed, 15 May 2019 12:21:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E127D20578 for ; Wed, 15 May 2019 12:21:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557922914; bh=eD4lWYg1cJCwoLotLo5LHXxm7mpQch3sdcfjSmTMFE0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=YR1eo7nidFB8Y9WxOqms6pBWoyBdlhvmtAgYrKd2ofSLmY8bDBi9kjL2H639KAQyC 6EZkl2bPa112gMldYtfhp2y/IVtnqs9mEa+sGlEkxPHkq39hNEt2FIU0u1E/vigBNv 05Dz49t9XEeDOfiO4VljHhz1UNW4Z9Entj9YcmPU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726720AbfEOK6U (ORCPT ); Wed, 15 May 2019 06:58:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:54506 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726744AbfEOK6S (ORCPT ); Wed, 15 May 2019 06:58:18 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7BEF721473; Wed, 15 May 2019 10:58:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557917898; bh=eD4lWYg1cJCwoLotLo5LHXxm7mpQch3sdcfjSmTMFE0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RjFd4o4DOwF6J1JGpgtZIsyTZivR5e+OFdd12ZMMwjkigKopZs3+tDyilPQlkDLH6 w5g9SY0badNbfJFMPgoQvtE1kF45d9fswFPfKDAn/Ij06K/1O39goTnKVZaLy2I1hn suY9+ZLB+D+XtJnhZU8foRij2rBsvAx67/dIfnnc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeff Layton , "Yan, Zheng" , Ilya Dryomov Subject: [PATCH 3.18 04/86] ceph: ensure d_name stability in ceph_dentry_hash() Date: Wed, 15 May 2019 12:54:41 +0200 Message-Id: <20190515090643.214149763@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190515090642.339346723@linuxfoundation.org> References: <20190515090642.339346723@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jeff Layton commit 76a495d666e5043ffc315695f8241f5e94a98849 upstream. Take the d_lock here to ensure that d_name doesn't change. Cc: stable@vger.kernel.org Signed-off-by: Jeff Layton Reviewed-by: "Yan, Zheng" Signed-off-by: Ilya Dryomov Signed-off-by: Greg Kroah-Hartman --- fs/ceph/dir.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -1308,6 +1308,7 @@ void ceph_dentry_lru_del(struct dentry * unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn) { struct ceph_inode_info *dci = ceph_inode(dir); + unsigned hash; switch (dci->i_dir_layout.dl_dir_hash) { case 0: /* for backward compat */ @@ -1315,8 +1316,11 @@ unsigned ceph_dentry_hash(struct inode * return dn->d_name.hash; default: - return ceph_str_hash(dci->i_dir_layout.dl_dir_hash, + spin_lock(&dn->d_lock); + hash = ceph_str_hash(dci->i_dir_layout.dl_dir_hash, dn->d_name.name, dn->d_name.len); + spin_unlock(&dn->d_lock); + return hash; } }