Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp576746img; Fri, 22 Mar 2019 04:23:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqyA4lQR4hXJxuxlIfbXw4PcueFgu1/TbwtD6/nDQNQBkzKrX/FYlIk8Q0KIDpMHFe5kFWHg X-Received: by 2002:a63:68ca:: with SMTP id d193mr8277178pgc.53.1553253817678; Fri, 22 Mar 2019 04:23:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553253817; cv=none; d=google.com; s=arc-20160816; b=IUuIGDvSjPELp3NYc3j/DIKm0Sz6VvH3uZ3WpEhwefPei7jY3og3NOsa97YxhXAaID gZBZbizTstPxLPSMwA71uPfFtuKKhae4fitzbgpTtYNc6M7U/ql3NbZH/XM7jcOIpW/a SXXiUxp/TpOh0GtA5GQO28jT0Lk5RkABjeumLW0KF3XpY16++f+UO2KjWbrIGhvl5wgh joMSOnkZ9T/IZmZbS/cr1mZSynEB6jDtrhBQHXoJgNJol1R5f56mQtUoNQFXNQ3NADz5 9iVi3KXl4pPFXSwds3LZ+UY95MB5pEHOEQ5htdRBkLMl8yptg5JyVaM6dZhpTy7HB5Po i17g== 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=GiM9g76Kw6+gVsZpTP+6bw8MJ2bInGSQJDh52/5pTv0=; b=qhrUyqw52Rht7qJapkEMSOCvT3Y/qp2YOw/iDU2INs1HfW7yqzO7QMkMlXUsMLusv3 fgZfhYF9fIvVqGun3cp9w+5l2dATw8RTAtd3n96oZu+O6ZOIXmHaEiboFOi5j0n5DCNO vBswJbyfCAHmvWZX4ssbAH22PQDFdSOYzPDaq91rUefLXGzfNv5prkPQAK5WWed0KZY4 3UnK36hMuUmTiEElgATo84B8KN2H/LYLQThKb8JRwEQ4frE81ZPHI8WLpsZUvaNPkGYr y+pSwWtXxUOjWoLHTd54/KMUAnZlpKBS3jVKFjDoeuIHU+WkNgq/9wmvbB3CaDcPTW2b PIog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RjITRafl; 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 d11si6398761pgh.447.2019.03.22.04.23.22; Fri, 22 Mar 2019 04:23:37 -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=RjITRafl; 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 S1728723AbfCVLWD (ORCPT + 99 others); Fri, 22 Mar 2019 07:22:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:48650 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728712AbfCVLWC (ORCPT ); Fri, 22 Mar 2019 07:22:02 -0400 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 448C421917; Fri, 22 Mar 2019 11:22:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553253721; bh=oZBQIJU6MLp4YqqWxuh9jx9ZcqMTRER9OHa1udUHnmI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RjITRaflOIhgUfnuXvonetEEfb1fy4UzbHebxORo24E0IYje/iIgmpacHEaHeAuHq WdXTGIuoJHPJItnZs6mJ8wSrgwMHaAojzJK/s2Ga6V/vznWVAYJBKdirDrIHPM6XeZ lcfGT8K3V2T9oxAQdSLVlPFFUY+7Gn2wVxBcmU7k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jann Horn , Paul Moore , "David S. Miller" Subject: [PATCH 3.18 051/134] netlabel: fix out-of-bounds memory accesses Date: Fri, 22 Mar 2019 12:14:24 +0100 Message-Id: <20190322111213.641135183@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111210.465931067@linuxfoundation.org> References: <20190322111210.465931067@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Paul Moore [ Upstream commit 5578de4834fe0f2a34fedc7374be691443396d1f ] There are two array out-of-bounds memory accesses, one in cipso_v4_map_lvl_valid(), the other in netlbl_bitmap_walk(). Both errors are embarassingly simple, and the fixes are straightforward. As a FYI for anyone backporting this patch to kernels prior to v4.8, you'll want to apply the netlbl_bitmap_walk() patch to cipso_v4_bitmap_walk() as netlbl_bitmap_walk() doesn't exist before Linux v4.8. Reported-by: Jann Horn Fixes: 446fda4f2682 ("[NetLabel]: CIPSOv4 engine") Fixes: 3faa8f982f95 ("netlabel: Move bitmap manipulation functions to the NetLabel core.") Signed-off-by: Paul Moore Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/cipso_ipv4.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/net/ipv4/cipso_ipv4.c +++ b/net/ipv4/cipso_ipv4.c @@ -165,7 +165,8 @@ static int cipso_v4_bitmap_walk(const un (state == 0 && (byte & bitmask) == 0)) return bit_spot; - bit_spot++; + if (++bit_spot >= bitmap_len) + return -1; bitmask >>= 1; if (bitmask == 0) { byte = bitmap[++byte_offset]; @@ -735,7 +736,8 @@ static int cipso_v4_map_lvl_valid(const case CIPSO_V4_MAP_PASS: return 0; case CIPSO_V4_MAP_TRANS: - if (doi_def->map.std->lvl.cipso[level] < CIPSO_V4_INV_LVL) + if ((level < doi_def->map.std->lvl.cipso_size) && + (doi_def->map.std->lvl.cipso[level] < CIPSO_V4_INV_LVL)) return 0; break; }