mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] ksmbd: Replace one-element arrays with flexible-array members
@ 2024-08-16 17:33 Thorsten Blum
  2024-08-16 19:20 ` Gustavo A. R. Silva
  2024-08-17  0:30 ` Namjae Jeon
  0 siblings, 2 replies; 7+ messages in thread
From: Thorsten Blum @ 2024-08-16 17:33 UTC (permalink / raw)
  To: gustavo, linkinjeon, sfrench, senozhatsky, tom
  Cc: linux-cifs, linux-kernel, linux-hardening, Thorsten Blum

Replace the deprecated one-element arrays with flexible-array members
in the structs filesystem_attribute_info and filesystem_device_info.

There are no binary differences after this conversion.

Link: https://github.com/KSPP/linux/issues/79
Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
---
Changes in v2:
- Take struct size changes into account and do not subtract 2 additional
  bytes after feedback from Gustavo A. R. Silva
- Compare the binaries before and after the conversion and add a note
  that there are no differences
- Link to v1: https://lore.kernel.org/linux-kernel/20240816135823.87543-1-thorsten.blum@toblux.com/
---
 fs/smb/server/smb2pdu.c    | 4 ++--
 fs/smb/server/smb_common.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 2df1354288e6..1ce747b4636b 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -5357,7 +5357,7 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
 					"NTFS", PATH_MAX, conn->local_nls, 0);
 		len = len * 2;
 		info->FileSystemNameLen = cpu_to_le32(len);
-		sz = sizeof(struct filesystem_attribute_info) - 2 + len;
+		sz = sizeof(struct filesystem_attribute_info) + len;
 		rsp->OutputBufferLength = cpu_to_le32(sz);
 		break;
 	}
@@ -5383,7 +5383,7 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
 		len = len * 2;
 		info->VolumeLabelSize = cpu_to_le32(len);
 		info->Reserved = 0;
-		sz = sizeof(struct filesystem_vol_info) - 2 + len;
+		sz = sizeof(struct filesystem_vol_info) + len;
 		rsp->OutputBufferLength = cpu_to_le32(sz);
 		break;
 	}
diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
index 4a3148b0167f..cc1d6dfe29d5 100644
--- a/fs/smb/server/smb_common.h
+++ b/fs/smb/server/smb_common.h
@@ -213,7 +213,7 @@ struct filesystem_attribute_info {
 	__le32 Attributes;
 	__le32 MaxPathNameComponentLength;
 	__le32 FileSystemNameLen;
-	__le16 FileSystemName[1]; /* do not have to save this - get subset? */
+	__le16 FileSystemName[]; /* do not have to save this - get subset? */
 } __packed;
 
 struct filesystem_device_info {
@@ -226,7 +226,7 @@ struct filesystem_vol_info {
 	__le32 SerialNumber;
 	__le32 VolumeLabelSize;
 	__le16 Reserved;
-	__le16 VolumeLabel[1];
+	__le16 VolumeLabel[];
 } __packed;
 
 struct filesystem_info {
-- 
2.46.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] ksmbd: Replace one-element arrays with flexible-array members
  2024-08-16 17:33 [PATCH v2] ksmbd: Replace one-element arrays with flexible-array members Thorsten Blum
@ 2024-08-16 19:20 ` Gustavo A. R. Silva
  2024-08-17  0:30 ` Namjae Jeon
  1 sibling, 0 replies; 7+ messages in thread
From: Gustavo A. R. Silva @ 2024-08-16 19:20 UTC (permalink / raw)
  To: Thorsten Blum, linkinjeon, sfrench, senozhatsky, tom
  Cc: linux-cifs, linux-kernel, linux-hardening



On 16/08/24 11:33, Thorsten Blum wrote:
> Replace the deprecated one-element arrays with flexible-array members
> in the structs filesystem_attribute_info and filesystem_device_info.
> 
> There are no binary differences after this conversion.
> 
> Link: https://github.com/KSPP/linux/issues/79
> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>

Looks good.

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks
-Gustavo

> ---
> Changes in v2:
> - Take struct size changes into account and do not subtract 2 additional
>    bytes after feedback from Gustavo A. R. Silva
> - Compare the binaries before and after the conversion and add a note
>    that there are no differences
> - Link to v1: https://lore.kernel.org/linux-kernel/20240816135823.87543-1-thorsten.blum@toblux.com/
> ---
>   fs/smb/server/smb2pdu.c    | 4 ++--
>   fs/smb/server/smb_common.h | 4 ++--
>   2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
> index 2df1354288e6..1ce747b4636b 100644
> --- a/fs/smb/server/smb2pdu.c
> +++ b/fs/smb/server/smb2pdu.c
> @@ -5357,7 +5357,7 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
>   					"NTFS", PATH_MAX, conn->local_nls, 0);
>   		len = len * 2;
>   		info->FileSystemNameLen = cpu_to_le32(len);
> -		sz = sizeof(struct filesystem_attribute_info) - 2 + len;
> +		sz = sizeof(struct filesystem_attribute_info) + len;
>   		rsp->OutputBufferLength = cpu_to_le32(sz);
>   		break;
>   	}
> @@ -5383,7 +5383,7 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
>   		len = len * 2;
>   		info->VolumeLabelSize = cpu_to_le32(len);
>   		info->Reserved = 0;
> -		sz = sizeof(struct filesystem_vol_info) - 2 + len;
> +		sz = sizeof(struct filesystem_vol_info) + len;
>   		rsp->OutputBufferLength = cpu_to_le32(sz);
>   		break;
>   	}
> diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
> index 4a3148b0167f..cc1d6dfe29d5 100644
> --- a/fs/smb/server/smb_common.h
> +++ b/fs/smb/server/smb_common.h
> @@ -213,7 +213,7 @@ struct filesystem_attribute_info {
>   	__le32 Attributes;
>   	__le32 MaxPathNameComponentLength;
>   	__le32 FileSystemNameLen;
> -	__le16 FileSystemName[1]; /* do not have to save this - get subset? */
> +	__le16 FileSystemName[]; /* do not have to save this - get subset? */
>   } __packed;
>   
>   struct filesystem_device_info {
> @@ -226,7 +226,7 @@ struct filesystem_vol_info {
>   	__le32 SerialNumber;
>   	__le32 VolumeLabelSize;
>   	__le16 Reserved;
> -	__le16 VolumeLabel[1];
> +	__le16 VolumeLabel[];
>   } __packed;
>   
>   struct filesystem_info {

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] ksmbd: Replace one-element arrays with flexible-array members
  2024-08-16 17:33 [PATCH v2] ksmbd: Replace one-element arrays with flexible-array members Thorsten Blum
  2024-08-16 19:20 ` Gustavo A. R. Silva
@ 2024-08-17  0:30 ` Namjae Jeon
  1 sibling, 0 replies; 7+ messages in thread
From: Namjae Jeon @ 2024-08-17  0:30 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: gustavo, sfrench, senozhatsky, tom, linux-cifs, linux-kernel,
	linux-hardening

>
> Replace the deprecated one-element arrays with flexible-array members
> in the structs filesystem_attribute_info and filesystem_device_info.
>
> There are no binary differences after this conversion.
>
> Link: https://github.com/KSPP/linux/issues/79
> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
Applied it to #ksmbd-for-next-next.
Thanks!

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] ksmbd: Replace one-element arrays with flexible-array members
  2024-09-19  9:12   ` Thorsten Blum
@ 2024-09-19 11:42     ` Namjae Jeon
  0 siblings, 0 replies; 7+ messages in thread
