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: Lorenzo Colitti <lorenzo@google.com>,
Steffen Klassert <steffen.klassert@secunet.com>,
Sasha Levin <Alexander.Levin@microsoft.com>
Subject: [PATCH AUTOSEL for 4.4 091/115] net: xfrm: allow clearing socket xfrm policies.
Date: Sat, 3 Mar 2018 22:31:43 +0000 [thread overview]
Message-ID: <20180303223010.27106-91-alexander.levin@microsoft.com> (raw)
In-Reply-To: <20180303223010.27106-1-alexander.levin@microsoft.com>
From: Lorenzo Colitti <lorenzo@google.com>
[ Upstream commit be8f8284cd897af2482d4e54fbc2bdfc15557259 ]
Currently it is possible to add or update socket policies, but
not clear them. Therefore, once a socket policy has been applied,
the socket cannot be used for unencrypted traffic.
This patch allows (privileged) users to clear socket policies by
passing in a NULL pointer and zero length argument to the
{IP,IPV6}_{IPSEC,XFRM}_POLICY setsockopts. This results in both
the incoming and outgoing policies being cleared.
The simple approach taken in this patch cannot clear socket
policies in only one direction. If desired this could be added
in the future, for example by continuing to pass in a length of
zero (which currently is guaranteed to return EMSGSIZE) and
making the policy be a pointer to an integer that contains one
of the XFRM_POLICY_{IN,OUT} enum values.
An alternative would have been to interpret the length as a
signed integer and use XFRM_POLICY_IN (i.e., 0) to clear the
input policy and -XFRM_POLICY_OUT (i.e., -1) to clear the output
policy.
Tested: https://android-review.googlesource.com/539816
Signed-off-by: Lorenzo Colitti <lorenzo@google.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
net/xfrm/xfrm_policy.c | 2 +-
net/xfrm/xfrm_state.c | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 4b09a9eaa35f..d95cb69460f0 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1313,7 +1313,7 @@ EXPORT_SYMBOL(xfrm_policy_delete);
int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol)
{
- struct net *net = xp_net(pol);
+ struct net *net = sock_net(sk);
struct xfrm_policy *old_pol;
#ifdef CONFIG_XFRM_SUB_POLICY
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 9895a8c56d8c..96d664e198bf 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1845,6 +1845,13 @@ int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen
struct xfrm_mgr *km;
struct xfrm_policy *pol = NULL;
+ if (!optval && !optlen) {
+ xfrm_sk_policy_insert(sk, XFRM_POLICY_IN, NULL);
+ xfrm_sk_policy_insert(sk, XFRM_POLICY_OUT, NULL);
+ __sk_dst_reset(sk);
+ return 0;
+ }
+
if (optlen <= 0 || optlen > PAGE_SIZE)
return -EMSGSIZE;
--
2.14.1
next prev parent reply other threads:[~2018-03-03 22:40 UTC|newest]
Thread overview: 118+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-03 22:30 [PATCH AUTOSEL for 4.4 001/115] Input: tsc2007 - check for presence and power down tsc2007 during probe Sasha Levin
2018-03-03 22:30 ` [PATCH AUTOSEL for 4.4 002/115] kretprobes: Ensure probe location is at function entry Sasha Levin
2018-03-03 22:30 ` [PATCH AUTOSEL for 4.4 003/115] staging: speakup: Replace BUG_ON() with WARN_ON() Sasha Levin
2018-03-03 22:30 ` [PATCH AUTOSEL for 4.4 004/115] staging: wilc1000: add check for kmalloc allocation failure Sasha Levin
2018-03-03 22:30 ` [PATCH AUTOSEL for 4.4 006/115] drm: qxl: Don't alloc fbdev if emulation is not supported Sasha Levin
2018-03-03 22:30 ` [PATCH AUTOSEL for 4.4 005/115] HID: reject input outside logical range only if null state is set Sasha Levin
2018-03-03 22:30 ` [PATCH AUTOSEL for 4.4 007/115] ath10k: fix a warning during channel switch with multiple vaps Sasha Levin
2018-03-03 22:30 ` [PATCH AUTOSEL for 4.4 008/115] net: mvpp2: set dma mask and coherent dma mask on PPv2.2 Sasha Levin
2018-03-03 22:30 ` [PATCH AUTOSEL for 4.4 009/115] PCI/MSI: Stop disabling MSI/MSI-X in pci_device_shutdown() Sasha Levin
2018-03-03 22:30 ` [PATCH AUTOSEL for 4.4 010/115] selinux: check for address length in selinux_socket_bind() Sasha Levin
2018-03-03 22:30 ` [PATCH AUTOSEL for 4.4 011/115] perf sort: Fix segfault with basic block 'cycles' sort dimension Sasha Levin
2018-03-03 22:30 ` [PATCH AUTOSEL for 4.4 012/115] i40e: Acquire NVM lock before reads on all devices Sasha Levin
2018-03-03 22:30 ` [PATCH AUTOSEL for 4.4 013/115] i40e: fix ethtool to get EEPROM data from X722 interface Sasha Levin
2018-03-03 22:30 ` [PATCH AUTOSEL for 4.4 014/115] perf tools: Make perf_event__synthesize_mmap_events() scale Sasha Levin
2018-03-03 22:30 ` [PATCH AUTOSEL for 4.4 015/115] drivers: net: xgene: Fix hardware checksum setting Sasha Levin
2018-03-03 22:30 ` [PATCH AUTOSEL for 4.4 016/115] drm: Defer disabling the vblank IRQ until the next interrupt (for instant-off) Sasha Levin
2018-03-29 16:32 ` Ben Hutchings
2018-03-29 16:42 ` Ville Syrjälä
2018-03-29 18:46 ` Ben Hutchings
2018-03-03 22:30 ` [PATCH AUTOSEL for 4.4 017/115] ath10k: disallow DFS simulation if DFS channel is not enabled Sasha Levin
2018-03-03 22:30 ` [PATCH AUTOSEL for 4.4 018/115] perf probe: Return errno when not hitting any event Sasha Levin
2018-03-03 22:30 ` [PATCH AUTOSEL for 4.4 019/115] HID: clamp input to logical range if no null state Sasha Levin
2018-03-03 22:30 ` [PATCH AUTOSEL for 4.4 020/115] net/8021q: create device with all possible features in wanted_features Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 022/115] batman-adv: handle race condition for claims between gateways Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 021/115] ARM: dts: Adjust moxart IRQ controller and flags Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 023/115] of: fix of_device_get_modalias returned length when truncating buffers Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 024/115] [media] solo6x10: release vb2 buffers in solo_stop_streaming() Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 025/115] scsi: ipr: Fix missed EH wakeup Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 026/115] [media] media: i2c/soc_camera: fix ov6650 sensor getting wrong clock Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 028/115] sysrq: Reset the watchdog timers while displaying high-resolution timers Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 027/115] timers, sched_clock: Update timeout for clock wrap Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 029/115] Input: qt1070 - add OF device ID table Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 031/115] ASoC: rcar: ssi: don't set SSICR.CKDV = 000 with SSIWSR.CONT Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 030/115] sched: act_csum: don't mangle TCP and UDP GSO packets Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 033/115] tcp: sysctl: Fix a race to avoid unexpected 0 window from space Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 032/115] spi: omap2-mcspi: poll OMAP2_MCSPI_CHSTAT_RXS for PIO transfer Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 034/115] dmaengine: imx-sdma: add 1ms delay to ensure SDMA channel is stopped Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 035/115] powerpc/xmon: Fix an unexpected xmon on/off state change Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 036/115] driver: (adm1275) set the m,b and R coefficients correctly for power Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 037/115] mm: Fix false-positive VM_BUG_ON() in page_cache_{get,add}_speculative() Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 038/115] blk-throttle: make sure expire time isn't too big Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 039/115] ARM: DRA7: hwmod_data: Prevent wait_target_disable error for usb_otg_ss Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 040/115] f2fs: relax node version check for victim data in gc Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 041/115] bonding: refine bond_fold_stats() wrap detection Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 044/115] drm/vmwgfx: Fixes to vmwgfx_fb Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 043/115] braille-console: Fix value returned by _braille_console_setup Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 046/115] NFC: nfcmrvl: Include unaligned.h instead of access_ok.h Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 045/115] vxlan: vxlan dev should inherit lowerdev's gso_max_size Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 047/115] NFC: nfcmrvl: double free on error path Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 048/115] ARM: dts: r8a7790: Correct parent of SSI[0-9] clocks Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 050/115] powerpc: Avoid taking a data miss on every userspace instruction miss Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 049/115] ARM: dts: r8a7791: Correct parent of SSI[0-9] clocks Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 052/115] ARM: dts: koelsch: Correct clock frequency of X2 DU clock input Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 051/115] net/faraday: Add missing include of of.h Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 053/115] reiserfs: Make cancel_old_flush() reliable Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 054/115] ASoc: rt5645: Add OF device ID table Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 055/115] ASoC: ssm4567: " Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 056/115] ASoC: wm8978: " Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 057/115] ALSA: firewire-digi00x: handle all MIDI messages on streaming packets Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 058/115] fm10k: correctly check if interface is removed Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 059/115] scsi: ses: don't get power status of SES device slot on probe Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 060/115] apparmor: Make path_max parameter readonly Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 061/115] iommu/iova: Fix underflow bug in __alloc_and_insert_iova_range Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 062/115] ARM: dts: rockchip: disable arm-global-timer for rk3188 Sasha Levin
2018-03-04 23:19 ` Alexander Kochetkov
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 063/115] video: ARM CLCD: fix dma allocation size Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 064/115] drm/radeon: Fail fb creation from imported dma-bufs Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 065/115] drm/amdgpu: Fail fb creation from imported dma-bufs. (v2) Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 066/115] coresight: Fixes coresight DT parse to get correct output port ID Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 067/115] MIPS: BPF: Quit clobbering callee saved registers in JIT code Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 068/115] MIPS: BPF: Fix multiple problems in JIT skb access helpers Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 069/115] MIPS: r2-on-r6-emu: Fix BLEZL and BGTZL identification Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 071/115] regulator: isl9305: fix array size Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 070/115] MIPS: r2-on-r6-emu: Clear BLTZALL and BGEZALL debugfs counters Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 072/115] md/raid6: Fix anomily when recovering a single device in RAID6 Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 074/115] usb: gadget: dummy_hcd: Fix wrong power status bit clear/reset in dummy_hub_control() Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 073/115] usb: dwc2: Make sure we disconnect the gadget state Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 075/115] drivers/perf: arm_pmu: handle no platform_device Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 077/115] perf session: Don't rely on evlist in pipe mode Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 076/115] perf inject: Copy events when reordering events " Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 078/115] scsi: sg: check for valid direction before starting the request Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 079/115] scsi: sg: close race condition in sg_remove_sfp_usercontext() Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 080/115] kprobes/x86: Fix kprobe-booster not to boost far call instructions Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 082/115] pwm: tegra: Increase precision in PWM rate calculation Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 081/115] kprobes/x86: Set kprobes pages read-only Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 083/115] wil6210: fix memory access violation in wil_memcpy_from/toio_32 Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 084/115] drm/edid: set ELD connector type in drm_edid_to_eld() Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 085/115] video/hdmi: Allow "empty" HDMI infoframes Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 087/115] ARM: dts: exynos: Correct Trats2 panel reset line Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 086/115] HID: elo: clear BTN_LEFT mapping Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 089/115] sched: Stop resched_cpu() from sending IPIs to offline CPUs Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 088/115] sched: Stop switched_to_rt() " Sasha Levin
2018-03-03 22:31 ` Sasha Levin [this message]
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 090/115] test_firmware: fix setting old custom fw path back on exit Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 092/115] mtd: nand: fix interpretation of NAND_CMD_NONE in nand_command[_lp]() Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 093/115] ARM: dts: am335x-pepper: Fix the audio CODEC's reset pin Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 094/115] ARM: dts: omap3-n900: " Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 095/115] mtd: nand: ifc: update bufnum mask for ver >= 2.0.0 Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 096/115] ASoC: tlv320aic31xx: Handle inverted BCLK in non-DSP modes Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 098/115] cpufreq: Fix governor module removal race Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 097/115] ath10k: update tdls teardown state to target Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 099/115] clk: qcom: msm8916: fix mnd_width for codec_digcodec Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 100/115] ath10k: fix invalid STS_CAP_OFFSET_MASK Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 101/115] tools/usbip: fixes build with musl libc toolchain Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 102/115] spi: sun6i: disable/unprepare clocks on remove Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 103/115] scsi: core: scsi_get_device_flags_keyed(): Always return device flags Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 104/115] scsi: devinfo: apply to HP XP the same flags as Hitachi VSP Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 105/115] scsi: dh: add new rdac devices Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 106/115] media: cpia2: Fix a couple off by one bugs Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 107/115] veth: set peer GSO values Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 108/115] drm/amdkfd: Fix memory leaks in kfd topology Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 109/115] agp/intel: Flush all chipset writes after updating the GGTT Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 110/115] mac80211_hwsim: enforce PS_MANUAL_POLL to be set after PS_ENABLED Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 112/115] ASoC: nuc900: Fix a loop timeout test Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 111/115] mac80211: remove BUG() when interface type is invalid Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 114/115] rcutorture/configinit: Fix build directory error message Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 113/115] ipvlan: add L2 check for packets arriving via virtual devices Sasha Levin
2018-03-03 22:31 ` [PATCH AUTOSEL for 4.4 115/115] ima: relax requiring a file signature for new files with zero length 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=20180303223010.27106-91-alexander.levin@microsoft.com \
--to=alexander.levin@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lorenzo@google.com \
--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
all inboxes | Powered by JetHome®