Race condition in glibc/NPTL/Linux robust mutexes?

前端 未结 2 870
刺人心
刺人心 2021-02-05 11:22

In a comment on the question Automatically release mutex on crashes in Unix back in 2010, jilles claimed:

glibc\'s robust mutexes are so fast because glib

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-05 11:44

    The description of the race by FreeBSD pthread developer David Xu: http://lists.freebsd.org/pipermail/svn-src-user/2010-November/003668.html

    I don't think the munmap/mmap cycle is strictly required for the race. The piece of shared memory might be put to a different use as well. This is uncommon but valid.

    As also mentioned in that message, more "fun" occurs if threads with different privilege access a common robust mutex. Because the node for the list of owned robust mutexes is in the mutex itself, a thread with low privilege may corrupt a high privilege thread's list. This could be exploited easily to make the high privilege thread crash and in rare cases this might allow the high privilege thread's memory to be corrupted. Apparently Linux's robust mutexes are only designed for use by threads with the same privileges. This could have been avoided easily by making the robust list an array fully in the thread's memory instead of a linked list.

提交回复
热议问题