From: Sean Anderson <sean.anderson@seco.com>
To: Andrew Lunn <andrew@lunn.ch>,
"Russell King (Oracle)" <linux@armlinux.org.uk>
Cc: Heiner Kallweit <hkallweit1@gmail.com>,
netdev@vger.kernel.org, "David S . Miller" <davem@davemloft.net>,
Vladimir Oltean <olteanv@gmail.com>,
linux-kernel@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>,
Eric Dumazet <edumazet@google.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Tobias Waldekranz <tobias@waldekranz.com>,
Jakub Kicinski <kuba@kernel.org>
Subject: Re: [PATCH net-next] net: mdio: Add netlink interface
Date: Tue, 7 Mar 2023 11:41:04 -0500 [thread overview]
Message-ID: <4249c911-91c8-5d56-78c2-460e8711456d@seco.com> (raw)
In-Reply-To: <537d82d4-9893-4329-874a-0a4f24af1a0d@lunn.ch>
On 3/7/23 08:47, Andrew Lunn wrote:
> On Mon, Mar 06, 2023 at 10:48:48PM +0000, Russell King (Oracle) wrote:
>> On Mon, Mar 06, 2023 at 03:45:16PM -0500, Sean Anderson wrote:
>> > +static int mdio_nl_eval(struct mdio_nl_xfer *xfer)
>> > +{
>> > + struct mdio_nl_insn *insn;
>> > + unsigned long timeout;
>> > + u16 regs[8] = { 0 };
>> > + int pc, ret = 0;
>>
>> So "pc" is signed.
>>
>> > + int phy_id, reg, prtad, devad, val;
>> > +
>> > + timeout = jiffies + msecs_to_jiffies(xfer->timeout_ms);
>> > +
>> > + mutex_lock(&xfer->mdio->mdio_lock);
>> > +
>> > + for (insn = xfer->prog, pc = 0;
>> > + pc < xfer->prog_len;
>>
>> xfer->prog_len is signed, so this is a signed comparison.
>>
>> > + case MDIO_NL_OP_JEQ:
>> > + if (__arg_ri(insn->arg0, regs) ==
>> > + __arg_ri(insn->arg1, regs))
>> > + pc += (s16)__arg_i(insn->arg2);
>>
>> This adds a signed 16-bit integer to pc, which can make pc negative.
>>
>> And so the question becomes... what prevents pc becoming negative
>> and then trying to use a negative number as an index?
>
> I don't know ebpf very well, but would it of caught this? I know the
> aim of this is to be simple, but due to its simplicity, we are loosing
> out on all the inherent safety of eBPF. Is a eBPF interface all that
> complex? I assume you just need to add some way to identify MDIO
> busses and kfunc to perform a read on the bus?
Regarding eBPF over netlink, the last time this was discussed, Tobias said
> - Why not use BPF?
>
> That could absolutely be one way forward, but the GENL approach was
> easy to build out-of-tree to prove the idea. Its not obvious how it
> would work though as BPF programs typically run async on some event
> (probe hit, packet received etc.) whereas this is a single execution
> on behalf of a user. So to what would the program be attached? The
> output path is also not straight forward, but it could be done with
> perf events i suppose.
I'm not familiar enough with eBPF to comment further.
--Sean
next prev parent reply other threads:[~2023-03-07 16:45 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-06 20:45 Sean Anderson
2023-03-06 22:48 ` Russell King (Oracle)
2023-03-06 23:39 ` Sean Anderson
2023-03-07 13:47 ` Andrew Lunn
2023-03-07 16:41 ` Sean Anderson [this message]
2023-03-07 0:05 ` kernel test robot
2023-03-07 11:23 ` Michael Walle
2023-03-07 13:49 ` Andrew Lunn
2023-03-07 14:05 ` Vladimir Oltean
2023-03-07 14:33 ` Andrew Lunn
2023-03-07 15:00 ` Russell King (Oracle)
2023-03-07 12:26 ` Tobias Waldekranz
2023-03-07 16:30 ` Sean Anderson
2023-03-07 14:22 ` Andrew Lunn
2023-03-07 14:50 ` Russell King (Oracle)
2023-03-07 16:16 ` Sean Anderson
2023-03-07 17:23 ` Andrew Lunn
2023-03-07 17:42 ` Sean Anderson
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=4249c911-91c8-5d56-78c2-460e8711456d@seco.com \
--to=sean.anderson@seco.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=tobias@waldekranz.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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
all inboxes | Powered by JetHome®