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.129.124]) by passt.top (Postfix) with ESMTP id 6A15B5A0280 for ; Fri, 16 Feb 2024 19:05:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708106745; 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=YTEsESnzo5wGebJd1/ElZerJUh3FJjnfyxMksRDPFjE=; b=bP5nR4owlGcgeGuqfysNGpB7Qg+RnUWz0IbI03yj86WfaFU00BWgd+uUfkzMiAj4tN+lxf eK2W7C3Y2trCVNRROgh1s17Gh2mhELVhZM1Cw5ksaMYWibmIBmWDw8XibVxrVGKWVzybmA fyTsiHtPYxbFozg9FAwpbc50sqiDz9s= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-75-eHhC-cU1N0ikOyRtHxiXDQ-1; Fri, 16 Feb 2024 13:05:42 -0500 X-MC-Unique: eHhC-cU1N0ikOyRtHxiXDQ-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-787303d8df9so110309485a.0 for ; Fri, 16 Feb 2024 10:05:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708106742; x=1708711542; 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=YTEsESnzo5wGebJd1/ElZerJUh3FJjnfyxMksRDPFjE=; b=DGxCFy8S/A/AThlId1V9CGSb+RgFMSgMweHXNPrkzyhpiovithZh/Tj5nXodheFxha 6u7LHMsGUGcEx1uDmIRJTb9drwul9xTttKEbSyMYCCy6LYf1aNIJO9ufYWn/R3vZOq2f 45R0diJFjN26AZ3qZsRpE1eM1NFKjCZKo7rgGfABjWVpsyzSaa3o13hom/ZY0uw4+gyI ls4yYCtvIi7g7c3wNjbRgy74+FT8fzYVhhF43kTbX8Umyg0C6/vuvoHxJ7dMoewbB4tt 9Lz2/uH3fWocGXXxDzrNOjIWB+yUGBrclZaWp3ZdealX00lzJ7yuA+ox8Sh2mZjmbhsf DCSw== X-Gm-Message-State: AOJu0YyOxuxeqrmgaLEKgnr1h8umFaOYQqXpbbqfKzUMXQ0VUdamAFKn LkDDehN4bPD6fgPBordn29gsCkU80ajFm7Gwm0EiCo0EI0tCqmKqmUZbhkaj/pMT2C4P6mqqygV 8KGVFh3ilD8MDrZz6IkKLRmCMDQJ7Dmymk10LhgSwlzZc1R46Bw== X-Received: by 2002:a05:620a:2195:b0:787:20c9:54ef with SMTP id g21-20020a05620a219500b0078720c954efmr6166288qka.68.1708106742213; Fri, 16 Feb 2024 10:05:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IG6fmdo8cDRI6FkZq+EmxDzGl0hJHNq+A0RL+wOp+EjWLrueNaaPDF3MxgX3nOg+kecX1o8/w== X-Received: by 2002:a05:620a:2195:b0:787:20c9:54ef with SMTP id g21-20020a05620a219500b0078720c954efmr6166269qka.68.1708106741908; Fri, 16 Feb 2024 10:05:41 -0800 (PST) Received: from [192.168.100.30] ([82.142.8.70]) by smtp.gmail.com with ESMTPSA id u3-20020ae9c003000000b007873306737fsm165490qkk.87.2024.02.16.10.05.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 16 Feb 2024 10:05:41 -0800 (PST) Message-ID: <7a9915cf-f004-453a-b328-80d086c14a80@redhat.com> Date: Fri, 16 Feb 2024 19:05:39 +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> <53d4a403-0d3f-4aa0-b980-27c2026a468b@redhat.com> <20240216155400.1d26ae17@elisabeth> From: Laurent Vivier In-Reply-To: <20240216155400.1d26ae17@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: KDYGTSBBMBICZMTODPUZAH55JP6EB7WQ X-Message-ID-Hash: KDYGTSBBMBICZMTODPUZAH55JP6EB7WQ 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 15:54, Stefano Brivio wrote: > On Fri, 16 Feb 2024 15:17:13 +0100 > Laurent Vivier wrote: > >> 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)))). > That's because of the size of struct tap_hdr (18 bytes). On, at least, > x86_64, armhf, and i686: > > $ pahole passt > > [...] > > struct udp4_l2_buf_t { > struct sockaddr_in s_in; /* 0 16 */ > struct tap_hdr taph; /* 16 18 */ > struct iphdr iph; /* 34 20 */ > > [...] > > ...we could align the start of 'taph' by adding 2 bytes of padding before > it, note that the size of struct sockaddr_in doesn't depend on the > architecture. But then you can't dereference 'taph', which is probably > even worse. > So I think in the worst case iph is aligned on 2. Do you know which architectures don't support this alignment? Do you know if we will support this architecture? I think I will send the v3 of my series without fixing that because I don't have enough time this week. I will address the problem later. Thanks, Laurent