linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Venkata Narendra Kumar Gutta <vnkgutta@codeaurora.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 4.14 036/167] driver core: platform: Fix the usage of platform device name(pdev->name)
Date: Wed, 22 May 2019 15:26:31 -0400	[thread overview]
Message-ID: <20190522192842.25858-36-sashal@kernel.org> (raw)
In-Reply-To: <20190522192842.25858-1-sashal@kernel.org>

From: Venkata Narendra Kumar Gutta <vnkgutta@codeaurora.org>

[ Upstream commit edb16da34b084c66763f29bee42b4e6bb33c3d66 ]

Platform core is using pdev->name as the platform device name to do
the binding of the devices with the drivers. But, when the platform
driver overrides the platform device name with dev_set_name(),
the pdev->name is pointing to a location which is freed and becomes
an invalid parameter to do the binding match.

use-after-free instance:

[   33.325013] BUG: KASAN: use-after-free in strcmp+0x8c/0xb0
[   33.330646] Read of size 1 at addr ffffffc10beae600 by task modprobe
[   33.339068] CPU: 5 PID: 518 Comm: modprobe Tainted:
			G S      W  O      4.19.30+ #3
[   33.346835] Hardware name: MTP (DT)
[   33.350419] Call trace:
[   33.352941]  dump_backtrace+0x0/0x3b8
[   33.356713]  show_stack+0x24/0x30
[   33.360119]  dump_stack+0x160/0x1d8
[   33.363709]  print_address_description+0x84/0x2e0
[   33.368549]  kasan_report+0x26c/0x2d0
[   33.372322]  __asan_report_load1_noabort+0x2c/0x38
[   33.377248]  strcmp+0x8c/0xb0
[   33.380306]  platform_match+0x70/0x1f8
[   33.384168]  __driver_attach+0x78/0x3a0
[   33.388111]  bus_for_each_dev+0x13c/0x1b8
[   33.392237]  driver_attach+0x4c/0x58
[   33.395910]  bus_add_driver+0x350/0x560
[   33.399854]  driver_register+0x23c/0x328
[   33.403886]  __platform_driver_register+0xd0/0xe0

So, use dev_name(&pdev->dev), which fetches the platform device name from
the kobject(dev->kobj->name) of the device instead of the pdev->name.

Signed-off-by: Venkata Narendra Kumar Gutta <vnkgutta@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/base/platform.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 9045c5f3734e8..080038bbed39b 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -855,7 +855,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *a,
 	if (len != -ENODEV)
 		return len;
 
-	len = snprintf(buf, PAGE_SIZE, "platform:%s\n", pdev->name);
+	len = snprintf(buf, PAGE_SIZE, "platform:%s\n", dev_name(&pdev->dev));
 
 	return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
 }
@@ -931,7 +931,7 @@ static int platform_uevent(struct device *dev, struct kobj_uevent_env *env)
 		return rc;
 
 	add_uevent_var(env, "MODALIAS=%s%s", PLATFORM_MODULE_PREFIX,
-			pdev->name);
+			dev_name(&pdev->dev));
 	return 0;
 }
 
