]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
4 years agoscript: cleanup --echo
Soumendra Ganguly [Thu, 27 Aug 2020 09:50:25 +0000 (11:50 +0200)] 
script: cleanup --echo

Permanently turn off current stdin ECHO when it is a terminal and enable setting slave ECHO instead.
Fix other minor typos, update documentation.

[kzak@redhat.com: - remove irrelevant changes
                  - keep --echo argument unchanged]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agobash-completion: add column --table-columns-limit
Karel Zak [Tue, 25 Aug 2020 12:23:28 +0000 (14:23 +0200)] 
bash-completion: add column --table-columns-limit

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agocolumn: add --table-columns-limit
Karel Zak [Tue, 25 Aug 2020 12:15:36 +0000 (14:15 +0200)] 
column: add --table-columns-limit

$ echo -e 'AAA:BBB:CCC:DDD\n' | ./column -t -s ':'
AAA  BBB  CCC  DDD

$ echo -e 'AAA:BBB:CCC:DDD\n' | ./column -t -s ':' -l 2
AAA  BBB:CCC:DDD

$ echo -e 'AAA:BBB:CCC:DDD\n' | ./column -t -s ':' -l 3
AAA  BBB  CCC:DDD

Addresses: https://github.com/karelzak/util-linux/issues/1124
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'fix-sfdisk-json' of https://github.com/adriaandegroot/util-linux
Karel Zak [Tue, 25 Aug 2020 09:29:16 +0000 (11:29 +0200)] 
Merge branch 'fix-sfdisk-json' of https://github.com/adriaandegroot/util-linux

* 'fix-sfdisk-json' of https://github.com/adriaandegroot/util-linux:
  Generate valid JSON if partition table is empty

4 years agomount, umount: restore environ[] after suid drop
Karel Zak [Tue, 25 Aug 2020 08:48:29 +0000 (10:48 +0200)] 
mount, umount: restore environ[] after suid drop

The commands mount and umount sanitize environment variables as it
works with suid permissions by default. Since v2.36 it's possible
that the commands drop the permissions and continue as regular user.
It seems we also need to restore the original environ to keep things
consistent for users (e.g. HOME=).

The implementation is pretty simple -- it keeps in memory removed
variables and use it after switch to non-suid mode.

Addresses: https://github.com/karelzak/util-linux/issues/880
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/env: add function to save and restore unwanted variables
Karel Zak [Tue, 25 Aug 2020 08:43:07 +0000 (10:43 +0200)] 
lib/env: add function to save and restore unwanted variables

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoGenerate valid JSON if partition table is empty
Adriaan de Groot [Mon, 24 Aug 2020 21:30:35 +0000 (23:30 +0200)] 
Generate valid JSON if partition table is empty

When the partition table is present **but** empty, the existing code would output fields followed by a `,` , on the assumption that the list of partitions would follow. But if the list of partitions is empty, it is skipped, leading to output like this:

```
{
  "partitiontable": {
      "label":"gpt",
      "id":"1F9E80D9-DD78-024F-94A3-B61EC82B18C8",
      "device":"/dev/sdb",
      "unit":"sectors",
      "firstlba":2048,
      "lastlba":30949342,
      "sectorsize":512,
  }
}
```

Note the `512,` on the *sectorsize* line.

This is invalid JSON for some parsers, which choke on it.

Avoid this, by checking when outputting the last separator: if there's no table, or there is a table but it is empty, then just put a newline, otherwise use the old path of comma-newline and assume there's going to be a list of partitions after.

4 years agolibfdisk: add systemd-homed user's home GPT partition type
nl6720 [Sat, 22 Aug 2020 12:16:27 +0000 (15:16 +0300)] 
libfdisk: add systemd-homed user's home GPT partition type

See https://systemd.io/HOME_DIRECTORY/ .
Additionally update the URL of the Boot Loader Specification.

Signed-off-by: nl6720 <nl6720@gmail.com>
4 years agolibmount: fix tab parser for badly terminated lines
Karel Zak [Mon, 17 Aug 2020 14:33:59 +0000 (16:33 +0200)] 
libmount: fix tab parser for badly terminated lines

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: cover the code parsing comments
Evgeny Vereshchagin [Thu, 13 Aug 2020 05:20:14 +0000 (05:20 +0000)] 
tests: cover the code parsing comments

