Date: Fri, 30 Mar 2018 18:37:51 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r331785 - stable/11/sys/ofed/drivers/infiniband/core Message-ID: <201803301837.w2UIbp6Z077642@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hselasky Date: Fri Mar 30 18:37:51 2018 New Revision: 331785 URL: https://svnweb.freebsd.org/changeset/base/331785 Log: MFC r330579: 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! Sponsored by: Mellanox Technologies Modified: stable/11/sys/ofed/drivers/infiniband/core/ib_cm.c stable/11/sys/ofed/drivers/infiniband/core/ib_mad.c stable/11/sys/ofed/drivers/infiniband/core/ib_mad_rmpp.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/ofed/drivers/infiniband/core/ib_cm.c ============================================================================== --- stable/11/sys/ofed/drivers/infiniband/core/ib_cm.c Fri Mar 30 18:36:44 2018 (r331784) +++ stable/11/sys/ofed/drivers/infiniband/core/ib_cm.c Fri Mar 30 18:37:51 2018 (r331785) @@ -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: stable/11/sys/ofed/drivers/infiniband/core/ib_mad.c ============================================================================== --- stable/11/sys/ofed/drivers/infiniband/core/ib_mad.c Fri Mar 30 18:36:44 2018 (r331784) +++ stable/11/sys/ofed/drivers/infiniband/core/ib_mad.c Fri Mar 30 18:37:51 2018 (r331785) @@ -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: stable/11/sys/ofed/drivers/infiniband/core/ib_mad_rmpp.c ============================================================================== --- stable/11/sys/ofed/drivers/infiniband/core/ib_mad_rmpp.c Fri Mar 30 18:36:44 2018 (r331784) +++ stable/11/sys/ofed/drivers/infiniband/core/ib_mad_rmpp.c Fri Mar 30 18:37:51 2018 (r331785) @@ -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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803301837.w2UIbp6Z077642>