Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
This bug was initially created as a copy of Bug #2042196
I am copying this bug because:
It seems this problem exists in rhel9.
Version-Release number of selected component (if applicable):
kernel-5.14.0-138.el9.x86_64
libtirpc-1.3.2-1.el9.x86_64
Beaker jobs:
https://beaker.engineering.redhat.com/jobs/6876111
Description of problem:
When an rpc call returns an error, lirbirpc frees the memory associated with the call before obtaining the error number stored in that memory.
Version-Release number of selected component (if applicable):
libtirpc-1.1.4-6.el8
How reproducible:
easy
Steps to Reproduce:
* add iptables rule to reject udp incoming to port 111:
# iptables -I INPUT -p udp --dport 111 -j REJECT --reject-with=icmp-host-prohibited
* make rpc call over udp
# valgrind rpcinfo -T udp localhost
Actual results:
# valgrind rpcinfo -T udp localhost
==2799905== Memcheck, a memory error detector
==2799905== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==2799905== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==2799905== Command: rpcinfo -T udp localhost
==2799905==
==2799905== Invalid read of size 4
==2799905== at 0x4E4F2B1: ??? (in /usr/lib64/libtirpc.so.3.0.0)
==2799905== by 0x10B819: rpcbdump (rpcinfo.c:831)
==2799905== by 0x109EE5: main (rpcinfo.c:302)
==2799905== Address 0x74287a0 is 16 bytes inside a block of size 296 free'd
==2799905== at 0x4C34A93: free (vg_replace_malloc.c:872)
==2799905== by 0x4E4F2A8: ??? (in /usr/lib64/libtirpc.so.3.0.0)
==2799905== by 0x10B819: rpcbdump (rpcinfo.c:831)
==2799905== by 0x109EE5: main (rpcinfo.c:302)
==2799905== Block was alloc'd at
==2799905== at 0x4C36E4B: calloc (vg_replace_malloc.c:1328)
==2799905== by 0x4E4F098: ??? (in /usr/lib64/libtirpc.so.3.0.0)
==2799905== by 0x10B819: rpcbdump (rpcinfo.c:831)
==2799905== by 0x109EE5: main (rpcinfo.c:302)
Expected results:
no use-after-free
Additional info:
The clnt_dg_call error handling reads the error number after it frees the memory that contains the error:
for (cmsg = CMSG_FIRSTHDR (&msg); cmsg;
cmsg = CMSG_NXTHDR (&msg, cmsg))
if (cmsg->cmsg_level == SOL_IP && cmsg->cmsg_type == IP_RECVERR)
{
mem_free(cbuf, (outlen + 256)); <<<<<<<< 'cbuf' freed
e = (struct sock_extended_err *) CMSG_DATA(cmsg);
cu->cu_error.re_errno = e->ee_errno; <<<<<<<< 'e' is a pointer to a location within 'cbuf' that was just freed
release_fd_lock(cu->cu_fd_lock, mask);
return (cu->cu_error.re_status = RPC_CANTRECV);
}
patch sent upstream https://www.spinics.net/lists/linux-nfs/msg88447.html
commit d0dc59e27263c6b53435d770010dcc6f397d58ee
Author: Frank Sorenson <sorenson>
Date: Mon Jan 17 13:33:13 2022 -0500
libtirpc: Fix use-after-free accessing the error number
Free the cbuf after obtaining the error number.
Signed-off-by: Frank Sorenson <sorenson>
Signed-off-by: Steve Dickson <steved>