Linux kernel source tree
Go to file
Martin Liu cea23cb745 ANDROID: GKI: dma-buf: use spinlock to protect set/get name operation
We introduced setname ioctl in commit bb2bb90304 ("dma-buf:
add DMA_BUF_SET_NAME ioctls") that provides userpsace
to attach a free-form name for tracking and counting shared
buffers. However the d_dname callback could be called in atomic
context. This call path comes from selinux that verifies all
inherited open files from exec call. To verify all inherited
open files, kernel would iterate all fds which need to hold
spin_lock to get denty name by calling d_dname operation.
In dma-buf d_dname callback, we use mutex lock to prevent the
race from setname causing this issue.

This commit adds a spinlock to protect set/get name operation
to fix this issue.

[  165.617090] Call trace:
[  165.620504]  ___might_sleep+0x114/0x118
[  165.625344]  __might_sleep+0x50/0x84
[  165.629928]  __mutex_lock_common+0x5c/0x10b0
[  165.635215]  mutex_lock_nested+0x40/0x50
[  165.640157]  dmabuffs_dname+0x48/0xdc
[  165.644821]  d_path+0x78/0x1e4
[  165.648870]  audit_log_d_path+0x68/0x134
[  165.653807]  common_lsm_audit+0x33c/0x6f4
[  165.658832]  slow_avc_audit+0xb4/0xf0
[  165.663503]  avc_has_perm+0xdc/0x1a4
[  165.668081]  file_has_perm+0x70/0x154
[  165.672750]  match_file+0x54/0x6c
[  165.677064]  iterate_fd+0x74/0xac
[  165.681369]  selinux_bprm_committing_creds+0xfc/0x210
[  165.687459]  security_bprm_committing_creds+0x2c/0x40
[  165.693546]  install_exec_creds+0x1c/0x68
[  165.698569]  load_elf_binary+0x3a0/0x13c8
[  165.703590]  search_binary_handler+0xb8/0x1e4
[  165.708964]  __do_execve_file+0x6e4/0x9c8
[  165.713984]  __arm64_sys_execve+0x44/0x54
[  165.719008]  el0_svc_common+0xa8/0x168
[  165.723765]  el0_svc_handler+0x78/0x94
[  165.728522]  el0_svc+0x8/0xc

Signed-off-by: Martin Liu <liumartin@google.com>

[surenb: cherry-picked and backported from:
https://lkml.org/lkml/2020/1/14/799

Conflicts:
        drivers/dma-buf/dma-buf.c

1. Resolved diffs between 4.19 and upstream by replacing dma_resv_lock
with dmabuf->lock
]

Bug: 150611569
Test: build
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ia0b20a40d491eb41b8844d05dc86dfd6039de07f
2020-03-16 18:12:28 +00:00
arch ANDROID: GKI: arm64: mm: Support setting removed_dma_ops in arch_setup_dma_ops 2020-03-16 18:10:51 +00:00
block ANDROID: block: Prevent crypto fallback for wrapped keys 2020-02-27 17:09:12 +00:00
certs export.h: remove VMLINUX_SYMBOL() and VMLINUX_SYMBOL_STR() 2018-08-22 23:21:44 +09:00
crypto UPSTREAM: crypto: skcipher - Introduce crypto_sync_skcipher 2020-03-12 10:46:18 -07:00
Documentation UPSTREAM: mm: Avoid creating virtual address aliases in brk()/mmap()/mremap() 2020-03-13 18:25:36 +00:00
drivers ANDROID: GKI: dma-buf: use spinlock to protect set/get name operation 2020-03-16 18:12:28 +00:00
firmware Fix built-in early-load Intel microcode alignment 2020-01-23 08:21:29 +01:00
fs UPSTREAM: fscrypt: don't evict dirty inodes after removing key 2020-03-11 14:05:28 -07:00
include ANDROID: GKI: dma-buf: use spinlock to protect set/get name operation 2020-03-16 18:12:28 +00:00
init ANDROID: GKI: enable PM_GENERIC_DOMAINS by default 2020-03-09 11:32:05 -07:00
ipc This is the 4.19.107 stable release 2020-03-03 07:33:01 +01:00
kernel ANDROID: GKI: drivers: Add dma removed ops 2020-03-16 18:10:36 +00:00
lib FROMLIST: lib: test_stackinit.c: XFAIL switch variable init tests 2020-03-05 17:59:19 +00:00
LICENSES LICENSES: Remove CC-BY-SA-4.0 license text 2018-10-18 11:28:50 +02:00
mm UPSTREAM: mm: Avoid creating virtual address aliases in brk()/mmap()/mremap() 2020-03-13 18:25:36 +00:00
net ANDROID: GKI: cfg80211: Add AP stopped interface 2020-03-12 10:46:18 -07:00
samples FROMGIT: samples/hw_breakpoint: drop use of kallsyms_lookup_name() 2020-03-12 11:18:49 +00:00
scripts ANDROID: kbuild: align UNUSED_KSYMS_WHITELIST with upstream 2020-03-10 13:08:52 +00:00
security This is the 4.19.106 stable release 2020-02-24 09:13:25 +01:00
sound This is the 4.19.109 stable release 2020-03-11 17:10:39 +01:00
tools This is the 4.19.109 stable release 2020-03-11 17:10:39 +01:00
usr kbuild: clean compressed initramfs image 2019-10-07 18:57:16 +02:00
virt KVM: Check for a bad hva before dropping into the ghc slow path 2020-03-05 16:42:21 +01:00
.clang-format clang-format: Set IndentWrappedFunctionNames false 2018-08-01 18:38:51 +02:00
.cocciconfig
.get_maintainer.ignore
.gitattributes .gitattributes: set git diff driver for C source code files 2016-10-07 18:46:30 -07:00
.gitignore Kbuild updates for v4.17 (2nd) 2018-04-15 17:21:30 -07:00
.mailmap libnvdimm-for-4.19_misc 2018-08-25 18:13:10 -07:00
abi_gki_aarch64_cuttlefish_whitelist ANDROID: ABI/Whitelist: update for Cuttlefish 2020-02-12 11:11:16 +00:00
abi_gki_aarch64_qcom_whitelist ANDROID: Update ABI whitelist for qcom SoCs 2020-03-06 14:50:51 -08:00
abi_gki_aarch64_whitelist ANDROID: abi_gki_aarch64_whitelist: add module_layout and task_struct 2020-03-05 09:07:15 +00:00
abi_gki_aarch64.xml ANDROID: GKI: update abi due to CONFIG_JUMP_LABEL being enabled 2020-03-16 15:55:55 +01:00
build.config.aarch64 ANDROID: refactor build.config files to remove duplication 2019-10-22 18:27:12 -07:00
build.config.allmodconfig ANDROID: Don't base allmodconfig on gki_defconfig 2019-12-05 12:48:26 +00:00
build.config.allmodconfig.aarch64 ANDROID: Add allmodconfig build.configs for x86_64 and aarch64 2019-11-12 20:55:23 +00:00
build.config.allmodconfig.arm ANDROID: Add build.config files for ARM 32-bit 2020-03-16 17:43:55 +00:00
build.config.allmodconfig.x86_64 ANDROID: Add allmodconfig build.configs for x86_64 and aarch64 2019-11-12 20:55:23 +00:00
build.config.arm ANDROID: Add build.config files for ARM 32-bit 2020-03-16 17:43:55 +00:00
build.config.common ANDROID: clang: update to 10.0.4 2020-02-19 19:33:36 +00:00
build.config.cuttlefish.aarch64 ANDROID: cf build: Use merge_configs 2020-02-18 21:19:23 +00:00
build.config.cuttlefish.x86_64 ANDROID: cf build: Use merge_configs 2020-02-18 21:19:23 +00:00
build.config.gki ANDROID: gki: Removed cf modules from gki_defconfig 2020-01-31 16:23:38 -08:00
build.config.gki-debug.aarch64 ANDROID: Add build.config.gki-debug.aarch64 2020-03-16 14:29:13 +00:00
build.config.gki-debug.x86_64 ANDROID: Add build.config.gki-debug.x86_64 2020-03-16 14:29:13 +00:00
build.config.gki.aarch64 ANDROID: Add ABI Whitelist for qcom 2020-02-28 23:45:43 +00:00
build.config.gki.x86_64 ANDROID: refactor build.config files to remove duplication 2019-10-22 18:27:12 -07:00
build.config.x86_64 ANDROID: refactor build.config files to remove duplication 2019-10-22 18:27:12 -07:00
COPYING COPYING: use the new text with points to the license files 2018-03-23 12:41:45 -06:00
CREDITS 9p: remove Ron Minnich from MAINTAINERS 2018-08-17 16:20:26 -07:00
cuttlefish.fragment ANDROID: Add TPM support and the vTPM proxy to Cuttlefish. 2020-03-13 17:19:53 +00:00
Kbuild Kbuild updates for v4.15 2017-11-17 17:45:29 -08:00
Kconfig kconfig: move the "Executable file formats" menu to fs/Kconfig.binfmt 2018-08-02 08:06:55 +09:00
MAINTAINERS This is the 4.19.107 stable release 2020-03-03 07:33:01 +01:00
Makefile This is the 4.19.110 stable release 2020-03-16 11:07:08 +01:00
README Docs: Added a pointer to the formatted docs to README 2018-03-21 09:02:53 -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.
See Documentation/00-INDEX for a list of what is contained in each file.

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.