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] [day] [month] [year] [list]
Message-ID: <CAFb8wJsPgfE2WRE2wcuYUwkqr27vGOPVv_VHJttQzWoA3dL_0Q@mail.gmail.com>
Date: Sat, 31 Jan 2026 08:15:44 +0800
From: eanut 6 <jiakaipeanut@...il.com>
To: Andrew Jones <andrew.jones@....qualcomm.com>
Cc: linux-kernel@...r.kernel.org, linux-riscv@...ts.infradead.org, 
	kvm-riscv@...ts.infradead.org, kvm@...r.kernel.org, 
	Alexandre Ghiti <alex@...ti.fr>, Albert Ou <aou@...s.berkeley.edu>, 
	Palmer Dabbelt <palmer@...belt.com>, Paul Walmsley <pjw@...nel.org>, Atish Patra <atish.patra@...ux.dev>, 
	Anup Patel <anup@...infault.org>, Jiakai Xu <xujiakai2025@...as.ac.cn>
Subject: Re: [PATCH] RISC-V: KVM: Validate SBI STA shmem alignment in kvm_sbi_ext_sta_set_reg

Thanks for the review.

I’ll send a v2 shortly with these changes.

Thanks,
Jiakai

On Sat, Jan 31, 2026 at 4:48 AM Andrew Jones
<andrew.jones@....qualcomm.com> wrote:
>
> On Sat, Jan 24, 2026 at 02:20:42AM +0000, Jiakai Xu wrote:
> ...
> > diff --git a/arch/riscv/kvm/vcpu_sbi_sta.c b/arch/riscv/kvm/vcpu_sbi_sta.c
> > index afa0545c3bcfc..7dfe671c42eaa 100644
> > --- a/arch/riscv/kvm/vcpu_sbi_sta.c
> > +++ b/arch/riscv/kvm/vcpu_sbi_sta.c
> > @@ -186,23 +186,25 @@ static int kvm_sbi_ext_sta_set_reg(struct kvm_vcpu *vcpu, unsigned long reg_num,
> >               return -EINVAL;
> >       value = *(const unsigned long *)reg_val;
> >
> > +     gpa_t new_shmem = vcpu->arch.sta.shmem;
>
> Please declare new_shmem at the top of the function and there's no
> need to initialize it to vcpu->arch.sta.shmem. Actually it appears you
> meant to initialize it to NULL, based on the 'if (new_shmem ...)' check
> below.
>
> > +
> >       switch (reg_num) {
> >       case KVM_REG_RISCV_SBI_STA_REG(shmem_lo):
> >               if (IS_ENABLED(CONFIG_32BIT)) {
> >                       gpa_t hi = upper_32_bits(vcpu->arch.sta.shmem);
> >
> > -                     vcpu->arch.sta.shmem = value;
> > -                     vcpu->arch.sta.shmem |= hi << 32;
> > +                     new_shmem = value;
> > +                     new_shmem |= hi << 32;
> >               } else {
> > -                     vcpu->arch.sta.shmem = value;
> > +                     new_shmem = value;
> >               }
> >               break;
> >       case KVM_REG_RISCV_SBI_STA_REG(shmem_hi):
> >               if (IS_ENABLED(CONFIG_32BIT)) {
> >                       gpa_t lo = lower_32_bits(vcpu->arch.sta.shmem);
> >
> > -                     vcpu->arch.sta.shmem = ((gpa_t)value << 32);
> > -                     vcpu->arch.sta.shmem |= lo;
> > +                     new_shmem = ((gpa_t)value << 32);
> > +                     new_shmem |= lo;
> >               } else if (value != 0) {
> >                       return -EINVAL;
> >               }
> > @@ -210,7 +212,10 @@ static int kvm_sbi_ext_sta_set_reg(struct kvm_vcpu *vcpu, unsigned long reg_num,
> >       default:
> >               return -ENOENT;
> >       }
>
> Please add a blank line here.
>
> > +     if (new_shmem && !IS_ALIGNED(new_shmem, 64))
> > +             return -EINVAL;
> >
> > +     vcpu->arch.sta.shmem = new_shmem;
>
> And another blank line here.
>
> >       return 0;
> >  }
> >
> > --
> > 2.34.1
> >
>
> Thanks,
> drew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