Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9184777pxu; Mon, 28 Dec 2020 08:42:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUih1mp2DADlq8Dt8shId8PRwL99VyLXdddneGannUlUZ5e7bZq0lKi7/tvK9KBzy3S5Wn X-Received: by 2002:a17:907:36a:: with SMTP id rs10mr41524391ejb.411.1609173731723; Mon, 28 Dec 2020 08:42:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609173731; cv=none; d=google.com; s=arc-20160816; b=AReSt+NEekiwpuPSb4MIQ3qjdhwKfWlKvgZJ4Nh9GgALgbbQ8XwRTFjx+F0MSYtpbW chgvwqhm//UIbFazpXWP+v9DDCkLVyyDI+/64PeQhx/mdii6CpBJ76b0QFLDqB/dodK7 nFFQzmvglYPYHJEBk4DhRIWj+l4tuA8gB87WTZZK5Jh/gLCYcV60QMQSKIZ5pcsq8VXh 6r8EhvT039G08bFXI+y3KJcenCFUHI8lwtTQ8Sa++LiYpOcZvRpAUt9G85G+q8RHnvMi w/mAQ3oNFkoCLLMoV4TfOPYxpVf9sqaT/O7LeGhAZLfuOOlxiPXylQirQlXCmKix4wtp gsBQ== 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=dITJmeUCN+0mJT3vcDvCl7rtiBJ++xnpAQi+neks8pI=; b=yUEWeL4B0Ec7oGi82IfcvV7MYM8blNAGjvhFEAC6Jgc3losDjtyX6ZlM/zXGrrmnQx /d5vQ8LAoU2ooeVMgCZwkDo8l+UC4jsgFqMQ7PeuaLwLJ3Zaxrdlmd5IjQk29LJ9apjB qeZwfpMgWpSZDUfcy8+0kMOSdGb60n8TUqdheauZ20SARGADyV0LAKCWieK8dJ+vhx4B eMjvUIMVbAs3lDDtZSKdndqZTgS1s6E2ka5Y+d0d6Rd6/0HiRwCOdytWKofFDGe8Ugb2 j33dTBbgaHV+GrEf6kHE6IA9BIjuLToAy50VTBTiuofc18c5xVqxwZ2E9jrYSFIqgPTO oIHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iBjwPEf+; 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 s2si20848015eds.424.2020.12.28.08.41.49; Mon, 28 Dec 2020 08:42:11 -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=iBjwPEf+; 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 S1729349AbgL1M7y (ORCPT + 99 others); Mon, 28 Dec 2020 07:59:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:55886 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729321AbgL1M7t (ORCPT ); Mon, 28 Dec 2020 07:59:49 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 65BB422573; Mon, 28 Dec 2020 12:59:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160374; bh=Q8JP1zhbZqwQs90LgMLu1Sy3i8j2Y/HYBBqjMnVMYTs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iBjwPEf+795ZVXxlZZNsgR4gNL5hAarGZ4vbS8cxTZO71npRFB6SSr7luryuRerOs Gv70AR1OTxvX+JDWHjMe+MfbwYXIxH5ZyiNjCDOeesjS3OgoS2efSFdZgn9a/GvMOk GUPMzy7iqvCOotYiKaJ6ySS8eSoIS6M7ZrZcH4Gw= 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.9 030/175] RDMA/cm: Fix an attempt to use non-valid pointer when cleaning timewait Date: Mon, 28 Dec 2020 13:48:03 +0100 Message-Id: <20201228124854.719587262@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124853.216621466@linuxfoundation.org> References: <20201228124853.216621466@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 304429fd04ddb..97168b856606b 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c @@ -1252,6 +1252,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; } @@ -1683,6 +1684,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