lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1149b747.c620.17820d56572.Coremail.lyl2019@mail.ustc.edu.cn>
Date:   Thu, 11 Mar 2021 18:29:19 +0800 (GMT+08:00)
From:   lyl2019@...l.ustc.edu.cn
To:     "Leon Romanovsky" <leon@...nel.org>
Cc:     dledford@...hat.com, jgg@...pe.ca, linux-rdma@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: Re: [PATCH] infiniband/core: Fix a use after free in
 cm_work_handler

In the implementation of destory_cm_id(), it restores cm_id_priv by 
"cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);".

And the last line of destory_cm_id() calls "(void)iwcm_deref_id(cm_id_priv);"
to free the cm_id_priv.


> -----原始邮件-----
> 发件人: "Leon Romanovsky" <leon@...nel.org>
> 发送时间: 2021-03-11 17:22:03 (星期四)
> 收件人: "Lv Yunlong" <lyl2019@...l.ustc.edu.cn>
> 抄送: dledford@...hat.com, jgg@...pe.ca, linux-rdma@...r.kernel.org, linux-kernel@...r.kernel.org
> 主题: Re: [PATCH] infiniband/core: Fix a use after free in cm_work_handler
> 
> On Wed, Mar 10, 2021 at 06:21:53PM -0800, Lv Yunlong wrote:
> > In cm_work_handler, it calls destory_cm_id() to release
> > the initial reference of cm_id_priv taken by iw_create_cm_id()
> > and free the cm_id_priv. After destory_cm_id(), iwcm_deref_id
> > (cm_id_priv) will be called and cause a use after free.
> >
> > Fixes: 59c68ac31e15a ("iw_cm: free cm_id resources on the last deref")
> > Signed-off-by: Lv Yunlong <lyl2019@...l.ustc.edu.cn>
> > ---
> >  drivers/infiniband/core/iwcm.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c
> > index da8adadf4755..cb6b4ac45e21 100644
> > --- a/drivers/infiniband/core/iwcm.c
> > +++ b/drivers/infiniband/core/iwcm.c
> > @@ -1035,8 +1035,10 @@ static void cm_work_handler(struct work_struct *_work)
> >
> >  		if (!test_bit(IWCM_F_DROP_EVENTS, &cm_id_priv->flags)) {
> >  			ret = process_event(cm_id_priv, &levent);
> > -			if (ret)
> > +			if (ret) {
> >  				destroy_cm_id(&cm_id_priv->id);
> > +				return;
> 
> The destroy_cm_id() is called to free ->id and not cm_id_priv. This "return"
> leaks cm_id_priv now and what "a use after free" do you see?
> 
> > +			}
> >  		} else
> >  			pr_debug("dropping event %d\n", levent.event);
> >  		if (iwcm_deref_id(cm_id_priv))
> > --
> > 2.25.1
> >
> >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