From nobody Mon Feb 9 15:32:36 2026 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB5391FA262 for ; Wed, 8 Jan 2025 11:41:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736336476; cv=none; b=OMhij4lMsuSTMXyIug56fCOSdMllmVPD54YqEtVtVEJpN7rJ7a81HT8wHeGT/6UUfFC2dGosdbvndafZRTE7ozjCCF19iUyYVJUUW3foaWiwDlSMvKQ9dHt7ggSY6zAbqCS/9EaQZODYzcutyaKALNfXeTn9CWEfdt6UgLFymL4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736336476; c=relaxed/simple; bh=3se5b6ZtcapIk1Hj4cssqIsg8szJXXkbOptd2HkOcvc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=O8BJkJF8/fswoOxHrIe6s/I0GhwGdFstNmRPyGLHcgXwBigUlPaN3IZck6zyjb1vqBD0mi/cCtFuDpVNyMIitanPcLqDpCJoOFtkp1U/uQkSB/CAzCCCIlI2Td2RZ9lC/NGFf17NR+hophzxoOQut+9vb+euBuvhFAsdDGvbdv0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com; spf=pass smtp.mailfrom=daynix.com; dkim=pass (2048-bit key) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.b=zM1czloq; arc=none smtp.client-ip=209.85.216.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=daynix.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.b="zM1czloq" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-2ee51f8c47dso19371244a91.1 for ; Wed, 08 Jan 2025 03:41:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1736336474; x=1736941274; darn=vger.kernel.org; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=O/vBDwZ1bg1e1swp4oqyRL1d2OsnyaZOIbrFToORcQk=; b=zM1czloqv0UV/90fK2rdkrxN+ZY60mhHl/ZYSJ9rHeQiW4eyOpA1E+thUrTj6zioWc s598jUHvTxuWkXw6pmtfxEF2bE2fSIiHEEzYPEJt9bN48jNUidJ1avW81VhCOkJOfFwg UvVgmYc02uOgVB4VrXfldtlls2Q/S5vl7/wA8+LPHyV6PlKe5W9cXjG+AZ33K5DX8vEe Ljw/up4z1U73PQTs6zLkxaGZg1BcE/DgXhBElV7rs6HAIOvNn3nfKn20B7AngL/ceUX1 3FMADKRwpaf7hw4/4D4rb4UlFQNF7RnJlzRrfIWbGf25ji7LoXxAfAaMYPK3Y9eolHPX p/OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736336474; x=1736941274; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=O/vBDwZ1bg1e1swp4oqyRL1d2OsnyaZOIbrFToORcQk=; b=m4j4yXRcz+QSoEX6G+YztCE0KWXMp5V1NxuYmYiMF84IduaANyAyUaCpfuv1XVHjLk O2AyeH1F4JRjFfm/J4+3FPpA1QhPfFa1AdGSi9V2lAQ8OnPEMlp6m4rJhqOqP6CMT6tS 1n8H/3FmlbWH0LLiZ1C7ylzb8B//zUWz2YeMbyLddw1oj4NCYVVeiXgQSXpj55a+pt9A vtOCiU6Ng1E061i/ckesKmlGbeOJA3KefeN7smps//3xVxw5n0L9kmj1TGJayo7O/JDL U9qaST8qPeBVuyCsv6+jWCfCO/YotJofHNdw/4qaAkOg/zxiyJ2kGyo+tMTP/by+ea/R DcFQ== X-Forwarded-Encrypted: i=1; AJvYcCWAZVW3WBhhAOcB0zGttWt/7hqRm+ff3rl9STEfTapXqxmQETvKz4C2z0QdjLjkDYPXcj1fsUeNQMAzK/E=@vger.kernel.org X-Gm-Message-State: AOJu0YxLHGimTU/0pp4GWD5K5Caqg1vJ8Qmn1SVj9xVQjXO3BMAzGujI sfNybRd9mhLwhKzBlBlOFulLzavfvYYCtvubJI8+DxDthH52teJ3tA1895hWBwg= X-Gm-Gg: ASbGnctRjBQvWNBX72Ev56WqKhf3M77heQHEkPni6/sOMc5oXHcaaFWlWYfsSzveI/T /SMyI9D6EdEj4hfsJwMSxHPPfqDYDCbIcTeQjDLNWOoVU+tFIUVpk/SLTgGlja04BmJZoH3rb03 UUuoKLxJTg+B3E2FvNPmv0Gl+q3Vf+lUidM/4fmBN4kg0hIeaFOjb9h0yqqW71bkrqsU2uY1qVT cn8h2qWA6vfqkTal0ywb4fu6h3RUYVir2WyEECnH0e/nn+QC2cp/MZCtLM= X-Google-Smtp-Source: AGHT+IEF8qMJ7NIeisRWLUDr1vgbLpWM1JpUxFEsueCBmq3r2f5ah2dV4+8clMjFEVU+QatbWr90SA== X-Received: by 2002:a17:90b:5484:b0:2ee:b8ac:73b4 with SMTP id 98e67ed59e1d1-2f548f4265emr3092055a91.36.1736336474242; Wed, 08 Jan 2025 03:41:14 -0800 (PST) Received: from localhost ([157.82.203.37]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2f54a36a5adsm1383037a91.49.2025.01.08.03.41.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Jan 2025 03:41:13 -0800 (PST) From: Akihiko Odaki Date: Wed, 08 Jan 2025 20:40:12 +0900 Subject: [PATCH 2/3] tun: Pad virtio header with zero Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250108-tun-v1-2-67d784b34374@daynix.com> References: <20250108-tun-v1-0-67d784b34374@daynix.com> In-Reply-To: <20250108-tun-v1-0-67d784b34374@daynix.com> To: Jonathan Corbet , Willem de Bruijn , Jason Wang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Michael S. Tsirkin" , Xuan Zhuo , Shuah Khan , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-kselftest@vger.kernel.org, Yuri Benditovich , Andrew Melnychenko , Stephen Hemminger , gur.stavi@huawei.com, devel@daynix.com, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 tun used to simply advance iov_iter when it needs to pad virtio header, which leaves the garbage in the buffer as is. This is especially problematic when tun starts to allow enabling the hash reporting feature; even if the feature is enabled, the packet may lack a hash value and may contain a hole in the virtio header because the packet arrived before the feature gets enabled or does not contain the header fields to be hashed. If the hole is not filled with zero, it is impossible to tell if the packet lacks a hash value. In theory, a user of tun can fill the buffer with zero before calling read() to avoid such a problem, but leaving the garbage in the buffer is awkward anyway so fill the buffer in tun. Signed-off-by: Akihiko Odaki --- drivers/net/tun_vnet.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/tun_vnet.c b/drivers/net/tun_vnet.c index fe842df9e9ef..ffb2186facd3 100644 --- a/drivers/net/tun_vnet.c +++ b/drivers/net/tun_vnet.c @@ -138,7 +138,8 @@ int tun_vnet_hdr_put(int sz, struct iov_iter *iter, if (copy_to_iter(hdr, sizeof(*hdr), iter) !=3D sizeof(*hdr)) return -EFAULT; =20 - iov_iter_advance(iter, sz - sizeof(*hdr)); + if (iov_iter_zero(sz - sizeof(*hdr), iter) !=3D sz - sizeof(*hdr)) + return -EFAULT; =20 return 0; } --=20 2.47.1