It seems to be failing with
```
AddressSanitizer:DEADLYSIGNAL
=================================================================
==13==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x00000055f428 bp 0x7ffc3743a170 sp 0x7ffc3743a080 T0)
==13==The signal is caused by a WRITE memory access.
==13==Hint: address points to the zero page.
SCARINESS: 10 (null-deref)
    #0 0x55f428 in mnt_table_parse_next /src/util-linux/libmount/src/tab_parse.c:587:6
    #1 0x55c200 in __table_parse_stream /src/util-linux/libmount/src/tab_parse.c:737:8
    #2 0x55be38 in mnt_table_parse_stream /src/util-linux/libmount/src/tab_parse.c:809:8
    #3 0x5511ff in LLVMFuzzerTestOneInput /src/util-linux/libmount/src/fuzz.c:21:16
    #4 0x458a31 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:558:15
    #5 0x458175 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:470:3
    #6 0x45a117 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:770:7
    #7 0x45a319 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:799:3
    #8 0x44a055 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:846:6
    #9 0x471bf2 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:19:10
    #10 0x7fe3bd93b83f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
    #11 0x41f208 in _start (/out/test_mount_fuzz+0x41f208)

DEDUP_TOKEN: mnt_table_parse_next--__table_parse_stream--mnt_table_parse_stream
```

4 years agoMerge branch 'patch-1' of https://github.com/8vasu/util-linux
Karel Zak [Fri, 14 Aug 2020 09:18:59 +0000 (11:18 +0200)] 
Merge branch 'patch-1' of https://github.com/8vasu/util-linux

* 'patch-1' of https://github.com/8vasu/util-linux:
  Update pty-session.c
  More minor typos
  Fix minor typo

4 years agoMerge branch 'fdisk-fuzzer-follow-up' of https://github.com/evverx/util-linux
Karel Zak [Fri, 14 Aug 2020 09:16:12 +0000 (11:16 +0200)] 
Merge branch 'fdisk-fuzzer-follow-up' of https://github.com/evverx/util-linux

* 'fdisk-fuzzer-follow-up' of https://github.com/evverx/util-linux:
  tests: add testcases that triggered various crashes

4 years agolibfdisk: (script) fix possible partno overflow
Karel Zak [Fri, 14 Aug 2020 09:13:50 +0000 (11:13 +0200)] 
libfdisk: (script) fix possible partno overflow

Addresses: https://oss-fuzz.com/testcase-detail/5740890480705536
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoUpdate pty-session.c
Soumendra Ganguly [Thu, 13 Aug 2020 17:58:22 +0000 (12:58 -0500)] 
Update pty-session.c

4 years agolibfdisk: (script) fix possible memory leaks
Karel Zak [Thu, 13 Aug 2020 11:48:28 +0000 (13:48 +0200)] 
libfdisk: (script) fix possible memory leaks

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMore minor typos
Soumendra Ganguly [Thu, 13 Aug 2020 11:01:57 +0000 (06:01 -0500)] 
More minor typos

4 years agolibfdisk: another parse_line_nameval() cleanup
Karel Zak [Thu, 13 Aug 2020 08:13:01 +0000 (10:13 +0200)] 
libfdisk: another parse_line_nameval() cleanup

4 years agolibfdisk: make fdisk_partname() more robust
Karel Zak [Thu, 13 Aug 2020 08:12:01 +0000 (10:12 +0200)] 
libfdisk: make fdisk_partname() more robust

4 years agoFix minor typo
Soumendra Ganguly [Thu, 13 Aug 2020 07:44:28 +0000 (02:44 -0500)] 
Fix minor typo

terminall -> terminal

4 years agolibfdisk: fix typo from 255f5f4c770ebd46a38b58975bd33e33ae87ed24
Karel Zak [Wed, 12 Aug 2020 17:48:47 +0000 (19:48 +0200)] 
libfdisk: fix typo from 255f5f4c770ebd46a38b58975bd33e33ae87ed24

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibfdisk: (script) make sure buffer is initialized
Karel Zak [Wed, 12 Aug 2020 17:36:51 +0000 (19:36 +0200)] 
libfdisk: (script) make sure buffer is initialized

Just to make static analyzers happy.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibfdisk: (script) don't use sector size if not specified
Karel Zak [Wed, 12 Aug 2020 13:59:38 +0000 (15:59 +0200)] 
libfdisk: (script) don't use sector size if not specified

This is probably bad script API use, but better be safe than sorry.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibfdisk: (script) make sure label is specified
Karel Zak [Wed, 12 Aug 2020 13:52:53 +0000 (15:52 +0200)] 
libfdisk: (script) make sure label is specified

and unref type if already specified (unlikely, but be paranoid)

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: add testcases that triggered various crashes
Evgeny Vereshchagin [Tue, 11 Aug 2020 23:58:15 +0000 (23:58 +0000)] 
tests: add testcases that triggered various crashes

to make it easier to catch regressions going forward.

