linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Stoakes <lstoakes@gmail.com>
To: kernel test robot <oliver.sang@intel.com>
Cc: "Liam R. Howlett" <Liam.Howlett@oracle.com>,
	oe-lkp@lists.linux.dev, lkp@intel.com,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org
Subject: Re: [linux-stable-rc:linux-6.2.y] [mm/mempolicy] 75cd8305a0: WARNING:at_mm/mmap.c:#vma_merge
Date: Sun, 30 Apr 2023 14:11:19 +0100	[thread overview]
Message-ID: <cf9f57eb-a657-4545-a430-1b0efe9a67de@lucifer.local> (raw)
In-Reply-To: <202304292203.44ddeff6-oliver.sang@intel.com>

On Sun, Apr 30, 2023 at 10:57:44AM +0800, kernel test robot wrote:
>
>
> Hello,
>
> kernel test robot noticed "WARNING:at_mm/mmap.c:#vma_merge" on:
>
> commit: 75cd8305a0bd360c3fedaefce1801c13b58e2311 ("mm/mempolicy: fix use-after-free of VMA iterator")
> https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable-rc.git linux-6.2.y
>
> in testcase: trinity
> version: trinity-static-x86_64-x86_64-f93256fb_2019-08-28
> with following parameters:
>
> 	runtime: 300s
> 	group: group-03
>
> test-description: Trinity is a linux system call fuzz tester.
> test-url: http://codemonkey.org.uk/projects/trinity/
>
>
> compiler: gcc-11
> test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 16G
>
> (please refer to attached dmesg/kmsg for entire log/backtrace)
>
>
>
> If you fix the issue, kindly add following tag
> | Reported-by: kernel test robot <oliver.sang@intel.com>
> | Link: https://lore.kernel.org/oe-lkp/202304292203.44ddeff6-oliver.sang@intel.com

[snip]

(resending email without the egregious quoting of the entire .config ,
apologies for that! :)

I have diagnosed this and submitted a patch which fixes it to mainline [1],
which should apply cleanly on backport.

Here is a reliable repro, should be built with -lnuma (forgive the messy
code, it can probably be pared down further from this):-

#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <unistd.h>
#include <numaif.h>

int main()
{
        const long page_size = sysconf(_SC_PAGESIZE);

        char *ptr = mmap(NULL, 5 * page_size,PROT_READ | PROT_WRITE,
                         MAP_ANON | MAP_PRIVATE | MAP_POPULATE, -1, 0);
        if (ptr == MAP_FAILED) {
                perror("mmap");
                return EXIT_FAILURE;
        }

        // Split into 5.
        if (mlock(ptr + page_size, page_size)) {
                perror("mlock 1");
                return EXIT_FAILURE;
        }

        unsigned long nodemask = 1;

        if (mbind(ptr, page_size * 2, MPOL_LOCAL, &nodemask, 1, 0)) {
                perror("mbind 1");
                return EXIT_FAILURE;
        }

        nodemask = 0;

        // Initialise ranges to be the same for first two pages.
        if (mbind(ptr, page_size * 2, MPOL_PREFERRED, &nodemask, 1, 0)) {
                perror("mbind 2");
                return EXIT_FAILURE;
        }

        // Now, try changing for full range.
        if (mbind(ptr, page_size * 4, MPOL_PREFERRED, &nodemask, 1, 0)) {
                perror("mbind 3");
                return EXIT_FAILURE;
        }

        return EXIT_SUCCESS;
}

[1]:https://lore.kernel.org/all/db42467a692d78c654ec5c1953329401bd8a9c34.1682859234.git.lstoakes@gmail.com/


      parent reply	other threads:[~2023-04-30 13:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-30  2:57 kernel test robot
2023-04-30 13:09 ` Lorenzo Stoakes
2023-04-30 13:11 ` Lorenzo Stoakes [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cf9f57eb-a657-4545-a430-1b0efe9a67de@lucifer.local \
    --to=lstoakes@gmail.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=oe-lkp@lists.linux.dev \
    --cc=oliver.sang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox