GNU bug report logs - #77232
[PATCH] Allow also to get attributes of the terminal line

Previous Next

Package: emacs;

Reported by: Werner Fink <werner <at> suse.de>

Date: Mon, 24 Mar 2025 08:54:01 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#77232: closed ([PATCH] Allow also to get attributes of the
 terminal line)
Date: Sat, 19 Apr 2025 15:13:01 +0000
[Message part 1 (text/plain, inline)]
Your message dated Sat, 19 Apr 2025 18:12:13 +0300
with message-id <86wmbg6v8y.fsf <at> gnu.org>
and subject line Re: bug#77232: [PATCH] Allow also to get attributes of the terminal line
has caused the debbugs.gnu.org bug report #77232,
regarding [PATCH] Allow also to get attributes of the terminal line
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
77232: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=77232
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Werner Fink <werner <at> suse.de>
To: bug-gnu-emacs <at> gnu.org
Cc: Werner Fink <werner <at> suse.de>
Subject: [PATCH] Allow also to get attributes of the terminal line
Date: Mon, 24 Mar 2025 09:51:47 +0100
as well as support mmap(2) flag MAP_DROPPABLE to allow
zero memory under memory pressure on newer Linux systems.

Otherwise a `make -k check` fails here in our build environment
with newer kernels and with /dev/console as physical device.

Signed-off-by: Werner Fink <werner <at> suse.de>
---
 lib-src/seccomp-filter.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git lib-src/seccomp-filter.c lib-src/seccomp-filter.c
index d6421f0ebdb..4dda7d8f020 100644
--- lib-src/seccomp-filter.c
+++ lib-src/seccomp-filter.c
@@ -42,6 +42,9 @@ variants of those files that can be used to sandbox Emacs before
 #include <stdlib.h>
 #include <stdint.h>
 #include <stdio.h>
+/* glibc uses internal an other TCGETS ioctl for its
+   tcgetattr(3) call with its internal struct termios */
+#include <asm/termbits.h>
 #include <time.h>
 
 #include <asm/prctl.h>
@@ -64,6 +67,11 @@ variants of those files that can be used to sandbox Emacs before
 #define ARCH_CET_STATUS 0x3001
 #endif
 
+/* https://github.com/torvalds/linux/commit/9651fcedf7b92d3f7f1ab179e8ab55b85ee10fc1 */
+#ifndef MAP_DROPPABLE
+#define MAP_DROPPABLE 0x0
+#endif
+
 static ATTRIBUTE_FORMAT_PRINTF (2, 3) _Noreturn void
 fail (int error, const char *format, ...)
 {
@@ -187,7 +195,7 @@ main (int argc, char **argv)
            some versions of the dynamic loader still use it.  Also
            allow allocating thread stacks.  */
         SCMP_A3_32 (SCMP_CMP_MASKED_EQ,
-                    ~(MAP_SHARED | MAP_PRIVATE | MAP_FILE
+                    ~(MAP_SHARED | MAP_PRIVATE | MAP_FILE | MAP_DROPPABLE
                       | MAP_ANONYMOUS | MAP_FIXED | MAP_DENYWRITE
                       | MAP_STACK | MAP_NORESERVE),
                     0));
@@ -274,6 +282,11 @@ main (int argc, char **argv)
         SCMP_A0_32 (SCMP_CMP_EQ, STDIN_FILENO),
         SCMP_A1_32 (SCMP_CMP_EQ, TIOCGPGRP));
 
+  /* Allow `tcgetattr' call of glibc on physical terminal devices. */
+  RULE (SCMP_ACT_ALLOW, SCMP_SYS (ioctl),
+        SCMP_A0_32 (SCMP_CMP_EQ, STDERR_FILENO),
+        SCMP_A1_32 (SCMP_CMP_EQ, TCGETS));
+
   /* Allow reading (but not setting) file flags.  */
   RULE (SCMP_ACT_ALLOW, SCMP_SYS (fcntl),
         SCMP_A1_32 (SCMP_CMP_EQ, F_GETFL));
-- 
2.35.3



[Message part 3 (message/rfc822, inline)]
From: Eli Zaretskii <eliz <at> gnu.org>
To: Philipp Stephani <p.stephani2 <at> gmail.com>
Cc: 77232-done <at> debbugs.gnu.org, werner <at> suse.de
Subject: Re: bug#77232: [PATCH] Allow also to get attributes of the terminal
 line
Date: Sat, 19 Apr 2025 18:12:13 +0300
> From: Philipp Stephani <p.stephani2 <at> gmail.com>
> Date: Sat, 19 Apr 2025 16:42:04 +0200
> Cc: "Dr. Werner Fink" <werner <at> suse.de>,
>  77232 <at> debbugs.gnu.org
> 
> 
> 
> > Am 19.04.2025 um 15:55 schrieb Eli Zaretskii <eliz <at> gnu.org>:
> > 
> > Ping! Philipp, any further comments?  Should we install this?
> 
> Yeah, looks good

Thanks, installed on the master branch, and closing the bug.


This bug report was last modified 28 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.