All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Taehee Yoo <ap420073@gmail.com>,
	syzbot+9328206518f08318a5fd@syzkaller.appspotmail.com,
	"David S . Miller" <davem@davemloft.net>,
	Sasha Levin <sashal@kernel.org>,
	netdev@vger.kernel.org, bpf@vger.kernel.org
Subject: [PATCH AUTOSEL 5.4 21/26] hsr: fix slab-out-of-bounds Read in hsr_debugfs_rename()
Date: Fri, 10 Jan 2020 17:05:14 -0500	[thread overview]
Message-ID: <20200110220519.28250-16-sashal@kernel.org> (raw)
In-Reply-To: <20200110220519.28250-1-sashal@kernel.org>

From: Taehee Yoo <ap420073@gmail.com>

[ Upstream commit 04b69426d846cd04ca9acefff1ea39e1c64d2714 ]

hsr slave interfaces don't have debugfs directory.
So, hsr_debugfs_rename() shouldn't be called when hsr slave interface name
is changed.

Test commands:
    ip link add dummy0 type dummy
    ip link add dummy1 type dummy
    ip link add hsr0 type hsr slave1 dummy0 slave2 dummy1
    ip link set dummy0 name ap

Splat looks like:
[21071.899367][T22666] ap: renamed from dummy0
[21071.914005][T22666] ==================================================================
[21071.919008][T22666] BUG: KASAN: slab-out-of-bounds in hsr_debugfs_rename+0xaa/0xb0 [hsr]
[21071.923640][T22666] Read of size 8 at addr ffff88805febcd98 by task ip/22666
[21071.926941][T22666]
[21071.927750][T22666] CPU: 0 PID: 22666 Comm: ip Not tainted 5.5.0-rc2+ #240
[21071.929919][T22666] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
[21071.935094][T22666] Call Trace:
[21071.935867][T22666]  dump_stack+0x96/0xdb
[21071.936687][T22666]  ? hsr_debugfs_rename+0xaa/0xb0 [hsr]
[21071.937774][T22666]  print_address_description.constprop.5+0x1be/0x360
[21071.939019][T22666]  ? hsr_debugfs_rename+0xaa/0xb0 [hsr]
[21071.940081][T22666]  ? hsr_debugfs_rename+0xaa/0xb0 [hsr]
[21071.940949][T22666]  __kasan_report+0x12a/0x16f
[21071.941758][T22666]  ? hsr_debugfs_rename+0xaa/0xb0 [hsr]
[21071.942674][T22666]  kasan_report+0xe/0x20
[21071.943325][T22666]  hsr_debugfs_rename+0xaa/0xb0 [hsr]
[21071.944187][T22666]  hsr_netdev_notify+0x1fe/0x9b0 [hsr]
[21071.945052][T22666]  ? __module_text_address+0x13/0x140
[21071.945897][T22666]  notifier_call_chain+0x90/0x160
[21071.946743][T22666]  dev_change_name+0x419/0x840
[21071.947496][T22666]  ? __read_once_size_nocheck.constprop.6+0x10/0x10
[21071.948600][T22666]  ? netdev_adjacent_rename_links+0x280/0x280
[21071.949577][T22666]  ? __read_once_size_nocheck.constprop.6+0x10/0x10
[21071.950672][T22666]  ? lock_downgrade+0x6e0/0x6e0
[21071.951345][T22666]  ? do_setlink+0x811/0x2ef0
[21071.951991][T22666]  do_setlink+0x811/0x2ef0
[21071.952613][T22666]  ? is_bpf_text_address+0x81/0xe0
[ ... ]

Reported-by: syzbot+9328206518f08318a5fd@syzkaller.appspotmail.com
Fixes: 4c2d5e33dcd3 ("hsr: rename debugfs file when interface name is changed")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/hsr/hsr_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/hsr/hsr_main.c b/net/hsr/hsr_main.c
index d2ee7125a7f1..9e389accbfc7 100644
--- a/net/hsr/hsr_main.c
+++ b/net/hsr/hsr_main.c
@@ -46,7 +46,8 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event,
 		hsr_check_carrier_and_operstate(hsr);
 		break;
 	case NETDEV_CHANGENAME:
-		hsr_debugfs_rename(dev);
+		if (is_hsr_master(dev))
+			hsr_debugfs_rename(dev);
 		break;
 	case NETDEV_CHANGEADDR:
 		if (port->type == HSR_PT_MASTER) {
-- 
2.20.1


  parent reply	other threads:[~2020-01-10 22:08 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-10 22:04 [PATCH AUTOSEL 5.4 06/26] rxrpc: Unlock new call in rxrpc_new_incoming_call() rather than the caller Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 07/26] rxrpc: Don't take call->user_mutex in rxrpc_new_incoming_call() Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 08/26] rxrpc: Fix missing security check on incoming calls Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 09/26] dmaengine: k3dma: Avoid null pointer traversal Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 10/26] s390/qeth: fix qdio teardown after early init error Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 11/26] s390/qeth: lock the card while changing its hsuid Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 12/26] s390/qeth: fix false reporting of VNIC CHAR config failure Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 13/26] s390/qeth: Fix vnicc_is_in_use if rx_bcast not set Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 14/26] s390/qeth: vnicc Fix init to default Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 15/26] s390/qeth: fix initialization on old HW Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 16/26] hsr: add hsr root debugfs directory Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 17/26] hsr: rename debugfs file when interface name is changed Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 18/26] hsr: reset network header when supervision frame is created Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 19/26] ioat: ioat_alloc_ring() failure handling Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 20/26] drm/amdgpu: enable gfxoff for raven1 refresh Sasha Levin
2020-01-10 22:05   ` Sasha Levin
2020-01-10 22:05   ` Sasha Levin
2020-01-10 22:05 ` Sasha Levin [this message]
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 22/26] media: intel-ipu3: Align struct ipu3_uapi_awb_fr_config_s to 32 bytes Sasha Levin
2020-01-10 22:05   ` Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 23/26] kbuild/deb-pkg: annotate libelf-dev dependency as :native Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 24/26] hexagon: parenthesize registers in asm predicates Sasha Levin
2020-01-10 22:05   ` Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 25/26] hexagon: work around compiler crash Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 26/26] ocfs2: call journal flush to mark journal as empty after journal recovery when mount 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=20200110220519.28250-16-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=ap420073@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+9328206518f08318a5fd@syzkaller.appspotmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.