Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp135779pxf; Wed, 31 Mar 2021 19:15:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxc0DO1diqgu86gSJ2xQwVuqd6NSL9wYSF7GF7HkEOKu/f3nQ+Zv750Xa1kaHev4UzYg2Fn X-Received: by 2002:a05:6402:b31:: with SMTP id bo17mr7226383edb.113.1617243324144; Wed, 31 Mar 2021 19:15:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617243324; cv=none; d=google.com; s=arc-20160816; b=NSq7stJ0L7kCya8OY5ZoqEqBx8Cs9IGEBEQz7neugJ15fwYpmTgICup0YFMTJPwfHw c0S451h1CRBQWRYb1bMbPGM0BSVV4AhUcaE9KZ5vM6eP7bx8PgenB/0YmubLyOjDesz7 4tBvb6KZkRTT3tJg5nJqZXpD6DfY7hQRz29N0FIk8eD+D2io+TSygy/5iRhJrSjRczf/ fGhX/y/tv+hFjp9o05CLrwzfzJaAP4LORhl+9Knrfenz9u26hxbpbLZqjV3AVd94y6J1 +GxB2hwL/002QbtIhBc/y2EQPXj4BOIJSVzY4YFG7RxwrluMTjM1XRgc6462/8Z3ua4o 6jJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=yqDrR3sS8EPc2HZxD8hW+Wfl/MQxb5jcNZZa3sNDth8=; b=F718Nze60kkizZzuDoZq/v0vlhdZNfWsyiRrdG/DFEU7GI00fib3g+20r0Cfbj+xna md2JdjF0EfTIdPhxkP13IlT1zLdPvQGSOMfAxAJsjYpSCsjS5BBA8+OwKHXo9daJ087O CAA7nXnKlampr8b47NMp87AAbEbRW56AWKV4P0dAlQwDPEhBi0ZVSCW6Jgl5kHOVtaiU DapVTZemO3JFiEK3F2rtLA/RIz2BObNql7qyCtRZe5LA6mN28y+uRFUaewPb/hQdiG0g qVy/dK8nUkuOaBRLijjxQwmCYO2CKVcOBvIl3MpwDarr/G25DT/pWDL5m/Q4g5xSVFUl /s0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l10si3121796edc.380.2021.03.31.19.14.59; Wed, 31 Mar 2021 19:15:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233036AbhDACLp (ORCPT + 99 others); Wed, 31 Mar 2021 22:11:45 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:14658 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230284AbhDACLY (ORCPT ); Wed, 31 Mar 2021 22:11:24 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4F9mnP6ZFDzmcfG; Thu, 1 Apr 2021 10:08:41 +0800 (CST) Received: from szvp000203569.huawei.com (10.120.216.130) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.498.0; Thu, 1 Apr 2021 10:11:11 +0800 From: Chao Yu To: CC: , , , Chao Yu Subject: [PATCH] f2fs: fix to avoid accessing invalid fio in f2fs_allocate_data_block() Date: Thu, 1 Apr 2021 10:10:57 +0800 Message-ID: <20210401021057.32984-1-yuchao0@huawei.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.120.216.130] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Callers may pass fio parameter with NULL value to f2fs_allocate_data_block(), so we should make sure accessing fio's field after fio's validation check. Fixes: f608c38c59c6 ("f2fs: clean up parameter of f2fs_allocate_data_block()") Signed-off-by: Chao Yu --- fs/f2fs/segment.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index c517e689a9a3..d076ae03b5dc 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -3417,9 +3417,6 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, f2fs_inode_chksum_set(sbi, page); } - if (F2FS_IO_ALIGNED(sbi)) - fio->retry = false; - if (fio) { struct f2fs_bio_info *io; @@ -3429,6 +3426,9 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, spin_lock(&io->io_lock); list_add_tail(&fio->list, &io->io_list); spin_unlock(&io->io_lock); + + if (F2FS_IO_ALIGNED(sbi)) + fio->retry = false; } mutex_unlock(&curseg->curseg_mutex); -- 2.29.2