From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C40EAC10F14 for ; Thu, 3 Oct 2019 17:26:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 91FE120830 for ; Thu, 3 Oct 2019 17:26:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570123596; bh=W4X8vXVHEFPFQSTdvRznwhMJHRc36QiMXlnVAAWFoUk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=wmy+0wJIAan039ge9SLZZqSS4cGKsLOCSe3KXSq9Xnxaw0Yl4nu4a7fg0/IqTNv/9 Ksyz5uCvRq9THgwjfB1rZf/ex4QcmoTmjpgJSwdm0LUUQ4hvuFPIX+BKEUWOn6HlfH 3YqBYL4gj21qhSLSl2j9kIxaLgzCAXR4fSX8lv1Q= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387863AbfJCQPv (ORCPT ); Thu, 3 Oct 2019 12:15:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:40220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732566AbfJCQPu (ORCPT ); Thu, 3 Oct 2019 12:15:50 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EC56F2054F; Thu, 3 Oct 2019 16:15:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570119349; bh=W4X8vXVHEFPFQSTdvRznwhMJHRc36QiMXlnVAAWFoUk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2sd8/vwTnmwIGwMEB5fTh4qjP797uKLWbTKRw6tXipVC0Ilk/El0HlCdd0pPwFERf LsEH5W+slu6/QrKsb7Td77ubB5M8bO/YLw9OenKbNpkhW8+WHHm0RDN/vph6BUSG73 iPPMQtjsUpbVaZMPVRshEH3j8sDbNB0bUjwI7qyM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jamal Hadi Salim , Cong Wang , David Ahern , Jiri Pirko , Jakub Kicinski , syzbot+618aacd49e8c8b8486bd@syzkaller.appspotmail.com Subject: [PATCH 4.19 007/211] net_sched: add max len check for TCA_KIND Date: Thu, 3 Oct 2019 17:51:13 +0200 Message-Id: <20191003154448.932834647@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154447.010950442@linuxfoundation.org> References: <20191003154447.010950442@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Cong Wang [ Upstream commit 62794fc4fbf52f2209dc094ea255eaef760e7d01 ] The TCA_KIND attribute is of NLA_STRING which does not check the NUL char. KMSAN reported an uninit-value of TCA_KIND which is likely caused by the lack of NUL. Change it to NLA_NUL_STRING and add a max len too. Fixes: 8b4c3cdd9dd8 ("net: sched: Add policy validation for tc attributes") Reported-and-tested-by: syzbot+618aacd49e8c8b8486bd@syzkaller.appspotmail.com Cc: Jamal Hadi Salim Signed-off-by: Cong Wang Reviewed-by: David Ahern Acked-by: Jiri Pirko Signed-off-by: Jakub Kicinski 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 @@ -1308,7 +1308,8 @@ check_loop_fn(struct Qdisc *q, unsigned } const struct nla_policy rtm_tca_policy[TCA_MAX + 1] = { - [TCA_KIND] = { .type = NLA_STRING }, + [TCA_KIND] = { .type = NLA_NUL_STRING, + .len = IFNAMSIZ - 1 }, [TCA_RATE] = { .type = NLA_BINARY, .len = sizeof(struct tc_estimator) }, [TCA_STAB] = { .type = NLA_NESTED },