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

 
 

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

Submitted by:  Kalle Olavi Niemitalo <kon>
Submitted on:  Sun 28 Aug 2016 02:07:56 PM UTC  
 
Category: Hurd ServersSeverity: 3 - Normal
Priority: 5 - NormalItem Group: None
Status: FixedPrivacy: Public
Assigned to: NoneOriginator Name: 
Open/Closed: ClosedReproducibility: Intermittent
Size (loc): NonePlanned Release: None
Effort: 0.00
Wiki-like text discussion box: 

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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>
Project 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:

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 File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 05 Oct 2016 04:26:46 PM UTCteythoonOpen/ClosedOpen=>Closed
    Wed 05 Oct 2016 04:26:17 PM UTCteythoonStatusNone=>Fixed

    Back to the top


    Powered by Savane 3.1-cleanup1