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]) (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 1B10538E8CC for ; Thu, 11 Jun 2026 09:10:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781169041; cv=none; b=LY1hehwhY48ROz8GVdeVY6Pft6YFydLIy7tURKCoO998YDo9BmYJypMGJxCtzZyDaYHGPOwh23EdSMZBzUvqyD6VziPa7iapLkge5ZP0iMjs+KPI3x1Jh5INB1u2NnixINT+SVMA7h2zQsTpurgQHkl71M62+bhyHvDhhQ1sWbs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781169041; c=relaxed/simple; bh=ngimsOS9hzgh2ezE0TEY4e5wFmKWHB3Fv7cSOMsZbsw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qSDZ9r+KqdAbKmDk4a/GtQS86R7wtgdm2QjegNFTCCOhAdAj84IjNXK8gz7X1k/Q0tsYavhO/Dss/Wk4iGrGZZ5muZcMDdsSFyGQ317f7oKQjSsclZyW0WMnp7/cdekmaBqsWuvvJEtrXsdp++yLIiuNYjKi3tDTymsm7O+pHKg= 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=b0VLzkWY; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=b2NAjCs+; arc=none smtp.client-ip=170.10.129.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="b0VLzkWY"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="b2NAjCs+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781169039; 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: in-reply-to:in-reply-to:references:references; bh=PriinPzTGWMIUfhykveslGOYnSGaX13PaffHy++jEKM=; b=b0VLzkWYkVtVbBPnsPDFwqjZnPmyJ691S3rsZu3Q+pBmmA36Xig2s7uBBsNME/HEWGq1ae bJEtoTY/pld3iMc424/p3QBhUhFaTiJiwiS8YbhRq2BJVUQjB68R2YaZXbFi3hAA91Ilqo z6wsD9T8Frzeh2M0xjFlBwhcfeYP4hg= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-55-B0U6QFrTNMmxmZYDaCqiFQ-1; Thu, 11 Jun 2026 05:10:37 -0400 X-MC-Unique: B0U6QFrTNMmxmZYDaCqiFQ-1 X-Mimecast-MFC-AGG-ID: B0U6QFrTNMmxmZYDaCqiFQ_1781169037 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-45ef697092fso4847517f8f.1 for ; Thu, 11 Jun 2026 02:10:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1781169036; x=1781773836; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=PriinPzTGWMIUfhykveslGOYnSGaX13PaffHy++jEKM=; b=b2NAjCs+yiocQ1EEMnKNWuTgzwjJqAoJvYaTBkId6WNxbzMw8MGCP+L0EnWjUKIqjI t9AjeHcGq7Rx+ml1EHQYMaSVyuSN9nCvMAY3cC50auM7kSzIpi1DvcKZ9gW71YvhqYGS /DSict8K0+f+y1mYNSFCQ6we744ImjdMrqboGFaRct0gz81QBQ9RgK7dts5HYflLNEJn WdXhiRZTvyxvNlNnjwqGgIFdEQHCmOxz6qsNT1yyQm/LT2rLCvewN5A6tTBNI5VxHD5i YbIXpLh4d4n7s7ZcmI3HzcOhf40ZRdVNBgOLVr+BnsHZaB9U6kZhOgDjjEJR+iDF1g9l Viiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781169036; x=1781773836; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PriinPzTGWMIUfhykveslGOYnSGaX13PaffHy++jEKM=; b=cvzvIxrk3DDVi/YO59uJ+KYN8cgc1zRm1AFnqqLZtHyz3bhpfplZK3wmkJe6gdebR0 ETR7f33pTY/PZVfNSKFut9lOFjH5HZndzyU0gzeL9C6cdYAkIwDFxfasQfILbDR34Gfe fzJD+b7y3u0iiYqbA/25Z0halqu1U8ftjI0QOZVN694Xq4mCNyA+5EI+UzkH7uXbFuA1 fSdmbQnTz5HY2x8Q4Ak6Fi0j39WaDsRych6JvJrbypS3YwRO3eENk+K9Lcec6YqI+C9O VvOH+xtuBhvomf8C0Nqg4Al5TKqaZI8NxCUzG3GCwVuGazY7uh8rJm5ctUBEqVJhrzQk nBqw== X-Forwarded-Encrypted: i=1; AFNElJ9nXvYgPbS1L6zOU37I3j2p6eNPFvWT8aNDlzRqGTaj4DUzjbm4swxGzh74uu52rRSnr/UuM+AlL8B5f+c=@vger.kernel.org X-Gm-Message-State: AOJu0YyCq1BVw8xGhLk5MDwYagQbPqcJWMnVubNzBZ7NLOoewQTZUlFq mb/PHPuFlJCAt8jhlJAkWXahy0Ls5MHMm1jFQ9XOa8XWxcM4rTAYLFVNlGyVoeb7s/5wm17XKJ/ enmBkxc+fA3zu6hkCW1an7ZmHaKBPUjzJyuW68jkVAYgQTk4RoPyfQRT9oZV7bAj0gg== X-Gm-Gg: Acq92OEOAnbb9xhBt1TjfAAJzUFEZs18LNUpDuw3DMdjdEzXWoA4A8RA9SDMRvVZ9rC v8f1eMuZbEJYhqkQZkxO5suL1rRRKoqoQvtAbu+V17+Hy2aOTW5+XcmO1NkyWm6P0y0o2W/dzyO +CWvUmEfZx4zqLG6PCoTWTJtkMbYJ2Yyt22t9rjMM/O7TgzQ2NpCG5NHM++vW0SXv1DH3qAyv0r tlv2snZK+EitaoWN6qnl2iFn7dfyVPqVaULRtq/5P33GjTOzGJ2Ke32ECz8euex4iJjazNZbheW 4KDawQ4Fa7zMK5IHy8GC/JL9CbAwChtkjVOXfbZ1n+15flW/JSBDvmQ6rSP5ICgGphXmcLk9wCt IzCtRrXlNSy1dDAAarXRTUxUEzVPChxnrhISRSiRODuHg/BHB2wZfBg== X-Received: by 2002:a05:6000:18ac:b0:45e:b21e:f840 with SMTP id ffacd0b85a97d-46067469f27mr2851813f8f.8.1781169036390; Thu, 11 Jun 2026 02:10:36 -0700 (PDT) X-Received: by 2002:a05:6000:18ac:b0:45e:b21e:f840 with SMTP id ffacd0b85a97d-46067469f27mr2851771f8f.8.1781169035966; Thu, 11 Jun 2026 02:10:35 -0700 (PDT) Received: from redhat.com (IGLD-80-230-85-71.inter.net.il. [80.230.85.71]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4602cda3651sm68120262f8f.32.2026.06.11.02.10.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jun 2026 02:10:35 -0700 (PDT) Date: Thu, 11 Jun 2026 05:10:32 -0400 From: "Michael S. Tsirkin" To: Herbert Xu Cc: Michael Bommarito , Olivia Mackall , linux-crypto@vger.kernel.org, Jason Wang , Kees Cook , Christian Borntraeger , virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, Dan Williams , Ingo Molnar , "H. Peter Anvin" , torvalds@linux-foundation.org, alan@linux.intel.com, tglx@linutronix.de Subject: Re: [PATCH v3] hwrng: virtio: clamp device-reported used.len at copy_data() Message-ID: <20260611050731-mutt-send-email-mst@kernel.org> References: <20260531142251.2792061-1-michael.bommarito@gmail.com> <20260611025916-mutt-send-email-mst@kernel.org> <20260611035035-mutt-send-email-mst@kernel.org> 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=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Jun 11, 2026 at 04:18:46PM +0800, Herbert Xu wrote: > On Thu, Jun 11, 2026 at 03:58:17AM -0400, Michael S. Tsirkin wrote: > > On Thu, Jun 11, 2026 at 03:46:58PM +0800, Herbert Xu wrote: > > > On Thu, Jun 11, 2026 at 03:30:14AM -0400, Michael S. Tsirkin wrote: > > > > On Thu, Jun 11, 2026 at 12:43:09PM +0800, Herbert Xu wrote: > > > > > On Sun, May 31, 2026 at 10:22:51AM -0400, Michael Bommarito wrote: > > > > > > > > > > > > + size = min_t(unsigned int, size, avail - vi->data_idx); > > > > > > + idx = array_index_nospec(vi->data_idx, sizeof(vi->data)); > > > > > > + memcpy(buf, vi->data + idx, size); > > > > > > > > All the "malicious device" things are confusing. Spectre things - > > > > doubly so. > > > > > > > > So if an access is speculated then CPU might speculate feeding a kernel > > > > secret into RNG. And then the speculated RNG value maybe can be also > > > > speculatively be used by some kernel code as an index > > > > to trigger a cache access, finally leaking the secret? > > > > > > > > Maybe? > > > > > > The way Spectre works is if you have an actual instruction using > > > idx directly. I don't see how that translates to memcpy. > > > > I am not sure it has to be direct: > > > > if (malicious_idx > SIZE) > > return; > > src += malicious_idx; > > Wait but vi->data_idx isn't even under the hypervisor's control. > > It's an index maintained by our own driver. So how can it be > malicious? > > Cheers, > -- > Email: Herbert Xu > Home Page: http://gondor.apana.org.au/~herbert/ > PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt data_avail is under hypervisor control avail = min_t(unsigned int, vi->data_avail, sizeof(vi->data)); if (vi->data_idx >= avail) { vi->data_idx = 0; and maybe this can speculate past the if? I agree, this is all speculation ) -- MST