Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2511418imm; Mon, 28 May 2018 09:27:48 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrerYf6qsNcOwPTRiLXGjIAAVELzySnGysmQL2pVS1Bbu2fyvNLHUUkE/T3Q95UTHuiH1X3 X-Received: by 2002:a65:6648:: with SMTP id z8-v6mr10791737pgv.397.1527524868711; Mon, 28 May 2018 09:27:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527524868; cv=none; d=google.com; s=arc-20160816; b=gDcnM38JhaSKawQt2dxHf4CqP/v74lnj1MzPGVv8niMqpkd9cqajFFkbtDAFvzhRLL GBGueD0n/A9WusGuQ9dsYBo5VrHVyFCj9xJehADH1ORaiVlX6B+1q9xWLomttDPuLMhl rkHyILoXay3NFoi3bgWRWHwi3Uw5OBSAJx3dEu8e29lXnk2KSJpJquinb+dxfY9gKhyb o+qqZu5tzuRn/OeMPmxAAqVq2pR6eS8GBTymuo+u+scETQHfj/4fBk8npMUeYr1oRXX4 IqD315m9Kh5ohd4PrTs2+2AreMFwyJX4YeIcoFvFGkHF7S095ZeqZk4dxxzYCue9DiXw KV5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=ZYTSMBn5jYgdFKs07DYZLHZ+EfdenY79r8ohUEBgW8Q=; b=JkTas/8o8HIRuwSxZxVUxUOhtUu9XJkOsuU9UxLdXG2HwlNhIAH+GLE0FCk8gCWNqM DOrj94FLq9nrKJU7g4u0YYtjMvg2rt+01+vUfh32pC5hG0VDCFiqpSq+tSvmWmyZhdVA guKI5MuKTiVV0sZRVjN8lCn6EQGYQGrZ5bNQxjxHdlWFVMwvWtvSXutF2MAWzzkSbb5d eHia+PJfbQit5R8Xbsq2Wgvh2mWF4uPbxLabbOxSNbY6nOEBlVqfNsMrsY+tZMmNnA3X nIYXWj+t7EGaS7edB+dFarVbIo5O5m3PRkIJDfmkjPydusRZECTSmv6FkuNmE9rYbGvK ipLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=s7RNiq53; 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 k33-v6si30218737pld.100.2018.05.28.09.27.34; Mon, 28 May 2018 09:27:48 -0700 (PDT) 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=s7RNiq53; 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 S936481AbeE1KKX (ORCPT + 99 others); Mon, 28 May 2018 06:10:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:58468 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933629AbeE1KKS (ORCPT ); Mon, 28 May 2018 06:10:18 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 630192086D; Mon, 28 May 2018 10:10:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502217; bh=ZDw/bmmGuHztb0dcOi6Bh4b1jcexELnfGA6mmkrSRLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s7RNiq53/7nefPg4beLUIDwgzPHq11/Ey9xCtCiqSKWPWJFnV1ec4kLXPaSETdHct eL4Sy+heeVe8g3XSJAQoyVHGTRFxDba68olytl8DRoNNsBXisiongN33QctHW8R4dV uO3tJhhigh9Gx6Sxs/5VU/B7+EXenXyVlhqHFZOw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Westphal , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 3.18 076/185] netfilter: ebtables: convert BUG_ONs to WARN_ONs Date: Mon, 28 May 2018 12:01:57 +0200 Message-Id: <20180528100057.221774162@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100050.700971285@linuxfoundation.org> References: <20180528100050.700971285@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Florian Westphal [ Upstream commit fc6a5d0601c5ac1d02f283a46f60b87b2033e5ca ] All of these conditions are not fatal and should have been WARN_ONs from the get-go. Convert them to WARN_ONs and bail out. Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- net/bridge/netfilter/ebtables.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c @@ -1612,7 +1612,8 @@ static int compat_match_to_user(struct e int off = ebt_compat_match_offset(match, m->match_size); compat_uint_t msize = m->match_size - off; - BUG_ON(off >= m->match_size); + if (WARN_ON(off >= m->match_size)) + return -EINVAL; if (copy_to_user(cm->u.name, match->name, strlen(match->name) + 1) || put_user(msize, &cm->match_size)) @@ -1639,7 +1640,8 @@ static int compat_target_to_user(struct int off = xt_compat_target_offset(target); compat_uint_t tsize = t->target_size - off; - BUG_ON(off >= t->target_size); + if (WARN_ON(off >= t->target_size)) + return -EINVAL; if (copy_to_user(cm->u.name, target->name, strlen(target->name) + 1) || put_user(tsize, &cm->match_size)) @@ -1867,7 +1869,8 @@ static int ebt_buf_add(struct ebt_entrie if (state->buf_kern_start == NULL) goto count_only; - BUG_ON(state->buf_kern_offset + sz > state->buf_kern_len); + if (WARN_ON(state->buf_kern_offset + sz > state->buf_kern_len)) + return -EINVAL; memcpy(state->buf_kern_start + state->buf_kern_offset, data, sz); @@ -1880,7 +1883,8 @@ static int ebt_buf_add_pad(struct ebt_en { char *b = state->buf_kern_start; - BUG_ON(b && state->buf_kern_offset > state->buf_kern_len); + if (WARN_ON(b && state->buf_kern_offset > state->buf_kern_len)) + return -EINVAL; if (b != NULL && sz > 0) memset(b + state->buf_kern_offset, 0, sz); @@ -1957,8 +1961,10 @@ static int compat_mtw_from_user(struct c pad = XT_ALIGN(size_kern) - size_kern; if (pad > 0 && dst) { - BUG_ON(state->buf_kern_len <= pad); - BUG_ON(state->buf_kern_offset - (match_size + off) + size_kern > state->buf_kern_len - pad); + if (WARN_ON(state->buf_kern_len <= pad)) + return -EINVAL; + if (WARN_ON(state->buf_kern_offset - (match_size + off) + size_kern > state->buf_kern_len - pad)) + return -EINVAL; memset(dst + size_kern, 0, pad); } return off + match_size; @@ -2009,7 +2015,8 @@ static int ebt_size_mwt(struct compat_eb if (ret < 0) return ret; - BUG_ON(ret < match32->match_size); + if (WARN_ON(ret < match32->match_size)) + return -EINVAL; growth += ret - match32->match_size; growth += ebt_compat_entry_padsize(); @@ -2119,7 +2126,8 @@ static int size_entry_mwt(struct ebt_ent startoff = state->buf_user_offset - startoff; - BUG_ON(*total < startoff); + if (WARN_ON(*total < startoff)) + return -EINVAL; *total -= startoff; return 0; } @@ -2247,7 +2255,8 @@ static int compat_do_replace(struct net state.buf_kern_len = size64; ret = compat_copy_entries(entries_tmp, tmp.entries_size, &state); - BUG_ON(ret < 0); /* parses same data again */ + if (WARN_ON(ret < 0)) + goto out_unlock; vfree(entries_tmp); tmp.entries_size = size64;