# HG changeset patch # User Paul Boddie # Date 1702318645 -3600 # Node ID 5283243773745a6c3556b0bd3a413b30f119322d # Parent b84b29de21ea4160f4ebe36e9eaa64df1e9958fd Permit the sending of deliberately invalid capabilities. diff -r b84b29de21ea -r 528324377374 libipc/lib/src/message.c --- a/libipc/lib/src/message.c Mon Dec 11 17:26:53 2023 +0100 +++ b/libipc/lib/src/message.c Mon Dec 11 19:17:25 2023 +0100 @@ -1,7 +1,7 @@ /* * Interprocess communication message abstraction. * - * Copyright (C) 2018, 2019, 2021, 2022 Paul Boddie + * Copyright (C) 2018, 2019, 2021, 2022, 2023 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 @@ -444,8 +444,16 @@ void ipc_message_export_capability(ipc_message_t *msg, int item, l4_cap_idx_t ref) { - msg->mregs.mr[msg->words + item * 2] = 0 | L4_ITEM_MAP; - msg->mregs.mr[msg->words + item * 2 + 1] = l4_obj_fpage(ref, 0, L4_FPAGE_RWX).raw; + if (l4_is_valid_cap(ref)) + { + msg->mregs.mr[msg->words + item * 2] = 0 | L4_ITEM_MAP; + msg->mregs.mr[msg->words + item * 2 + 1] = l4_obj_fpage(ref, 0, L4_FPAGE_RWX).raw; + } + else + { + msg->mregs.mr[msg->words + item * 2] = 0; + msg->mregs.mr[msg->words + item * 2 + 1] = 0; + } } /* Export a flexpage at the given position in the message. Here, the snd_base diff -r b84b29de21ea -r 528324377374 libipc/lib/src/util_ipc.c --- a/libipc/lib/src/util_ipc.c Mon Dec 11 17:26:53 2023 +0100 +++ b/libipc/lib/src/util_ipc.c Mon Dec 11 19:17:25 2023 +0100 @@ -1,7 +1,7 @@ /* * Interprocess communication abstractions. * - * Copyright (C) 2018, 2019, 2021, 2022 Paul Boddie + * Copyright (C) 2018, 2019, 2021, 2022, 2023 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 @@ -154,10 +154,10 @@ *local = 1; } - /* Unsupported item. */ + /* Unsupported item which may legitimately be an invalid capability. */ else - return -L4_EIO; + *ref = L4_INVALID_CAP; return L4_EOK; }