Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3324089imu; Sun, 11 Nov 2018 12:23:08 -0800 (PST) X-Google-Smtp-Source: AJdET5eyREk5jKtXdTnPKWXV7JBotsDhy7zyR4mShUo0/bKgIq7sCcs+R6Q+7OSjl+40HfyietLE X-Received: by 2002:a17:902:bc4c:: with SMTP id t12mr1196326plz.45.1541967788081; Sun, 11 Nov 2018 12:23:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541967788; cv=none; d=google.com; s=arc-20160816; b=NO9s2wQxsmsq06uiDh7zgbEPyb0F/38XZWPWIBOIgcKk/R6S3vEJbDdEs404lefMFF tf95xV0r1iDuKk29T5QF+09nFf1rx3mJl8+klevQIJBiCXdGlS04CbWFzHxG10rI2pnO h/J1EvXq5RjbwzuBxV3ERMvsRbTt99C75a+yhSSccQ2Au1E6ThwvhXkFYjpVc28MHoEf Xez/+pCqr98M6/g3VlODttmlX83ciYLYbPirTSfr+S2G9Tt8CYDHkTKC2Y4H4LZXnDOq AMlgxu0hDRCAV8LDWMjL/uyVv+VEkfwXYSmrBQtHCL/d3jDYm/kASy9koorKL7aNk58p 0VCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=2k/BBokF4kx1S67PGplO8uObJ7YAlwzkX8Ci2pfihtg=; b=ItFUggwxGIgYBQIDwPU9wbALjwRKMKqQp4YsrTpFr3fEEonZyx++jTCOOTK8Amg970 n1P5Oy/ZnkSsE7LJ7fpQT9MoRv1XoRkcPj1JHX33CPzU1xKN1QtUkNnQ83gfMhjPJStq 7X3OYwg79KO2a3StoRvFxMt+Hrn8JCyavNOudM3pN79b5C66hPxcNO7EZ2kC45OdORo1 1+mUciA86oYkA0seBuw/e/+jCz9lqVQeil4DZwxenEFO8afsISR5C9D0484PJx3MOYzt qX+85rYvW4+e6oYxQyscGfJaxBjwEAa5hEM+zEeEgMQjUDsI9v1fMFu+ceUld7w4uOa4 08RA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f184-v6si723294pfc.224.2018.11.11.12.22.53; Sun, 11 Nov 2018 12:23:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731809AbeKLGKE (ORCPT + 99 others); Mon, 12 Nov 2018 01:10:04 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:53508 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727357AbeKLGKD (ORCPT ); Mon, 12 Nov 2018 01:10:03 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvt2-0000oU-F5; Sun, 11 Nov 2018 19:59:12 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsR-0001XH-RK; Sun, 11 Nov 2018 19:58:35 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "David S. Miller" , "Davide Caratti" , "Simon Horman" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 129/366] net/sched: act_simple: fix parsing of TCA_DEF_DATA In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Davide Caratti commit 8d499533e0bc02d44283dbdab03142b599b8ba16 upstream. use nla_strlcpy() to avoid copying data beyond the length of TCA_DEF_DATA netlink attribute, in case it is less than SIMP_MAX_DATA and it does not end with '\0' character. v2: fix errors in the commit message, thanks Hangbin Liu Fixes: fa1b1cff3d06 ("net_cls_act: Make act_simple use of netlink policy.") Signed-off-by: Davide Caratti Reviewed-by: Simon Horman Signed-off-by: David S. Miller [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- --- a/net/sched/act_simple.c +++ b/net/sched/act_simple.c @@ -52,22 +52,22 @@ static void tcf_simp_release(struct tc_a kfree(d->tcfd_defdata); } -static int alloc_defdata(struct tcf_defact *d, char *defdata) +static int alloc_defdata(struct tcf_defact *d, const struct nlattr *defdata) { d->tcfd_defdata = kzalloc(SIMP_MAX_DATA, GFP_KERNEL); if (unlikely(!d->tcfd_defdata)) return -ENOMEM; - strlcpy(d->tcfd_defdata, defdata, SIMP_MAX_DATA); + nla_strlcpy(d->tcfd_defdata, defdata, SIMP_MAX_DATA); return 0; } -static void reset_policy(struct tcf_defact *d, char *defdata, +static void reset_policy(struct tcf_defact *d, const struct nlattr *defdata, struct tc_defact *p) { spin_lock_bh(&d->tcf_lock); d->tcf_action = p->action; memset(d->tcfd_defdata, 0, SIMP_MAX_DATA); - strlcpy(d->tcfd_defdata, defdata, SIMP_MAX_DATA); + nla_strlcpy(d->tcfd_defdata, defdata, SIMP_MAX_DATA); spin_unlock_bh(&d->tcf_lock); } @@ -83,7 +83,6 @@ static int tcf_simp_init(struct net *net struct nlattr *tb[TCA_DEF_MAX + 1]; struct tc_defact *parm; struct tcf_defact *d; - char *defdata; int ret = 0, err; if (nla == NULL) @@ -100,7 +99,6 @@ static int tcf_simp_init(struct net *net return -EINVAL; parm = nla_data(tb[TCA_DEF_PARMS]); - defdata = nla_data(tb[TCA_DEF_DATA]); if (!tcf_hash_check(parm->index, a, bind)) { ret = tcf_hash_create(parm->index, est, a, sizeof(*d), bind); @@ -108,7 +106,7 @@ static int tcf_simp_init(struct net *net return ret; d = to_defact(a); - ret = alloc_defdata(d, defdata); + ret = alloc_defdata(d, tb[TCA_DEF_DATA]); if (ret < 0) { tcf_hash_cleanup(a, est); return ret; @@ -124,7 +122,7 @@ static int tcf_simp_init(struct net *net if (!ovr) return -EEXIST; - reset_policy(d, defdata, parm); + reset_policy(d, tb[TCA_DEF_DATA], parm); } if (ret == ACT_P_CREATED)