From 79c17e18afc4fc01e4f0bf724be2cc47a0bfc48b Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Tue, 3 Nov 2020 06:44:08 -0500 Subject: [PATCH] import libhugetlbfs-2.21-17.el8 --- SOURCES/0001-wait-child-with-os-wait.patch | 52 +++ ...ge_page_setup_helper-python3-convert.patch | 304 ++++++++++++++++++ ...ovscan-SHELLCHECK_WARNING-complaints.patch | 212 ++++++++++++ ...lude-missing-LDFLAGS-to-make-targets.patch | 56 ++++ SPECS/libhugetlbfs.spec | 33 +- 5 files changed, 656 insertions(+), 1 deletion(-) create mode 100644 SOURCES/0001-wait-child-with-os-wait.patch create mode 100644 SOURCES/huge_page_setup_helper-python3-convert.patch create mode 100644 SOURCES/tests-fix-covscan-SHELLCHECK_WARNING-complaints.patch create mode 100644 SOURCES/tests-include-missing-LDFLAGS-to-make-targets.patch diff --git a/SOURCES/0001-wait-child-with-os-wait.patch b/SOURCES/0001-wait-child-with-os-wait.patch new file mode 100644 index 0000000..73b59e3 --- /dev/null +++ b/SOURCES/0001-wait-child-with-os-wait.patch @@ -0,0 +1,52 @@ +commit e7b3e6817421763eee37cb35ef8627bdd37a3690 +Author: Chunyu Hu +Date: Wed May 6 18:59:43 2020 +0800 + + Wait child with os.wait() + + os.popen() is an async method, it fork() child and exec() in child + with the arg command. If it's slow enough, main process could get + incomplete result. + + During our test, we find python3 is faster than python2,after coverting + to python3, 'groupadd' usually doesn't finish when the followed step iter + on groups, we would get '-1' as the groupid and lead to error. + + To reproduce it with python3: + /root/rpmbuild/BUILD/libhugetlbfs-2.21/huge_page_setup_helper.py < + +diff --git a/huge_page_setup_helper.py b/huge_page_setup_helper.py +index a9ba2bf..01fc8dc 100755 +--- a/huge_page_setup_helper.py ++++ b/huge_page_setup_helper.py +@@ -169,6 +169,10 @@ else: + os.popen("/usr/sbin/groupadd %s" % userGroupReq) + else: + print("/usr/sbin/groupadd %s" % userGroupReq) ++ ++ # wait for the groupadd finish ++ os.wait() ++ + groupNames = os.popen("/usr/bin/getent group %s" % userGroupReq).readlines() + for line in groupNames: + curGroupName = line.split(":")[0] +@@ -244,6 +248,9 @@ else: + print("/usr/bin/hugeadm --set-recommended-shmmax") + print() + ++# wait for the hugepage setups finish ++os.wait() ++ + # figure out what that shmmax value we just set was + hugeadmexplain = os.popen("/usr/bin/hugeadm --explain 2>/dev/null").readlines() + for line in hugeadmexplain: diff --git a/SOURCES/huge_page_setup_helper-python3-convert.patch b/SOURCES/huge_page_setup_helper-python3-convert.patch new file mode 100644 index 0000000..a84ac5a --- /dev/null +++ b/SOURCES/huge_page_setup_helper-python3-convert.patch @@ -0,0 +1,304 @@ +diff --git a/huge_page_setup_helper.py b/huge_page_setup_helper.py +index 43c9916..7ba0c92 100755 +--- a/huge_page_setup_helper.py ++++ b/huge_page_setup_helper.py +@@ -1,4 +1,4 @@ +-#!/usr/bin/python ++#!/usr/bin/env python3 + + # + # Tool to set up Linux large page support with minimal effort +@@ -14,13 +14,13 @@ debug = False + + # must be executed under the root to operate + if os.geteuid() != 0: +- print "You must be root to setup hugepages!" ++ print("You must be root to setup hugepages!") + os._exit(1) + + # config files we need access to + sysctlConf = "/etc/sysctl.conf" + if not os.access(sysctlConf, os.W_OK): +- print "Cannot access %s" % sysctlConf ++ print("Cannot access %s" % sysctlConf) + if debug == False: + os._exit(1) + +@@ -41,7 +41,7 @@ for line in hugeadmexplain: + break + + if memTotal == 0: +- print "Your version of libhugetlbfs' hugeadm utility is too old!" ++ print("Your version of libhugetlbfs' hugeadm utility is too old!") + os._exit(1) + + +@@ -54,7 +54,7 @@ for line in poolList: + break + + if hugePageSize == 0: +- print "Aborting, cannot determine system huge page size!" ++ print("Aborting, cannot determine system huge page size!") + os._exit(1) + + # Get initial sysctl settings +@@ -83,22 +83,22 @@ for line in groupNames: + + + # dump system config as we see it before we start tweaking it +-print "Current configuration:" +-print " * Total System Memory......: %6d MB" % memTotal +-print " * Shared Mem Max Mapping...: %6d MB" % (shmmax / (1024 * 1024)) +-print " * System Huge Page Size....: %6d MB" % (hugePageSize / (1024 * 1024)) +-print " * Number of Huge Pages.....: %6d" % hugePages +-print " * Total size of Huge Pages.: %6d MB" % (hugePages * hugePageSize / (1024 * 1024)) +-print " * Remaining System Memory..: %6d MB" % (memTotal - (hugePages * hugePageSize / (1024 * 1024))) +-print " * Huge Page User Group.....: %s (%d)" % (hugeGIDName, hugeGID) +-print ++print("Current configuration:") ++print(" * Total System Memory......: %6d MB" % memTotal) ++print(" * Shared Mem Max Mapping...: %6d MB" % (shmmax / (1024 * 1024))) ++print(" * System Huge Page Size....: %6d MB" % (hugePageSize / (1024 * 1024))) ++print(" * Number of Huge Pages.....: %6d" % hugePages) ++print(" * Total size of Huge Pages.: %6d MB" % (hugePages * hugePageSize / (1024 * 1024))) ++print(" * Remaining System Memory..: %6d MB" % (memTotal - (hugePages * hugePageSize / (1024 * 1024)))) ++print(" * Huge Page User Group.....: %s (%d)" % (hugeGIDName, hugeGID)) ++print() + + + # ask how memory they want to allocate for huge pages + userIn = None + while not userIn: + try: +- userIn = raw_input("How much memory would you like to allocate for huge pages? " ++ userIn = input("How much memory would you like to allocate for huge pages? " + "(input in MB, unless postfixed with GB): ") + if userIn[-2:] == "GB": + userHugePageReqMB = int(userIn[0:-2]) * 1024 +@@ -113,19 +113,19 @@ while not userIn: + # As a sanity safeguard, require at least 128M not be allocated to huge pages + if userHugePageReqMB > (memTotal - 128): + userIn = None +- print "Refusing to allocate %d, you must leave at least 128MB for the system" % userHugePageReqMB ++ print("Refusing to allocate %d, you must leave at least 128MB for the system" % userHugePageReqMB) + elif userHugePageReqMB < (hugePageSize / (1024 * 1024)): + userIn = None +- print "Sorry, allocation must be at least a page's worth!" ++ print("Sorry, allocation must be at least a page's worth!") + else: + break + except ValueError: + userIn = None +- print "Input must be an integer, please try again!" ++ print("Input must be an integer, please try again!") + userHugePageReqKB = userHugePageReqMB * 1024 + userHugePagesReq = userHugePageReqKB / (hugePageSize / 1024) +-print "Okay, we'll try to allocate %d MB for huge pages..." % userHugePageReqMB +-print ++print("Okay, we'll try to allocate %d MB for huge pages..." % userHugePageReqMB) ++print() + + + # some basic user input validation +@@ -134,24 +134,24 @@ inputIsValid = False + # ask for the name of the group allowed access to huge pages + while inputIsValid == False: + foundbad = False +- userGroupReq = raw_input("What group should have access to the huge pages?" ++ userGroupReq = input("What group should have access to the huge pages?" + "(The group will be created, if need be) [hugepages]: ") + if userGroupReq is '': + userGroupReq = 'hugepages' + if userGroupReq[0].isdigit() or userGroupReq[0] == "-": + foundbad = True +- print "Group names cannot start with a number or dash, please try again!" ++ print("Group names cannot start with a number or dash, please try again!") + for char in badchars: + if char in userGroupReq: + foundbad = True +- print "Illegal characters in group name, please try again!" ++ print("Illegal characters in group name, please try again!") + break + if len(userGroupReq) > 16: + foundbad = True +- print "Group names can't be more than 16 characaters, please try again!" ++ print("Group names can't be more than 16 characaters, please try again!") + if foundbad == False: + inputIsValid = True +-print "Okay, we'll give group %s access to the huge pages" % userGroupReq ++print("Okay, we'll give group %s access to the huge pages" % userGroupReq) + + + # see if group already exists, use it if it does, if not, create it +@@ -163,20 +163,20 @@ for line in groupNames: + break + + if userGIDReq > -1: +- print "Group %s (gid %d) already exists, we'll use it" % (userGroupReq, userGIDReq) ++ print("Group %s (gid %d) already exists, we'll use it" % (userGroupReq, userGIDReq)) + else: + if debug == False: + os.popen("/usr/sbin/groupadd %s" % userGroupReq) + else: +- print "/usr/sbin/groupadd %s" % userGroupReq ++ print("/usr/sbin/groupadd %s" % userGroupReq) + groupNames = os.popen("/usr/bin/getent group %s" % userGroupReq).readlines() + for line in groupNames: + curGroupName = line.split(":")[0] + if curGroupName == userGroupReq: + userGIDReq = int(line.split(":")[2]) + break +- print "Created group %s (gid %d) for huge page use" % (userGroupReq, userGIDReq) +-print ++ print("Created group %s (gid %d) for huge page use" % (userGroupReq, userGIDReq)) ++print() + + + # basic user input validation, take 2 +@@ -186,20 +186,20 @@ inputIsValid = False + # ask for user(s) that should be in the huge page access group + while inputIsValid == False: + foundbad = False +- userUsersReq = raw_input("What user(s) should have access to the huge pages (space-delimited list, users created as needed)? ") ++ userUsersReq = input("What user(s) should have access to the huge pages (space-delimited list, users created as needed)? ") + for char in badchars: + if char in userUsersReq: + foundbad = True +- print "Illegal characters in user name(s) or invalid list format, please try again!" ++ print("Illegal characters in user name(s) or invalid list format, please try again!") + break + for n in userUsersReq.split(): + if len(n) > 32: + foundbad = True +- print "User names can't be more than 32 characaters, please try again!" ++ print("User names can't be more than 32 characaters, please try again!") + break + if n[0] == "-": + foundbad = True +- print "User names cannot start with a dash, please try again!" ++ print("User names cannot start with a dash, please try again!") + break + if foundbad == False: + inputIsValid = True +@@ -211,24 +211,24 @@ for hugeUser in hugePageUserList: + for line in curUserList: + curUser = line.split(":")[0] + if curUser == hugeUser: +- print "Adding user %s to huge page group" % hugeUser ++ print("Adding user %s to huge page group" % hugeUser) + userExists = True + if debug == False: + os.popen("/usr/sbin/usermod -a -G %s %s" % (userGroupReq, hugeUser)) + else: +- print "/usr/sbin/usermod -a -G %s %s" % (userGroupReq, hugeUser) ++ print("/usr/sbin/usermod -a -G %s %s" % (userGroupReq, hugeUser)) + if userExists == True: + break + if userExists == False: +- print "Creating user %s with membership in huge page group" % hugeUser ++ print("Creating user %s with membership in huge page group" % hugeUser) + if debug == False: + if hugeUser == userGroupReq: + os.popen("/usr/sbin/useradd %s -g %s" % (hugeUser, userGroupReq)) + else: + os.popen("/usr/sbin/useradd %s -G %s" % (hugeUser, userGroupReq)) + else: +- print "/usr/sbin/useradd %s -G %s" % (hugeUser, userGroupReq) +-print ++ print("/usr/sbin/useradd %s -G %s" % (hugeUser, userGroupReq)) ++print() + + + # set values for the current running environment +@@ -238,11 +238,11 @@ if debug == False: + os.popen("/usr/bin/hugeadm --set-shm-group %d" % userGIDReq) + os.popen("/usr/bin/hugeadm --set-recommended-shmmax") + else: +- print "/usr/bin/hugeadm --pool-pages-min DEFAULT:%sM" % userHugePageReqMB +- print "/usr/bin/hugeadm --pool-pages-max DEFAULT:%sM" % userHugePageReqMB +- print "/usr/bin/hugeadm --set-shm-group %d" % userGIDReq +- print "/usr/bin/hugeadm --set-recommended-shmmax" +- print ++ print("/usr/bin/hugeadm --pool-pages-min DEFAULT:%sM" % userHugePageReqMB) ++ print("/usr/bin/hugeadm --pool-pages-max DEFAULT:%sM" % userHugePageReqMB) ++ print("/usr/bin/hugeadm --set-shm-group %d" % userGIDReq) ++ print("/usr/bin/hugeadm --set-recommended-shmmax") ++ print() + + # figure out what that shmmax value we just set was + hugeadmexplain = os.popen("/usr/bin/hugeadm --explain 2>/dev/null").readlines() +@@ -258,7 +258,7 @@ if debug == False: + try: + sysctlConfLines = open(sysctlConf).readlines() + os.rename(sysctlConf, sysctlConf + ".backup") +- print("Saved original %s as %s.backup" % (sysctlConf, sysctlConf)) ++ print(("Saved original %s as %s.backup" % (sysctlConf, sysctlConf))) + except: + pass + +@@ -279,11 +279,11 @@ if debug == False: + fd.close() + + else: +- print "Add to %s:" % sysctlConf +- print "kernel.shmmax = %d" % shmmax +- print "vm.nr_hugepages = %d" % userHugePagesReq +- print "vm.hugetlb_shm_group = %d" % userGIDReq +- print ++ print("Add to %s:" % sysctlConf) ++ print("kernel.shmmax = %d" % shmmax) ++ print("vm.nr_hugepages = %d" % userHugePagesReq) ++ print("vm.hugetlb_shm_group = %d" % userGIDReq) ++ print() + + + # write out limits.conf changes to persist across reboot +@@ -293,7 +293,7 @@ if debug == False: + try: + limitsConfLines = open(limitsConf).readlines() + os.rename(limitsConf, limitsConf + ".backup") +- print("Saved original %s as %s.backup" % (limitsConf, limitsConf)) ++ print(("Saved original %s as %s.backup" % (limitsConf, limitsConf))) + except: + pass + +@@ -319,25 +319,25 @@ if debug == False: + fd.close() + + else: +- print "Add to %s:" % limitsConf ++ print("Add to %s:" % limitsConf) + for hugeUser in hugePageUserList: +- print "%s soft memlock %d" % (hugeUser, userHugePageReqKB) +- print "%s hard memlock %d" % (hugeUser, userHugePageReqKB) ++ print("%s soft memlock %d" % (hugeUser, userHugePageReqKB)) ++ print("%s hard memlock %d" % (hugeUser, userHugePageReqKB)) + + + # dump the final configuration of things now that we're done tweaking +-print +-print "Final configuration:" +-print " * Total System Memory......: %6d MB" % memTotal ++print() ++print("Final configuration:") ++print(" * Total System Memory......: %6d MB" % memTotal) + if debug == False: +- print " * Shared Mem Max Mapping...: %6d MB" % (shmmax / (1024 * 1024)) ++ print(" * Shared Mem Max Mapping...: %6d MB" % (shmmax / (1024 * 1024))) + else: + # This should be what we *would* have set it to, had we actually run hugeadm --set-recommended-shmmax +- print " * Shared Mem Max Mapping...: %6d MB" % (userHugePagesReq * hugePageSize / (1024 * 1024)) +-print " * System Huge Page Size....: %6d MB" % (hugePageSize / (1024 * 1024)) +-print " * Available Huge Pages.....: %6d" % userHugePagesReq +-print " * Total size of Huge Pages.: %6d MB" % (userHugePagesReq * hugePageSize / (1024 * 1024)) +-print " * Remaining System Memory..: %6d MB" % (memTotal - userHugePageReqMB) +-print " * Huge Page User Group.....: %s (%d)" % (userGroupReq, userGIDReq) +-print ++ print(" * Shared Mem Max Mapping...: %6d MB" % (userHugePagesReq * hugePageSize / (1024 * 1024))) ++print(" * System Huge Page Size....: %6d MB" % (hugePageSize / (1024 * 1024))) ++print(" * Available Huge Pages.....: %6d" % userHugePagesReq) ++print(" * Total size of Huge Pages.: %6d MB" % (userHugePagesReq * hugePageSize / (1024 * 1024))) ++print(" * Remaining System Memory..: %6d MB" % (memTotal - userHugePageReqMB)) ++print(" * Huge Page User Group.....: %s (%d)" % (userGroupReq, userGIDReq)) ++print() + diff --git a/SOURCES/tests-fix-covscan-SHELLCHECK_WARNING-complaints.patch b/SOURCES/tests-fix-covscan-SHELLCHECK_WARNING-complaints.patch new file mode 100644 index 0000000..8a721f1 --- /dev/null +++ b/SOURCES/tests-fix-covscan-SHELLCHECK_WARNING-complaints.patch @@ -0,0 +1,212 @@ +From 815072b9163cae73671baae448f974cc8f8a84be Mon Sep 17 00:00:00 2001 +From: Rafael Aquini +Date: Sun, 12 Apr 2020 21:08:01 -0400 +Subject: [PATCH] tests: fix covscan SHELLCHECK_WARNING complaints + +Signed-off-by: Rafael Aquini +--- + tests/counters.sh | 2 +- + tests/fadvise_reserve.sh | 2 +- + tests/fallocate_align.sh | 2 +- + tests/fallocate_basic.sh | 2 +- + tests/fallocate_stress.sh | 2 +- + tests/madvise_reserve.sh | 2 +- + tests/mremap-expand-slice-collision.sh | 2 +- + tests/mremap-fixed-huge-near-normal.sh | 2 +- + tests/mremap-fixed-normal-near-huge.sh | 2 +- + tests/quota.sh | 2 +- + tests/readahead_reserve.sh | 2 +- + tests/wrapper-utils.sh | 18 +++++++++--------- + 12 files changed, 20 insertions(+), 20 deletions(-) + +diff --git a/tests/counters.sh b/tests/counters.sh +index e3ffabe..27bfca3 100755 +--- a/tests/counters.sh ++++ b/tests/counters.sh +@@ -3,7 +3,7 @@ + . wrapper-utils.sh + + # Huge page overcommit was not available until 2.6.24 +-compare_kvers `uname -r` "2.6.24" ++compare_kvers "$(uname -r)" "2.6.24" + if [ $? -eq 1 ]; then + EXP_RC=$RC_FAIL + else +diff --git a/tests/fadvise_reserve.sh b/tests/fadvise_reserve.sh +index 74496ec..ff96003 100755 +--- a/tests/fadvise_reserve.sh ++++ b/tests/fadvise_reserve.sh +@@ -3,7 +3,7 @@ + . wrapper-utils.sh + + # fadvise is known broken before 2.6.30 +-compare_kvers `uname -r` "2.6.30" ++compare_kvers "$(uname -r)" "2.6.30" + if [ $? -eq 1 ]; then + echo "FAIL (assumed) kernel bug" + exit $RC_FAIL +diff --git a/tests/fallocate_align.sh b/tests/fallocate_align.sh +index 5105151..4397cd3 100755 +--- a/tests/fallocate_align.sh ++++ b/tests/fallocate_align.sh +@@ -5,7 +5,7 @@ + # + # hugetlbfs fallocate support was not available until 4.3 + # +-compare_kvers `uname -r` "4.3.0" ++compare_kvers "$(uname -r)" "4.3.0" + if [ $? -eq 1 ]; then + echo "FAIL no fallocate support in kernels before 4.3.0" + exit $RC_FAIL +diff --git a/tests/fallocate_basic.sh b/tests/fallocate_basic.sh +index 904dfd6..1af6196 100755 +--- a/tests/fallocate_basic.sh ++++ b/tests/fallocate_basic.sh +@@ -5,7 +5,7 @@ + # + # hugetlbfs fallocate support was not available until 4.3 + # +-compare_kvers `uname -r` "4.3.0" ++compare_kvers "$(uname -r)" "4.3.0" + if [ $? -eq 1 ]; then + echo "FAIL no fallocate support in kernels before 4.3.0" + exit $RC_FAIL +diff --git a/tests/fallocate_stress.sh b/tests/fallocate_stress.sh +index 622084f..3b5b70a 100755 +--- a/tests/fallocate_stress.sh ++++ b/tests/fallocate_stress.sh +@@ -5,7 +5,7 @@ + # + # hugetlbfs fallocate support was not available until 4.3 + # +-compare_kvers `uname -r` "4.3.0" ++compare_kvers "$(uname -r)" "4.3.0" + if [ $? -eq 1 ]; then + echo "FAIL no fallocate support in kernels before 4.3.0" + exit $RC_FAIL +diff --git a/tests/madvise_reserve.sh b/tests/madvise_reserve.sh +index cfe582d..eb289d6 100755 +--- a/tests/madvise_reserve.sh ++++ b/tests/madvise_reserve.sh +@@ -3,7 +3,7 @@ + . wrapper-utils.sh + + # madvise is known broken before 2.6.30 +-compare_kvers `uname -r` "2.6.30" ++compare_kvers "$(uname -r)" "2.6.30" + if [ $? -eq 1 ]; then + echo "FAIL (assumed) kernel bug" + exit $RC_FAIL +diff --git a/tests/mremap-expand-slice-collision.sh b/tests/mremap-expand-slice-collision.sh +index 8c9d98a..dd4eba3 100755 +--- a/tests/mremap-expand-slice-collision.sh ++++ b/tests/mremap-expand-slice-collision.sh +@@ -3,7 +3,7 @@ + . wrapper-utils.sh + + # mremap-expand-slice-collision is known broken before 2.6.33 +-compare_kvers `uname -r` "2.6.33" ++compare_kvers "$(uname -r)" "2.6.33" + if [ $? -eq 1 ]; then + echo "FAIL (assumed) kernel bug" + exit $RC_FAIL +diff --git a/tests/mremap-fixed-huge-near-normal.sh b/tests/mremap-fixed-huge-near-normal.sh +index 4b89c35..22fde79 100755 +--- a/tests/mremap-fixed-huge-near-normal.sh ++++ b/tests/mremap-fixed-huge-near-normal.sh +@@ -3,7 +3,7 @@ + . wrapper-utils.sh + + # mremap-fixed-huge-near-normal is known broken before 2.6.33 +-compare_kvers `uname -r` "2.6.33" ++compare_kvers "$(uname -r)" "2.6.33" + if [ $? -eq 1 ]; then + echo "FAIL (assumed) kernel bug" + exit $RC_FAIL +diff --git a/tests/mremap-fixed-normal-near-huge.sh b/tests/mremap-fixed-normal-near-huge.sh +index 9ed058f..45b8f26 100755 +--- a/tests/mremap-fixed-normal-near-huge.sh ++++ b/tests/mremap-fixed-normal-near-huge.sh +@@ -3,7 +3,7 @@ + . wrapper-utils.sh + + # mremap-fixed-normal-near-huge is known broken before 2.6.33 +-compare_kvers `uname -r` "2.6.33" ++compare_kvers "$(uname -r)" "2.6.33" + if [ $? -eq 1 ]; then + echo "FAIL (assumed) kernel bug" + exit $RC_FAIL +diff --git a/tests/quota.sh b/tests/quota.sh +index 398d442..55c764a 100755 +--- a/tests/quota.sh ++++ b/tests/quota.sh +@@ -3,7 +3,7 @@ + . wrapper-utils.sh + + # There are known bugs in quota accounting prior to 2.6.24 +-compare_kvers `uname -r` "2.6.24" ++compare_kvers "$(uname -r)" "2.6.24" + if [ $? -eq 1 ]; then + EXP_RC=$RC_FAIL + else +diff --git a/tests/readahead_reserve.sh b/tests/readahead_reserve.sh +index 5ab7400..861ef5a 100755 +--- a/tests/readahead_reserve.sh ++++ b/tests/readahead_reserve.sh +@@ -3,7 +3,7 @@ + . wrapper-utils.sh + + # readahead is known broken before 2.6.30 +-compare_kvers `uname -r` "2.6.30" ++compare_kvers "$(uname -r)" "2.6.30" + if [ $? -eq 1 ]; then + echo "FAIL (assumed) kernel bug" + exit $RC_FAIL +diff --git a/tests/wrapper-utils.sh b/tests/wrapper-utils.sh +index 2f6451d..79e7ed1 100644 +--- a/tests/wrapper-utils.sh ++++ b/tests/wrapper-utils.sh +@@ -1,12 +1,12 @@ + #!/bin/bash + + # Standard return codes +-RC_PASS=0 +-RC_CONFIG=1 +-RC_FAIL=2 +-RC_XFAIL=3 +-RC_XPASS=4 +-RC_BUG=99 ++export RC_PASS=0 ++export RC_CONFIG=1 ++export RC_FAIL=2 ++export RC_XFAIL=3 ++export RC_XPASS=4 ++export RC_BUG=99 + + function unexpected_pass() + { +@@ -28,10 +28,10 @@ function check_rc() + EXP_RC=$1 + ACT_RC=$2 + +- if [ $ACT_RC -eq $RC_PASS -a $EXP_RC -ne $RC_PASS ]; then ++ if [[ ($ACT_RC -eq $RC_PASS) && ($EXP_RC -ne $RC_PASS) ]]; then + unexpected_pass + return $RC_XPASS +- elif [ $EXP_RC -ne $RC_PASS -a $EXP_RC -eq $ACT_RC ]; then ++ elif [[ ($EXP_RC -ne $RC_PASS) && ($EXP_RC -eq $ACT_RC) ]]; then + expected_fail + return $RC_XFAIL + else +@@ -47,7 +47,7 @@ function exec_and_check() + EXP_RC=$1 + shift + +- OUTPUT=`$@` ++ OUTPUT=$("$@") + check_rc $EXP_RC $? + RC=$? + echo $OUTPUT +-- +2.25.2 + diff --git a/SOURCES/tests-include-missing-LDFLAGS-to-make-targets.patch b/SOURCES/tests-include-missing-LDFLAGS-to-make-targets.patch new file mode 100644 index 0000000..3095813 --- /dev/null +++ b/SOURCES/tests-include-missing-LDFLAGS-to-make-targets.patch @@ -0,0 +1,56 @@ +From 112f4b7266cae313e5a7f3d720360cdb294db496 Mon Sep 17 00:00:00 2001 +From: Rafael Aquini +Date: Sun, 12 Apr 2020 22:59:32 -0400 +Subject: [PATCH] tests: include missing LDFLAGS to make targets + +Signed-off-by: Rafael Aquini +--- + tests/Makefile | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/tests/Makefile b/tests/Makefile +index 9fd15eb..216942e 100644 +--- a/tests/Makefile ++++ b/tests/Makefile +@@ -120,32 +120,32 @@ shmoverride_linked.c: shmoverride_unlinked.c + obj32/%.o: %.c + @$(VECHO) CC32 $@ + @mkdir -p obj32 +- $(CC32) $(CPPFLAGS) $(CFLAGS) -o $@ -c $< ++ $(CC32) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ -c $< + + obj64/%.o: %.c + @$(VECHO) CC64 $@ + @mkdir -p obj64 +- $(CC64) $(CPPFLAGS) $(CFLAGS) -o $@ -c $< ++ $(CC64) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ -c $< + + obj32/%-pic.o: %.c + @$(VECHO) CC32 $@ + @mkdir -p obj32 +- $(CC32) $(CPPFLAGS) $(CFLAGS) -fPIC -o $@ -c $< ++ $(CC32) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -fPIC -o $@ -c $< + + obj64/%-pic.o: %.c + @$(VECHO) CC64 $@ + @mkdir -p obj64 +- $(CC64) $(CPPFLAGS) $(CFLAGS) -fPIC -o $@ -c $< ++ $(CC64) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -fPIC -o $@ -c $< + + obj32/libheapshrink.so: obj32/heapshrink-helper-pic.o + @$(VECHO) LD32 "(shared)" $@ + @mkdir -p obj32 +- $(CC32) -Wl,-soname,$(notdir $@) -shared -o $@ $^ ++ $(CC32) $(LDFLAGS) -Wl,-soname,$(notdir $@) -shared -o $@ $^ + + obj64/libheapshrink.so: obj64/heapshrink-helper-pic.o + @$(VECHO) LD64 "(shared)" $@ + @mkdir -p obj64 +- $(CC64) -Wl,-soname,$(notdir $@) -shared -o $@ $^ ++ $(CC64) $(LDFLAGS) -Wl,-soname,$(notdir $@) -shared -o $@ $^ + + $(LIB_TESTS:%=obj32/%): %: %.o obj32/testutils.o obj32/libtestutils.o + @$(VECHO) LD32 "(lib test)" $@ +-- +2.25.2 + diff --git a/SPECS/libhugetlbfs.spec b/SPECS/libhugetlbfs.spec index 004e5c2..7a92b44 100644 --- a/SPECS/libhugetlbfs.spec +++ b/SPECS/libhugetlbfs.spec @@ -1,6 +1,6 @@ Name: libhugetlbfs Version: 2.21 -Release: 12%{?dist} +Release: 17%{?dist} Summary: A library which provides easy access to huge pages of memory Group: System Environment/Libraries License: LGPLv2+ @@ -12,6 +12,7 @@ BuildRequires: glibc-static BuildRequires: python3-devel BuildRequires: execstack +%global _hardened_build 1 %define ldscriptdir %{_datadir}/%{name}/ldscripts # Patch0: build flags adjusts to build in stricter RHEL-8 buildroots @@ -29,6 +30,18 @@ Patch4: elflink-return-type-fix.patch # tests install and fix run_tests.py path for hugeadm tool call Patch5: tests-makefile-fix.patch Patch6: tests-run_tests-fix-hugeadm-path.patch +# Patch7: huge_page_setup_helper.py Python3 conversion +# Upstream tickets: +# Fedora: https://bugzilla.redhat.com/show_bug.cgi?id=1598570 +# libhugetlbfs: https://github.com/libhugetlbfs/libhugetlbfs/issues/35 +Patch7: huge_page_setup_helper-python3-convert.patch +# Fixes for downstream COVSCAN and RPMDiff execshield complaints: +Patch8: tests-fix-covscan-SHELLCHECK_WARNING-complaints.patch +Patch9: tests-include-missing-LDFLAGS-to-make-targets.patch +# Patch10: RHBZ#1832243 "hugeadm: ERROR: Invalid group specification (-1)" fix +# upstream pull request +# https://github.com/libhugetlbfs/libhugetlbfs/pull/48/commits/e7b3e6817421763eee37cb35ef8627bdd37a3690 +Patch10: 0001-wait-child-with-os-wait.patch # Upstream follow-ups for libhugetlbfs-2.21 Patch50: 0001-tests-Add-utility-to-check-for-a-minimum-number-of-o.patch @@ -138,6 +151,10 @@ to verify the libhugetlbfs functionality and validate the library. %patch4 -p1 %patch5 -p1 %patch6 -p1 +%patch7 -p1 +%patch8 -p1 +%patch9 -p1 +%patch10 -p1 pathfix.py -i %{__python3} -pn huge_page_setup_helper.py \ tests/run_tests.py @@ -160,6 +177,7 @@ execstack --clear-execstack %{buildroot}/%{_libdir}/libhugetlbfs_privutils.so # remove statically built libraries: rm -f $RPM_BUILD_ROOT/%{_libdir}/*.a +rm -f $RPM_BUILD_ROOT/%{_libdir}/libhugetlbfs/tests/*/*.link* # remove unused sbin directory rm -fr $RPM_BUILD_ROOT/%{_sbindir}/ @@ -211,6 +229,19 @@ rm -fr $RPM_BUILD_ROOT/%{_sbindir}/ %{_libdir}/libhugetlbfs %changelog +* Tue May 26 2020 Rafael Aquini - 2.21-17 +- hugeadm: "ERROR: Invalid group specification" fix (1832243) + +* Mon Apr 13 2020 Rafael Aquini - 2.21-16 +- libhugetlbfs-tests: harden the testcases to satisfy EXECSHIELD RPMDiff checks (1785296) + +* Thu Apr 9 2020 Rafael Aquini - 2.21-14 +- Follow up fix for harden the testcases (1785296) + +* Thu Apr 9 2020 Rafael Aquini - 2.21-13 +- Fix: huge_page_setup_helper.py: SyntaxError: Missing parentheses in call to 'print' (1821938) +- libhugetlbfs-tests: harden the testcases to satisfy EXECSHIELD RPMDiff checks (1785296) + * Tue Oct 29 2019 Rafael Aquini - 2.21-12 - Fix: Introduce libhugetlbfs-tests subpkg for CI tests (1688930) - trim repetitive changelogs for interim debug builds