Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4678227imm; Fri, 18 May 2018 08:55:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp3Wd1F9BxO9IH+Kj9Wu81IlZO09ipIr4w3wcVlWL2fBWl+4Azas8Qj/uD51tL/Xlh98Gim X-Received: by 2002:a62:8ac1:: with SMTP id o62-v6mr10016393pfk.141.1526658906718; Fri, 18 May 2018 08:55:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526658906; cv=none; d=google.com; s=arc-20160816; b=uV+MLppjyYEBfJCrWupVLx/39DCg+wYjT0jkeB1RW0Za9Ck7E+rxOAwGDrF+b4nnV2 M/XAvZU282y3WV/gLVw6lB9TzRbrt02AbioQkgTLGuhmknsaJQuTYYEIEIhu0mErbWe9 1PAGb1wPG8ghh2GsU82bhxhpuPI1SmGsuWZNn5y4xPqHIv7zGP0u0TdiHO2BAXE+DzdE vJ0TNa8uzpHSiKr+5ulN6kqDVl9Ujt0YS5rAS2hGoPU8po3pdSTQ2eroVWuMqwe8DHwY ub/Ql/VECa+4oHdVjl1hkYQ/M50BnKZoG+mWcbqPlXEtHhPLKngQ8gJY9ZxzS4UqqRlD XZCw== 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=eOSKsmDPQKXfUXlxIojIikR8fbkLe34IkqG2g+0zKK8uqSAiFnCizTyTcS8YekXTKP f8ltNtzbXQ5n6jLEAEb0OA8bzUoMI4kSETzSH4a8mgem8JtRaoQSz3Sfe7RBjrSCdFUq 0muePrHRYe1SOq8KhmPOwBULd4kuT9xGHzWKYKM7wgUtmaRX5bbFEbkjBFA1Pg7355Fy LdW872rb1TqseTSRslynn5yazdT1UHhrYa8tpdDSPxJdXh7taPV2ZYp+Uvb5PS3hycsX qjUt7/808pE+ejFn/LS66OULziqA4Px0hwuKzqC2nVol4I1RkG1ygBcaWHWRNKp1BKPL Qw/w== 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 l61-v6si7199638plb.507.2018.05.18.08.54.51; Fri, 18 May 2018 08:55:06 -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 S1752189AbeERPyR (ORCPT + 99 others); Fri, 18 May 2018 11:54:17 -0400 Received: from mgwym02.jp.fujitsu.com ([211.128.242.41]:54935 "EHLO mgwym02.jp.fujitsu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751112AbeERPyQ (ORCPT ); Fri, 18 May 2018 11:54:16 -0400 Received: from yt-mxoi2.gw.nic.fujitsu.com (unknown [192.168.229.69]) by mgwym02.jp.fujitsu.com with smtp id 6237_3c3d_c581f880_f4d0_4e39_a632_0cc2ce14cf11; Sat, 19 May 2018 00:43:01 +0900 Received: from g01jpfmpwyt01.exch.g01.fujitsu.local (g01jpfmpwyt01.exch.g01.fujitsu.local [10.128.193.38]) by yt-mxoi2.gw.nic.fujitsu.com (Postfix) with ESMTP id 5338BAC02E4 for ; Sat, 19 May 2018 00:43:00 +0900 (JST) Received: from G01JPEXCHYT16.g01.fujitsu.local (G01JPEXCHYT16.g01.fujitsu.local [10.128.194.55]) by g01jpfmpwyt01.exch.g01.fujitsu.local (Postfix) with ESMTP id 8DC496D6640; Sat, 19 May 2018 00:42:59 +0900 (JST) Received: from G01JPEXMBYT03.g01.fujitsu.local ([10.128.194.67]) by g01jpexchyt16 ([10.128.194.55]) with mapi id 14.03.0352.000; Sat, 19 May 2018 00:43:00 +0900 From: "Hatayama, Daisuke" To: "'gregkh@linuxfoundation.org'" CC: "Okajima, Toshiyuki" , "linux-kernel@vger.kernel.org" , "'ebiederm@aristanetworks.com'" 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:42:58 +0000 Message-ID: <33710E6CAA200E4583255F4FB666C4E21B5E150F@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: 57d448c65dfa492c9c8c514099097a95 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