1
0
mirror of https://github.com/systemd/systemd synced 2026-04-11 17:44:58 +02:00

Compare commits

...

11 Commits

Author SHA1 Message Date
Luca Boccassi
ff97eb4aac
Merge pull request #21977 from systemd/wip/hadess/minipro-uaccess
hwdb: Allow end-users root-less access to TL866 EPROM readers
2022-01-04 15:51:28 +00:00
Frantisek Sumsal
7847b54814 test: build fuzzers with --werror if set
to catch issues like systemd/systemd#21996.
2022-01-04 18:49:56 +03:00
Zbigniew Jędrzejewski-Szmek
5377ad4ea4 fuzz-bcd: silence warning about always-true comparison
Occurs with gcc-11.2.1-7.fc35.x86_64.
2022-01-04 11:49:45 +00:00
Bastien Nocera
f097f4ab89 hwdb: Allow end-users root-less access to TL866 EPROM readers
As is currently done in the upstream minipro tool:
https://gitlab.com/DavidGriffith/minipro/-/tree/master/udev
2022-01-04 11:06:12 +01:00
Zbigniew Jędrzejewski-Szmek
ba5b19ef4d Revert "udev: Import hwdb matches for USB devices"
This reverts commit 94cb45d57f6e94dd4c93bd4706f9be70634bf03f.

This rule set up a duplicate import:

$ udevadm test /devices/pci0000:00/0000:00:14.0/usb2/2-4/2-4.1/2-4.1.3
...
2-4.1.3: /usr/lib/udev/rules.d/40-libgphoto2.rules:9 Importing properties from results of builtin command 'usb_id'
2-4.1.3: /usr/lib/udev/rules.d/50-udev-default.rules:13 Skipping builtin 'usb_id' in IMPORT key
2-4.1.3: /usr/lib/udev/rules.d/50-udev-default.rules:13 Importing properties from results of builtin command 'hwdb --subsystem=usb'
2-4.1.3: hwdb modalias key: "usb:v17EFp3054:OneLink+ Giga"
2-4.1.3: /usr/lib/udev/rules.d/50-udev-default.rules:15 Importing properties from results of builtin command 'hwdb 'usb:v17efp3054''
2-4.1.3: No entry found from hwdb.
2-4.1.3: /usr/lib/udev/rules.d/50-udev-default.rules:15 Failed to run builtin 'hwdb 'usb:v17efp3054'': No data available
2-4.1.3: /usr/lib/udev/rules.d/50-udev-default.rules:52 MODE 0664

except that the existing one was done with uppercase digits and the full match pattern,
and the second one was done with lowercase digits.

