diff --git a/0001-Add-PL_ARCH-for-AArch64.patch b/0001-Add-PL_ARCH-for-AArch64.patch new file mode 100644 index 0000000000000000000000000000000000000000..df359d93f805feefaae8d02f378e5f8e0e7989b3 --- /dev/null +++ b/0001-Add-PL_ARCH-for-AArch64.patch @@ -0,0 +1,118 @@ +From a33b23b9ec5c0733a0ff85dafc46b3df2a6d2249 Mon Sep 17 00:00:00 2001 +From: Mark Salter +Date: Fri, 21 Aug 2015 12:03:30 -0400 +Subject: [PATCH] Add PL_ARCH for AArch64 + +Add a skeleton PL_ARCH for AArch64. Just enough to support +execstack. + +Signed-off-by: Mark Salter +--- + src/Makefile.am | 3 ++- + src/Makefile.in | 9 ++++++--- + src/arch-aarch64.c | 38 ++++++++++++++++++++++++++++++++++++++ + 3 files changed, 46 insertions(+), 4 deletions(-) + create mode 100644 src/arch-aarch64.c + +diff --git a/src/Makefile.am b/src/Makefile.am +index d2265aa9c0..a4c65f2e65 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -12,7 +12,8 @@ bin_PROGRAMS = execstack + + arch_SOURCES = arch-i386.c arch-alpha.c arch-ppc.c arch-ppc64.c \ + arch-sparc.c arch-sparc64.c arch-x86_64.c arch-mips.c \ +- arch-s390.c arch-s390x.c arch-arm.c arch-sh.c arch-ia64.c ++ arch-s390.c arch-s390x.c arch-arm.c arch-sh.c arch-ia64.c \ ++ arch-aarch64.c + common_SOURCES = checksum.c data.c dso.c dwarf2.c dwarf2.h fptr.c fptr.h \ + hashtab.c hashtab.h mdebug.c prelink.h stabs.c crc32.c + prelink_SOURCES = cache.c conflict.c cxx.c doit.c exec.c execle_open.c get.c \ +diff --git a/src/Makefile.in b/src/Makefile.in +index 85cf84577f..863dc835a0 100644 +--- a/src/Makefile.in ++++ b/src/Makefile.in +@@ -107,7 +107,8 @@ bin_PROGRAMS = execstack + + arch_SOURCES = arch-i386.c arch-alpha.c arch-ppc.c arch-ppc64.c \ + arch-sparc.c arch-sparc64.c arch-x86_64.c arch-mips.c \ +- arch-s390.c arch-s390x.c arch-arm.c arch-sh.c arch-ia64.c ++ arch-s390.c arch-s390x.c arch-arm.c arch-sh.c arch-ia64.c \ ++ arch-aarch64.c + + common_SOURCES = checksum.c data.c dso.c dwarf2.c dwarf2.h fptr.c fptr.h \ + hashtab.c hashtab.h mdebug.c prelink.h stabs.c crc32.c +@@ -139,7 +140,8 @@ am__objects_2 = arch-i386.$(OBJEXT) arch-alpha.$(OBJEXT) \ + arch-ppc.$(OBJEXT) arch-ppc64.$(OBJEXT) arch-sparc.$(OBJEXT) \ + arch-sparc64.$(OBJEXT) arch-x86_64.$(OBJEXT) \ + arch-mips.$(OBJEXT) arch-s390.$(OBJEXT) arch-s390x.$(OBJEXT) \ +- arch-arm.$(OBJEXT) arch-sh.$(OBJEXT) arch-ia64.$(OBJEXT) ++ arch-arm.$(OBJEXT) arch-sh.$(OBJEXT) arch-ia64.$(OBJEXT) \ ++ arch-aarch64.$(OBJEXT) + am_execstack_OBJECTS = execstack.$(OBJEXT) $(am__objects_1) \ + $(am__objects_2) + execstack_OBJECTS = $(am_execstack_OBJECTS) +@@ -162,7 +164,7 @@ LIBS = @LIBS@ + depcomp = $(SHELL) $(top_srcdir)/depcomp + am__depfiles_maybe = depfiles + @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/arch-alpha.Po \ +-@AMDEP_TRUE@ ./$(DEPDIR)/arch-arm.Po ./$(DEPDIR)/arch-i386.Po \ ++@AMDEP_TRUE@ ./$(DEPDIR)/arch-arm.Po ./$(DEPDIR)/arch-aarch64.Po ./$(DEPDIR)/arch-i386.Po \ + @AMDEP_TRUE@ ./$(DEPDIR)/arch-ia64.Po ./$(DEPDIR)/arch-mips.Po \ + @AMDEP_TRUE@ ./$(DEPDIR)/arch-ppc.Po ./$(DEPDIR)/arch-ppc64.Po \ + @AMDEP_TRUE@ ./$(DEPDIR)/arch-s390.Po ./$(DEPDIR)/arch-s390x.Po \ +@@ -277,6 +279,7 @@ distclean-compile: + + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arch-alpha.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arch-arm.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arch-arch64.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arch-i386.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arch-ia64.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arch-mips.Po@am__quote@ +diff --git a/src/arch-aarch64.c b/src/arch-aarch64.c +new file mode 100644 +index 0000000000..42eb2ececb +--- /dev/null ++++ b/src/arch-aarch64.c +@@ -0,0 +1,38 @@ ++/* Copyright (C) 2015 Red Hat, Inc. ++ Written by Mark Salter , 2015. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 2, or (at your option) ++ any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program; if not, write to the Free Software Foundation, ++ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "prelink.h" ++ ++PL_ARCH = { ++ .name = "AArch64", ++ .class = ELFCLASS64, ++ .machine = EM_AARCH64, ++ .alternate_machine = { EM_NONE }, ++ .max_page_size = 0x10000, ++ .page_size = 0x1000 ++}; +-- +2.1.0 + diff --git a/0002-execstack-configure-c99.patch b/0002-execstack-configure-c99.patch new file mode 100644 index 0000000000000000000000000000000000000000..f0b36febe88b0eb8de310fd91c85930bb19df192 --- /dev/null +++ b/0002-execstack-configure-c99.patch @@ -0,0 +1,37 @@ +Avoid implicit function declarations, a C feature removed in 1999. + +diff --git a/aclocal.m4 b/aclocal.m4 +index a357ef74b30a09a6..2d2af334d5369e8e 100644 +--- a/aclocal.m4 ++++ b/aclocal.m4 +@@ -6727,6 +6727,7 @@ AC_DEFUN(AC_LIBELF_SXWORD, + #include + #include + #include ++#include + + static unsigned char sparc64_elf[] = { + 0x7f,0x45,0x4c,0x46,0x02,0x02,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +diff --git a/configure b/configure +index 9f2a746fbf3f7471..960e140559761417 100755 +--- a/configure ++++ b/configure +@@ -4438,8 +4438,8 @@ main () + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) +- exit(2); +- exit (0); ++ return 2; ++ return 0; + } + _ACEOF + rm -f conftest$ac_exeext +@@ -19411,6 +19411,7 @@ cat >>conftest.$ac_ext <<_ACEOF + #include + #include + #include ++#include + + static unsigned char sparc64_elf[] = { + 0x7f,0x45,0x4c,0x46,0x02,0x02,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, diff --git a/execstack-0.5.0-25.fc38.src.rpm b/execstack-0.5.0-25.fc38.src.rpm new file mode 100644 index 0000000000000000000000000000000000000000..2f2135acf4d4245b66d37298177dc17858af2baf Binary files /dev/null and b/execstack-0.5.0-25.fc38.src.rpm differ diff --git a/execstack.spec b/execstack.spec new file mode 100644 index 0000000000000000000000000000000000000000..04106c806fe9a1b43b1aa94d9fbc7ffa23dfd111 --- /dev/null +++ b/execstack.spec @@ -0,0 +1,71 @@ +%define anolis_release 1 + +%global commit 4c79120bcdbde0616f592458ccde7035e92ca3d8 +%global shortcommit %(c=%{commit}; echo ${c:0:7}) + +Name: execstack +Summary: Utility to set/clear/query executable stack bit +Version: 0.5.0 +Release: %{anolis_release}%{?dist} +License: GPLv2+ +Source0: https://github.com/keszybz/prelink/archive/%{commit}.tar.gz#/prelink-%{shortcommit}.tar.gz +Patch0001: 0001-Add-PL_ARCH-for-AArch64.patch +Patch0002: 0002-execstack-configure-c99.patch + +BuildRequires: gcc gcc-c++ make +BuildRequires: elfutils-libelf-devel libselinux-devel, libselinux-utils git +Requires: glibc >= 2.2.4-18, coreutils, findutils +Requires: util-linux, gawk, grep +Obsoletes: prelink < 0.5.0-8 + +%description +Execstack is a Linux command that allows the execution of code on the stack. +By default, modern operating systems prevent code from being executed on the +stack as a security measure against buffer overflow attacks. However, in some +cases, it may be necessary to execute code on the stack, for example, when +running legacy applications or when working with certain programming languages. +The execstack command can be used to mark a particular binary executable as +"executable on the stack" or to check if an existing executable has this property. + +%package doc +Summary: Documents for %{name} +Requires: %{name} = %{EVR} +BuildArch: noarch + +%description doc +This document package contains the doc files for %{name}. + +%prep +%autosetup -p1 -n prelink-%{commit} -Sgit + +%build +sed -i -e '/^prelink_LDADD/s/$/ -lpthread/' src/Makefile.{am,in} +%configure +%{make_build} %{?_smp_mflags} -C gelf +%{make_build} %{?_smp_mflags} -C gelfx +%{make_build} %{?_smp_mflags} -C gelfx32 +%{make_build} %{?_smp_mflags} -C src execstack + +%check +cp src/execstack test +src/execstack -q test | grep '^-' +src/execstack -s test +src/execstack -q test | grep '^X' +src/execstack -c test +src/execstack -q test | grep '^-' + +%install +install -D src/execstack %{buildroot}%{_bindir}/execstack +install -D -m 0644 doc/execstack.8 %{buildroot}%{_mandir}/man8/execstack.8 + +%files +%license COPYING +%{_bindir}/execstack +%{_mandir}/man8/execstack.8.* + +%files doc +%doc ChangeLog NEWS README TODO THANKS + +%changelog +* Sat Apr 15 2023 Heng Qi - 0.5.0-1 +- Init the package diff --git a/prelink-4c79120.tar.gz b/prelink-4c79120.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..20275fb1c12bd4deb0bbf422e2c6c6dcec458f44 Binary files /dev/null and b/prelink-4c79120.tar.gz differ