Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3008802imm; Sun, 1 Jul 2018 10:12:26 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKrvD6tQQPdrSRn+L2kz0O7OeqIqo2otzbxDh7+slBTYSPXrrLq4qj5887Apm9PI/5DoYEH X-Received: by 2002:a63:be05:: with SMTP id l5-v6mr19003133pgf.330.1530465146005; Sun, 01 Jul 2018 10:12:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530465145; cv=none; d=google.com; s=arc-20160816; b=SBkEWkbhHIWFmHCicmG1W0igiAlC24SA1iJAxJ08RgRlTu1c6sxlgcPakBDBei/lMl RknMs/fvWSenGbd+0XbYXr91i/8IsCXgo+1c1mOtty+LxufLf6aQvfyTsbQ6gsg+oE7X dg1LuqmEz3Zw2tej4gRQcVtwWuBhIZKLM0IM3OfQlNAsHniH7bHqsSSCgfDgHBgv8iEO SZRo7HV4meuwSvBRQDKS7+vt7reOyfOWdfRwPdyViNaa7X/nCscbr0XKpX8e6nnfOocX 509PzE5TG8iPYVN4mj31e5pyd7LDYgNRoQEF0BK6+TRH5C3zhT/cssUsFkWbb7EW8s3f 206Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=yJPahArmMhsKf0hBVScSG+qDq8rdg8bd1EtiZ1t/Jfo=; b=Xv4M5X07zJcv8tS7QMPqfCG0MA4X/e+FVHQHBVrY8J94Efywu9VgbcMN0xr0eid/Zf ojMPyX2KNg4HZn7KZSnJvOi6g4bBUbERrd5QPRFgwYfkYvQLizziFxel4Cr0GQ6zNrzn k8D/4p9i44gCozIc+86558RY41UlEJkh3lgLuoPU1Ohv3X7JxRTIarE0DUeHVyPkkbOS XhOeoOsj2RMQihJhQe9Akivy3bnw2X4doUZ2oCtzS3zLzgVhDPlcAx2YEyZamNVNBYEn Wm3Wh9IlzapKuHE5ypU+GN1z5sqeKzs1vjb1f0wJ+mnL7x5OGR2k6h645IDVuCpsEYEy 0APQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t12-v6si12046380pgp.565.2018.07.01.10.12.11; Sun, 01 Jul 2018 10:12:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753729AbeGARKT (ORCPT + 99 others); Sun, 1 Jul 2018 13:10:19 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37286 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031995AbeGAQlD (ORCPT ); Sun, 1 Jul 2018 12:41:03 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 22CBDAA6; Sun, 1 Jul 2018 16:41:02 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Steve Wise , Potnuri Bharat Teja , Leon Romanovsky , Jason Gunthorpe Subject: [PATCH 4.17 098/220] RDMA/core: Save kernel caller name when creating CQ using ib_create_cq() Date: Sun, 1 Jul 2018 18:22:02 +0200 Message-Id: <20180701160912.507158106@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bharat Potnuri commit 7350cdd0257e73a37df57253fb9decd8effacd37 upstream. Few kernel applications like SCST-iSER create CQ using ib_create_cq(), where accessing CQ structures using rdma restrack tool leads to below NULL pointer dereference. This patch saves caller kernel module name similar to ib_alloc_cq(). BUG: unable to handle kernel NULL pointer dereference at (null) IP: [] skip_spaces+0x30/0x30 PGD 738bac067 PUD 8533f0067 PMD 0 Oops: 0000 [#1] SMP R10: ffff88017fc03300 R11: 0000000000000246 R12: 0000000000000000 R13: ffff88082fa5a668 R14: ffff88017475a000 R15: 0000000000000000 FS: 00002b32726582c0(0000) GS:ffff88087fc40000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 00000008491a1000 CR4: 00000000003607e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: [] ? fill_res_name_pid+0x7c/0x90 [ib_core] [] fill_res_cq_entry+0xef/0x170 [ib_core] [] res_get_common_dumpit+0x3c4/0x480 [ib_core] [] nldev_res_get_cq_dumpit+0x13/0x20 [ib_core] [] netlink_dump+0x117/0x2e0 [] __netlink_dump_start+0x1ab/0x230 [] ibnl_rcv_msg+0x11d/0x1f0 [ib_core] [] ? nldev_res_get_mr_dumpit+0x20/0x20 [ib_core] [] ? rdma_nl_multicast+0x30/0x30 [ib_core] [] netlink_rcv_skb+0xa9/0xc0 [] ibnl_rcv+0x98/0xb0 [ib_core] [] netlink_unicast+0xf2/0x1b0 [] netlink_sendmsg+0x31f/0x6a0 [] sock_sendmsg+0xb0/0xf0 [] ? _raw_spin_unlock_bh+0x1e/0x20 [] ? release_sock+0x118/0x170 [] SYSC_sendto+0x121/0x1c0 [] ? sock_alloc_file+0xa0/0x140 [] ? __fd_install+0x25/0x60 [] SyS_sendto+0xe/0x10 [] system_call_fastpath+0x16/0x1b RIP [] skip_spaces+0x30/0x30 RSP CR2: 0000000000000000 Cc: Fixes: f66c8ba4c9fa ("RDMA/core: Save kernel caller name when creating PD and CQ objects") Reviewed-by: Steve Wise Signed-off-by: Potnuri Bharat Teja Reviewed-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/core/verbs.c | 14 ++++++++------ include/rdma/ib_verbs.h | 13 ++++++++----- 2 files changed, 16 insertions(+), 11 deletions(-) --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -1562,11 +1562,12 @@ EXPORT_SYMBOL(ib_destroy_qp); /* Completion queues */ -struct ib_cq *ib_create_cq(struct ib_device *device, - ib_comp_handler comp_handler, - void (*event_handler)(struct ib_event *, void *), - void *cq_context, - const struct ib_cq_init_attr *cq_attr) +struct ib_cq *__ib_create_cq(struct ib_device *device, + ib_comp_handler comp_handler, + void (*event_handler)(struct ib_event *, void *), + void *cq_context, + const struct ib_cq_init_attr *cq_attr, + const char *caller) { struct ib_cq *cq; @@ -1580,12 +1581,13 @@ struct ib_cq *ib_create_cq(struct ib_dev cq->cq_context = cq_context; atomic_set(&cq->usecnt, 0); cq->res.type = RDMA_RESTRACK_CQ; + cq->res.kern_name = caller; rdma_restrack_add(&cq->res); } return cq; } -EXPORT_SYMBOL(ib_create_cq); +EXPORT_SYMBOL(__ib_create_cq); int rdma_set_cq_moderation(struct ib_cq *cq, u16 cq_count, u16 cq_period) { --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -3310,11 +3310,14 @@ int ib_process_cq_direct(struct ib_cq *c * * Users can examine the cq structure to determine the actual CQ size. */ -struct ib_cq *ib_create_cq(struct ib_device *device, - ib_comp_handler comp_handler, - void (*event_handler)(struct ib_event *, void *), - void *cq_context, - const struct ib_cq_init_attr *cq_attr); +struct ib_cq *__ib_create_cq(struct ib_device *device, + ib_comp_handler comp_handler, + void (*event_handler)(struct ib_event *, void *), + void *cq_context, + const struct ib_cq_init_attr *cq_attr, + const char *caller); +#define ib_create_cq(device, cmp_hndlr, evt_hndlr, cq_ctxt, cq_attr) \ + __ib_create_cq((device), (cmp_hndlr), (evt_hndlr), (cq_ctxt), (cq_attr), KBUILD_MODNAME) /** * ib_resize_cq - Modifies the capacity of the CQ.