Skip to contentSkip to conversation

FAILED: patch "[PATCH] erofs: add unsupported inode i_format check" failed to apply to 4.19-stable tree

PATCH In review [email protected] 2 participants 3 messages May 7, 2021

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 24a806d849c0b0c1d0cd6a6b93ba4ae4c0ec9f08 Mon Sep 17 00:00:00 2001
From: Gao Xiang <[email protected]>
Date: Mon, 29 Mar 2021 08:36:14 +0800
Subject: [PATCH] erofs: add unsupported inode i_format check

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.

Fixes 431339ba9042 ("staging: erofs: add inode operations")
Cc <[email protected]> # 4.19+
fs/erofs/erofs_fs.h +3 -0
index 9ad1615f4474..e8d04d808fa6 100644
@@ -75,6 +75,9 @@ static inline bool erofs_inode_is_data_compressed(unsigned int datamode)
 #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 */
fs/erofs/inode.c +7 -0
index 119fdce1b520..7ed2d7391692 100644
@@ -44,6 +44,13 @@ static struct page *erofs_read_inode(struct inode *inode,
 	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",
#1 lore raw

PATCH 1/1 erofs: add unsupported inode i_format check

From: Gao Xiang <[email protected]>

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.

Fixes 431339ba9042 ("staging: erofs: add inode operations")
Cc <[email protected]> # 4.19+
[ Gao Xiang: Manually backport to 4.19.y due to trivial conflicts. ]

---
Hi Greg,

Please consider this backport patch for 4.19 staging erofs. (btw, I use [email protected] instead of @redhat.com here since
I'll shift to Alibaba in weeks...)

Thanks,
Gao Xiang

 drivers/staging/erofs/erofs_fs.h | 3 +++
 drivers/staging/erofs/inode.c    | 6 ++++++
 2 files changed, 9 insertions(+)
drivers/staging/erofs/erofs_fs.h +3 -0
index 7677da889f12..38f15e3d8ebb 100644
@@ -71,6 +71,9 @@ enum {
 #define EROFS_I_VERSION_BIT             0
 __EROFS_BIT(EROFS_I_, DATA_MAPPING, VERSION);
 
+#define EROFS_I_ALL	\
+	((1 << (EROFS_I_DATA_MAPPING_BIT + EROFS_I_DATA_MAPPING_BITS)) - 1)
+
 struct erofs_inode_v1 {
 /*  0 */__le16 i_advise;
 
drivers/staging/erofs/inode.c +6 -0
index a43abd530cc1..02398c7eb4a4 100644
@@ -48,6 +48,12 @@ static struct page *read_inode(struct inode *inode, unsigned int *ofs)
 	v1 = page_address(page) + *ofs;
 	ifmt = le16_to_cpu(v1->i_advise);
 
+	if (ifmt & ~EROFS_I_ALL) {
+		errln("unsupported i_format %u of nid %llu", ifmt, vi->nid);
+		err = -EOPNOTSUPP;
+		goto err_out;
+	}
+
 	vi->data_mapping_mode = __inode_data_mapping(ifmt);
 	if (unlikely(vi->data_mapping_mode >= EROFS_INODE_LAYOUT_MAX)) {
 		errln("unknown data mapping mode %u of nid %llu",
Signature · 1 line
2.27.0
author maintainer
#2 lore raw

Re: [PATCH 4.19.y] erofs: add unsupported inode i_format check

Quoted 13 lines · Gao Xiang

From: Gao Xiang <[email protected]>

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.

Fixes 431339ba9042 ("staging: erofs: add inode operations")
Cc <[email protected]> # 4.19+
[ Gao Xiang: Manually backport to 4.19.y due to trivial conflicts. ]
Quoted 6 lines

---
Hi Greg,

Please consider this backport patch for 4.19 staging erofs. (btw, I use [email protected] instead of @redhat.com here since
I'll shift to Alibaba in weeks...)

Thanks for this, now queued up!

greg k-h