Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp889632pxb; Wed, 27 Oct 2021 14:32:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqiHYVxsnRnW2+7z4yk9L0MgtQeeGSpw5Dts3h/Ak5eulR7cY/z8OLf7m5k/V9HcL8kRQ8 X-Received: by 2002:a17:90b:1a85:: with SMTP id ng5mr8620297pjb.43.1635370349188; Wed, 27 Oct 2021 14:32:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635370349; cv=none; d=google.com; s=arc-20160816; b=em1YD+d1MX07rXnFS5qvz3Esju3oY4zw5dkJvO+wnCEEgb8OVUSDiYtXbyed5rtNxg rkcp1Pv9Wor9+Us32RS6srlSVWKDSKmjJXRiznt7t60IuVlpM1PvxzzTuZzXiFWsgCPa Ghq7tBoxsAiXT7M/Zy0dgbipx5wkfCvarz1IF511YXFcOFceyyBvFsz456PboqRoWgSM VoALuyLi4m7Xf6I6xZeLzYjXuSyASk3yL1PP2VxuqrYngRXheTG7PzraF3VpvptKPQuw I0pDqeCMZDy2FjiiOozDvJreyHH6zvGWhdiLkEz8IT0ftEQxOtXs2dOemjNFzem7bBmn r3gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=fHL8U/ZQJJWFEflWR8JykfHUlV09wWEBVk/S1a/68vE=; b=zcRpqafesRdojpYVA3kZVPBlc+Jx4uY/ZYzuooY5O52dkZCioY3wCYGebxV/IWZ+wA ChGlFG1ffdfg5MuKaMVifqnOcZzffYIdVDrnjkOaNxhkGMpWbA9fXuiKbB1wS5qJOIHI ZxbpmqW71D1DJ19JssjWmbAAti9Idg1L5cM0AKQJ+3Us7VmvpPCGNnfCIFcDWRbYlTnA jmnohC6u2syJMMnz37+w1qWjGn6ODJQph1Zei6TvIYeIeq9n91OX4N6K7Dziq6M/b/M1 gBKNesu0WrVtpZ2TxtYbRi5h/sEUg5fm1U8S47XjcshBnUplf4wVQ4pUF2hkufvxcaoz fcsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YYOZirjk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 k34si1722643pgi.580.2021.10.27.14.32.17; Wed, 27 Oct 2021 14:32:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=YYOZirjk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S231530AbhJ0SWj (ORCPT + 97 others); Wed, 27 Oct 2021 14:22:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50150 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236965AbhJ0SWi (ORCPT ); Wed, 27 Oct 2021 14:22:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635358813; 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=fHL8U/ZQJJWFEflWR8JykfHUlV09wWEBVk/S1a/68vE=; b=YYOZirjkisX39lxhIeMLfYyaKTOxZ+3ji+lBfgu1OAY6Mef7+R50ZvDfX2mYJWW3SC4Bgu RteGhyzvUzOmMMIXxEnJ2m5Y5UqEbjclBDMQW/Uutmf/tXtnYfelQCojsptuJQsVBXeeQg mkKZ0oIbMp0+QoZbP89Fn+t+fcIhlUY= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-502-5BVVy3BrM1OGC4mQQzYN_A-1; Wed, 27 Oct 2021 14:20:11 -0400 X-MC-Unique: 5BVVy3BrM1OGC4mQQzYN_A-1 Received: by mail-wr1-f70.google.com with SMTP id t6-20020a5d6906000000b0016d956560d3so990514wru.9 for ; Wed, 27 Oct 2021 11:20:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=fHL8U/ZQJJWFEflWR8JykfHUlV09wWEBVk/S1a/68vE=; b=CIlqUK3rfRLlF3R3Dwer91IF8pYTmp2kJs40qX9hplmq7asL1cRjVeJx2Q8KLSayEz T99PulAvHpAEZJS8sydIfJdQN45fo7MbEDp5rh66FpVFnMrhb/Ke3XATFoQAbqAaLij+ 9iQq3S5uq+1j0lkyy6We0cMxmFsmRJyXTazaU1Jc+fItf+ZyMkfcWlKC/1nYQKCDoX1j 3n3V0Q+NqqEpgT12oP3wGI87ary+5jUL4tSLyAMQ+v6BMA7waLypgWgMD4QRU92lrHSJ tVezG+wR5neufQX760dn6e9LzLrtPOmnhG9tSZv5KBcel9CBAC4XsUFjkFvfiQsRL2zV dPNw== X-Gm-Message-State: AOAM533yfWK9BguJMhA2ElBTfHQ+BGZiUj6Jk4gJyWh1N1Q8XckSGpeT 6FxXlKENGvSUDSppuG90u9/5qyLhhXrFse9tQGTNjpCt84IY1eFpVESlnCBVS9XU8oK4bs351/Y TQ+Bjks1I5vsHbCmHHhmzCJa/ X-Received: by 2002:a5d:614d:: with SMTP id y13mr43766550wrt.199.1635358810391; Wed, 27 Oct 2021 11:20:10 -0700 (PDT) X-Received: by 2002:a5d:614d:: with SMTP id y13mr43766508wrt.199.1635358810124; Wed, 27 Oct 2021 11:20:10 -0700 (PDT) Received: from [192.168.100.42] ([82.142.14.190]) by smtp.gmail.com with ESMTPSA id p18sm535005wmq.4.2021.10.27.11.20.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Oct 2021 11:20:09 -0700 (PDT) Message-ID: <1c0652f7-bb1b-99e1-7e8b-0613cc764ddd@redhat.com> Date: Wed, 27 Oct 2021 20:20:08 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [syzbot] KASAN: slab-out-of-bounds Read in copy_data Content-Language: en-US From: Laurent Vivier To: "Michael S. Tsirkin" , Dmitry Vyukov Cc: 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 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> In-Reply-To: <8b5fb6ae-ab66-607f-b7c8-993c483846ca@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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