Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753944AbaGVJHp (ORCPT ); Tue, 22 Jul 2014 05:07:45 -0400 Received: from ja.ssi.bg ([178.16.129.10]:35001 "EHLO ja.home.ssi.bg" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753754AbaGVJHm (ORCPT ); Tue, 22 Jul 2014 05:07:42 -0400 Date: Tue, 22 Jul 2014 11:52:02 +0300 (EEST) From: Julian Anastasov X-X-Sender: ja@ja.home.ssi.bg To: Dan Carpenter cc: Andrey Utkin , "linux-kernel@vger.kernel.org" , kernel-janitors@vger.kernel.org, coreteam@netfilter.org, netfilter-devel@vger.kernel.org, lvs-devel@vger.kernel.org, netdev@vger.kernel.org, dcb314@hotmail.com, David Miller , kadlec@blackhole.kfki.hu, Patrick McHardy , pablo@netfilter.org, Simon Horman , wensong@linux-vs.org Subject: Re: [PATCH 3/5] net/netfilter/ipvs/ip_vs_ctl.c: drop argument range check just before the check for equality In-Reply-To: <20140722074214.GL25880@mwanda> Message-ID: References: <1405697638-23767-1-git-send-email-andrey.krieger.utkin@gmail.com> <20140722074214.GL25880@mwanda> User-Agent: Alpine 2.11 (LFD 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Tue, 22 Jul 2014, Dan Carpenter wrote: > On Mon, Jul 21, 2014 at 11:01:56PM +0300, Julian Anastasov wrote: > > @@ -2333,13 +2339,12 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) > > struct ip_vs_dest_user_kern udest; > > struct netns_ipvs *ipvs = net_ipvs(net); > > > > + BUILD_BUG_ON(sizeof(arg) > 256); > > 256 is off-by-one because u8 ranges from 0-255 so we are never able to > copy 256 bytes into the "arg" buffer. I'll change it to >= 256, to catch that we can not hold such big size in unsigned char [gs]et_arglen and also as an indication that we have to use allocated buffer instead of stack. > > - if (copylen > 128) > > + if (*len < (int) copylen || *len < 0) { > > + pr_err("get_ctl: len %d < %u\n", *len, copylen); > > Don't let users flood dmesg. Just return an error. (This can be > triggered by non-root as well). For now both set and get are privileged operations, so we can keep it, it can catch if something wrong happens with the structure sizes. Regards -- Julian Anastasov -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/