linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Steffen Klassert <steffen.klassert@secunet.com>,
	Sasha Levin <alexander.levin@microsoft.com>
Subject: [PATCH 3.18 51/58] xfrm: Fix stack-out-of-bounds with misconfigured transport mode policies.
Date: Fri, 23 Feb 2018 19:26:50 +0100	[thread overview]
Message-ID: <20180223170214.786890273@linuxfoundation.org> (raw)
In-Reply-To: <20180223170206.724655284@linuxfoundation.org>

3.18-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Steffen Klassert <steffen.klassert@secunet.com>


[ Upstream commit 732706afe1cc46ef48493b3d2b69c98f36314ae4 ]

On policies with a transport mode template, we pass the addresses
from the flowi to xfrm_state_find(), assuming that the IP addresses
(and address family) don't change during transformation.

Unfortunately our policy template validation is not strict enough.
It is possible to configure policies with transport mode template
where the address family of the template does not match the selectors
address family. This lead to stack-out-of-bound reads because
we compare arddesses of the wrong family. Fix this by refusing
such a configuration, address family can not change on transport
mode.

We use the assumption that, on transport mode, the first templates
address family must match the address family of the policy selector.
Subsequent transport mode templates must mach the address family of
the previous template.

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/xfrm/xfrm_user.c |    9 +++++++++
 1 file changed, 9 insertions(+)

--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -1349,11 +1349,14 @@ static void copy_templates(struct xfrm_p
 
 static int validate_tmpl(int nr, struct xfrm_user_tmpl *ut, u16 family)
 {
+	u16 prev_family;
 	int i;
 
 	if (nr > XFRM_MAX_DEPTH)
 		return -EINVAL;
 
+	prev_family = family;
+
 	for (i = 0; i < nr; i++) {
 		/* We never validated the ut->family value, so many
 		 * applications simply leave it at zero.  The check was
@@ -1365,6 +1368,12 @@ static int validate_tmpl(int nr, struct
 		if (!ut[i].family)
 			ut[i].family = family;
 
+		if ((ut[i].mode == XFRM_MODE_TRANSPORT) &&
+		    (ut[i].family != prev_family))
+			return -EINVAL;
+
+		prev_family = ut[i].family;
+
 		switch (ut[i].family) {
 		case AF_INET:
 			break;

  parent reply	other threads:[~2018-02-23 18:32 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-23 18:25 [PATCH 3.18 00/58] 3.18.96-stable review Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 01/58] IB/mlx4: Fix incorrectly releasing steerable UD QPs when have only ETH ports Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 02/58] PM / devfreq: Propagate error from devfreq_add_device() Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 03/58] s390: fix handling of -1 in set{,fs}[gu]id16 syscalls Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 04/58] arm: spear600: Add missing interrupt-parent of rtc Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 05/58] arm: spear13xx: Fix dmas cells Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 06/58] arm: spear13xx: Fix spics gpio controllers warning Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 07/58] ALSA: seq: Fix regression by incorrect ioctl_mutex usages Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 08/58] drm/radeon: adjust tested variable Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 09/58] ext4: save error to disk in __ext4_grp_locked_error() Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 10/58] ext4: correct documentation for grpid mount option Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 11/58] video: fbdev: atmel_lcdfb: fix display-timings lookup Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 12/58] console/dummy: leave .con_font_get set to NULL Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 13/58] Btrfs: fix deadlock in run_delalloc_nocow Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 14/58] Btrfs: fix crash due to not cleaning up tree log blocks dirty bits Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 15/58] ALSA: seq: Fix racy pool initializations Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 16/58] ARM: dts: s5pv210: add interrupt-parent for ohci Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 17/58] media: r820t: fix r820t_write_reg for KASAN Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 18/58] mm,vmscan: Make unregister_shrinker() no-op if register_shrinker() failed Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 19/58] xfrm: check id proto in validate_tmpl() Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 20/58] selinux: skip bounded transition processing if the policy isnt loaded Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 21/58] crypto: x86/twofish-3way - Fix %rbp usage Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 22/58] staging: android: ion: Add __GFP_NOWARN for system contig heap Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 23/58] netfilter: x_tables: fix int overflow in xt_alloc_table_info() Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 24/58] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_{match|target} Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 25/58] netfilter: ipt_CLUSTERIP: fix out-of-bounds accesses in clusterip_tg_check() Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 26/58] netfilter: on sockopt() acquire sock lock only in the required scope Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 27/58] netfilter: xt_RATEEST: acquire xt_rateest_mutex for hash insert Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 28/58] net: avoid skb_warn_bad_offload on IS_ERR Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 29/58] Provide a function to create a NUL-terminated string from unterminated data Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 30/58] selinux: ensure the context is NUL terminated in security_context_to_sid_core() Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 31/58] ASoC: ux500: add MODULE_LICENSE tag Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 32/58] video: fbdev/mmp: add MODULE_LICENSE Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 33/58] dn_getsockoptdecnet: move nf_{get/set}sockopt outside sock lock Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 34/58] usbip: keep usbip_device sockfd state in sync with tcp_socket Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 35/58] usb: build drivers/usb/common/ when USB_SUPPORT is set Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 36/58] ARM: AM33xx: PRM: Remove am33xx_pwrdm_read_prev_pwrst function Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 37/58] ARM: dts: am4372: Correct the interrupts_properties of McASP Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 38/58] perf top: Fix window dimensions change handling Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 39/58] perf bench numa: Fixup discontiguous/sparse numa nodes Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 40/58] media: s5k6aa: describe some function parameters Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 41/58] scripts/kernel-doc: Dont fail with status != 0 if error encountered with -none Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 42/58] m68k: add missing SOFTIRQENTRY_TEXT linker section Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 43/58] powerpc/perf: Fix oops when grouping different pmu events Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 44/58] s390/dasd: prevent prefix I/O error Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 45/58] gianfar: fix a flooded alignment reports because of padding issue Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 46/58] net_sched: red: Avoid devision by zero Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 47/58] net_sched: red: Avoid illegal values Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 48/58] btrfs: Fix possible off-by-one in btrfs_search_path_in_tree Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 49/58] 509: fix printing uninitialized stack memory when OID is empty Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 50/58] spi: sun4i: disable clocks in the remove function Greg Kroah-Hartman
2018-02-23 18:26 ` Greg Kroah-Hartman [this message]
2018-02-23 18:26 ` [PATCH 3.18 52/58] dmaengine: jz4740: disable/unprepare clk if probe fails Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 53/58] mm/early_ioremap: Fix boot hang with earlyprintk=efi,keep Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 54/58] x86/mm/kmmio: Fix mmiotrace for page unaligned addresses Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 55/58] xen: XEN_ACPI_PROCESSOR is Dom0-only Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 56/58] hippi: Fix a Fix a possible sleep-in-atomic bug in rr_close Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 57/58] KVM: async_pf: Fix #DF due to inject "Page not Present" and "Page Ready" exceptions simultaneously Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 58/58] crypto: s5p-sss - Fix kernel Oops in AES-ECB mode Greg Kroah-Hartman
2018-02-23 22:17 ` [PATCH 3.18 00/58] 3.18.96-stable review kernelci.org bot
2018-02-24  0:37 ` Shuah Khan
2018-02-24 11:41 ` Harsh Shandilya
2018-02-24 18:38   ` Greg Kroah-Hartman
2018-02-24 17:54 ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180223170214.786890273@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=alexander.levin@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).