From nobody Mon Jun 26 12:08:32 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 4QqRSw3QPwz4k6SC; Mon, 26 Jun 2023 12:08:32 +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 4QqRSw1qsRz3hmt; Mon, 26 Jun 2023 12:08:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687781312; 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=pQmyMuJaJ4Qf6S/qgz4pYPyq7UoX+rP+4oauLPmoQ0c=; b=SU6n+/W72vC1DNng9npHIwPEojKM31hU0gb2QpTgHiQkNdL9Px0mIm+xIBNsHHnx1DNl+U IOmtyR/zg3EquvLn/YUEzukjxAOY6ok0zpD8WYn53VWLODrnbKNQWCewZpXt/dOY1Clnfi NtN5cUQQTN+owM1awhH9MCY3TFY4AZccCgMj58/U+e6DJxrt021wX8K6jUq5RE0TDysdwX DuvTHBujNQs6lY/Mf62dMYoTKJFTDkCoDQ9hYCLxrIHF3imI1xte/joKfhADjCG0QJuNsX qA8tbx/Z7kCkFoF6MrkQif8CRrh2emI5TP3kNQKvBWDgmMc4lYdk3zeNSUydOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687781312; 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=pQmyMuJaJ4Qf6S/qgz4pYPyq7UoX+rP+4oauLPmoQ0c=; b=qnglbvX84FvOj+9VJPylslAVe57zNETG5BvwILT1km4uuIMj9JdJAnczhkTZN4uVrK5K0C yME+SOhqZ64Df34+Yg0fgD6T/YIA2R41gk5dAFepaFT/klJMTR8y9jakqL3jpAhETjQ9ke 1qS3ajK7vY3Urd9hJ3/1SOfm604FpDCfRFDCyJW2DsrFR7oW3AevuOeG6zlcRkBcyDmqjw a96a6jtKDr4QS/O1X75KoMsgfTbycr+3PXpnvc1tT48147liEznb6mXi9uXJW3tuiMpi8m I2e2tPHS/T4PABxuuHq93hDKwdiB711iLJGKElsN7iddcmEa4io3cpLmL776/g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1687781312; a=rsa-sha256; cv=none; b=OLUtbls1uGjl/rtsaciUhdXIxx3ouyadmiSWOblE2eWvwJRkxPjfhA6IWf23uDT9dSVMSA pBO/I/I3AUkC6SUL4lzE3LUDHbJ6fPW/eMS0QpIgo1ISQVSWill5kybpm/JfnG6wnm9oHC jflZo9wtzElcSWhF6oekKfwWKyp/+TAI3KjWrqhUkMP0fRehWisZmBXZWYeuXO5hj6ai7m HynbHpMqNLNjU2xQU4NNpl56Qp0jMBO6wj+PUbnBbBG28fofI+HkKHkp/+y2SVKMqo8LkP buylGG3MlAwhxh4cua9Dai5M0D2XJUG/FefHtDh/bvsReLmSps3WrqhrfIrQkQ== 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 4QqRSw0xbjz17dY; Mon, 26 Jun 2023 12:08:32 +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 35QC8Wij083000; Mon, 26 Jun 2023 12:08:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35QC8WrL082999; Mon, 26 Jun 2023 12:08:32 GMT (envelope-from git) Date: Mon, 26 Jun 2023 12:08:32 GMT Message-Id: <202306261208.35QC8WrL082999@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: de40bc6f3d6b - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: de40bc6f3d6bf8ab1a4b546630cc847a3b8c5113 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=de40bc6f3d6bf8ab1a4b546630cc847a3b8c5113 commit de40bc6f3d6bf8ab1a4b546630cc847a3b8c5113 Author: Bjoern A. Zeeb AuthorDate: 2023-04-19 21:37:01 +0000 Commit: Bjoern A. Zeeb CommitDate: 2023-06-26 09:09:49 +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 (cherry picked from commit b2dcb848688e1e8346762531208dd7d468ff3854) --- 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); }