Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2039998pxb; Mon, 12 Apr 2021 12:42:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMLXy6FXsGnNjKGt/oWfoERCoCUNghSpqxk79b2H0L6MiRdA+73Ym/s2oCsz0g7SShbOor X-Received: by 2002:a17:906:1e8e:: with SMTP id e14mr29135095ejj.399.1618256535471; Mon, 12 Apr 2021 12:42:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618256535; cv=none; d=google.com; s=arc-20160816; b=SbXDKUO3OmrIc49Au+9UL5XgY9TrYh9eaTFlzk0JAnYU6k8Ume+H/peOW+f3T5nKM6 dVR8wPm0gwUgDBKUczFozq5w7Z2rKzrDvMB4BOS3NMQe5vKLfn3UM5SJl+fdbQ9wjeqC BFpezs7wosW6KqqLwynBqd23WBtOp8jEW4tZDh+R2gApmJEbPtCz0HIj9Z00CXUmN/cq eJ/Jg8lknCd+IdB/DZSkTc2hyUsXpaQrADoebqHvRa2cbskogUDD1yJnl26bNs/VidXc MAxhsuYJ/28H7nYVfHh4DFZ9l13d5Hv+iljNIXVQzgRHlm79U+kqgdKrYNKvPhPel53t buEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=B9oHIvkXrquVmA3PsFRsrFIOgcgu5ZiprCh3R3Vq6Ko=; b=CiUEvwniKHA7EAtTozIkI+rcdALqHzfxf+pcKiNt2IrOYWOeTp7+HXXFskZvLd+nK7 08X0bq4xF7PbNzuSz/MnlGlwqzy8BkYQx0X4Snsm4t4WI7cCi/pt8FUD026ABbWdPG+a ymv9WwlOKbaieIH/s5NFEIRpO190YCVcfJ84PqmgCXa0Dt3hXYzA+H+euWRPvWOWKlvV GVuZ3Krn+FXq9bvOEkPX9Z41JO96PYIaOjZAgrOPmS91t53r7cefh1/V9DjUOJ0e+wIc /XcBwgtsWXewg5rvXObP18B4ixYSc7st74E5ap4wXcQfO3kzORQsxJa2cDrKpgXD5LGC +mCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yisBDrgt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g12si8110823eds.274.2021.04.12.12.41.51; Mon, 12 Apr 2021 12:42:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yisBDrgt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237564AbhDLIq3 (ORCPT + 99 others); Mon, 12 Apr 2021 04:46:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:37746 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237733AbhDLIpT (ORCPT ); Mon, 12 Apr 2021 04:45:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DBFEF60241; Mon, 12 Apr 2021 08:45:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618217101; bh=EvXScd5g8HMt6o/FKz8nYJ7vsp83HBpWwfqwm6F4ICQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yisBDrgtMjSPloHKmRP50dU/hYaXVn3RyiKlWrj3Ps3TgqbvQ6fwHxEJAwRd/plX+ k53BpC0gSD8OGyrm0BbK1LV6Kkk2xIZnuTHk4iOfGqA9oO85zXugNZE7RYzzj5kAVN pnVRbCkQFd22H8HtkbMquLhGKa8AbEJKVfgdQiDE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , syzbot , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 36/66] sch_red: fix off-by-one checks in red_check_params() Date: Mon, 12 Apr 2021 10:40:42 +0200 Message-Id: <20210412083959.287168902@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412083958.129944265@linuxfoundation.org> References: <20210412083958.129944265@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Dumazet [ Upstream commit 3a87571f0ffc51ba3bf3ecdb6032861d0154b164 ] This fixes following syzbot report: UBSAN: shift-out-of-bounds in ./include/net/red.h:237:23 shift exponent 32 is too large for 32-bit type 'unsigned int' CPU: 1 PID: 8418 Comm: syz-executor170 Not tainted 5.12.0-rc4-next-20210324-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:79 [inline] dump_stack+0x141/0x1d7 lib/dump_stack.c:120 ubsan_epilogue+0xb/0x5a lib/ubsan.c:148 __ubsan_handle_shift_out_of_bounds.cold+0xb1/0x181 lib/ubsan.c:327 red_set_parms include/net/red.h:237 [inline] choke_change.cold+0x3c/0xc8 net/sched/sch_choke.c:414 qdisc_create+0x475/0x12f0 net/sched/sch_api.c:1247 tc_modify_qdisc+0x4c8/0x1a50 net/sched/sch_api.c:1663 rtnetlink_rcv_msg+0x44e/0xad0 net/core/rtnetlink.c:5553 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2502 netlink_unicast_kernel net/netlink/af_netlink.c:1312 [inline] netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1338 netlink_sendmsg+0x856/0xd90 net/netlink/af_netlink.c:1927 sock_sendmsg_nosec net/socket.c:654 [inline] sock_sendmsg+0xcf/0x120 net/socket.c:674 ____sys_sendmsg+0x6e8/0x810 net/socket.c:2350 ___sys_sendmsg+0xf3/0x170 net/socket.c:2404 __sys_sendmsg+0xe5/0x1b0 net/socket.c:2433 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x43f039 Code: 28 c3 e8 2a 14 00 00 66 2e 0f 1f 84 00 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007ffdfa725168 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 0000000000400488 RCX: 000000000043f039 RDX: 0000000000000000 RSI: 0000000020000040 RDI: 0000000000000004 RBP: 0000000000403020 R08: 0000000000400488 R09: 0000000000400488 R10: 0000000000400488 R11: 0000000000000246 R12: 00000000004030b0 R13: 0000000000000000 R14: 00000000004ac018 R15: 0000000000400488 Fixes: 8afa10cbe281 ("net_sched: red: Avoid illegal values") Signed-off-by: Eric Dumazet Reported-by: syzbot Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- include/net/red.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/net/red.h b/include/net/red.h index 8fe55b8b2fb8..ff07a7cedf68 100644 --- a/include/net/red.h +++ b/include/net/red.h @@ -171,9 +171,9 @@ static inline void red_set_vars(struct red_vars *v) static inline bool red_check_params(u32 qth_min, u32 qth_max, u8 Wlog, u8 Scell_log, u8 *stab) { - if (fls(qth_min) + Wlog > 32) + if (fls(qth_min) + Wlog >= 32) return false; - if (fls(qth_max) + Wlog > 32) + if (fls(qth_max) + Wlog >= 32) return false; if (Scell_log >= 32) return false; -- 2.30.2