Make all accesses to capabilites exclusive
This commit makes sure that all accesses to the capabilities array and other
metadata are protected by a mutex. This is necessary for future resizing of the
capabilities array.
Group task's capabilities by type so that it is possible to visit all
capabilities of the given type effectively.
Provide cap_publish() and cap_unpublish() to automate steps that make the
capability visible/invisible to userspace and insert/remove the capability from
the respective type list.