Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9176388pxu; Mon, 28 Dec 2020 08:28:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJw9xlru/5wCld6LV9HBHKoGAqrl98KmH54PFKiturC37VOZoCW8xu83RtWyFSgLYOtpsV2Y X-Received: by 2002:a17:907:d09:: with SMTP id gn9mr41424188ejc.349.1609172932885; Mon, 28 Dec 2020 08:28:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609172932; cv=none; d=google.com; s=arc-20160816; b=AArKhy9PzbAFmj4vjI3r9iAcamngn0eo3CDUW8H+BUMjSWhR6cKO0TldaGCEG/50A6 Plm/zzP0V/XhZyvjbtsvLgEa6352zHUzmI4WDMtthIPJaGiBH0mGUa4RaQ5PY2EPnZ4K fjtz+6eSfWxkPWrkLn1nxbNgl0EaZJB0sSyzuPo0Pkr3AWAfL6rZ4+Ur7HtzgbIxAQil zve3HubBCyfEF4pmiL5Dxo2uC8EPSDXi8SLfR+0qTWazRnH9CuRA0nu3v3Y7EKrBMots FalO1L3NRdQa1jnMITPVuIHscdZwIiXk9VFdxoU/8byzuhkluYcc1xlMRFZIJ9IKM3Sd vHrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6Gb+qMx9phaU4pu/H548GZEfit7MAhTBJcFKTJCYVPk=; b=Yn+7AaoetRNXV53C3ECrsk5ELihOPskn5piCBlonw0UuHdS9zbQA4+E2SGIwHYUDGj UyXlmGFl25FonIjrbh92bBzf+jwH/d+xP+T4pu8/Oc7xf7ISkGd4S8x+f8V5Ys+RRSiU qWruQIalWz4XcwgQCklANMh/H0zZtZG+T64wPRIZY17klTDQozi9hGapwMyO6iYCP1SI VO8u3LkF/+BDK4fmaMxC98IP6QVjtl2x/wsGCUjjwmZ1ke8h+9zueU3y8W44qnag8I9K awCeKzBWP9wPNCSlwZt7a7OoCTgmyTlpRnvZaIX+NKoIH6v1m70FJS/V2OaSrG2FnmIO 4pDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VqodDdD1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v1si19800870edy.108.2020.12.28.08.28.30; Mon, 28 Dec 2020 08:28:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VqodDdD1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2633296AbgL1QZK (ORCPT + 99 others); Mon, 28 Dec 2020 11:25:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:37366 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731212AbgL1NJw (ORCPT ); Mon, 28 Dec 2020 08:09:52 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0CD82229EF; Mon, 28 Dec 2020 13:09:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160976; bh=VVhoxsibmQMZF0preU3apNC9zIU+02FhwYWUXuXTIHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VqodDdD1cfZXdFzmsyOpcWERJ2y/NkWmMTdZwf61Z9z3eXnEVi9Qhfvw/ZwnDIuo7 qClOfk+HHXpeJLQUVenMiBr0hGTb9tJ3AtQP4SmczqFxF5iERtdAjYZ1FD8VuJsodN IJLT/UVbB+clrgemOwuj1B8KQITrZDSgICyyO5FM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maor Gottlieb , Amit Matityahu , Leon Romanovsky , Jason Gunthorpe , Sasha Levin Subject: [PATCH 4.14 041/242] RDMA/cm: Fix an attempt to use non-valid pointer when cleaning timewait Date: Mon, 28 Dec 2020 13:47:26 +0100 Message-Id: <20201228124906.694822183@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leon Romanovsky [ Upstream commit 340b940ea0ed12d9adbb8f72dea17d516b2019e8 ] If cm_create_timewait_info() fails, the timewait_info pointer will contain an error value and will be used in cm_remove_remote() later. general protection fault, probably for non-canonical address 0xdffffc0000000024: 0000 [#1] SMP KASAN PTI KASAN: null-ptr-deref in range [0×0000000000000120-0×0000000000000127] CPU: 2 PID: 12446 Comm: syz-executor.3 Not tainted 5.10.0-rc5-5d4c0742a60e #27 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 RIP: 0010:cm_remove_remote.isra.0+0x24/0×170 drivers/infiniband/core/cm.c:978 Code: 84 00 00 00 00 00 41 54 55 53 48 89 fb 48 8d ab 2d 01 00 00 e8 7d bf 4b fe 48 89 ea 48 b8 00 00 00 00 00 fc ff df 48 c1 ea 03 <0f> b6 04 02 48 89 ea 83 e2 07 38 d0 7f 08 84 c0 0f 85 fc 00 00 00 RSP: 0018:ffff888013127918 EFLAGS: 00010006 RAX: dffffc0000000000 RBX: fffffffffffffff4 RCX: ffffc9000a18b000 RDX: 0000000000000024 RSI: ffffffff82edc573 RDI: fffffffffffffff4 RBP: 0000000000000121 R08: 0000000000000001 R09: ffffed1002624f1d R10: 0000000000000003 R11: ffffed1002624f1c R12: ffff888107760c70 R13: ffff888107760c40 R14: fffffffffffffff4 R15: ffff888107760c9c FS: 00007fe1ffcc1700(0000) GS:ffff88811a600000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000001b2ff21000 CR3: 000000010f504001 CR4: 0000000000370ee0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: cm_destroy_id+0x189/0×15b0 drivers/infiniband/core/cm.c:1155 cma_connect_ib drivers/infiniband/core/cma.c:4029 [inline] rdma_connect_locked+0x1100/0×17c0 drivers/infiniband/core/cma.c:4107 rdma_connect+0x2a/0×40 drivers/infiniband/core/cma.c:4140 ucma_connect+0x277/0×340 drivers/infiniband/core/ucma.c:1069 ucma_write+0x236/0×2f0 drivers/infiniband/core/ucma.c:1724 vfs_write+0x220/0×830 fs/read_write.c:603 ksys_write+0x1df/0×240 fs/read_write.c:658 do_syscall_64+0x33/0×40 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Fixes: a977049dacde ("[PATCH] IB: Add the kernel CM implementation") Link: https://lore.kernel.org/r/20201204064205.145795-1-leon@kernel.org Reviewed-by: Maor Gottlieb Reported-by: Amit Matityahu Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/core/cm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index 80a8eb7e5d6ec..3ddc556df809c 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c @@ -1349,6 +1349,7 @@ int ib_send_cm_req(struct ib_cm_id *cm_id, id.local_id); if (IS_ERR(cm_id_priv->timewait_info)) { ret = PTR_ERR(cm_id_priv->timewait_info); + cm_id_priv->timewait_info = NULL; goto out; } @@ -1836,6 +1837,7 @@ static int cm_req_handler(struct cm_work *work) id.local_id); if (IS_ERR(cm_id_priv->timewait_info)) { ret = PTR_ERR(cm_id_priv->timewait_info); + cm_id_priv->timewait_info = NULL; goto destroy; } cm_id_priv->timewait_info->work.remote_id = req_msg->local_comm_id; -- 2.27.0