lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 22 Nov 2021 14:03:59 -0800 (PST)
From:   Stefano Stabellini <sstabellini@...nel.org>
To:     Jan Beulich <jbeulich@...e.com>
cc:     Stefano Stabellini <sstabellini@...nel.org>,
        boris.ostrovsky@...cle.com, xen-devel@...ts.xenproject.org,
        linux-kernel@...r.kernel.org,
        Stefano Stabellini <stefano.stabellini@...inx.com>,
        stable@...r.kernel.org, jgross@...e.com
Subject: Re: [PATCH v2] xen: detect uninitialized xenbus in xenbus_init

On Mon, 22 Nov 2021, Jan Beulich wrote:
> On 19.11.2021 21:29, Stefano Stabellini wrote:
> > --- a/drivers/xen/xenbus/xenbus_probe.c
> > +++ b/drivers/xen/xenbus/xenbus_probe.c
> > @@ -951,6 +951,20 @@ static int __init xenbus_init(void)
> >  		err = hvm_get_parameter(HVM_PARAM_STORE_PFN, &v);
> >  		if (err)
> >  			goto out_error;
> > +		/* Uninitialized. */
> > +		if (v == 0 || v == ULLONG_MAX) {
> 
> Didn't you have a comment in v1 here regarding the check against 0? Or was that
> just like now only in the description? IOW I think there ought to be a code
> comment justifying the theoretically wrong check ...

Yeah, I added all the info in the commit message and shortened the
in-code comment this time. I am also happy to keep the details in the
in-code comment, e.g.:

/*
 * If the xenstore page hasn't been allocated properly, reading the
 * value of the related hvm_param (HVM_PARAM_STORE_PFN) won't actually
 * return error. Instead, it will succeed and return zero. Instead of
 * attempting to xen_remap a bad guest physical address, detect this
 * condition and return early.
 *
 * Note that although a guest physical address of zero for
 * HVM_PARAM_STORE_PFN is theoretically possible, it is not a good
 * choice and zero has never been validly used in that capacity.
 *
 * Also recognize the invalid value of INVALID_PFN which is ULLONG_MAX.
 */


> Also, while I realize there are various other similar assumptions elsewhere, I
> would generally recommend to avoid such: There's no guarantee that now and
> forever unsigned long long and uint64_t are the same thing. And it's easy in
> cases like this one:
> 
> 		if (!v || !(v + 1)) {

I am happy to use this.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