From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 2DAC25A027B for ; Fri, 16 Feb 2024 15:17:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708093039; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mO7KT8AXIJY8T+pM98CV20LCTOUFcdfU+Lv2DO74YpM=; b=gkYo+axbkSmTPkkZzPAQKWbFJN3MJZug+388BUzQyBSG/+mecmt8ZhCD652PvhOuOkwCf9 AkATJ00sDQvDqKW0e/nmgcJG97vja/Z/+KXpCNrenrXiz4gdcJX0VDxcIcj4clKkHtmJIi y1WmLxS2egE8WTaVx18z7McY4kp76xY= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-550-YF3bg9oXPASLzGOxpRRKuA-1; Fri, 16 Feb 2024 09:17:17 -0500 X-MC-Unique: YF3bg9oXPASLzGOxpRRKuA-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-680b7da38bcso11779396d6.3 for ; Fri, 16 Feb 2024 06:17:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708093037; x=1708697837; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mO7KT8AXIJY8T+pM98CV20LCTOUFcdfU+Lv2DO74YpM=; b=gu+WsjMNYaV9hJxuj6iXBSEK1t6H3bpee2THGb0L65AREbQx3A2e5KXprcRJrsDeSQ Bv9wQdwI5ZU2PNtspxVAU8cqnudSx4yo0wSO2yDzUz5WgUH6xYWzmsCf8HxlvE0PZ2bR vovBbQgQdp1GW1XFcwxjnBj+yCkEbm5KwT/EdYRCLdwkIH9RHiiYGn2lSj5aj3GKftCs 0Tu101qpG7ggyBtRjkEo54Ist2szkWLU1IFcoEd+eCt/sz2NzM6RqgZQlHNs1KCTZUmK xn+RGJ74wVU7nNKaypcIerKSYMP1j9kB5gB4QDW4cAIqBFF2UiVbcfnkMxRBZAEu399u ybdg== X-Gm-Message-State: AOJu0YwBPWcdMQ0JXH0ScgjCcWgwPk7rT0ToxdkIM7gseVR4j4/mKsZm PLESqV3pQ4HV0ANBoRBgiuVVROUB7CGuPv5VpuvcPT5pmVItISlvh7L1dK85xuNj+7nQEBZe931 YKsBBE09tNeTORunL8OgQ1xCVFyRvhp8DxuwqrYnH2230+zeXKg== X-Received: by 2002:a0c:cc14:0:b0:68c:e81a:6618 with SMTP id r20-20020a0ccc14000000b0068ce81a6618mr4660555qvk.10.1708093037359; Fri, 16 Feb 2024 06:17:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IH6asQe5DSUwrtaLEEwqZ8Mn7/GaB8aZEC3rFPi7NW6LBydKHkQbY8w4CoJaZ7vUeQ7r/Peew== X-Received: by 2002:a0c:cc14:0:b0:68c:e81a:6618 with SMTP id r20-20020a0ccc14000000b0068ce81a6618mr4660489qvk.10.1708093035885; Fri, 16 Feb 2024 06:17:15 -0800 (PST) Received: from [192.168.100.30] ([82.142.8.70]) by smtp.gmail.com with ESMTPSA id ok25-20020a0562143c9900b0068f3291f860sm614004qvb.95.2024.02.16.06.17.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 16 Feb 2024 06:17:15 -0800 (PST) Message-ID: <53d4a403-0d3f-4aa0-b980-27c2026a468b@redhat.com> Date: Fri, 16 Feb 2024 15:17:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 6/8] checksum: use csum_ip4_header() in udp.c and tcp.c To: Stefano Brivio References: <20240214085628.210783-1-lvivier@redhat.com> <20240214085628.210783-7-lvivier@redhat.com> <20240216100805.040826b3@elisabeth> From: Laurent Vivier In-Reply-To: <20240216100805.040826b3@elisabeth> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: Q7LW5GWEPHQHXW34JMZG4M5KWM54TUIG X-Message-ID-Hash: Q7LW5GWEPHQHXW34JMZG4M5KWM54TUIG X-MailFrom: lvivier@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On 2/16/24 10:08, Stefano Brivio wrote: > On Wed, 14 Feb 2024 09:56:26 +0100 > Laurent Vivier wrote: > >> ... >> /** >> * udp_update_l2_buf() - Update L2 buffers with Ethernet and IPv4 addresses >> * @eth_d: Ethernet destination address, NULL if unchanged >> @@ -579,6 +562,9 @@ static void udp_splice_sendfrom(const struct ctx *c, unsigned start, unsigned n, >> * >> * Return: size of tap frame with headers >> */ >> +#pragma GCC diagnostic push >> +/* ignore unaligned pointer value warning for &b->iph */ >> +#pragma GCC diagnostic ignored "-Waddress-of-packed-member" >> static size_t udp_update_hdr4(const struct ctx *c, int n, in_port_t dstport, >> const struct timespec *now) >> { >> @@ -614,13 +600,14 @@ static size_t udp_update_hdr4(const struct ctx *c, int n, in_port_t dstport, >> b->iph.saddr = b->s_in.sin_addr.s_addr; >> } >> >> - udp_update_check4(b); >> + b->iph.check = csum_ip4_header(&b->iph); > Similar comment as I had on v1: I don't think this is safe. > > If &b->iph is, say, 0x2000, it's all fine: when csum_ip4_header() needs > to access, say, ip4h->tot_len, it will dereference 0x2000 and look at > 16 bits, 2 bytes into it. > > If &b->iph is 0x2001, though, csum_ip4_header() will dereference 0x2001 > and, on some architectures, boom. I don't understand how &b->iph cannot be aligned as b should be aligned and b is defined using udp4_l2_buf_t structure with _attribute__ ((packed, aligned(__alignof__(unsigned int)))). Thanks, Laurent