Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1062369imm; Tue, 5 Jun 2018 08:33:08 -0700 (PDT) X-Google-Smtp-Source: ADUXVKImcTq3m826X9TQXMcW0iQg9zqDEINSholp0f9OPxWjVB70yfzAgAuWpYdmf+5JhIhRwFOR X-Received: by 2002:a17:902:aa48:: with SMTP id c8-v6mr13230687plr.132.1528212788057; Tue, 05 Jun 2018 08:33:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528212788; cv=none; d=google.com; s=arc-20160816; b=OWwZ9Q+49er4LhJEP9CFZDucABxIWn7tilTAOr1oZ+RAS0LnN7ydFJzQTnTfVOqVNO +39HetQFNizi/Wp0k6IyzcIuhYuW/8c9G+NM26WFaaoGbaVdgyy0i8lIVORQzZeTsF61 0uGpLbtWuBdgVQ0Kui+gEXVxhBl0RpJx89DasuyrBMQc/oQMwEBUR9Aoh1hJiOu+vJ+G cLPs5Lhj5xYWdvBYM2xTiqvwYXKAgq2xyDvL2K4B7h3mWXwmlvvWCziVGVBCcbDbSYzx QybXUzjEnUsfPxlWpsnNf5uuMbbdu5x994JahABw+r0SWsuloqw+O65nd5EkovSx7rSp mkUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:mime-version:user-agent :message-id:in-reply-to:date:references:cc:to:from :arc-authentication-results; bh=eo8jcwZzO2P/7tLvfZhpnfb3TmrkZ6/VOhUryY5BxsY=; b=NS7gLC5v3ER4m/BlhEGK4nL9JnIncd55tTJb/69+TjuuXqh65k0ZoWg1huyqTcK9is xTNTzmbMDYd9mZ/mfwzJ/Pa5hABQoAfQ2BwfBxeKSUI01suRYjQ8MSOUWU34qo7s7eSc 7Dm2yUwiSvGwUeKIttMmJbWg0XUBxJXJxL4TRhK8hrHkDnFxV+jrGhC1OGXxS0q/7U7O GfZJcwiluxYqwG9oCE3wCkwpPejIfDCdvQLhPuwqbCbwUjNSbyV5bvCLQ4VbawBrsEBl 7v0CMyqekcn4A8XTbV+MsTpfQDcACCfPSGAQi/HILqO1NFJ6soScZZ7NR+Jj7bG7Oz9G vN/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 x20-v6si20427902pge.395.2018.06.05.08.32.53; Tue, 05 Jun 2018 08:33:08 -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 S1752078AbeFEPcD (ORCPT + 99 others); Tue, 5 Jun 2018 11:32:03 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:58484 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751701AbeFEPcB (ORCPT ); Tue, 5 Jun 2018 11:32:01 -0400 Received: from in02.mta.xmission.com ([166.70.13.52]) by out03.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1fQDwF-0008L4-7k; Tue, 05 Jun 2018 09:31:59 -0600 Received: from 97-119-124-205.omah.qwest.net ([97.119.124.205] helo=x220.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1fQDvz-0004Jr-Re; Tue, 05 Jun 2018 09:31:59 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: "Hatayama\, Daisuke" Cc: "'gregkh\@linuxfoundation.org'" , "'tj\@kernel.org'" , "Okajima\, Toshiyuki" , "linux-kernel\@vger.kernel.org" , "'ebiederm\@aristanetworks.com'" References: <33710E6CAA200E4583255F4FB666C4E21B63D491@G01JPEXMBYT03> <87wovhqex2.fsf@xmission.com> <87po17r9ek.fsf_-_@xmission.com> <33710E6CAA200E4583255F4FB666C4E21B65E04E@G01JPEXMBYT03> <87sh62k3vk.fsf@xmission.com> <33710E6CAA200E4583255F4FB666C4E21B66BAC8@G01JPEXMBYT03> Date: Tue, 05 Jun 2018 10:31:36 -0500 In-Reply-To: <33710E6CAA200E4583255F4FB666C4E21B66BAC8@G01JPEXMBYT03> (Daisuke Hatayama's message of "Tue, 5 Jun 2018 05:45:54 +0000") Message-ID: <87h8mhgsh3.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1fQDvz-0004Jr-Re;;;mid=<87h8mhgsh3.fsf@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=97.119.124.205;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1+0rEr2uBNUDlFg+H4X10BUkYgI4opbNxQ= X-SA-Exim-Connect-IP: 97.119.124.205 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa07.xmission.com X-Spam-Level: X-Spam-Status: No, score=0.5 required=8.0 tests=ALL_TRUSTED,BAYES_20, DCC_CHECK_NEGATIVE,TR_Symld_Words,TVD_RCVD_IP,T_TM2_M_HEADER_IN_MSG autolearn=disabled version=3.4.1 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.0 TVD_RCVD_IP Message was received from an IP address * 1.5 TR_Symld_Words too many words that have symbols inside * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * -0.0 BAYES_20 BODY: Bayes spam probability is 5 to 20% * [score: 0.1962] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;"Hatayama\, Daisuke" X-Spam-Relay-Country: X-Spam-Timing: total 15030 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 2.3 (0.0%), b_tie_ro: 1.55 (0.0%), parse: 1.18 (0.0%), extract_message_metadata: 16 (0.1%), get_uri_detail_list: 2.6 (0.0%), tests_pri_-1000: 4.6 (0.0%), tests_pri_-950: 1.70 (0.0%), tests_pri_-900: 1.40 (0.0%), tests_pri_-400: 24 (0.2%), check_bayes: 23 (0.2%), b_tokenize: 10 (0.1%), b_tok_get_all: 6 (0.0%), b_comp_prob: 3.0 (0.0%), b_tok_touch_all: 1.94 (0.0%), b_finish: 0.59 (0.0%), tests_pri_0: 199 (1.3%), check_dkim_signature: 0.44 (0.0%), check_dkim_adsp: 2.8 (0.0%), tests_pri_500: 14775 (98.3%), poll_dns_idle: 14766 (98.2%), rewrite_mail: 0.00 (0.0%) Subject: Re: [CFT][PATCH] kernfs: Correct kernfs directory seeks. X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "Hatayama, Daisuke" writes: >> >> + >> >> + /* Is the saved position usable? */ >> >> + if (saved) { >> >> + /* Proper parent and hash? */ >> >> + if ((parent != saved->parent) || (saved->hash != hash)) { >> >> + saved = NULL; >> > >> > name is uninitialized in this path. >> >> It is. name is initialized to "" see above. >> > > Or when either of the conditions is true, it has resulted in some inconsistent state, right? > So, why not terminating this session of readdir() immediately by > returning NULL just as when off is turned out to be invalid? What I have above is not the clearest, and in fact the logic could be better. The fundamental challenge is because hash collisions are possible a file offset does not hold complete position information in a directory. So the kernfs node that is to be read/displayed next is saved in the struct file. The it is tested if the saved kernfs node is usable for finding the location in the directory. Several things may have gone wrong. - Someone may have called seekdir. - The saved kernfs node may have been renamed. - The saved kernfs node may have been moved to a different directory in kernfs. - the saved kernfs node may have been deleted. If any of those are true the code needs to do the rbtree lookup. If the kernfs node has been deleted or moved to a different directory we can safely use it's name while performing the rbtree lookup. Which in the event of a hash collision will be more accurate in finding our old location, and preventing the same directory entry being returned multiple times. Which is completely different than if the directory offset is an invalid value that will never point to any directory entries. Eric