Anonymous | Login | 2023-06-11 01:19 UTC |
Main | My View | View Issues | Change Log | Docs |
Viewing Issue Simple Details [ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||||||
ID | Category | Severity | Type | Date Submitted | Last Update | |||||||
0000728 | [1003.1(2013)/Issue7+TC1] System Interfaces | Editorial | Clarification Requested | 2013-08-05 15:16 | 2023-01-26 10:46 | |||||||
Reporter | dalias | View Status | public | |||||||||
Assigned To | ||||||||||||
Priority | normal | Resolution | Open | |||||||||
Status | New | |||||||||||
Name | Rich Felker | |||||||||||
Organization | musl libc | |||||||||||
User Reference | ||||||||||||
Section | XSH 2.4.3 Signal Actions | |||||||||||
Page Number | unknown | |||||||||||
Line Number | unknown | |||||||||||
Interp Status | --- | |||||||||||
Final Accepted Text | ||||||||||||
Summary | 0000728: Restrictions on signal handlers are both excessive and insufficient | |||||||||||
Description |
Per XSH 2.4.3: "the behavior is undefined if the signal handler refers to any object other than errno with static storage duration other than by assigning a value to an object declared as volatile sig_atomic_t, or if the signal handler calls any function defined in this standard other than one of the functions listed in the following table." The intent here is that signal handlers cannot access objects which might be in a partially-modified state when the (asynchronous) signal handler is invoked. However, this is not what it says. Consider for example a program which allocates an object via malloc (or with automatic storage in main()) and stores the address in /tmp/foo. Per the language of the standard, the signal handler can legitimately open /tmp/foo (open is AS-safe), read that address (read is AS-safe), and dereference the pointer, even though the object may be in a partially-modified state. As a second example, one can arrange for the address of such an object to be delivered to the signal handler via the sigval argument to realtime signals, timers, etc. and in fact using these features generally REQUIRES a pointer to be delivered to the signal handler. Moreover, plenty of legitimate accesses to objects with static storage duration is wrongly forbidden: - Access to const-qualified objects. - Access to string literals (note in the above example, a string literal could not be passed to open; instead, the array "/dev/tmp" must be automatic). - Access to a modifiable object of static storage duration whose last modification was sequenced before the signal handler could have been invoked via sigprocmask(), pthread_sigmask(), sigaction(), etc. There is no reason to forbid such accesses, and to my knowledge there is no historical implementation for which they would not work. This issue report is partly inspired by: http://www.tedunangst.com/flak/post/signal-safe-strcpy [^] |
|||||||||||
Desired Action |
Ideally, replace the restriction on access to static objects in XSH 2.4.3 with a proper memory model for access to objects (static or otherwise) from signal handlers based on sequencing by signal masking or other means. Alternatively, require that no object except objects with automatic storage duration whose lifetimes began within the signal handling context be accessed from within the signal handling context. In my opinion, this would be excessively restrictive, but at least it would close the loophole/inconsistency in the existing language where access to static objects is forbidden but access to dynamic or automatic objects that exist outside the signal handler is permitted. |
|||||||||||
Tags | No tags attached. | |||||||||||
Attached Files | ||||||||||||
|
![]() |
||||||
|
Mantis 1.1.6[^] Copyright © 2000 - 2008 Mantis Group |