1
0
forked from pool/util-linux

Backport fixes from SLE15

- Skip aarch64 decode path for rest of the architectures
  (bsc#1229476, util-linux-lscpu-skip-aarch64-decode.patch).
- agetty: Prevent login cursor escape (bsc#1194818,
  util-linux-agetty-prevent-cursor-escape.patch).
- Document unexpected side effects of lazy destruction
  (bsc#1159034, util-linux-umount-losetup-lazy-destruction.patch,
  util-linux-umount-losetup-lazy-destruction-generated.patch).
- And add more bug references.
This commit is contained in:
Stanislav Brabec 2024-11-17 21:36:44 +00:00 committed by Jan Engelhardt
parent 7c038e86c6
commit 1f607dd355
6 changed files with 292 additions and 2 deletions

View File

@ -0,0 +1,44 @@
From 20b405c0fea29675e1fb54b894eb1c18459f9d50 Mon Sep 17 00:00:00 2001
From: Stanislav Brabec <sbrabec@suse.cz>
Date: Sun, 21 Jul 2024 15:01:42 +0200
Subject: [PATCH] agetty: Prevent cursor escape
Starting with 5de97519, it is possible to escape the login dialog on the
screen by arrow characters or using escape sequences.
Since full processing of escape sequences and ignore them would be
complicated, use a work around: instead of sending ESC to output, send a
printable character.
It could cause a rendering regression in a very obscure condition: compiled
without IUTF8, encoding is ISO-11548-1 and BRAILLE PATTERN DOTS-1245 is
part of login name. I believe that it is out of supported combinations.
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
---
term-utils/agetty.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index b28b197ff..500e0992f 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -2289,7 +2289,14 @@ static char *get_logname(struct issue *ie, struct options *op, struct termios *t
if ((size_t)(bp - logname) >= sizeof(logname) - 1)
log_err(_("%s: input overrun"), op->tty);
if ((tp->c_lflag & ECHO) == 0)
- write_all(1, &c, 1); /* echo the character */
+ /* Visualize escape sequence instead of its execution */
+ if (ascval == CTL('['))
+ /* Ideally it should be "\xe2\x90\x9b"
+ * if (op->flags & (F_UTF8)),
+ * but only some fonts contain it */
+ write_all(1, "^[", 2);
+ else
+ write_all(1, &c, 1); /* echo the character */
*bp++ = ascval; /* and store it */
break;
}
--
2.45.2

View File

@ -0,0 +1,158 @@
From 50a3efab6d126b28fcdcc28f1a0cd5cd596ae357 Mon Sep 17 00:00:00 2001
From: "Pratik R. Sampat" <pratikrajesh.sampat@amd.com>
Date: Mon, 22 Jul 2024 16:00:46 +0000
Subject: [PATCH] lscpu: Skip aarch64 decode path for rest of the architectures
lscpu behaves differently when run sudo vs non-sudo on AMD architectures.
On sudo runs, it adds a BIOS model name and BIOS CPU family which it
does not add for the latter. However since this parsing from the DMI is
primarily catered to aarch64, for AMD platform the BIOS model name is
printed out as follows "AMD XXX Processor *Unknown* CPU @ X.XGHz" due
to the part number is not populated on the platform.
The issue boils down to an unconditional call to arm_decode() which
attempts to read the DMI path and populate the processor information
such as processor version and part number which is set to Unknown on AMD
CPUs.
81d6de9 (lscpu: remove the old code) changed the DMI path from
/sys/firmware/dmi/entries/4-0/raw (non-existent) to
/sys/firmware/dmi/tables/dmi (existent) which has brought this latent
issue to light as DMI was starting to be parsed incorrectly.
Therefore, do not perform aarch64 parsing for other architectures.
Before
------
$ lscpu
Vendor ID: AuthenticAMD
Model name: AMD EPYC XXXX X-Core Processor
CPU family: 26
$ sudo lscpu
Vendor ID: AuthenticAMD
BIOS Vendor ID: Advanced Micro Devices, Inc.
Model name: AMD EPYC XXXX X-Core Processor
BIOS Model name: AMD EPYC XXXX X-Core Processor Unknown CPU @ X.XGHz
BIOS CPU family: 107
CPU family: 26
After
-----
$ lscpu
Vendor ID: AuthenticAMD
Model name: AMD EPYC XXXX X-Core Processor
CPU family: 26
$ sudo lscpu
Vendor ID: AuthenticAMD
Model name: AMD EPYC XXXX X-Core Processor
CPU family: 26
Fixes: 81d6de9 ("lscpu: remove the old code")
Co-developed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Pratik R. Sampat <pratikrajesh.sampat@amd.com>
---
sys-utils/lscpu-arm.c | 37 ++++++++++++++++++++++++++++++++++++-
sys-utils/lscpu.c | 3 ++-
sys-utils/lscpu.h | 2 ++
3 files changed, 40 insertions(+), 2 deletions(-)
Contains parts of:
commit 5d1129e6879a05aa9ac5804ffc8ace22cda735c1
Author: Karel Zak <kzak@redhat.com>
Date: Mon Jul 29 10:21:28 2024 +0200
Index: util-linux-2.39.3/sys-utils/lscpu-arm.c
===================================================================
--- util-linux-2.39.3.orig/sys-utils/lscpu-arm.c
+++ util-linux-2.39.3/sys-utils/lscpu-arm.c
@@ -332,14 +332,49 @@ static int parse_id(const char *str)
#define parse_model_id(_cxt) (parse_id((_cxt)->model))
+static inline int get_implementer_id(struct lscpu_cputype *ct)
+{
+ if (ct->vendor_id)
+ return ct->vendor_id;
+ return parse_id(ct->vendor);
+}
+
static inline int parse_implementer_id(struct lscpu_cputype *ct)
{
+ int id;
+
if (ct->vendor_id)
return ct->vendor_id;
- ct->vendor_id = parse_id(ct->vendor);
+ id = get_implementer_id(ct);
+ if (id <= 0)
+ return id;
+
+ ct->vendor_id = id;
return ct->vendor_id;
}
+int is_arm(struct lscpu_cxt *cxt)
+{
+ size_t i;
+
+ if (is_live(cxt))
+ return strcmp(cxt->arch->name, "aarch64") == 0;
+
+ /* dump; assume ARM if vendor ID is known */
+ for (i = 0; i < cxt->ncputypes; i++) {
+
+ int j, id = get_implementer_id(cxt->cputypes[i]);
+ if (id <= 0)
+ continue;
+ for (j = 0; hw_implementer[j].id != -1; j++) {
+ if (hw_implementer[j].id == id)
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
/*
* Use model and vendor IDs to decode to human readable names.
*/
Index: util-linux-2.39.3/sys-utils/lscpu.c
===================================================================
--- util-linux-2.39.3.orig/sys-utils/lscpu.c
+++ util-linux-2.39.3/sys-utils/lscpu.c
@@ -1371,7 +1371,8 @@ int main(int argc, char *argv[])
lscpu_read_numas(cxt);
lscpu_read_topology(cxt);
- lscpu_decode_arm(cxt);
+ if (is_arm(cxt))
+ lscpu_decode_arm(cxt);
cxt->virt = lscpu_read_virtualization(cxt);
Index: util-linux-2.39.3/sys-utils/lscpu.h
===================================================================
--- util-linux-2.39.3.orig/sys-utils/lscpu.h
+++ util-linux-2.39.3/sys-utils/lscpu.h
@@ -252,6 +252,8 @@ struct lscpu_cxt {
int is_cluster; /* For aarch64 if the machine doesn't have ACPI PPTT */
};
+#define is_live(_cxt) (!(_cxt)->noalive)
+
#define is_cpu_online(_cxt, _cpu) \
((_cxt) && (_cpu) && (_cxt)->online && \
CPU_ISSET_S((_cpu)->logical_id, (_cxt)->setsize, (_cxt)->online))
@@ -260,6 +262,8 @@ struct lscpu_cxt {
((_cxt) && (_cpu) && (_cxt)->present && \
CPU_ISSET_S((_cpu)->logical_id, (_cxt)->setsize, (_cxt)->present))
+int is_arm(struct lscpu_cxt *cxt);
+
struct lscpu_cputype *lscpu_new_cputype(void);
void lscpu_ref_cputype(struct lscpu_cputype *ct);
void lscpu_unref_cputype(struct lscpu_cputype *ct);

View File

@ -0,0 +1,22 @@
--- util-linux-2.39.3/sys-utils/umount.8 2023-12-04 20:34:55.708989211 +0100
+++ util-linux-2.39.3.patched/sys-utils/umount.8 2024-08-01 19:46:58.227874568 +0200
@@ -156,6 +156,8 @@
The \fBumount\fP command will automatically detach loop device previously initialized by \fBmount\fP(8) command independently of \fI/etc/mtab\fP.
.sp
In this case the device is initialized with "autoclear" flag (see \fBlosetup\fP(8) output for more details), otherwise it\(cqs necessary to use the option \fB\-\-detach\-loop\fP or call \fBlosetup \-d\fP \fIdevice\fP. The autoclear feature is supported since Linux 2.6.25.
+.sp
+Note that since Linux v3.7 kernel uses "lazy device destruction". The system just marks the loop device by autoclear flag and destroys it later. If you need to wait for a complete removal of the loop device, call \fBudevadm settle\fP after \fBumount\fP.
.SH "EXTERNAL HELPERS"
.sp
The syntax of external unmount helpers is:
--- util-linux-2.39.3/sys-utils/losetup.8 2023-12-04 20:34:54.926993943 +0100
+++ util-linux-2.39.3.patched/sys-utils/losetup.8 2024-08-01 19:37:02.084188151 +0200
@@ -74,7 +74,7 @@
.sp
\fB\-d\fP, \fB\-\-detach\fP \fIloopdev\fP...
.RS 4
-Detach the file or device associated with the specified loop device(s). Note that since Linux v3.7 kernel uses "lazy device destruction". The detach operation does not return \fBEBUSY\fP error anymore if device is actively used by system, but it is marked by autoclear flag and destroyed later.
+Detach the file or device associated with the specified loop device(s). Note that since Linux v3.7 kernel uses "lazy device destruction". The detach operation does not return \fBEBUSY\fP error anymore if device is actively used by system, but it is marked by autoclear flag and destroyed later. Even if the device is not used, the loop device can be destroyed later. If you need to wait for a complete removal of the loop device, call \fBudevadm settle\fP after \fBlosetup\fP.
.RE
.sp
\fB\-D\fP, \fB\-\-detach\-all\fP

View File

@ -0,0 +1,41 @@
From fc67f18be51f57ee9a59a0f8f7ad16f284a24a3e Mon Sep 17 00:00:00 2001
From: Stanislav Brabec <sbrabec@suse.cz>
Date: Wed, 19 Jun 2024 17:31:34 +0200
Subject: [PATCH] umount, losetup: Document loop destroy behavior
The loop device detach runs asynchronously in the background. It can cause
unexpected errors. Document the possible existence of the loop device after
exit of losetup -d or umount and need of "udevadm settle".
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
---
sys-utils/losetup.8.adoc | 2 +-
sys-utils/umount.8.adoc | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
Index: util-linux-2.39.3/sys-utils/losetup.8.adoc
===================================================================
--- util-linux-2.39.3.orig/sys-utils/losetup.8.adoc
+++ util-linux-2.39.3/sys-utils/losetup.8.adoc
@@ -54,7 +54,7 @@ The _size_ and _offset_ arguments may be
Show the status of all loop devices. Note that not all information is accessible for non-root users. See also *--list*. The old output format (as printed without *--list*) is deprecated.
*-d*, *--detach* _loopdev_...::
-Detach the file or device associated with the specified loop device(s). Note that since Linux v3.7 kernel uses "lazy device destruction". The detach operation does not return *EBUSY* error anymore if device is actively used by system, but it is marked by autoclear flag and destroyed later.
+Detach the file or device associated with the specified loop device(s). Note that since Linux v3.7 kernel uses "lazy device destruction". The detach operation does not return *EBUSY* error anymore if device is actively used by system, but it is marked by autoclear flag and destroyed later. Even if the device is not used, the loop device can be destroyed later. If you need to wait for a complete removal of the loop device, call *udevadm settle* after *losetup*.
*-D*, *--detach-all*::
Detach all associated loop devices.
Index: util-linux-2.39.3/sys-utils/umount.8.adoc
===================================================================
--- util-linux-2.39.3.orig/sys-utils/umount.8.adoc
+++ util-linux-2.39.3/sys-utils/umount.8.adoc
@@ -127,6 +127,8 @@ The *umount* command will automatically
In this case the device is initialized with "autoclear" flag (see *losetup*(8) output for more details), otherwise it's necessary to use the option *--detach-loop* or call *losetup -d* _device_. The autoclear feature is supported since Linux 2.6.25.
+Note that since Linux v3.7 kernel uses "lazy device destruction". The system just marks the loop device by autoclear flag and destroys it later. If you need to wait for a complete removal of the loop device, call *udevadm settle* after *umount*.
+
== EXTERNAL HELPERS
The syntax of external unmount helpers is:

View File

@ -1,3 +1,14 @@
-------------------------------------------------------------------
Sun Nov 17 21:06:01 UTC 2024 - Stanislav Brabec <sbrabec@suse.com>
- Skip aarch64 decode path for rest of the architectures
(bsc#1229476, util-linux-lscpu-skip-aarch64-decode.patch).
- agetty: Prevent login cursor escape (bsc#1194818,
util-linux-agetty-prevent-cursor-escape.patch).
- Document unexpected side effects of lazy destruction
(bsc#1159034, util-linux-umount-losetup-lazy-destruction.patch,
util-linux-umount-losetup-lazy-destruction-generated.patch).
-------------------------------------------------------------------
Mon Oct 21 23:25:19 UTC 2024 - Stanislav Brabec <sbrabec@suse.com>
@ -12,6 +23,7 @@ Mon Aug 5 22:14:13 UTC 2024 - Stanislav Brabec <sbrabec@suse.com>
* libmount: improving robustness in reading kernel messages,
add pidfs to pseudo fs list
* lscpu: New Arm Cortex part numbers
fix hang of lscpu -e (bsc#1225598)
* lsfd: Refactor the pidfd logic, support pidfs
(obsoletes
0001-include-Include-unistd.h-in-pidfd-utils.h-for-syscal.patch,
@ -111,7 +123,7 @@ Thu Apr 4 12:27:18 UTC 2024 - Thorsten Kukuk <kukuk@suse.com>
* blockdev: add support for BLKGETZONESZ
* cfdisk: ask y/n before wipe
* cfdisk: properly handle out-of-order partitions during resize
* chcpu: document limitations of -g
* chcpu: document limitations of -g (bsc#1218609)
* chsh: use libeconf to read /etc/shells
* column: fix -l
* column: fix memory leak
@ -134,10 +146,12 @@ Thu Apr 4 12:27:18 UTC 2024 - Thorsten Kukuk <kukuk@suse.com>
* lsblk: add --highlight
* lsblk: add --list-columns
* lsclocks: new command to show clocks
* lscpu: even more Arm part numbers
* lscpu: even more Arm part numbers (bsc#1223605)
* mkfs.minix: handle 64bit time on 32bit system
* mkswap: implement --file
* mkswap: implement --offset
* more: clea processes not cleaned up after failed SSH session
using up 100% CPU (bsc#1220117)
* mount: add --map-users and --map-groups convenience options
* nsenter: add option `-c` to join the cgroup of target process
* setarch: add riscv64/riscv32 support
@ -145,6 +159,8 @@ Thu Apr 4 12:27:18 UTC 2024 - Thorsten Kukuk <kukuk@suse.com>
* uuidd: add cont_clock persistence
* uuidgen: add option --count
* wall: query logind for list of users with tty (#2088)
properly neutralize escape sequences (bsc#1221831,
CVE-2024-28085)
* write: query logind for list of users with tty (#2088)
* libuuid: improved support for 64-bit time
- skip-lsfd-tests-PR2888.patch: skip some lsfd tests which OBS does
@ -264,6 +280,7 @@ Fri Jul 28 14:47:15 UTC 2023 - Goldwyn Rodrigues <rgoldwyn@suse.com>
- Re-add 0001-Revert-libblkid-try-LUKS2-first-when-probing.patch
because the patch is not in 2.39.1
(bsc#1224393, boo#1213227, boo#1213361)
-------------------------------------------------------------------
Wed Jul 26 01:22:20 UTC 2023 - Neil Brown <nfbrown@suse.com>

View File

@ -110,6 +110,14 @@ Patch2: Add-documentation-on-blacklisted-modules-to-mount-8-.patch
# PATCH-FIX-SUSE util-linux-bash-completion-su-chsh-l.patch bsc1172427 -- Fix "su -s" bash completion.
Patch3: util-linux-bash-completion-su-chsh-l.patch
Patch5: static_lib.patch
# PATCH-FIX-UPSTREAM util-linux-umount-losetup-lazy-destruction.patch bsc1159034 sbrabec@suse.com -- Document unexpected side effects of lazy destruction.
Patch12: util-linux-umount-losetup-lazy-destruction.patch
# PATCH-FIX-UPSTREAM util-linux-umount-losetup-lazy-destruction-generated.patch bsc1159034 sbrabec@suse.com -- Document unexpected side effects of lazy destruction. (patch generated file)
Patch13: util-linux-umount-losetup-lazy-destruction-generated.patch
# PATCH-FIX-UPSTREAM util-linux-agetty-prevent-cursor-escape.patch bsc1194818 sbrabec@suse.com -- Prevent cursor escape using arrows or escape sequences.
Patch14: util-linux-agetty-prevent-cursor-escape.patch
# PATCH-FIX-UPSTREAM util-linux-lscpu-skip-aarch64-decode.patch bsc1229476 sbrabec@suse.com -- Skip aarch64 decode path for rest of the architectures.
Patch15: util-linux-lscpu-skip-aarch64-decode.patch
BuildRequires: audit-devel
BuildRequires: bc
BuildRequires: binutils-devel