Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5894762imb; Fri, 8 Mar 2019 04:58:48 -0800 (PST) X-Google-Smtp-Source: APXvYqydj3VnlcX1hMfGDEGHaKPOr1ThoZGG17Fc0fLYyTlSGXUCDOz9T0+NKSDebPfM/RiGCHDa X-Received: by 2002:aa7:854d:: with SMTP id y13mr18263464pfn.175.1552049928444; Fri, 08 Mar 2019 04:58:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552049928; cv=none; d=google.com; s=arc-20160816; b=ckZrABIbIOoJWBQlDOCiaSJTBm7y5VL73UhR3F7R965maQo5AWF8hoyG4MryKOE8tT VVzV8Il0F2e5yiZ5NPLjDqApfBVpomK0WPIbwe0CmF/F59g54LYSX2NI5SoFDMnvyarP r16aJNagDcbFagbVs+ZstkYXa8iIxlg16wblIZBRWxFJocxie7gqJDU9HYSTTV/NzYbs cGqkQT6KGc2TB2R87g60kcGvaEYyVnEmo9A+1ndflulXDo8pT2xGsBHWEufnU5WBX4SO hKx4dJDcra69adOnX9bAKvVjo3wtaPsr162iU/xaz6Lvmhqi18lxeO9DjH3YQsWT6WGw fAAw== 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=FO1hx5dOSivQ7Ux76l8ywkmVPmVIgFNZsFqn68+Z060=; b=QbZeOWfle+9hTwqRvlWsf4ZDtXPEZkQ+YyVY0VCyYc6DvZkaxStmuQAQakF/EcEpac 5+dgV4hbQ9QitljSTqOvNi9kOHiXjjCuQ94K4BhUmc29dJxxuR6F+exiYCkGOqYPuVoJ eq1YLC3Ygwnj1BfK09T+UeK6hupPacwa3jgeqziocNvg6mFFmNGe2QObkPhbj5eb3NDg gMys42ywrxN1uRyUwhZfSRpu+IIJVzirMUD2ZWcgTLQXyIOulMumMBOiruqc23GF9yS/ z8Uhdg7zo52v2IM5RpmlynRp4FNik0wMS5BvTXK2mAZ01tzOvRwW7Utycc2Zp+AYJmsz MUww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="og/FXlqZ"; 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 p12si6811986plq.16.2019.03.08.04.58.33; Fri, 08 Mar 2019 04:58:48 -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="og/FXlqZ"; 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 S1727850AbfCHM5Z (ORCPT + 99 others); Fri, 8 Mar 2019 07:57:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:33738 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727490AbfCHM5V (ORCPT ); Fri, 8 Mar 2019 07:57:21 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 C3E2320449; Fri, 8 Mar 2019 12:57:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552049841; bh=YOuIvdNooku/v9BOs+eNwSKg3mUY4rvraURQrILCA1U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=og/FXlqZSJN81+YVa7xSOoSEf4UT3/dUGpnMfsmVW/x/uCh5XHm7BWmpBcUXpc9uk EZKx5iDuX4YSEPuTqW1hUaws5h/YluVUu3kfWQcx2gnX/4gWG41dBFp3JWcj2cdFmX J9iHOF5kRLgvF7IsYTEzE9Q6sFK59zJRAXL7cKJg= 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 4.20 37/76] netlabel: fix out-of-bounds memory accesses Date: Fri, 8 Mar 2019 13:49:49 +0100 Message-Id: <20190308124916.133340758@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190308124914.789210760@linuxfoundation.org> References: <20190308124914.789210760@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 4.20-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 | 3 ++- net/netlabel/netlabel_kapi.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) --- a/net/ipv4/cipso_ipv4.c +++ b/net/ipv4/cipso_ipv4.c @@ -667,7 +667,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; } --- a/net/netlabel/netlabel_kapi.c +++ b/net/netlabel/netlabel_kapi.c @@ -903,7 +903,8 @@ int netlbl_bitmap_walk(const unsigned ch (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];