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 38537C10F14 for ; Thu, 3 Oct 2019 16:39:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1095720830 for ; Thu, 3 Oct 2019 16:39:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570120773; bh=/aWRxZsB9K/yMyjiaf4ASpJt4T0jT1xNzIVu/vT4QAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ZWhnAApaz34JSd2lObwxbZx95UZWgLZcDEkM3VolV8WkYk109dN9F5r2QSwPgYbHC 7rybb6sYgW1y1MEpeIlJb7/IA/yuRNMnfgdVdVf7jzUHA2nGuGDQV654eGAMSsekKY AM08J8gtxpBZx7w3TxitZA2/5cDcmcAl7Jkf6VTk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404840AbfJCQjc (ORCPT ); Thu, 3 Oct 2019 12:39:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:49460 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404349AbfJCQja (ORCPT ); Thu, 3 Oct 2019 12:39:30 -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 328142070B; Thu, 3 Oct 2019 16:39:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570120769; bh=/aWRxZsB9K/yMyjiaf4ASpJt4T0jT1xNzIVu/vT4QAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v9Uzt0UnuFMNmBT8pghIZ9XgYtYDjZ80/q6wWe2RrRV8bYjEdxYiek/ptkipAdIky s4lJC56vJbGuVirnlh7L/F3+NrWh8B69AAvkbhH34en3fFZmTBqOwBJGXm8l7LRezh ESICSMKwSdKm/e650QSI6f1I5Zp8SL+Y4aN0dFl8= 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 5.3 008/344] net_sched: add max len check for TCA_KIND Date: Thu, 3 Oct 2019 17:49:33 +0200 Message-Id: <20191003154540.905814353@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154540.062170222@linuxfoundation.org> References: <20191003154540.062170222@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 @@ -1390,7 +1390,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 },