1
0
mirror of https://github.com/systemd/systemd synced 2026-04-18 04:55:04 +02:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Lennart Poettering
362c62296a sd-boot: rename LOADER_STUB → LOADER_UNIFIED_LINUX
No actual code changes, just renaming.

Rationale: the focus here should be on the fact that these are "unified"
images, whether our stub is used or not, or something else doesn't
really matter. Moreover, these are still Linux entries. Hence, emphasize
that these are *unified* images, and *Linux* images, and deemphesize
that our sd-stub is likely used.
2022-02-03 13:44:28 +09:00
Evgeny Vereshchagin
697bb76589 tests: fuzz client_send_message
to make sure outgoing packets based on incoming packets are fine.
It's just another follow-up to
https://github.com/systemd/systemd/pull/10200.
Better late than never :-)
2022-02-03 13:43:49 +09:00
6 changed files with 71 additions and 8 deletions

View File

@ -44,8 +44,8 @@ enum loader_type {
LOADER_UNDEFINED,
LOADER_AUTO,
LOADER_EFI,
LOADER_LINUX,
LOADER_STUB,
LOADER_LINUX, /* Boot loader spec type #1 entries */
LOADER_UNIFIED_LINUX, /* Boot loader spec type #2 entries */
};
typedef struct {
@ -856,13 +856,13 @@ static BOOLEAN menu_run(
case KEYPRESS(0, 0, 'E'):
/* only the options of configured entries can be edited */
if (!config->editor || !IN_SET(config->entries[idx_highlight]->type,
LOADER_EFI, LOADER_LINUX, LOADER_STUB))
LOADER_EFI, LOADER_LINUX, LOADER_UNIFIED_LINUX))
break;
/* The stub will not accept command line options when secure boot is enabled
* unless there is none embedded in the image. Do not try to pretend we
* can edit it to only have it be ignored. */
if (config->entries[idx_highlight]->type == LOADER_STUB &&
/* Unified kernels that are signed as a whole will not accept command line options
* when secure boot is enabled unless there is none embedded in the image. Do not try
* to pretend we can edit it to only have it be ignored. */
if (config->entries[idx_highlight]->type == LOADER_UNIFIED_LINUX &&
secure_boot_enabled() &&
config->entries[idx_highlight]->options)
break;
@ -2196,7 +2196,7 @@ static void config_entry_add_linux(
entry = config_entry_add_loader(
config,
device,
LOADER_STUB,
LOADER_UNIFIED_LINUX,
f->FileName,
/* key= */ 'l',
good_name,

View File

@ -0,0 +1,59 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "fuzz.h"
#include "sd-dhcp6-client.c"
int dhcp6_network_send_udp_socket(int s, struct in6_addr *server_address,
const void *packet, size_t len) {
return len;
}
int dhcp6_network_bind_udp_socket(int index, struct in6_addr *local_address) {
int fd;
fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
assert_se(fd >= 0);
return fd;
}
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_(sd_event_unrefp) sd_event *e = NULL;
_cleanup_(sd_dhcp6_client_unrefp) sd_dhcp6_client *client = NULL;
struct in6_addr address = { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01 } } };
triple_timestamp t = {};
usec_t time_now;
int r;
if (size < sizeof(DHCP6Message))
return 0;
assert_se(sd_event_new(&e) >= 0);
assert_se(sd_dhcp6_client_new(&client) >= 0);
assert_se(sd_dhcp6_client_attach_event(client, e, 0) >= 0);
assert_se(sd_dhcp6_client_set_ifindex(client, 42) == 0);
assert_se(sd_dhcp6_client_set_fqdn(client, "example.com") == 1);
assert_se(sd_dhcp6_client_set_request_mud_url(client, "https://www.example.com/mudfile.json") >= 0);
assert_se(sd_dhcp6_client_set_request_user_class(client, STRV_MAKE("u1", "u2", "u3")) >= 0);
assert_se(sd_dhcp6_client_set_request_vendor_class(client, STRV_MAKE("v1", "v2", "v3")) >= 0);
assert_se(sd_dhcp6_client_set_local_address(client, &address) >= 0);
assert_se(sd_dhcp6_client_set_information_request(client, false) == 0);
dhcp6_client_set_test_mode(client, true);
assert_se(sd_dhcp6_client_start(client) >= 0);
assert_se(sd_dhcp6_client_set_transaction_id(client, htobe32(0x00ffffff) & ((const DHCP6Message *) data)->transaction_id) == 0);
triple_timestamp_get(&t);
if (client_receive_advertise(client, (DHCP6Message *) data, size, &t, NULL) != DHCP6_STATE_REQUEST)
goto cleanup;
r = sd_event_now(client->event, clock_boottime_or_monotonic(), &time_now);
if (r < 0)
goto cleanup;
client->state = DHCP6_STATE_REQUEST;
(void) client_send_message(client, time_now);
cleanup:
assert_se(sd_dhcp6_client_stop(client) >= 0);
return 0;
}

View File

@ -113,6 +113,10 @@ fuzzers += [
[libshared,
libsystemd_network]],
[files('fuzz-dhcp6-client-send.c'),
[libshared,
libsystemd_network]],
[files('fuzz-dhcp-server.c'),
[libsystemd_network,
libshared]],