Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2064447pxb; Mon, 12 Apr 2021 13:23:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgvNFegob+74RdF7RgkLD3NlmeR3SjQ8oYt3x7prunEYDW0E/az1hALh29tRR4b11P7+jK X-Received: by 2002:aa7:d3d5:: with SMTP id o21mr27756542edr.183.1618258988330; Mon, 12 Apr 2021 13:23:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618258988; cv=none; d=google.com; s=arc-20160816; b=EYaXEZbFHMs+ebEJreQVhL1F0os3U/5zAdisc7lJvh8q+9S5yMOfxiq1V0j+jU9x7V HBajgTwOj4c8Av/6DAwNVRbvZt2iG7WwzjNWbyOjn+JYI1Td3dF9qhJ2kC1Ggwb28KLP w8+pXaXXTFosGGOFlf9A11/BYKNWYT583sQV4vOT+ZNnV/Hv183wCkLH/Ibj+/AOVoba gBL25AfTeeJ4pqYHKKTPu5ClwfXUbyudkDj3ub5Xpk5z2JY3xxg0w8n72GPFbQlNaBkP aceBcMVmL9a9XTewaN/wsV+sNHP/N+QwHsSoSkC/eYoyvt9ZiQZwCn+ibZ6acje1utTV P1ig== 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=OTlBZsvSjRn/gMF75FJJ0Dxi8AeKxLP4mnoWKsdpPvRzC8kiYCQXnHij2a6Jx6D19A Vg8a4ZcswoSlS7n2ffZFKSA75QEKXgCFfM9LvPYJI9XhHOKz/0hqGoZ/Bt6dbR5WyzAr /efRm4QWkZH5Q3tm9KKTldXAXJRmNjDcng7RYY8uIkNPk1WOY1NrLywRTajR1a+P/4Vo igpZogUycmmk8pUAQErVdblZqkyAkgu3/6sx8r+ES54YkidlEYhWmIljB+4V7/PHPFXL Ehd9xW13FHGboIXM1fPmugn4WgHm/3GTyyUjcj/m+ipl6hKM98Zsoi6xgA5k8VstDTut pnnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EKQWCXvq; 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 s21si7452562ejm.689.2021.04.12.13.22.44; Mon, 12 Apr 2021 13:23:08 -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=EKQWCXvq; 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 S238272AbhDLI4a (ORCPT + 99 others); Mon, 12 Apr 2021 04:56:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:39448 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238473AbhDLIt4 (ORCPT ); Mon, 12 Apr 2021 04:49:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E47D361261; Mon, 12 Apr 2021 08:49:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618217349; bh=EvXScd5g8HMt6o/FKz8nYJ7vsp83HBpWwfqwm6F4ICQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EKQWCXvqUIriTiCZSEaCTp1oU+xCiSvNa30TcLzh3y6xuPhlSA1izFUk7Ho78zvbM RFdAoEWWRfBhdZ2T6mLyQxLMWgyjSNhjH8+MGV1N9Uk8lIeNJLyzqb+gXm3VHC93xA c9572Hx/an53nOiJzOMovmDPMmanhHKuqH+/8ank= 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 5.4 058/111] sch_red: fix off-by-one checks in red_check_params() Date: Mon, 12 Apr 2021 10:40:36 +0200 Message-Id: <20210412084006.196722308@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412084004.200986670@linuxfoundation.org> References: <20210412084004.200986670@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