It's a follow-up to 678d03cc8a9c665ba989b099f03ad60e58f7bdcac6a
and 4bdb681571d5f510ab2abff86

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agotravis: stop building fuzz targets on macOS
Evgeny Vereshchagin [Mon, 10 Aug 2020 23:33:51 +0000 (23:33 +0000)] 
travis: stop building fuzz targets on macOS

Looks like `-fsanitize=fuzzer` isn't supported there:

https://travis-ci.org/github/karelzak/util-linux/jobs/716894984
```
clang: error: unsupported option '-fsanitize=fuzzer' for target 'x86_64-apple-darwin17.7.0'
```

4 years agotests: add a fuzz target calling fdisk_script_read_file
Evgeny Vereshchagin [Mon, 10 Aug 2020 22:24:41 +0000 (22:24 +0000)] 
tests: add a fuzz target calling fdisk_script_read_file

It has already found a couple of issues mentioned in
https://github.com/karelzak/util-linux/issues/1023#issuecomment-671910621

4 years agoMerge branch 'scriptreplay_noebadf' of https://github.com/8vasu/util-linux
Karel Zak [Tue, 11 Aug 2020 09:58:30 +0000 (11:58 +0200)] 
Merge branch 'scriptreplay_noebadf' of https://github.com/8vasu/util-linux

4 years agohwclock: add fallback if SYS_settimeofday does not exist
Karel Zak [Tue, 11 Aug 2020 09:02:31 +0000 (11:02 +0200)] 
hwclock: add fallback if SYS_settimeofday does not exist

It seems Musl-C removes SYS_settimeofday macro at all.

Addresses: https://github.com/karelzak/util-linux/commit/9c6139a72017cecb9145e46102152cb4f456ada6#commitcomment-41290951
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'fuzz' of https://github.com/evverx/util-linux
Karel Zak [Mon, 10 Aug 2020 12:40:44 +0000 (14:40 +0200)] 
Merge branch 'fuzz' of https://github.com/evverx/util-linux

* 'fuzz' of https://github.com/evverx/util-linux:
  tests: pack testcases into zip archives
  tests: integrate test_last_fuzz into the testsuite
  tests: add a fuzzer for process_wtmp_file
  docs: mention OSS-Fuzz and CIFuzz and how to build fuzz targets locally
  tools: make it possible to set all the fuzzing flags with config-gen
  build-system: make "make distcheck" work
  travis: set CXX correctly
  travis: turn on --enable-fuzzing-engine
  build-sys: add support for --enable-fuzzing-engine
  tests: integrate test_mount_fuzz into the testsuite
  tests: take exit codes into account
  tests: add a fuzzer for mnt_table_parse_stream

4 years agotests: add sfdisk test for 4fe7f9b614e2b5bb97f6d89af02acb867cffccc1
Karel Zak [Mon, 10 Aug 2020 10:00:17 +0000 (12:00 +0200)] 
tests: add sfdisk test for 4fe7f9b614e2b5bb97f6d89af02acb867cffccc1

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibfdisk: fix last free sector detection if partition size specified
Karel Zak [Mon, 10 Aug 2020 09:37:32 +0000 (11:37 +0200)] 
libfdisk: fix last free sector detection if partition size specified

We need to skip useless gaps between partition if the gap is no large
enough for a new partition. Unfortunately, the current code checks
size of the gap, but does not care for location of the gap -- this is
good enough for dialog driven partitioning, but it's pretty bad if
start of the partition is explicitly specified (e.g. sfdisk).

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1860461
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoChange tcgetattr error handling.
Soumendra Ganguly [Sat, 8 Aug 2020 10:28:42 +0000 (05:28 -0500)] 
Change tcgetattr error handling.

4 years agoMerge branch 'scriptreplay_noisatty' of https://github.com/8vasu/util-linux
Karel Zak [Fri, 7 Aug 2020 13:08:03 +0000 (15:08 +0200)] 
Merge branch 'scriptreplay_noisatty' of https://github.com/8vasu/util-linux

4 years agoMerge branch 'sscanf-specifiers' of https://github.com/evverx/util-linux
Karel Zak [Fri, 7 Aug 2020 13:02:56 +0000 (15:02 +0200)] 
Merge branch 'sscanf-specifiers' of https://github.com/evverx/util-linux

* 'sscanf-specifiers' of https://github.com/evverx/util-linux:
  travis: turn off libmount on OSX
  cifuzz: turn on MSan
  build-system: stop looking for %ms and %as

4 years agodocs: fix typo in v2.36-ReleaseNotes
Karel Zak [Fri, 7 Aug 2020 11:49:19 +0000 (13:49 +0200)] 
docs: fix typo in v2.36-ReleaseNotes

