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]
Message-ID: <20180301112237.pjn5rmvkkpxcntl7@lakrids.cambridge.arm.com>
Date:   Thu, 1 Mar 2018 11:22:37 +0000
From:   Mark Rutland <mark.rutland@....com>
To:     Michal Hocko <mhocko@...nel.org>
Cc:     linux-kernel@...r.kernel.org,
        Andrew Morton <akpm@...ux-foundation.org>,
        Ingo Molnar <mingo@...nel.org>,
        Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Rik van Riel <riel@...hat.com>,
        Will Deacon <will.deacon@....com>
Subject: Re: [PATCH] Detect early free of a live mm

On Thu, Mar 01, 2018 at 10:35:22AM +0100, Michal Hocko wrote:
> On Wed 28-02-18 12:18:10, Mark Rutland wrote:
> > Ugh, I messed up Peter's email when sending this out. please
> > s/infraded/infradead/ if replying to the first mail.
> > 
> > Sorry about that.
> > 
> > Mark.
> > 
> > On Wed, Feb 28, 2018 at 12:14:58PM +0000, Mark Rutland wrote:
> > > KASAN splats indicate that in some cases we free a live mm, then
> > > continue to access it, with potentially disastrous results. This is
> > > likely due to a mismatched mmdrop() somewhere in the kernel, but so far
> > > the culprit remains elusive.
> > > 
> > > Let's have __mmdrop() verify that the mm isn't live for the current
> > > task, similar to the existing check for init_mm. This way, we can catch
> > > this class of issue earlier, and without requiring KASAN.
> 
> Wouldn't it be better to check the mm_users count instead?
> {VM_}BUG_ON(atomic_read(&mm->mm_users));

Perhaps, but that won't catch a mismatched mmput(), which could
decrement mm_users (and mm_count) to zero early, before current->mm is
cleared in exit_mm().

Locally, I'm testing with:

  BUG_ON(mm == current->mm);
  BUG_ON(mm == current->active_mm);
  BUG_ON(refcount_read(&mm->mm_users) != 0);
  BUG_ON(refcount_read(&mm->mm_count) != 0);

... so as to also catch an early free from another thread.

> Relying on current->mm resetting works currently but this is quite a
> subtle dependency.

Do you mean because it only catches an early free in a thread using that
mm, or is there another subtlety you had in mind?

Thanks,
Mark.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