From nobody Wed Apr 19 21:50:27 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Q1vbl4qWPz45Gfh; Wed, 19 Apr 2023 21:50:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Q1vbl3tnxz3Bq6; Wed, 19 Apr 2023 21:50:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681941027; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=krqnTaDJy9bnPmJwH+MYAZGIECbupO2zH5Uhy3Z7y4s=; b=UYhj2kYn4yM4e9Vw7dNL/MyhcBK6Fxma0WmTp0o9uuK4WRLrHjt0aaMOraYFJiecjif1OO 6MlfQFOQeGxzuX1yfTY+RD0W2AnXZYlB3XoivzUJVB+RtOonLIVh4Pf9jEpX/YywyZGFSH pUxyIXrFdqjBdXcq8e/smmCgCVNGQqfEx8uvHbKSq/N8GhaDiG9ltQZGjTCABCCHKXmMhw 2+quVnXdPu2gw0YBTF2AILXGdepLYJQRJZGl3wXiC0bqLToYWIFV8axjhUg1bV//LgFlSZ BxhV5/4FmOi6Z5wju2olTkphmkmHiP/CUQ7VWxk4ekH9KTqeWZh22uV/UOOtzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681941027; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=krqnTaDJy9bnPmJwH+MYAZGIECbupO2zH5Uhy3Z7y4s=; b=I9sVAqhi0hkes28dAJwplkZOnLfsea8K0tCTOngjHaMPpbBbU/jXJrz4UKI1RGF8pJbxg1 1aPowR3mIPYXe+GrS4YK3Bu4qBkZ/ZRUX1FVB9Moc7DIk06zJq+C2EUmywkzbmKIYlf8MV 7TnmalgT3TX/G04DTXX80X5jzOgXFrvEhMxiaRrlUqk3odDB3fzsl7h9nTVcPMnjyCOr1f zJT2rqLZd4onkbXX0wvIPeYt8dDg01inBxa7v+jFX+drzw+SyCaMoPBJddmRNfuy0PTiqR Lqp8FGKbH1q8QrnNAYr3sY92UheFzJoneUK6wWPOMO8OFJNC99rt2hSh3gCmlw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1681941027; a=rsa-sha256; cv=none; b=ufLSTzlPl/LRooxoWpB3zytpEWJt0S1zauGoDivTE7QfXkQ2bUCBz4jO3HOAp4FQ6yNdIU ZTl8Xj5ROjMow4nvUJxHGJWVdUIjQkcRyqR6iuDDMretgCKyIXwlXRqddzdsuh0LpYAkGP wHiCkHRXm3VVPGZQFsSfU2XiXaUGoTvulS2wyk05+E3DvmK/ZYpj8sQujbLWZqW7z0tvs9 AtsXBlUUGdhNVvpusnsZF1EeVjt8mBgomsTMynYjzz/y9JiuFoo+J+95YTagX7SnhJqzcz +Lwi1ThEYGKM2znvCdxbd99ZzfM9jEhybP2mErchUC2kFQUx5lMhlC3AF78Zmw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Q1vbl2pF4z19rM; Wed, 19 Apr 2023 21:50:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 33JLoRrG027033; Wed, 19 Apr 2023 21:50:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33JLoRV7027032; Wed, 19 Apr 2023 21:50:27 GMT (envelope-from git) Date: Wed, 19 Apr 2023 21:50:27 GMT Message-Id: <202304192150.33JLoRV7027032@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: b2dcb848688e - main - LinuxKPI: skbuff.h: fix -Warray-bounds warnings List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b2dcb848688e1e8346762531208dd7d468ff3854 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=b2dcb848688e1e8346762531208dd7d468ff3854 commit b2dcb848688e1e8346762531208dd7d468ff3854 Author: Bjoern A. Zeeb AuthorDate: 2023-04-19 21:37:01 +0000 Commit: Bjoern A. Zeeb CommitDate: 2023-04-19 21:49:00 +0000 LinuxKPI: skbuff.h: fix -Warray-bounds warnings Harmonize sk_buff_head and sk_buff further and fix -Warray-bounds warnings reports by gcc. At the same time simplify some code by re-using other functions or factoring some code out. Sponsored by: The FreeBSD Foundation MFC after: 3 days --- sys/compat/linuxkpi/common/include/linux/skbuff.h | 61 +++++++++++++---------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/skbuff.h b/sys/compat/linuxkpi/common/include/linux/skbuff.h index 12a6be42e743..fca161537837 100644 --- a/sys/compat/linuxkpi/common/include/linux/skbuff.h +++ b/sys/compat/linuxkpi/common/include/linux/skbuff.h @@ -89,8 +89,16 @@ enum sk_buff_pkt_type { struct sk_buff_head { /* XXX TODO */ - struct sk_buff *next; - struct sk_buff *prev; + union { + struct { + struct sk_buff *next; + struct sk_buff *prev; + }; + struct sk_buff_head_l { + struct sk_buff *next; + struct sk_buff *prev; + } list; + }; size_t qlen; spinlock_t lock; }; @@ -527,8 +535,8 @@ __skb_insert(struct sk_buff *new, struct sk_buff *prev, struct sk_buff *next, SKB_TRACE_FMT(new, "prev %p next %p q %p", prev, next, q); new->prev = prev; new->next = next; - next->prev = new; - prev->next = new; + ((struct sk_buff_head_l *)next)->prev = new; + ((struct sk_buff_head_l *)prev)->next = new; q->qlen++; } @@ -538,7 +546,7 @@ __skb_queue_after(struct sk_buff_head *q, struct sk_buff *skb, { SKB_TRACE_FMT(q, "skb %p new %p", skb, new); - __skb_insert(new, skb, skb->next, q); + __skb_insert(new, skb, ((struct sk_buff_head_l *)skb)->next, q); } static inline void @@ -551,24 +559,18 @@ __skb_queue_before(struct sk_buff_head *q, struct sk_buff *skb, } static inline void -__skb_queue_tail(struct sk_buff_head *q, struct sk_buff *skb) +__skb_queue_tail(struct sk_buff_head *q, struct sk_buff *new) { - struct sk_buff *s; - SKB_TRACE2(q, skb); - q->qlen++; - s = (struct sk_buff *)q; - s->prev->next = skb; - skb->prev = s->prev; - skb->next = s; - s->prev = skb; + SKB_TRACE2(q, new); + __skb_queue_after(q, (struct sk_buff *)q, new); } static inline void -skb_queue_tail(struct sk_buff_head *q, struct sk_buff *skb) +skb_queue_tail(struct sk_buff_head *q, struct sk_buff *new) { SKB_TRACE2(q, skb); - return (__skb_queue_tail(q, skb)); + return (__skb_queue_tail(q, new)); } static inline struct sk_buff * @@ -817,26 +819,31 @@ skb_mark_not_on_list(struct sk_buff *skb) SKB_TODO(); } +static inline void +___skb_queue_splice_init(const struct sk_buff_head *from, + struct sk_buff *p, struct sk_buff *n) +{ + struct sk_buff *b, *e; + + b = from->next; + e = from->prev; + + b->prev = p; + ((struct sk_buff_head_l *)p)->next = b; + e->next = n; + ((struct sk_buff_head_l *)n)->prev = e; +} + static inline void skb_queue_splice_init(struct sk_buff_head *from, struct sk_buff_head *to) { - struct sk_buff *b, *e, *n; SKB_TRACE2(from, to); if (skb_queue_empty(from)) return; - /* XXX do we need a barrier around this? */ - b = from->next; - e = from->prev; - n = to->next; - - b->prev = (struct sk_buff *)to; - to->next = b; - e->next = n; - n->prev = e; - + ___skb_queue_splice_init(from, (struct sk_buff *)to, to->next); to->qlen += from->qlen; __skb_queue_head_init(from); }