From patchwork Mon Nov 10 16:11:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pablo Neira Ayuso X-Patchwork-Id: 408991 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id B3ECE14012A for ; Tue, 11 Nov 2014 03:09:37 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752272AbaKJQJg (ORCPT ); Mon, 10 Nov 2014 11:09:36 -0500 Received: from mail.us.es ([193.147.175.20]:57530 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751292AbaKJQJg (ORCPT ); Mon, 10 Nov 2014 11:09:36 -0500 Received: (qmail 5795 invoked from network); 10 Nov 2014 17:09:32 +0100 Received: from unknown (HELO us.es) (192.168.2.16) by us.es with SMTP; 10 Nov 2014 17:09:32 +0100 Received: (qmail 7320 invoked by uid 507); 10 Nov 2014 16:09:32 -0000 X-Qmail-Scanner-Diagnostics: from 127.0.0.1 by antivirus6 (envelope-from , uid 501) with qmail-scanner-2.10 (clamdscan: 0.98.4/19608. spamassassin: 3.3.2. Clear:RC:1(127.0.0.1):SA:0(-103.2/7.5):. Processed in 2.419873 secs); 10 Nov 2014 16:09:32 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on antivirus6 X-Spam-Level: X-Spam-Status: No, score=-103.2 required=7.5 tests=BAYES_50,SMTPAUTH_US, SPF_HELO_FAIL,USER_IN_WHITELIST autolearn=disabled version=3.3.2 X-Spam-ASN: AS12715 87.216.0.0/16 X-Envelope-From: pneira@us.es Received: from unknown (HELO antivirus6) (127.0.0.1) by us.es with SMTP; 10 Nov 2014 16:09:29 -0000 Received: from 192.168.1.13 (192.168.1.13) by antivirus6 (F-Secure/fsigk_smtp/412/antivirus6); Mon, 10 Nov 2014 17:09:29 +0100 (CET) X-Virus-Status: clean(F-Secure/fsigk_smtp/412/antivirus6) Received: (qmail 7992 invoked from network); 10 Nov 2014 17:09:29 +0100 Received: from 129.166.216.87.static.jazztel.es (HELO us.es) (1984lsi@87.216.166.129) by mail.us.es with AES128-SHA encrypted SMTP; 10 Nov 2014 17:09:29 +0100 Date: Mon, 10 Nov 2014 17:11:21 +0100 From: Pablo Neira Ayuso To: Jozsef Kadlecsik Cc: Dan Carpenter , Patrick McHardy , "David S. Miller" , Sergey Popovich , Masanari Iida , Anton Danilov , stephen hemminger , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernddel.org, kernel-janitors@vger.kernel.org Subject: Re: [patch -mainline] netfilter: ipset: small potential read beyond the end of buffer Message-ID: <20141110161121.GA7398@salvia> References: <20141107062140.GA10905@mwanda> <20141110142446.GA29586@salvia> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org On Mon, Nov 10, 2014 at 03:27:51PM +0100, Jozsef Kadlecsik wrote: > On Mon, 10 Nov 2014, Pablo Neira Ayuso wrote: > > >From other similar code in that location, I can see Jozsef is using > > this pattern: > > > > if (*len != sizeof(struct ip_set_req_version)) { > > ret = -EINVAL; > > goto done; > > } > > > > I think it would be good to stick to that for consistency. Thanks. > > Absolutely, yes. > > Acked-by: Jozsef Kadlecsik OK, then does this look fine to you? I took over Dan's patch and gave it another spin. See it attached, thanks. From d67bad383d4ea9dea8872e3999324ccbeb2a5815 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 7 Nov 2014 09:21:40 +0300 Subject: [PATCH] netfilter: ipset: small potential read beyond the end of buffer We could be reading 8 bytes into a 4 byte buffer here. It seems harmless but adding a check is the right thing to do and it silences a static checker warning. Signed-off-by: Dan Carpenter Signed-off-by: Pablo Neira Ayuso --- net/netfilter/ipset/ip_set_core.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c index 86f9d76..d259da3 100644 --- a/net/netfilter/ipset/ip_set_core.c +++ b/net/netfilter/ipset/ip_set_core.c @@ -1863,6 +1863,12 @@ ip_set_sockfn_get(struct sock *sk, int optval, void __user *user, int *len) if (*op < IP_SET_OP_VERSION) { /* Check the version at the beginning of operations */ struct ip_set_req_version *req_version = data; + + if (*len < sizeof(struct ip_set_req_version)) { + ret = -EINVAL; + goto done; + } + if (req_version->version != IPSET_PROTOCOL) { ret = -EPROTO; goto done; -- 1.7.10.4