History

signals/sigaltstack: Report current flag bits in sigaltstack()

sigaltstack()'s reported previous state uses a somewhat odd convention, but the concept of flag bits is new, and we can do the flag bits sensibly. Specifically, let's just report them directly. This will allow saving and restoring the sigaltstack state using sigaltstack() to work correctly.

Andy Lutomirski committed 10 years ago

Commit 0318bc81 parent 158b67b2 files · +18 −4Browse files

Unified · Split

2 files
  1. kernel/signal.c +2 −1
  2. tools/testing/selftests/sigaltstack/sas.c +16 −3
kernel/signal.c+2−1
@@ -3099,7 +3099,8 @@ do_sigaltstack (const stack_t __user *uss, stack_t __user *uoss, unsigned long s · 3098 unmodified lines
30993099
31003100 oss.ss_sp = (void __user *) current->sas_ss_sp;
31013101 oss.ss_size = current->sas_ss_size;
3102− oss.ss_flags = sas_ss_flags(sp);
3102+ oss.ss_flags = sas_ss_flags(sp) |
3103+ (current->sas_ss_flags & SS_FLAG_BITS);
31033104
31043105 if (uss) {
31053106 void __user *ss_sp;
tools/testing/selftests/sigaltstack/sas.c+16−3
@@ -113,6 +113,19 @@ int main(void) · 112 unmodified lines
113113 perror("mmap()");
114114 return EXIT_FAILURE;
115115 }
116+
117+ err = sigaltstack(NULL, &stk);
118+ if (err) {
119+ perror("[FAIL]\tsigaltstack()");
120+ exit(EXIT_FAILURE);
121+ }
122+ if (stk.ss_flags == SS_DISABLE) {
123+ printf("[OK]\tInitial sigaltstack state was SS_DISABLE\n");
124+ } else {
125+ printf("[FAIL]\tInitial sigaltstack state was %i; should have been SS_DISABLE\n", stk.ss_flags);
126+ return EXIT_FAILURE;
127+ }
128+
116129 stk.ss_sp = sstack;
117130 stk.ss_size = SIGSTKSZ;
118131 stk.ss_flags = SS_ONSTACK | SS_AUTODISARM;
@@ -151,12 +164,12 @@ int main(void) · 32 unmodified lines
151164 perror("[FAIL]\tsigaltstack()");
152165 exit(EXIT_FAILURE);
153166 }
154− if (stk.ss_flags != 0) {
155− printf("[FAIL]\tss_flags=%i, should be 0\n",
167+ if (stk.ss_flags != SS_AUTODISARM) {
168+ printf("[FAIL]\tss_flags=%i, should be SS_AUTODISARM\n",
156169 stk.ss_flags);
157170 exit(EXIT_FAILURE);
158171 }
159− printf("[OK]\tsigaltstack is enabled after signal\n");
172+ printf("[OK]\tsigaltstack is still SS_AUTODISARM after signal\n");
160173
161174 printf("[OK]\tTest passed\n");
162175 return 0;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t