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: <fbdc12c8-762a-4ed6-ae44-a464494b9ef3@lucifer.local>
Date: Tue, 3 Jun 2025 10:56:27 +0100
From: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
To: Pu Lehui <pulehui@...weicloud.com>
Cc: mhiramat@...nel.org, oleg@...hat.com, peterz@...radead.org,
        akpm@...ux-foundation.org, Liam.Howlett@...cle.com, vbabka@...e.cz,
        jannh@...gle.com, pfalcato@...e.de, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org, stable@...r.kernel.org,
        pulehui@...wei.com
Subject: Re: [PATCH v1 4/4] selftests/mm: Add test about uprobe pte be orphan
 during vma merge

On Tue, Jun 03, 2025 at 03:08:22PM +0800, Pu Lehui wrote:
>
>
> On 2025/5/30 19:32, Lorenzo Stoakes wrote:
> > On Thu, May 29, 2025 at 03:56:50PM +0000, Pu Lehui wrote:
> > > From: Pu Lehui <pulehui@...wei.com>
> > >
> > > Add test about uprobe pte be orphan during vma merge.
> > >
> > > Signed-off-by: Pu Lehui <pulehui@...wei.com>
> > > ---
> > >   tools/testing/selftests/mm/merge.c | 42 ++++++++++++++++++++++++++++++
> > >   1 file changed, 42 insertions(+)
> > >
> > > diff --git a/tools/testing/selftests/mm/merge.c b/tools/testing/selftests/mm/merge.c
> > > index c76646cdf6e6..8e1f38d23384 100644
> > > --- a/tools/testing/selftests/mm/merge.c
> > > +++ b/tools/testing/selftests/mm/merge.c
> > > @@ -2,11 +2,13 @@
> > >
> > >   #define _GNU_SOURCE
> > >   #include "../kselftest_harness.h"
> > > +#include <fcntl.h>
> > >   #include <stdio.h>
> > >   #include <stdlib.h>
> > >   #include <unistd.h>
> > >   #include <sys/mman.h>
> > >   #include <sys/wait.h>
> > > +#include <linux/perf_event.h>
> > >   #include "vm_util.h"
> >
> > Need to include sys/syscall.h...
> >
> > >
> > >   FIXTURE(merge)
> > > @@ -452,4 +454,44 @@ TEST_F(merge, forked_source_vma)
> > >   	ASSERT_EQ(procmap->query.vma_end, (unsigned long)ptr2 + 5 * page_size);
> > >   }
> > >
> > > +TEST_F(merge, handle_uprobe_upon_merged_vma)
> > > +{
> > > +	const size_t attr_sz = sizeof(struct perf_event_attr);
> > > +	unsigned int page_size = self->page_size;
> > > +	const char *probe_file = "./foo";
> > > +	char *carveout = self->carveout;
> > > +	struct perf_event_attr attr;
> > > +	unsigned long type;
> > > +	void *ptr1, *ptr2;
> > > +	int fd;
> > > +
> > > +	fd = open(probe_file, O_RDWR|O_CREAT, 0600);
> > > +	ASSERT_GE(fd, 0);
> > > +
> > > +	ASSERT_EQ(ftruncate(fd, page_size), 0);
> > > +	ASSERT_EQ(read_sysfs("/sys/bus/event_source/devices/uprobe/type", &type), 0);
> > > +
> > > +	memset(&attr, 0, attr_sz);
> > > +	attr.size = attr_sz;
> > > +	attr.type = type;
> > > +	attr.config1 = (__u64)(long)probe_file;
> > > +	attr.config2 = 0x0;
> > > +
> > > +	ASSERT_GE(syscall(__NR_perf_event_open, &attr, 0, -1, -1, 0), 0);
> >
> > ...Because this results in:
> >
> > In file included from merge.c:4:
> > merge.c: In function ‘merge_handle_uprobe_upon_merged_vma’:
> > merge.c:480:27: error: ‘__NR_perf_event_open’ undeclared (first use in this function)
> >    480 |         ASSERT_GE(syscall(__NR_perf_event_open, &attr, 0, -1, -1, 0), 0);
> >
>
> I did not encounter this problem when compiling in the
> tools/testing/selftests/mm directory, but in any case, adding the
> sys/syscall.h header file makes sense.

Weird, it can depend on what system headers are implicitly included due to a
header in the dependency chain including something else. At any rate, I think
Andrew has already updated this?

If you send a respin obviously do include this fix.

>
> > Otherwise :>)
> >
> > > +
> > > +	ptr1 = mmap(&carveout[page_size], 10 * page_size, PROT_EXEC,
> > > +		    MAP_PRIVATE | MAP_FIXED, fd, 0);
> > > +	ASSERT_NE(ptr1, MAP_FAILED);
> > > +
> > > +	ptr2 = mremap(ptr1, page_size, 2 * page_size,
> > > +		      MREMAP_MAYMOVE | MREMAP_FIXED, ptr1 + 5 * page_size);
> > > +	ASSERT_NE(ptr2, MAP_FAILED);
> > > +
> > > +	ASSERT_NE(mremap(ptr2, page_size, page_size,
> > > +			 MREMAP_MAYMOVE | MREMAP_FIXED, ptr1), MAP_FAILED);
> > > +
> > > +	close(fd);
> > > +	remove(probe_file);
> > > +}
> > > +
> > >   TEST_HARNESS_MAIN
> > > --
> > > 2.34.1
> > >
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