From nobody Fri Jan 13 10:19:33 2023 X-Original-To: dev-commits-src-main@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 4Ntcps2bTYz2p34X; Fri, 13 Jan 2023 10:19:33 +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 4Ntcps1rSzz3l5V; Fri, 13 Jan 2023 10:19:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673605173; 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=Nshpi43nf+rsMNeIFetV7ZOhem18GzXxFjNrY2+kb7w=; b=sKv2WgekEwR7rHwfUcBzsXVlcuUgtqosa/RxThFAam9nU4eNkoZToTTVesfe9ekzcpslDH m6Rg7wjkfAoHTSwJV3fAqayYrQis+l8mlr9ghX62fIjcwtDvqX5p6pJm0U5vYRn76EeAkg PIQRo+e5BKsh3IpEVYzlH7LAiiaceZOf9LeNdF9jpR8znnq0MHw9LbQqsgX2NtJEI+epx5 AfT9iJxml4S/92Qfvul27MHGOHOkbVnoO7maOQ6PI4A9ELZZWfvsTQRrpwVzBupqHk8SE1 EerYTRyC8OtFcQrDbVBZtqiuH21EPpn9qNajftjh6spMP//n2gwl+gsTxZBsaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673605173; 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=Nshpi43nf+rsMNeIFetV7ZOhem18GzXxFjNrY2+kb7w=; b=oegZJ8YQSy6ZZf1m8qjlHzDJqQnXt9Fen5r/XI3PXijsycHTcM1v4qUnjIRnPkUmlLX3IE Sd/DhtIXn5aDMkQnlJJicF8z9Ix2lXIrjmyj01xZBRItzBYOwM7Ffj0pgxJfSIlcxoeJPq 15b2kYrJQ5xp3k02FFydlE/17d5TYb4Y/JB2ESwnN7ugTX+3uGtA4dSDu8mnCAt7WRE88y sZCC8aQ8IIsDSqaGD0fo1sOwUljYjkPKjOYKtdU75OGx3c6IitzNjWw7f0c/gjci3eYZzC SDOko49TvkaBTyeMBrv7BdHrFtxEv0U7eNDEXpY61qpOueyxFv8Nico6Mj6mFw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673605173; a=rsa-sha256; cv=none; b=gqH/XiHN3SG2ZTI6ei1QlFxRgW2EeSjPXHtq1z+EIiNjDCkvCrQtWtbQTndjPfJKZ25L6j c3s+vzpJD6hkZxawQnH0dNeIEI+rX8Q30O5CoUomrWIkkBdAEjVWSK57NCV6m/GI2wcaZE M9wK18cXhOKaQ9ZKnP7pXTdfnI57pUxcllaFJQrDfzyih0LXUBPhoeUWh1M3eF2RnCHYsv HJY8SRymS4mOWICRL+qCxpDGM5mmhcI+DRaiqm0L34dKlPT0BK5nElTNby7ZxLSlOct74D HCrmi2k7EjLn50bsjq2iQo7E5ZvzZA3Tioxs37eZJwjLeot88pr9h6vnqJHe5Q== 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 4Ntcps0rTKz13mN; Fri, 13 Jan 2023 10:19:33 +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 30DAJXrN081969; Fri, 13 Jan 2023 10:19:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30DAJXWf081968; Fri, 13 Jan 2023 10:19:33 GMT (envelope-from git) Date: Fri, 13 Jan 2023 10:19:33 GMT Message-Id: <202301131019.30DAJXWf081968@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: e0d8add4af0b - main - tcp_lro: Fix for undefined behaviour. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e0d8add4af0be1d37ede9a16f46424dc08f0d95e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=e0d8add4af0be1d37ede9a16f46424dc08f0d95e commit e0d8add4af0be1d37ede9a16f46424dc08f0d95e Author: Hans Petter Selasky AuthorDate: 2022-11-28 22:56:16 +0000 Commit: Hans Petter Selasky CommitDate: 2023-01-13 10:18:19 +0000 tcp_lro: Fix for undefined behaviour. Make sure the size of the raw[] array in the lro_address union is correctly set at compile time, so that static code analysis tools do not report undefined behaviour. MFC after: 1 week Sponsored by: NVIDIA Networking --- sys/netinet/tcp_lro.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sys/netinet/tcp_lro.h b/sys/netinet/tcp_lro.h index 427657df47e7..e01e451c1e77 100644 --- a/sys/netinet/tcp_lro.h +++ b/sys/netinet/tcp_lro.h @@ -34,6 +34,8 @@ #define _TCP_LRO_H_ #include +#include + #include #ifndef TCP_LRO_ENTRIES @@ -65,8 +67,12 @@ struct inpcb; +/* Precompute the LRO_RAW_ADDRESS_MAX value: */ +#define LRO_RAW_ADDRESS_MAX \ + howmany(12 + 2 * sizeof(struct in6_addr), sizeof(u_long)) + union lro_address { - u_long raw[1]; + u_long raw[LRO_RAW_ADDRESS_MAX]; struct { uint8_t lro_type; /* internal */ #define LRO_TYPE_NONE 0 @@ -89,10 +95,10 @@ union lro_address { struct in6_addr v6; } d_addr; /* destination IPv4/IPv6 address */ }; -} __aligned(sizeof(u_long)); +}; -#define LRO_RAW_ADDRESS_MAX \ - (sizeof(union lro_address) / sizeof(u_long)) +_Static_assert(sizeof(union lro_address) == sizeof(u_long) * LRO_RAW_ADDRESS_MAX, + "The raw field in the lro_address union does not cover the whole structure."); /* Optimize address comparison by comparing one unsigned long at a time: */