libmpathutil: don't call pthread_testcancel as part of udev commands
Benjamin Marzinski
maintainerPATCH 1/1 libmpathutil: don't call pthread_testcancel as part of udev commands
Commit 47a654f0 ("libmpathutil: udev: prevent interruption by thread cancellation") added pthread_testcancel() calls to the udev command wrappers. This makes these commands cancellation points (but only after any waiting has already happened without cancellation), while the rest of the code assumes that they are not.
This can cause problems like in uev_update_path() when multipathd first calls udev_device_unref(pp->udev) and afterwards resets pp->udev. If the thread is cancelled after unref'ing device in the udev_device_unref() call, pp->udev will still point to the now-freed udev_device.
--- libmpathutil/mt-libudev.c | 4 ---- 1 file changed, 4 deletions(-)
libmpathutil/mt-libudev.c +0 -4
@@ -14,7 +14,6 @@ static pthread_mutex_t libudev_mutex = PTHREAD_MUTEX_INITIALIZER; __r =func (); \pthread_mutex_unlock (&libudev_mutex); \pthread_setcancelstate (__oldstate,NULL ); \ -pthread_testcancel (); \return __r; \ }
@@ -27,7 +26,6 @@ static pthread_mutex_t libudev_mutex = PTHREAD_MUTEX_INITIALIZER; __r =func (__arg1); \pthread_mutex_unlock (&libudev_mutex); \pthread_setcancelstate (__oldstate,NULL ); \ -pthread_testcancel (); \return __r; \ }
@@ -40,7 +38,6 @@ static pthread_mutex_t libudev_mutex = PTHREAD_MUTEX_INITIALIZER; __r =func (__arg1, __arg2); \pthread_mutex_unlock (&libudev_mutex); \pthread_setcancelstate (__oldstate,NULL ); \ -pthread_testcancel (); \return __r; \ }
@@ -53,7 +50,6 @@ static pthread_mutex_t libudev_mutex = PTHREAD_MUTEX_INITIALIZER; __r =func (__arg1, __arg2, __arg3); \pthread_mutex_unlock (&libudev_mutex); \pthread_setcancelstate (__oldstate,NULL ); \ -pthread_testcancel (); \return __r; \ }
Signature · 1 line
2.46.1
Quoted 15 lines · Benjamin Marzinski
Commit
47a654f0("libmpathutil: udev: prevent interruption by thread cancellation") addedpthread_testcancel()calls to the udev command wrappers. This makes these commands cancellation points (but only after
any waiting has already happened without cancellation), while the rest
of the code assumes that they are not.This can cause problems like in
uev_update_path()when multipathd first
callsudev_device_unref(pp->udev)and afterwards resetspp->udev. If the
thread is cancelled after unref'ing device in theudev_device_unref()call,pp->udevwill still point to the now-freedudev_device.
Quoted 3 lines
Fixes 47a654f0 ("libmpathutil: udev: prevent interruption by threadcancellation")
Signed-off-by Benjamin Marzinski <[email protected]>
Quoted 64 lines
---
libmpathutil/mt-libudev.c | 4 ----1 file changed, 4 deletions(-)libmpathutil/mt-libudev.c +0
-0@@ -14,7 +14,6 @@ static pthread_mutex_t libudev_mutex =PTHREAD_MUTEX_INITIALIZER ;
__r=func(); \pthread_mutex_unlock(&libudev_mutex); \ pthread_setcancelstate(__oldstate, NULL); \ - pthread_testcancel(); \return
__r; \
}libmpathutil/mt-libudev.c +0
-0@@ -27,7 +26,6 @@ static pthread_mutex_t libudev_mutex =PTHREAD_MUTEX_INITIALIZER ;
__r=func(__arg1); \pthread_mutex_unlock(&libudev_mutex); \ pthread_setcancelstate(__oldstate, NULL); \ - pthread_testcancel(); \return
__r; \
}libmpathutil/mt-libudev.c +0
-0@@ -40,7 +38,6 @@ static pthread_mutex_t libudev_mutex =PTHREAD_MUTEX_INITIALIZER ; __r = func(__arg1, __arg2); \ pthread_mutex_unlock(&libudev_mutex); \ pthread_setcancelstate(__oldstate,NULL); \
-pthread_testcancel(); \return
__r; \
}libmpathutil/mt-libudev.c +0
-0@@ -53,7 +50,6 @@ static pthread_mutex_t libudev_mutex =PTHREAD_MUTEX_INITIALIZER ; __r = func(__arg1, __arg2, __arg3); \ pthread_mutex_unlock(&libudev_mutex); \ pthread_setcancelstate(__oldstate,NULL); \
-pthread_testcancel(); \return
__r; \
}
Signature · 4 lines
Dr. Martin Wilck <[email protected]> SUSE Software Solutions Germany GmbH, Frankenstr. 146, 90461 Nürnberg, Germany Geschäftsführer: Jochen Jaser, Andrew McDonald (HRB 36809,AG Nürnberg)