* [PATCH net-next] wwan: iosm: use a flexible array rather than allocate short objects
@ 2022-05-20 6:00 Jakub Kicinski
2022-05-20 6:03 ` Jakub Kicinski
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Jakub Kicinski @ 2022-05-20 6:00 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, Jakub Kicinski, m.chetan.kumar,
linuxwwan, loic.poulain, ryazanov.s.a, johannes
GCC array-bounds warns that ipc_coredump_get_list() under-allocates
the size of struct iosm_cd_table *cd_table.
This is avoidable - we just need a flexible array. Nothing calls
sizeof() on struct iosm_cd_list or anything that contains it.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: m.chetan.kumar@intel.com
CC: linuxwwan@intel.com
CC: loic.poulain@linaro.org
CC: ryazanov.s.a@gmail.com
CC: johannes@sipsolutions.net
---
drivers/net/wwan/iosm/iosm_ipc_coredump.h | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/net/wwan/iosm/iosm_ipc_coredump.h b/drivers/net/wwan/iosm/iosm_ipc_coredump.h
index 0809ba664276..3da5ec75e0f0 100644
--- a/drivers/net/wwan/iosm/iosm_ipc_coredump.h
+++ b/drivers/net/wwan/iosm/iosm_ipc_coredump.h
@@ -14,9 +14,6 @@
/* Max buffer allocated to receive coredump data */
#define MAX_DATA_SIZE 0x00010000
-/* Max number of file entries */
-#define MAX_NOF_ENTRY 256
-
/* Max length */
#define MAX_SIZE_LEN 32
@@ -38,7 +35,7 @@ struct iosm_cd_list_entry {
*/
struct iosm_cd_list {
__le32 num_entries;
- struct iosm_cd_list_entry entry[MAX_NOF_ENTRY];
+ struct iosm_cd_list_entry entry[];
} __packed;
/**
--
2.34.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] wwan: iosm: use a flexible array rather than allocate short objects
2022-05-20 6:00 [PATCH net-next] wwan: iosm: use a flexible array rather than allocate short objects Jakub Kicinski
@ 2022-05-20 6:03 ` Jakub Kicinski
2022-05-20 18:12 ` Kumar, M Chetan
2022-05-20 18:13 ` Kumar, M Chetan
2022-05-21 1:10 ` patchwork-bot+netdevbpf
2 siblings, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2022-05-20 6:03 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, m.chetan.kumar, linuxwwan, loic.poulain,
ryazanov.s.a, johannes
On Thu, 19 May 2022 23:00:13 -0700 Jakub Kicinski wrote:
> GCC array-bounds warns that ipc_coredump_get_list() under-allocates
> the size of struct iosm_cd_table *cd_table.
>
> This is avoidable - we just need a flexible array. Nothing calls
> sizeof() on struct iosm_cd_list or anything that contains it.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Coincidentally IDK if this:
int ipc_coredump_get_list(struct iosm_devlink *devlink, u16 cmd)
if (byte_read != MAX_CD_LIST_SIZE)
goto cd_init_fail;
shouldn't set ret before jumping? Maybe set it to 0 if it's okay for
it to be zero to make that clear?
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH net-next] wwan: iosm: use a flexible array rather than allocate short objects
2022-05-20 6:03 ` Jakub Kicinski
@ 2022-05-20 18:12 ` Kumar, M Chetan
0 siblings, 0 replies; 5+ messages in thread
From: Kumar, M Chetan @ 2022-05-20 18:12 UTC (permalink / raw)
To: Jakub Kicinski, davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
linuxwwan, loic.poulain@linaro.org, ryazanov.s.a@gmail.com,
johannes@sipsolutions.net
> -----Original Message-----
> From: Jakub Kicinski <kuba@kernel.org>
> Sent: Friday, May 20, 2022 11:34 AM
> To: davem@davemloft.net
> Cc: netdev@vger.kernel.org; edumazet@google.com; pabeni@redhat.com;
> Kumar, M Chetan <m.chetan.kumar@intel.com>; linuxwwan
> <linuxwwan@intel.com>; loic.poulain@linaro.org; ryazanov.s.a@gmail.com;
> johannes@sipsolutions.net
> Subject: Re: [PATCH net-next] wwan: iosm: use a flexible array rather than
> allocate short objects
>
> On Thu, 19 May 2022 23:00:13 -0700 Jakub Kicinski wrote:
> > GCC array-bounds warns that ipc_coredump_get_list() under-allocates
> > the size of struct iosm_cd_table *cd_table.
> >
> > This is avoidable - we just need a flexible array. Nothing calls
> > sizeof() on struct iosm_cd_list or anything that contains it.
> >
> > Signed-off-by: Jakub Kicinski <kuba@kernel.org>
>
> Coincidentally IDK if this:
>
> int ipc_coredump_get_list(struct iosm_devlink *devlink, u16 cmd)
>
> if (byte_read != MAX_CD_LIST_SIZE)
> goto cd_init_fail;
>
> shouldn't set ret before jumping? Maybe set it to 0 if it's okay for it to be zero
> to make that clear?
This is a redundant check we can remove it.
If the byte_read is less than MAX_CD_LIST_SIZE an error is returned as part of previous ret
check.
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH net-next] wwan: iosm: use a flexible array rather than allocate short objects
2022-05-20 6:00 [PATCH net-next] wwan: iosm: use a flexible array rather than allocate short objects Jakub Kicinski
2022-05-20 6:03 ` Jakub Kicinski
@ 2022-05-20 18:13 ` Kumar, M Chetan
2022-05-21 1:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: Kumar, M Chetan @ 2022-05-20 18:13 UTC (permalink / raw)
To: Jakub Kicinski, davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
linuxwwan, loic.poulain@linaro.org, ryazanov.s.a@gmail.com,
johannes@sipsolutions.net
> -----Original Message-----
> From: Jakub Kicinski <kuba@kernel.org>
> Sent: Friday, May 20, 2022 11:30 AM
> To: davem@davemloft.net
> Cc: netdev@vger.kernel.org; edumazet@google.com; pabeni@redhat.com;
> Jakub Kicinski <kuba@kernel.org>; Kumar, M Chetan
> <m.chetan.kumar@intel.com>; linuxwwan <linuxwwan@intel.com>;
> loic.poulain@linaro.org; ryazanov.s.a@gmail.com;
> johannes@sipsolutions.net
> Subject: [PATCH net-next] wwan: iosm: use a flexible array rather than
> allocate short objects
>
> GCC array-bounds warns that ipc_coredump_get_list() under-allocates the
> size of struct iosm_cd_table *cd_table.
>
> This is avoidable - we just need a flexible array. Nothing calls
> sizeof() on struct iosm_cd_list or anything that contains it.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: M Chetan Kumar <m.chetan.kumar@intel.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] wwan: iosm: use a flexible array rather than allocate short objects
2022-05-20 6:00 [PATCH net-next] wwan: iosm: use a flexible array rather than allocate short objects Jakub Kicinski
2022-05-20 6:03 ` Jakub Kicinski
2022-05-20 18:13 ` Kumar, M Chetan
@ 2022-05-21 1:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-05-21 1:10 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, m.chetan.kumar, linuxwwan,
loic.poulain, ryazanov.s.a, johannes
Hello:
This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 19 May 2022 23:00:13 -0700 you wrote:
> GCC array-bounds warns that ipc_coredump_get_list() under-allocates
> the size of struct iosm_cd_table *cd_table.
>
> This is avoidable - we just need a flexible array. Nothing calls
> sizeof() on struct iosm_cd_list or anything that contains it.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
>
> [...]
Here is the summary with links:
- [net-next] wwan: iosm: use a flexible array rather than allocate short objects
https://git.kernel.org/netdev/net-next/c/eac67d83bf25
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-05-21 1:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-20 6:00 [PATCH net-next] wwan: iosm: use a flexible array rather than allocate short objects Jakub Kicinski
2022-05-20 6:03 ` Jakub Kicinski
2022-05-20 18:12 ` Kumar, M Chetan
2022-05-20 18:13 ` Kumar, M Chetan
2022-05-21 1:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).