Linux kernel source tree
Go to file
Will Deacon 4c2eddf774 FROMGIT: pinctrl: devicetree: Avoid taking direct reference to device name string
When populating the pinctrl mapping table entries for a device, the
'dev_name' field for each entry is initialised to point directly at the
string returned by 'dev_name()' for the device and subsequently used by
'create_pinctrl()' when looking up the mappings for the device being
probed.

This is unreliable in the presence of calls to 'dev_set_name()', which may
reallocate the device name string leaving the pinctrl mappings with a
dangling reference. This then leads to a use-after-free every time the
name is dereferenced by a device probe:

  | BUG: KASAN: invalid-access in strcmp+0x20/0x64
  | Read of size 1 at addr 13ffffc153494b00 by task modprobe/590
  | Pointer tag: [13], memory tag: [fe]
  |
  | Call trace:
  |  __kasan_report+0x16c/0x1dc
  |  kasan_report+0x10/0x18
  |  check_memory_region
  |  __hwasan_load1_noabort+0x4c/0x54
  |  strcmp+0x20/0x64
  |  create_pinctrl+0x18c/0x7f4
  |  pinctrl_get+0x90/0x114
  |  devm_pinctrl_get+0x44/0x98
  |  pinctrl_bind_pins+0x5c/0x450
  |  really_probe+0x1c8/0x9a4
  |  driver_probe_device+0x120/0x1d8

Follow the example of sysfs, and duplicate the device name string before
stashing it away in the pinctrl mapping entries.

Cc: Linus Walleij <linus.walleij@linaro.org>
Reported-by: Elena Petrova <lenaptr@google.com>
Tested-by: Elena Petrova <lenaptr@google.com>
Signed-off-by: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20191002124206.22928-1-will@kernel.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

(cherry picked from commit be4c60b563
https: //git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git
devel)
Bug: 140550171
Signed-off-by: Elena Petrova <lenaptr@google.com>
Change-Id: Ia54c7088590ab0f9adc7753c191bba85c06dfdc1
2019-11-25 17:19:04 +00:00
arch This is the 4.19.86 stable release 2019-11-25 10:00:06 +01:00
block This is the 4.19.85 stable release 2019-11-20 20:43:17 +01:00
certs export.h: remove VMLINUX_SYMBOL() and VMLINUX_SYMBOL_STR() 2018-08-22 23:21:44 +09:00
crypto This is the 4.19.85 stable release 2019-11-20 20:43:17 +01:00
Documentation This is the 4.19.85 stable release 2019-11-20 20:43:17 +01:00
drivers FROMGIT: pinctrl: devicetree: Avoid taking direct reference to device name string 2019-11-25 17:19:04 +00:00
firmware kbuild: remove all dummy assignments to obj- 2017-11-18 11:46:06 +09:00
fs This is the 4.19.86 stable release 2019-11-25 10:00:06 +01:00
include This is the 4.19.86 stable release 2019-11-25 10:00:06 +01:00
init This is the 4.19.76 stable release 2019-10-01 08:51:37 +02:00
ipc This is the 4.19.65 stable release 2019-08-06 20:08:18 +02:00
kernel This is the 4.19.86 stable release 2019-11-25 10:00:06 +01:00
lib This is the 4.19.86 stable release 2019-11-25 10:00:06 +01:00
LICENSES LICENSES: Remove CC-BY-SA-4.0 license text 2018-10-18 11:28:50 +02:00
mm This is the 4.19.86 stable release 2019-11-25 10:00:06 +01:00
net This is the 4.19.86 stable release 2019-11-25 10:00:06 +01:00
samples mei: samples: fix a signedness bug in amt_host_if_call() 2019-11-24 08:19:50 +01:00
scripts This is the 4.19.82 stable release 2019-11-06 13:21:58 +01:00
security ANDROID: Fix allmodconfig build with CC=clang 2019-11-14 10:56:08 -08:00
sound This is the 4.19.86 stable release 2019-11-25 10:00:06 +01:00
tools This is the 4.19.86 stable release 2019-11-25 10:00:06 +01:00
usr kbuild: clean compressed initramfs image 2019-10-07 18:57:16 +02:00
virt kvm: arm/arm64: Fix stage2_flush_memslot for 4 level page table 2019-11-24 08:19:31 +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.xml ANDROID: update abi_gki_aarch64.xml for 4.19.86 update 2019-11-25 10:44:11 +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: Add allmodconfig build.configs for x86_64 and aarch64 2019-11-12 20:55:23 +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.x86_64 ANDROID: Add allmodconfig build.configs for x86_64 and aarch64 2019-11-12 20:55:23 +00:00
build.config.common ANDROID: add unstripped modules to the distribution 2019-11-20 23:43:35 +00:00
build.config.gki ANDROID: refactor build.config files to remove duplication 2019-10-22 18:27:12 -07:00
build.config.gki.aarch64 ANDROID: refactor build.config files to remove duplication 2019-10-22 18:27:12 -07: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
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.80 stable release 2019-10-17 15:33:07 -07:00
Makefile This is the 4.19.86 stable release 2019-11-25 10:00:06 +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.