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: <c77d1201-41be-4c55-af7f-07432b139b88@lucifer.local>
Date: Fri, 20 Jun 2025 06:21:26 +0100
From: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
To: Zi Yan <ziy@...dia.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
        David Hildenbrand <david@...hat.com>,
        Baolin Wang <baolin.wang@...ux.alibaba.com>,
        "Liam R . Howlett" <Liam.Howlett@...cle.com>,
        Nico Pache <npache@...hat.com>, Ryan Roberts <ryan.roberts@....com>,
        Dev Jain <dev.jain@....com>, Barry Song <baohua@...nel.org>,
        Vlastimil Babka <vbabka@...e.cz>, Jann Horn <jannh@...gle.com>,
        linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        Lance Yang <ioworker0@...il.com>, SeongJae Park <sj@...nel.org>,
        Suren Baghdasaryan <surenb@...gle.com>,
        "Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>
Subject: Re: [PATCH 3/5] mm/madvise: thread VMA range state through
 madvise_behavior

On Thu, Jun 19, 2025 at 10:13:19PM -0400, Zi Yan wrote:
> On 19 Jun 2025, at 21:54, Zi Yan wrote:
> >> @@ -1846,22 +1854,23 @@ static int madvise_do_behavior(unsigned long start, size_t len_in,
> >>  		struct madvise_behavior *madv_behavior)
> >>  {
> >>  	struct blk_plug plug;
> >> -	unsigned long end;
> >>  	int error;
> >> +	struct madvise_behavior_range *range = &madv_behavior->range;
> >>
> >>  	if (is_memory_failure(madv_behavior)) {
> >> -		end = start + len_in;
> >> -		return madvise_inject_error(start, end, madv_behavior);
> >> +		range->start = start;
> >> +		range->end = start + len_in;
> >> +		return madvise_inject_error(madv_behavior);
> >>  	}
> >>
> >> -	start = get_untagged_addr(madv_behavior->mm, start);
> >> -	end = start + PAGE_ALIGN(len_in);
> >> +	range->start = get_untagged_addr(madv_behavior->mm, start);
> >> +	range->end = range->start + PAGE_ALIGN(len_in);
> >>
> >>  	blk_start_plug(&plug);
> >>  	if (is_madvise_populate(madv_behavior))
> >> -		error = madvise_populate(start, end, madv_behavior);
> >> +		error = madvise_populate(madv_behavior);
> >>  	else
> >> -		error = madvise_walk_vmas(start, end, madv_behavior);
> >> +		error = madvise_walk_vmas(madv_behavior);
> >>  	blk_finish_plug(&plug);
> >>  	return error;
> >>  }
> >
> > We almost can pass just struct madvise_behavior to madvise_do_behavior().
> > I wonder why memory_failure behaves differently.
>
> Based on git history, it seems that no one paid attention to
> madvise_inject_error() and the [start, start + len_in] has never been
> changed since it was added back from 2009.
>
> OK, it seems that Kirill (cc'd) moved start = untagged_addr(start); from
> before madvise_inject_error() to after it at commit 428e106ae1ad
> ("mm: Introduce untagged_addr_remote()"). It changed code behavior.
>
> So memory_failure should get the same range as others, meaning
> madvise_do_behavior() can just take struct madvise_behavior
> and the range can be set at the call sites.

Well it's also page aligned in other cases right?

Anyway overall I'm not touching that in this series, sorry. This is a clean
up, and this stuff is a functional change that needs to be carefully
thought out.

So this is legitimately I think one for a follow-up. But this series makes
it easier to fix up later :)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