From: Fabiano Rosas <farosas@suse.de>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, Peter Xu <peterx@redhat.com>,
Richard Henderson <richard.henderson@linaro.org>
Subject: Re: [PULL 27/34] migration/multifd: Move nocomp code into multifd-nocomp.c
Date: Mon, 09 Sep 2024 12:01:01 -0300 [thread overview]
Message-ID: <87ikv4lvma.fsf@suse.de> (raw)
In-Reply-To: <CAFEAcA_F2qrSAacY=V5Hez1qFGuNW0-XqL2LQ=Y_UKYuHEJWhw@mail.gmail.com>
Peter Maydell <peter.maydell@linaro.org> writes:
> On Wed, 4 Sept 2024 at 13:48, Fabiano Rosas <farosas@suse.de> wrote:
>>
>> In preparation for adding new payload types to multifd, move most of
>> the no-compression code into multifd-nocomp.c. Let's try to keep a
>> semblance of layering by not mixing general multifd control flow with
>> the details of transmitting pages of ram.
>>
>> There are still some pieces leftover, namely the p->normal, p->zero,
>> etc variables that we use for zero page tracking and the packet
>> allocation which is heavily dependent on the ram code.
>>
>> Reviewed-by: Peter Xu <peterx@redhat.com>
>> Signed-off-by: Fabiano Rosas <farosas@suse.de>
>
> I know Coverity has only flagged this up because the
> code has moved, but it seems like a good place to ask
> the question:
>
>> +void multifd_ram_fill_packet(MultiFDSendParams *p)
>> +{
>> + MultiFDPacket_t *packet = p->packet;
>> + MultiFDPages_t *pages = &p->data->u.ram;
>> + uint32_t zero_num = pages->num - pages->normal_num;
>> +
>> + packet->pages_alloc = cpu_to_be32(multifd_ram_page_count());
>> + packet->normal_pages = cpu_to_be32(pages->normal_num);
>> + packet->zero_pages = cpu_to_be32(zero_num);
>> +
>> + if (pages->block) {
>> + strncpy(packet->ramblock, pages->block->idstr, 256);
>
> Coverity points out that when we fill in the RAMBlock::idstr
> here, if packet->ramblock is not NUL terminated then we won't
> NUL-terminate idstr either (CID 1560071).
>
> Is this really what is intended?
This is probably an oversight, although the migration destination
truncates it before reading:
/* make sure that ramblock is 0 terminated */
packet->ramblock[255] = 0;
p->block = qemu_ram_block_by_name(packet->ramblock);
If we ever start reading packet->ramblock on the source side in the
future, then there might be a problem.
>
> Perhaps
> pstrncpy(packet->ramblock, sizeof(packet->ramblock),
> pages->block->idstr);
>
> would be better?
Yep, thanks. I'll send a patch.
>
> (pstrncpy will always NUL-terminate, and won't pointlessly
> zero-fill the space after the string in the destination.)
>
>> + }
>> +
>> + for (int i = 0; i < pages->num; i++) {
>> + /* there are architectures where ram_addr_t is 32 bit */
>> + uint64_t temp = pages->offset[i];
>> +
>> + packet->offset[i] = cpu_to_be64(temp);
>> + }
>> +
>> + trace_multifd_send_ram_fill(p->id, pages->normal_num,
>> + zero_num);
>> +}
>
> thanks
> -- PMM
next prev parent reply other threads:[~2024-09-09 15:01 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-04 12:43 [PULL 00/34] Migration patches for 2024-09-04 Fabiano Rosas
2024-09-04 12:43 ` [PULL 01/34] migration: delete unused parameter mis Fabiano Rosas
2024-09-04 12:43 ` [PULL 02/34] tests/qtest/migration: Remove vmstate-static-checker test Fabiano Rosas
2024-09-04 12:43 ` [PULL 03/34] tests/qtest/migration-test: Fix bootfile cleanup handling Fabiano Rosas
2024-09-04 12:43 ` [PULL 04/34] tests/qtest/migration-test: Don't leak resp in multifd_mapped_ram_fdset_end() Fabiano Rosas
2024-09-04 12:43 ` [PULL 05/34] tests/qtest/migration-test: Fix leaks in calc_dirtyrate_ready() Fabiano Rosas
2024-09-04 12:43 ` [PULL 06/34] tests/qtest/migration-helpers: Fix migrate_get_socket_address() leak Fabiano Rosas
2024-09-04 12:43 ` [PULL 07/34] tests/qtest/migration-test: Free QCRyptoTLSTestCertReq objects Fabiano Rosas
2024-09-04 12:43 ` [PULL 08/34] tests/unit/crypto-tls-x509-helpers: deinit privkey in test_tls_cleanup Fabiano Rosas
2024-09-04 12:43 ` [PULL 09/34] tests/qtest/migration-helpers: Don't dup argument to qdict_put_str() Fabiano Rosas
2024-09-04 12:43 ` [PULL 10/34] tests/qtest/migration-test: Don't strdup in get_dirty_rate() Fabiano Rosas
2024-09-04 12:43 ` [PULL 11/34] tests/qtest/migration-test: Don't leak QTestState in test_multifd_tcp_cancel() Fabiano Rosas
2024-09-04 12:43 ` [PULL 12/34] migration/multifd: Reduce access to p->pages Fabiano Rosas
2024-09-04 12:43 ` [PULL 13/34] migration/multifd: Inline page_size and page_count Fabiano Rosas
2024-09-04 12:43 ` [PULL 14/34] migration/multifd: Remove pages->allocated Fabiano Rosas
2024-09-04 12:43 ` [PULL 15/34] migration/multifd: Pass in MultiFDPages_t to file_write_ramblock_iov Fabiano Rosas
2024-09-04 12:43 ` [PULL 16/34] migration/multifd: Introduce MultiFDSendData Fabiano Rosas
2024-09-04 12:44 ` [PULL 17/34] migration/multifd: Make MultiFDPages_t:offset a flexible array member Fabiano Rosas
2024-09-04 12:44 ` [PULL 18/34] migration/multifd: Replace p->pages with an union pointer Fabiano Rosas
2024-09-04 12:44 ` [PULL 19/34] migration/multifd: Move pages accounting into multifd_send_zero_page_detect() Fabiano Rosas
2024-09-04 12:44 ` [PULL 20/34] migration/multifd: Remove total pages tracing Fabiano Rosas
2024-09-04 12:44 ` [PULL 21/34] migration/multifd: Isolate ram pages packet data Fabiano Rosas
2024-09-04 12:44 ` [PULL 22/34] migration/multifd: Don't send ram data during SYNC Fabiano Rosas
2024-09-04 12:44 ` [PULL 23/34] migration/multifd: Replace multifd_send_state->pages with client data Fabiano Rosas
2024-09-04 12:44 ` [PULL 24/34] migration/multifd: Allow multifd sync without flush Fabiano Rosas
2024-09-04 12:44 ` [PULL 25/34] migration/multifd: Standardize on multifd ops names Fabiano Rosas
2024-09-04 12:44 ` [PULL 26/34] migration/multifd: Register nocomp ops dynamically Fabiano Rosas
2024-09-04 12:44 ` [PULL 27/34] migration/multifd: Move nocomp code into multifd-nocomp.c Fabiano Rosas
2024-09-09 10:28 ` Peter Maydell
2024-09-09 10:37 ` Peter Maydell
2024-09-09 14:31 ` Peter Xu
2024-09-09 15:01 ` Fabiano Rosas [this message]
2024-09-04 12:44 ` [PULL 28/34] migration/multifd: Make MultiFDMethods const Fabiano Rosas
2024-09-04 12:44 ` [PULL 29/34] migration/multifd: Stop changing the packet on recv side Fabiano Rosas
2024-09-04 12:44 ` [PULL 30/34] migration/multifd: Fix p->iov leak in multifd-uadk.c Fabiano Rosas
2024-09-04 12:44 ` [PULL 31/34] migration/multifd: Add a couple of asserts for p->iov Fabiano Rosas
2024-09-04 12:44 ` [PULL 32/34] migration/multifd: Add documentation for multifd methods Fabiano Rosas
2024-09-04 12:44 ` [PULL 33/34] target/ppc: Fix migration of CPUs with TLB_EMB TLB type Fabiano Rosas
2024-09-04 12:44 ` [PULL 34/34] tests/qtest/migration: Add a check for the availability of the "pc" machine Fabiano Rosas
2024-09-05 12:01 ` [PULL 00/34] Migration patches for 2024-09-04 Peter Maydell
2024-09-05 14:46 ` Fabiano Rosas
2024-09-06 12:57 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ikv4lvma.fsf@suse.de \
--to=farosas@suse.de \
--cc=peter.maydell@linaro.org \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.