Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp462923ybl; Tue, 28 Jan 2020 06:21:35 -0800 (PST) X-Google-Smtp-Source: APXvYqzQ2/13GainFA6MCLhIH/bIp/q8gP6E+NvIGd3LM8d4lc1WP/yJicCT0uchp4ZcNIgREpJa X-Received: by 2002:aca:f305:: with SMTP id r5mr3036003oih.174.1580221295725; Tue, 28 Jan 2020 06:21:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580221295; cv=none; d=google.com; s=arc-20160816; b=WsqqfeVNHrsHFjYwdJDj1giWyQSZLp9Ef6xvmldgVzMhfn0xa1CO3u24zT77E1N3PP iJri3y4uFFWlW/SK1ubsE4KY2GWeMz2oHyvDBr/u68vDRnr2cR6EsBx3jhXOZ2OcWcJe x0ICS9mOKw4kb7JqVZVD8jGofrBjFARV3UcM5aPnaA8V4jZrJqLXBpWlM8kfM3T0eIAM 5Wsuboi+Z5RmAW23DCPgcfDF9R41NuBacveUQ4lC6QTbaaBRxjJVNhXpqk0+aksvd6BV 06OQjmOBxHEnjbW9ZtjeB5fSCqI5JPEe8AFolHXfRj+O+0Jd3neVfeeWXBOIgiFV4+lU jqOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7sBoumHm2LUm2ofNgKsv6whVCMaVQj0o/R6qedqVTBo=; b=wMzCV+0B9AfWN5k5tvw4lCaa1BHhTkVYV0SW1yieVVYheUBO+iPxE3DCXf0wYiQmAv hdQ77TX8s1glittWnoWXB36nqinqFORmwINM77y+QKKipC6+advfbICfRwEQ65MrUH6W AMljXiZO+WnEC4ULDrgflvFTg1A5stsF0mUg3PiikHNb+vRTj1SnP2MTQ/z4PnbVLvxX t1JWaojVX8NiouwYf/igkXtkRjUXWahVja8WpWWlWt0mKg6PeOSpeWfwJm+sxpdYPg0f 4AGVGwckwtDn+sINTxObR983wf/S4ai55UEWVwR1hmLClqibeO/9WItDL/uE+CRjCWL/ lvAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WKc3gdHY; 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 h21si8879419otr.235.2020.01.28.06.21.23; Tue, 28 Jan 2020 06:21:35 -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; dkim=pass header.i=@kernel.org header.s=default header.b=WKc3gdHY; 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 S1730877AbgA1OU3 (ORCPT + 99 others); Tue, 28 Jan 2020 09:20:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:45316 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730493AbgA1OU0 (ORCPT ); Tue, 28 Jan 2020 09:20:26 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A54802071E; Tue, 28 Jan 2020 14:20:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580221226; bh=px0afCn0JOfjUFEZYl6xoAn5bctMPsUjfQduTDVGCDA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WKc3gdHYu0AyoICVdoSC2HAcOeJdN76QpRln0DPzqCgVGEwMVuFFmFDB8nGc/flWg Wr2JuuZAv1bhX7J+wIMErplJwYE6v26ZZ57ZUIIkfXTHEl6THQ2o4YG3NuCpkkKaH5 EuSzmTRktCLPvXQP9HnMZrYdH0Ng8/SYpntQEq7s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tetsuo Handa , Florian Westphal , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 4.9 138/271] netfilter: ebtables: CONFIG_COMPAT: reject trailing data after last rule Date: Tue, 28 Jan 2020 15:04:47 +0100 Message-Id: <20200128135902.856425665@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135852.449088278@linuxfoundation.org> References: <20200128135852.449088278@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Florian Westphal [ Upstream commit 680f6af5337c98d116e4f127cea7845339dba8da ] If userspace provides a rule blob with trailing data after last target, we trigger a splat, then convert ruleset to 64bit format (with trailing data), then pass that to do_replace_finish() which then returns -EINVAL. Erroring out right away avoids the splat plus unneeded translation and error unwind. Fixes: 81e675c227ec ("netfilter: ebtables: add CONFIG_COMPAT support") Reported-by: Tetsuo Handa Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/bridge/netfilter/ebtables.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index 56b7197f03739..1d850edecd724 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c @@ -2182,7 +2182,9 @@ static int compat_copy_entries(unsigned char *data, unsigned int size_user, if (ret < 0) return ret; - WARN_ON(size_remaining); + if (size_remaining) + return -EINVAL; + return state->buf_kern_offset; } -- 2.20.1