@@ -940,7 +940,7 @@ static const struct platform_device_id *platform_match_id(
 			struct platform_device *pdev)
 {
 	while (id->name[0]) {
-		if (strcmp(pdev->name, id->name) == 0) {
+		if (strcmp(dev_name(&pdev->dev), id->name) == 0) {
 			pdev->id_entry = id;
 			return id;
 		}
@@ -984,7 +984,7 @@ static int platform_match(struct device *dev, struct device_driver *drv)
 		return platform_match_id(pdrv->id_table, pdev) != NULL;
 
 	/* fall-back to driver name match */
-	return (strcmp(pdev->name, drv->name) == 0);
+	return (strcmp(dev_name(&pdev->dev), drv->name) == 0);
 }
 
 #ifdef CONFIG_PM_SLEEP
-- 
2.20.1


  parent reply	other threads:[~2019-05-22 19:39 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22 19:25 [PATCH AUTOSEL 4.14 001/167] gfs2: Fix lru_count going negative Sasha Levin
2019-05-22 19:25 ` [PATCH AUTOSEL 4.14 002/167] cxgb4: Fix error path in cxgb4_init_module Sasha Levin
2019-05-22 19:25 ` [PATCH AUTOSEL 4.14 003/167] NFS: make nfs_match_client killable Sasha Levin
2019-05-22 19:25 ` [PATCH AUTOSEL 4.14 004/167] IB/hfi1: Fix WQ_MEM_RECLAIM warning Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 005/167] gfs2: Fix occasional glock use-after-free Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 006/167] mmc: core: Verify SD bus width Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 007/167] tools/bpf: fix perf build error with uClibc (seen on ARC) Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 008/167] dmaengine: tegra210-dma: free dma controller in remove() Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 009/167] net: ena: gcc 8: fix compilation warning Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 010/167] orangefs: truncate before updating size Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 011/167] pinctrl: zte: fix leaked of_node references Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 012/167] ASoC: hdmi-codec: unlock the device on startup errors Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 013/167] leds: avoid races with workqueue Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 014/167] powerpc/perf: Return accordingly on invalid chip-id in Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 015/167] powerpc/boot: Fix missing check of lseek() return value Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 016/167] ASoC: imx: fix fiq dependencies Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 017/167] spi: pxa2xx: fix SCR (divisor) calculation Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 018/167] brcm80211: potential NULL dereference in brcmf_cfg80211_vndr_cmds_dcmd_handler() Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 019/167] ACPI / property: fix handling of data_nodes in acpi_get_next_subnode() Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 020/167] ARM: vdso: Remove dependency with the arch_timer driver internals Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 021/167] arm64: Fix compiler warning from pte_unmap() with -Wunused-but-set-variable Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 022/167] sched/cpufreq: Fix kobject memleak Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 023/167] scsi: qla2xxx: Fix a qla24xx_enable_msix() error path Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 024/167] scsi: qla2xxx: Fix abort handling in tcm_qla2xxx_write_pending() Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 025/167] scsi: qla2xxx: Avoid that lockdep complains about unsafe locking in tcm_qla2xxx_close_session() Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 026/167] Btrfs: fix data bytes_may_use underflow with fallocate due to failed quota reserve Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 027/167] btrfs: fix panic during relocation after ENOSPC before writeback happens Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 028/167] btrfs: Don't panic when we can't find a root key Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 029/167] iwlwifi: pcie: don't crash on invalid RX interrupt Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 030/167] rtc: 88pm860x: prevent use-after-free on device remove Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 031/167] scsi: qedi: Abort ep termination if offload not scheduled Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 032/167] w1: fix the resume command API Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 033/167] dmaengine: pl330: _stop: clear interrupt status Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 034/167] mac80211/cfg80211: update bss channel on channel switch Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 035/167] libbpf: fix samples/bpf build failure due to undefined UINT32_MAX Sasha Levin
2019-05-22 19:26 ` Sasha Levin [this message]
2019-05-22 20:05   ` [PATCH AUTOSEL 4.14 036/167] driver core: platform: Fix the usage of platform device name(pdev->name) Greg Kroah-Hartman
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 037/167] ASoC: fsl_sai: Update is_slave_mode with correct value Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 038/167] mwifiex: prevent an array overflow Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 039/167] net: cw1200: fix a NULL pointer dereference Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 040/167] at76c50x-usb: Don't register led_trigger if usb_register_driver failed Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 041/167] ssb: Fix possible NULL pointer dereference in ssb_host_pcmcia_exit Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 042/167] crypto: sun4i-ss - Fix invalid calculation of hash end Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 043/167] bcache: return error immediately in bch_journal_replay() Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 044/167] bcache: fix failure in journal relplay Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 045/167] bcache: add failure check to run_cache_set() for journal replay Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 046/167] bcache: avoid clang -Wunintialized warning Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 047/167] RDMA/cma: Consider scope_id while binding to ipv6 ll address Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 048/167] vfio-ccw: Do not call flush_workqueue while holding the spinlock Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 049/167] vfio-ccw: Release any channel program when releasing/removing vfio-ccw mdev Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 050/167] x86/build: Move _etext to actual end of .text Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 051/167] smpboot: Place the __percpu annotation correctly Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 052/167] x86/mm: Remove in_nmi() warning from 64-bit implementation of vmalloc_fault() Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 053/167] mm/uaccess: Use 'unsigned long' to placate UBSAN warnings on older GCC versions Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 054/167] HID: logitech-hidpp: use RAP instead of FAP to get the protocol version Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 055/167] pinctrl: pistachio: fix leaked of_node references Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 056/167] pinctrl: samsung: " Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 057/167] clk: rockchip: undo several noc and special clocks as critical on rk3288 Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 058/167] dmaengine: at_xdmac: remove BUG_ON macro in tasklet Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 059/167] media: coda: clear error return value before picture run Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 060/167] media: ov6650: Move v4l2_clk_get() to ov6650_video_probe() helper Sasha Levin
2019-05-22 19:26 ` [PATCH AUTOSEL 4.14 061/167] media: au0828: stop video streaming only when last user stops Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190522192842.25858-36-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=vnkgutta@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).