netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Anton Protopopov <a.s.protopopov@gmail.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Alexei Starovoitov <ast@kernel.org>,
	Sasha Levin <sashal@kernel.org>,
	netdev@vger.kernel.org, bpf@vger.kernel.org
Subject: [PATCH AUTOSEL 5.4 169/175] bpf: Fix map permissions check
Date: Mon,  8 Jun 2020 19:18:42 -0400	[thread overview]
Message-ID: <20200608231848.3366970-169-sashal@kernel.org> (raw)
In-Reply-To: <20200608231848.3366970-1-sashal@kernel.org>

From: Anton Protopopov <a.s.protopopov@gmail.com>

[ Upstream commit 1ea0f9120c8ce105ca181b070561df5cbd6bc049 ]

The map_lookup_and_delete_elem() function should check for both FMODE_CAN_WRITE
and FMODE_CAN_READ permissions because it returns a map element to user space.

Fixes: bd513cd08f10 ("bpf: add MAP_LOOKUP_AND_DELETE_ELEM syscall")
Signed-off-by: Anton Protopopov <a.s.protopopov@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20200527185700.14658-5-a.s.protopopov@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/bpf/syscall.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 946cfdd3b2cc..e7af1ac69d75 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -1118,7 +1118,8 @@ static int map_lookup_and_delete_elem(union bpf_attr *attr)
 	map = __bpf_map_get(f);
 	if (IS_ERR(map))
 		return PTR_ERR(map);
