All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Pierre-Clément Tosi" <ptosi@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 3/4] perf bench mem: Add --prot option
Date: Tue, 01 Dec 2026 12:28:03 +0000	[thread overview]
Message-ID: <sashiko-outbox-243259@kernel.org> (raw)
In-Reply-To: <20261201-perf-prot-mte-v1-3-4dc4e1da7460@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] perf bench mem: SIGSEGV in do_memcpy() and do_memset() with
  non-R/W --prot
--

commit b56a3ed736613b352b96a30c844d4df11b43ee88
Author: Pierre-Clément Tosi <ptosi@google.com>

perf bench mem: Add --prot option

This commit adds a --prot option to the perf bench mem suites to configure
the memory protection flags passed to mmap() and gates page loads and
stores in mmap_page_touch() on PROT_READ and PROT_WRITE.

> diff --git a/tools/perf/bench/mem-functions.c b/tools/perf/bench/mem-functions.c
> index 92f41820137fb..84247f83da593 100644
> --- a/tools/perf/bench/mem-functions.c
> +++ b/tools/perf/bench/mem-functions.c
[ ... ]
> @@ -63,6 +64,9 @@ static const struct option bench_common_options[] = {
>  	OPT_BOOLEAN('c', "cycles", &use_cycles,
>  		    "Use a cycles event instead of gettimeofday() to measure performance"),
>  
> +	OPT_STRING(0, "prot", &prot_str, "read,write",
> +		   "Memory protection: none, read, write, exec (comma-separated)"),
> +
>  	OPT_END()
>  };
[ ... ]
> @@ -376,7 +411,7 @@ static void *bench_mmap(const struct bench_params *p)
>  	if (p->page_shift != PAGE_SHIFT_4KB)
>  		flags |= MAP_HUGETLB | (p->page_shift << MAP_HUGE_SHIFT);
>  
> -	addr = mmap(NULL, p->size, PROT_READ | PROT_WRITE, flags, 0, 0);
> +	addr = mmap(NULL, p->size, p->prot, flags, 0, 0);
>  
>  	return addr == MAP_FAILED ? NULL : addr;
>  }

[Severity: Medium]
Does exposing --prot in bench_common_options cause a SIGSEGV in
do_memcpy() and do_memset() when the user passes a protection without
write (or read) access?

mem_alloc() uses bench_mmap() to allocate src and dst for both memcpy and
memset, and unlike mmap_page_touch(), memcpy_prefault() and do_memset()
unconditionally write to and read from those buffers.  Running perf bench
mem memcpy or memset with --prot=read (or --prot=none) faults immediately
instead of rejecting incompatible protections or scoping --prot to
bench_mmap_options.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-perf-prot-mte-v1-0-4dc4e1da7460@google.com?part=3

  reply	other threads:[~2026-12-01 12:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 12:11 [PATCH 0/4] perf bench mem: Add support for PROT_MTE Pierre-Clément Tosi
2026-12-01 12:11 ` [PATCH 1/4] perf bench mem: Report why mmap() failed Pierre-Clément Tosi
2026-12-01 12:11 ` [PATCH 2/4] perf bench mem: Pass bench_params to bench_mmap() Pierre-Clément Tosi
2026-12-01 12:11 ` [PATCH 3/4] perf bench mem: Add --prot option Pierre-Clément Tosi
2026-12-01 12:28   ` sashiko-bot [this message]
2026-12-01 12:11 ` [PATCH 4/4] perf bench mem: Support PROT_MTE on arm64 Pierre-Clément Tosi
2026-12-01 12:28 ` [PATCH 0/4] perf bench mem: Add support for PROT_MTE sashiko-bot

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=sashiko-outbox-243259@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=ptosi@google.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.