[gentoo-dev] [PATCH] profiles/features/hardened/amd64: enable USE=pic

2023-11-24 Thread Sam James
There's no real reason not to do this. The status quo is wrong for when
we're doing multilib 32-bit builds on x86, and we already have to undo
this on musl because its handling for TEXTRELs is limited (see bug #707660).

(I noted my intention to do this in 80a72bac2350811712c018b68f61a031736c579f
as well.)

This seems to have been added originally in 
e718e1dc1781b3bb5cd80233c217aea3b0e46755
and bb28d08f1cf8cf16f6e57929a8de6b7c85bbe714 (git graft commit).

Bug: https://bugs.gentoo.org/707660
Bug: https://bugs.gentoo.org/913412
Signed-off-by: Sam James 
---
 profiles/features/hardened/amd64/make.defaults | 2 +-
 profiles/features/hardened/amd64/no-multilib/make.defaults | 6 --
 2 files changed, 1 insertion(+), 7 deletions(-)
 delete mode 100644 profiles/features/hardened/amd64/no-multilib/make.defaults

diff --git a/profiles/features/hardened/amd64/make.defaults 
b/profiles/features/hardened/amd64/make.defaults
index e8f0bdf8ba650..89a7242c35648 100644
--- a/profiles/features/hardened/amd64/make.defaults
+++ b/profiles/features/hardened/amd64/make.defaults
@@ -1,4 +1,4 @@
 # Copyright 1999-2023 Gentoo Authors.
 # Distributed under the terms of the GNU General Public License v2
 
-USE="cet -pic"
+USE="cet"
diff --git a/profiles/features/hardened/amd64/no-multilib/make.defaults 
b/profiles/features/hardened/amd64/no-multilib/make.defaults
deleted file mode 100644
index 1dd0a2a0f7e0d..0
--- a/profiles/features/hardened/amd64/no-multilib/make.defaults
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright 1999-2011 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-# We don't need to have pic on
-USE="-pic"
-
-- 
2.43.0




[gentoo-dev] [PATCH] kernel-build.eclass: copy module signing key to tempdir in, pkg_setup

2023-11-24 Thread Andrew Ammerlaan

Patch from https://github.com/gentoo/gentoo/pull/33850

Note that we only have this problem here, and not in linux-mod-r1.eclass 
or secureboot.eclass, because in the latter two eclasses the signing is 
done in src_install while the kernel build system requires the key in 
src_compile. src_install has root privileges, src_compile does not.


This is a better solution then simply having the key readable by the 
portage user on the file system directly.


Best regards,
Andrew

From aacf155e66f42a4ccd33a666e29210042659ad90 Mon Sep 17 00:00:00 2001
From: Violet Purcell 
Date: Thu, 16 Nov 2023 12:23:16 -0500
Subject: [PATCH] kernel-build.eclass: copy module signing key to tempdir 
in pkg_setup


Previously, it was being copied in src_prepare, and thus would fail if
the signing key was not readable by portage:portage. This commit makes
kernel-build.eclass instead copy the signing key in pkg_setup, and then
correct the permissions.

Signed-off-by: Violet Purcell 
---
 eclass/kernel-build.eclass | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass
index 4f7e4d0477393..6f18bc1dc9694 100644
--- a/eclass/kernel-build.eclass
+++ b/eclass/kernel-build.eclass
@@ -114,6 +114,16 @@ kernel-build_pkg_setup() {
python-any-r1_pkg_setup
if [[ ${KERNEL_IUSE_MODULES_SIGN} ]]; then
secureboot_pkg_setup
+   if [[ -e ${MODULES_SIGN_KEY} && ${MODULES_SIGN_KEY} != pkcs11:* 
]]; then
+			if [[ -e ${MODULES_SIGN_CERT} && ${MODULES_SIGN_CERT} != 
${MODULES_SIGN_KEY} ]]; then
+cat "${MODULES_SIGN_CERT}" "${MODULES_SIGN_KEY}" > 
"${T}/kernel_key.pem" || die

+   else
+   cp "${MODULES_SIGN_KEY}" "${T}/kernel_key.pem" 
|| die
+   fi
+   chown portage:portage "${T}/kernel_key.pem" || die
+   chmod 0400 "${T}/kernel_key.pem" || die
+   export MODULES_SIGN_KEY="${T}/kernel_key.pem"
+   fi
fi
 }

@@ -427,13 +437,6 @@ kernel-build_merge_configs() {
CONFIG_MODULE_SIG_FORCE=y
CONFIG_MODULE_SIG_${MODULES_SIGN_HASH^^}=y
EOF
-   if [[ -e ${MODULES_SIGN_KEY} && -e ${MODULES_SIGN_CERT} 
&&
-   ${MODULES_SIGN_KEY} != ${MODULES_SIGN_CERT} &&
-   ${MODULES_SIGN_KEY} != pkcs11:* ]]
-   then
-cat "${MODULES_SIGN_CERT}" "${MODULES_SIGN_KEY}" > 
"${T}/kernel_key.pem" || die

-   MODULES_SIGN_KEY="${T}/kernel_key.pem"
-   fi
 			if [[ ${MODULES_SIGN_KEY} == pkcs11:* || -r ${MODULES_SIGN_KEY} ]]; 
then

echo 
"CONFIG_MODULE_SIG_KEY=\"${MODULES_SIGN_KEY}\"" \
>> "${WORKDIR}/modules-sign.config"