Skip to contentSkip to conversation

media: venus: hfi_cmds: struct hfi_session_release_buffer_pkt

PATCH Applied Kees Cook 5 participants 12 messages Jul 10, 2024 – Aug 23, 2024

Subsystems (4)
lore
Share & tools
lore

Kees Cook

author
#0 lore raw

cover media: venus: hfi_cmds: struct hfi_session_release_buffer_pkt

Hi,

This replaces the 1-element "fake" flexible array in struct hfi_session_release_buffer_pkt with a modern flexible array and adds the __counted_by annotation that was identified during the analysis.

Thanks!

-Kees

Kees Cook (2):
media: venus: hfi_cmds: struct hfi_session_release_buffer_pkt: Replace
1-element array with flexible array
media: venus: hfi_cmds: struct hfi_session_release_buffer_pkt: Add
__counted_by annotation

 drivers/media/platform/qcom/venus/hfi_cmds.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 1/2 media: venus: hfi_cmds: struct hfi_session_release_buffer_pkt: Replace 1-element array with flexible array

Replace the deprecated[1] use of a 1-element array in struct hfi_session_release_buffer_pkt with a modern flexible array.

No binary differences are present after this conversion.

---
Cc: Stanimir Varbanov <[email protected]>
Cc: Vikash Garodia <[email protected]>
Cc: "Bryan O'Donoghue" <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 drivers/media/platform/qcom/venus/hfi_cmds.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/venus/hfi_cmds.h +1 -1
index 20acd412ee7b..42825f07939d 100644
@@ -227,7 +227,7 @@ struct hfi_session_release_buffer_pkt {
 	u32 extradata_size;
 	u32 response_req;
 	u32 num_buffers;
-	u32 buffer_info[1];
+	u32 buffer_info[];
 };
 
 struct hfi_session_release_resources_pkt {
Signature · 1 line
2.34.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] media: venus: hfi_cmds: struct hfi_session_release_buffer_pkt: Replace 1-element array with flexible array

Quoted 7 lines · Kees Cook

Replace the deprecated[1] use of a 1-element array in struct hfi_session_release_buffer_pkt with a modern flexible array.

No binary differences are present after this conversion.

Quoted 9 lines

---
Cc: Stanimir Varbanov <[email protected]>
Cc: Vikash Garodia <[email protected]>
Cc: "Bryan O'Donoghue" <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

Thanks
--
Gustavo

Quoted 17 lines
---
  drivers/media/platform/qcom/venus/hfi_cmds.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/venus/hfi_cmds.h +1 -1
