From: Sasha Levin <Alexander.Levin@microsoft.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Cc: Steffen Klassert <steffen.klassert@secunet.com>,
Sasha Levin <Alexander.Levin@microsoft.com>
Subject: [PATCH AUTOSEL for 4.4 24/36] xfrm: Fix stack-out-of-bounds read on socket policy lookup.
Date: Sun, 28 Jan 2018 22:28:40 +0000 [thread overview]
Message-ID: <20180128222815.29479-24-alexander.levin@microsoft.com> (raw)
In-Reply-To: <20180128222815.29479-1-alexander.levin@microsoft.com>
From: Steffen Klassert <steffen.klassert@secunet.com>
[ Upstream commit ddc47e4404b58f03e98345398fb12d38fe291512 ]
When we do tunnel or beet mode, we pass saddr and daddr from the
template to xfrm_state_find(), this is ok. On transport mode,
we pass the addresses from the flowi, assuming that the IP
addresses (and address family) don't change during transformation.
This assumption is wrong in the IPv4 mapped IPv6 case, packet
is IPv4 and template is IPv6.
Fix this by catching address family missmatches of the policy
and the flow already before we do the lookup.
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
net/xfrm/xfrm_policy.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 22df3b51e905..4b09a9eaa35f 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1225,9 +1225,15 @@ static struct xfrm_policy *xfrm_sk_policy_lookup(const struct sock *sk, int dir,
read_lock_bh(&net->xfrm.xfrm_policy_lock);
pol = rcu_dereference(sk->sk_policy[dir]);
if (pol != NULL) {
- bool match = xfrm_selector_match(&pol->selector, fl, family);
+ bool match;
int err = 0;
+ if (pol->family != family) {
+ pol = NULL;
+ goto out;
+ }
+
+ match = xfrm_selector_match(&pol->selector, fl, family);
if (match) {
if ((sk->sk_mark & pol->mark.m) != pol->mark.v) {
pol = NULL;
--
2.11.0
next prev parent reply other threads:[~2018-01-28 22:29 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-28 22:28 [PATCH AUTOSEL for 4.4 01/36] usb: build drivers/usb/common/ when USB_SUPPORT is set Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 02/36] ARM: OMAP2+: Fix SRAM virt to phys translation for save_secure_ram_context Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 03/36] ARM: AM33xx: PRM: Remove am33xx_pwrdm_read_prev_pwrst function Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 04/36] ARM: dts: Fix omap4 hang with GPS connected to USB by using wakeupgen Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 05/36] ARM: dts: am4372: Correct the interrupts_properties of McASP Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 06/36] perf top: Fix window dimensions change handling Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 07/36] perf bench numa: Fixup discontiguous/sparse numa nodes Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 08/36] media: s5k6aa: describe some function parameters Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 09/36] pinctrl: sunxi: Fix A80 interrupt pin bank Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 10/36] RDMA/cma: Make sure that PSN is not over max allowed Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 11/36] scripts/kernel-doc: Don't fail with status != 0 if error encountered with -none Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 13/36] m68k: add missing SOFTIRQENTRY_TEXT linker section Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 12/36] ipvlan: Add the skb->mark as flow4's member to lookup route Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 14/36] powerpc/perf: Fix oops when grouping different pmu events Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 15/36] s390/dasd: prevent prefix I/O error Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 16/36] gianfar: fix a flooded alignment reports because of padding issue Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 17/36] net_sched: red: Avoid devision by zero Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 18/36] net_sched: red: Avoid illegal values Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 19/36] dccp: CVE-2017-8824: use-after-free in DCCP code Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 20/36] btrfs: Fix possible off-by-one in btrfs_search_path_in_tree Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 22/36] dmaengine: ioat: Fix error handling path Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 21/36] 509: fix printing uninitialized stack memory when OID is empty Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 23/36] dmaengine: at_hdmac: fix potential NULL pointer dereference in atc_prep_dma_interleaved Sasha Levin
2018-01-28 22:28 ` Sasha Levin [this message]
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 26/36] clk: fix a panic error caused by accessing NULL pointer Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 25/36] netfilter: nfnetlink_cthelper: Add missing permission checks Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 27/36] netfilter: xt_osf: " Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 28/36] ASoC: rockchip: disable clock on error Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 29/36] spi: sun4i: disable clocks in the remove function Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 30/36] xfrm: Fix stack-out-of-bounds with misconfigured transport mode policies Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 31/36] drm/armada: fix leak of crtc structure Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 32/36] dmaengine: jz4740: disable/unprepare clk if probe fails Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 34/36] x86/mm/kmmio: Fix mmiotrace for page unaligned addresses Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 35/36] xen: XEN_ACPI_PROCESSOR is Dom0-only Sasha Levin
2018-01-28 22:28 ` [PATCH AUTOSEL for 4.4 36/36] hippi: Fix a Fix a possible sleep-in-atomic bug in rr_close Sasha Levin
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=20180128222815.29479-24-alexander.levin@microsoft.com \
--to=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).