From: Namjae Jeon @ 2024-09-19 11:42 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: sfrench, senozhatsky, tom, linux-cifs, linux-kernel, linux-hardening

On Thu, Sep 19, 2024 at 6:12 PM Thorsten Blum <thorsten.blum@toblux.com> wrote:
>
> Hi Namjae,
>
> On 22. Aug 2024, at 14:01, Namjae Jeon <linkinjeon@kernel.org> wrote:
> > On Wed, Aug 21, 2024 at 4:15 AM Thorsten Blum <thorsten.blum@toblux.com> wrote:
> >>
> >> Replace the deprecated one-element arrays with flexible-array members
> >> in the structs copychunk_ioctl_req and smb2_ea_info_req.
> >>
> >> There are no binary differences after this conversion.
> >>
> >> Link: https://github.com/KSPP/linux/issues/79
> >> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
> >> ---
> >> Changes in v2:
> >> - Use <= instead of < and +1 as suggested by Namjae Jeon and Tom Talpey
> >> - Link to v1: https://lore.kernel.org/linux-kernel/20240818162136.268325-2-thorsten.blum@toblux.com/
> > Applied it to #ksmbd-for-next-next.
> > Thanks!
>
> I just noticed this patch never made it to linux-next and I can't find
> it anywhere else (also not in #ksmbd-for-next-next).
>
> Maybe it got lost because it has the same subject and a very similar
> commit message as [1] (I submitted both around the same time)?
Sorry for missing it. I have pushed it to #ksmbd-for-next-next again.
Thanks for your report:)
>
> Thanks,
> Thorsten
>
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7c525dddbee71880e654ad44f3917787a4f6042c

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] ksmbd: Replace one-element arrays with flexible-array members
  2024-08-22 12:01 ` Namjae Jeon
@ 2024-09-19  9:12   ` Thorsten Blum
  2024-09-19 11:42     ` Namjae Jeon
  0 siblings, 1 reply; 7+ messages in thread
From: Thorsten Blum @ 2024-09-19  9:12 UTC (permalink / raw)
  To: Namjae Jeon
  Cc: sfrench, senozhatsky, tom, linux-cifs, linux-kernel, linux-hardening

Hi Namjae,

On 22. Aug 2024, at 14:01, Namjae Jeon <linkinjeon@kernel.org> wrote:
> On Wed, Aug 21, 2024 at 4:15 AM Thorsten Blum <thorsten.blum@toblux.com> wrote:
>> 
>> Replace the deprecated one-element arrays with flexible-array members
>> in the structs copychunk_ioctl_req and smb2_ea_info_req.
>> 
>> There are no binary differences after this conversion.
>> 
>> Link: https://github.com/KSPP/linux/issues/79
>> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
>> ---
>> Changes in v2:
>> - Use <= instead of < and +1 as suggested by Namjae Jeon and Tom Talpey
>> - Link to v1: https://lore.kernel.org/linux-kernel/20240818162136.268325-2-thorsten.blum@toblux.com/
> Applied it to #ksmbd-for-next-next.
> Thanks!

I just noticed this patch never made it to linux-next and I can't find 
it anywhere else (also not in #ksmbd-for-next-next).

Maybe it got lost because it has the same subject and a very similar 
commit message as [1] (I submitted both around the same time)?

Thanks,
Thorsten

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7c525dddbee71880e654ad44f3917787a4f6042c

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] ksmbd: Replace one-element arrays with flexible-array members
  2024-08-20 19:15 Thorsten Blum
@ 2024-08-22 12:01 ` Namjae Jeon
  2024-09-19  9:12   ` Thorsten Blum
  0 siblings, 1 reply; 7+ messages in thread
From: Namjae Jeon @ 2024-08-22 12:01 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: sfrench, senozhatsky, tom, linux-cifs, linux-kernel, linux-hardening

On Wed, Aug 21, 2024 at 4:15 AM Thorsten Blum <thorsten.blum@toblux.com> wrote:
>
> Replace the deprecated one-element arrays with flexible-array members
> in the structs copychunk_ioctl_req and smb2_ea_info_req.
>
> There are no binary differences after this conversion.
>
> Link: https://github.com/KSPP/linux/issues/79
> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
> ---
> Changes in v2:
> - Use <= instead of < and +1 as suggested by Namjae Jeon and Tom Talpey
> - Link to v1: https://lore.kernel.org/linux-kernel/20240818162136.268325-2-thorsten.blum@toblux.com/
Applied it to #ksmbd-for-next-next.
Thanks!

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] ksmbd: Replace one-element arrays with flexible-array members
@ 2024-08-20 19:15 Thorsten Blum
  2024-08-22 12:01 ` Namjae Jeon
  0 siblings, 1 reply; 7+ messages in thread
