No description
  • C 98.2%
  • Assembly 1%
  • Makefile 0.3%
  • Shell 0.2%
  • Python 0.1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Ryusuke Konishi 9b162e8104 nilfs2: fix use-after-free bug of ns_writer on remount
commit 8cccf05fe857a18ee26e20d11a8455a73ffd4efd upstream.

If a nilfs2 filesystem is downgraded to read-only due to metadata
corruption on disk and is remounted read/write, or if emergency read-only
remount is performed, detaching a log writer and synchronizing the
filesystem can be done at the same time.

In these cases, use-after-free of the log writer (hereinafter
nilfs->ns_writer) can happen as shown in the scenario below:

 Task1                               Task2
 --------------------------------    ------------------------------
 nilfs_construct_segment
   nilfs_segctor_sync
     init_wait
     init_waitqueue_entry
     add_wait_queue
     schedule
                                     nilfs_remount (R/W remount case)
				       nilfs_attach_log_writer
                                         nilfs_detach_log_writer
                                           nilfs_segctor_destroy
                                             kfree
     finish_wait
       _raw_spin_lock_irqsave
         __raw_spin_lock_irqsave
           do_raw_spin_lock
             debug_spin_lock_before  <-- use-after-free

While Task1 is sleeping, nilfs->ns_writer is freed by Task2.  After Task1
waked up, Task1 accesses nilfs->ns_writer which is already freed.  This
scenario diagram is based on the Shigeru Yoshida's post [1].

This patch fixes the issue by not detaching nilfs->ns_writer on remount so
that this UAF race doesn't happen.  Along with this change, this patch
also inserts a few necessary read-only checks with superblock instance
where only the ns_writer pointer was used to check if the filesystem is
read-only.

Link: https://syzkaller.appspot.com/bug?id=79a4c002e960419ca173d55e863bd09e8112df8b
Link: https://lkml.kernel.org/r/20221103141759.1836312-1-syoshida@redhat.com [1]
Link: https://lkml.kernel.org/r/20221104142959.28296-1-konishi.ryusuke@gmail.com
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Reported-by: syzbot+f816fa82f8783f7a02bb@syzkaller.appspotmail.com
Reported-by: Shigeru Yoshida <syoshida@redhat.com>
Tested-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-11-25 17:42:09 +01:00
arch MIPS: jump_label: Fix compat branch range check 2022-11-25 17:42:08 +01:00
block block, bfq: protect 'bfqd->queued' by 'bfqd->lock' 2022-11-10 17:57:54 +01:00
certs certs/blacklist_hashes.c: fix const confusion in certs blacklist 2022-06-22 14:11:22 +02:00
crypto crypto: akcipher - default implementation for setting a private key 2022-10-26 13:22:45 +02:00
Documentation tracing/histogram: Update document for KEYS_MAX size 2022-11-10 17:57:55 +01:00
drivers mmc: sdhci-tegra: Fix SDHCI_RESET_ALL for CQHCI 2022-11-25 17:42:08 +01:00
fs nilfs2: fix use-after-free bug of ns_writer on remount 2022-11-25 17:42:09 +01:00
include vmlinux.lds.h: Fix placement of '.data..decrypted' section 2022-11-25 17:42:09 +01:00
init
ipc ipc: remove memcg accounting for sops objects in do_semtimedop() 2022-11-10 17:57:58 +01:00
kernel kprobe: reverse kp->flags when arm_kprobe failed 2022-11-10 17:57:55 +01:00
lib dyndbg: let query-modname override actual module name 2022-10-26 13:22:37 +02:00
LICENSES
mm mm,hugetlb: take hugetlb_lock before decrementing h->resv_huge_pages 2022-11-03 23:56:54 +09:00
net tipc: fix the msg->req tlv len check in tipc_nl_compat_name_table_dump_header 2022-11-25 17:42:05 +01:00
samples
scripts kbuild: remove the target in signal traps when interrupted 2022-10-26 13:22:46 +02:00
security capabilities: fix potential memleak on error path from vfs_getxattr_alloc() 2022-11-10 17:57:55 +01:00
sound ALSA: usb-audio: Add DSD support for Accuphase DAC-60 2022-11-25 17:42:08 +01:00
tools perf stat: Fix printing os->prefix in CSV metrics output 2022-11-25 17:42:06 +01:00
usr
virt KVM: arm64: vgic: Fix exit condition in scan_its_table() 2022-10-29 10:20:35 +02:00
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS MAINTAINERS: add Chandan as xfs maintainer for 5.4.y 2022-09-28 11:03:58 +02:00
Makefile Linux 5.4.224 2022-11-10 17:57:58 +01: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.