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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuE1bG_+qj++Q0OXfBe3Z_aA-zFj3nmzr9CHCuKJ_Jr19oWEg@mail.gmail.com>
Date: Mon, 14 Apr 2025 13:56:04 +0300
From: Sagi Maimon <maimon.sagi@...il.com>
To: Vadim Fedorenko <vadim.fedorenko@...ux.dev>
Cc: jonathan.lemon@...il.com, richardcochran@...il.com, andrew+netdev@...n.ch, 
	davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com, 
	linux-kernel@...r.kernel.org, netdev@...r.kernel.org
Subject: Re: [PATCH v1] ptp: ocp: fix NULL deref in _signal_summary_show

On Mon, Apr 14, 2025 at 12:37 PM Vadim Fedorenko
<vadim.fedorenko@...ux.dev> wrote:
>
> On 14/04/2025 09:54, Sagi Maimon wrote:
> > Sysfs signal show operations can invoke _signal_summary_show before
> > signal_out array elements are initialized, causing a NULL pointer
> > dereference. Add NULL checks for signal_out elements to prevent kernel
> > crashes.
> >
> > Fixes: b325af3cfab9 ("ptp: ocp: Add signal generators and update sysfs nodes")
> > Signed-off-by: Sagi Maimon <maimon.sagi@...il.com>
> > ---
> >   drivers/ptp/ptp_ocp.c | 3 +++
> >   1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> > index 7945c6be1f7c..4c7893539cec 100644
> > --- a/drivers/ptp/ptp_ocp.c
> > +++ b/drivers/ptp/ptp_ocp.c
> > @@ -3963,6 +3963,9 @@ _signal_summary_show(struct seq_file *s, struct ptp_ocp *bp, int nr)
> >       bool on;
> >       u32 val;
> >
> > +     if (!bp->signal_out[nr])
> > +             return;
> > +
> >       on = signal->running;
> >       sprintf(label, "GEN%d", nr + 1);
> >       seq_printf(s, "%7s: %s, period:%llu duty:%d%% phase:%llu pol:%d",
>
> That's not correct, the dereference of bp->signal_out[nr] happens before
> the check. But I just wonder how can that even happen?
>
The scenario (our case): on ptp_ocp_adva_board_init we
initiate only signals 0 and 1 so 2 and 3 are NULL.
Later ptp_ocp_summary_show runs on all 4 signals and calls _signal_summary_show
when calling signal 2 or 3  the dereference occurs.
can you please explain: " the dereference of bp->signal_out[nr] happens before
the check", where exactly? do you mean in those lines:
struct signal_reg __iomem *reg = bp->signal_out[nr]->mem;
struct ptp_ocp_signal *signal = &bp->signal[nr];
> I believe the proper fix is to move ptp_ocp_attr_group_add() closer to
> the end of ptp_ocp_adva_board_init() like it's done for other boards.
>
> --
> pw-bot: cr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