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: <20220912103818.j2u6afz66tcxvnr6@pengutronix.de>
Date:   Mon, 12 Sep 2022 12:38:18 +0200
From:   Marc Kleine-Budde <mkl@...gutronix.de>
To:     Bence Csókás <bence98@....bme.hu>
Cc:     netdev@...r.kernel.org, Richard Cochran <richardcochran@...il.com>,
        "David S . Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Francesco Dolcini <francesco.dolcini@...adex.com>,
        Andrew Lunn <andrew@...n.ch>,
        Guenter Roeck <linux@...ck-us.net>, kernel@...gutronix.de,
        Csókás Bence <csokas.bence@...lan.hu>
Subject: Re: [PATCH 1/2] Revert "net: fec: Use a spinlock to guard
 `fep->ptp_clk_on`"

On 12.09.2022 07:31:04, Bence Csókás wrote:
> From: Csókás Bence <csokas.bence@...lan.hu>
> 
> `clk_prepare_enable()` gets called in atomic context (holding a spinlock),
> which may sleep, causing a BUG on certain platforms.
> 
> This reverts commit b353b241f1eb9b6265358ffbe2632fdcb563354f.
> 
> Reported-by: Marc Kleine-Budde <mkl@...gutronix.de>
> Link: https://lore.kernel.org/all/20220907143915.5w65kainpykfobte@pengutronix.de/
> Signed-off-by: Csókás Bence <csokas.bence@...lan.hu>

This is not a 100% revert.

In b353b241f1eb ("net: fec: Use a spinlock to guard `fep->ptp_clk_on`")
the "struct fec_enet_private *fep" was renamed to "struct
fec_enet_private *adapter" for no apparent reason. The driver uses "fep"
everywhere else. This revert doesn't restore the original state.

This leads to the following diff against a 100% revert.

diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c
index c99dff3c3422..c74d04f4b2fd 100644
--- a/drivers/net/ethernet/freescale/fec_ptp.c
+++ b/drivers/net/ethernet/freescale/fec_ptp.c
@@ -365,21 +365,21 @@ static int fec_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
  */
 static int fec_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
 {
-       struct fec_enet_private *fep =
+       struct fec_enet_private *adapter =
            container_of(ptp, struct fec_enet_private, ptp_caps);
        u64 ns;
        unsigned long flags;
 
-       mutex_lock(&fep->ptp_clk_mutex);
+       mutex_lock(&adapter->ptp_clk_mutex);
        /* Check the ptp clock */
-       if (!fep->ptp_clk_on) {
-               mutex_unlock(&fep->ptp_clk_mutex);
+       if (!adapter->ptp_clk_on) {
+               mutex_unlock(&adapter->ptp_clk_mutex);
                return -EINVAL;
        }
-       spin_lock_irqsave(&fep->tmreg_lock, flags);
-       ns = timecounter_read(&fep->tc);
-       spin_unlock_irqrestore(&fep->tmreg_lock, flags);
-       mutex_unlock(&fep->ptp_clk_mutex);
+       spin_lock_irqsave(&adapter->tmreg_lock, flags);
+       ns = timecounter_read(&adapter->tc);
+       spin_unlock_irqrestore(&adapter->tmreg_lock, flags);
+       mutex_unlock(&adapter->ptp_clk_mutex);
 
        *ts = ns_to_timespec64(ns);

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