Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3027791pxj; Mon, 17 May 2021 15:57:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBxnhtUAZgSIadepD+mdlR3HtWfC8tARXr+tmX+OKH03W7mXM614uM+B2fZQmaixDx3ijA X-Received: by 2002:a92:ca0a:: with SMTP id j10mr1729898ils.73.1621292257670; Mon, 17 May 2021 15:57:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621292257; cv=none; d=google.com; s=arc-20160816; b=hKUZ7VLPGOrA8HKMrT9MV/bq11OOFGKv9T5dyUMy/x3Gd39DucY/dgAqoGeJxP5Ury LxBthwN1iH3vse91py6Ls0BQIcrgAgpQuq+0V2HCdGdNgNzTwedi78birqZ/1yc5pbTL BqWFJoULQ8AWolVm76VZ4j15/+99YGaHrLPlDQfpgzh569ygRPwJUnGe/RtyDJ2qgqSx +KzAgpCK84IzrPqprucqXEDQ9qG7M61r5KIOJsMBGvhOrfiy9G4Su0aLmde6FxmndKOx Z1+3/C7p2//P5bcuznZ/dsKr+ktAFHVVTEsGk844WNuOhZZpmLeZjJ4sCRf1nYtIxgtf eOhw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mbvF7OAIzknNBrr53oaFdQrd6ZlbWBPIkPY+uJK6zkA=; b=y7+9Oy6tSqzphr/KoHwqGA+A98NgetfTfp6Sow7uTJgPJfkSv8oxHO329dov19y0DK WHm8o6EIVG8oTfqaFoQPBRutCxtEVC9sZ3GWq8HbKuoKq67gcmN7iu5mP6JBSzrzDw7Q aZjQuis3mqlqCCez1ipWs0MJ3k33tJ6ZVtfLQQZ23WubuPit1cvbHkuok5QywEr5d2lt lGOJdTBmKDc5DhehV4JLYnjrnQqmhvDRjwAWeKbDlvjogxIpXZ7WLAHDZZL1egDmYltZ goaTo/HO4ISYe6lywtzjuwXOpQrzOrObCoC2HPPpY/oGHhAsyDompCLz4h9ANFjk0c3d ioyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=z28RXVGp; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y7si2174901jap.36.2021.05.17.15.57.25; Mon, 17 May 2021 15:57:37 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=z28RXVGp; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238924AbhEQOTE (ORCPT + 99 others); Mon, 17 May 2021 10:19:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:46510 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238864AbhEQOQp (ORCPT ); Mon, 17 May 2021 10:16:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 17069613F1; Mon, 17 May 2021 14:09:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260583; bh=Y8nwbp6Ngul8junayUwSNqCku1/xpPxKJfxiXn6WgH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z28RXVGpknaSynWbMRDf5K60G2wnC2XINrlmbgF5a7HoJMKqoUBokAXb2zQj5tqjr UUUWvuoPsqWy2n7Q/C6ph/1gW5KqoBNSCZ9h1hgJp1rcSX9aNwyrz+18qjMS5CIN8S Rqii5o2Ecem8CHVu4sF5IuE6WzbYzptyz8RsC/Bs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 5.12 148/363] f2fs: fix to avoid accessing invalid fio in f2fs_allocate_data_block() Date: Mon, 17 May 2021 16:00:14 +0200 Message-Id: <20210517140307.615596205@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chao Yu [ Upstream commit 25ae837e61dee712b4b1df36602ebfe724b2a0b6 ] 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 Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- 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 d83cb1359e53..77456d228f2a 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -3397,12 +3397,12 @@ 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; + if (F2FS_IO_ALIGNED(sbi)) + fio->retry = false; + INIT_LIST_HEAD(&fio->list); fio->in_list = true; io = sbi->write_io[fio->type] + fio->temp; -- 2.30.2