Skip to contentSkip to conversation

jfs: validate max amount of blocks before allocation.

PATCH In review Aleksei Filippov 3 participants 10 messages Jul 22, 2023 – Aug 29, 2023 JFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 jfs: validate max amount of blocks before allocation.

From: Alexei Filippov <[email protected]>

The lack of checking bmp->db_max_freebud in extBalloc() can lead to shift out of bounds, so this patch prevents undefined behavior, because bmp->db_max_freebud == -1 only if there
is no free space.

---
 fs/jfs/jfs_extent.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/jfs/jfs_extent.c +5 -0
index ae99a7e232ee..a82751e6c47f 100644
@@ -311,6 +311,11 @@ extBalloc(struct inode *ip, s64 hint, s64 * nblocks, s64 * blkno)
 	 * blocks in the map. in that case, we'll start off with the
 	 * maximum free.
 	 */
+
+	/* give up if no space left */
+	if (bmp->db_maxfreebud == -1)
+		return -ENOSPC;
+
 	max = (s64) 1 << bmp->db_maxfreebud;
 	if (*nblocks >= max && *nblocks > nbperpage)
 		nb = nblks = (max > nbperpage) ? max : nbperpage;
Signature · 1 line
2.25.1
#1 lore raw
Quoted 6 lines · Aleksei Filippov

From: Alexei Filippov <[email protected]>

The lack of checking bmp->db_max_freebud in extBalloc() can lead to shift out of bounds, so this patch prevents undefined behavior, because bmp->db_max_freebud == -1 only if there
is no free space.

Please wrap at 72 columns properly.

Quoted 7 lines
---
 fs/jfs/jfs_extent.c | 5 +++++
 1 file changed, 5 insertions(+)

What commit id does this fix?

Is it needed for stable kernels? If so, please tag it as such.

thanks,

greg k-h

#2 lore raw

PATCH 1/1 jfs: validate max amount of blocks before allocation.

From: Alexei Filippov <[email protected]>

The lack of checking bmp->db_max_freebud in extBalloc() can lead to shift out of bounds, so this patch prevents undefined behavior, because bmp->db_max_freebud == -1 only if there is no free space.

---
 fs/jfs/jfs_extent.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/jfs/jfs_extent.c +5 -0
index ae99a7e232ee..a82751e6c47f 100644
@@ -311,6 +311,11 @@ extBalloc(struct inode *ip, s64 hint, s64 * nblocks, s64 * blkno)
 	 * blocks in the map. in that case, we'll start off with the
 	 * maximum free.
 	 */
+
+	/* give up if no space left */
+	if (bmp->db_maxfreebud == -1)
+		return -ENOSPC;
+
 	max = (s64) 1 << bmp->db_maxfreebud;
 	if (*nblocks >= max && *nblocks > nbperpage)
 		nb = nblks = (max > nbperpage) ? max : nbperpage;
Signature · 1 line
2.25.1
#3 lore raw
Quoted 33 lines · Aleksei Filippov

From: Alexei Filippov <[email protected]>

The lack of checking bmp->db_max_freebud in extBalloc() can lead to shift out of bounds, so this patch prevents undefined behavior, because bmp->db_max_freebud == -1 only if there is no free space.

---
 fs/jfs/jfs_extent.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/jfs/jfs_extent.c +5 -0
index ae99a7e232ee..a82751e6c47f 100644
@@ -311,6 +311,11 @@ extBalloc(struct inode *ip, s64 hint, s64 * nblocks, s64 * blkno)
 	 * blocks in the map. in that case, we'll start off with the
 	 * maximum free.
 	 */
+
+	/* give up if no space left */
+	if (bmp->db_maxfreebud == -1)
+		return -ENOSPC;
+
 	max = (s64) 1 << bmp->db_maxfreebud;
 	if (*nblocks >= max && *nblocks > nbperpage)
 		nb = nblks = (max > nbperpage) ? max : nbperpage;
Signature · 1 line
2.25.1

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree.

You are receiving this message because of the following common error(s) as indicated below:

- This looks like a new version of a previously submitted patch, but you did not list below the --- line any changes from the previous version. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/process/submitting-patches.rst for what needs to be done here to properly describe this.

If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers.

thanks,

greg k-h's patch email bot

#4 lore raw

PATCH v3 1/1 jfs: validate max amount of blocks before allocation.

From: Alexei Filippov <[email protected]>

The lack of checking bmp->db_max_freebud in extBalloc() can lead to shift out of bounds, so this patch prevents undefined behavior, because bmp->db_max_freebud == -1 only if there is no free space.

---
 fs/jfs/jfs_extent.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/jfs/jfs_extent.c +5 -0
index ae99a7e232ee..a82751e6c47f 100644
@@ -311,6 +311,11 @@ extBalloc(struct inode *ip, s64 hint, s64 * nblocks, s64 * blkno)
 	 * blocks in the map. in that case, we'll start off with the
 	 * maximum free.
 	 */
+
+	/* give up if no space left */
+	if (bmp->db_maxfreebud == -1)
+		return -ENOSPC;
+
 	max = (s64) 1 << bmp->db_maxfreebud;
 	if (*nblocks >= max && *nblocks > nbperpage)
 		nb = nblks = (max > nbperpage) ? max : nbperpage;
Signature · 3 lines
2.25.1

Fix commit message.
#5 lore raw
Quoted 34 lines · Aleksei Filippov

