Messages in this thread Patch in this message |  | | Subject | Re: [PATCH v2 04/16] skbuff: Phase out ksize() fallback for frag_size | From | Paolo Abeni <> | Date | Sun, 25 Sep 2022 09:17:40 +0200 |
| |
On Fri, 2022-09-23 at 13:28 -0700, Kees Cook wrote: > All callers of APIs that allowed a 0-sized frag_size appear to be > passing actual size information already
AFAICS, not yet:
drivers/net/ethernet/qlogic/qed/qed_ll2.c: skb = build_skb(buffer->data, 0); // -> __build_skb(..., 0) // -> __build_skb_around()
drivers/net/ethernet/broadcom/bnx2.c: skb = build_skb(data, 0);
I guess some more drivers have calls leading to
__build_skb_around(..., 0)
there are several call path to checks...
> , so this use of ksize() can > be removed. However, just in case there is something still depending > on this behavior, issue a WARN and fall back to as before to ksize() > which means we'll also potentially get KASAN warnings. > > Cc: "David S. Miller" <davem@davemloft.net> > Cc: Eric Dumazet <edumazet@google.com> > Cc: Jakub Kicinski <kuba@kernel.org> > Cc: Paolo Abeni <pabeni@redhat.com> > Cc: netdev@vger.kernel.org > Signed-off-by: Kees Cook <keescook@chromium.org> > --- > net/core/skbuff.c | 18 ++++++++++-------- > 1 file changed, 10 insertions(+), 8 deletions(-) > > diff --git a/net/core/skbuff.c b/net/core/skbuff.c > index 0b30fbdbd0d0..84ca89c781cd 100644 > --- a/net/core/skbuff.c > +++ b/net/core/skbuff.c > @@ -195,7 +195,11 @@ static void __build_skb_around(struct sk_buff *skb, void *data, > unsigned int frag_size) > { > struct skb_shared_info *shinfo; > - unsigned int size = frag_size ? : ksize(data); > + unsigned int size = frag_size; > + > + /* All callers should be setting frag size now? */ > + if (WARN_ON_ONCE(size == 0)) > + size = ksize(data);
At some point in the future, I guess we could even drop this check, right?
Thanks!
Paolo
|  |