All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: syzbot <syzbot+5fe14f2ff4ccbace9a26@syzkaller.appspotmail.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [syzbot] [net?] KASAN: slab-use-after-free Read in __ethtool_get_link_ksettings
Date: Tue, 8 Oct 2024 14:44:06 +0300	[thread overview]
Message-ID: <20241008114406.GD25819@unreal> (raw)
In-Reply-To: <67048e62.050a0220.49194.051e.GAE@google.com>

On Mon, Oct 07, 2024 at 06:44:02PM -0700, syzbot wrote:
> syzbot has bisected this issue to:
> 
> commit 5f8ca04fdd3c66a322ea318b5f1cb684dd56e5b2
> Author: Chiara Meiohas <cmeiohas@nvidia.com>
> Date:   Mon Sep 9 17:30:22 2024 +0000
> 
>     RDMA/device: Remove optimization in ib_device_get_netdev()
> 
> bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=16db2327980000
> start commit:   c4a14f6d9d17 ipv4: ip_gre: Fix drops of small packets in i..
> git tree:       net
> final oops:     https://syzkaller.appspot.com/x/report.txt?x=15db2327980000
> console output: https://syzkaller.appspot.com/x/log.txt?x=11db2327980000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=b2d4fdf18a83ec0b
> dashboard link: https://syzkaller.appspot.com/bug?extid=5fe14f2ff4ccbace9a26
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=11eca3d0580000
> 
> Reported-by: syzbot+5fe14f2ff4ccbace9a26@syzkaller.appspotmail.com
> Fixes: 5f8ca04fdd3c ("RDMA/device: Remove optimization in ib_device_get_netdev()")
> 
> For information about bisection process see: https://goo.gl/tpsmEJ#bisection

#syz test: https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next

diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index e029401b5680..f56085b928a4 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -2070,10 +2070,6 @@ static int iw_query_port(struct ib_device *device,
 
 	memset(port_attr, 0, sizeof(*port_attr));
 
-	netdev = ib_device_get_netdev(device, port_num);
-	if (!netdev)
-		return -ENODEV;
-
 	port_attr->max_mtu = IB_MTU_4096;
 	port_attr->active_mtu = ib_mtu_int_to_enum(netdev->mtu);
 
@@ -2096,7 +2092,6 @@ static int iw_query_port(struct ib_device *device,
 		rcu_read_unlock();
 	}
 
-	dev_put(netdev);
 	return device->ops.query_port(device, port_num, port_attr);
 }
 
@@ -2134,13 +2129,27 @@ int ib_query_port(struct ib_device *device,
 		  u32 port_num,
 		  struct ib_port_attr *port_attr)
 {
+	struct net_device *netdev = NULL;
+	int ret;
+
 	if (!rdma_is_port_valid(device, port_num))
 		return -EINVAL;
 
+	if (rdma_protocol_iwarp(device, port_num) ||
+	    rdma_protocol_roce(device, port_num)) {
+		netdev = ib_device_get_netdev(device, port_num);
+		if (!netdev)
+			return -ENODEV;
+	}
+
 	if (rdma_protocol_iwarp(device, port_num))
-		return iw_query_port(device, port_num, port_attr);
+		ret = iw_query_port(device, port_num, port_attr);
 	else
-		return __ib_query_port(device, port_num, port_attr);
+		ret = __ib_query_port(device, port_num, port_attr);
+	if (netdev)
+		dev_put(netdev);
+	return ret;
+
 }
 EXPORT_SYMBOL(ib_query_port);
 

  reply	other threads:[~2024-10-08 11:44 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-22 20:10 [syzbot] [net?] KASAN: slab-use-after-free Read in __ethtool_get_link_ksettings syzbot
2024-03-25 12:09 ` Denis Kirjanov
2024-03-25 13:08   ` Eric Dumazet
2024-09-28 12:21     ` Hillf Danton
2024-09-29 11:46       ` Hillf Danton
2024-09-30  8:32         ` Eric Dumazet
2024-09-30 12:27           ` Hillf Danton
2024-09-27 18:26 ` syzbot
2024-09-28  8:22 ` Hillf Danton
2024-09-28  9:08   ` syzbot
2024-09-29 10:38 ` Hillf Danton
2024-09-29 11:17   ` syzbot
2024-10-08  1:44 ` syzbot
2024-10-08 11:44   ` Leon Romanovsky [this message]
2024-10-08 12:02     ` syzbot
2024-10-08 11:51   ` Leon Romanovsky
2024-10-08 12:24     ` syzbot
2024-10-08 11:44 ` [syzbot] " syzbot
2024-10-08 11:51 ` syzbot
2024-10-10  8:25 ` syzbot
2024-10-10  9:12 ` syzbot
2024-10-10 13:27 ` syzbot
2024-10-10 13:46 ` syzbot
2024-10-13 10:54 ` syzbot
2024-10-13 11:44 ` syzbot
2024-10-13 15:45 ` syzbot
2024-10-16 12:24 ` syzbot
2024-10-16 20:28 ` syzbot
2024-10-19 17:04 ` syzbot
2024-10-20  6:49 ` syzbot
2024-10-20  6:54 ` syzbot
2024-10-21 10:09 ` syzbot
     [not found] <53e285ce-2977-467a-ae0e-8d54f6835c09@nvidia.com>
2024-10-10 13:30 ` syzbot
     [not found] <45071abc-d5fd-4c24-9e36-e8164eca3867@nvidia.com>
2024-10-10 13:30 ` syzbot
     [not found] <397b6a20-036f-404b-bdd1-82cc07d05296@nvidia.com>
2024-10-10 14:02 ` syzbot
     [not found] <181d9e88-ae98-4b4c-bd99-1e0e99da8588@nvidia.com>
2024-10-10 14:26 ` syzbot
     [not found] <68d66e2d-78f8-4a7c-890e-ca81af38984a@nvidia.com>
2024-10-13 11:29 ` syzbot
     [not found] <170d194b-686e-482d-a2f0-151a12887545@nvidia.com>
2024-10-13 12:05 ` syzbot
     [not found] <d21ac7f8-ab23-4b37-80f6-43836bbdbf12@nvidia.com>
2024-10-13 16:08 ` syzbot
     [not found] <53cfa80b-e1f9-4784-b725-e4e7b5c0cb4c@nvidia.com>
2024-10-16 20:02 ` syzbot
     [not found] <db9cbaed-a5a6-419b-8a46-0a9ce4ed4a5f@nvidia.com>
2024-10-16 20:57 ` syzbot
     [not found] <2deb0631-ce6c-4b18-8c34-9401198c9d39@nvidia.com>
2024-10-19 18:55 ` syzbot
     [not found] <605a7a92-5e06-42b6-a44c-6529cfa86d47@nvidia.com>
2024-10-20  8:33 ` syzbot
     [not found] <27386470-ef9f-49dc-a3d6-6c7f428737ad@nvidia.com>
2024-10-20  8:54 ` syzbot
     [not found] <a9414b93-0179-4d20-b619-3ef736f223f0@nvidia.com>
2024-10-21 13:32 ` syzbot

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=20241008114406.GD25819@unreal \
    --to=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=syzbot+5fe14f2ff4ccbace9a26@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.