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=ham 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 1C3FCC4CED1 for ; Thu, 3 Oct 2019 16:15:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DE85D20700 for ; Thu, 3 Oct 2019 16:15:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570119354; bh=W4X8vXVHEFPFQSTdvRznwhMJHRc36QiMXlnVAAWFoUk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=EDBFq3rfcWRWxKAz9JQ5C19ou3JeGrrGNHVYgx6BMZv7/WapY9Mx63D+bZPA7oVui O+PoRQtWi3nsW60MgNWUynXrXZjkIjUb11LNMwDWksCZXZuopvutefprkotz2HhQAV KWdPeB4rWBovZYeFHoobHxBP9k38MfO5RgkKtMk8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388868AbfJCQPw (ORCPT ); Thu, 3 Oct 2019 12:15:52 -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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 },