All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] change mmap flags from PROT_EXEC to PROT_READ
@ 2021-03-23 13:31 xueshi hu
  2021-07-21 16:34 ` Cyril Hrubis
  0 siblings, 1 reply; 2+ messages in thread
From: xueshi hu @ 2021-03-23 13:31 UTC (permalink / raw)
  To: ltp

In some architecture(e.g., mips), PROT_EXEC doesn't guarantee PROT_READ,
which will cause segment fault. In others architectures, PROT_READ is
more accurate.

Signed-off-by: xueshi hu <hubachelar@gmail.com>
---
 testcases/kernel/syscalls/mmap/mmap03.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/mmap/mmap03.c b/testcases/kernel/syscalls/mmap/mmap03.c
index b957a3218..2fcf1ef17 100644
--- a/testcases/kernel/syscalls/mmap/mmap03.c
+++ b/testcases/kernel/syscalls/mmap/mmap03.c
@@ -85,7 +85,7 @@ int main(int ac, char **av)
 		 * with execute access.
 		 */
 		errno = 0;
-		addr = mmap(0, page_sz, PROT_EXEC,
+		addr = mmap(0, page_sz, PROT_READ,
 			    MAP_FILE | MAP_SHARED, fildes, 0);
 
 		/* Check for the return value of mmap() */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [LTP] [PATCH] change mmap flags from PROT_EXEC to PROT_READ
  2021-03-23 13:31 [LTP] [PATCH] change mmap flags from PROT_EXEC to PROT_READ xueshi hu
@ 2021-07-21 16:34 ` Cyril Hrubis
  0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2021-07-21 16:34 UTC (permalink / raw)
  To: ltp

Hi!
> In some architecture(e.g., mips), PROT_EXEC doesn't guarantee PROT_READ,
> which will cause segment fault. In others architectures, PROT_READ is
> more accurate.

First of all sorry for the late response.

> Signed-off-by: xueshi hu <hubachelar@gmail.com>
> ---
>  testcases/kernel/syscalls/mmap/mmap03.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/testcases/kernel/syscalls/mmap/mmap03.c b/testcases/kernel/syscalls/mmap/mmap03.c
> index b957a3218..2fcf1ef17 100644
> --- a/testcases/kernel/syscalls/mmap/mmap03.c
> +++ b/testcases/kernel/syscalls/mmap/mmap03.c
> @@ -85,7 +85,7 @@ int main(int ac, char **av)
>  		 * with execute access.
>  		 */
>  		errno = 0;
> -		addr = mmap(0, page_sz, PROT_EXEC,
> +		addr = mmap(0, page_sz, PROT_READ,
>  			    MAP_FILE | MAP_SHARED, fildes, 0);

This is not correct fix. The test actually expects that on certain
architectures PROT_EXEC does not imply PROT_READ but that check is
missing mips, so this should probably be fixed with:

diff --git a/testcases/kernel/syscalls/mmap/mmap03.c b/testcases/kernel/syscalls/mmap/mmap03.c
index b957a3218..9d94d2653 100644
--- a/testcases/kernel/syscalls/mmap/mmap03.c
+++ b/testcases/kernel/syscalls/mmap/mmap03.c
@@ -124,7 +124,7 @@ int main(int ac, char **av)
                                         "correct");
                        }
                }
-#if defined(__ia64__) || defined(__hppa__)
+#if defined(__ia64__) || defined(__hppa__) || defined(__mips__)
                if (pass) {
                        tst_resm(TPASS, "Got SIGSEGV as expected");
                } else {

Does this change fixes the test for you?

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-21 16:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-23 13:31 [LTP] [PATCH] change mmap flags from PROT_EXEC to PROT_READ xueshi hu
2021-07-21 16:34 ` Cyril Hrubis

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.