diff mbox series

net: sched: fix warning in tcindex_alloc_perfect_hash

Message ID 20210625202348.24560-1-paskripkin@gmail.com (mailing list archive)
State Accepted
Commit 3f2db250099f46988088800052cdf2332c7aba61
Delegated to: Netdev Maintainers
Headers show
Series net: sched: fix warning in tcindex_alloc_perfect_hash | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cc_maintainers warning 1 maintainers not CCed: kuba@kernel.org
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, 8 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Pavel Skripkin June 25, 2021, 8:23 p.m. UTC
Syzbot reported warning in tcindex_alloc_perfect_hash. The problem
was in too big cp->hash, which triggers warning in kmalloc. Since
cp->hash comes from userspace, there is no need to warn if value
is not correct

Fixes: b9a24bb76bf6 ("net_sched: properly handle failure case of tcf_exts_init()")
Reported-and-tested-by: syzbot+1071ad60cd7df39fdadb@syzkaller.appspotmail.com
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
---
 net/sched/cls_tcindex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Cong Wang June 27, 2021, 6:22 p.m. UTC | #1
On Fri, Jun 25, 2021 at 1:23 PM Pavel Skripkin <paskripkin@gmail.com> wrote:
>
> Syzbot reported warning in tcindex_alloc_perfect_hash. The problem
> was in too big cp->hash, which triggers warning in kmalloc. Since
> cp->hash comes from userspace, there is no need to warn if value
> is not correct
>
> Fixes: b9a24bb76bf6 ("net_sched: properly handle failure case of tcf_exts_init()")
> Reported-and-tested-by: syzbot+1071ad60cd7df39fdadb@syzkaller.appspotmail.com
> Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>

Looks reasonable.

Acked-by: Cong Wang <cong.wang@bytedance.com>

Thanks.
patchwork-bot+netdevbpf@kernel.org June 28, 2021, 8:10 p.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Fri, 25 Jun 2021 23:23:48 +0300 you wrote:
> Syzbot reported warning in tcindex_alloc_perfect_hash. The problem
> was in too big cp->hash, which triggers warning in kmalloc. Since
> cp->hash comes from userspace, there is no need to warn if value
> is not correct
> 
> Fixes: b9a24bb76bf6 ("net_sched: properly handle failure case of tcf_exts_init()")
> Reported-and-tested-by: syzbot+1071ad60cd7df39fdadb@syzkaller.appspotmail.com
> Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
> 
> [...]

Here is the summary with links:
  - net: sched: fix warning in tcindex_alloc_perfect_hash
    https://git.kernel.org/netdev/net/c/3f2db250099f

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c
index c4007b9cd16d..5b274534264c 100644
--- a/net/sched/cls_tcindex.c
+++ b/net/sched/cls_tcindex.c
@@ -304,7 +304,7 @@  static int tcindex_alloc_perfect_hash(struct net *net, struct tcindex_data *cp)
 	int i, err = 0;
 
 	cp->perfect = kcalloc(cp->hash, sizeof(struct tcindex_filter_result),
-			      GFP_KERNEL);
+			      GFP_KERNEL | __GFP_NOWARN);
 	if (!cp->perfect)
 		return -ENOMEM;