From: Petr Vorel <pvorel@suse.cz>
To: Martin Doucha <mdoucha@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] Revert "pkey01: Adding test for PKEY_DISABLE_EXECUTE"
Date: Fri, 15 Nov 2024 19:58:19 +0100 [thread overview]
Message-ID: <20241115185819.GA1754587@pevik> (raw)
In-Reply-To: <f92ebef0-5861-4a7c-8503-b4edbc18d7d7@suse.cz>
Hi Li, Martin,
> Sorry, I forgot to CC Li in the patch.
> On 15. 11. 24 16:44, Martin Doucha wrote:
> > This reverts commit d2b8a476c29d52c484b387454082bbc906b0b4f8.
> > Remove the PKEY_DISABLE_EXECUTE subtest. The function_size() code
> > is broken in a way that I cannot easily fix. The function tries
> > to calculate the size of a function by finding the first RET
> > instruction. However, in 32bit LTP builds, the code gets compiled
> > to this:
> > 0804b690 <function_size>:
> > 804b690: 8b 4c 24 04 mov 0x4(%esp),%ecx
> > 804b694: 0f b6 01 movzbl (%ecx),%eax
> > 804b697: 83 c0 3e add $0x3e,%eax
> > 804b69a: 3c 01 cmp $0x1,%al
> > 804b69c: 76 1a jbe 804b6b8 <function_size+0x28>
> > 804b69e: 89 c8 mov %ecx,%eax
> > 804b6a0: 83 c0 01 add $0x1,%eax
> > 804b6a3: 0f b6 10 movzbl (%eax),%edx
> > 804b6a6: 83 c2 3e add $0x3e,%edx
> > 804b6a9: 80 fa 01 cmp $0x1,%dl
> > 804b6ac: 77 f2 ja 804b6a0 <function_size+0x10>
> > 804b6ae: 29 c8 sub %ecx,%eax
> > 804b6b0: 83 c0 10 add $0x10,%eax
> > 804b6b3: c3 ret
> > 804b6b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
> > 804b6b8: b8 10 00 00 00 mov $0x10,%eax
> > 804b6bd: c3 ret
> > 804b6be: 66 90 xchg %ax,%ax
> > If you look closely enough, you'll notice a C2 byte in add $0x3e,%edx
> > instruction on address 804b6a6. The function will assume this byte is
> > a RET instruction, return a size that's 22 bytes too short and then
> > the code execution inside the executable buffer will run past the end
> > of buffer, resulting in a segfault.
Martin, thanks a lot for debugging!
Acked-by: Petr Vorel <pvorel@suse.cz>
Other option would be to disable this test only for 32bit (keep it for 64bit).
Li, any change you could have look into it?
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2024-11-15 18:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-15 15:44 [LTP] [PATCH] Revert "pkey01: Adding test for PKEY_DISABLE_EXECUTE" Martin Doucha
2024-11-15 16:06 ` Martin Doucha
2024-11-15 18:58 ` Petr Vorel [this message]
2024-11-19 13:11 ` Jan Stancek
2024-11-19 13:31 ` Jan Stancek
2024-11-19 15:47 ` [LTP] [PATCH] syscalls/pkeys01: use a dummy function instead of function_size Jan Stancek
2024-11-20 14:56 ` Jan Stancek
2024-11-20 17:07 ` Petr Vorel
2024-11-25 3:43 ` Li Wang
2024-11-25 16:20 ` Martin Doucha
2024-11-26 8:05 ` Jan Stancek
2024-11-20 12:57 ` [LTP] [PATCH] Revert "pkey01: Adding test for PKEY_DISABLE_EXECUTE" Li Wang
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=20241115185819.GA1754587@pevik \
--to=pvorel@suse.cz \
--cc=ltp@lists.linux.it \
--cc=mdoucha@suse.cz \
/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.