Karel Zak [Mon, 2 Oct 2023 10:40:55 +0000 (12:40 +0200)]
Merge branch 'libblkid/drbd-simplify' of https://github.com/t-8ch/util-linux
* 'libblkid/drbd-simplify' of https://github.com/t-8ch/util-linux:
libblkid: (drbd) avoid unaligned accesses
include/c.h: add helpers for unaligned structure access
libblkid: (drbd) use magics
libblkid: (probe) allow superblock offset from end of device
libblkid: (cramfs) use magic hint
libblkid: (probe) add magic hint
libblkid: (drbd) validate size in standard minsz predicate
libblkid: (via_raid) validate size in standard minsz predicate
libblkid: (silicon_raid) validate size in standard minsz predicate
libblkid: (promise_raid) validate size in standard minsz predicate
libblkid: (nvidia_raid) validate size in standard minsz predicate
libblkid: (lsi_raid) validate size in standard minsz predicate
libblkid: (jmicron_raid) validate size in standard minsz predicate
libblkid: (isw_raid) validate size in standard minsz predicate
libblkid: (highpoint_raid) validate size in standard minsz predicate
libblkid: (ddf_raid) validate size in standard minsz predicate
libblkid: (adapted_raid) validate size in standard minsz predicate
libblkid: (probe) remove duplicate log
Karel Zak [Mon, 2 Oct 2023 10:40:38 +0000 (12:40 +0200)]
Merge branch 'analyzer2' of https://github.com/t-8ch/util-linux
* 'analyzer2' of https://github.com/t-8ch/util-linux:
libblkid: (probe) handle probe without chain gracefully
libsmartcols: (cell) consistently handle NULL argument
lib/idcache: always gracefully handle null cache
script-playutils: close filestream in case ignore_line() fails
lib/colors: correct documentation of colors_add_scheme()
treewide: use reallocarray to allocated memory that will be reallocated
Thomas Weißschuh [Sat, 30 Sep 2023 21:58:05 +0000 (23:58 +0200)]
libblkid: (drbd) use magics
Reuse more of the standard prober functionality.
This also avoids a potential unaligned access when comparing the
superblock magic as a number.
In case the superblock was already cached by a different loader the
return address may have been unaligned leading to undefined behavior.
Some functions allow passing NULL, some don't.
Even users internal to util-linux are passing NULL parameters to these
functions, even for ones where it is not allowed.
Unify the API. As there may be external users that rely on the
NULL-accepting behavior for some functions use it everywhere.
Thomas Weißschuh [Wed, 27 Sep 2023 20:04:40 +0000 (22:04 +0200)]
lib/colors: correct documentation of colors_add_scheme()
The function does not take ownership of its arguments and it does not
require those arguments to be heap-allocated.
In fact there is only one caller and it passed stack-allocated values.
Thomas Weißschuh [Mon, 25 Sep 2023 22:27:22 +0000 (00:27 +0200)]
libblkid: (ntfs) validate that sector_size is a power of two
The NTFS prober reads data based off an offset of the sector size.
If the sector size is unaligned and the read data is cached then other
probers can read unaligned values.
Sector sizes for NTFS actually only make sense as power-of-two so
validate that and as a sideeffect avoid the unaligned reads.
Also add the reproducer from OSS-Fuzz that found this issue.
Karel Zak [Mon, 25 Sep 2023 10:44:46 +0000 (12:44 +0200)]
Merge branch 'login-terminal' of https://github.com/stoeckmann/util-linux
* 'login-terminal' of https://github.com/stoeckmann/util-linux:
login: prevent undefined ioctl and tcsetattr calls
login: use correct terminal fd during setup
Karel Zak [Mon, 25 Sep 2023 10:35:48 +0000 (12:35 +0200)]
Merge branch 'timestamp' of https://github.com/t-8ch/util-linux
* 'timestamp' of https://github.com/t-8ch/util-linux:
lib/timeutils: (parse_timestamp_reference) report errors on overflow
lib/timeutils: print error if timestamp can't be parsed
lib/timeutils: test epoch timestamp
Karel Zak [Mon, 25 Sep 2023 10:22:54 +0000 (12:22 +0200)]
Merge branch 'lsfd--resolve-mqueue-nodev' of https://github.com/masatake/util-linux
* 'lsfd--resolve-mqueue-nodev' of https://github.com/masatake/util-linux:
lsfd: collect the device number for mqueue fs in the initialization stage
tests: (lsfd) show the entry for mqueue in /proc/self/mountinfo
Thomas Weißschuh [Fri, 22 Sep 2023 18:38:13 +0000 (20:38 +0200)]
ci: also use GCC 13 for sanitizer builds
Now that -Werror is not used anymore with -fsanitize the false-postives
are not a problem anymore and we get the better runtime checks of newer
sanitizers.
Thomas Weißschuh [Fri, 22 Sep 2023 09:19:24 +0000 (11:19 +0200)]
ci: don't combine -Werror and -fsanitize
As explained in [0]:
Note that sanitizers tend to increase the rate of false positive
warnings, most notably those around -Wmaybe-uninitialized. We recommend
against combining -Werror and [the use of] sanitizers.
login: prevent undefined ioctl and tcsetattr calls
Do not call tcsetattr if tcgetattr fails, because the content of
tt and ttt is undefined in that case.
Also do not just warn if ioctl fails, but also avoid calling it again
after tty has been re-opened.
I've solved this by setting struct variables to values which cannot be
valid at this point. If they do have these exact values, then the
calls will be prevented.
The function get_terminal_name iterates through standard file
descriptors until it finds a terminal. This means that it's not
guaranteed that STDIN_FILENO (i.e. 0) is actually a terminal.
Do not modify permissions on possible files. Instead, retrieve
the file descriptor which was used by get_terminal_name as well.
Proof of Concept (as root):
1. Create a temporary file with a mode different than TTYPERM.
```
install -m 700 /dev/null /tmp/test
ls -l /tmp/test
-rwx------ 1 root root 0 Sep 21 20:15 /tmp/test
```
2. Run login within a terminal with adjusted stdin.
```
login < /tmp/test
host login:
Hangup
```
3. Check permissions of input file.
```
ls -l /tmp/test
-rw------- 1 root root 0 Sep 21 20:15 /tmp/test
```
Karel Zak [Mon, 18 Sep 2023 10:10:01 +0000 (12:10 +0200)]
Merge branch 'lsfd--monitor-flag-for-poll-syscall' of https://github.com/masatake/util-linux
* 'lsfd--monitor-flag-for-poll-syscall' of https://github.com/masatake/util-linux:
tests: (test_mkfds::mkfds-multiplexing) make the output of ts_skip_subtest visible
tests: (test_mkfds::mkfds-multiplexing) dump /proc/$pid/syscall for debugging
lsfd: (man) write about XMODE.m and classical system calls for multiplexing
tests: (lsfd) add a case testing XMODE.m for classical syscalls for multiplexing
tests: (test_mkfds) add ppoll multiplexer
tests: (test_mkfds) add poll multiplexer
tests: (test_mkfds) add pselect6 and select multiplexers
tests: (test_mkfds) add a new factory "multiplexing"
tests: (test_mkfds) allow to add factory-made fds to the multiplexer as event source
tests: (test_mkfds, refactor) make the function for waiting events plugable
tests: (test_mkfds) include locale headers first to define _GNU_SOURCE
tests: (test_mkfds) use err() when a system call fails
lsfd: (comment) fix a typo
lsfd: mark XMODE.m on fds monitored by select(2) and pselect6(2)
lsfd: mark XMODE.m on fds monitored by poll(2) and ppoll(2)
lsfd: cache the result of checking whether "XMODE" column is enabled or not
procfs: add a helper function to access /proc/$pid/syscall
lsfd: (refactor) make the code for traversing threads reusable
lsfd: collect the device number for mqueue fs in the initialization stage
Though lsfd reads device minor numbers for file-systems having "nodev"
from /proc/$pid/mountinfo, we observed lsfd failed to resolve the
values of SOURCE column for mqueue files on s390 CI/CD env. It seems
that /proc/$pid/mountinfo doesn't provide enough information.
This change makes lsfd open a mqueue file in lsfd's initialization
stage as a new data source for resolving; lsfd can collect an
actually-used minor number from the file descriptor with fstat(2).
Karel Zak [Mon, 18 Sep 2023 09:14:38 +0000 (11:14 +0200)]
Merge branch 'vla-alloca' of https://github.com/t-8ch/util-linux
* 'vla-alloca' of https://github.com/t-8ch/util-linux:
buildsys: warn on usage of alloca()
more: remove usage of alloca()
buildsys: warn on usage of VLAs
lib/mbsedit: remove usage of VLA
lscpu: remove usage of VLA
fdisk: remove usage of VLA
libfdisk: (dos) remove usage of VLA
libblkid: (stratis) remove usage of VLA
lib/path: remove usage of VLA
Some lines in /proc/cpuinfo can be large e.g. flags and can then
truncate them in displaying them
BUFSIZ can vary quite a bit e.g. glibc/linux systems its 8192
but on musl/linux and OSX its 1024, on mingW it is 256, some tests e.g.
x86_64-64cpu-linux6.2.tar.gz has added really long line for cpu flags
line which is greater than 1024 characters and hence this test fails
on musl because lscpu -s reports truncated string