Commit Graph

14548 Commits

Author SHA1 Message Date
Karel Zak 4bdb681571 libfdisk: (script) make sure buffer is initialized
Just to make static analyzers happy.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-08-12 19:39:34 +02:00
Karel Zak 8bbc11f12f 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>
2020-08-12 15:59:38 +02:00
Karel Zak 255f5f4c77 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>
2020-08-12 15:52:53 +02:00
Evgeny Vereshchagin 6c13bfcfed 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'
```
2020-08-11 00:21:27 +00:00
Evgeny Vereshchagin b62ec52e8f 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
2020-08-10 23:30:50 +00:00
Karel Zak 943f4dbdfe Merge branch 'scriptreplay_noebadf' of https://github.com/8vasu/util-linux 2020-08-11 11:58:30 +02:00
Karel Zak 69e4fbfbfd hwclock: add fallback if SYS_settimeofday does not exist
It seems Musl-C removes SYS_settimeofday macro at all.

Addresses: 9c6139a720 (commitcomment-41290951)
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-08-11 11:02:31 +02:00
Karel Zak c87cce57d8 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
2020-08-10 14:40:44 +02:00
Karel Zak dc4816142c tests: add sfdisk test for 4fe7f9b614
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-08-10 12:00:17 +02:00
Karel Zak 4fe7f9b614 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>
2020-08-10 11:37:32 +02:00
Soumendra Ganguly 535e81ebba Change tcgetattr error handling. 2020-08-08 05:28:42 -05:00
Karel Zak fbc9b69151 Merge branch 'scriptreplay_noisatty' of https://github.com/8vasu/util-linux 2020-08-07 15:08:03 +02:00
Karel Zak 4418b5aa49 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
2020-08-07 15:02:56 +02:00
Karel Zak 8451390bd9 docs: fix typo in v2.36-ReleaseNotes
Reported-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-08-07 13:49:19 +02:00
Soumendra Ganguly cfc264d50b Add more elegant error handling. Avoid isatty. 2020-08-07 03:01:02 -05:00
Evgeny Vereshchagin 67884c75e2 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>
2020-08-06 16:15:31 +00:00
Evgeny Vereshchagin 2bb8c73696 cifuzz: turn on MSan
Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2020-08-06 15:36:45 +00:00
Evgeny Vereshchagin 0be452a82a build-system: stop looking for %ms and %as
Looks like those specifiers haven't been used since 6c9ab254ae
(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>
2020-08-06 14:27:20 +00:00
Evgeny Vereshchagin 6e277b7a97 tests: pack testcases into zip archives
so that OSS-Fuzz can use them as seed corpora

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2020-08-06 12:33:11 +00:00
Evgeny Vereshchagin 877356164a 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>
2020-08-06 12:33:11 +00:00
Evgeny Vereshchagin 2cdbf06f5e tests: add a fuzzer for process_wtmp_file
Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2020-08-06 12:33:11 +00:00
Evgeny Vereshchagin 0f311c7ae7 docs: mention OSS-Fuzz and CIFuzz and how to build fuzz targets locally
Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2020-08-06 12:33:11 +00:00
Evgeny Vereshchagin 02f5fc1407 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>
2020-08-06 12:33:11 +00:00
Evgeny Vereshchagin 681d3a9586 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>
2020-08-06 12:33:11 +00:00
Evgeny Vereshchagin 6056e05b28 travis: set CXX correctly
Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2020-08-06 12:33:11 +00:00
Evgeny Vereshchagin c8f78bde3a travis: turn on --enable-fuzzing-engine
Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2020-08-06 12:33:11 +00:00
Evgeny Vereshchagin 75196cd8be build-sys: add support for --enable-fuzzing-engine
Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2020-08-06 12:33:11 +00:00
Evgeny Vereshchagin 7b4ab119f4 tests: integrate test_mount_fuzz into the testsuite
Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2020-08-06 12:33:11 +00:00
Evgeny Vereshchagin 78905e4450 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>
2020-08-06 12:33:11 +00:00
Evgeny Vereshchagin ccdc47b7f5 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>
2020-08-06 12:33:11 +00:00
Karel Zak db85c0eb89 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
2020-08-06 11:49:29 +02:00
Karel Zak 33f50706fd 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>
2020-08-06 11:32:33 +02:00
Evgeny Vereshchagin f04521f4ac tests: an attempt to get around https://github.com/karelzak/util-linux/issues/1110
Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2020-07-28 08:15:23 +00:00
Michael Kerrisk (man-pages) 359b522c39 Manual pages: wipefs.8: Formatting fixes
Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
2020-07-24 14:41:49 +02:00
Michael Kerrisk (man-pages) 2b34e0141d Manual pages: agetty.8: Minor formatting and wording fixes
Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
2020-07-24 14:41:49 +02:00
Michael Kerrisk (man-pages) 04be4affb7 Manual pages: wdctl.8: typo fix 2020-07-24 14:41:49 +02:00
Michael Kerrisk (man-pages) 4aabe42985 Manual pages: lsblk.8: Minor formatting and typo fixes
Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
2020-07-24 14:41:49 +02:00
Michael Kerrisk (man-pages) cbb38bfbdf Manual pages: logger.1: minor formatting and typo fixes
Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
2020-07-24 14:41:49 +02:00
Michael Kerrisk (man-pages) 95553ea0dd Manual pages: nologin.8: formatting fixes
Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
2020-07-24 14:41:49 +02:00
Michael Kerrisk (man-pages) 47c6012f2b Manual pages: lslogins.1: Minor wording and formatting fixres
Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
2020-07-24 14:41:49 +02:00
Michael Kerrisk (man-pages) 89fdd6d439 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>
2020-07-24 14:41:49 +02:00
Michael Kerrisk (man-pages) b382d543ed Manual pages: sfdisk.8: Minor wording and formatting fixes
Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
2020-07-24 14:41:49 +02:00
Michael Kerrisk (man-pages) 8be2cc8171 Manual pages: raw.8: Minor formatting and wording fixes
Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
2020-07-24 14:41:49 +02:00
Michael Kerrisk (man-pages) 342af74630 Manual pages: blockdev.8: Minor wording and formatting fixes
Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
2020-07-24 14:41:49 +02:00
Chris Hofstaedtler dcd77a69da 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>
2020-07-24 09:09:43 +02:00
Chris Hofstaedtler 7259f318b9 manpages: fix "The example command" in AVAILABILITY section
Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
2020-07-24 09:09:43 +02:00
Soumendra Ganguly 00a09d78ea 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.
2020-07-23 12:23:56 +02:00
Luca Boccassi b725361adf 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>
2020-07-23 12:23:56 +02:00
Luca Boccassi e0b6f5a7c8 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>
2020-07-23 12:23:56 +02:00
SOUMENDRA GANGULY edb088ffbe Make scriptreplay set terminal to raw mode 2020-07-23 12:23:56 +02:00