From: Alexei Filippov <[email protected]>

The lack of checking bmp->db_max_freebud in extBalloc() can lead to shift out of bounds, so this patch prevents undefined behavior, because bmp->db_max_freebud == -1 only if there is no free space.

---
 fs/jfs/jfs_extent.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/jfs/jfs_extent.c +5 -0
index ae99a7e232ee..a82751e6c47f 100644
@@ -311,6 +311,11 @@ extBalloc(struct inode *ip, s64 hint, s64 * nblocks, s64 * blkno)
 	 * blocks in the map. in that case, we'll start off with the
 	 * maximum free.
 	 */
+
+	/* give up if no space left */
+	if (bmp->db_maxfreebud == -1)
+		return -ENOSPC;
+
 	max = (s64) 1 << bmp->db_maxfreebud;
 	if (*nblocks >= max && *nblocks > nbperpage)
 		nb = nblks = (max > nbperpage) ? max : nbperpage;
Signature · 3 lines
2.25.1

Fix commit message.

The --- information for the version goes below the first --- line, not the last. Look at the examples on the mailing lists for the proper format.

thanks,

greg k-h

#6 lore raw

PATCH v4 1/1 jfs: validate max amount of blocks before allocation.

From: Alexei Filippov <[email protected]>

The lack of checking bmp->db_max_freebud in extBalloc() can lead to shift out of bounds, so this patch prevents undefined behavior, because bmp->db_max_freebud == -1 only if there is no free space.

---
Changes:
Fix commit message.

 fs/jfs/jfs_extent.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/jfs/jfs_extent.c +5 -0
index ae99a7e232ee..a82751e6c47f 100644
@@ -311,6 +311,11 @@ extBalloc(struct inode *ip, s64 hint, s64 * nblocks, s64 * blkno)
 	 * blocks in the map. in that case, we'll start off with the
 	 * maximum free.
 	 */
+
+	/* give up if no space left */
+	if (bmp->db_maxfreebud == -1)
+		return -ENOSPC;
+
 	max = (s64) 1 << bmp->db_maxfreebud;
 	if (*nblocks >= max && *nblocks > nbperpage)
 		nb = nblks = (max > nbperpage) ? max : nbperpage;
Signature · 1 line
2.25.1
#7 lore raw
Quoted 10 lines · Aleksei Filippov

From: Alexei Filippov <[email protected]>

The lack of checking bmp->db_max_freebud in extBalloc() can lead to shift out of bounds, so this patch prevents undefined behavior, because bmp->db_max_freebud == -1 only if there is no free space.

Quoted 5 lines

---
Changes:
Fix commit message.

 fs/jfs/jfs_extent.c | 5 +++++
 1 file changed, 5 insertions(+)

{sigh}

Please, take some time, read the documentation for how to do this correctly. Wait a day, and then submit it again, properly.

Also, do you have a jfs system? Isn't this filesystem obsolete?

thanks,

greg k-h

#8 lore raw

PATCH v5 1/1 jfs: validate max amount of blocks before allocation.

From: Alexei Filippov <[email protected]>

The lack of checking bmp->db_max_freebud in extBalloc() can lead to shift out of bounds, so this patch prevents undefined behavior, because bmp->db_max_freebud == -1 only if there is no free space.

---

Changes since v1:
-Commit message fix. Add Fixes line.
Changes since v2-v4:
-Commit message fixes.

 fs/jfs/jfs_extent.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/jfs/jfs_extent.c +5 -0
index ae99a7e232ee..a82751e6c47f 100644
@@ -311,6 +311,11 @@ extBalloc(struct inode *ip, s64 hint, s64 * nblocks, s64 * blkno)
 	 * blocks in the map. in that case, we'll start off with the
 	 * maximum free.
 	 */
+
+	/* give up if no space left */
+	if (bmp->db_maxfreebud == -1)
+		return -ENOSPC;
+
 	max = (s64) 1 << bmp->db_maxfreebud;
 	if (*nblocks >= max && *nblocks > nbperpage)
 		nb = nblks = (max > nbperpage) ? max : nbperpage;
Signature · 1 line
2.25.1
#9 lore raw
Quoted 5 lines · Aleksei Filippov

From: Alexei Filippov <[email protected]>

The lack of checking bmp->db_max_freebud in extBalloc() can lead to shift out of bounds, so this patch prevents undefined behavior, because bmp->db_max_freebud == -1 only if there is no free space.

Thanks. Applied.

Quoted 30 lines

---

Changes since v1:
-Commit message fix. Add Fixes line.
Changes since v2-v4:
-Commit message fixes.

  fs/jfs/jfs_extent.c | 5 +++++
  1 file changed, 5 insertions(+)
fs/jfs/jfs_extent.c +5 -0
index ae99a7e232ee..a82751e6c47f 100644
@@ -311,6 +311,11 @@ extBalloc(struct inode *ip, s64 hint, s64 * nblocks, s64 * blkno)
  	 * blocks in the map. in that case, we'll start off with the
  	 * maximum free.
  	 */
+
+	/* give up if no space left */
+	if (bmp->db_maxfreebud == -1)
+		return -ENOSPC;
+
  	max = (s64) 1 << bmp->db_maxfreebud;
  	if (*nblocks >= max && *nblocks > nbperpage)
  		nb = nblks = (max > nbperpage) ? max : nbperpage;