From: Tobias Waldekranz <tobias@waldekranz•com>
To: Andrew Lunn <andrew@lunn•ch>
Cc: davem@davemloft•net, kuba@kernel•org, linux@armlinux•org.uk,
kabel@kernel•org, hkallweit1@gmail•com, robh+dt@kernel•org,
krzysztof.kozlowski+dt@linaro•org, conor+dt@kernel•org,
netdev@vger•kernel.org, devicetree@vger•kernel.org
Subject: Re: [PATCH net-next 1/4] net: phy: marvell10g: Support firmware loading on 88X3310
Date: Mon, 18 Dec 2023 18:11:55 +0100 [thread overview]
Message-ID: <871qbj8mg4.fsf@waldekranz.com> (raw)
In-Reply-To: <627fbf7d-5992-4c4b-9e32-b34e363db928@lunn.ch>
On fre, dec 15, 2023 at 15:30, Andrew Lunn <andrew@lunn•ch> wrote:
> On Thu, Dec 14, 2023 at 09:14:39PM +0100, Tobias Waldekranz wrote:
>> When probing, if a device is waiting for firmware to be loaded into
>> its RAM, ask userspace for the binary and load it over XMDIO.
>
> Does a device without firmware have valid ID registers? Is the driver
> going to probe via bus enumeration, or is it necessary to use a
> compatible with ID values?
>
>> + for (sect = fw->data; (sect + sizeof(hdr)) < (fw->data + fw->size);) {
>
> This validates that the firmware is big enough to hold the header...
>
>> + memcpy(&hdr, sect, sizeof(hdr));
>> + hdr.data.size = cpu_to_le32(hdr.data.size);
>> + hdr.data.addr = cpu_to_le32(hdr.data.addr);
>> + hdr.data.csum = cpu_to_le16(hdr.data.csum);
>> + hdr.next_hdr = cpu_to_le32(hdr.next_hdr);
>
> I'm surprised sparse is not complaining about this. You have the same
> source and destination, and sparse probably wants the destination to
> be marked as little endian.
>
>> + hdr.csum = cpu_to_le16(hdr.csum);
>> +
>> + for (i = 0, csum = 0; i < offsetof(struct mv3310_fw_hdr, csum); i++)
>> + csum += sect[i];
>> +
>> + if ((u16)~csum != hdr.csum) {
>> + dev_err(&phydev->mdio.dev, "Corrupt section header\n");
>> + err = -EINVAL;
>> + break;
>> + }
>> +
>> + err = mv3310_load_fw_sect(phydev, &hdr, sect + sizeof(hdr));
>
> What i don't see is any validation that the firmware left at sect +
> sizeof(hdr) big enough to contain hdr.data.size bytes.
>
Thanks Andrew and Russel, for the review!
You both make valid points, I'll try to be less clever about this whole
section in v2.
next prev parent reply other threads:[~2023-12-18 17:11 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-14 20:14 [PATCH net-next 0/4] net: phy: marvell10g: Firmware loading and LED support for 88X3310 Tobias Waldekranz
2023-12-14 20:14 ` [PATCH net-next 1/4] net: phy: marvell10g: Support firmware loading on 88X3310 Tobias Waldekranz
2023-12-15 14:30 ` Andrew Lunn
2023-12-15 14:34 ` Russell King (Oracle)
2023-12-18 17:11 ` Tobias Waldekranz [this message]
2023-12-15 14:33 ` Andrew Lunn
2023-12-15 15:52 ` Russell King (Oracle)
2023-12-16 14:35 ` kernel test robot
2023-12-19 9:22 ` Marek Behún
2023-12-19 10:15 ` Tobias Waldekranz
2023-12-19 10:49 ` Marek Behún
2023-12-19 13:15 ` Tobias Waldekranz
2024-01-02 10:12 ` Russell King (Oracle)
2024-01-02 13:09 ` Tobias Waldekranz
2024-10-06 16:15 ` Daniel Golle
2024-10-06 21:32 ` Tobias Waldekranz
2023-12-14 20:14 ` [PATCH net-next 2/4] net: phy: marvell10g: Fix power-up when strapped to start powered down Tobias Waldekranz
2023-12-15 15:44 ` Russell King (Oracle)
2023-12-18 18:02 ` Tobias Waldekranz
2023-12-14 20:14 ` [PATCH net-next 3/4] net: phy: marvell10g: Add LED support for 88X3310 Tobias Waldekranz
2023-12-15 14:44 ` Andrew Lunn
2023-12-15 15:12 ` Russell King (Oracle)
2023-12-18 15:55 ` Simon Horman
2023-12-14 20:14 ` [PATCH net-next 4/4] dt-bindings: net: marvell10g: Document LED polarity Tobias Waldekranz
2023-12-15 8:47 ` Krzysztof Kozlowski
2023-12-15 11:19 ` Andrew Lunn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871qbj8mg4.fsf@waldekranz.com \
--to=tobias@waldekranz$(echo .)com \
--cc=andrew@lunn$(echo .)ch \
--cc=conor+dt@kernel$(echo .)org \
--cc=davem@davemloft$(echo .)net \
--cc=devicetree@vger$(echo .)kernel.org \
--cc=hkallweit1@gmail$(echo .)com \
--cc=kabel@kernel$(echo .)org \
--cc=krzysztof.kozlowski+dt@linaro$(echo .)org \
--cc=kuba@kernel$(echo .)org \
--cc=linux@armlinux$(echo .)org.uk \
--cc=netdev@vger$(echo .)kernel.org \
--cc=robh+dt@kernel$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox