How to get all users with a specific permission
I had to get the roles that had a given permission to get users with a permission, example:
$roles = user_role_names(FALSE, 'example_permission');
$rids = array_keys($roles);

$uids = Drupal::service('entity_type.manager')-&gt;getStorage('user')-&gt;getQuery()
  -&gt;condition('roles', $rids, 'IN')
  -&gt;execute();

Apparently thats what Drupal core does in the permission filter for views, see:
\Drupal\user\Plugin\views\filter\Permissions
Hope that helps some!