# HG changeset patch # User Paul Boddie # Date 1705859084 -3600 # Node ID b6288af98f9345966fb5950e10a8a0ec31bf8fe5 # Parent 09a9290aea31db8aed4b4d60b7b4dbc513e689fe Fixed mapping to permit the inclusion of undefined/invalid capabilities without terminating the mapping operation. diff -r 09a9290aea31 -r b6288af98f93 libexec/lib/src/process.cc --- a/libexec/lib/src/process.cc Sun Jan 21 17:56:36 2024 +0100 +++ b/libexec/lib/src/process.cc Sun Jan 21 18:44:44 2024 +0100 @@ -1,7 +1,7 @@ /* * Support for initialising programs in new tasks and threads. * - * Copyright (C) 2022, 2023 Paul Boddie + * Copyright (C) 2022, 2023, 2024 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -144,7 +144,7 @@ {_env.log, l4re_env()->log, L4_CAP_FPAGE_RWS, 0}, {_env.scheduler, l4re_env()->scheduler, L4_CAP_FPAGE_RWS, 0}, {_env.mem_alloc, l4re_env()->mem_alloc, L4_CAP_FPAGE_RWS, 0}, - {0, L4_INVALID_CAP, 0, 0}, + {L4_INVALID_CAP, L4_INVALID_CAP, 0, 0}, }; /* Return the capability details for the task. */ diff -r 09a9290aea31 -r b6288af98f93 libexec/lib/src/process_creating.cc --- a/libexec/lib/src/process_creating.cc Sun Jan 21 17:56:36 2024 +0100 +++ b/libexec/lib/src/process_creating.cc Sun Jan 21 18:44:44 2024 +0100 @@ -1,7 +1,7 @@ /* * Support for executing code in new tasks and threads. * - * Copyright (C) 2022, 2023 Paul Boddie + * Copyright (C) 2022, 2023, 2024 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -215,7 +215,7 @@ rm_mapped_caps[rm_index++] = (struct ipc_mapped_cap) {_mapped_internal_pager, _internal_pager, L4_CAP_FPAGE_RWS, L4_FPAGE_C_OBJ_RIGHTS}; - rm_mapped_caps[rm_index] = (struct ipc_mapped_cap) {0, L4_INVALID_CAP, 0, 0}; + rm_mapped_caps[rm_index] = (struct ipc_mapped_cap) {L4_INVALID_CAP, L4_INVALID_CAP, 0, 0}; /* Map these additional capabilities. */ @@ -326,7 +326,7 @@ struct ipc_mapped_cap program_mapped_caps[] = { {fsserver_cap, fsserver, L4_CAP_FPAGE_RWS, L4_FPAGE_C_OBJ_RIGHTS}, {writer_cap, writer, L4_CAP_FPAGE_RWS, L4_FPAGE_C_OBJ_RIGHTS}, - {0, L4_INVALID_CAP, 0, 0}, + {L4_INVALID_CAP, L4_INVALID_CAP, 0, 0}, }; /* Map these additional capabilities. */ diff -r 09a9290aea31 -r b6288af98f93 libipc/lib/src/map.c --- a/libipc/lib/src/map.c Sun Jan 21 17:56:36 2024 +0100 +++ b/libipc/lib/src/map.c Sun Jan 21 18:44:44 2024 +0100 @@ -1,7 +1,7 @@ /* * Capability mapping between tasks. * - * Copyright (C) 2022, 2023 Paul Boddie + * Copyright (C) 2022, 2023, 2024 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -46,8 +46,13 @@ long err = L4_EOK; unsigned int i; - for (i = 0; l4_is_valid_cap(mapped_caps[i].cap) && !err; i++) - err = ipc_map_capability(task, mapped_caps[i]); + /* Use an invalid mapped capability as the sentinel. */ + + for (i = 0; l4_is_valid_cap(mapped_caps[i].mapped_cap) && !err; i++) + { + if (l4_is_valid_cap(mapped_caps[i].cap)) + err = ipc_map_capability(task, mapped_caps[i]); + } if (count != NULL) *count = i;