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:	Tue, 26 Aug 2014 17:04:19 +0300
From:	"Kirill A. Shutemov" <kirill@...temov.name>
To:	Cyrill Gorcunov <gorcunov@...il.com>
Cc:	Hugh Dickins <hughd@...gle.com>, Peter Feiner <pfeiner@...gle.com>,
	linux-mm@...ck.org, linux-kernel@...r.kernel.org,
	Pavel Emelyanov <xemul@...allels.com>,
	Jamie Liu <jamieliu@...gle.com>,
	Naoya Horiguchi <n-horiguchi@...jp.nec.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Magnus Damm <magnus.damm@...il.com>
Subject: Re: [PATCH v5] mm: softdirty: enable write notifications on VMAs
 after VM_SOFTDIRTY cleared

On Tue, Aug 26, 2014 at 10:49:52AM +0400, Cyrill Gorcunov wrote:
> On Mon, Aug 25, 2014 at 09:45:34PM -0700, Hugh Dickins wrote:
> > > +static int clear_refs(struct mm_struct *mm, enum clear_refs_types type,
> > > +                      int write)
> > > +{
> ...
> > > +
> > > +	if (write)
> > > +		down_write(&mm->mmap_sem);
> > > +	else
> > > +		down_read(&mm->mmap_sem);
> > > +
> > > +	if (type == CLEAR_REFS_SOFT_DIRTY)
> > > +		mmu_notifier_invalidate_range_start(mm, 0, -1);
> > > +
> > > +	for (vma = mm->mmap; vma; vma = vma->vm_next) {
> > > +		cp.vma = vma;
> > > +		if (is_vm_hugetlb_page(vma))
> > > +			continue;
> ...
> > > +		if (type == CLEAR_REFS_ANON && vma->vm_file)
> > > +			continue;
> > > +		if (type == CLEAR_REFS_MAPPED && !vma->vm_file)
> > > +			continue;
> > > +		if (type == CLEAR_REFS_SOFT_DIRTY &&
> > > +		    (vma->vm_flags & VM_SOFTDIRTY)) {
> > > +			if (!write) {
> > > +				r = -EAGAIN;
> > > +				break;
> > 
> > Hmm.  For a long time I thought you were fixing another important bug
> > with down_write, since we "always" use down_write to modify vm_flags.
> > 
> > But now I'm realizing that if this is the _only_ place which modifies
> > vm_flags with down_read, then it's "probably" safe.  I've a vague
> > feeling that this was discussed before - is that so, Cyrill?
> 
> Well, as far as I remember we were not talking before about vm_flags
> and read-lock in this function, maybe it was on some unrelated lkml thread
> without me CC'ed? Until I miss something obvious using read-lock here
> for vm_flags modification should be safe, since the only thing which is
> important (in context of vma-softdirty) is the vma's presence. Hugh,
> mind to refresh my memory, how long ago the discussion took place?

It seems safe in vma-softdirty context. But if somebody else will decide that
it's fine to modify vm_flags without down_write (in their context), we
will get trouble. Sasha will come with weird bug report one day ;)

At least vm_flags must be updated atomically to avoid race in middle of
load-modify-store.

-- 
 Kirill A. Shutemov
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists