No description
Find a file
Sultan Alsawaf c5402fb5f7 zsmalloc: fix races between asynchronous zspage free and page migration
commit 2505a98111 upstream.

The asynchronous zspage free worker tries to lock a zspage's entire page
list without defending against page migration.  Since pages which haven't
yet been locked can concurrently migrate off the zspage page list while
lock_zspage() churns away, lock_zspage() can suffer from a few different
lethal races.

It can lock a page which no longer belongs to the zspage and unsafely
dereference page_private(), it can unsafely dereference a torn pointer to
the next page (since there's a data race), and it can observe a spurious
NULL pointer to the next page and thus not lock all of the zspage's pages
(since a single page migration will reconstruct the entire page list, and
create_page_chain() unconditionally zeroes out each list pointer in the
process).

Fix the races by using migrate_read_lock() in lock_zspage() to synchronize
with page migration.

Link: https://lkml.kernel.org/r/20220509024703.243847-1-sultan@kerneltoast.com
Fixes: 77ff465799 ("zsmalloc: zs_page_migrate: skip unnecessary loops but not return -EBUSY if zspage is not inuse")
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-06-06 08:48:56 +02:00
arch KVM: SVM: Use kzalloc for sev ioctl interfaces to prevent kernel data leak 2022-06-06 08:48:56 +02:00
block block/mq-deadline: Set the fifo_time member also if inserting at head 2022-05-13 17:02:46 -06:00
certs Kbuild updates for v5.18 2022-03-31 11:59:03 -07:00
crypto crypto: ecrdsa - Fix incorrect use of vli_cmp 2022-06-06 08:48:56 +02:00
Documentation random: fix sysctl documentation nits 2022-05-30 09:24:03 +02:00
drivers crypto: qat - rework the VF2PF interrupt handling logic 2022-06-06 08:48:56 +02:00
fs exfat: check if cluster num is valid 2022-06-06 08:48:54 +02:00
include netfilter: conntrack: re-fetch conntrack after insertion 2022-06-06 08:48:54 +02:00
init random: handle latent entropy and command line from random_init() 2022-05-30 09:24:07 +02:00
ipc fs: allocate inode by using alloc_inode_sb() 2022-03-22 15:57:03 -07:00
kernel timekeeping: Add raw clock fallback for random_get_entropy() 2022-05-30 09:24:04 +02:00
lib assoc_array: Fix BUG_ON during garbage collect 2022-06-06 08:48:53 +02:00
LICENSES LICENSES/LGPL-2.1: Add LGPL-2.1-or-later as valid identifiers 2021-12-16 14:33:10 +01:00
mm zsmalloc: fix races between asynchronous zspage free and page migration 2022-06-06 08:48:56 +02:00
net netfilter: nf_tables: double hook unregistration in netns path 2022-06-06 08:48:54 +02:00
samples sched/tracing: Append prev_state to tp args instead 2022-05-12 00:37:11 +02:00
scripts objtool: Enable unreachable warnings for CLANG LTO 2022-04-19 21:58:48 +02:00
security lockdown: also lock down previous kgdb use 2022-05-30 09:24:03 +02:00
sound ALSA: ctxfi: Add SB046x PCI ID 2022-05-30 09:24:09 +02:00
tools perf tools fixes for v5.18: 6th batch 2022-05-21 14:14:02 -10:00
usr Kbuild updates for v5.18 2022-03-31 11:59:03 -07:00
virt KVM: Free new dirty bitmap if creating a new memslot fails 2022-05-20 13:02:05 -04:00
.clang-format genirq/msi: Make interrupt allocation less convoluted 2021-12-16 22:22:20 +01:00
.cocciconfig scripts: add Linux .cocciconfig for coccinelle 2016-07-22 12:13:39 +02:00
.get_maintainer.ignore Opt out of scripts/get_maintainer.pl 2019-05-16 10:53:40 -07:00
.gitattributes .gitattributes: use 'dts' diff driver for dts files 2019-12-04 19:44:11 -08:00
.gitignore .gitignore: ignore only top-level modules.builtin 2021-05-02 00:43:35 +09:00
.mailmap hotfixes for 5.18-rc7 2022-05-13 10:22:37 -07:00
COPYING COPYING: state that all contributions really are covered by this file 2020-02-10 13:32:20 -08:00
CREDITS MAINTAINERS: replace a Microchip AT91 maintainer 2022-02-09 11:30:01 +01:00
Kbuild kbuild: rename hostprogs-y/always to hostprogs/always-y 2020-02-04 01:53:07 +09:00
Kconfig kbuild: ensure full rebuild when the compiler is updated 2020-05-12 13:28:33 +09:00
MAINTAINERS Merge branch 'arm/fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc 2022-05-18 14:07:43 -10:00
Makefile Linux 5.18.1 2022-05-30 09:24:09 +02:00
README Drop all 00-INDEX files from Documentation/ 2018-09-09 15:08:58 -06:00

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.