Reported-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoAdd more elegant error handling. Avoid isatty.
Soumendra Ganguly [Fri, 7 Aug 2020 08:01:02 +0000 (03:01 -0500)] 
Add more elegant error handling. Avoid isatty.

4 years agotravis: turn off libmount on OSX
Evgeny Vereshchagin [Thu, 6 Aug 2020 16:10:28 +0000 (16:10 +0000)] 
travis: turn off libmount on OSX

Now that the absence of the sscanf modifiers no longer prevents Travis from building libmount
automatically it seems util-linux is failing to compile there with
```
In file included from disk-utils/fsck.c:49:

[1m./libmount/src/libmount.h:32:10: [0m[0;1;31mfatal error: [0m[1m'mntent.h' file not found[0m

[0;1;32m         ^~~~~~~~~~

[0m1 error generated.

make[2]: *** [disk-utils/fsck-fsck.o] Error 1

make[2]: *** Waiting for unfinished jobs....

make[1]: *** [all-recursive] Error 1

make: *** [all] Error 2
```

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agocifuzz: turn on MSan
Evgeny Vereshchagin [Thu, 6 Aug 2020 14:10:22 +0000 (14:10 +0000)] 
cifuzz: turn on MSan

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agobuild-system: stop looking for %ms and %as
Evgeny Vereshchagin [Thu, 6 Aug 2020 13:59:35 +0000 (13:59 +0000)] 
build-system: stop looking for %ms and %as

Looks like those specifiers haven't been used since 6c9ab254aefb6ce7e0e
(where sscanf was removed) was merged. This should help to get
util-linux to compile with MSan. Currently it's failing with
```
...
configure: error: libmount selected, but required scanf string alloc modifier not available
...
configure:20240: ./conftest
==116617==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x496fd6 in main /home/vagrant/util-linux/conftest.c:171:6
    #1 0x7f5eb85ea1a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
    #2 0x41c2cd in _start (/home/vagrant/util-linux/conftest+0x41c2cd)

SUMMARY: MemorySanitizer: use-of-uninitialized-value /home/vagrant/util-linux/conftest.c:171:6 in main
Exiting
configure:20240: $? = 77
...
configure:20265: $? = 0
configure:20265: ./conftest
MemorySanitizer: bad pointer 0x000000496e60
==116627==MemorySanitizer CHECK failed: /builddir/build/BUILD/compiler-rt-9.0.1.src/lib/msan/../sanitizer_common/sanitizer_allocator_secondary.h:177 "((IsAligned(reinterpret_cast<uptr>(p), page_size_))) != (0)" (0x0, 0x0)
    #0 0x41d1d8 in MsanCheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (/home/vagrant/util-linux/conftest+0x41d1d8)
    #1 0x484e1e in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (/home/vagrant/util-linux/conftest+0x484e1e)
    #2 0x42066c in __msan::MsanDeallocate(__sanitizer::StackTrace*, void*) (/home/vagrant/util-linux/conftest+0x42066c)
    #3 0x424bc9 in free (/home/vagrant/util-linux/conftest+0x424bc9)
    #4 0x496fae in main /home/vagrant/util-linux/conftest.c:173:2
    #5 0x7f2245f311a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
    #6 0x41c2cd in _start (/home/vagrant/util-linux/conftest+0x41c2cd)

configure:20265: $? = 77
configure: program exited with status 77
...
| }
configure:22568: result: no
configure:22926: error: libmount selected, but required scanf string alloc modifier not available
```

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agotests: pack testcases into zip archives
Evgeny Vereshchagin [Wed, 29 Jul 2020 07:22:41 +0000 (07:22 +0000)] 
tests: pack testcases into zip archives

so that OSS-Fuzz can use them as seed corpora

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agotests: integrate test_last_fuzz into the testsuite
Evgeny Vereshchagin [Wed, 29 Jul 2020 06:31:11 +0000 (06:31 +0000)] 
tests: integrate test_last_fuzz into the testsuite

