From: Benjamin Marzinski <bmarzins@redhat.com>
To: Martin Wilck <martin.wilck@suse.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>,
dm-devel@lists.linux.dev, Martin Wilck <mwilck@suse.com>
Subject: Re: [PATCH v2 13/26] multipath: free paths through pathvec in check_usable_paths()
Date: Fri, 19 Dec 2025 23:19:37 -0500 [thread overview]
Message-ID: <aUYj2RFgD81maXre@redhat.com> (raw)
In-Reply-To: <20251219144108.237928-14-mwilck@suse.com>
On Fri, Dec 19, 2025 at 03:40:55PM +0100, Martin Wilck wrote:
> Paths belong to the pathvec and should be freed from it.
> Use cleanup_multipath() instead of cleanup_multipath_and_paths(),
> and free the paths via the pathvec instead.
>
I don't know if this matters, but until you stop free_multipaths() from
clearing pp->mpp in patch 15/26, this will temporarily cause UAF errors,
since you free the paths from the pathvec first, and then attempt to
reset their pp->mpp value in free_multipaths() later.
You could avoid the temporary problem by moving the pathvec definition
before the mpp definition, since cleanup functions are run in reverse
order of their declaration.
But after applying patch 15/26, this is fine, so
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
> Suggested-by: Benjamin Marzinski <bmarzins@redhat.com>
> Signed-off-by: Martin Wilck <mwilck@suse.com>
> ---
> multipath/main.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/multipath/main.c b/multipath/main.c
> index 4b8d7dd..d28628b 100644
> --- a/multipath/main.c
> +++ b/multipath/main.c
> @@ -214,12 +214,12 @@ static int check_usable_paths(struct config *conf,
> const char *devpath, enum devtypes dev_type)
> {
> struct udev_device __attribute__((cleanup(cleanup_udev_device))) *ud = NULL;
> - struct multipath __attribute__((cleanup(cleanup_multipath_and_paths))) *mpp = NULL;
> + struct multipath __attribute__((cleanup(cleanup_multipath))) *mpp = NULL;
> struct pathgroup *pg;
> struct path *pp;
> char __attribute__((cleanup(cleanup_charp))) *params = NULL;
> char __attribute__((cleanup(cleanup_charp))) *status = NULL;
> - vector __attribute((cleanup(cleanup_vector))) pathvec = NULL;
> + vector __attribute((cleanup(cleanup_pathvec_and_free_paths))) pathvec = NULL;
> char uuid[DM_UUID_LEN];
> dev_t devt;
> int r = 1, i, j;
> --
> 2.52.0
next prev parent reply other threads:[~2025-12-20 4:19 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-19 14:40 [PATCH v2 00/26] Multipath-tools: various bug fixes Martin Wilck
2025-12-19 14:40 ` [PATCH v2 01/26] libmultipath: drop drop_multipath Martin Wilck
2025-12-19 14:40 ` [PATCH v2 02/26] libmultipath: don't access path members in free_pgvec() Martin Wilck
2025-12-19 14:40 ` [PATCH v2 03/26] libmpathutil: constify find_slot() Martin Wilck
2025-12-19 14:40 ` [PATCH v2 04/26] libmultipath: don't touch mpvec in remove_map() Martin Wilck
2025-12-19 14:40 ` [PATCH v2 05/26] libmultipath: export orphan_paths() Martin Wilck
2025-12-19 14:40 ` [PATCH v2 06/26] libmultipath: export cleanup_multipath() Martin Wilck
2025-12-19 14:40 ` [PATCH v2 07/26] libmultipath: add cleanup_pathvec_and_free_paths() Martin Wilck
2025-12-19 14:40 ` [PATCH v2 08/26] libmultipath: don't free paths in orphan_paths() Martin Wilck
2025-12-19 14:40 ` [PATCH v2 09/26] multipathd: free orphaned paths in checker_finished() Martin Wilck
2025-12-19 14:40 ` [PATCH v2 10/26] libmultipath: remove free_paths argument from free_pathgroup() Martin Wilck
2025-12-19 14:40 ` [PATCH v2 11/26] libmultipath: remove free_paths argument from free_pgvec() Martin Wilck
2025-12-19 14:40 ` [PATCH v2 12/26] libmultipath: remove free_paths argument from free_multipathvec() Martin Wilck
2025-12-19 14:40 ` [PATCH v2 13/26] multipath: free paths through pathvec in check_usable_paths() Martin Wilck
2025-12-20 4:19 ` Benjamin Marzinski [this message]
2026-01-05 14:38 ` Martin Wilck
2025-12-19 14:40 ` [PATCH v2 14/26] multipathd: add_map_without_path(): orphan paths instead of freeing them Martin Wilck
2025-12-19 14:46 ` Martin Wilck
2025-12-20 4:23 ` Benjamin Marzinski
2026-01-05 15:15 ` Martin Wilck
2026-01-05 23:17 ` Benjamin Marzinski
2026-01-06 10:31 ` Martin Wilck
2025-12-19 14:40 ` [PATCH v2 15/26] libmultipath: remove free_paths argument from free_multipath() Martin Wilck
2025-12-19 14:40 ` [PATCH v2 16/26] libmultipath: remove cleanup_multipath_and_paths() Martin Wilck
2025-12-20 4:26 ` Benjamin Marzinski
2025-12-19 14:40 ` [PATCH v2 17/26] libmultipaths: annotate functions that may free paths Martin Wilck
2025-12-20 4:35 ` Benjamin Marzinski
2025-12-19 14:41 ` [PATCH v2 18/26] multipath-tools: Fix ISO C23 errors with strchr() Martin Wilck
2025-12-19 14:41 ` [PATCH v2 19/26] libmultipath: simplify sysfs_get_target_nodename() Martin Wilck
2025-12-19 14:41 ` [PATCH v2 20/26] multipathd: join the init_unwinder dummy thread Martin Wilck
2025-12-19 14:41 ` [PATCH v2 21/26] kpartx: fix some memory leaks Martin Wilck
2025-12-19 14:41 ` [PATCH v2 22/26] libmpathutil: use union for bitfield Martin Wilck
2025-12-19 14:41 ` [PATCH v2 23/26] libmpathutil: add wrapper code for libudev Martin Wilck
2025-12-19 14:41 ` [PATCH v2 24/26] multipath-tools: use the libudev wrapper functions Martin Wilck
2025-12-19 14:41 ` [PATCH v2 25/26] Makefile: add functionality to determine cmocka version Martin Wilck
2025-12-19 14:41 ` [PATCH v2 26/26] multipath-tools tests: adaptations for cmocka 2.0 Martin Wilck
2025-12-20 4:41 ` [PATCH v2 00/26] Multipath-tools: various bug fixes Benjamin Marzinski
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=aUYj2RFgD81maXre@redhat.com \
--to=bmarzins@redhat.com \
--cc=christophe.varoqui@opensvc.com \
--cc=dm-devel@lists.linux.dev \
--cc=martin.wilck@suse.com \
--cc=mwilck@suse.com \
/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.