<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 24, 2019 at 2:56 PM Jan Stancek <<a href="mailto:jstancek@redhat.com">jstancek@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
----- Original Message -----<br>
> Signed-off-by: Li Wang <<a href="mailto:liwang@redhat.com" target="_blank">liwang@redhat.com</a>><br>
> +<br>
> +static void pkey_tests(int pkey, int prot, int flags, int fd)<br>
> +{<br>
> +     char *buffer;<br>
> +<br>
> +     if (fd == 0) {<br>
> +             fd = SAFE_OPEN(TEST_FILE, O_RDWR | O_CREAT, 0664);<br>
> +     }<br>
> +<br>
> +     buffer = SAFE_MMAP(NULL, psize, prot, flags, fd, 0);<br>
> +<br>
> +     if (pkey_mprotect(buffer, psize, prot, pkey) == -1)<br>
> +             tst_brk(TBROK, "pkey_mprotect failed");<br>
> +<br>
> +     tst_res(TPASS, "apply pkey to the buffer area success");<br>
> +<br>
> +     if (fd > 0) {<br>
> +             SAFE_CLOSE(fd);<br>
> +     }<br>
> +<br>
> +     SAFE_MUNMAP(buffer, psize);<br>
> +}<br>
> +<br>
<br>
Hi,<br>
<br>
pkey02 doesn't try to read/write as pkey01, but otherwise two tests look<br>
very similar.<br>
<br>
Could we try to read/write here as well for all combinations of map flags?<br>
Then pkey01 could be dropped since pkey02 would cover more than just 1 combination.<br>
Or is there a different reason behind separate tests, that I'm missing?<br>
<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">The pkey02 is a follow new test idea(test more types of memory) after I completed pkey01. </div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Yes, the diffenrence bettwen them is pkey02 cover more map flags but not do R/W verification. That's because I'm hoping to add {0, 0x0} to the test which does not trigger SIGSEGV in pkey02, it seems a bit tricky to distinguish the SIGSEGV is come from 0x0(if bug there) or PKEY_DISABLE_ACCESS progress.</div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>