Project

General

Profile

Bug #13101

pargs dumps core when it can't read argv

Added by Robert Mustacchi 6 months ago. Updated 6 months ago.

Status:
Closed
Priority:
Normal
Category:
cmd - userland programs
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

While looking at a core dump that had been truncated, pargs dumped core:

rm@beowulf:/ws/rm/igb-sensor$ pargs /ws/rm/igb-sensor/usr/src/lib/iconv_modules/euro/amd64/core
core '/ws/rm/igb-sensor/usr/src/lib/iconv_modules/euro/amd64/core' of 798441:   /usr/bin/rm -f /ws/rm/igb-sensor/proto/root_i386/usr/lib/iconv/amd64/646%8859-1
pargs: failed to read argv[]
Segmentation Fault (core dumped)
> $C
fffffc7fffdf0550 free_data+0x24()
fffffc7fffdf0c30 main+0x5ff()
fffffc7fffdf0c60 _start_crt+0x83()
fffffc7fffdf0c70 _start+0x18()

When I modified pags to have CTF, this became rather obvious:

> $C
fffffc7fffdf0550 free_data+0x24(fffffc7fffdf05d0)
fffffc7fffdf0c30 main+0x5ff(2, fffffc7fffdf0c88)
fffffc7fffdf0c60 _start_crt+0x83()
fffffc7fffdf0c70 _start+0x18()
> fffffc7fffdf05d0::print pargs_data_t
{
    pd_proc = 0x8a0010
    pd_psinfo = 0xfffffc7fffdf0650
    pd_locale = 0x8a2770 "C" 
    pd_conv_flags = 0x2
    pd_iconv = 0
    pd_argc = 0x46
    pd_argv = 0
    pd_argv_strs = 0
    pd_envc = 0
    pd_env_space = 0x1
    pd_envp = 0x8a2750
    pd_envp_strs = 0x8a2690
    pd_auxc = 0
    pd_auxv = 0
    pd_auxv_strs = 0
    pd_execname = 0
}

Effectively we freed the argv data, but left argc intact. If you look at free_data, it's pretty clear that if pd_argc is valid, we expect pd_argv to be valid. When get_args fails to read argv, it frees this. This means we need to reset argc at the same time.

#1

Updated by Electric Monk 6 months ago

  • Gerrit CR set to 882
#2

Updated by Robert Mustacchi 6 months ago

To test this I verified that pargs no longer dumped core on the affected core dump and that it worked correctly on several other core files.

#3

Updated by Electric Monk 6 months ago

  • Status changed from New to Closed
  • % Done changed from 90 to 100

git commit fbfe962ed9b45c98bebaea25573c8b8f1630d482

commit  fbfe962ed9b45c98bebaea25573c8b8f1630d482
Author: Robert Mustacchi <rm@fingolfin.org>
Date:   2020-09-03T22:08:35.000Z

    13101 pargs dumps core when it can't read argv
    13102 ptools could be built with ctf
    Reviewed by: C Fraire <cfraire@me.com>
    Reviewed by: Andy Fiddaman <andy@omniosce.org>
    Reviewed by: Toomas Soome <tsoome@me.com>
    Approved by: Dan McDonald <danmcd@joyent.com>

Also available in: Atom PDF