No description
Find a file
Kuniyuki Iwashima b978d22fa1 netlink: Use copy_to_user() for optval in netlink_getsockopt().
[ Upstream commit d913d32cc2 ]

Brad Spencer provided a detailed report [0] that when calling getsockopt()
for AF_NETLINK, some SOL_NETLINK options set only 1 byte even though such
options require at least sizeof(int) as length.

The options return a flag value that fits into 1 byte, but such behaviour
confuses users who do not initialise the variable before calling
getsockopt() and do not strictly check the returned value as char.

Currently, netlink_getsockopt() uses put_user() to copy data to optlen and
optval, but put_user() casts the data based on the pointer, char *optval.
As a result, only 1 byte is set to optval.

To avoid this behaviour, we need to use copy_to_user() or cast optval for
put_user().

Note that this changes the behaviour on big-endian systems, but we document
that the size of optval is int in the man page.

  $ man 7 netlink
  ...
  Socket options
       To set or get a netlink socket option, call getsockopt(2) to read
       or setsockopt(2) to write the option with the option level argument
       set to SOL_NETLINK.  Unless otherwise noted, optval is a pointer to
       an int.

Fixes: 9a4595bc7e ("[NETLINK]: Add set/getsockopt options to support more than 32 groups")
Fixes: be0c22a46c ("netlink: add NETLINK_BROADCAST_ERROR socket option")
Fixes: 38938bfe34 ("netlink: add NETLINK_NO_ENOBUFS socket flag")
Fixes: 0a6a3a23ea ("netlink: add NETLINK_CAP_ACK socket option")
Fixes: 2d4bc93368 ("netlink: extended ACK reporting")
Fixes: 89d35528d1 ("netlink: Add new socket option to enable strict checking on dumps")
Reported-by: Brad Spencer <bspencer@blackberry.com>
Link: https://lore.kernel.org/netdev/ZD7VkNWFfp22kTDt@datsun.rim.net/
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Johannes Berg <johannes@sipsolutions.net>
Link: https://lore.kernel.org/r/20230421185255.94606-1-kuniyu@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-05-17 11:47:54 +02:00
arch arm64: kgdb: Set PSTATE.SS to 1 to re-enable single-step 2023-05-17 11:47:45 +02:00
block blk-crypto: make blk_crypto_evict_key() more robust 2023-05-17 11:47:32 +02:00
certs certs/blacklist_hashes.c: fix const confusion in certs blacklist 2022-06-22 14:13:17 +02:00
crypto crypto: drbg - Only fail when jent is unavailable in FIPS mode 2023-05-17 11:47:50 +02:00
Documentation docs: futex: Fix kernel-doc references after code split-up preparation 2023-04-26 11:27:40 +02:00
drivers Revert "Bluetooth: btsdio: fix use after free bug in btsdio_remove due to unfinished work" 2023-05-17 11:47:54 +02:00
fs jdb2: Don't refuse invalidation of already invalidated buffers 2023-05-17 11:47:52 +02:00
include netfilter: nf_tables: don't write table validation state without mutex 2023-05-17 11:47:53 +02:00
init kbuild: check the minimum assembler version in Kconfig 2023-04-20 12:10:28 +02:00
io_uring io_uring: avoid null-ptr-deref in io_arm_poll_handler 2023-03-22 13:30:05 +01:00
ipc ipc/sem: Fix dangling sem_array access in semtimedop race 2022-12-08 11:24:00 +01:00
kernel bpf: Don't EFAULT for getsockopt with optval=NULL 2023-05-17 11:47:53 +02:00
lib debugobject: Prevent init race with static objects 2023-05-17 11:47:45 +02:00
LICENSES
mm writeback, cgroup: fix null-ptr-deref write in bdi_split_work_to_wbs 2023-05-17 11:47:34 +02:00
net netlink: Use copy_to_user() for optval in netlink_getsockopt(). 2023-05-17 11:47:54 +02:00
samples samples: vfio-mdev: Fix missing pci_disable_device() in mdpy_fb_probe() 2023-01-14 10:16:01 +01:00
scripts ASN.1: Fix check for strdup() success 2023-04-26 11:27:42 +02:00
security selinux: ensure av_permissions.h is built when needed 2023-05-17 11:47:37 +02:00
sound sound/oss/dmasound: fix build when drivers are mixed =y/=m 2023-05-17 11:47:35 +02:00
tools bpftool: Fix bug for long instructions in program CFG dumps 2023-05-17 11:47:50 +02:00
usr usr/include/Makefile: add linux/nfc.h to the compile-test coverage 2022-02-01 17:25:48 +01:00
virt KVM: fix memoryleak in kvm_init() 2023-04-05 11:23:43 +02:00
.clang-format RDMA 5.10 pull request 2020-10-17 11:18:18 -07:00
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore kbuild: generate Module.symvers only when vmlinux exists 2021-05-19 10:12:59 +02:00
.mailmap mailmap: add two more addresses of Uwe Kleine-König 2020-12-06 10:19:07 -08:00
COPYING
CREDITS MAINTAINERS: Move Jason Cooper to CREDITS 2020-11-30 10:20:34 +01:00
Kbuild
Kconfig
MAINTAINERS audit: update the mailing list in MAINTAINERS 2023-02-25 11:55:04 +01:00
Makefile Linux 5.10.179 2023-04-26 11:27:43 +02:00
README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.