On Thu, May 28, 2020 at 04:08:56AM -0700, Sargun Dhillon wrote:
> This adds a helper which can iterate through a seccomp_filter to
> find a notification matching an ID. It removes several replicated
> chunks of code.

Nice, yes. I was noticing this redundancy too while I was looking at
notify locking earlier today. One note below...

> +/* must be called with notif_lock held */
> +static inline struct seccomp_knotif *
> +find_notification(struct seccomp_filter *filter, u64 id)
> +{
> +     struct seccomp_knotif *cur;

While the comment is good, let's actually enforce this with:

if (WARN_ON(!mutex_is_locked(&filter->notif_lock)))
        return NULL;

> +
> +     list_for_each_entry(cur, &filter->notif->notifications, list) {
> +             if (cur->id == id)
> +                     return cur;
> +     }
> +
> +     return NULL;
> +}

Everything else looks good!

-- 
Kees Cook

Reply via email to