Re: [PATCH net v5 1/1] net/sched: fix pedit partial COW leading to page cache corruption
From: David Laight
Date: Sun May 31 2026 - 14:52:34 EST
On Sun, 31 May 2026 19:42:41 +0100
David Laight <david.laight.linux@xxxxxxxxx> wrote:
> On Sun, 31 May 2026 13:25:36 -0400
> Jamal Hadi Salim <jhs@xxxxxxxxxxxx> wrote:
....
> > >
> > > > + goto bad;
> > > > + if (skb_ensure_writable(skb, min_t(int, skb->len,
> > > > + write_len)))
>
> You've completely missed that the above has to include the write_offset.
And I've missed that write_len isn't the length you are going to write :-(
This version is unreadable....
A few one line comments can make all the difference.
I put these two in for a reason.
It took some effort to find out exactly what they did.
> > /* Ensure any needed headroom is writeable */
> > if (hoffset < 0 && skb_cow(skb, -hoffset)
> > goto bad;
> > /* Ensure the skb is writeable to the end of the area to be written.
> > * The data is pulled into the skb header. */
-- David