-	if (!(map_get_sys_perms(map, f) & FMODE_CAN_WRITE)) {
+	if (!(map_get_sys_perms(map, f) & FMODE_CAN_READ) ||
+	    !(map_get_sys_perms(map, f) & FMODE_CAN_WRITE)) {
 		err = -EPERM;
 		goto err_put;
 	}
-- 
2.25.1


  parent reply	other threads:[~2020-06-09  0:01 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200608231848.3366970-1-sashal@kernel.org>
2020-06-08 23:15 ` [PATCH AUTOSEL 5.4 002/175] ath10k: Fix the race condition in firmware dump work queue Sasha Levin
2020-06-08 23:15 ` [PATCH AUTOSEL 5.4 003/175] ath9x: Fix stack-out-of-bounds Write in ath9k_hif_usb_rx_cb Sasha Levin
2020-06-08 23:15 ` [PATCH AUTOSEL 5.4 004/175] ath9k: Fix use-after-free Write in ath9k_htc_rx_msg Sasha Levin
2020-06-08 23:15 ` [PATCH AUTOSEL 5.4 005/175] ath9k: Fix use-after-free Read in htc_connect_service Sasha Levin
2020-06-08 23:16 ` [PATCH AUTOSEL 5.4 016/175] libbpf: Fix memory leak and possible double-free in hashmap__clear Sasha Levin
2020-06-08 23:16 ` [PATCH AUTOSEL 5.4 020/175] net: atlantic: make hw_get_regs optional Sasha Levin
2020-06-08 23:16 ` [PATCH AUTOSEL 5.4 021/175] net: ena: fix error returning in ena_com_get_hash_function() Sasha Levin
2020-06-08 23:16 ` [PATCH AUTOSEL 5.4 023/175] ath10k: remove the max_sched_scan_reqs value Sasha Levin
2020-06-08 23:16 ` [PATCH AUTOSEL 5.4 026/175] rtw88: fix an issue about leak system resources Sasha Levin
2020-06-08 23:16 ` [PATCH AUTOSEL 5.4 035/175] ixgbe: Fix XDP redirect on archs with PAGE_SIZE above 4K Sasha Levin
2020-06-08 23:16 ` [PATCH AUTOSEL 5.4 038/175] Bluetooth: Add SCO fallback for invalid LMP parameters error Sasha Levin
2020-06-08 23:16 ` [PATCH AUTOSEL 5.4 051/175] batman-adv: Revert "disable ethtool link speed detection when auto negotiation off" Sasha Levin
2020-06-08 23:16 ` [PATCH AUTOSEL 5.4 052/175] ice: Fix memory leak Sasha Levin
2020-06-08 23:16 ` [PATCH AUTOSEL 5.4 053/175] ice: Fix for memory leaks and modify ICE_FREE_CQ_BUFS Sasha Levin
2020-06-08 23:16 ` [PATCH AUTOSEL 5.4 058/175] net: vmxnet3: fix possible buffer overflow caused by bad DMA value in vmxnet3_get_rss() Sasha Levin
2020-06-08 23:16 ` [PATCH AUTOSEL 5.4 059/175] tun: correct header offsets in napi frags mode Sasha Levin
2020-06-08 23:16 ` [PATCH AUTOSEL 5.4 062/175] ath10k: fix kernel null pointer dereference Sasha Levin
2020-06-08 23:16 ` [PATCH AUTOSEL 5.4 063/175] ath9k: Fix use-after-free Read in ath9k_wmi_ctrl_rx Sasha Levin
2020-06-08 23:16 ` [PATCH AUTOSEL 5.4 064/175] ath9k: Fix general protection fault in ath9k_hif_usb_rx_cb Sasha Levin
2020-06-08 23:17 ` [PATCH AUTOSEL 5.4 067/175] brcmfmac: fix wrong location to get firmware feature Sasha Levin
2020-06-08 23:17 ` [PATCH AUTOSEL 5.4 070/175] e1000: Distribute switch variables for initialization Sasha Levin
2020-06-08 23:17 ` [PATCH AUTOSEL 5.4 077/175] ath10k: add flush tx packets for SDIO chip Sasha Levin
2020-06-08 23:17 ` [PATCH AUTOSEL 5.4 081/175] dpaa2-eth: fix return codes used in ndo_setup_tc Sasha Levin
2020-06-08 23:17 ` [PATCH AUTOSEL 5.4 082/175] netfilter: nft_nat: return EOPNOTSUPP if type or flags are not supported Sasha Levin
2020-06-08 23:17 ` [PATCH AUTOSEL 5.4 083/175] selftests/bpf: Fix memory leak in extract_build_id() Sasha Levin
2020-06-08 23:17 ` [PATCH AUTOSEL 5.4 084/175] net: bcmgenet: set Rx mode before starting netif Sasha Levin
2020-06-08 23:17 ` [PATCH AUTOSEL 5.4 085/175] net: bcmgenet: Fix WoL with password after deep sleep Sasha Levin
2020-06-08 23:17 ` [PATCH AUTOSEL 5.4 092/175] net: lpc-enet: fix error return code in lpc_mii_init() Sasha Levin
2020-06-08 23:17 ` [PATCH AUTOSEL 5.4 094/175] drivers: net: davinci_mdio: fix potential NULL dereference in davinci_mdio_probe() Sasha Levin
2020-06-08 23:17 ` [PATCH AUTOSEL 5.4 096/175] net: allwinner: Fix use correct return type for ndo_start_xmit() Sasha Levin
2020-06-08 23:17 ` [PATCH AUTOSEL 5.4 098/175] ath9k_htc: Silence undersized packet warnings Sasha Levin
2020-06-08 23:17 ` [PATCH AUTOSEL 5.4 099/175] libertas_tf: avoid a null dereference in pointer priv Sasha Levin
2020-06-08 23:17 ` [PATCH AUTOSEL 5.4 112/175] iwlwifi: avoid debug max amsdu config overwriting itself Sasha Levin
2020-06-08 23:17 ` [PATCH AUTOSEL 5.4 116/175] ath10k: Remove msdu from idr when management pkt send fails Sasha Levin
2020-06-08 23:17 ` [PATCH AUTOSEL 5.4 117/175] wcn36xx: Fix error handling path in 'wcn36xx_probe()' Sasha Levin
2020-06-08 23:17 ` [PATCH AUTOSEL 5.4 118/175] net: qed*: Reduce RX and TX default ring count when running inside kdump kernel Sasha Levin
2020-06-08 23:17 ` [PATCH AUTOSEL 5.4 120/175] mt76: avoid rx reorder buffer overflow Sasha Levin
2020-06-08 23:17 ` [PATCH AUTOSEL 5.4 123/175] net: dsa: mt7530: set CPU port to fallback mode Sasha Levin
2020-06-08 23:17 ` [PATCH AUTOSEL 5.4 126/175] veth: Adjust hard_start offset on redirect XDP frames Sasha Levin
2020-06-08 23:18 ` [PATCH AUTOSEL 5.4 127/175] net/mlx5e: IPoIB, Drop multicast packets that this interface sent Sasha Levin
2020-06-08 23:18 ` [PATCH AUTOSEL 5.4 128/175] rtlwifi: Fix a double free in _rtl_usb_tx_urb_setup() Sasha Levin
2020-06-08 23:18 ` [PATCH AUTOSEL 5.4 129/175] mwifiex: Fix memory corruption in dump_station Sasha Levin
2020-06-08 23:18 ` [PATCH AUTOSEL 5.4 140/175] selftests/bpf: CONFIG_IPV6_SEG6_BPF required for test_seg6_loop.o Sasha Levin
2020-06-08 23:18 ` [PATCH AUTOSEL 5.4 146/175] net: ethernet: fec: move GPR register offset and bit into DT Sasha Levin
2020-06-08 23:18 ` [PATCH AUTOSEL 5.4 147/175] macvlan: Skip loopback packets in RX handler Sasha Levin
2020-06-08 23:18 ` [PATCH AUTOSEL 5.4 157/175] ice: fix potential double free in probe unrolling Sasha Levin
2020-06-08 23:18 ` [PATCH AUTOSEL 5.4 158/175] ixgbe: fix signed-integer-overflow warning Sasha Levin
2020-06-08 23:18 ` [PATCH AUTOSEL 5.4 159/175] iwlwifi: mvm: fix aux station leak Sasha Levin
2020-06-08 23:18 ` [PATCH AUTOSEL 5.4 167/175] vxlan: Avoid infinite loop when suppressing NS messages with invalid options Sasha Levin
2020-06-08 23:18 ` [PATCH AUTOSEL 5.4 168/175] libbpf: Fix perf_buffer__free() API for sparse allocs Sasha Levin
2020-06-08 23:18 ` Sasha Levin [this message]
2020-06-08 23:18 ` [PATCH AUTOSEL 5.4 170/175] bpf: Refactor sockmap redirect code so its easy to reuse Sasha Levin
2020-06-08 23:18 ` [PATCH AUTOSEL 5.4 171/175] bpf: Fix running sk_skb program types with ktls Sasha Levin
2020-06-08 23:18 ` [PATCH AUTOSEL 5.4 172/175] selftests/bpf, flow_dissector: Close TAP device FD after the test Sasha Levin
2020-06-08 23:18 ` [PATCH AUTOSEL 5.4 173/175] net_failover: fixed rollback in net_failover_open() 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=20200608231848.3366970-169-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=a.s.protopopov@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /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).