All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Kyuwon Shim <kyuwon.shim@alliedtelesis.co.nz>
Cc: pablo@netfilter.org, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH v2] ulogd2: Avoid use after free in unregister on global ulogd_fds linked list
Date: Thu, 16 Mar 2023 12:28:12 +0100	[thread overview]
Message-ID: <ZBL9TEfTBqwoEZH5@strlen.de> (raw)
In-Reply-To: <20230309012447.201582-1-kyuwon.shim@alliedtelesis.co.nz>

Kyuwon Shim <kyuwon.shim@alliedtelesis.co.nz> wrote:
> The issue "core dumped" occurred  from
> ulogd_unregister_fd(). One of the processes is unlink
> from list and remove, but some struct 'pi' values
> freed without ulogd_unregister_fd().
> Unlink process needs to access the previous pointer
> value of struct 'pi', but it was already freed.
> 
> Therefore, the free() process moved location
> after finishing all ulogd_unregister_fd().

I don't understand this patch.

llist_for_each_entry_safe() doesn't dereference 'pi' after its free'd.

Where does this deref happen?  Can you share a backtrace?

> +		}
> +	}
> +
> +	llist_for_each_entry(stack, &ulogd_pi_stacks, stack_list) {
> +		llist_for_each_entry_safe(pi, npi, &stack->list, list) {
>  			free(pi);

Perhaps there should be a 'llist_del' before pi gets free'd instead?

  reply	other threads:[~2023-03-16 11:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1678233154187.35009@alliedtelesis.co.nz>
2023-03-09  1:24 ` [PATCH v2] ulogd2: Avoid use after free in unregister on global ulogd_fds linked list Kyuwon Shim
2023-03-16 11:28   ` Florian Westphal [this message]
2023-03-20 20:41     ` Kyuwon Shim
2023-03-20 21:43       ` Jeremy Sowden
2023-03-20 22:10       ` Florian Westphal
2023-03-20 23:35         ` Kyuwon Shim

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=ZBL9TEfTBqwoEZH5@strlen.de \
    --to=fw@strlen.de \
    --cc=kyuwon.shim@alliedtelesis.co.nz \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.