Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4673616imm; Fri, 18 May 2018 08:50:52 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo5dciYbKF6kxii6f3MRXWTSlpoJSli/DK9M+cEpnkyjMz1TRoInsc8r57d2q6FkHpkA62w X-Received: by 2002:a63:7e18:: with SMTP id z24-v6mr7834940pgc.276.1526658652872; Fri, 18 May 2018 08:50:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526658652; cv=none; d=google.com; s=arc-20160816; b=DQxVGNItw3tbpvI4jnbKyD9hb6wKEiZ1e5vrALD1CAQfmnhdMr7gUdyBd04laDyttj OKhv46jbfBciG4HQfts3s2WinOj0Wk8HFlaUZ6kUN08iYn9dAjnYiQWfCH1m8sNRid9g ki7yQWQCMd/CPN6xcLP8doVHajKwmIR44DsoWTHTfrK7lWHYrJis8qLK+eHCLpKJzHUU h3ZkAtcV6rMK62Zlb2nxBGKCz6V7oVMcflSkRhaHPmb+5Ud5kW9vTBMUO8Enp92SM1Wv Jiz3Rq+oFUOK6KRXsmdffXXBTRsbxRLVmKRZzKeYauNtXROWGoWGXSAKBST+RLYJ0V9i Ctiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-language :accept-language:message-id:date:thread-index:thread-topic:subject :cc:to:from:arc-authentication-results; bh=uHkB80e1d2HVn5SesLMMB1uQzpV+Ju0UWz8+ea2bzv4=; b=ALKlhuiuaSwwZ/A19TQldkrMjgC1WZgMdIXmXms+N6oBIEGtkucUj0/dzNlU4rGmOz c5AmWxUXnP1DPYfdLrMh45qJ619kbs6gxoeAxn95fbiYXY04gvWZSNxkKo7SS8FmMpBt hUsuG+HStK40c0mAeTdVSaJOVTCOVXCyp2zYVm03D9f3WZ7BQSEWvxBOWObr1BX3Ik3o vevDRQcgHNDMX3EmMEqxig5iF5WakmeXAzs2INlPUX3Fj7NmfMfqzLOlCk71+uoSq3qs +VaJjc3EWieoxBm6kJAAUQ1tS9So7E8jNn2/tdSh8DsmJ7ud1EWmdlKC6AaKLUnkbquv JXGg== 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 h5-v6si1220740pgs.201.2018.05.18.08.50.38; Fri, 18 May 2018 08:50:52 -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 S1752221AbeERPsk (ORCPT + 99 others); Fri, 18 May 2018 11:48:40 -0400 Received: from mgwym03.jp.fujitsu.com ([211.128.242.42]:56162 "EHLO mgwym03.jp.fujitsu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751395AbeERPsh (ORCPT ); Fri, 18 May 2018 11:48:37 -0400 X-Greylist: delayed 332 seconds by postgrey-1.27 at vger.kernel.org; Fri, 18 May 2018 11:48:36 EDT Received: from yt-mxoi2.gw.nic.fujitsu.com (unknown [192.168.229.69]) by mgwym03.jp.fujitsu.com with smtp id 46c4_3e63_c7322638_6107_4bca_a924_082af430049e; Sat, 19 May 2018 00:48:32 +0900 Received: from g01jpfmpwyt02.exch.g01.fujitsu.local (g01jpfmpwyt02.exch.g01.fujitsu.local [10.128.193.56]) by yt-mxoi2.gw.nic.fujitsu.com (Postfix) with ESMTP id CCCB0AC02E7 for ; Sat, 19 May 2018 00:48:32 +0900 (JST) Received: from G01JPEXCHYT14.g01.fujitsu.local (G01JPEXCHYT14.g01.fujitsu.local [10.128.194.53]) by g01jpfmpwyt02.exch.g01.fujitsu.local (Postfix) with ESMTP id 1E0DF584274; Sat, 19 May 2018 00:48:32 +0900 (JST) Received: from G01JPEXMBYT03.g01.fujitsu.local ([10.128.194.67]) by G01JPEXCHYT14 ([10.128.194.53]) with mapi id 14.03.0352.000; Sat, 19 May 2018 00:48:32 +0900 From: "Hatayama, Daisuke" To: "'gregkh@linuxfoundation.org'" CC: "Okajima, Toshiyuki" , "'ebiederm@aristanetworks.com'" , "linux-kernel@vger.kernel.org" Subject: [PATCH] kernfs: fix dentry unexpected skip Thread-Topic: [PATCH] kernfs: fix dentry unexpected skip Thread-Index: AdPuvebs2fEv/eaSRfWTwq90/56eXQ== Date: Fri, 18 May 2018 15:48:31 +0000 Message-ID: <33710E6CAA200E4583255F4FB666C4E21B5E1D83@G01JPEXMBYT03> Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-securitypolicycheck: OK by SHieldMailChecker v2.5.2 x-shieldmailcheckerpolicyversion: FJ-ISEC-20170217-enc x-shieldmailcheckermailid: 90e05ad139a64bbebc26b391736c13bd x-originating-ip: [10.124.136.24] Content-Type: text/plain; charset="iso-2022-jp" MIME-Version: 1.0 X-SecurityPolicyCheck-GC: OK by FENCE-Mail X-TM-AS-MML: disable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kernfs_dir_next_pos() overlooks the situation that the dentry corresponding to a given pos object has already been inactive. Hence, when kernfs_dir_pos() returns the dentry with a hash value larger than the original one, kernfs_dir_next_pos() returns the dentry next to the one returned by kernfs_dir_pos(). As a result, the dentry returned by kernfs_dir_pos() is skipped. To fix this issue, try to find a next node only when the returned object has a hash value equal to or smaller than the original one. Signed-off-by: HATAYAMA Daisuke Suggested-by: Toshiyuki Okajima Cc: Eric W. Biederman --- fs/kernfs/dir.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c index 89d1dc1..8a2f49c 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c @@ -1622,7 +1622,7 @@ static int kernfs_dir_fop_release(struct inode *inode, struct file *filp) struct kernfs_node *parent, ino_t ino, struct kernfs_node *pos) { pos = kernfs_dir_pos(ns, parent, ino, pos); - if (pos) { + if (pos && pos->hash <= ino) { do { struct rb_node *node = rb_next(&pos->rb); if (!node) -- 1.7.1