Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2469249pxj; Mon, 10 May 2021 03:52:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVaDY29JMIC/sO3A73bKid+/ut3yKn3yjy6um949xsTcdydlTbO36GbcmbO6lozJf65ERR X-Received: by 2002:a92:cd52:: with SMTP id v18mr20984436ilq.308.1620643929655; Mon, 10 May 2021 03:52:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620643929; cv=none; d=google.com; s=arc-20160816; b=0BUuLySggbUUN9pAQcpLHgyJVVH9PFpGjzmiavt73QeIX6MeEKfUOQtEJ7GAQiCf1j l7fFxhdq4qNKmw5p3xXRVSA79H0m0//ligrhdOvXUzbGxJV9V3DLxqG05JLOqRugnlw0 T5uMrBWtQuKxwqgKn7y77OoNk+mJAX1iXuRmZ5D8eb4NAoFv5jodBSoVKCW4mHXosRFR H4st7bo1eqH4iV+GK6CAx7N6SAsl9LJzmxC3Gt+Exnlmzb58Ax3/UBshgTYUcELpMETw Vmm5IU9Lo//d/nEAbWTf5nxSSYNo+pjMgPAi4/fJYCCmClcx9FPYDfkgHiOXJf5jRmAe 5eOw== 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=W9Elf0zJZWmffQpqWqrzOANsCzEf60ga/ZOXMZku1Dc=; b=VwQIP1qo6zm4Jwb2lqaayFSHmSzwguiSdX2tWjpfYJJnHW1dS7VUoyWi9aDsUVN7vE OSgo98LpSIb+wpE+qaKb2Qmbtud/RbQa3XzkzUcbZsXMBxOVTFpc5/j1yrRFAO4OTNZ8 4jYoMdehYJUgJ3QK7pEN0cajnFBF0YIvpPCIjwBLxcVDnBpsG9L7AjxV8E4IDrqHJKdC oRpiSiSV7DXwvtacXT3ANCWvqxkkY+kijeIM15ee4mLM/jHFA0qfK0UQiSuhGoa1af7m GrVFJQsbiRBVFDa/b/LSb24BLuNBbomWaunyHozj+nrhtYFEe9ys4Q3765xmhpxuIMzy GkRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RuhqwTT3; 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 n4si15260719ion.59.2021.05.10.03.51.57; Mon, 10 May 2021 03:52:09 -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=RuhqwTT3; 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 S233051AbhEJKvc (ORCPT + 99 others); Mon, 10 May 2021 06:51:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:50354 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233034AbhEJKlK (ORCPT ); Mon, 10 May 2021 06:41:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F0A306192A; Mon, 10 May 2021 10:31:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620642717; bh=IRG8d4vowIAaGqZfnkozIZe9SalBzyrS24k59EHczvo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RuhqwTT3jds2WIX5eimZHpaZ7wAb+cjskHfWf7n1NUovXRcZPKWp8sVUEpn7v6eVF uI2CU1UsQXu483L2a/AoKucMZLhQ6K96kn3Rfx11chKmL5soEp7WVQkl8amu4I1H6q 8Vf5L+WKRaIJbLNXiCpdDyaUXCaIEgaHQjJ2MGoU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gao Xiang Subject: [PATCH 5.10 023/299] erofs: add unsupported inode i_format check Date: Mon, 10 May 2021 12:17:00 +0200 Message-Id: <20210510102005.616878635@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@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: Gao Xiang commit 24a806d849c0b0c1d0cd6a6b93ba4ae4c0ec9f08 upstream. If any unknown i_format fields are set (may be of some new incompat inode features), mark such inode as unsupported. Just in case of any new incompat i_format fields added in the future. Link: https://lore.kernel.org/r/20210329003614.6583-1-hsiangkao@aol.com Fixes: 431339ba9042 ("staging: erofs: add inode operations") Cc: # 4.19+ Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- fs/erofs/erofs_fs.h | 3 +++ fs/erofs/inode.c | 7 +++++++ 2 files changed, 10 insertions(+) --- a/fs/erofs/erofs_fs.h +++ b/fs/erofs/erofs_fs.h @@ -75,6 +75,9 @@ static inline bool erofs_inode_is_data_c #define EROFS_I_VERSION_BIT 0 #define EROFS_I_DATALAYOUT_BIT 1 +#define EROFS_I_ALL \ + ((1 << (EROFS_I_DATALAYOUT_BIT + EROFS_I_DATALAYOUT_BITS)) - 1) + /* 32-byte reduced form of an ondisk inode */ struct erofs_inode_compact { __le16 i_format; /* inode format hints */ --- a/fs/erofs/inode.c +++ b/fs/erofs/inode.c @@ -44,6 +44,13 @@ static struct page *erofs_read_inode(str dic = page_address(page) + *ofs; ifmt = le16_to_cpu(dic->i_format); + if (ifmt & ~EROFS_I_ALL) { + erofs_err(inode->i_sb, "unsupported i_format %u of nid %llu", + ifmt, vi->nid); + err = -EOPNOTSUPP; + goto err_out; + } + vi->datalayout = erofs_inode_datalayout(ifmt); if (vi->datalayout >= EROFS_INODE_DATALAYOUT_MAX) { erofs_err(inode->i_sb, "unsupported datalayout %u of nid %llu",