about summary refs log tree commit diff
path: root/apple-silicon-support
diff options
context:
space:
mode:
authorThomas Watson <twatson52@icloud.com>2024-02-26 19:55:50 -0600
committerThomas Watson <twatson52@icloud.com>2024-02-26 21:04:36 -0600
commite7f0326a5cc14f77a9d993a1cba89d30647ab6c9 (patch)
treeeef547448c857fafb897cc75466e5c73715456db /apple-silicon-support
parente3628070c9794955fdd3d54d0b1137dd87f82827 (diff)
downloadnixlib-e7f0326a5cc14f77a9d993a1cba89d30647ab6c9.tar
nixlib-e7f0326a5cc14f77a9d993a1cba89d30647ab6c9.tar.gz
nixlib-e7f0326a5cc14f77a9d993a1cba89d30647ab6c9.tar.bz2
nixlib-e7f0326a5cc14f77a9d993a1cba89d30647ab6c9.tar.lz
nixlib-e7f0326a5cc14f77a9d993a1cba89d30647ab6c9.tar.xz
nixlib-e7f0326a5cc14f77a9d993a1cba89d30647ab6c9.tar.zst
nixlib-e7f0326a5cc14f77a9d993a1cba89d30647ab6c9.zip
linux-asahi: add patch to fix coreutils test suite
Diffstat (limited to 'apple-silicon-support')
-rw-r--r--apple-silicon-support/packages/linux-asahi/0001-fs-fcntl-accept-more-values-as-F_DUPFD_CLOEXEC-args.patch40
-rw-r--r--apple-silicon-support/packages/linux-asahi/default.nix3
2 files changed, 43 insertions, 0 deletions
diff --git a/apple-silicon-support/packages/linux-asahi/0001-fs-fcntl-accept-more-values-as-F_DUPFD_CLOEXEC-args.patch b/apple-silicon-support/packages/linux-asahi/0001-fs-fcntl-accept-more-values-as-F_DUPFD_CLOEXEC-args.patch
new file mode 100644
index 000000000000..647fdb6c5340
--- /dev/null
+++ b/apple-silicon-support/packages/linux-asahi/0001-fs-fcntl-accept-more-values-as-F_DUPFD_CLOEXEC-args.patch
@@ -0,0 +1,40 @@
+From 0fcdbacd8b06c24f5761a0cf9cb0c43cad05c19b Mon Sep 17 00:00:00 2001
+From: Thomas Watson <twatson52@icloud.com>
+Date: Mon, 26 Feb 2024 19:51:12 -0600
+Subject: [PATCH] fs/fcntl: accept more values as F_DUPFD_CLOEXEC args
+
+libwebrtc doesn't pass anything as the arg to this function so the
+minimum fd ends up as random garbage. If it's bigger than the maximum
+fd, which is likely, then the duplication fails, and libwebrtc breaks.
+
+The previous patch (081abc5fa701738699705a6c0a41c824df77cb37) rejects
+args >= 1024 (the default soft max fd) and instead subtitutes a minimum
+fd of 0 to allow such requests to succeed.
+
+However, gnulib's test suite can pass the following values and expects
+them to fail; this patch prevents those from succeeding:
+* -1 (hard-coded)
+* 1024 (`ulimit -n` value by default)
+* 1048576 (`ulimit -n` value in Nix build sandbox)
+
+Hopefully the garbage values libwebrtc passes do not match very often.
+---
+ fs/fcntl.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/fs/fcntl.c b/fs/fcntl.c
+index f18f87419445..65a6861476ec 100644
+--- a/fs/fcntl.c
++++ b/fs/fcntl.c
+@@ -326,7 +326,7 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
+ 		err = f_dupfd(argi, filp, 0);
+ 		break;
+ 	case F_DUPFD_CLOEXEC:
+-		if (arg >= 1024)
++		if ((arg > 1024) && (argi != 1048576) && (argi != -1))
+ 			argi = 0; /* Lol libwebrtc */
+ 		err = f_dupfd(argi, filp, O_CLOEXEC);
+ 		break;
+-- 
+2.43.0
+
diff --git a/apple-silicon-support/packages/linux-asahi/default.nix b/apple-silicon-support/packages/linux-asahi/default.nix
index 780178f3284e..36e7c0758a85 100644
--- a/apple-silicon-support/packages/linux-asahi/default.nix
+++ b/apple-silicon-support/packages/linux-asahi/default.nix
@@ -100,6 +100,9 @@ let
       };
 
       kernelPatches = [
+        { name = "coreutils-fix";
+          patch = ./0001-fs-fcntl-accept-more-values-as-F_DUPFD_CLOEXEC-args.patch;
+        }
         # speaker enablement; we assert on the relevant lsp-plugins patch
         # before installing speakersafetyd to let the speakers work
         { name = "speakers-1";