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 D30C3370AD1 for ; Thu, 11 Jun 2026 07:58:25 +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=1781164707; cv=none; b=BPv1LNYlR2fC7jR+p8uZVkZw/f7yIxSL+YiWf4h0HUYvEZCGyOp55Plq2e82VmxlPrTiYnQl+d95iDQ+AeYAdJ1godgVacvq5f2l91mJGmq2GBmm2bal9XfuAAFaGgG0tmh+QsCaj/vda1+HQUP+Dl45SBSnVKMWortmNhiQY2Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781164707; c=relaxed/simple; bh=Bjyaxy6d6sDYB0cCMVeZFvsz5568RZUKEAaWTXKM5X0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cAhSIESOpo9FMA5NJxkum58MzC9wIJKkdSuBqf+ndEBVxkCatJRokqr/Cgn49Tb0CZRiKHZPg1BIZbGWD0+vj1xwzq1LiXmnhT+BmIdIYg80+YSPZl1Qzy91mfdEeRJoV6oNFVj8G/X6/EAOl0xKiyyJPQMt1KSDCNKBHVMPN3U= 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=WWEH+1tZ; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=WjjU4qZ1; 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="WWEH+1tZ"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="WjjU4qZ1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781164705; 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=RPZeu4WL540NL3gNeV8fLdaGS7lC3tamuCeTPSZyTwA=; b=WWEH+1tZI8jPlQIl2i0wLY7+Rq/YSLRo/npCLWyPxVE0v76yo+f1F+GYLbuTFBL/V1gAx5 hACQd5d3pLyC3QWUeaE/VrsR6VHGafG4ksQEJ4ynzVeCaBa6xQ4doHk5kVKCvgaMHqYjXA DPwgJIOHtTpHA1r63SXq9ZrMepwmF6A= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-471-8KAr9w4ANemTv0iKsMv2Vw-1; Thu, 11 Jun 2026 03:58:23 -0400 X-MC-Unique: 8KAr9w4ANemTv0iKsMv2Vw-1 X-Mimecast-MFC-AGG-ID: 8KAr9w4ANemTv0iKsMv2Vw_1781164702 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-490bfd70b0fso76799325e9.0 for ; Thu, 11 Jun 2026 00:58:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1781164702; x=1781769502; 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=RPZeu4WL540NL3gNeV8fLdaGS7lC3tamuCeTPSZyTwA=; b=WjjU4qZ1kWsk0PF23cQWp2FEI8rM6sOTrKrFwoYF017fbPV8UAKCNQAEja+LhxKUkl TQANN0Web0ndXeIFWCq1qRg8QcXG6hF4xwr6b++xTODdLbwcDZg/9M1TY6cQ4DRU5oiG HEmD3mVDwiwVOK//IIeRlFAn8gKkRYyW8sEdNX0gyczkDfgokiHnWl+VERJEBX+/Jp8k eXc/2fcdz8j4kP8Y5s6ULgLv66G2cB0HjFZvahkoWfZVpdFbIEvejC8p2530G1BhUE67 I+aTlHeBwgVUABRlkAdYlPRU6w7qp3EL1ch9ZZUfUxDkwRT3gerZtdKu4EBNx29HSi7X bFkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781164702; x=1781769502; 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=RPZeu4WL540NL3gNeV8fLdaGS7lC3tamuCeTPSZyTwA=; b=sJ08Xh6H9GGaJgHiH8madj1UksqkVtd9RHWoNBs2xlcG0y02XLFC2/XTqs8dg3zs8I WHXzu4t4+oPrt62b2YbYz0K5fZroDG+2CBVcfQcSQ2sFbpRkTpZPYAICu5jRWpKXDDxZ dMVLa8/oDEEvudkP0G5g9TB4/D82oyjumA30x63zRulBjmzwnUl30Zz7KyY89SDBULjs +T7nP816LCZfEC6oGrJAMg064abdabmupcuX5ray/fy4zxzEllbSPLikuAF6TP7TxmUr obJc8kJP296tPtaw5QW18Azbth18UBVikEZcDINOxlt7qS0yd4XiMy128eAhbrFGwvht Bq+g== X-Forwarded-Encrypted: i=1; AFNElJ9UXR2vcYHNDntoX/mbJ7JpymNzbHs/jocYBzXoHupKoiZlIhNZDIIdWZ6CmHmTDMbQ1f2ws6eHRLGptXM=@vger.kernel.org X-Gm-Message-State: AOJu0YzoMHtj7ZKQ0PlZw6FwA2D4M+L9FEgxUYU7Iqcj7W1F19ZFrJ1L EP6GkS0jKqVacASXHEpZTCYxXA6E1e+H6ZSOj/9Ad8wzx4/6Vl3IhLPMfVoHEHnpV7GbdgsKnHx MNg74oQDQarShb7yZNTjiqQ4SSOAcRluTJceXrgXMTpQi6l7Jp9QQYs3yG3aTKlyKtA== X-Gm-Gg: Acq92OFHnBQAM1bNWex82foFLJ5OLERIgnY219Z+8OiFpIM/b202ELexOg3dASCMzb0 Eo4G59jYv9s7xCTKPQ0nFEynPtPlPlQQYX5NhOJKB+zYd21E9pMsU/urw2MiTiA7R9FP36Xil+P D1/qf0JaXRiIL32is088f4D4uW0k4sMgUCAhwu2vuVlo0ZmbBekWppWwmBgua3k8QCa/GUbiI0B YYVYuU6mhRWwCVYMi1+f8TLKtWSMYM/IfMBgGI9UVdEPePSFEVnmFdnMosSIS+D9FYZQSR2mfM7 E7AxlRwdj9koDw/uQwYwO7qPK1xXuKYPBcGATFIwmJ/SbCusFE9CP7tw2CbSRkhxTGpqgTwjk2j wmK/104x5pGrxO/Dd1f/g0y2TDmP61PmL1H6I7RvHCrz28vmtdFLIKQ== X-Received: by 2002:a05:600c:8b31:b0:490:bb3e:30b0 with SMTP id 5b1f17b1804b1-490e55dc1c0mr20745665e9.4.1781164702066; Thu, 11 Jun 2026 00:58:22 -0700 (PDT) X-Received: by 2002:a05:600c:8b31:b0:490:bb3e:30b0 with SMTP id 5b1f17b1804b1-490e55dc1c0mr20745215e9.4.1781164701625; Thu, 11 Jun 2026 00:58:21 -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-4601f2ec711sm76254621f8f.12.2026.06.11.00.58.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jun 2026 00:58:21 -0700 (PDT) Date: Thu, 11 Jun 2026 03:58:17 -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: <20260611035035-mutt-send-email-mst@kernel.org> References: <20260531142251.2792061-1-michael.bommarito@gmail.com> <20260611025916-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 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; memcpy(&value, src, ...) .... hash = complex_hash_of(value) .... return p[hash * 512]; is IIUC still a valid spectre v1 gadget leaking a value beyong SIZE, or did I miss something? And rng is a kind of a complex hash, but I also think in that "...." in the kernel is probably large enough to close any transient execution window. So sure, we can drop this. > Cheers, > -- > Email: Herbert Xu > Home Page: http://gondor.apana.org.au/~herbert/ > PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt