Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4091732pxb; Mon, 8 Feb 2021 07:45:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJyuwbbGlnvQGD8LsZAQ1lWxjtOdcSrjyRZJmHYiPNAPL0B21x0Da5P82LxXbdUmMBEirJPL X-Received: by 2002:a17:906:e104:: with SMTP id gj4mr17358352ejb.349.1612799143445; Mon, 08 Feb 2021 07:45:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612799143; cv=none; d=google.com; s=arc-20160816; b=ENWGM13nzVzJ2ABM9FMxF9lgdOC9TVLt8tJtMNWz6EMLawthzclaQUDuVmKE8Pq0gv cOrxwd2h9j7mY7zt1AEFbwz6K0ER56ZSBkMb+9KX2EXIdYXClrXKvHRAEc+i3YhalLLP n/2xGYpAxahDFkQndLSDA+pSWR9/1hEC3dx7Koz1NqSEudE/kZYAuO6bKsuRpD3fMSJz od/iIDGwKX1E+vkz4BtaYgHrh3orLUXQNHgOuj+wfkiSpiZQqjg7jteoaIGMDaBhK5CM 08YOKLFec5/Om44DkvRfTd8dmIt6g08XSFrLH9WE9YdGMe9vzuqyywEJKRwqqqtG5Zgg Tb/Q== 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=1/0YBSlnh2xrRAoBSZYQBUOUTqxnhiCFZ3Ou6P9L3Ck=; b=Me7kVAvc2KZWb25e5viYmzUWQUpIWKOmdRPM+hQ0y9ppz6lumCTVPEuvADrDDhKUEY r/2xKQoqGjXgRSqP5DCpaQk+se903Zljg9+Rvt4GPIYJTMPgLQNC+FNJAIIXxImKIGKB bDHxolwGG5jXqo+FmWH5u5fYQ7sWOYcFZ0rHVjvq2oIOqY0aFT+jbCufynL4JDrzU5tV pdsOjbypvAkbEE0JTtnO1O/D47i2RVo4Xjujelmw7/VLI5q0y0+VU42T0ZoEmh5ZQ8e3 WDgs1yeu9S9POc7m0M1BMyMCxRXz8WBKK+WhQW+KvCZY1VWq3IeXHL/w2UKm32GXWuMT B5ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=t9vRUKyI; 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 f7si14702948edd.343.2021.02.08.07.45.19; Mon, 08 Feb 2021 07:45:43 -0800 (PST) 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=t9vRUKyI; 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 S234119AbhBHPmo (ORCPT + 99 others); Mon, 8 Feb 2021 10:42:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:52606 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231929AbhBHPF6 (ORCPT ); Mon, 8 Feb 2021 10:05:58 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0611064ED3; Mon, 8 Feb 2021 15:04:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612796669; bh=N9Eqn0l5ZRmlnndfynirlS5F+CtRRs3NmT7NYOisCjU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t9vRUKyITtDzYC+4r6rA4OYr6M1iDmK7RnyO90UiOem3pv4Cy0EivxzEeKMQA839g uH7Hddc5cfvHMlLj3Mdhars26WCRqUfNRbJG4mLMFdFNbbrTYE/WRJXMQTibbP17Y6 HZYPr46x+ZgV/DrUV/8LXMw6fy/SLf2dTjOSq9K0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , syzbot , Cong Wang , Jakub Kicinski , Sudip Mukherjee Subject: [PATCH 4.9 03/43] net_sched: reject silly cell_log in qdisc_get_rtab() Date: Mon, 8 Feb 2021 16:00:29 +0100 Message-Id: <20210208145806.421469570@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208145806.281758651@linuxfoundation.org> References: <20210208145806.281758651@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 commit e4bedf48aaa5552bc1f49703abd17606e7e6e82a upstream iproute2 probably never goes beyond 8 for the cell exponent, but stick to the max shift exponent for signed 32bit. UBSAN reported: UBSAN: shift-out-of-bounds in net/sched/sch_api.c:389:22 shift exponent 130 is too large for 32-bit type 'int' CPU: 1 PID: 8450 Comm: syz-executor586 Not tainted 5.11.0-rc3-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+0x183/0x22e lib/dump_stack.c:120 ubsan_epilogue lib/ubsan.c:148 [inline] __ubsan_handle_shift_out_of_bounds+0x432/0x4d0 lib/ubsan.c:395 __detect_linklayer+0x2a9/0x330 net/sched/sch_api.c:389 qdisc_get_rtab+0x2b5/0x410 net/sched/sch_api.c:435 cbq_init+0x28f/0x12c0 net/sched/sch_cbq.c:1180 qdisc_create+0x801/0x1470 net/sched/sch_api.c:1246 tc_modify_qdisc+0x9e3/0x1fc0 net/sched/sch_api.c:1662 rtnetlink_rcv_msg+0xb1d/0xe60 net/core/rtnetlink.c:5564 netlink_rcv_skb+0x1f0/0x460 net/netlink/af_netlink.c:2494 netlink_unicast_kernel net/netlink/af_netlink.c:1304 [inline] netlink_unicast+0x7de/0x9b0 net/netlink/af_netlink.c:1330 netlink_sendmsg+0xaa6/0xe90 net/netlink/af_netlink.c:1919 sock_sendmsg_nosec net/socket.c:652 [inline] sock_sendmsg net/socket.c:672 [inline] ____sys_sendmsg+0x5a2/0x900 net/socket.c:2345 ___sys_sendmsg net/socket.c:2399 [inline] __sys_sendmsg+0x319/0x400 net/socket.c:2432 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Eric Dumazet Reported-by: syzbot Acked-by: Cong Wang Link: https://lore.kernel.org/r/20210114160637.1660597-1-eric.dumazet@gmail.com Signed-off-by: Jakub Kicinski [sudip: adjust context] Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- net/sched/sch_api.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -393,7 +393,8 @@ struct qdisc_rate_table *qdisc_get_rtab( { struct qdisc_rate_table *rtab; - if (tab == NULL || r->rate == 0 || r->cell_log == 0 || + if (tab == NULL || r->rate == 0 || + r->cell_log == 0 || r->cell_log >= 32 || nla_len(tab) != TC_RTAB_SIZE) return NULL;