Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp16940imu; Thu, 8 Nov 2018 14:00:18 -0800 (PST) X-Google-Smtp-Source: AJdET5eDm5rCkzBzAhcNy+ONz6YWifcv2hyY68kP77icjxMvpzqSGZqAEAjhqzAR1zpsvZycyLiw X-Received: by 2002:a63:d015:: with SMTP id z21-v6mr5232863pgf.64.1541714418207; Thu, 08 Nov 2018 14:00:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541714418; cv=none; d=google.com; s=arc-20160816; b=QV1YHT78wXi0Mr0LJ4NPuYO/3uYYQpXWAgLn2eeSnylV4C/rnxiUoFSSM3X4h5dW1P XlfLZZbrGmHgqfMm5JfKQ9ZhiNeX1Db/LajR9rdZazyxKET/5EiVzoSyVs2cFwq0VcNu 7M/djFS0/2UG+bDphx0A2DjEiJ4jg40jvk+pLRS/bXddq4QIdUwxs17CLcfTDA0EFOOC QPl5qVGXZniXXV/Wdxmw8ZtHfNti/gGHa+KtqJ29Rm+SUa6Rm44q8cu1GIMHAzXOTb0i 3QkHo5RhjwrHKsK/V/OpvWv9gYuA54NAz6c7JUXmGVZtE1iu+fflsFeDgC4aKSQGdC1o 6zlw== 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=PESPXC14IidPB4M3Dr4EO67xhDtXf5kMjUlN1czzREU=; b=v3rcIIE8yLSacC47U19mjFHXPwCh5fPbvwImu4QVTViA+L4+kuAA0hlTrAFbmPkIEb xh26ql7OfLjrRRFrp5PxEfEHKE5NrEXdyqLX/PM4IpBAVmgo5ndgEaQML/Ch/H5QwtAA taxJZ0M/bWR1sdEWLCjeiFEYaKVgdP5VxUMrwX0IAntRTu4xRxskYeyQdf2w8q3g6Rgi pcdJN6AflAgDM+XXJbxtMNR+NuEt4qtfv84WqFZFrGjx15PTlqmhUUYW55Qr0CGb19Jt JnibiG1PBiPgoY+syUUoRwi77ldQWjqeD4Kou1AE2B4/ZG51d8ElBFS6TseCBCNvaZe/ hlaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YzZ6I3vu; 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 y16-v6si4202273pgk.479.2018.11.08.14.00.01; Thu, 08 Nov 2018 14:00:18 -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=YzZ6I3vu; 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 S1729796AbeKIHgR (ORCPT + 99 others); Fri, 9 Nov 2018 02:36:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:53492 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728347AbeKIHgO (ORCPT ); Fri, 9 Nov 2018 02:36:14 -0500 Received: from localhost (unknown [208.72.13.198]) (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 5D96C20892; Thu, 8 Nov 2018 21:58:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541714326; bh=TBY5Vv0NrMygxnTEvsyZ2cX1EpOkK7CdK2smcXJRuS4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YzZ6I3vu9m4Nx6yEKHo6CONqhFotsHvJ4qOHPL1y0fvdCHnCPIvFUFurh/QECz9yL x1+9oG3puXjeOfjzU5sEUHWpHrNsuQ2e7gJi/y2tQZgFwbLDzymOQKPCksI3ljBG+Q VWMfj6A4MR6wL6sbgdutQxZhdtLxuWKbmsiZQD9A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Tranchetti , Steffen Klassert , Sasha Levin Subject: [PATCH 4.4 006/114] xfrm: validate template mode Date: Thu, 8 Nov 2018 13:50:21 -0800 Message-Id: <20181108215059.533003683@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108215059.051093652@linuxfoundation.org> References: <20181108215059.051093652@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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.4-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 32bf94fb5c2ec4ec842152d0e5937cd4bb6738fa ] XFRM mode parameters passed as part of the user templates in the IP_XFRM_POLICY are never properly validated. Passing values other than valid XFRM modes can cause stack-out-of-bounds reads to occur later in the XFRM processing: [ 140.535608] ================================================================ [ 140.543058] BUG: KASAN: stack-out-of-bounds in xfrm_state_find+0x17e4/0x1cc4 [ 140.550306] Read of size 4 at addr ffffffc0238a7a58 by task repro/5148 [ 140.557369] [ 140.558927] Call trace: [ 140.558936] dump_backtrace+0x0/0x388 [ 140.558940] show_stack+0x24/0x30 [ 140.558946] __dump_stack+0x24/0x2c [ 140.558949] dump_stack+0x8c/0xd0 [ 140.558956] print_address_description+0x74/0x234 [ 140.558960] kasan_report+0x240/0x264 [ 140.558963] __asan_report_load4_noabort+0x2c/0x38 [ 140.558967] xfrm_state_find+0x17e4/0x1cc4 [ 140.558971] xfrm_resolve_and_create_bundle+0x40c/0x1fb8 [ 140.558975] xfrm_lookup+0x238/0x1444 [ 140.558977] xfrm_lookup_route+0x48/0x11c [ 140.558984] ip_route_output_flow+0x88/0xc4 [ 140.558991] raw_sendmsg+0xa74/0x266c [ 140.558996] inet_sendmsg+0x258/0x3b0 [ 140.559002] sock_sendmsg+0xbc/0xec [ 140.559005] SyS_sendto+0x3a8/0x5a8 [ 140.559008] el0_svc_naked+0x34/0x38 [ 140.559009] [ 140.592245] page dumped because: kasan: bad access detected [ 140.597981] page_owner info is not active (free page?) [ 140.603267] [ 140.653503] ================================================================ Signed-off-by: Sean Tranchetti Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin --- net/xfrm/xfrm_user.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index c2e98dcba9fe..476f1fc6d655 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c @@ -1408,6 +1408,9 @@ static int validate_tmpl(int nr, struct xfrm_user_tmpl *ut, u16 family) (ut[i].family != prev_family)) return -EINVAL; + if (ut[i].mode >= XFRM_MODE_MAX) + return -EINVAL; + prev_family = ut[i].family; switch (ut[i].family) { -- 2.17.1