[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AM6PR04MB3976D736CB1EFD55F0224E0BEC289@AM6PR04MB3976.eurprd04.prod.outlook.com>
Date: Tue, 18 Oct 2022 06:45:56 +0000
From: Madalin Bucur <madalin.bucur@....com>
To: Sean Anderson <sean.anderson@...o.com>,
"David S . Miller" <davem@...emloft.net>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Jakub Kicinski <kuba@...nel.org>,
Eric Dumazet <edumazet@...gle.com>,
Paolo Abeni <pabeni@...hat.com>,
Camelia Alexandra Groza <camelia.groza@....com>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Sean Anderson <sean.anderson@...o.com>
Subject: RE: [PATCH net] net: fman: Use physical address for userspace
interfaces
> -----Original Message-----
> From: Sean Anderson <sean.anderson@...o.com>
> Sent: 17 October 2022 19:28
> To: David S . Miller <davem@...emloft.net>; netdev@...r.kernel.org
> Cc: linux-kernel@...r.kernel.org; Madalin Bucur <madalin.bucur@....com>;
> Jakub Kicinski <kuba@...nel.org>; Eric Dumazet <edumazet@...gle.com>;
> Paolo Abeni <pabeni@...hat.com>; Camelia Alexandra Groza
> <camelia.groza@....com>; Geert Uytterhoeven <geert@...ux-m68k.org>; Sean
> Anderson <sean.anderson@...o.com>
> Subject: [PATCH net] net: fman: Use physical address for userspace
> interfaces
>
> For whatever reason, the address of the MAC is exposed to userspace in
> several places. We need to use the physical address for this purpose to
> avoid leaking information about the kernel's memory layout, and to keep
> backwards compatibility.
>
> Fixes: 262f2b782e25 ("net: fman: Map the base address once")
> Reported-by: Geert Uytterhoeven <geert@...ux-m68k.org>
> Signed-off-by: Sean Anderson <sean.anderson@...o.com>
> ---
>
> drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 4 ++--
> drivers/net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c | 2 +-
> drivers/net/ethernet/freescale/fman/mac.c | 12 ++++++------
> drivers/net/ethernet/freescale/fman/mac.h | 2 +-
> 4 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> index 31cfa121333d..fc68a32ce2f7 100644
> --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> @@ -221,8 +221,8 @@ static int dpaa_netdev_init(struct net_device *net_dev,
> net_dev->netdev_ops = dpaa_ops;
> mac_addr = mac_dev->addr;
>
> - net_dev->mem_start = (unsigned long)mac_dev->vaddr;
> - net_dev->mem_end = (unsigned long)mac_dev->vaddr_end;
> + net_dev->mem_start = (unsigned long)priv->mac_dev->res->start;
> + net_dev->mem_end = (unsigned long)priv->mac_dev->res->end;
>
> net_dev->min_mtu = ETH_MIN_MTU;
> net_dev->max_mtu = dpaa_get_max_mtu();
> diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c
> b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c
> index 258eb6c8f4c0..4fee74c024bd 100644
> --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c
> +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c
> @@ -18,7 +18,7 @@ static ssize_t dpaa_eth_show_addr(struct device *dev,
>
> if (mac_dev)
> return sprintf(buf, "%llx",
> - (unsigned long long)mac_dev->vaddr);
> + (unsigned long long)mac_dev->res->start);
> else
> return sprintf(buf, "none");
> }
> diff --git a/drivers/net/ethernet/freescale/fman/mac.c
> b/drivers/net/ethernet/freescale/fman/mac.c
> index 7b7526fd7da3..65df308bad97 100644
> --- a/drivers/net/ethernet/freescale/fman/mac.c
> +++ b/drivers/net/ethernet/freescale/fman/mac.c
> @@ -279,7 +279,6 @@ static int mac_probe(struct platform_device *_of_dev)
> struct device_node *mac_node, *dev_node;
> struct mac_device *mac_dev;
> struct platform_device *of_dev;
> - struct resource *res;
> struct mac_priv_s *priv;
> struct fman_mac_params params;
> u32 val;
> @@ -338,24 +337,25 @@ static int mac_probe(struct platform_device *_of_dev)
> of_node_put(dev_node);
>
> /* Get the address of the memory mapped registers */
> - res = platform_get_mem_or_io(_of_dev, 0);
> - if (!res) {
> + mac_dev->res = platform_get_mem_or_io(_of_dev, 0);
> + if (!mac_dev->res) {
> dev_err(dev, "could not get registers\n");
> return -EINVAL;
> }
>
> - err = devm_request_resource(dev, fman_get_mem_region(priv->fman),
> res);
> + err = devm_request_resource(dev, fman_get_mem_region(priv->fman),
> + mac_dev->res);
> if (err) {
> dev_err_probe(dev, err, "could not request resource\n");
> return err;
> }
>
> - mac_dev->vaddr = devm_ioremap(dev, res->start, resource_size(res));
> + mac_dev->vaddr = devm_ioremap(dev, mac_dev->res->start,
> + resource_size(mac_dev->res));
> if (!mac_dev->vaddr) {
> dev_err(dev, "devm_ioremap() failed\n");
> return -EIO;
> }
> - mac_dev->vaddr_end = mac_dev->vaddr + resource_size(res);
>
> if (!of_device_is_available(mac_node))
> return -ENODEV;
> diff --git a/drivers/net/ethernet/freescale/fman/mac.h
> b/drivers/net/ethernet/freescale/fman/mac.h
> index b95d384271bd..13b69ca5f00c 100644
> --- a/drivers/net/ethernet/freescale/fman/mac.h
> +++ b/drivers/net/ethernet/freescale/fman/mac.h
> @@ -20,8 +20,8 @@ struct mac_priv_s;
>
> struct mac_device {
> void __iomem *vaddr;
> - void __iomem *vaddr_end;
> struct device *dev;
> + struct resource *res;
> u8 addr[ETH_ALEN];
> struct fman_port *port[2];
> u32 if_support;
> --
> 2.35.1.1320.gc452695387.dirty
Thanks for the fix,
Acked-by: Madalin Bucur <madalin.bucur@....nxp.com>
Powered by blists - more mailing lists