From: Thorsten Blum @ 2024-08-20 19:15 UTC (permalink / raw)
  To: linkinjeon, sfrench, senozhatsky, tom
  Cc: linux-cifs, linux-kernel, linux-hardening, Thorsten Blum

Replace the deprecated one-element arrays with flexible-array members
in the structs copychunk_ioctl_req and smb2_ea_info_req.

There are no binary differences after this conversion.

Link: https://github.com/KSPP/linux/issues/79
Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
---
Changes in v2:
- Use <= instead of < and +1 as suggested by Namjae Jeon and Tom Talpey
- Link to v1: https://lore.kernel.org/linux-kernel/20240818162136.268325-2-thorsten.blum@toblux.com/
---
 fs/smb/server/smb2pdu.c | 4 ++--
 fs/smb/server/smb2pdu.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 2df1354288e6..2c0731a2751f 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -4579,7 +4579,7 @@ static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp,
 	path = &fp->filp->f_path;
 	/* single EA entry is requested with given user.* name */
 	if (req->InputBufferLength) {
-		if (le32_to_cpu(req->InputBufferLength) <
+		if (le32_to_cpu(req->InputBufferLength) <=
 		    sizeof(struct smb2_ea_info_req))
 			return -EINVAL;
 
@@ -8083,7 +8083,7 @@ int smb2_ioctl(struct ksmbd_work *work)
 			goto out;
 		}
 
-		if (in_buf_len < sizeof(struct copychunk_ioctl_req)) {
+		if (in_buf_len <= sizeof(struct copychunk_ioctl_req)) {
 			ret = -EINVAL;
 			goto out;
 		}
diff --git a/fs/smb/server/smb2pdu.h b/fs/smb/server/smb2pdu.h
index 3be7d5ae65a8..73aff20e22d0 100644
--- a/fs/smb/server/smb2pdu.h
+++ b/fs/smb/server/smb2pdu.h
@@ -194,7 +194,7 @@ struct copychunk_ioctl_req {
 	__le64 ResumeKey[3];
 	__le32 ChunkCount;
 	__le32 Reserved;
-	__u8 Chunks[1]; /* array of srv_copychunk */
+	__u8 Chunks[]; /* array of srv_copychunk */
 } __packed;
 
 struct srv_copychunk {
@@ -370,7 +370,7 @@ struct smb2_file_attr_tag_info {
 struct smb2_ea_info_req {
 	__le32 NextEntryOffset;
 	__u8   EaNameLength;
-	char name[1];
+	char name[];
 } __packed; /* level 15 Query */
 
 struct smb2_ea_info {
-- 
2.46.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-09-19 11:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-16 17:33 [PATCH v2] ksmbd: Replace one-element arrays with flexible-array members Thorsten Blum
2024-08-16 19:20 ` Gustavo A. R. Silva
2024-08-17  0:30 ` Namjae Jeon
2024-08-20 19:15 Thorsten Blum
2024-08-22 12:01 ` Namjae Jeon
2024-09-19  9:12   ` Thorsten Blum
2024-09-19 11:42     ` Namjae Jeon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®