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=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_SBL,URIBL_SBL_A,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 65795C47404 for ; Mon, 7 Oct 2019 20:27:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 38450206C0 for ; Mon, 7 Oct 2019 20:27:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sSzbJ7UL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729082AbfJGU1D (ORCPT ); Mon, 7 Oct 2019 16:27:03 -0400 Received: from mail-pg1-f169.google.com ([209.85.215.169]:41903 "EHLO mail-pg1-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728212AbfJGU1C (ORCPT ); Mon, 7 Oct 2019 16:27:02 -0400 Received: by mail-pg1-f169.google.com with SMTP id t3so3062467pga.8 for ; Mon, 07 Oct 2019 13:27:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2iYngEvnZDmzD/znQk3fm2VIAdjMXrMKfM+x4TqLNis=; b=sSzbJ7ULIOYy0Xu1wExNyYL3IhN+L/eN7UyWBu61brX3FdAoQxwhv9+GFNaus919Nh 8trWYAw3aGuqeyjXg1GjotVMObWEx0+qtHehaaU323PZB4VcseuKfCMHZp/9IUq1m4h4 +1GLE8sHDnh/YW2VIg4QjzrudNms7/MSP3PleVGHjdz5vbWDCWnYFIOe86IxsOj8FbZP B6HYy1j4c1x2y/2QiEjynRjgVf6lqd9kYcm3lqwNrxCh90x4QT4vPH+Bvm2U57KBGgI8 /oKplWzNsVdlWPizM5IhtIe6LbGleqvhDsQ/RT2mrYQC2YZUKGA8UUJA457kU148l5nQ dFNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2iYngEvnZDmzD/znQk3fm2VIAdjMXrMKfM+x4TqLNis=; b=mjVuQcBUr+qGuffIw6McXjblAXQKL07BK1S/JxA4e2k3CgfNSBAVPUtAl+VahDjaSq OeFCpHGwadGU87sqKWAR25r0mDumIzyF7LXjzNI6Qc53vMOOxh3Y7FqQj5tDT8/O7pnc AqWMd8wXQudXiMqIRjCD/mH9vNukkWqiicAMaDO1RHueVoULpFK7ZtE2YxjbR4ilBiCS Bm/dY78FvBdHSZHdorSMqfDP8/ywGQEr2gsHpsB0WAliSfqQNPbCHP5coa7l/j3220HT gdVf9QjoI6a5R6iuHDy/cmYK3fIxRfTKKKGLbBRTyax3LQjq6fNfqGPk9ycYI6/jD5w0 EeXg== X-Gm-Message-State: APjAAAW2IlZbQP2oxH4+i273IuiG1I1XQcMnl105IzOqI8c/K9aQ9Z4h yAXEI/KwqqxfRhoRvGk/7RGdleOh X-Google-Smtp-Source: APXvYqxquy5mUWSY9TTAGrPIhK1IoNnW6l3FLRpz/+lSggeCkCIecH7uUQ0uZ5t+OKabzS/BnEnRYw== X-Received: by 2002:a63:1002:: with SMTP id f2mr18692403pgl.84.1570480021756; Mon, 07 Oct 2019 13:27:01 -0700 (PDT) Received: from tw-172-25-31-76.office.twttr.net ([8.25.197.24]) by smtp.gmail.com with ESMTPSA id k8sm12679602pgm.14.2019.10.07.13.27.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 13:27:01 -0700 (PDT) From: Cong Wang To: netdev@vger.kernel.org Cc: Cong Wang , Marcelo Ricardo Leitner , Jamal Hadi Salim , Jiri Pirko Subject: [Patch net] net_sched: fix backward compatibility for TCA_ACT_KIND Date: Mon, 7 Oct 2019 13:26:29 -0700 Message-Id: <20191007202629.32462-2-xiyou.wangcong@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org For TCA_ACT_KIND, we have to keep the backward compatibility too, and rely on nla_strlcpy() to check and terminate the string with a NUL. Note for TC actions, nla_strcmp() is already used to compare kind strings, so we don't need to fix other places. Fixes: 199ce850ce11 ("net_sched: add policy validation for action attributes") Reported-by: Marcelo Ricardo Leitner Cc: Jamal Hadi Salim Cc: Jiri Pirko Signed-off-by: Cong Wang --- net/sched/act_api.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/net/sched/act_api.c b/net/sched/act_api.c index da99667589f8..4684f2f24b17 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -832,8 +832,7 @@ static struct tc_cookie *nla_memdup_cookie(struct nlattr **tb) } static const struct nla_policy tcf_action_policy[TCA_ACT_MAX + 1] = { - [TCA_ACT_KIND] = { .type = NLA_NUL_STRING, - .len = IFNAMSIZ - 1 }, + [TCA_ACT_KIND] = { .type = NLA_STRING }, [TCA_ACT_INDEX] = { .type = NLA_U32 }, [TCA_ACT_COOKIE] = { .type = NLA_BINARY, .len = TC_COOKIE_MAX_SIZE }, @@ -865,8 +864,10 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, NL_SET_ERR_MSG(extack, "TC action kind must be specified"); goto err_out; } - nla_strlcpy(act_name, kind, IFNAMSIZ); - + if (nla_strlcpy(act_name, kind, IFNAMSIZ) >= IFNAMSIZ) { + NL_SET_ERR_MSG(extack, "TC action name too long"); + goto err_out; + } if (tb[TCA_ACT_COOKIE]) { cookie = nla_memdup_cookie(tb); if (!cookie) { -- 2.21.0