qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [BUG] Inappropriate size of target_sigset_t


From: Laurent Vivier
Subject: Re: [Qemu-devel] [BUG] Inappropriate size of target_sigset_t
Date: Wed, 3 Jul 2019 22:39:56 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0

Le 03/07/2019 à 22:28, Peter Maydell a écrit :
> On Wed, 3 Jul 2019 at 21:20, Aleksandar Markovic <address@hidden> wrote:
>>
>> From: Laurent Vivier <address@hidden>
>>> If I compare with kernel, it looks good:
>>> ...
>>> I think there is no problem.
>>
>> Sure, thanks for such fast response - again, I am glad if you are right. 
>> However, for some reason, glibc (and musl too) define sigset_t differently 
>> than kernel. Please take a look. I am not sure if this is covered fine in 
>> our code.
> 
> Yeah, the libc definitions of sigset_t don't match the
> kernel ones (this is for obscure historical reasons IIRC).
> We're providing implementations of the target
> syscall interface, so our target_sigset_t should be the
> target kernel's version (and the target libc's version doesn't
> matter to us). On the other hand we will be using the
> host libc version, I think, so a little caution is required
> and it's possible we have some bugs in our code.

It's why we need host_to_target_sigset_internal() and
target_to_host_sigset_internal() that translates bits and bytes between
guest kernel interface and host libc interface.

void host_to_target_sigset_internal(target_sigset_t *d,
                                    const sigset_t *s)
{
    int i;
    target_sigemptyset(d);
    for (i = 1; i <= TARGET_NSIG; i++) {
        if (sigismember(s, i)) {
            target_sigaddset(d, host_to_target_signal(i));
        }
    }
}

void target_to_host_sigset_internal(sigset_t *d,
                                    const target_sigset_t *s)
{
    int i;
    sigemptyset(d);
    for (i = 1; i <= TARGET_NSIG; i++) {
        if (target_sigismember(s, i)) {
            sigaddset(d, target_to_host_signal(i));
        }
    }
}

Thanks,
Laurent



reply via email to

[Prev in Thread] Current Thread [Next in Thread]