With the previous commit we only have uppercase digits in our match patterns, so we can
drop the duplicate import. (Some other projects might have rules that used the lowercase
match patterns, and people might have some local rules that did that too. But the second
import was only added recently so I think it's better to rip off the bandaid quickly.)
2022-01-04 11:04:53 +01:00
Zbigniew Jędrzejewski-Szmek
cc1746bbed hwdb: make usb match patterns uppercase
Those patterns were always supposed to be uppercase.
2022-01-04 11:04:51 +01:00
Zbigniew Jędrzejewski-Szmek
1a37237e2f hwdb: fix check for uppercasedness of match patterns
The check was added in 77547d5313ea916d2fb64ca5a8812734e9b50f92, but
it doesn't work as expected. Because the second part is wrapped in Optional(),
it would silently "succeed" when the lowercase digits were in the second part:

>>> from parse_hwdb import *
>>> g = 'v' + upperhex_word(4) + Optional('p' + upperhex_word(4))
>>> g.parseString('v04D8pE11C*')
(['v', '04D8', 'p', 'E11C'], {})
>>> g.parseString('v04D8pe11c*')
(['v', '04D8'], {})

The following matches are OK:
usb:v0627p0001:*QEMU USB Keyboard*
usb:v0627p0001:*
usb:v0627p0001*
usb:v0627*
2022-01-04 11:04:33 +01:00
Yu Watanabe
1341f25b9b
Merge pull request #21778 from evverx/test-cifuzz
tests: run nss-{users|hosts} by default
2022-01-04 18:46:58 +09:00
Evgeny Vereshchagin
5df66d7d68 fuzz: no longer skip empty files
Empty files and empty strings seem to have triggered various
issues in the past so it seems they shouldn't be ignore by the
fuzzers just because fmemopen can't handle them.

Prompted by https://github.com/systemd/systemd/pull/21939#issuecomment-1003113669
2022-01-04 09:26:26 +01:00
Evgeny Vereshchagin
951280ce99 tests: no longer load libnss_{files|dns}
Those libraries aren't provided by systemd so they shouldn't be
included here
2022-01-03 04:36:37 +00:00
Evgeny Vereshchagin
637ccd2fa4 tests: run nss-{users|hosts} by default
to prevent issues like https://github.com/systemd/systemd/issues/21935
by testing the code under ASan/UBSan
2022-01-02 20:37:59 +00:00
15 changed files with 45 additions and 41 deletions

View File

@ -12,7 +12,7 @@
# Total Phase
###########################################################
# Aarvark I2C/SPI Host Adapter
usb:v0403pe0d0*
usb:v0403pE0D0*
ID_SIGNAL_ANALYZER=1
# Beagle Protocol Analyzers
@ -29,5 +29,16 @@ usb:v1679p3001*
# Power Delivery Analyzers
usb:v1679p6003*
usb:v0483pdf11*
usb:v0483pDF11*
ID_SIGNAL_ANALYZER=1
###########################################################
# XGecu
###########################################################
# TL866A/CS
usb:v04D8pE11C*
ID_SIGNAL_ANALYZER=1
# TL866II+
usb:vA466p0A53*
ID_SIGNAL_ANALYZER=1

View File

@ -212,21 +212,23 @@ def check_matches(groups):
# This is a partial check. The other cases could be also done, but those
# two are most commonly wrong.
grammars = { 'usb' : 'v' + upperhex_word(4) + Optional('p' + upperhex_word(4)),
'pci' : 'v' + upperhex_word(8) + Optional('d' + upperhex_word(8)),
grammars = { 'usb' : 'v' + upperhex_word(4) + Optional('p' + upperhex_word(4) + Optional(':')) + '*',
'pci' : 'v' + upperhex_word(8) + Optional('d' + upperhex_word(8) + Optional(':')) + '*',
}
for match in matches:
prefix, rest = match.split(':', maxsplit=1)
gr = grammars.get(prefix)
if gr:
# we check this first to provide an easy error message
if rest[-1] not in '*:':
error('pattern {} does not end with "*" or ":"', match)
try:
gr.parseString(rest)
except ParseBaseException as e:
error('Pattern {!r} is invalid: {}', rest, e)
continue
if rest[-1] not in '*:':
error('pattern {} does not end with "*" or ":"', match)
matches.sort()
prev = None

View File

@ -12,7 +12,6 @@ SUBSYSTEM=="rtc", KERNEL=="rtc0", SYMLINK+="rtc", OPTIONS+="link_priority=-100"
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", IMPORT{builtin}="usb_id", IMPORT{builtin}="hwdb --subsystem=usb"
ENV{MODALIAS}!="", IMPORT{builtin}="hwdb --subsystem=$env{SUBSYSTEM}"
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", IMPORT{builtin}="hwdb 'usb:v$attr{idVendor}p$attr{idProduct}'"
ACTION!="add", GOTO="default_end"

View File

@ -21,6 +21,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
assert_se(p);
char16_t *title = get_bcd_title(p, size);
assert_se(!title || char16_strlen(title) >= 0);
if (title)
(void) char16_strlen(title);
return 0;
}

View File

@ -2,7 +2,6 @@
#include "conf-parser.h"
#include "fd-util.h"
#include "fileio.h"
#include "fuzz.h"
#include "install.h"
#include "load-fragment.h"
@ -22,10 +21,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
const char *name;
long offset;
if (size == 0)
return 0;
f = fmemopen_unlocked((char*) data, size, "re");
f = data_to_file(data, size);
assert_se(f);
if (read_line(f, LINE_MAX, &p) < 0)

View File

@ -4,7 +4,6 @@
#include "alloc-util.h"
#include "env-file.h"
#include "fileio.h"
#include "fd-util.h"
#include "fuzz.h"
#include "strv.h"
@ -13,10 +12,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_fclose_ FILE *f = NULL;
_cleanup_strv_free_ char **rl = NULL, **rlp = NULL;
if (size == 0 || size > 65535)
if (size > 65535)
return 0;
f = fmemopen_unlocked((char*) data, size, "re");
f = data_to_file(data, size);
assert_se(f);
/* We don't want to fill the logs with messages about parse errors.

View File

@ -2,7 +2,6 @@
#include "alloc-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "fuzz.h"
#include "hostname-setup.h"
@ -10,10 +9,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_fclose_ FILE *f = NULL;
_cleanup_free_ char *ret = NULL;
if (size == 0)
return 0;
f = fmemopen_unlocked((char*) data, size, "re");
f = data_to_file(data, size);
assert_se(f);
/* We don't want to fill the logs with messages about parse errors.

View File

@ -1,7 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "alloc-util.h"
#include "fileio.h"
#include "fd-util.h"
#include "fuzz.h"
#include "json.h"
@ -12,10 +11,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_fclose_ FILE *f = NULL, *g = NULL;
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
if (size == 0)
return 0;
f = fmemopen_unlocked((char*) data, size, "re");
f = data_to_file(data, size);
assert_se(f);
if (json_parse_file(f, NULL, 0, &v, NULL, NULL) < 0)

View File

@ -4,5 +4,14 @@
#include <stddef.h>
#include <stdint.h>
#include "fileio.h"
/* The entry point into the fuzzer */
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
static inline FILE* data_to_file(const uint8_t *data, size_t size) {
if (size == 0)
return fopen("/dev/null", "re");
else
return fmemopen_unlocked((char*) data, size, "re");
}

View File

@ -2,7 +2,6 @@
#include "alloc-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "fuzz.h"
#include "nspawn-oci.h"
@ -10,10 +9,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_fclose_ FILE *f = NULL;
_cleanup_(settings_freep) Settings *s = NULL;
if (size == 0)
return 0;
f = fmemopen_unlocked((char*) data, size, "re");
f = data_to_file(data, size);
assert_se(f);
/* We don't want to fill the logs with messages about parse errors.

View File

@ -2,7 +2,6 @@
#include "alloc-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "fuzz.h"
#include "nspawn-settings.h"
@ -10,10 +9,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_fclose_ FILE *f = NULL;
_cleanup_(settings_freep) Settings *s = NULL;
if (size == 0)
return 0;
f = fmemopen_unlocked((char*) data, size, "re");
f = data_to_file(data, size);
assert_se(f);
/* We don't want to fill the logs with messages about parse errors.

View File

@ -608,14 +608,14 @@ tests += [
'src/test/nss-test-util.h'],
[],
[libdl],
[], 'ENABLE_NSS', 'manual'],
[], 'ENABLE_NSS'],
[['src/test/test-nss-users.c',
'src/test/nss-test-util.c',
'src/test/nss-test-util.h'],
[],
[libdl],
[], 'ENABLE_NSS', 'manual'],
[], 'ENABLE_NSS'],
[['src/test/test-bus-util.c']],

View File

@ -420,7 +420,7 @@ static int parse_argv(int argc, char **argv,
#if ENABLE_NSS_MYMACHINES
"mymachines",
#endif
"dns");
NULL);
assert_se(modules);
if (argc > 2) {

View File

@ -214,7 +214,7 @@ static int parse_argv(int argc, char **argv,
#if ENABLE_NSS_MYMACHINES
"mymachines",
#endif
"files");
NULL);
assert_se(modules);
if (argc > 2)

View File

@ -7,7 +7,10 @@ sanitize_address_undefined = custom_target(
project_source_root,
'@OUTPUT@',
'fuzzers',
'-Dfuzz-tests=true -Db_lundef=false -Db_sanitize=address,undefined --optimization=@0@'.format(get_option('optimization')),
'-Dfuzz-tests=true -Db_lundef=false -Db_sanitize=address,undefined --optimization=@0@ @1@'.format(
get_option('optimization'),
get_option('werror') ? '--werror' : ''
),
' '.join(cc.cmd_array()),
cxx_cmd])