Message ID | 20210816111333.GE7722@kadam (mailing list archive) |
---|---|
State | Accepted |
Commit | 4f3f2e3fa0431b93745b110da1c365806c5acce3 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [v2,net] net: iosm: Prevent underflow in ipc_chnl_cfg_get() | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | fail | Series targets non-next tree, but doesn't contain any Fixes tags |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | success | CCed 8 of 8 maintainers |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 13 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
> -----Original Message----- > From: Dan Carpenter <dan.carpenter@oracle.com> > Sent: Monday, August 16, 2021 4:44 PM > To: Kumar, M Chetan <m.chetan.kumar@intel.com>; Solomon Ucko > <solly.ucko@gmail.com> > Cc: linuxwwan <linuxwwan@intel.com>; Loic Poulain > <loic.poulain@linaro.org>; Sergey Ryazanov <ryazanov.s.a@gmail.com>; > Johannes Berg <johannes@sipsolutions.net>; David S. Miller > <davem@davemloft.net>; Jakub Kicinski <kuba@kernel.org>; > netdev@vger.kernel.org; security@kernel.org > Subject: [PATCH v2 net] net: iosm: Prevent underflow in ipc_chnl_cfg_get() > > The bounds check on "index" doesn't catch negative values. Using > ARRAY_SIZE() directly is more readable and more robust because it prevents > negative values for "index". Fortunately we only pass valid values to > ipc_chnl_cfg_get() so this patch does not affect runtime. > > > Reported-by: Solomon Ucko <solly.ucko@gmail.com> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> > --- > v2: Remove underscore between "array" and "size". > Use %zu print format specifier to fix a compile warning on 32 bit. > > drivers/net/wwan/iosm/iosm_ipc_chnl_cfg.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) Reviewed-by: M Chetan Kumar <m.chetan.kumar@intel.com>
Hello: This patch was applied to netdev/net.git (refs/heads/master): On Mon, 16 Aug 2021 14:13:33 +0300 you wrote: > The bounds check on "index" doesn't catch negative values. Using > ARRAY_SIZE() directly is more readable and more robust because it prevents > negative values for "index". Fortunately we only pass valid values to > ipc_chnl_cfg_get() so this patch does not affect runtime. > > > Reported-by: Solomon Ucko <solly.ucko@gmail.com> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> > > [...] Here is the summary with links: - [v2,net] net: iosm: Prevent underflow in ipc_chnl_cfg_get() https://git.kernel.org/netdev/net/c/4f3f2e3fa043 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
diff --git a/drivers/net/wwan/iosm/iosm_ipc_chnl_cfg.c b/drivers/net/wwan/iosm/iosm_ipc_chnl_cfg.c index 804e6c4f2c78..016c9c3aea8e 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_chnl_cfg.c +++ b/drivers/net/wwan/iosm/iosm_ipc_chnl_cfg.c @@ -64,10 +64,9 @@ static struct ipc_chnl_cfg modem_cfg[] = { int ipc_chnl_cfg_get(struct ipc_chnl_cfg *chnl_cfg, int index) { - int array_size = ARRAY_SIZE(modem_cfg); - - if (index >= array_size) { - pr_err("index: %d and array_size %d", index, array_size); + if (index >= ARRAY_SIZE(modem_cfg)) { + pr_err("index: %d and array size %zu", index, + ARRAY_SIZE(modem_cfg)); return -ECHRNG; }
The bounds check on "index" doesn't catch negative values. Using ARRAY_SIZE() directly is more readable and more robust because it prevents negative values for "index". Fortunately we only pass valid values to ipc_chnl_cfg_get() so this patch does not affect runtime. Reported-by: Solomon Ucko <solly.ucko@gmail.com> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> --- v2: Remove underscore between "array" and "size". Use %zu print format specifier to fix a compile warning on 32 bit. drivers/net/wwan/iosm/iosm_ipc_chnl_cfg.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)