by adding tests/ts/* and a testcase triggering https://github.com/karelzak/util-linux/pull/1097

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agotests: add a fuzzer for process_wtmp_file
Evgeny Vereshchagin [Wed, 8 Jul 2020 22:13:40 +0000 (22:13 +0000)] 
tests: add a fuzzer for process_wtmp_file

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agodocs: mention OSS-Fuzz and CIFuzz and how to build fuzz targets locally
Evgeny Vereshchagin [Tue, 28 Jul 2020 11:47:08 +0000 (11:47 +0000)] 
docs: mention OSS-Fuzz and CIFuzz and how to build fuzz targets locally

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agotools: make it possible to set all the fuzzing flags with config-gen
Evgeny Vereshchagin [Tue, 28 Jul 2020 11:23:50 +0000 (11:23 +0000)] 
tools: make it possible to set all the fuzzing flags with config-gen

so that the fuzz targets (along with everything else) can be built
and run with:
```
./tools/config-gen fuzz
make check
```

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agobuild-system: make "make distcheck" work
Evgeny Vereshchagin [Tue, 28 Jul 2020 10:31:58 +0000 (10:31 +0000)] 
build-system: make "make distcheck" work

It failed with:
```
make[5]: Entering directory '/home/travis/build/karelzak/util-linux/util-linux-2.36.32-0fea/_build/sub/po'
make[5]: *** No rule to make target '../../../include/fuzz.h', needed by 'util-linux.pot-update'.  Stop.
make[5]: Leaving directory '/home/travis/build/karelzak/util-linux/util-linux-2.36.32-0fea/_build/sub/po'
Makefile:896: recipe for target 'update-po' failed
make[4]: *** [update-po] Error 2
```

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agotravis: set CXX correctly
Evgeny Vereshchagin [Tue, 28 Jul 2020 05:26:53 +0000 (05:26 +0000)] 
travis: set CXX correctly

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agotravis: turn on --enable-fuzzing-engine
Evgeny Vereshchagin [Tue, 28 Jul 2020 04:19:10 +0000 (04:19 +0000)] 
travis: turn on --enable-fuzzing-engine

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agobuild-sys: add support for --enable-fuzzing-engine
Evgeny Vereshchagin [Tue, 28 Jul 2020 04:17:40 +0000 (04:17 +0000)] 
build-sys: add support for --enable-fuzzing-engine

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agotests: integrate test_mount_fuzz into the testsuite
Evgeny Vereshchagin [Tue, 28 Jul 2020 00:56:04 +0000 (00:56 +0000)] 
tests: integrate test_mount_fuzz into the testsuite

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agotests: take exit codes into account
Evgeny Vereshchagin [Sun, 28 Jun 2020 02:15:23 +0000 (04:15 +0200)] 
tests: take exit codes into account

In its current form the testsuite isn't suitable for running
fuzz targets because it ignores exit codes and relies solely
on diffs (that unfortunately aren't helpful because the nondeterministic
nature of fuzz targets makes it kind of hard to specify expected output
in advance). This patch is supposed to address the "exit code" issue for now.

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agotests: add a fuzzer for mnt_table_parse_stream
Evgeny Vereshchagin [Sat, 11 Apr 2020 13:25:26 +0000 (13:25 +0000)] 
tests: add a fuzzer for mnt_table_parse_stream

The fuzzer is supposed to cover `mnt_table_parse_stream`, which is
used by systemd to parse /proc/self/mountinfo. The systemd project
has run into memory leaks there at least twice:

https://github.com/systemd/systemd/pull/12252#issuecomment-482804040
https://github.com/systemd/systemd/issues/8504

so it seems to be a good idea to continuously fuzz that particular
function.

The patch can be tested locally by installing clang and running
./tools/oss-fuzz.sh. Currently the fuzzer is failing with
```
=================================================================
==96638==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 216 byte(s) in 1 object(s) allocated from:
    #0 0x50cd77 in calloc (/home/vagrant/util-linux/out/test_mount_fuzz+0x50cd77)
    #1 0x58716a in mnt_new_fs /home/vagrant/util-linux/libmount/src/fs.c:36:25
    #2 0x54f224 in __table_parse_stream /home/vagrant/util-linux/libmount/src/tab_parse.c:728:9
    #3 0x54eed8 in mnt_table_parse_stream /home/vagrant/util-linux/libmount/src/tab_parse.c:804:8
    #4 0x5448b2 in LLVMFuzzerTestOneInput /home/vagrant/util-linux/libmount/src/fuzz.c:19:16
    #5 0x44cc88 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/home/vagrant/util-linux/out/test_mount_fuzz+0x44cc88)
    #6 0x44d8b0 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) (/home/vagrant/util-linux/out/test_mount_fuzz+0x44d8b0)
    #7 0x44e270 in fuzzer::Fuzzer::MutateAndTestOne() (/home/vagrant/util-linux/out/test_mount_fuzz+0x44e270)
    #8 0x450617 in fuzzer::Fuzzer::Loop(std::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) (/home/vagrant/util-linux/out/test_mount_fuzz+0x450617)
    #9 0x43adbb in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/home/vagrant/util-linux/out/test_mount_fuzz+0x43adbb)
    #10 0x42ad46 in main (/home/vagrant/util-linux/out/test_mount_fuzz+0x42ad46)
    #11 0x7fa084f621a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)

SUMMARY: AddressSanitizer: 216 byte(s) leaked in 1 allocation(s).
INFO: to ignore leaks on libFuzzer side use -detect_leaks=0.
```

Once the bug is fixed and the OSS-Fuzz counterpart is merged it should be possible
to turn on CIFuzz to make sure the fuzz target can be built and run for some time
without crashing: https://google.github.io/oss-fuzz/getting-started/continuous-integration/

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agoMerge branch 'mk-rm' of https://github.com/evverx/util-linux
Karel Zak [Thu, 6 Aug 2020 09:49:29 +0000 (11:49 +0200)] 
Merge branch 'mk-rm' of https://github.com/evverx/util-linux

* 'mk-rm' of https://github.com/evverx/util-linux:
  tests: an attempt to get around https://github.com/karelzak/util-linux/issues/1110

4 years agolibfdisk: fix fdisk_reread_changes() for extended partitions
Karel Zak [Thu, 6 Aug 2020 09:32:33 +0000 (11:32 +0200)] 
libfdisk: fix fdisk_reread_changes() for extended partitions

Linux kernel assumes only 1KiB extended partition to avoid overlapping
with nested logical partitions. We need to follow this rule for
BLKPG_ADD_PARTITION.

Addresses: https://github.com/karelzak/util-linux/issues/1112
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agotests: an attempt to get around https://github.com/karelzak/util-linux/issues/1110
Evgeny Vereshchagin [Tue, 28 Jul 2020 08:04:35 +0000 (08:04 +0000)] 
tests: an attempt to get around https://github.com/karelzak/util-linux/issues/1110

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
5 years agoManual pages: wipefs.8: Formatting fixes
Michael Kerrisk (man-pages) [Fri, 24 Jul 2020 10:06:18 +0000 (12:06 +0200)] 
Manual pages: wipefs.8: Formatting fixes

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
5 years agoManual pages: agetty.8: Minor formatting and wording fixes
Michael Kerrisk (man-pages) [Fri, 24 Jul 2020 10:06:17 +0000 (12:06 +0200)] 
Manual pages: agetty.8: Minor formatting and wording fixes

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
5 years agoManual pages: wdctl.8: typo fix
Michael Kerrisk (man-pages) [Fri, 24 Jul 2020 10:06:16 +0000 (12:06 +0200)] 
Manual pages: wdctl.8: typo fix

5 years agoManual pages: lsblk.8: Minor formatting and typo fixes
Michael Kerrisk (man-pages) [Fri, 24 Jul 2020 10:06:15 +0000 (12:06 +0200)] 
Manual pages: lsblk.8: Minor formatting and typo fixes

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
5 years agoManual pages: logger.1: minor formatting and typo fixes
Michael Kerrisk (man-pages) [Fri, 24 Jul 2020 10:06:14 +0000 (12:06 +0200)] 
Manual pages: logger.1: minor formatting and typo fixes

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
5 years agoManual pages: nologin.8: formatting fixes
Michael Kerrisk (man-pages) [Fri, 24 Jul 2020 10:06:13 +0000 (12:06 +0200)] 
Manual pages: nologin.8: formatting fixes

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
5 years agoManual pages: lslogins.1: Minor wording and formatting fixres
Michael Kerrisk (man-pages) [Fri, 24 Jul 2020 10:06:12 +0000 (12:06 +0200)] 
Manual pages: lslogins.1: Minor wording and formatting fixres

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
5 years agoManual pages: sfdisk.8: Use less aggressive indenting
Michael Kerrisk (man-pages) [Fri, 24 Jul 2020 10:06:11 +0000 (12:06 +0200)] 
Manual pages: sfdisk.8: Use less aggressive indenting

The page currently uses rather aggressive indenting, which doesn't
really improve readability, but does have cause ugly line filling.

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
5 years agoManual pages: sfdisk.8: Minor wording and formatting fixes
Michael Kerrisk (man-pages) [Fri, 24 Jul 2020 10:06:10 +0000 (12:06 +0200)] 
Manual pages: sfdisk.8: Minor wording and formatting fixes

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
5 years agoManual pages: raw.8: Minor formatting and wording fixes
Michael Kerrisk (man-pages) [Fri, 24 Jul 2020 10:06:09 +0000 (12:06 +0200)] 
Manual pages: raw.8: Minor formatting and wording fixes

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
5 years agoManual pages: blockdev.8: Minor wording and formatting fixes
Michael Kerrisk (man-pages) [Fri, 24 Jul 2020 10:06:07 +0000 (12:06 +0200)] 
Manual pages: blockdev.8: Minor wording and formatting fixes

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
5 years agofdisk: fix expected test output on alpha
Chris Hofstaedtler [Fri, 24 Jul 2020 00:35:09 +0000 (00:35 +0000)] 
fdisk: fix expected test output on alpha

The last test output update inadvertedly replaced "ext2" with "MS-DOS"
in the alpha-specific data.

Fixes: 3c36438f0
Broken build log: https://buildd.debian.org/status/fetch.php?pkg=util-linux&arch=alpha&ver=2.36-1&stamp=1595550493&raw=0
Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
5 years agomanpages: fix "The example command" in AVAILABILITY section
Chris Hofstaedtler [Thu, 23 Jul 2020 22:31:41 +0000 (22:31 +0000)] 
manpages: fix "The example command" in AVAILABILITY section

Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
5 years agoscriptreplay: enable special character handling
Soumendra Ganguly [Fri, 17 Jul 2020 09:54:30 +0000 (04:54 -0500)] 
scriptreplay: enable special character handling

Calling cfmakeraw disables terminal special character handling. For
example, Ctrl-C does not send SIGINT to scriptreplay. The following
fixes this.

 tattr.c_lflag |= ISIG;

where tattr is the struct termios with which we are working.

5 years agolibmount (verity): let crypt_deactivate_by_name handle its own data structure
Luca Boccassi [Wed, 8 Jul 2020 14:15:03 +0000 (15:15 +0100)] 
libmount (verity): let crypt_deactivate_by_name handle its own data structure

It's not necessary to initialize a crypt_device, the function will do it
on its own if NULL is passed. Removes a few extra library calls.

Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com>
5 years agolibmount (verity): plug libcryptsetup logger into our logging system
Luca Boccassi [Wed, 8 Jul 2020 14:12:34 +0000 (15:12 +0100)] 
libmount (verity): plug libcryptsetup logger into our logging system

Allows logs from the library to be printed by our system:

731814: libmount:   VERITY: crypsetup: Device libmnt_img.raw already exists.

If the mount context is in verbose mode, enable all debug logs from
libcrypsetup as well.

Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com>
5 years agoMake scriptreplay set terminal to raw mode
SOUMENDRA GANGULY [Fri, 10 Jul 2020 11:16:03 +0000 (06:16 -0500)] 
Make scriptreplay set terminal to raw mode

5 years agobash-completion: add irqtop/lsirq --softirq
Karel Zak [Fri, 3 Jul 2020 08:37:54 +0000 (10:37 +0200)] 
bash-completion: add irqtop/lsirq --softirq

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoirqtop/lsirq: add softirq for man page
zhenwei pi [Thu, 2 Jul 2020 12:31:39 +0000 (20:31 +0800)] 
irqtop/lsirq: add softirq for man page

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
5 years agoirqtop/lsirq: add additional desc for softirq
zhenwei pi [Thu, 2 Jul 2020 12:24:20 +0000 (20:24 +0800)] 
irqtop/lsirq: add additional desc for softirq

Suggested by Karel, add additional description to make softirq more
friendly to end-user. Discuss about this:
    https://github.com/karelzak/util-linux/pull/1079

Note that, we should keep softirqs table align to kernel source code.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
5 years agoirqtop/lsirq: support softirq
zhenwei pi [Mon, 29 Jun 2020 06:19:21 +0000 (14:19 +0800)] 
irqtop/lsirq: support softirq

Add '-S' or '--softirq' for irqtop/lsirq, instead of interrupts, show
softirqs infomation. Because there is no more description of softirq,
do not show 'NAME' column by default.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
5 years agoblkzone: add capacity field to zone report
Shin'ichiro Kawasaki [Wed, 1 Jul 2020 11:33:26 +0000 (20:33 +0900)] 
blkzone: add capacity field to zone report

NVMe ZNS specification defines zone capacity. The report zone interface
of Linux kernel supports it. Expose it in report zone by blkzone command.

Signed-off-by: Hans Holmberg <hans.holmberg@wdc.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
5 years agohexdump: automatically use -C when called as hd
Chris Hofstaedtler [Tue, 23 Jun 2020 00:14:30 +0000 (00:14 +0000)] 
hexdump: automatically use -C when called as hd

When invoking hexdump as hd enable the "Canonical" format to by
default, implying the -C option.

This is historic behaviour on Debian and apparently also on FreeBSD.
Some Debian users have asked for this to be restored, after Debian
switched to util-linux' hexdump and hd.

Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
5 years agobuild-sys: release++ (v2.36) v2.36
Karel Zak [Thu, 23 Jul 2020 09:26:04 +0000 (11:26 +0200)] 
build-sys: release++ (v2.36)

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agopo: update fr.po (from translationproject.org)
Frédéric Marchal [Thu, 23 Jul 2020 09:25:41 +0000 (11:25 +0200)] 
po: update fr.po (from translationproject.org)

5 years agotools: remove changes merged by accident
Karel Zak [Thu, 23 Jul 2020 09:22:42 +0000 (11:22 +0200)] 
tools: remove changes merged by accident

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agodocs: update v2.36-ReleaseNotes
Karel Zak [Wed, 22 Jul 2020 12:40:18 +0000 (14:40 +0200)] 
docs: update v2.36-ReleaseNotes

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agodocs: update AUTHORS file
Karel Zak [Wed, 22 Jul 2020 12:38:31 +0000 (14:38 +0200)] 
docs: update AUTHORS file

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agopo: merge changes
Karel Zak [Wed, 22 Jul 2020 10:20:36 +0000 (12:20 +0200)] 
po: merge changes

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agopo: update zh_CN.po (from translationproject.org)
Boyuan Yang [Wed, 22 Jul 2020 10:04:53 +0000 (12:04 +0200)] 
po: update zh_CN.po (from translationproject.org)

5 years agopo: update uk.po (from translationproject.org)
Yuri Chornoivan [Wed, 22 Jul 2020 10:04:53 +0000 (12:04 +0200)] 
po: update uk.po (from translationproject.org)

5 years agopo: update pt.po (from translationproject.org)
Pedro Albuquerque [Wed, 22 Jul 2020 10:04:53 +0000 (12:04 +0200)] 
po: update pt.po (from translationproject.org)

5 years agopo: update pt_BR.po (from translationproject.org)
Rafael Fontenelle [Wed, 22 Jul 2020 10:04:53 +0000 (12:04 +0200)] 
po: update pt_BR.po (from translationproject.org)

5 years agopo: update pl.po (from translationproject.org)
Jakub Bogusz [Wed, 22 Jul 2020 10:04:53 +0000 (12:04 +0200)] 
po: update pl.po (from translationproject.org)

5 years agopo: update ja.po (from translationproject.org)
Takeshi Hamasaki [Wed, 22 Jul 2020 10:04:53 +0000 (12:04 +0200)] 
po: update ja.po (from translationproject.org)

5 years agopo: update hr.po (from translationproject.org)
Božidar Putanec [Wed, 22 Jul 2020 10:04:53 +0000 (12:04 +0200)] 
po: update hr.po (from translationproject.org)

5 years agopo: update fr.po (from translationproject.org)
Frédéric Marchal [Wed, 22 Jul 2020 10:04:53 +0000 (12:04 +0200)] 
po: update fr.po (from translationproject.org)

5 years agopo: update es.po (from translationproject.org)
Antonio Ceballos Roa [Wed, 22 Jul 2020 10:04:53 +0000 (12:04 +0200)] 
po: update es.po (from translationproject.org)

5 years agopo: update de.po (from translationproject.org)
Mario Blättermann [Wed, 22 Jul 2020 10:04:53 +0000 (12:04 +0200)] 
po: update de.po (from translationproject.org)

5 years agopo: update cs.po (from translationproject.org)
Petr Písař [Wed, 22 Jul 2020 10:04:53 +0000 (12:04 +0200)] 
po: update cs.po (from translationproject.org)

5 years agodocs: add blkdiscard to ReleaseNotes
Karel Zak [Wed, 22 Jul 2020 09:23:18 +0000 (11:23 +0200)] 
docs: add blkdiscard to ReleaseNotes

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibsmartcols: (docs) fix reference
Karel Zak [Wed, 22 Jul 2020 09:22:51 +0000 (11:22 +0200)] 
libsmartcols: (docs) fix reference

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibfdisk: (docs) add missing comment
Karel Zak [Wed, 22 Jul 2020 08:44:47 +0000 (10:44 +0200)] 
libfdisk: (docs) add missing comment

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibmount: (docs) fix typo, remove unused reference
Karel Zak [Wed, 22 Jul 2020 08:44:33 +0000 (10:44 +0200)] 
libmount: (docs) fix typo, remove unused reference

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibsmartcols: (docs) add missing references
Karel Zak [Wed, 22 Jul 2020 08:34:14 +0000 (10:34 +0200)] 
libsmartcols: (docs) add missing references

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibmount: (docs) add missing references
Karel Zak [Wed, 22 Jul 2020 08:34:03 +0000 (10:34 +0200)] 
libmount: (docs) add missing references

Signed-off-by: Karel Zak <kzak@redhat.com>