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:
 <PAXPR04MB8510790CAA16524DA0AC1A0D887F2@PAXPR04MB8510.eurprd04.prod.outlook.com>
Date: Wed, 9 Oct 2024 12:43:50 +0000
From: Wei Fang <wei.fang@....com>
To: Simon Horman <horms@...nel.org>
CC: "davem@...emloft.net" <davem@...emloft.net>, "edumazet@...gle.com"
	<edumazet@...gle.com>, "kuba@...nel.org" <kuba@...nel.org>,
	"pabeni@...hat.com" <pabeni@...hat.com>, "richardcochran@...il.com"
	<richardcochran@...il.com>, "csokas.bence@...lan.hu"
	<csokas.bence@...lan.hu>, Shenwei Wang <shenwei.wang@....com>, Clark Wang
	<xiaoning.wang@....com>, "linux@...ck-us.net" <linux@...ck-us.net>,
	"imx@...ts.linux.dev" <imx@...ts.linux.dev>, "netdev@...r.kernel.org"
	<netdev@...r.kernel.org>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>
Subject: RE: [PATCH net] net: fec: don't save PTP state if PTP is unsupported

> -----Original Message-----
> From: Simon Horman <horms@...nel.org>
> Sent: 2024年10月9日 19:55
> To: Wei Fang <wei.fang@....com>
> Cc: davem@...emloft.net; edumazet@...gle.com; kuba@...nel.org;
> pabeni@...hat.com; richardcochran@...il.com; csokas.bence@...lan.hu;
> Shenwei Wang <shenwei.wang@....com>; Clark Wang
> <xiaoning.wang@....com>; linux@...ck-us.net; imx@...ts.linux.dev;
> netdev@...r.kernel.org; linux-kernel@...r.kernel.org
> Subject: Re: [PATCH net] net: fec: don't save PTP state if PTP is unsupported
>
> On Tue, Oct 08, 2024 at 02:11:53PM +0800, Wei Fang wrote:
> > Some platforms (such as i.MX25 and i.MX27) do not support PTP, so on
> > these platforms fec_ptp_init() is not called and the related members
> > in fep are not initialized. However, fec_ptp_save_state() is called
> > unconditionally, which causes the kernel to panic. Therefore, add a
> > condition so that fec_ptp_save_state() is not called if PTP is not
> > supported.
> >
> > Fixes: a1477dc87dc4 ("net: fec: Restart PPS after link state change")
> > Reported-by: Guenter Roeck <linux@...ck-us.net>
> > Closes:
> https://lore.ker/
> nel.org%2Flkml%2F353e41fe-6bb4-4ee9-9980-2da2a9c1c508%40roeck-us.net
> %2F&data=05%7C02%7Cwei.fang%40nxp.com%7Cb10cac9ed8cd43284aae08
> dce85930cd%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63864
> 0716999752935%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLC
> JQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=1
> gxwnxNjk91xX7I%2Foco%2F4OhBbxNCryhDMo72O9Jkr2w%3D&reserved=0
> > Signed-off-by: Wei Fang <wei.fang@....com>
> > ---
> >  drivers/net/ethernet/freescale/fec_main.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/freescale/fec_main.c
> b/drivers/net/ethernet/freescale/fec_main.c
> > index 60fb54231ead..1b55047c0237 100644
> > --- a/drivers/net/ethernet/freescale/fec_main.c
> > +++ b/drivers/net/ethernet/freescale/fec_main.c
> > @@ -1077,7 +1077,8 @@ fec_restart(struct net_device *ndev)
> >     u32 rcntl = OPT_FRAME_SIZE | 0x04;
> >     u32 ecntl = FEC_ECR_ETHEREN;
> >
> > -   fec_ptp_save_state(fep);
> > +   if (fep->bufdesc_ex)
> > +           fec_ptp_save_state(fep);
>
> Hi,
>
> I am wondering if you considered adding this check to (the top of)
> fec_ptp_save_state. It seems like it would both lead to a smaller
> change and be less error-prone to use.
>

Yes, I considered this solution, but when I thought about it,
fec_ptp_save_state() and fec_ptp_restore_state() are a pair. If
the check is added to fec_ptp_save_state(), it is better to add
it to fec_ptp_restore_state(). However, considering that this is
not related to the current problem, and there are relatively few
calls to fec_ptp_restore_state(), I did not do this. If there are more
calls to fec_ptp_restore_state()/fec_ptp_restore_state() in the
future, I will consider it.

Thanks.

> >
> >     /* Whack a reset.  We should wait for this.
> >      * For i.MX6SX SOC, enet use AXI bus, we use disable MAC
> > @@ -1340,7 +1341,8 @@ fec_stop(struct net_device *ndev)
> >                     netdev_err(ndev, "Graceful transmit stop did not complete!\n");
> >     }
> >
> > -   fec_ptp_save_state(fep);
> > +   if (fep->bufdesc_ex)
> > +           fec_ptp_save_state(fep);
> >
> >     /* Whack a reset.  We should wait for this.
> >      * For i.MX6SX SOC, enet use AXI bus, we use disable MAC
> > --
> > 2.34.1
> >
> >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