From patchwork Tue Apr 26 02:53:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 8934451 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5C80F9F441 for ; Tue, 26 Apr 2016 02:53:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 72CB320166 for ; Tue, 26 Apr 2016 02:53:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 89D0820155 for ; Tue, 26 Apr 2016 02:53:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751964AbcDZCxK (ORCPT ); Mon, 25 Apr 2016 22:53:10 -0400 Received: from mail.kernel.org ([198.145.29.136]:57799 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751073AbcDZCxJ (ORCPT ); Mon, 25 Apr 2016 22:53:09 -0400 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CDC062015A; Tue, 26 Apr 2016 02:53:07 +0000 (UTC) Received: from localhost (107-1-141-74-ip-static.hfc.comcastbusiness.net [107.1.141.74]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D42AA20155; Tue, 26 Apr 2016 02:53:06 +0000 (UTC) Date: Mon, 25 Apr 2016 19:53:06 -0700 From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: He YunLei Subject: Re: [PATCH v2 7/7] f2fs: should check the remaining dentry bits Message-ID: <20160426025306.GA18242@jaegeuk.gateway> References: <1461629220-16280-1-git-send-email-jaegeuk@kernel.org> <1461629220-16280-7-git-send-email-jaegeuk@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1461629220-16280-7-git-send-email-jaegeuk@kernel.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Change log from v1: o remove wron f2fs_bug_on() From 545c0c9055b0d8dc5d134d9340b3cd80eeecdafa Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Mon, 25 Apr 2016 14:24:44 -0700 Subject: [PATCH] f2fs: should check the remaining dentry bits Let's consider a race condition between f2fs_add_regular_entry and find_target_dentry. 1. - f2fs_add_regular_entry updated len: 24 first. | Bits: 0 0 0 1 Lens: 24 0 0 3 (name: foo) |-> - find_target_dentry checks the first bit to find "foo", then ++pointer. 2. - f2fs_add_regular_entry updates bits. |>|>| Bits: 1 1 1 1 Lens: 24 0 0 3 (name: foo) | - find_target_dentry is checking second bit, but it's len is zero, which makes the process being terminated. In this case, user can add additional dentry named "foo" accordingly. This patch enables to check the remaining bits. Signed-off-by: He YunLei Signed-off-by: Jaegeuk Kim --- fs/f2fs/dir.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index e90380d..0ad7b9a 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -100,12 +100,6 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, *res_page = dentry_page; else kunmap(dentry_page); - - /* - * For the most part, it should be a bug when name_len is zero. - * We stop here for figuring out where the bugs has occurred. - */ - f2fs_bug_on(F2FS_P_SB(dentry_page), d.max < 0); return de; } @@ -149,9 +143,9 @@ struct f2fs_dir_entry *find_target_dentry(struct fscrypt_name *fname, /* remain bug on condition */ if (unlikely(!de->name_len)) - d->max = -1; - - bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len)); + bit_pos++; + else + bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len)); } de = NULL;