bugThe GNU Hurd - Bugs: bug #48930, crash server crashes after...

 
 

bug #48930: crash server crashes after --core-file-name is changed with fsysopts

Submitter:  Kalle Olavi Niemitalo <kon>
Submitted:  Sun 28 Aug 2016 02:07:56 PM UTC
   
 
Category:  Hurd Servers Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Fixed Privacy:  Public
Assigned to:  None Originator Name: 
Open/Closed:  Closed Reproducibility:  Intermittent
Size (loc):  None Planned Release:  None
Effort:  0.00
Wiki-like text discussion box: 


* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 06 Oct 2016 12:39:21 AM UTC, comment #4: 

The fix looks OK, except I don't like the assumption that argp_error will preserve errno.  It will hold in practice though, unless someone specifies ARGP_NO_EXIT without ARGP_NO_ERRS.  Currently only console-client/ does that.

Kalle Olavi Niemitalo <kon>
Wed 05 Oct 2016 04:26:17 PM UTC, comment #3: 

Fixed as of 74998f9d.

Justus Winter <teythoon>
Group Member
Wed 07 Sep 2016 08:41:29 PM UTC, comment #2: 

trans/hello-mt.c contains a nice example of how to use pthread_rwlock_t for this kind of option.

Kalle Olavi Niemitalo <kon>
Sun 28 Aug 2016 02:35:22 PM UTC, comment #1: 

I tried implementing (b) using pthread_rwlock_t.  It took about 15 lines of code.  However, I noticed two more problems along the way:

1. --core-file-name can be set via fsysopts but it cannot be unset via fsysopts.  Fixing this would require designing a command-line option for that purpose, or perhaps --core-file-name= with an empty template should unset it.

2. If --core-file-name is set via fsysopts, and its argument is not a valid template, then the crash server exits.  It should instead return an error to the fsys_set_options RPC, like --action=GARBAGE does.  This is simply a bug and can be fixed without further design.

Kalle Olavi Niemitalo <kon>
Sun 28 Aug 2016 02:07:56 PM UTC, original submission:  


% mkdir ~/servers
% settrans --create --active ~/servers/crash /hurd/crash
% fsysopts ~/servers/crash
/hurd/crash --action=suspend --orphan-action=core-file
% fsysopts ~/servers/crash --core-file-name=foo
% fsysopts ~/servers/crash
/hurd/crash --action=suspend --orphan-action=core-file --core-file-name=foo
% fsysopts ~/servers/crash --some-unsupported-long-option
fsysopts: /home/kalle/servers/crash: --some-unsupported-long-option: Invalid argument
% fsysopts ~/servers/crash
fsysopts: /home/kalle/servers/crash: (ipc/mig) server died


Apparently, 'char *arg' passed to trans/crash.c (parse_opt) points into the 'options: data_t' buffer of the received fsys_set_options request.  parse_opt assigns this pointer to corefile_template, but the buffer can be reused or freed after parse_opt returns.

Possible fixes:

(a) Prevent changing --core-file-name via fsysopts.  This would be easiest to implement by setting a flag after the argp_parse call in the main function and then checking that flag in parse_opt.  If --core-file-name is used after the flag has been set, then return an error.  Although perhaps it should allow using --core-file-name with an argument that matches the current corefile_template, so that any argument list retrieved from fsys_get_options can be fed back to fsys_set_options without causing an error.  In that case, it should not change corefile_template.

(b) Always use strdup when setting corefile_template, and free the previous string.  Add locking so that it doesn't crash if different threads receive fsys_set_options and crash_dump_task requests at the same time.  It could be an RW lock, although high contention seems unlikely.

Kalle Olavi Niemitalo <kon>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by teythoon (Posted a comment)
  • -email is unavailable- added by kon (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-10-05 teythoon Open/ClosedOpen Closed
    2016-10-05 teythoon StatusNone Fixed

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code