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]
Message-ID: <Z8HPENTMF5xZikVd@kbusch-mbp>
Date: Fri, 28 Feb 2025 07:58:24 -0700
From: Keith Busch <kbusch@...nel.org>
To: Sean Christopherson <seanjc@...gle.com>
Cc: Lei Yang <leiyang@...hat.com>, Keith Busch <kbusch@...a.com>,
	pbonzini@...hat.com, kvm@...r.kernel.org,
	virtualization@...ts.linux.dev, x86@...nel.org,
	netdev@...r.kernel.org
Subject: Re: [PATCHv3 0/2]

On Fri, Feb 28, 2025 at 06:32:47AM -0800, Sean Christopherson wrote:
> On Fri, Feb 28, 2025, Sean Christopherson wrote:
> > On Fri, Feb 28, 2025, Lei Yang wrote:
> > > Hi Keith
> > > 
> > > V3 introduced a new bug, the following error messages from qemu output
> > > after applying this patch to boot up a guest.
> > 
> > Doh, my bug.  Not yet tested, but this should fix things.  Assuming it does, I'll
> > post a v3 so I can add my SoB.
>          v4
> 
> Confirmed that it worked, but deleting the pre-mutex check for ONCE_COMPLETED.
> Will post v4 later today.
> 
> > diff --git a/include/linux/call_once.h b/include/linux/call_once.h
> > index ddcfd91493ea..b053f4701c94 100644
> > --- a/include/linux/call_once.h
> > +++ b/include/linux/call_once.h
> > @@ -35,10 +35,12 @@ static inline int call_once(struct once *once, int (*cb)(struct once *))
> >                 return 0;
> >  
> >          guard(mutex)(&once->lock);
> > -        WARN_ON(atomic_read(&once->state) == ONCE_RUNNING);
> > -        if (atomic_read(&once->state) != ONCE_NOT_STARTED)
> > +        if (WARN_ON(atomic_read(&once->state) == ONCE_RUNNING))
> >                  return -EINVAL;
> >  
> > +        if (atomic_read(&once->state) == ONCE_COMPLETED)
> > +                return 0;
> > +
> >          atomic_set(&once->state, ONCE_RUNNING);
> >         r = cb(once);
> >         if (r)

Possible suggestion since it seems odd to do an atomic_read twice on the
same value. Maybe make this a switch:

	switch (atomic_read(&once->state) {
	case ONCE_NOT_STARTED:
		atomic_set(&once->state, ONCE_RUNNING);
		break;
	case ONCE_COMPLETED:
		return 0;
	case ONCE_RUNNING:
	default:
		WARN_ON(1);
		return -EINVAL;
	} 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