public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Duoming Zhou <duoming@zju.edu.cn>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	isdn@linux-pingi.de, kuba@kernel.org
Subject: Re: [PATCH V4] mISDN: fix use-after-free bugs in l1oip timer handlers
Date: Thu, 29 Sep 2022 10:22:07 +0300	[thread overview]
Message-ID: <YzVHn6Gtfog6RyNR@unreal> (raw)
In-Reply-To: <20220928133938.86143-1-duoming@zju.edu.cn>

On Wed, Sep 28, 2022 at 09:39:38PM +0800, Duoming Zhou wrote:
> The l1oip_cleanup() traverses the l1oip_ilist and calls
> release_card() to cleanup module and stack. However,
> release_card() calls del_timer() to delete the timers
> such as keep_tl and timeout_tl. If the timer handler is
> running, the del_timer() will not stop it and result in
> UAF bugs. One of the processes is shown below:
> 
>     (cleanup routine)          |        (timer handler)
> release_card()                 | l1oip_timeout()
>  ...                           |
>  del_timer()                   | ...
>  ...                           |
>  kfree(hc) //FREE              |
>                                | hc->timeout_on = 0 //USE
> 
> Fix by calling del_timer_sync() in release_card(), which
> makes sure the timer handlers have finished before the
> resources, such as l1oip and so on, have been deallocated.
> 
> What's more, the hc->workq and hc->socket_thread can kick
> those timers right back in. We add a bool flag to show
> if card is released. Then, check this flag in hc->workq
> and hc->socket_thread.
> 
> Fixes: 3712b42d4b1b ("Add layer1 over IP support")
> Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
> ---
> Changes in v4:
>   - Use bool flag to judge whether card is released.
> 
>  drivers/isdn/mISDN/l1oip.h      |  1 +
>  drivers/isdn/mISDN/l1oip_core.c | 13 +++++++------
>  2 files changed, 8 insertions(+), 6 deletions(-)

It looks like it is ok now, but whole mISDN code doesn't look healthy,
so it is hard to say for sure.

Are you fixing real issue that you saw in field?

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>

  reply	other threads:[~2022-09-29  7:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-28 13:39 [PATCH V4] mISDN: fix use-after-free bugs in l1oip timer handlers Duoming Zhou
2022-09-29  7:22 ` Leon Romanovsky [this message]
2022-09-29 12:23   ` duoming
2022-09-30 11:40 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YzVHn6Gtfog6RyNR@unreal \
    --to=leon@kernel.org \
    --cc=duoming@zju.edu.cn \
    --cc=isdn@linux-pingi.de \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox