[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241121130127.5df61661@endymion.delvare>
Date: Thu, 21 Nov 2024 13:01:27 +0100
From: Jean Delvare <jdelvare@...e.de>
To: Leon Romanovsky <leon@...nel.org>
Cc: Bjorn Helgaas <helgaas@...nel.org>, Leon Romanovsky <leonro@...dia.com>,
Krzysztof Wilczyński <kw@...ux.com>,
linux-pci@...r.kernel.org, Ariel Almog <ariela@...dia.com>, Aditya Prabhune
<aprabhune@...dia.com>, Hannes Reinecke <hare@...e.de>, Heiner Kallweit
<hkallweit1@...il.com>, Arun Easi <aeasi@...vell.com>, Jonathan Chocron
<jonnyc@...zon.com>, Bert Kenward <bkenward@...arflare.com>, Matt Carlson
<mcarlson@...adcom.com>, Kai-Heng Feng <kai.heng.feng@...onical.com>, Alex
Williamson <alex.williamson@...hat.com>, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org, Jakub Kicinski <kuba@...nel.org>, Thomas
Weißschuh <linux@...ssschuh.net>, Stephen Hemminger
<stephen@...workplumber.org>
Subject: Re: [PATCH v2] PCI/sysfs: Change read permissions for VPD
attributes
Hi Leon,
On Wed, 13 Nov 2024 14:59:58 +0200, Leon Romanovsky wrote:
> --- a/drivers/pci/vpd.c
> +++ b/drivers/pci/vpd.c
> @@ -332,6 +332,14 @@ static umode_t vpd_attr_is_visible(struct kobject *kobj,
> if (!pdev->vpd.cap)
> return 0;
>
> + /*
> + * Mellanox devices have implementation that allows VPD read by
> + * unprivileged users, so just add needed bits to allow read.
> + */
> + WARN_ON_ONCE(a->attr.mode != 0600);
> + if (unlikely(pdev->vendor == PCI_VENDOR_ID_MELLANOX))
> + return a->attr.mode + 0044;
When manipulating bitfields, | is preferred. This would make the
operation safe regardless of the initial value, so you can even get rid
of the WARN_ON_ONCE() above.
> +
> return a->attr.mode;
> }
>
--
Jean Delvare
SUSE L3 Support
Powered by blists - more mailing lists