From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org,
Christophe Leroy <christophe.leroy@c-s.fr>,
Richard Guy Briggs <rgb@redhat.com>,
"Erhard F." <erhard_f@mailbox.org>,
Nikolay Aleksandrov <nikolay@cumulusnetworks.com>,
"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 4.9 40/88] net: netlink: cap max groups which will be considered in netlink_bind()
Date: Tue, 10 Mar 2020 13:38:48 +0100 [thread overview]
Message-ID: <20200310123615.720352829@linuxfoundation.org> (raw)
In-Reply-To: <20200310123606.543939933@linuxfoundation.org>
From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
commit 3a20773beeeeadec41477a5ba872175b778ff752 upstream.
Since nl_groups is a u32 we can't bind more groups via ->bind
(netlink_bind) call, but netlink has supported more groups via
setsockopt() for a long time and thus nlk->ngroups could be over 32.
Recently I added support for per-vlan notifications and increased the
groups to 33 for NETLINK_ROUTE which exposed an old bug in the
netlink_bind() code causing out-of-bounds access on archs where unsigned
long is 32 bits via test_bit() on a local variable. Fix this by capping the
maximum groups in netlink_bind() to BITS_PER_TYPE(u32), effectively
capping them at 32 which is the minimum of allocated groups and the
maximum groups which can be bound via netlink_bind().
CC: Christophe Leroy <christophe.leroy@c-s.fr>
CC: Richard Guy Briggs <rgb@redhat.com>
Fixes: 4f520900522f ("netlink: have netlink per-protocol bind function return an error code.")
Reported-by: Erhard F. <erhard_f@mailbox.org>
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/netlink/af_netlink.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1003,7 +1003,8 @@ static int netlink_bind(struct socket *s
if (nlk->netlink_bind && groups) {
int group;
- for (group = 0; group < nlk->ngroups; group++) {
+ /* nl_groups is a u32, so cap the maximum groups we can bind */
+ for (group = 0; group < BITS_PER_TYPE(u32); group++) {
if (!test_bit(group, &groups))
continue;
err = nlk->netlink_bind(net, group + 1);
@@ -1022,7 +1023,7 @@ static int netlink_bind(struct socket *s
netlink_insert(sk, nladdr->nl_pid) :
netlink_autobind(sock);
if (err) {
- netlink_undo_bind(nlk->ngroups, groups, sk);
+ netlink_undo_bind(BITS_PER_TYPE(u32), groups, sk);
return err;
}
}
next prev parent reply other threads:[~2020-03-10 13:34 UTC|newest]
Thread overview: 96+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-10 12:38 [PATCH 4.9 00/88] 4.9.216-stable review Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 01/88] iwlwifi: pcie: fix rb_allocator workqueue allocation Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 02/88] ext4: fix potential race between online resizing and write operations Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 03/88] ext4: fix potential race between s_flex_groups online resizing and access Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 04/88] ext4: fix potential race between s_group_info " Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 05/88] ipmi:ssif: Handle a possible NULL pointer reference Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 06/88] drm/msm: Set dma maximum segment size for mdss Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 07/88] mac80211: consider more elements in parsing CRC Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 08/88] cfg80211: check wiphy driver existence for drvinfo report Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 09/88] qmi_wwan: re-add DW5821e pre-production variant Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 10/88] net: ena: fix potential crash when rxfh key is NULL Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 11/88] net: ena: add missing ethtool TX timestamping indication Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 12/88] net: ena: fix incorrect default RSS key Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 13/88] net: ena: rss: fix failure to get indirection table Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 14/88] net: ena: rss: store hash function as values and not bits Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 15/88] net: ena: fix incorrectly saving queue numbers when setting RSS indirection table Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 16/88] net: ena: ena-com.c: prevent NULL pointer dereference Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 17/88] cifs: Fix mode output in debugging statements Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 18/88] cfg80211: add missing policy for NL80211_ATTR_STATUS_CODE Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 19/88] sysrq: Restore original console_loglevel when sysrq disabled Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 20/88] sysrq: Remove duplicated sysrq message Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 21/88] net: fib_rules: Correctly set table field when table number exceeds 8 bits Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 22/88] net: phy: restore mdio regs in the iproc mdio driver Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 23/88] ipv6: Fix nlmsg_flags when splitting a multipath route Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 24/88] ipv6: Fix route replacement with dev-only route Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 25/88] sctp: move the format error check out of __sctp_sf_do_9_1_abort Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 26/88] nfc: pn544: Fix occasional HW initialization failure Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 27/88] net: sched: correct flower port blocking Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 28/88] ext4: potential crash on allocation error in ext4_alloc_flex_bg_array() Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 29/88] audit: fix error handling in audit_data_to_entry() Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 30/88] ACPICA: Introduce ACPI_ACCESS_BYTE_WIDTH() macro Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 31/88] ACPI: watchdog: Fix gas->access_width usage Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 32/88] HID: core: fix off-by-one memset in hid_report_raw_event() Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 33/88] HID: core: increase HID report buffer size to 8KiB Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 34/88] HID: hiddev: Fix race in in hiddev_disconnect() Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 35/88] MIPS: VPE: Fix a double free and a memory leak in release_vpe() Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 36/88] i2c: jz4780: silence log flood on txabrt Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 37/88] ecryptfs: Fix up bad backport of fe2e082f5da5b4a0a92ae32978f81507ef37ec66 Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 38/88] serial: 8250: Check UPF_IRQ_SHARED in advance Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 39/88] include/linux/bitops.h: introduce BITS_PER_TYPE Greg Kroah-Hartman
2020-03-10 12:38 ` Greg Kroah-Hartman [this message]
2020-03-10 12:38 ` [PATCH 4.9 41/88] net: ena: make ena rxfh support ETH_RSS_HASH_NO_CHANGE Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 42/88] namei: only return -ECHILD from follow_dotdot_rcu() Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 43/88] KVM: Check for a bad hva before dropping into the ghc slow path Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 44/88] slip: stop double free sl->dev in slip_open Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 45/88] tuntap: correctly set SOCKWQ_ASYNC_NOSPACE Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 46/88] drivers: net: xgene: Fix the order of the arguments of alloc_etherdev_mqs() Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 47/88] perf hists browser: Restore ESC as "Zoom out" of DSO/thread/etc Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 48/88] mm/huge_memory.c: use head to check huge zero page Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 49/88] audit: always check the netlink payload length in audit_receive_msg() Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 50/88] vhost: Check docket sk_family instead of call getname Greg Kroah-Hartman
2020-03-10 12:38 ` [PATCH 4.9 51/88] serial: ar933x_uart: set UART_CS_{RX,TX}_READY_ORIDE Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 52/88] usb: gadget: composite: Support more than 500mA MaxPower Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 53/88] usb: gadget: ffs: ffs_aio_cancel(): Save/restore IRQ flags Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 54/88] usb: gadget: serial: fix Tx stall after buffer overflow Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 55/88] drm: msm: Fix return type of dsi_mgr_connector_mode_valid for kCFI Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 56/88] drm/msm/dsi: save pll state before dsi host is powered off Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 57/88] net: ks8851-ml: Remove 8-bit bus accessors Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 58/88] net: ks8851-ml: Fix 16-bit data access Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 59/88] net: ks8851-ml: Fix 16-bit IO operation Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 60/88] watchdog: da9062: do not ping the hw during stop() Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 61/88] s390/cio: cio_ignore_proc_seq_next should increase position index Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 62/88] x86/boot/compressed: Dont declare __force_order in kaslr_64.c Greg Kroah-Hartman
2020-03-10 14:33 ` Thomas Voegtle
2020-03-10 15:08 ` Borislav Petkov
2020-03-10 16:55 ` Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 63/88] cifs: dont leak -EAGAIN for stat() during reconnect Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 64/88] usb: storage: Add quirk for Samsung Fit flash Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 65/88] usb: quirks: add NO_LPM quirk for Logitech Screen Share Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 66/88] usb: core: hub: do error out if usb_autopm_get_interface() fails Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 67/88] usb: core: port: " Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 68/88] vgacon: Fix a UAF in vgacon_invert_region Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 69/88] fat: fix uninit-memory access for partial initialized inode Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 70/88] tty:serial:mvebu-uart:fix a wrong return Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 71/88] vt: selection, close sel_buffer race Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 72/88] vt: selection, push console lock down Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 73/88] vt: selection, push sel_lock up Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 74/88] x86/pkeys: Manually set X86_FEATURE_OSPKE to preserve existing changes Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 75/88] dmaengine: tegra-apb: Fix use-after-free Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 76/88] dmaengine: tegra-apb: Prevent race conditions of tasklet vs free list Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 77/88] ARM: dts: ls1021a: Restore MDIO compatible to gianfar Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 78/88] ASoC: pcm: Fix possible buffer overflow in dpcm state sysfs output Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 79/88] ASoC: pcm512x: Fix unbalanced regulator enable call in probe error path Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 80/88] ASoC: dapm: Correct DAPM handling of active widgets during shutdown Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 81/88] RDMA/iwcm: Fix iwcm work deallocation Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 82/88] RMDA/cm: Fix missing ib_cm_destroy_id() in ib_cm_insert_listen() Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 83/88] ARM: imx: build v7_cpu_resume() unconditionally Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 84/88] hwmon: (adt7462) Fix an error return in ADT7462_REG_VOLT() Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 85/88] dmaengine: coh901318: Fix a double lock bug in dma_tc_handle() Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 86/88] powerpc: fix hardware PMU exception bug on PowerVM compatibility mode systems Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 87/88] dm cache: fix a crash due to incorrect work item cancelling Greg Kroah-Hartman
2020-03-10 12:39 ` [PATCH 4.9 88/88] crypto: algif_skcipher - use ZERO_OR_NULL_PTR in skcipher_recvmsg_async Greg Kroah-Hartman
2020-03-10 18:21 ` [PATCH 4.9 00/88] 4.9.216-stable review Naresh Kamboju
2020-03-10 20:07 ` Jon Hunter
2020-03-10 21:32 ` shuah
2020-03-10 21:57 ` 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=20200310123615.720352829@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=christophe.leroy@c-s.fr \
--cc=davem@davemloft.net \
--cc=erhard_f@mailbox.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nikolay@cumulusnetworks.com \
--cc=rgb@redhat.com \
--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).