From: Olga Kornievskaia <okorniev@redhat.com>
To: steved@redhat.com
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 1/3] libtirpc: Fix use-after-free in xdr_pmaplist() XDR_FREE path
Date: Sun, 6 Sep 2026 21:13:26 -0400 [thread overview]
Message-ID: <20260907011328.21425-2-okorniev@redhat.com> (raw)
In-Reply-To: <20260907011328.21425-1-okorniev@redhat.com>
The XDR_FREE loop saved a pointer to the pml_next field inside the
struct being freed (next = &((*rp)->pml_next)), then dereferenced it
on the next iteration. This reads freed memory.
Adopt the same pattern xdr_rpcblist_ptr() already uses: save the
value of the next pointer before freeing, then point rp at a stack
copy.
Signed-off-by: Olga Kornievskaia <okorniev@redhat.com>
---
src/pmap_prot2.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/pmap_prot2.c b/src/pmap_prot2.c
index bbac74f..7611bd5 100644
--- a/src/pmap_prot2.c
+++ b/src/pmap_prot2.c
@@ -88,7 +88,8 @@ xdr_pmaplist(XDR *xdrs, struct pmaplist **rp)
*/
bool_t more_elements;
int freeing;
- struct pmaplist **next = NULL; /* pacify gcc */
+ struct pmaplist *next = NULL;
+ struct pmaplist *next_copy;
assert(xdrs != NULL);
assert(rp != NULL);
@@ -107,11 +108,16 @@ xdr_pmaplist(XDR *xdrs, struct pmaplist **rp)
* before we free the current object ...
*/
if (freeing)
- next = &((*rp)->pml_next);
+ next = (*rp)->pml_next;
if (! xdr_reference(xdrs, (caddr_t *)rp,
(u_int)sizeof(struct pmaplist), (xdrproc_t)xdr_pmap))
return (FALSE);
- rp = (freeing) ? next : &((*rp)->pml_next);
+ if (freeing) {
+ next_copy = next;
+ rp = &next_copy;
+ } else {
+ rp = &((*rp)->pml_next);
+ }
}
}
--
2.52.0
next prev parent reply other threads:[~2026-09-07 1:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 1:13 [PATCH 1/1] fsidd: require root credentials on abstract socket Olga Kornievskaia
2026-09-07 1:13 ` Olga Kornievskaia [this message]
2026-09-13 3:48 ` [PATCH 1/3] libtirpc: Fix use-after-free in xdr_pmaplist() XDR_FREE path Steve Dickson
2026-09-07 1:13 ` [PATCH 2/3] libtirpc: limit XDR decode node count Olga Kornievskaia
2026-09-13 3:48 ` Steve Dickson
2026-09-07 1:13 ` [PATCH 3/3] libtirpc: Bound maxsize in xdr_rpc_gss_unwrap_data() decode calls Olga Kornievskaia
2026-09-13 3:49 ` Steve Dickson
2026-09-13 3:47 ` [PATCH 1/1] fsidd: require root credentials on abstract socket Steve Dickson
2026-09-16 14:19 ` Steve Dickson
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=20260907011328.21425-2-okorniev@redhat.com \
--to=okorniev@redhat.com \
--cc=linux-nfs@vger.kernel.org \
--cc=steved@redhat.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.