Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 Sep 2022 23:59:17 GMT
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 36a757de23ac - stable/13 - Disallow invalid PT_GNU_STACK
Message-ID:  <202209042359.284NxHuo082826@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=36a757de23ace0bedd20c83635281427cfc7da30

commit 36a757de23ace0bedd20c83635281427cfc7da30
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-03-18 17:56:32 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2022-09-04 23:55:58 +0000

    Disallow invalid PT_GNU_STACK
    
    Stack must be at least readable and writable.
    
    PR:             242570
    Reviewed by:    kib, markj
    MFC after:      1 month
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D35867
    
    (cherry picked from commit fbafa98a94cc7f4f30d71003c230d1b5d4c5960b)
---
 sys/kern/imgact_elf.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
index 11ab46767fce..548a65a6f677 100644
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -1216,9 +1216,16 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp)
 				goto ret;
 			break;
 		case PT_GNU_STACK:
-			if (__elfN(nxstack))
+			if (__elfN(nxstack)) {
 				imgp->stack_prot =
 				    __elfN(trans_prot)(phdr[i].p_flags);
+				if ((imgp->stack_prot & VM_PROT_RW) !=
+				    VM_PROT_RW) {
+					uprintf("Invalid PT_GNU_STACK\n");
+					error = ENOEXEC;
+					goto ret;
+				}
+			}
 			imgp->stack_sz = phdr[i].p_memsz;
 			break;
 		case PT_PHDR: 	/* Program header table info */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202209042359.284NxHuo082826>