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

Re: [PATCH 1/6] xen/trace: Don't over-read trace objects


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Mon, 20 Sep 2021 11:24:45 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=52fKv83QhqJGhWASPxnT8whS4RezB2CT5RddIuOzg1A=; b=e3gbLLpDxLpG0JclEe2BTH22inzokOuSZ8w00nx2KxKBzdO1VKqe/zfrF/g881M5bjUnH8qUqWULtczASbsGlAlPeFzmddxYywZe0PfpqzifMtnzcUAO5627ajxeH+dGDwS0gHPOQBodMYfULCSWpOkdLP4OfSC2zKL+u1gWUuw+qca5VdIzksJsZk7sBagQrKqvkMH34mTFmHnus/S3Sr8CK9t5zndjtiwbQxOATrbyvaPIQTdvD6uXGQW8u6UrIHQ9G/KuynJipJLna2TKpUHo+LwvASW52MPCC8X2oE0OBDncl9CncdAKv1exEA/RAs3hRHLSK4fpE1RJHdz5qg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JKZ6015f7lOjirwy8KMnLBtd1N3P4UG78gKgPE5JxyHRi4r1G2mw4uGdgU4bU7WG5cGyWWLly+oTMpywImENlKtUSaPqrCkHnak3bSn73En0uM0qnFFqpBTgOSrRdHBe+xIVZ2AxxhYXZx/jOGkG1miwxdJUu45mGFPejjrmgo82DOV/77NlANWCBGsUc6/dmaIONeOy2GtMC6CE3VabvA3fLBVzMHMh1o8Lu7LftGMK4uuloCjOo6XVOSCGY1YATT+8padLnA1+z3khUmp97bBnCRR2W8suHqvpLnAJ1YxHDFwwICKzfUMgk8bWfJz5o8Nam+a3iLJeBA8/dwI9NQ==
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: George Dunlap <George.Dunlap@xxxxxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Dario Faggioli <dfaggioli@xxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 20 Sep 2021 10:25:22 +0000
  • Ironport-data: A9a23:ujfZ1amOH3mRRXh5ArhTUUPo5gwAIURdPkR7XQ2eYbSJt1+Wr1Gzt xJNDWuPO/uCMTD1eNgkYY/n/U5U6pSAx4RiSQI6pCxjESMWpZLJC+rCIxarNUt+DCFioGGLT Sk6QoOdRCzhZiaE/n9BClVlxJVF/fngqoDUUYYoAQgsA185IMsdoUg7wbdh09Qw2YLR7z6l4 rseneWOYDdJ5BYsWo4kw/rrRMRH5amaVJsw5zTSVNgT1LPsvyB94KE3fMldG0DQUIhMdtNWc s6YpF2PEsE1yD92Yj+tuu6TnkTn2dc+NyDW4pZdc/DKbhSvOkXee0v0XRYRQR4/ttmHozx+4 ItBr625TRUOB5XvtOJab0MHAR1AYKITrdcrIVDn2SCS50jPcn+qyPRyFkAme4Yf/46bA0kXq 6ZecmpUKEne2aTmm9pXScE17ignBODtMJkSpTdLyjbBAOx9aZvCX7/L9ZlT2zJYasVmQK2HP 5BFMmEHgBLoUgQRNRAZJosFxuaXlHTVaRxThkvEqv9ii4TU5FMoi+W8WDbPQfSRXtlclEuco mPA/kz6DwscOdjZziCKmlqtme3njS79QJgVFrCz6rhtmlL77m4ZBQASVFC7ieKkkUP4UNVaQ 2QL/gI+oK5081akJvHtUhv9rHOasxo0X9tLD/Z8+AyL0rDT4QuSGi4DVDEpQNAovcA5RDsu1 3eSgsjkQzdotdW9S2+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tg/J YlX69iCMDhSXhW5PyKhDVQyuxQo+VvJprY59vj8w==
  • Ironport-sdr: TCGJyqO8gytrFeIpPRGs7im+weToOjOzYFqtEZjrWOCUlthe8ZegqGGKKxC8bkpv7DSibcETZx UT4iebUJf0zm6Jvv/EeanHyBoUxi/PNTLt5inSHX6rkZ1m+CwphFnpPNxBkdDIE6eCLpL2UQRd n++XLe2NficoawfseuZJfL0EXfo72k/vo0UMTrCAftW9JLGyb8VS/+iPGXt/SX7gT9KJaCJqwT 4nqZX8rl8VgD0/ak9DdK0lxsW9hchg/JxeJ7SEPF8qN9rQp9RDWsizQ/CPUahrCug6wIl5vsxv es2WQ/vaJpM+yHKEqSYVGGDw
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 20/09/2021 09:00, Jan Beulich wrote:
> On 17.09.2021 15:26, Andrew Cooper wrote:
>> On 17/09/2021 13:58, Jan Beulich wrote:
>>> On 17.09.2021 10:45, Andrew Cooper wrote:
>>>> --- a/xen/common/trace.c
>>>> +++ b/xen/common/trace.c
>>>> @@ -686,22 +686,21 @@ void __trace_var(u32 event, bool_t cycles, unsigned 
>>>> int extra,
>>>>      unsigned long flags;
>>>>      u32 bytes_to_tail, bytes_to_wrap;
>>>>      unsigned int rec_size, total_size;
>>>> -    unsigned int extra_word;
>>>>      bool_t started_below_highwater;
>>>>  
>>>>      if( !tb_init_done )
>>>>          return;
>>>>  
>>>> -    /* Convert byte count into word count, rounding up */
>>>> -    extra_word = (extra / sizeof(u32));
>>>> -    if ( (extra % sizeof(u32)) != 0 )
>>>> -        extra_word++;
>>>> -    
>>>> -    ASSERT(extra_word <= TRACE_EXTRA_MAX);
>>>> -    extra_word = min_t(int, extra_word, TRACE_EXTRA_MAX);
>>>> -
>>>> -    /* Round size up to nearest word */
>>>> -    extra = extra_word * sizeof(u32);
>>>> +    /*
>>>> +     * Trace records require extra data which is an exact multiple of
>>>> +     * uint32_t.  Reject out-of-spec records.  Any failure here is an 
>>>> error in
>>>> +     * the caller.
>>>> +     */
>>> Hmm, is "require" accurate?
>> In terms of "what will go wrong if this condition is violated", yes.
>>
>>>  They may very well come without extra data
>>> afaics.
>> 0 is fine, and used by plenty of records, and also permitted by the
>> filtering logic.
> I was about to say that the two parts of your reply contradict one
> another, when I finally realized that it looks like the first sentence
> in the comment can be read two ways: "Trace records require extra data"
> then going on to describe properties, or "Trace records require extra
> data to be an exact multiple of uint32_t." Obviously this is to me as a
> non-native speaker. But maybe you could still reword this to be
> unambiguous? (I'm not going to exclude that the lack of a comma, which
> I did silently add while reading, makes a difference here: Does "Trace
> records require extra data, which is an exact multiple of uint32_t" end
> up altering the meaning?)

Yes.  The requirement is for "extra data which is an exact multiple of
uint32_t", not "extra data".

The comma massively changes the meaning.

I'll see about tweaking the wording.

~Andrew




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.