From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Carpenter Subject: [PATCH net] net: sched: act_ipt: check for underflow in __tcf_ipt_init() Date: Sat, 22 Sep 2018 16:46:48 +0300 Message-ID: <20180922134648.GA7027@mwanda> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Cong Wang , Jiri Pirko , "David S. Miller" , netdev@vger.kernel.org, kernel-janitors@vger.kernel.org To: Jamal Hadi Salim , Patrick McHardy Return-path: Received: from aserp2120.oracle.com ([141.146.126.78]:38530 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727013AbeIVTks (ORCPT ); Sat, 22 Sep 2018 15:40:48 -0400 Content-Disposition: inline Sender: netdev-owner@vger.kernel.org List-ID: If "td->u.target_size" is larger than sizeof(struct xt_entry_target) we return -EINVAL. But we don't check whether it's smaller than sizeof(struct xt_entry_target) and that could lead to an out of bounds read. Fixes: 7ba699c604ab ("[NET_SCHED]: Convert actions from rtnetlink to new netlink API") Signed-off-by: Dan Carpenter --- I haven't tested this. Please review carefully. diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c index 1efbfb10b1fc..8af6c11d2482 100644 --- a/net/sched/act_ipt.c +++ b/net/sched/act_ipt.c @@ -135,7 +135,7 @@ static int __tcf_ipt_init(struct net *net, unsigned int id, struct nlattr *nla, } td = (struct xt_entry_target *)nla_data(tb[TCA_IPT_TARG]); - if (nla_len(tb[TCA_IPT_TARG]) < td->u.target_size) { + if (nla_len(tb[TCA_IPT_TARG]) != td->u.target_size) { if (exists) tcf_idr_release(*a, bind); else