[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: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 17 Sep 2021 14:58:35 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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=RONU+ejaKqP7oeNza1QQPRqupv8noL3rm/46uCuwdSk=; b=FY2uJA4cYtf9cXamrfAHu3QMOYpT746e86WlxSDPA2AjpjjWrBSIg2TAsvaLFnKZredyinfAtUUnuDvKCgFPAVnY8YfLH7h2es8SS8tAJaxKkv/MP3iY7/PCS4E8yVioRWgROS+80+tmrjy3g/2699O2gojQlVvuMu1SK4tWedIVt5PV4HW95hQDL2R91q8QmxqDzSc3VxB0Mx24bs7A8sbwPbRlRDfHsR23WzG+vLXv+X+A6bJxCSkHfejyurtfbf9OxM1ZVhM51bp6+DIqSHJgmC7BNuwuDrhuW+i/1V147BGMA5gKZhdT7VCJu+RuDxNbq1Sc1qpLo62wfgSYaA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XFEHw5XkJFcmpvX+NCQwd/9y1/kIrZbVzbNy3D7Woj9wQ3QYAdPHJsGjdkJ0sKg6QI5Jge7/m0J28vBMKfO7O8Cmn5TwWzy+GS4psUtalAKvvViDXxGSnkDHFxoagnBgGEHTKSqHDXr888qGNjdKaNmphpGV8Qm3FVbkZGLZBjcMhvVs1Oah6yJdloTMCK4RQnqW4eKfCymW3npndfDCgtOS6wAe7a17NCVdoddAN+EcRZmHdPiYKGEllxyFRskS+VBY+MYKybMbfWYrQ0dxeAjN/jo9kIKGpRzAkg0bMTAWUs1yC51tiMPHETRoOxSPT9tovtYocD+RDlP2d+gcqw==
  • Authentication-results: lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=suse.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: Fri, 17 Sep 2021 12:58:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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? They may very well come without extra data
afaics.

> +    if ( extra % sizeof(uint32_t) ||
> +         extra / sizeof(uint32_t) > TRACE_EXTRA_MAX )
> +        return printk_once(XENLOG_WARNING
> +                           "Trace event %#x bad size %u, discarding\n",
> +                           event, extra);

Any HVM guest looks to be able to trivially trigger this log message
(via HVMOP_xentrace), thus pointing out an issue in a guest and hiding
any other Xen related output. I'd like to suggest to adjust that call
site in prereq patch (I'm not overly fussed which of the two relatively
obvious ways).

Further sched/rt.c:burn_budget() has a bool field last in a packed
struct, yielding a sizeof() that's not a multiple of 4. All the uses of
__packed there look at best suspicious anyway.

Jan




 


Rackspace

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