index 20acd412ee7b..42825f07939d 100644
@@ -227,7 +227,7 @@ struct hfi_session_release_buffer_pkt {
  	u32 extradata_size;
  	u32 response_req;
  	u32 num_buffers;
-	u32 buffer_info[1];
+	u32 buffer_info[];
  };
 
  struct hfi_session_release_resources_pkt {
Reviewed-by on v1 1/2
#3 lore raw

Re: [PATCH 1/2] media: venus: hfi_cmds: struct hfi_session_release_buffer_pkt: Replace 1-element array with flexible array

In reply to Kees Cook
Quoted 25 lines · Kees Cook

Replace the deprecated[1] use of a 1-element array in struct hfi_session_release_buffer_pkt with a modern flexible array.

No binary differences are present after this conversion.

---
Cc: Stanimir Varbanov <[email protected]>
Cc: Vikash Garodia <[email protected]>
Cc: "Bryan O'Donoghue" <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
  drivers/media/platform/qcom/venus/hfi_cmds.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/venus/hfi_cmds.h +0 -0
index 20acd412ee7b..42825f07939d 100644

drivers/media/platform/qcom/venus/hfi_cmds.h struct hfi_session_release_buffer_pkt { · line 233

Quoted 8 lines
drivers/media/platform/qcom/venus/hfi_cmds.h +1 -1
@@ -227,7 +227,7 @@ struct hfi_session_release_buffer_pkt {
  	u32 extradata_size;
  	u32 response_req;
  	u32 num_buffers;
-	u32 buffer_info[1];
+	u32 buffer_info[];
  };
 
  struct hfi_session_release_resources_pkt {
Reviewed-by on v1 1/2
#4 lore raw

Re: [PATCH 1/2] media: venus: hfi_cmds: struct hfi_session_release_buffer_pkt: Replace 1-element array with flexible array

In reply to Kees Cook
Quoted 25 lines · Kees Cook

Replace the deprecated[1] use of a 1-element array in struct hfi_session_release_buffer_pkt with a modern flexible array.

No binary differences are present after this conversion.

---
Cc: Stanimir Varbanov <[email protected]>
Cc: Vikash Garodia <[email protected]>
Cc: "Bryan O'Donoghue" <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 drivers/media/platform/qcom/venus/hfi_cmds.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/venus/hfi_cmds.h +0 -0
index 20acd412ee7b..42825f07939d 100644

drivers/media/platform/qcom/venus/hfi_cmds.h struct hfi_session_release_buffer_pkt { · line 233

Quoted 8 lines
drivers/media/platform/qcom/venus/hfi_cmds.h +1 -1
@@ -227,7 +227,7 @@ struct hfi_session_release_buffer_pkt {
 	u32 extradata_size;
 	u32 response_req;
 	u32 num_buffers;
-	u32 buffer_info[1];
+	u32 buffer_info[];
 };
 
 struct hfi_session_release_resources_pkt {

Regards,
Vikash

Reviewed-by on v1 1/2
#5 lore raw

Re: [PATCH 1/2] media: venus: hfi_cmds: struct hfi_session_release_buffer_pkt: Replace 1-element array with flexible array

In reply to Kees Cook
Quoted 25 lines · Kees Cook

Replace the deprecated[1] use of a 1-element array in struct hfi_session_release_buffer_pkt with a modern flexible array.

No binary differences are present after this conversion.

---
Cc: Stanimir Varbanov <[email protected]>
Cc: Vikash Garodia <[email protected]>
Cc: "Bryan O'Donoghue" <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 drivers/media/platform/qcom/venus/hfi_cmds.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/venus/hfi_cmds.h +0 -0
index 20acd412ee7b..42825f07939d 100644

drivers/media/platform/qcom/venus/hfi_cmds.h struct hfi_session_release_buffer_pkt { · line 233

Quoted 8 lines
drivers/media/platform/qcom/venus/hfi_cmds.h +1 -1
@@ -227,7 +227,7 @@ struct hfi_session_release_buffer_pkt {
 	u32 extradata_size;
 	u32 response_req;
 	u32 num_buffers;
-	u32 buffer_info[1];
+	u32 buffer_info[];
 };
 
 struct hfi_session_release_resources_pkt {

Thanks,
Dikshita

author
#6 lore raw

PATCH 2/2 media: venus: hfi_cmds: struct hfi_session_release_buffer_pkt: Add __counted_by annotation

In reply to Kees Cook

The only direct user of struct hfi_session_release_buffer_pkt is pkt_session_unset_buffers() which sets "num_buffers" before using it as a loop counter for accessing "buffer_info". Add the __counted_by annotation to reflect the relationship.

---
Cc: Stanimir Varbanov <[email protected]>
Cc: Vikash Garodia <[email protected]>
Cc: "Bryan O'Donoghue" <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 drivers/media/platform/qcom/venus/hfi_cmds.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/venus/hfi_cmds.h +1 -1
index 42825f07939d..1adf2d2ae5f2 100644
@@ -227,7 +227,7 @@ struct hfi_session_release_buffer_pkt {
 	u32 extradata_size;
 	u32 response_req;
 	u32 num_buffers;
-	u32 buffer_info[];
+	u32 buffer_info[] __counted_by(num_buffers);
 };
 
 struct hfi_session_release_resources_pkt {
Signature · 1 line
2.34.1
Reviewed-by on v1 2/2
#7 lore raw

Re: [PATCH 2/2] media: venus: hfi_cmds: struct hfi_session_release_buffer_pkt: Add __counted_by annotation

Quoted 6 lines · Kees Cook

The only direct user of struct hfi_session_release_buffer_pkt is pkt_session_unset_buffers() which sets "num_buffers" before using it as a loop counter for accessing "buffer_info". Add the __counted_by annotation to reflect the relationship.

Quoted 9 lines

---
Cc: Stanimir Varbanov <[email protected]>
Cc: Vikash Garodia <[email protected]>
Cc: "Bryan O'Donoghue" <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

Thanks
--
Gustavo

Quoted 17 lines
---
  drivers/media/platform/qcom/venus/hfi_cmds.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/venus/hfi_cmds.h +1 -1
index 42825f07939d..1adf2d2ae5f2 100644
@@ -227,7 +227,7 @@ struct hfi_session_release_buffer_pkt {
  	u32 extradata_size;
  	u32 response_req;
  	u32 num_buffers;
-	u32 buffer_info[];
+	u32 buffer_info[] __counted_by(num_buffers);
  };
 
  struct hfi_session_release_resources_pkt {
Reviewed-by on v1 2/2
#8 lore raw

Re: [PATCH 2/2] media: venus: hfi_cmds: struct hfi_session_release_buffer_pkt: Add __counted_by annotation

In reply to Kees Cook
Quoted 24 lines · Kees Cook

The only direct user of struct hfi_session_release_buffer_pkt is pkt_session_unset_buffers() which sets "num_buffers" before using it as a loop counter for accessing "buffer_info". Add the __counted_by annotation to reflect the relationship.

---
Cc: Stanimir Varbanov <[email protected]>
Cc: Vikash Garodia <[email protected]>
Cc: "Bryan O'Donoghue" <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
  drivers/media/platform/qcom/venus/hfi_cmds.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/venus/hfi_cmds.h +0 -0
index 42825f07939d..1adf2d2ae5f2 100644

drivers/media/platform/qcom/venus/hfi_cmds.h struct hfi_session_release_buffer_pkt { · line 233

Quoted 8 lines
drivers/media/platform/qcom/venus/hfi_cmds.h +1 -1
@@ -227,7 +227,7 @@ struct hfi_session_release_buffer_pkt {
  	u32 extradata_size;
  	u32 response_req;
  	u32 num_buffers;
-	u32 buffer_info[];
+	u32 buffer_info[] __counted_by(num_buffers);
  };
 
  struct hfi_session_release_resources_pkt {
Reviewed-by on v1 2/2
#9 lore raw

Re: [PATCH 2/2] media: venus: hfi_cmds: struct hfi_session_release_buffer_pkt: Add __counted_by annotation

In reply to Kees Cook
Quoted 24 lines · Kees Cook

The only direct user of struct hfi_session_release_buffer_pkt is pkt_session_unset_buffers() which sets "num_buffers" before using it as a loop counter for accessing "buffer_info". Add the __counted_by annotation to reflect the relationship.

---
Cc: Stanimir Varbanov <[email protected]>
Cc: Vikash Garodia <[email protected]>
Cc: "Bryan O'Donoghue" <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 drivers/media/platform/qcom/venus/hfi_cmds.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/venus/hfi_cmds.h +0 -0
index 42825f07939d..1adf2d2ae5f2 100644

drivers/media/platform/qcom/venus/hfi_cmds.h struct hfi_session_release_buffer_pkt { · line 233

Quoted 8 lines
drivers/media/platform/qcom/venus/hfi_cmds.h +1 -1
@@ -227,7 +227,7 @@ struct hfi_session_release_buffer_pkt {
 	u32 extradata_size;
 	u32 response_req;
 	u32 num_buffers;
-	u32 buffer_info[];
+	u32 buffer_info[] __counted_by(num_buffers);
 };
 
 struct hfi_session_release_resources_pkt {

Regards,
Vikash

Reviewed-by on v1 2/2
#10 lore raw

Re: [PATCH 2/2] media: venus: hfi_cmds: struct hfi_session_release_buffer_pkt: Add __counted_by annotation

In reply to Kees Cook
Quoted 24 lines · Kees Cook

The only direct user of struct hfi_session_release_buffer_pkt is pkt_session_unset_buffers() which sets "num_buffers" before using it as a loop counter for accessing "buffer_info". Add the __counted_by annotation to reflect the relationship.

---
Cc: Stanimir Varbanov <[email protected]>
Cc: Vikash Garodia <[email protected]>
Cc: "Bryan O'Donoghue" <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 drivers/media/platform/qcom/venus/hfi_cmds.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/venus/hfi_cmds.h +0 -0
index 42825f07939d..1adf2d2ae5f2 100644

drivers/media/platform/qcom/venus/hfi_cmds.h struct hfi_session_release_buffer_pkt { · line 233

Quoted 8 lines
drivers/media/platform/qcom/venus/hfi_cmds.h +1 -1
@@ -227,7 +227,7 @@ struct hfi_session_release_buffer_pkt {
 	u32 extradata_size;
 	u32 response_req;
 	u32 num_buffers;
-	u32 buffer_info[];
+	u32 buffer_info[] __counted_by(num_buffers);
 };
 
 struct hfi_session_release_resources_pkt {

Thanks,
Dikshita

author Applied
#11 lore raw
In reply to Kees Cook
Quoted 9 lines · Kees Cook

This replaces the 1-element "fake" flexible array in struct hfi_session_release_buffer_pkt with a modern flexible array and adds the __counted_by annotation that was identified during the analysis.

Thanks!

-Kees

[...]

Applied to for-next/hardening, thanks!

[1/2] media: venus: hfi_cmds: struct hfi_session_release_buffer_pkt: Replace 1-element array with flexible array

      https://git.kernel.org/kees/c/c93452777f53
[2/2] media: venus: hfi_cmds: struct hfi_session_release_buffer_pkt: Add __counted_by annotation
      https://git.kernel.org/kees/c/32ef4b710cbe

Take care,

Signature · 1 line
Kees Cook