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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77DD129E11A for ; Tue, 13 Jan 2026 14:30:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768314609; cv=none; b=WdpvygbnbmMnXSb0NsZoYMTPgXuFjIQhclrDJlHZOOhsfNOXBGgwf0JIA8pYTPUfvzqFICy2NbcKjJdbdRA+EmkHL0C9cHuFzXs9EKmu09ypIxE1IA+oAjg64kIuY/bW9RR9aczJOuHsMD5/PVBgFUb4vrdKauAsuurQ8tYbdd8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768314609; c=relaxed/simple; bh=lHu6MXmC881GNys4A4x9dwsGJnuct71yJhITMvkSNBg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=m1NVNVU8wKfZtZcdD/pBuOHegAq5lEl6j9hvMKZ+LWZdCGSRMQczAPdChzfJVIkUf4xy8ME1jkX5/fL9ARnhB6ruLRVfdjIsMCHu5mXWMe9QlZ7hzbYaKV3ohZycFeOPm8cFTXinZe+9RwdtgXYG5/W30G1z95uUpw6I7+kK1EI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=bromVzgr; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=AkGAVH8A; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bromVzgr"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="AkGAVH8A" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768314606; 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=BsGMLadexo/nCzuVTGjgLCJkB33PukmvAkeDyomNP3Y=; b=bromVzgrBJurf6ULQmtIlScUDtIY1Pv68F1sIuDGnLPmYnT03ugRa/YEMygbX2a4kBcz5Y ONP5Slyy9UA7q/eG4Z3wkwHx0RLhCVUObbG9SqPH+ePueEzQ9Z2a4S5RBpvOqj92ixY0ym wnvOqd4az+yHrISLx36hc571cDtcXzQ= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-650-6booQ7lJMYG9zhKzCwj6gQ-1; Tue, 13 Jan 2026 09:30:04 -0500 X-MC-Unique: 6booQ7lJMYG9zhKzCwj6gQ-1 X-Mimecast-MFC-AGG-ID: 6booQ7lJMYG9zhKzCwj6gQ_1768314603 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-430ffa9fccaso6218454f8f.1 for ; Tue, 13 Jan 2026 06:30:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1768314603; x=1768919403; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=BsGMLadexo/nCzuVTGjgLCJkB33PukmvAkeDyomNP3Y=; b=AkGAVH8AAq7YbxYn2HohM+WvuYm26hHNeYCJ9GMukCkw3vgLzKZzWtgDZj1sYqEz5G GQRnn9dT2I2UD37mPsM10Jl5VaRIRAKaj0gfl00kov7vXBEC2/nPa7k8VmMW6GApgJjX momVrU+4Edk+Fg4PpowsqTdf9LzaDhb002ZlK/rPlaCF13SFddR8OZD1LEU2gy7Mj/su yUUW7QeIPaHdU/cyObfavcHW3UnF8joQLmjpPu292FiA+iSBUGnJVCn4nnXIb9rh6ZzL uIKbsYgYNnaESReoejdSLhkcrtLCGPSrG7xzd759PRs1IdAYuHH5M8i0f0wkk2wfGf7b +XSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768314603; x=1768919403; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BsGMLadexo/nCzuVTGjgLCJkB33PukmvAkeDyomNP3Y=; b=hUMa419hjY+ebEHCJqWJyLRVYwpfNbYz24ce/wFN+nK/z+aZJikCtpBEHQ5EoNemmH 2OX8kcRQtiUFtw9rhjiO8mlwnrupoQR+c96LkRVbdld6q2eFW6fPIsWEuAzaH78UCQzF OSK+qrtDIfbDCp9PknMie9uiQicTEMvaKAS7Eje6buncgimQfoEqMcPVi8/SsrZWmWEK vbbUvFuxRMXEA0QSqpePjYPG+5WANkVBt9409tmny4m/KC8HmeESXUlSbBzUt+WO7sUx CwKu67u8TWbjQgHEYubGMrbNOWL/S6hB6BoT2sQ4Q0qp9QOW61JXzZqWtHnVQhgzfgjq JVfg== X-Forwarded-Encrypted: i=1; AJvYcCXP8ZJy0NAJZMgT4JQVQcr6l8ghGirs0k4FRjVLeFc6ZpEiLnVVrHIhxeAotVvOOURtgpcM1ZhJ9KMIHVo=@vger.kernel.org X-Gm-Message-State: AOJu0YwiSPUR7iOle7rb+Ku0c8lTmqcxV5vVx/t+s+Tvz8c+/FcTuKiR V3bOcfwwBuNPhVRCVI8R2uPIMSPOcgGGoDTAvlEkKuIBBwB09C+BckgUQJnlqqfOb1eJ3HVkL2c wBU8kOz0yYeqYy63Bgxl0D3IB4q7cxxlcyRYOXHG/AGfFpcTzVUyxiyF/IgcKOB0Wog== X-Gm-Gg: AY/fxX5etVVHsflR487B8zd17GMo/fWAfUdKfleQVgShthAB24aSg88zy5Id88jncdR InCj5/mwgQrNOKlcDY2tYq/BRVUdwlx+3jmexXfm9dZTnFOTmuTqAcuuBFZc4Ov5x4d4RFJU4Yd oDUuXIFWDSLP00s6po8nUnHAIEr+6lossOLEtC3M4M3UbLgj2hr7PFjhD7dTfBElEgrrwxWzSDk vjnaLFtfRvQvK8lW3aKhyipXsCAeSHWgSX2jmpYMh+4T/S4dEYY15pTxSOp5mOHUbrCViFL+YTN GB7nYkqLdD2PfrJCbVdG0WcNGp4Fhgs4LvZo8TG02m+pOtSH2ScFCRLi6hfpxS6uUe4mU8J4+Ip Gmb7KhFGetcwW X-Received: by 2002:a05:6000:2411:b0:431:c2:c632 with SMTP id ffacd0b85a97d-432c38d22f0mr26992655f8f.57.1768314603284; Tue, 13 Jan 2026 06:30:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IH/QAVAjAHGrbVqsroQVjucumpuberxPHjIK5D6+36lcnv98Jxe8Pu+ntURZqANmPNOZ6UFhw== X-Received: by 2002:a05:6000:2411:b0:431:c2:c632 with SMTP id ffacd0b85a97d-432c38d22f0mr26992605f8f.57.1768314602838; Tue, 13 Jan 2026 06:30:02 -0800 (PST) Received: from [192.168.88.32] ([212.105.155.93]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-432bd5df9afsm47097191f8f.24.2026.01.13.06.30.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Jan 2026 06:30:02 -0800 (PST) Message-ID: Date: Tue, 13 Jan 2026 15:30:00 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2][next] virtio_net: Fix misalignment bug in struct virtnet_info To: "Gustavo A. R. Silva" , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?Q?Eugenio_P=C3=A9rez?= , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Akihiko Odaki , Simon Horman Cc: netdev@vger.kernel.org, virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Kees Cook References: Content-Language: en-US From: Paolo Abeni In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 1/10/26 9:07 AM, Gustavo A. R. Silva wrote: > Use the new TRAILING_OVERLAP() helper to fix a misalignment bug > along with the following warning: > > drivers/net/virtio_net.c:429:46: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] > > This helper creates a union between a flexible-array member (FAM) > and a set of members that would otherwise follow it (in this case > `u8 rss_hash_key_data[VIRTIO_NET_RSS_MAX_KEY_SIZE];`). This > overlays the trailing members (rss_hash_key_data) onto the FAM > (hash_key_data) while keeping the FAM and the start of MEMBERS aligned. > The static_assert() ensures this alignment remains. > > Notice that due to tail padding in flexible `struct > virtio_net_rss_config_trailer`, `rss_trailer.hash_key_data` > (at offset 83 in struct virtnet_info) and `rss_hash_key_data` (at > offset 84 in struct virtnet_info) are misaligned by one byte. See > below: > > struct virtio_net_rss_config_trailer { > __le16 max_tx_vq; /* 0 2 */ > __u8 hash_key_length; /* 2 1 */ > __u8 hash_key_data[]; /* 3 0 */ > > /* size: 4, cachelines: 1, members: 3 */ > /* padding: 1 */ > /* last cacheline: 4 bytes */ > }; > > struct virtnet_info { > ... > struct virtio_net_rss_config_trailer rss_trailer; /* 80 4 */ > > /* XXX last struct has 1 byte of padding */ > > u8 rss_hash_key_data[40]; /* 84 40 */ > ... > /* size: 832, cachelines: 13, members: 48 */ > /* sum members: 801, holes: 8, sum holes: 31 */ > /* paddings: 2, sum paddings: 5 */ > }; > > After changes, those members are correctly aligned at offset 795: > > struct virtnet_info { > ... > union { > struct virtio_net_rss_config_trailer rss_trailer; /* 792 4 */ > struct { > unsigned char __offset_to_hash_key_data[3]; /* 792 3 */ > u8 rss_hash_key_data[40]; /* 795 40 */ > }; /* 792 43 */ > }; /* 792 44 */ > ... > /* size: 840, cachelines: 14, members: 47 */ > /* sum members: 801, holes: 8, sum holes: 35 */ > /* padding: 4 */ > /* paddings: 1, sum paddings: 4 */ > /* last cacheline: 8 bytes */ > }; > > As a result, the RSS key passed to the device is shifted by 1 > byte: the last byte is cut off, and instead a (possibly > uninitialized) byte is added at the beginning. > > As a last note `struct virtio_net_rss_config_hdr *rss_hdr;` is also > moved to the end, since it seems those three members should stick > around together. :) > > Cc: stable@vger.kernel.org > Fixes: ed3100e90d0d ("virtio_net: Use new RSS config structs") > Signed-off-by: Gustavo A. R. Silva > --- > Changes in v2: > - Update subject and changelog text (include feedback from Simon and > Michael --thanks folks) > - Add Fixes tag and CC -stable. @Michael, @Jason: This is still apparently targeting 'net-next', but I think it should land in the 'net' tree, right? /P