diff mbox series

[walnascar] util-linux: fix agetty segfault issue

Message ID 20250611020701.1005436-1-yongxin.liu@windriver.com
State Under Review
Delegated to: Steve Sakoman
Headers show
Series [walnascar] util-linux: fix agetty segfault issue | expand

Commit Message

Yongxin Liu June 11, 2025, 2:07 a.m. UTC
From: Yongxin Liu <yongxin.liu@windriver.com>

Backport a commit from util-linux upstream to fix the following error.

agetty: segfault at 0 ip 00007fc65600295c sp 00007fffa8dd67e8 error 4 in libc.so.6

Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
---
 meta/recipes-core/util-linux/util-linux.inc   |  1 +
 ...tty-fix-stdin-conversion-to-tty-name.patch | 40 +++++++++++++++++++
 2 files changed, 41 insertions(+)
 create mode 100644 meta/recipes-core/util-linux/util-linux/0003-agetty-fix-stdin-conversion-to-tty-name.patch
diff mbox series

Patch

diff --git a/meta/recipes-core/util-linux/util-linux.inc b/meta/recipes-core/util-linux/util-linux.inc
index 4e8701ffdf..cbf148073b 100644
--- a/meta/recipes-core/util-linux/util-linux.inc
+++ b/meta/recipes-core/util-linux/util-linux.inc
@@ -40,6 +40,7 @@  SRC_URI = "${KERNELORG_MIRROR}/linux/utils/util-linux/v${MAJOR_VERSION}/util-lin
            file://fcntl-lock.c \
            file://0001-cfdisk-add-sector-size-commanand-line-option.patch \
            file://0002-sfdisk-add-sector-size-commanand-line-option.patch \
+           file://0003-agetty-fix-stdin-conversion-to-tty-name.patch \
            "
 
 SRC_URI[sha256sum] = "5c1daf733b04e9859afdc3bd87cc481180ee0f88b5c0946b16fdec931975fb79"
diff --git a/meta/recipes-core/util-linux/util-linux/0003-agetty-fix-stdin-conversion-to-tty-name.patch b/meta/recipes-core/util-linux/util-linux/0003-agetty-fix-stdin-conversion-to-tty-name.patch
new file mode 100644
index 0000000000..2766ee2c0d
--- /dev/null
+++ b/meta/recipes-core/util-linux/util-linux/0003-agetty-fix-stdin-conversion-to-tty-name.patch
@@ -0,0 +1,40 @@ 
+From bd6c104f931329ce6fbc5a1250c8c80a1d8223ee Mon Sep 17 00:00:00 2001
+From: Karel Zak <kzak@redhat.com>
+Date: Mon, 24 Feb 2025 13:37:04 +0100
+Subject: [PATCH] agetty: fix stdin conversion to tty name
+
+Addresses: https://github.com/util-linux/util-linux/issues/3304
+
+Upstream-Status: Backport
+[https://github.com/util-linux/util-linux/commit/bd6c104f931329ce6fbc5a1250c8c80a1d8223ee]
+Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
+---
+ term-utils/agetty.c | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/term-utils/agetty.c b/term-utils/agetty.c
+index aa859c27b..0dfe52c90 100644
+--- a/term-utils/agetty.c
++++ b/term-utils/agetty.c
+@@ -928,11 +928,15 @@ static void parse_args(int argc, char **argv, struct options *op)
+ 
+ 	/* resolve the tty path in case it was provided as stdin */
+ 	if (strcmp(op->tty, "-") == 0) {
++		int fd;
++		const char *name = op->tty;
++
+ 		op->tty_is_stdin = 1;
+-		int fd = get_terminal_name(NULL, &op->tty, NULL);
+-		if (fd < 0) {
++		fd = get_terminal_name(NULL, &name, NULL);
++		if (fd >= 0)
++			op->tty = name;	/* set real device name */
++		else
+ 			log_warn(_("could not get terminal name: %d"), fd);
+-		}
+ 	}
+ 
+ 	/* On virtual console remember the line which is used for */
+-- 
+2.46.2
+