Skip to contentSkip to conversation

ntfs : fix shift-out-of-bounds in ntfs_iget

PATCH Superseded Manas Ghandat 2 participants 8 messages Aug 8, 2023 – Aug 10, 2023

Subsystems (2)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ntfs : fix shift-out-of-bounds in ntfs_iget

Added a check to the compression_unit so that out of bound doesn't occur.

---
 fs/ntfs/inode.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
fs/ntfs/inode.c +11 -0
index 6c3f38d66579..2ee100a7df32 100644
@@ -1077,6 +1077,17 @@ static int ntfs_read_locked_inode(struct inode *vi)
 					goto unm_err_out;
 				}
 				if (a->data.non_resident.compression_unit) {
+					if(a->data.non_resident.compression_unit + 
+						vol->cluster_size_bits > 32) {
+							ntfs_error(vi->i_sb, "Found "
+								"non-standard "
+								"compression unit (%u).   "
+								"Cannot handle this.",
+								a->data.non_resident.
+								compression_unit);
+							err = -EOPNOTSUPP;
+							goto unm_err_out;
+						}
 					ni->itype.compressed.block_size = 1U <<
 							(a->data.non_resident.
 							compression_unit +
Signature · 6 lines
2.37.2

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
#1 lore raw
Quoted 14 lines · Manas Ghandat

Added a check to the compression_unit so that out of bound doesn't occur.

---
 fs/ntfs/inode.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
fs/ntfs/inode.c +0 -0
index 6c3f38d66579..2ee100a7df32 100644

fs/ntfs/inode.c static int ntfs_read_locked_inode(struct inode *vi) · line 1085

Quoted 9 lines
fs/ntfs/inode.c +6 -0
@@ -1077,6 +1077,17 @@ static int ntfs_read_locked_inode(struct inode *vi)
 					goto unm_err_out;
 				}
 				if (a->data.non_resident.compression_unit) {
+					if(a->data.non_resident.compression_unit + 
+						vol->cluster_size_bits > 32) {
+							ntfs_error(vi->i_sb, "Found "
+								"non-standard "
+								"compression unit (%u).   "
+								"Cannot handle this.",

Please do not split strings across lines.

And checkpatch will find other problems with this change as well, did you run it before submitting it.

thanks,

greg k-h
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

#2 lore raw

PATCH v2 1/1 ntfs : fix shift-out-of-bounds in ntfs_iget

Added a check to the compression_unit so that out of bound doesn't occur.

Fix patching issues in version 2.

---
 fs/ntfs/inode.c | 9 +++++++++
 1 file changed, 9 insertions(+)
fs/ntfs/inode.c +9 -0
index 6c3f38d66579..a657322874ed 100644
@@ -1077,6 +1077,15 @@ static int ntfs_read_locked_inode(struct inode *vi)
 					goto unm_err_out;
 				}
 				if (a->data.non_resident.compression_unit) {
+					if (a->data.non_resident.compression_unit +
+						vol->cluster_size_bits > 32) {
+						ntfs_error(vi->i_sb,
+							"Found non-standard compression unit (%u).   Cannot handle this.",
+							a->data.non_resident.compression_unit
+						);
+						err = -EOPNOTSUPP;
+						goto unm_err_out;
+					}
 					ni->itype.compressed.block_size = 1U <<
 							(a->data.non_resident.
 							compression_unit +
Signature · 6 lines
2.37.2

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
#3 lore raw
Quoted 34 lines · Manas Ghandat

Added a check to the compression_unit so that out of bound doesn't occur.

Fix patching issues in version 2.

---
 fs/ntfs/inode.c | 9 +++++++++
 1 file changed, 9 insertions(+)
fs/ntfs/inode.c +9 -0
index 6c3f38d66579..a657322874ed 100644
@@ -1077,6 +1077,15 @@ static int ntfs_read_locked_inode(struct inode *vi)
 					goto unm_err_out;
 				}
 				if (a->data.non_resident.compression_unit) {
+					if (a->data.non_resident.compression_unit +
+						vol->cluster_size_bits > 32) {
+						ntfs_error(vi->i_sb,
+							"Found non-standard compression unit (%u).   Cannot handle this.",
+							a->data.non_resident.compression_unit
+						);
+						err = -EOPNOTSUPP;
+						goto unm_err_out;
+					}
 					ni->itype.compressed.block_size = 1U <<
 							(a->data.non_resident.
 							compression_unit +
Signature · 1 line
2.37.2

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
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

#4 lore raw

In the above patch I have mentioned what are the changes from the version
1. Also since most of the lines of the patch were a change due to some indentation error, the whole patch appears as the diff.

Quoted 64 lines · Greg KH

fs/ntfs/inode.c static int ntfs_read_locked_inode(struct inode

Quoted 16 lines · Manas Ghandat

Added a check to the compression_unit so that out of bound doesn't occur.

Fix patching issues in version 2.

---
 fs/ntfs/inode.c | 9 +++++++++
 1 file changed, 9 insertions(+)
fs/ntfs/inode.c +0 -0
index 6c3f38d66579..a657322874ed 100644
@@ -1077,6 +1077,15 @@ static int ntfs_read_locked_inode(struct inode

*vi)

fs/ntfs/inode.c static int ntfs_read_locked_inode(struct inode *vi)

Quoted 3 lines
fs/ntfs/inode.c +0 -0
                                      goto unm_err_out;
                              }
                              if (a->data.non_resident.compression_unit)

{

fs/ntfs/inode.c static int ntfs_read_locked_inode(struct inode · line 1080

Quoted 1 line
fs/ntfs/inode.c +1 -0
+                                     if

(a->data.non_resident.compression_unit +

fs/ntfs/inode.c static int ntfs_read_locked_inode(struct inode · line 1081

Quoted 1 line
fs/ntfs/inode.c +1 -0
+                                             vol->cluster_size_bits >

32) {

fs/ntfs/inode.c static int ntfs_read_locked_inode(struct inode · line 1083

Quoted 2 lines
fs/ntfs/inode.c +2 -0
+                                             ntfs_error(vi->i_sb,
+                                                     "Found

non-standard compression unit (%u). Cannot handle this.",

fs/ntfs/inode.c static int ntfs_read_locked_inode(struct inode · line 1084

Quoted 1 line
fs/ntfs/inode.c +1 -0
+

a->data.non_resident.compression_unit

fs/ntfs/inode.c static int ntfs_read_locked_inode(struct inode *vi)

Quoted 5 lines
fs/ntfs/inode.c +4 -0
+                                             );
+                                             err = -EOPNOTSUPP;
+                                             goto unm_err_out;
+                                     }
                                      ni->itype.compressed.block_size =

1U <<

Quoted 1 line

(a->data.non_resident.

Quoted 4 lines

compression_unit +
--
2.37.2

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.

Quoted 9 lines

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

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

#5 lore raw
Quoted 3 lines · Manas Ghandat

In the above patch I have mentioned what are the changes from the version
1. Also since most of the lines of the patch were a change due to some indentation error, the whole patch appears as the diff.

Quoted 5 lines · As my bot
Quoted 5 lines

- 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.

Please read that and submit a new patch based on the requirements there.

thanks,

greg k-h
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

#6 lore raw

PATCH v3 1/1 ntfs : fix shift-out-of-bounds in ntfs_iget

Added a check to the compression_unit so that out of bound doesn't occur.

---
V2 -> V3: Fix patching issue.
V1 -> V2: Cleaned up coding style.

 fs/ntfs/inode.c | 9 +++++++++
 1 file changed, 9 insertions(+)
fs/ntfs/inode.c +9 -0
index 6c3f38d66579..a657322874ed 100644
@@ -1077,6 +1077,15 @@ static int ntfs_read_locked_inode(struct inode *vi)
 					goto unm_err_out;
 				}
 				if (a->data.non_resident.compression_unit) {
+					if (a->data.non_resident.compression_unit +
+						vol->cluster_size_bits > 32) {
+						ntfs_error(vi->i_sb,
+							"Found non-standard compression unit (%u).   Cannot handle this.",
+							a->data.non_resident.compression_unit
+						);
+						err = -EOPNOTSUPP;
+						goto unm_err_out;
+					}
 					ni->itype.compressed.block_size = 1U <<
 							(a->data.non_resident.
 							compression_unit +
Signature · 6 lines
2.37.2

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
#7 lore raw
Quoted 1 line · Manas Ghandat

Added a check to the compression_unit so that out of bound doesn't occur.

This probably needs more text to describe what is happening.

Quoted 4 lines

What commit id does this fix? Should it go to stable kernels?

Quoted 12 lines

---
V2 -> V3: Fix patching issue.
V1 -> V2: Cleaned up coding style.

 fs/ntfs/inode.c | 9 +++++++++
 1 file changed, 9 insertions(+)
fs/ntfs/inode.c +0 -0
index 6c3f38d66579..a657322874ed 100644

fs/ntfs/inode.c static int ntfs_read_locked_inode(struct inode *vi) · line 1081

Quoted 5 lines
fs/ntfs/inode.c +2 -0
@@ -1077,6 +1077,15 @@ static int ntfs_read_locked_inode(struct inode *vi)
 					goto unm_err_out;
 				}
 				if (a->data.non_resident.compression_unit) {
+					if (a->data.non_resident.compression_unit +
+						vol->cluster_size_bits > 32) {

Should be indented a bit left, right?

fs/ntfs/inode.c static int ntfs_read_locked_inode(struct inode *vi) · line 1083

Quoted 2 lines
fs/ntfs/inode.c +2 -0
+						ntfs_error(vi->i_sb,
+							"Found non-standard compression unit (%u).   Cannot handle this.",

Why all the extra ' ' characters?

thanks,

greg k-h