lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 13 Feb 2020 15:08:59 +0100
From:   Jann Horn <jannh@...gle.com>
To:     Minchan Kim <minchan@...nel.org>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        LKML <linux-kernel@...r.kernel.org>,
        linux-mm <linux-mm@...ck.org>,
        Linux API <linux-api@...r.kernel.org>,
        Oleksandr Natalenko <oleksandr@...hat.com>,
        Suren Baghdasaryan <surenb@...gle.com>,
        Tim Murray <timmurray@...gle.com>,
        Daniel Colascione <dancol@...gle.com>,
        Sandeep Patil <sspatil@...gle.com>,
        Sonny Rao <sonnyrao@...gle.com>,
        Brian Geffon <bgeffon@...gle.com>,
        Michal Hocko <mhocko@...e.com>,
        Johannes Weiner <hannes@...xchg.org>,
        Shakeel Butt <shakeelb@...gle.com>,
        John Dias <joaodias@...gle.com>,
        Joel Fernandes <joel@...lfernandes.org>,
        Alexander Duyck <alexander.h.duyck@...ux.intel.com>
Subject: Re: [PATCH v4 2/8] mm: introduce external memory hinting API

On Thu, Feb 13, 2020 at 12:40 AM Minchan Kim <minchan@...nel.org> wrote:
> To solve the issue, this patch introduces a new syscall process_madvise(2).
> It uses pidfd of an external process to give the hint.
[...]
> +       mm = mm_access(task, PTRACE_MODE_ATTACH_FSCREDS);
> +       if (IS_ERR_OR_NULL(mm)) {
> +               ret = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
> +               goto release_task;
> +       }
> +
> +       ret = do_madvise(task, start, len_in, behavior);

When you're accessing another task, you should ensure that the other
task doesn't gain new privileges by executing a setuid binary in the
middle of being accessed. mm_access() does that for you; it holds the
->cred_guard_mutex while it is looking up the task's ->mm and doing
the security check. mm_access() then returns you an mm pointer that
you're allowed to access without worrying about such things; an
mm_struct never gains privileges, since a setuid execution creates a
fresh mm_struct. However, the task may still execute setuid binaries
and such things.

This means that after you've looked up the mm with mm_access(), you
have to actually *use* that pointer. You're not allowed to simply read
task->mm yourself.

Therefore, I think you should:

 - change patch 1/8 ("mm: pass task to do_madvise") to also pass an
mm_struct* to do_madvise (but keep the task_struct* for patch 4/8)
 - in this patch, pass the mm_struct* from mm_access() into do_madvise()
 - drop patch 3/8 ("mm: validate mm in do_madvise"); it just papers
over a symptom without addressing the underlying problem

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