From owner-svn-src-all@freebsd.org Wed Mar 7 12:56:05 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5040DF27E62; Wed, 7 Mar 2018 12:56:05 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F1A2871707; Wed, 7 Mar 2018 12:56:04 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E84A121A0F; Wed, 7 Mar 2018 12:56:04 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w27Cu4l1097690; Wed, 7 Mar 2018 12:56:04 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w27Cu4iq097687; Wed, 7 Mar 2018 12:56:04 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201803071256.w27Cu4iq097687@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 7 Mar 2018 12:56:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r330579 - head/sys/ofed/drivers/infiniband/core X-SVN-Group: head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: head/sys/ofed/drivers/infiniband/core X-SVN-Commit-Revision: 330579 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Mar 2018 12:56:05 -0000 Author: hselasky Date: Wed Mar 7 12:56:04 2018 New Revision: 330579 URL: https://svnweb.freebsd.org/changeset/base/330579 Log: Fix for use-after-free when using delayed work structures in ibcore. It is not enough to cancel delayed work structures before freeing. Always cancel delayed work synchronously before freeing! MFC after: 1 week Sponsored by: Mellanox Technologies Modified: head/sys/ofed/drivers/infiniband/core/ib_cm.c head/sys/ofed/drivers/infiniband/core/ib_mad.c head/sys/ofed/drivers/infiniband/core/ib_mad_rmpp.c Modified: head/sys/ofed/drivers/infiniband/core/ib_cm.c ============================================================================== --- head/sys/ofed/drivers/infiniband/core/ib_cm.c Wed Mar 7 11:09:07 2018 (r330578) +++ head/sys/ofed/drivers/infiniband/core/ib_cm.c Wed Mar 7 12:56:04 2018 (r330579) @@ -4132,6 +4132,7 @@ static void __exit ib_cm_cleanup(void) destroy_workqueue(cm.wq); list_for_each_entry_safe(timewait_info, tmp, &cm.timewait_list, list) { + cancel_delayed_work_sync(&timewait_info->work.work); list_del(&timewait_info->list); kfree(timewait_info); } Modified: head/sys/ofed/drivers/infiniband/core/ib_mad.c ============================================================================== --- head/sys/ofed/drivers/infiniband/core/ib_mad.c Wed Mar 7 11:09:07 2018 (r330578) +++ head/sys/ofed/drivers/infiniband/core/ib_mad.c Wed Mar 7 12:56:04 2018 (r330579) @@ -572,7 +572,7 @@ static void unregister_mad_agent(struct ib_mad_agent_p */ cancel_mads(mad_agent_priv); port_priv = mad_agent_priv->qp_info->port_priv; - cancel_delayed_work(&mad_agent_priv->timed_work); + cancel_delayed_work_sync(&mad_agent_priv->timed_work); spin_lock_irqsave(&port_priv->reg_lock, flags); remove_mad_reg_req(mad_agent_priv); Modified: head/sys/ofed/drivers/infiniband/core/ib_mad_rmpp.c ============================================================================== --- head/sys/ofed/drivers/infiniband/core/ib_mad_rmpp.c Wed Mar 7 11:09:07 2018 (r330578) +++ head/sys/ofed/drivers/infiniband/core/ib_mad_rmpp.c Wed Mar 7 12:56:04 2018 (r330579) @@ -103,8 +103,8 @@ void ib_cancel_rmpp_recvs(struct ib_mad_agent_private spin_unlock_irqrestore(&agent->lock, flags); list_for_each_entry(rmpp_recv, &agent->rmpp_list, list) { - cancel_delayed_work(&rmpp_recv->timeout_work); - cancel_delayed_work(&rmpp_recv->cleanup_work); + cancel_delayed_work_sync(&rmpp_recv->timeout_work); + cancel_delayed_work_sync(&rmpp_recv->cleanup_work); } flush_workqueue(agent->qp_info->port_priv->wq);