@@ -257,12 +257,36 @@ static void ClearShadowMemoryForContextStack(uptr stack, uptr ssize) {
257
257
PoisonShadow (bottom, ssize, 0 );
258
258
}
259
259
260
- INTERCEPTOR (int , getcontext, struct ucontext_t *ucp) {
261
- // API does not requires to have ucp clean, and sets only part of fields. We
262
- // use ucp->uc_stack to unpoison new stack. We prefer to have zeroes then
263
- // uninitialized bytes.
264
- ResetContextStack (ucp);
265
- return REAL (getcontext)(ucp);
260
+ INTERCEPTOR (void , makecontext, struct ucontext_t *ucp, void (*func)(), int argc,
261
+ ...) {
262
+ va_list ap;
263
+ uptr args[64 ];
264
+ // We don't know a better way to forward ... into REAL function. We can
265
+ // increase args size if neccecary.
266
+ CHECK_LE (argc, ARRAY_SIZE (args));
267
+ internal_memset (args, 0 , sizeof (args));
268
+ va_start (ap, argc);
269
+ for (int i = 0 ; i < argc; ++i) args[i] = va_arg (ap, uptr);
270
+ va_end (ap);
271
+
272
+ # define ENUMERATE_ARRAY_4 (start ) \
273
+ args[start], args[start + 1 ], args[start + 2 ], args[start + 3 ]
274
+ # define ENUMERATE_ARRAY_16 (start ) \
275
+ ENUMERATE_ARRAY_4 (start), ENUMERATE_ARRAY_4 (start + 4 ), \
276
+ ENUMERATE_ARRAY_4 (start + 8 ), ENUMERATE_ARRAY_4 (start + 12 )
277
+ # define ENUMERATE_ARRAY_64 () \
278
+ ENUMERATE_ARRAY_16 (0 ), ENUMERATE_ARRAY_16 (16 ), ENUMERATE_ARRAY_16 (32 ), \
279
+ ENUMERATE_ARRAY_16 (48 )
280
+
281
+ REAL (makecontext)
282
+ ((struct ucontext_t *)ucp, func, argc, ENUMERATE_ARRAY_64 ());
283
+
284
+ # undef ENUMERATE_ARRAY_4
285
+ # undef ENUMERATE_ARRAY_16
286
+ # undef ENUMERATE_ARRAY_64
287
+
288
+ // Sign the stack so we can identify it for unpoisoning.
289
+ SignContextStack (ucp);
266
290
}
267
291
268
292
INTERCEPTOR (int , swapcontext, struct ucontext_t *oucp,
@@ -279,9 +303,6 @@ INTERCEPTOR(int, swapcontext, struct ucontext_t *oucp,
279
303
ReadContextStack (ucp, &stack, &ssize);
280
304
ClearShadowMemoryForContextStack (stack, ssize);
281
305
282
- // See getcontext interceptor.
283
- ResetContextStack (oucp);
284
-
285
306
# if __has_attribute(__indirect_return__) && \
286
307
(defined (__x86_64__) || defined (__i386__))
287
308
int (*real_swapcontext)(struct ucontext_t *, struct ucontext_t *)
@@ -658,11 +679,11 @@ void InitializeAsanInterceptors() {
658
679
// Intecept jump-related functions.
659
680
ASAN_INTERCEPT_FUNC (longjmp );
660
681
661
- #if ASAN_INTERCEPT_SWAPCONTEXT
662
- ASAN_INTERCEPT_FUNC (getcontext);
682
+ # if ASAN_INTERCEPT_SWAPCONTEXT
663
683
ASAN_INTERCEPT_FUNC (swapcontext);
664
- #endif
665
- #if ASAN_INTERCEPT__LONGJMP
684
+ ASAN_INTERCEPT_FUNC (makecontext);
685
+ # endif
686
+ # if ASAN_INTERCEPT__LONGJMP
666
687
ASAN_INTERCEPT_FUNC (_longjmp);
667
688
#endif
668
689
#if ASAN_INTERCEPT___LONGJMP_CHK
0 commit comments