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.
Bug 2138317 - clnt_raw.c: possibly null pointer dereference in clnt_raw_freeres()
Summary: clnt_raw.c: possibly null pointer dereference in clnt_raw_freeres()
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: libtirpc
Version: 9.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Steve Dickson
QA Contact: Zhi Li
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-10-28 05:28 UTC by Zhi Li
Modified: 2023-05-09 10:27 UTC (History)
1 user (show)

Fixed In Version: libtirpc-1.3.3-1.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-05-09 08:19:31 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-137772 0 None None None 2022-10-28 05:35:16 UTC
Red Hat Product Errata RHBA-2023:2506 0 None None None 2023-05-09 08:19:32 UTC

Description Zhi Li 2022-10-28 05:28:57 UTC
Description of problem:

Possibly null pointer dereference in clnt_raw_freeres() of /root/libtirpc-1.3.3/src/clnt_raw.c

 240 /* ARGSUSED */
 241 static bool_t
 242 clnt_raw_freeres(cl, xdr_res, res_ptr)
 243         CLIENT *cl;
 244         xdrproc_t xdr_res;
 245         void *res_ptr;
 246 {
 247         struct clntraw_private *clp = clntraw_private;
 248         XDR *xdrs = &clp->xdr_stream;    // << pointer clp could be NULL here
 249         bool_t rval;
 250
 251         mutex_lock(&clntraw_lock);
 252         if (clp == NULL) {
 253                 rval = (bool_t) RPC_FAILED;
 254                 mutex_unlock(&clntraw_lock);
 255                 return (rval);
 256         }
 257         mutex_unlock(&clntraw_lock);
 258         xdrs->x_op = XDR_FREE;
 259         return ((*xdr_res)(xdrs, res_ptr));
 260 }

captured from clang-static-analyzer

Since the mutex clntraw_lock exists in multiple functions, and the valid structure of clntraw_private is allocated in clnt_raw_create(), who shares the same mutex with clnt_raw_freeres(), if that function is invoked before clnt_raw_create() in parallel or serial manner, the dereference of clp could lead to a null pointer reference.

  76 /*
  77  * Create a client handle for memory based rpc.
  78  */
  79 CLIENT *
  80 clnt_raw_create(prog, vers)
  81         rpcprog_t prog;
  82         rpcvers_t vers;
  83 {
  84         struct clntraw_private *clp;
  85         struct rpc_msg call_msg;
  86         XDR *xdrs;
  87         CLIENT  *client;
  88
  89         mutex_lock(&clntraw_lock);
  90         clp = clntraw_private;
  91         if (clp == NULL) {
  92                 clp = (struct clntraw_private *)calloc(1, sizeof (*clp)); // clntraw_private allocated here
  93                 if (clp == NULL) {
  94                         mutex_unlock(&clntraw_lock);
  95                         return NULL;
  96                 }
  97                 if (__rpc_rawcombuf == NULL)
  98                         __rpc_rawcombuf =
  99                             (char *)calloc(UDPMSGSIZE, sizeof (char));
 100                 clp->_raw_buf = __rpc_rawcombuf;
 101                 clntraw_private = clp;
 102         }
 103         xdrs = &clp->xdr_stream;
 104         client = &clp->client_object;
-- snip --


Version-Release number of selected component (if applicable):
libtirpc-1.1.3.el9

Comment 1 Steve Dickson 2022-10-28 18:31:27 UTC
commit 4a2d85c64110ee9e21a8c4f9dafd6b0ae621506d
Author: Zhi Li <yieli>
Date:   Fri Oct 28 14:19:04 2022 -0400

    clnt_raw.c: fix a possible null pointer dereference

Comment 6 errata-xmlrpc 2023-05-09 08:19:31 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (libtirpc bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:2506


Note You need to log in before you can comment on or make changes to this bug.