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, 20 Jun 2022 17:44:02 +0300
From:   Nikita Shubin <nikita.shubin@...uefel.me>
To:     Geert Uytterhoeven <geert@...ux-m68k.org>
Cc:     Atish Patra <atishp@...shpatra.org>, Will Deacon <will@...nel.org>,
        Sunil V L <sunilvl@...tanamicro.com>,
        João Mário Domingos 
        <joao.mario@...nico.ulisboa.pt>, linux@...ro.com,
        Nikita Shubin <n.shubin@...ro.com>,
        Paul Walmsley <paul.walmsley@...ive.com>,
        Palmer Dabbelt <palmer@...belt.com>,
        Albert Ou <aou@...s.berkeley.edu>,
        Anup Patel <anup@...infault.org>,
        Mark Rutland <mark.rutland@....com>,
        linux-riscv <linux-riscv@...ts.infradead.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Linux ARM <linux-arm-kernel@...ts.infradead.org>
Subject: Re: [PATCH v4 1/1] RISC-V: Create unique identification for SoC PMU

Hello Geert!

On Mon, 20 Jun 2022 09:50:14 +0200
Geert Uytterhoeven <geert@...ux-m68k.org> wrote:

> Hi Nikita,
> 
> On Sun, Jun 19, 2022 at 1:11 PM Nikita Shubin
> <nikita.shubin@...uefel.me> wrote:
> > From: Nikita Shubin <n.shubin@...ro.com>
> >
> > Provide RISC-V SBI PMU id to distinguish different cores or SoCs via
> > "devices/platform/riscv-pmu/id" sysfs entry.
> >
> > The identification is generated as string of marchid, mimpid,
> > mvendorid in hex format separated by coma - "0x70032,0x70032,0x0".
> >
> > The CSRs are detailed in the RISC-V privileged spec [1].
> > [1] https://github.com/riscv/riscv-isa-manual
> >
> > Inspired-by: João Mário Domingos <joao.mario@...nico.ulisboa.pt>
> > Signed-off-by: Nikita Shubin <n.shubin@...ro.com>  
> 
> Thanks for your patch!
> 
> > --- a/arch/riscv/kernel/sbi.c
> > +++ b/arch/riscv/kernel/sbi.c  
> 
> > --- a/drivers/perf/riscv_pmu_sbi.c
> > +++ b/drivers/perf/riscv_pmu_sbi.c
> > @@ -693,6 +693,28 @@ static int pmu_sbi_setup_irqs(struct riscv_pmu
> > *pmu, struct platform_device *pde return 0;
> >  }
> >
> > +static ssize_t id_show(struct device *dev,
> > +                               struct device_attribute *attr, char
> > *buf) +{
> > +       int len;
> > +       struct riscv_pmu *pmu = container_of(dev_get_drvdata(dev),
> > struct riscv_pmu, pmu); +
> > +       len = sprintf(buf, "%s\n", pmu->pmuid);
> > +       if (len <= 0)
> > +               dev_err(dev, "invalid sprintf len: %d\n", len);  
> 
> How can this fail?
> 
> Please use sysfs_emit() instead of sprintf(), and drop the error
> message.

Indeed, thank you for your comments.

Also i missed some explicit free:

> > +out_free_pmuid:
> > +       kfree(pmu->pmuid);

This is not needed.

> 
> > +
> > +       return len;
> > +}  
> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 --
> geert@...ux-m68k.org
> 
> In personal conversations with technical people, I call myself a
> hacker. But when I'm talking to journalists I just say "programmer"
> or something like that. -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