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, Bui Quang Minh <minhquangbui99@gmail.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.4 28/60] bpf: Check for integer overflow when using roundup_pow_of_two()
Date: Mon, 15 Feb 2021 16:27:16 +0100	[thread overview]
Message-ID: <20210215152716.249107879@linuxfoundation.org> (raw)
In-Reply-To: <20210215152715.401453874@linuxfoundation.org>

From: Bui Quang Minh <minhquangbui99@gmail.com>

[ Upstream commit 6183f4d3a0a2ad230511987c6c362ca43ec0055f ]

On 32-bit architecture, roundup_pow_of_two() can return 0 when the argument
has upper most bit set due to resulting 1UL << 32. Add a check for this case.

Fixes: d5a3b1f69186 ("bpf: introduce BPF_MAP_TYPE_STACK_TRACE")
Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20210127063653.3576-1-minhquangbui99@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/bpf/stackmap.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c
index 173e983619d77..fba2ade28fb3a 100644
--- a/kernel/bpf/stackmap.c
+++ b/kernel/bpf/stackmap.c
@@ -112,6 +112,8 @@ static struct bpf_map *stack_map_alloc(union bpf_attr *attr)
 
 	/* hash table size must be power of 2 */
 	n_buckets = roundup_pow_of_two(attr->max_entries);
+	if (!n_buckets)
+		return ERR_PTR(-E2BIG);
 
 	cost = n_buckets * sizeof(struct stack_map_bucket *) + sizeof(*smap);
 	cost += n_buckets * (value_size + sizeof(struct stack_map_bucket));
