summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWill Deacon <will@kernel.org>2019-10-02 13:42:06 +0100
committerElena Petrova <lenaptr@google.com>2019-11-22 18:41:26 +0000
commit437a2a739c5f6f637ac29c0c613d2fbc791597c4 (patch)
treebfba48b575a845dc64492c29955d9da97d739386 /lib
parent7bc77fd33905a3c760a4d06064db4b5a818560d6 (diff)
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 be4c60b563edee3712d392aaeb0943a768df7023 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: I90e9f4f64c694a195b0963b88bb32bd8cee42aa5
Diffstat (limited to 'lib')
0 files changed, 0 insertions, 0 deletions