Re: [PATCH v2 2/3] mm: add LSM hook for writes to readonly memory

Ingo Molnar
2016-09-29T06:25:20Z

* Jann Horn <jann@thejh.net> wrote:

> +/*
> + * subject_cred must be the subjective credentials using which access is
> + * requested.
> + * object_cred must be the objective credentials of the target task at the time
> + * the mm_struct was acquired.
> + * Both of these may be NULL if FOLL_FORCE is unset or FOLL_WRITE is unset.

Hm, I have trouble parsing the first sentence.

> - return __get_user_pages_locked(current, current->mm, start, nr_pages,
> - write, force, pages, vmas, NULL, false,
> - FOLL_TOUCH);
> + return __get_user_pages_locked(current, current->mm, current_cred(),
> + current_real_cred(), start,
> + nr_pages, write, force, pages, vmas,
> + NULL, false, FOLL_TOUCH);

So the parameter passing was disgustig before, and now it became super disgusing!

Would it improve the code if we added a friendly helper structure (or two if
that's better) to clean up all the interactions within these various functions?

Thanks,

Ingo