-- 
2.27.0




  parent reply	other threads:[~2021-02-15 15:47 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-15 15:26 [PATCH 5.4 00/60] 5.4.99-rc1 review Greg Kroah-Hartman
2021-02-15 15:26 ` [PATCH 5.4 01/60] gpio: ep93xx: fix BUG_ON port F usage Greg Kroah-Hartman
2021-02-15 15:26 ` [PATCH 5.4 02/60] gpio: ep93xx: Fix single irqchip with multi gpiochips Greg Kroah-Hartman
2021-02-15 15:26 ` [PATCH 5.4 03/60] tracing: Do not count ftrace events in top level enable output Greg Kroah-Hartman
2021-02-15 15:26 ` [PATCH 5.4 04/60] tracing: Check length before giving out the filter buffer Greg Kroah-Hartman
2021-02-15 15:26 ` [PATCH 5.4 05/60] arm/xen: Dont probe xenbus as part of an early initcall Greg Kroah-Hartman
2021-02-15 15:26 ` [PATCH 5.4 06/60] cgroup: fix psi monitor for root cgroup Greg Kroah-Hartman
2021-02-15 15:26 ` [PATCH 5.4 07/60] arm64: dts: rockchip: Fix PCIe DT properties on rk3399 Greg Kroah-Hartman
2021-02-15 15:26 ` [PATCH 5.4 08/60] arm64: dts: qcom: sdm845: Reserve LPASS clocks in gcc Greg Kroah-Hartman
2021-02-15 15:26 ` [PATCH 5.4 09/60] ARM: OMAP2+: Fix suspcious RCU usage splats for omap_enter_idle_coupled Greg Kroah-Hartman
2021-02-15 15:26 ` [PATCH 5.4 10/60] platform/x86: hp-wmi: Disable tablet-mode reporting by default Greg Kroah-Hartman
2021-02-15 15:26 ` [PATCH 5.4 11/60] ovl: perform vfs_getxattr() with mounter creds Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 12/60] cap: fix conversions on getxattr Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 13/60] ovl: skip getxattr of security labels Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 14/60] nvme-pci: ignore the subsysem NQN on Phison E16 Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 15/60] drm/amd/display: Add more Clock Sources to DCN2.1 Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 16/60] drm/amd/display: Fix dc_sink kref count in emulated_link_detect Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 17/60] drm/amd/display: Free atomic state after drm_atomic_commit Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 18/60] drm/amd/display: Decrement refcount of dc_sink before reassignment Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 19/60] riscv: virt_addr_valid must check the address belongs to linear mapping Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 20/60] bfq-iosched: Revert "bfq: Fix computation of shallow depth" Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 21/60] ARM: dts: lpc32xx: Revert set default clock rate of HCLK PLL Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 22/60] ARM: ensure the signal page contains defined contents Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 23/60] ARM: kexec: fix oops after TLB are invalidated Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 24/60] vmlinux.lds.h: Create section for protection against instrumentation Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 25/60] lkdtm: dont move ctors to .rodata Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 26/60] mt76: dma: fix a possible memory leak in mt76_add_fragment() Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 27/60] drm/vc4: hvs: Fix buffer overflow with the dlist handling Greg Kroah-Hartman
2021-02-15 15:27 ` Greg Kroah-Hartman [this message]
2021-02-15 15:27 ` [PATCH 5.4 29/60] netfilter: xt_recent: Fix attempt to update deleted entry Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 30/60] netfilter: nftables: fix possible UAF over chains from packet path in netns Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 31/60] netfilter: flowtable: fix tcp and udp header checksum update Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 32/60] xen/netback: avoid race in xenvif_rx_ring_slots_available() Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 33/60] net: enetc: initialize the RFS and RSS memories Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 34/60] selftests: txtimestamp: fix compilation issue Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 35/60] net: stmmac: set TxQ mode back to DCB after disabling CBS Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 36/60] ibmvnic: Clear failover_pending if unable to schedule Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 37/60] netfilter: conntrack: skip identical origin tuple in same zone only Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 38/60] x86/build: Disable CET instrumentation in the kernel for 32-bit too Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 39/60] net: hns3: add a check for queue_id in hclge_reset_vf_queue() Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 40/60] firmware_loader: align .builtin_fw to 8 Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 41/60] drm/sun4i: tcon: set sync polarity for tcon1 channel Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 42/60] drm/sun4i: Fix H6 HDMI PHY configuration Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 43/60] drm/sun4i: dw-hdmi: Fix max. frequency for H6 Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 44/60] clk: sunxi-ng: mp: fix parent rate change flag check Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 45/60] i2c: stm32f7: fix configuration of the digital filter Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 46/60] h8300: fix PREEMPTION build, TI_PRE_COUNT undefined Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 47/60] usb: dwc3: ulpi: fix checkpatch warning Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 48/60] usb: dwc3: ulpi: Replace CPU-based busyloop with Protocol-based one Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 49/60] rxrpc: Fix clearance of Tx/Rx ring when releasing a call Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 50/60] udp: fix skb_copy_and_csum_datagram with odd segment sizes Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 51/60] net: dsa: call teardown method on probe failure Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 52/60] net: gro: do not keep too many GRO packets in napi->rx_list Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 53/60] net: fix iteration for sctp transport seq_files Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 54/60] net/vmw_vsock: improve locking in vsock_connect_timeout() Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 55/60] net: watchdog: hold device global xmit lock during tx disable Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 56/60] vsock/virtio: update credit only if socket is not closed Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 57/60] vsock: fix locking in vsock_shutdown() Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 58/60] net/rds: restrict iovecs length for RDS_CMSG_RDMA_ARGS Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 59/60] net/qrtr: restrict user-controlled length in qrtr_tun_write_iter() Greg Kroah-Hartman
2021-02-15 15:27 ` [PATCH 5.4 60/60] ovl: expand warning in ovl_d_real() Greg Kroah-Hartman
2021-02-16  3:59 ` [PATCH 5.4 00/60] 5.4.99-rc1 review Naresh Kamboju
2021-02-16 18:43 ` Guenter Roeck
2021-02-16 22:29 ` Shuah Khan
2021-02-17  1:12 ` Ross Schmidt

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=20210215152716.249107879@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=daniel@iogearbox.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minhquangbui99@gmail.com \
    --cc=sashal@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).