[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PULL 03/11] tools: build qemu-vmsr-helper
From: |
Peter Maydell |
Subject: |
Re: [PULL 03/11] tools: build qemu-vmsr-helper |
Date: |
Thu, 25 Jul 2024 11:28:16 +0100 |
On Tue, 23 Jul 2024 at 15:16, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> From: Anthony Harivel <aharivel@redhat.com>
>
> Introduce a privileged helper to access RAPL MSR.
Hi; Coverity points out an issue with this commit
(CID 1558555):
> +static void coroutine_fn vh_co_entry(void *opaque)
> +{
> + VMSRHelperClient *client = opaque;
> + Error *local_err = NULL;
> + unsigned int peer_pid;
> + uint32_t request[3];
> + uint64_t vmsr;
> + int r;
> +
> + qio_channel_set_blocking(QIO_CHANNEL(client->ioc),
> + false, NULL);
> +
> + qio_channel_set_follow_coroutine_ctx(QIO_CHANNEL(client->ioc), true);
> +
> + /*
> + * Check peer credentials
> + */
> + r = qio_channel_get_peerpid(QIO_CHANNEL(client->ioc),
> + &peer_pid,
> + &local_err);
> + if (r < 0) {
> + error_report_err(local_err);
> + goto out;
Here we have a check for r < 0 that forces an early exit...
> + }
> +
> + while (r < 0) {
...but then immediately we do a while (r < 0). r cannot be < 0
here because we just checked that, so this while loop will
never execute and the whole loop body is dead code.
What was the intention here ?
> + /*
> + * Read the requested MSR
> + * Only RAPL MSR in rapl-msr-index.h is allowed
> + */
> + r = qio_channel_read_all(QIO_CHANNEL(client->ioc),
> + (char *) &request, sizeof(request),
> &local_err);
> + if (r < 0) {
> + error_report_err(local_err);
> + break;
> + }
> +
> + if (!is_msr_allowed(request[0])) {
> + error_report("Requested unallowed msr: %d", request[0]);
> + break;
> + }
> +
> + vmsr = vmsr_read_msr(request[0], request[1]);
> +
> + if (!is_tid_present(peer_pid, request[2])) {
> + error_report("Requested TID not in peer PID: %d %d",
> + peer_pid, request[2]);
> + vmsr = 0;
> + }
> +
> + r = qio_channel_write_all(QIO_CHANNEL(client->ioc),
> + (char *) &vmsr,
> + sizeof(vmsr),
> + &local_err);
> + if (r < 0) {
> + error_report_err(local_err);
> + break;
> + }
> + }
> +out:
> + object_unref(OBJECT(client->ioc));
> + g_free(client);
> +}
thanks
-- PMM
- [PULL 00/11] target/i386, HPET changes for QEMU 9.1 soft freeze, Paolo Bonzini, 2024/07/23
- [PULL 01/11] target/i386: do not crash if microvm guest uses SGX CPUID leaves, Paolo Bonzini, 2024/07/23
- [PULL 02/11] qio: add support for SO_PEERCRED for socket channel, Paolo Bonzini, 2024/07/23
- [PULL 03/11] tools: build qemu-vmsr-helper, Paolo Bonzini, 2024/07/23
- Re: [PULL 03/11] tools: build qemu-vmsr-helper,
Peter Maydell <=
- [PULL 05/11] hpet: fix and cleanup persistence of interrupt status, Paolo Bonzini, 2024/07/23
- [PULL 04/11] Add support for RAPL MSRs in KVM/Qemu, Paolo Bonzini, 2024/07/23
- [PULL 07/11] hpet: remove unnecessary variable "index", Paolo Bonzini, 2024/07/23
- [PULL 08/11] hpet: place read-only bits directly in "new_val", Paolo Bonzini, 2024/07/23
- [PULL 06/11] hpet: ignore high bits of comparator in 32-bit mode, Paolo Bonzini, 2024/07/23
- [PULL 11/11] hpet: avoid timer storms on periodic timers, Paolo Bonzini, 2024/07/23
- [PULL 09/11] hpet: accept 64-bit reads and writes, Paolo Bonzini, 2024/07/23
- [PULL 10/11] hpet: store full 64-bit target value of the counter, Paolo Bonzini, 2024/07/23