From patchwork Tue Oct 29 13:38:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 3918 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:c09d:b0:5b9:581e:f939 with SMTP id jr29csp265489mab; Tue, 29 Oct 2024 06:55:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUXReLiYbGorOW49KCkLRESv7VmHozmsTHMrPdjrC/2TTJS9XyvSyGxnEisA6lb8FZpsiFMJ6/4Qrk=@openvpn.net X-Google-Smtp-Source: AGHT+IHNrLU2b6XUBwblpns/fq6a1+itGV3IY6u3ASLo4A93gGKUhewshZkiq14bJ1vIqfptVCPB X-Received: by 2002:a05:6602:611b:b0:83b:2c8e:c4 with SMTP id ca18e2360f4ac-83b2c8e0793mr834095839f.9.1730210100739; Tue, 29 Oct 2024 06:55:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730210100; cv=none; d=google.com; s=arc-20240605; b=ODVDCRZ8BKRAvUg8iCqT5nXxjo71U67SeYQ/bVteQcmPDPT9xjIboTK9ZbyKIgUhwJ rNpPwiXCbzlQ7GHOzkuiP8ir75uzs6K4+WLxEbB6eoTrPJbZHabp1yHXgJgOhCy7M4Ii 3/fPomOTAbst9z7JFYYOhwGLSDLZiRL/vMINE1FmFaV+nkOkSNLS0KcfnfDV0W7C0AaD igmxo0J0S7bx06iMW+slhUk/CcR1doKJx20UC5U+N2gl7SJMlFmdcfel9A+BGYW9pmlb Ej6YN2OuTefk1fKW6KUCx34pjfHMjfyLhYh+o560hXchguy7Lg7ntuGOcTUYSRwOU3tC o4NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:content-transfer-encoding:cc:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:message-id:date:to:from:dkim-signature:dkim-signature :dkim-signature; bh=KgoDleag5b2ih3bc5Un+jLKj13yN2G8JsDYR1biHkAk=; fh=10tBNjXj/wkJoIBSfHvI5xr4knRr+m5zCVrzABMRuHI=; b=Pl0LB8l67iu/Vqa9vfJZRjokskTeZKM8Ccn5+0l19lodmz5sHExG+bH3Kcn/TtKoIQ zYJODMkN9DwmePfaKJzBEZdJFVOB0WhugG0NGzeilz4P4xqH0qAjSwABof9U/5rowzJM m3Cc1iwhlVSH9mVnbriAuW/vcbyHWBwFgqLDqMiPQPKyb4+z+fpqo19pt55KkamZcC+C E+RhN4alqyyLfz1JQETqgnxstaRA+DUAqlnTLfT1MoOO59tR9w+dRTH7wnn96mEp0EnT qBBa4bQICDBuP9RV6XFy+uXSgIOnFVA+YbvTnQJcBxxJIKMym2I3ZQHx7IQgDKjSkFUF 3crg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=SA6pTGUK; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="J/DbYPHw"; dkim=neutral (body hash did not verify) header.i=@unstable.cc header.s=20220809-q8oc header.b="iWq1Lt/H"; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id ca18e2360f4ac-83b137de3f5si468672439f.55.2024.10.29.06.55.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Oct 2024 06:55:00 -0700 (PDT) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=SA6pTGUK; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="J/DbYPHw"; dkim=neutral (body hash did not verify) header.i=@unstable.cc header.s=20220809-q8oc header.b="iWq1Lt/H"; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1t5mgM-0002kv-66; Tue, 29 Oct 2024 13:54:50 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1t5mgK-0002kn-SI for openvpn-devel@lists.sourceforge.net; Tue, 29 Oct 2024 13:54:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:Content-Type:MIME-Version :Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=JHcBKsQn6xFodmUeM+8FrmRS3jocRzpU0U+ZckYrr1Y=; b=SA6pTGUKKITVdpY81/64xRC8LB IaQ0X56QJXkWCVfk5vvWyJLQfGxRiFgMI8Q+qH0LoILSUZL8ecG3TSB2POoO3HBObWpXyC9me7pzi +a2U92IinICtaayKYl5/fOxq/RhsQ3EngtJwAnKI1PGuuESgoDCMch/B+b0oGH5iLagM=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date: Subject:Cc:To:From:Sender:Reply-To:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=JHcBKsQn6xFodmUeM+8FrmRS3jocRzpU0U+ZckYrr1Y=; b=J /DbYPHwD2C1vjhQjdoPz3ssTL3s6LoXswhb+tylkd8v+kXfVOaKutfSJ9E6X5/U/S4UHQT9/zjORh +I098MNupYSaIZ/xaeR0nms3gl0hu4L78dwJBV/lx3/69VXor3i5YwqP2hTyclaM6y4pDTEhOc0on 6rbtagLq5c4sAECU=; Received: from wilbur.contactoffice.com ([212.3.242.68]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1t5mgK-0000bg-EX for openvpn-devel@lists.sourceforge.net; Tue, 29 Oct 2024 13:54:49 +0000 Received: from smtpauth2.co-bxl (smtpauth2.co-bxl [10.2.0.24]) by wilbur.contactoffice.com (Postfix) with ESMTP id 78FEB4065; Tue, 29 Oct 2024 14:39:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1730209164; s=20220809-q8oc; d=unstable.cc; i=a@unstable.cc; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=JHcBKsQn6xFodmUeM+8FrmRS3jocRzpU0U+ZckYrr1Y=; b=iWq1Lt/HDTidqXl7lILkheYM8PF4PRlknP62QfujHIqGNWagHRfsb2MvyKlsBT5D 2KQ1fGJJ/nJNlyzTl3WKN1xeZ+nIDENB7ggfCVfZS2ygZO/2rmCM0L4z3cxBJBfAU31 7hHIwHlHahM5hfHOKEuqH6/s+VZkk36x1SWG3rEv+m8drv3ntdZyL/W9dh7IjhK3E2M yJ5ZQl15YesJTdqgCm8sMpBoDojCInZnu23L1bd4TPbzKssgfE5QzTyMx0JY4b0dg9g Zeyr2fvgyDXYlNeQPYM6EHdUWxm1tlgvRHtKnNSksScIuW/3SV4m6iSLAtuHSN4PBsq Dwg7NmotlQ== Received: by smtp.mailfence.com with ESMTPSA ; Tue, 29 Oct 2024 14:39:21 +0100 (CET) From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Tue, 29 Oct 2024 14:38:58 +0100 Message-ID: <20241029133858.22873-1-a@unstable.cc> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-ContactOffice-Account: com:375058688 X-Spam-Score: -0.9 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Antonio Quartulli The NLMSG_TAIL macro never had any reason to exist, because libnl already provides a function doing exactly the same: nlmsg_tail(). Moreover, this macro was found to confuse gcc when compiling with -O3, which would result in subsequent warnings like: Content analysis details: (-0.9 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [212.3.242.68 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-Headers-End: 1t5mgK-0000bg-EX Subject: [Openvpn-devel] [PATCH] sitnl: replace NLMSG_TAIL macro with nlmsg_tail() function X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Antonio Quartulli Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1814256786211274600?= X-GMAIL-MSGID: =?utf-8?q?1814256786211274600?= From: Antonio Quartulli The NLMSG_TAIL macro never had any reason to exist, because libnl already provides a function doing exactly the same: nlmsg_tail(). Moreover, this macro was found to confuse gcc when compiling with -O3, which would result in subsequent warnings like: networking_sitnl.c:143:9: warning: writing 4 bytes into a region of size 0 [-Wstringop-overflow=] 143 | memcpy(RTA_DATA(rta), data, alen); | ^ networking_sitnl.c:101:21: note: at offset [72, 88] into destination object ā€˜nā€™ of size 16 101 | struct nlmsghdr n; | ^ (Above warnings are critical on Fedora 40 as they are turned into errors) Delete the macro, replace it with nlmsg_tail() and get rid of the warnings. Signed-off-by: Antonio Quartulli --- src/openvpn/networking_sitnl.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/openvpn/networking_sitnl.c b/src/openvpn/networking_sitnl.c index f53f5ee9..8eeab72a 100644 --- a/src/openvpn/networking_sitnl.c +++ b/src/openvpn/networking_sitnl.c @@ -40,6 +40,7 @@ #include #include #include +#include #define SNDBUF_SIZE (1024 * 2) #define RCVBUF_SIZE (1024 * 4) @@ -52,19 +53,16 @@ } \ } -#define NLMSG_TAIL(nmsg) \ - ((struct rtattr *)(((uint8_t *)(nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len))) - #define SITNL_NEST(_msg, _max_size, _attr) \ ({ \ - struct rtattr *_nest = NLMSG_TAIL(_msg); \ + struct rtattr *_nest = nlmsg_tail(_msg); \ SITNL_ADDATTR(_msg, _max_size, _attr, NULL, 0); \ _nest; \ }) #define SITNL_NEST_END(_msg, _nest) \ { \ - _nest->rta_len = (void *)NLMSG_TAIL(_msg) - (void *)_nest; \ + _nest->rta_len = (void *)nlmsg_tail(_msg) - (void *)_nest; \ } /** @@ -130,7 +128,7 @@ sitnl_addattr(struct nlmsghdr *n, int maxlen, int type, const void *data, return -EMSGSIZE; } - rta = NLMSG_TAIL(n); + rta = nlmsg_tail(n); rta->rta_type = type; rta->rta_len = len;