[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH mig] Check that msgt_name is always smaller than 255.
From: |
Samuel Thibault |
Subject: |
Re: [PATCH mig] Check that msgt_name is always smaller than 255. |
Date: |
Thu, 11 May 2023 01:27:25 +0200 |
User-agent: |
NeoMutt/20170609 (1.8.3) |
Applied, thanks!
Flavio Cruz, le mer. 10 mai 2023 01:39:54 -0400, a ecrit:
> For the x86_64 ABI we want this to always fit into 1 byte. Even for
> regular i686, msgt_name is always smaller than 25 (MACH_MSG_TYPE_LAST)
> and we don't have plans to have more names.
>
> Also throw an error if we deemed an RPC to be "TooLong" as that won't
> work or work badly.
>
> Tested by cross-compiling a basic Hurd system.
> ---
> type.c | 18 ++++++++++--------
> 1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/type.c b/type.c
> index 6158c14..253a194 100644
> --- a/type.c
> +++ b/type.c
> @@ -323,19 +323,21 @@ itUseLong(const ipc_type_t *it)
> if ((it->itVarArray && !it->itInLine) || it->itIndefinite)
> uselong = ShouldBeLong;
>
> + /* Check that msgt_name fits into 1 byte as the x86_64 ABI requires it.
> + Note that MACH_MSG_TYPE_POLYMORPHIC is -1 hence it is ignored. */
> if (((it->itInName != MACH_MSG_TYPE_POLYMORPHIC) &&
> (it->itInName >= (1<<8))) ||
> ((it->itOutName != MACH_MSG_TYPE_POLYMORPHIC) &&
> - (it->itOutName >= (1<<8))) ||
> - (it->itSize >= (1<<8)) ||
> + (it->itOutName >= (1<<8)))) {
> + error("Cannot have msgt_name greater than 255");
> + uselong = TooLong;
> + }
> +
> + if ((it->itSize >= (1<<8)) ||
> (it->itNumber >= (1<<12)))
> uselong = MustBeLong;
>
> - if (((it->itInName != MACH_MSG_TYPE_POLYMORPHIC) &&
> - (it->itInName >= (1<<16))) ||
> - ((it->itOutName != MACH_MSG_TYPE_POLYMORPHIC) &&
> - (it->itOutName >= (1<<16))) ||
> - (it->itSize >= (1<<16)))
> + if (it->itSize >= (1<<16))
> uselong = TooLong;
>
> return uselong;
> @@ -416,7 +418,7 @@ itCheckDecl(identifier_t name, ipc_type_t *it)
>
> uselong = itUseLong(it);
> if (uselong == TooLong)
> - warn("%s: too big for mach_msg_type_long_t", name);
> + error("%s: too big for mach_msg_type_long_t", name);
> it->itLongForm = itCheckIsLong(it, it->itFlags,
> (int)uselong >= (int)ShouldBeLong, name);
> }
> --
> 2.39.2
>
>
--
Samuel
---
Pour une évaluation indépendante, transparente et rigoureuse !
Je soutiens la Commission d'Évaluation de l'Inria.