Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp890364pxb; Wed, 27 Oct 2021 14:33:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrLJWMlORace9xBsIAl8fO+AMCOOAVMHj/xrpbuDHox+6ihyFd3L7Biy7LwyLJb3taVfGA X-Received: by 2002:a17:907:7d9f:: with SMTP id oz31mr151497ejc.180.1635370404082; Wed, 27 Oct 2021 14:33:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635370404; cv=none; d=google.com; s=arc-20160816; b=OHtRjXY8wt76Iy5XG2qRDmRkG1QVcDxRmfaSr4jUT2kAHV6OVU8Xu6Zah5RUKozIqY EvFTfQXg38ZgW5xCQ45vqv28HsATJZ8DQCPPKP+bPzkf5yOO5ClUbrqZtPN8Jxj1/IeL tzlvUKR/k8ZOl/tYRRPd35u2iD1Jy6SqTwoOJtoxS3pnOPEiPJTgQArflyqGfBE6t0SN tc2YqwljyuzfRUiSFxYbF1wVqBfJ4pMEWlFsOSZwj+ee1sXGLunWTAwEV/+wMCqssxcl TBCJ0/XXTUu/6LjzXsYilxSnREX3GAHnAn33/BL3GGohyYqfrcxIiAk9WJ9FlRCnVD1B hCXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=XMEXe0ICv6BgWp98rw/aHq8v8AFBOl4vDkhRVIL80bM=; b=a+dC8cw/lS1i9D/XPKw4DBA5ZdX73/DSV5bCDZeCMzDEJcrho7quhcVhIAXn8sGYeE sO4q2mcudWRulU664yMlM7v85B6PLfmuGO1my2e5eW0NDYtK3Y5RQH11oP7SsIAWPHpr /KFL/QHI57JkaESpx/5okY+GPMhXabsbHMD2c/he3UNlnT4kryDYZqYBWFCs9tD0CWIr gtKdYUNJneWPZZSgZl3IvK7WYOfOYhlySsp5VmNXjrd1NjkTkGVb/0N1AeJBbYJMv6gL dwxPHO4A6PfLoZqYOCwzO/bjQNrbpmSEPYRzVlae8D99owuixsxx4sTFdLOS+IZSaQvc TYyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Cf+eilEk; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z19si1750563edd.610.2021.10.27.14.32.57; Wed, 27 Oct 2021 14:33:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Cf+eilEk; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240316AbhJ0SlO (ORCPT + 99 others); Wed, 27 Oct 2021 14:41:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56551 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235990AbhJ0SlN (ORCPT ); Wed, 27 Oct 2021 14:41:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635359927; 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=XMEXe0ICv6BgWp98rw/aHq8v8AFBOl4vDkhRVIL80bM=; b=Cf+eilEk6I/qHCq0VZGva3yy/wcczIeUUS57T79r/dWWkSynzLbB9doLca+UUKOHbaJTfi kz9eJ/xz3lVtKdQNEYv+hgoLZQEDoQqDgP8xlw6xPTr4xWqYmOYySseyhUgMH6AkVEU9Mq CsYH0UA9QTDFBJR31vrgz90H91vIQ8M= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-392-weYbP1l3MO6JyCUfP1tvBA-1; Wed, 27 Oct 2021 14:38:46 -0400 X-MC-Unique: weYbP1l3MO6JyCUfP1tvBA-1 Received: by mail-ed1-f71.google.com with SMTP id o22-20020a056402439600b003dd4f228451so3142556edc.16 for ; Wed, 27 Oct 2021 11:38:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=XMEXe0ICv6BgWp98rw/aHq8v8AFBOl4vDkhRVIL80bM=; b=FE3WJ4WBwFzA4w8PuBMvufi373apd4a5KEeNYJRKVn4LlNDddgFOs5YqakCM5nug/v V238etbiTpwPgDy1HZ78aWaSVRJ1fMbnjGa+7OLf5IKyQ3fn0t8eD19ZvcommROdQgUB 1DV9CKPq/MQRb4J3p6FkUBD31FiSYjCZYLfxpHVavE447WC78fAYNvrizaY6TWTewi69 lUNp0U9nti8t2yVx4j6LJjgp7TVFjWEWgSN7gT6M646mzloU3++ahhrXtU+ApdvyThvi aIuw2RyQgv30xuNzTonUrQXZGWETHG2Wgciv5Bpm88vq3rQm0zjhxzVNoLXbOglIOctg Nxgg== X-Gm-Message-State: AOAM531HejCrYCn1eb+lZU7ZNdYTBTf32/oqv2kmkZbMbycn6rivF/p9 2t7SAV0M+UnVlr1l9Z1/12rzKan9nj+krH7vQo7sLWgPhE9d+9ABD5SFnnyoU1hhxk/zcU3cgmz xWGkYVjd8EROze7nWQ5eikNmu X-Received: by 2002:a05:6402:55:: with SMTP id f21mr46840909edu.8.1635359924974; Wed, 27 Oct 2021 11:38:44 -0700 (PDT) X-Received: by 2002:a05:6402:55:: with SMTP id f21mr46840891edu.8.1635359924798; Wed, 27 Oct 2021 11:38:44 -0700 (PDT) Received: from redhat.com ([2.55.137.59]) by smtp.gmail.com with ESMTPSA id g8sm324197ejt.104.2021.10.27.11.38.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 11:38:44 -0700 (PDT) Date: Wed, 27 Oct 2021 14:38:39 -0400 From: "Michael S. Tsirkin" To: Laurent Vivier Cc: Dmitry Vyukov , syzbot , davem@davemloft.net, herbert@gondor.apana.org.au, jiri@nvidia.com, kuba@kernel.org, leonro@nvidia.com, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, mpm@selenic.com, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] KASAN: slab-out-of-bounds Read in copy_data Message-ID: <20211027143801-mutt-send-email-mst@kernel.org> References: <000000000000a4cd2105cf441e76@google.com> <20211027111300-mutt-send-email-mst@kernel.org> <589f86e0-af0e-c172-7ec6-72148ba7b3b0@redhat.com> <8b5fb6ae-ab66-607f-b7c8-993c483846ca@redhat.com> <1c0652f7-bb1b-99e1-7e8b-0613cc764ddd@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1c0652f7-bb1b-99e1-7e8b-0613cc764ddd@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Wed, Oct 27, 2021 at 08:20:08PM +0200, Laurent Vivier wrote: > On 27/10/2021 19:03, Laurent Vivier wrote: > > On 27/10/2021 18:25, Laurent Vivier wrote: > > > On 27/10/2021 17:28, Michael S. Tsirkin wrote: > > > > On Wed, Oct 27, 2021 at 03:36:19PM +0200, Dmitry Vyukov wrote: > > > > > On Wed, 27 Oct 2021 at 15:11, Laurent Vivier wrote: > > > > > > > > > > > > On 26/10/2021 18:39, syzbot wrote: > > > > > > > Hello, > > > > > > > > > > > > > > syzbot found the following issue on: > > > > > > > > > > > > > > HEAD commit:??? 9ae1fbdeabd3 Add linux-next specific files for 20211025 > > > > > > > git tree:?????? linux-next > > > > > > > console output: https://syzkaller.appspot.com/x/log.txt?x=1331363cb00000 > > > > > > > kernel config:? https://syzkaller.appspot.com/x/.config?x=aeb17e42bc109064 > > > > > > > dashboard link: https://syzkaller.appspot.com/bug?extid=b86736b5935e0d25b446 > > > > > > > compiler:?????? gcc (Debian 10.2.1-6) 10.2.1 > > > > > > > 20210110, GNU ld (GNU Binutils for Debian) 2.35.2 > > > > > > > syz repro:????? https://syzkaller.appspot.com/x/repro.syz?x=116ce954b00000 > > > > > > > C reproducer:?? https://syzkaller.appspot.com/x/repro.c?x=132fcf62b00000 > > > > > > > > > > > > > > The issue was bisected to: > > > > > > > > > > > > > > commit 22849b5ea5952d853547cc5e0651f34a246b2a4f > > > > > > > Author: Leon Romanovsky > > > > > > > Date:?? Thu Oct 21 14:16:14 2021 +0000 > > > > > > > > > > > > > > ????? devlink: Remove not-executed trap policer notifications > > > > > > > > > > > > > > bisection log:? https://syzkaller.appspot.com/x/bisect.txt?x=137d8bfcb00000 > > > > > > > final oops:???? https://syzkaller.appspot.com/x/report.txt?x=10fd8bfcb00000 > > > > > > > console output: https://syzkaller.appspot.com/x/log.txt?x=177d8bfcb00000 > > > > > > > > > > > > > > IMPORTANT: if you fix the issue, please add the following tag to the commit: > > > > > > > Reported-by: syzbot+b86736b5935e0d25b446@syzkaller.appspotmail.com > > > > > > > Fixes: 22849b5ea595 ("devlink: Remove not-executed trap policer notifications") > > > > > > > > > > > > > > ================================================================== > > > > > > > BUG: KASAN: slab-out-of-bounds in memcpy include/linux/fortify-string.h:225 [inline] > > > > > > > BUG: KASAN: slab-out-of-bounds in > > > > > > > copy_data+0xf3/0x2e0 > > > > > > > drivers/char/hw_random/virtio-rng.c:68 > > > > > > > Read of size 64 at addr ffff88801a7a1580 by task syz-executor989/6542 > > > > > > > > > > > > > > > > > > > I'm not able to reproduce the problem with next-20211026 and the C reproducer. > > > > > > > > > > > > And reviewing the code in copy_data() I don't see any issue. > > > > > > > > > > > > Is it possible to know what it the VM configuration used to test it? > > > > > > > > > > Hi Laurent, > > > > > > > > > > syzbot used e2-standard-2 GCE VM when that happened. > > > > > You can see some info about these VMs under the "VM info" link on the dashboard. > > > > > > > > Could you pls confirm whether reverting > > > > caaf2874ba27b92bca6f0298bf88bad94067ec37 addresses this? > > > > > > > > > > I've restarted the syzbot on top of "hwrng: virtio - don't wait on > > > cleanup" [1] and the problem has not been triggered. > > > > > > See https://syzkaller.appspot.com/bug?extid=b86736b5935e0d25b446 > > > > The problem seems to be introduced by the last patch: > > > > "hwrng: virtio - always add a pending request" > > I think I understand the problem. > > As we check data_avail != 0 before waiting on the completion, we can have a data_idx != 0. > > The following change fixes the problem for me: > > --- a/drivers/char/hw_random/virtio-rng.c > +++ b/drivers/char/hw_random/virtio-rng.c > @@ -52,6 +52,8 @@ static void request_entropy(struct virtrng_info *vi) > struct scatterlist sg; > > reinit_completion(&vi->have_data); > + vi->data_avail = 0; > + vi->data_idx = 0; > > sg_init_one(&sg, vi->data, sizeof(vi->data)); > > > MST, do you update the patch or do you want I send a new version? > > Thanks, > Laurent New version of the patchset pls, and note in the changelog that just this patch changed. -- MST