Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp745492rdb; Thu, 19 Oct 2023 19:29:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IET7955R4wrGlXqwErvgMP0GAJOzqgQAEjCSGstC/xeeM4gjgosJWKO5QE1XAadDUGaiCur X-Received: by 2002:a05:6870:28d:b0:1e9:e605:279b with SMTP id q13-20020a056870028d00b001e9e605279bmr784415oaf.19.1697768959605; Thu, 19 Oct 2023 19:29:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697768959; cv=none; d=google.com; s=arc-20160816; b=UhYT7XX0pB/MXTH91Bv72zBHbpAN0EOj83MJUszCGfwTQwJU2lx6bn0vZ6ylJOBl44 /APgDaMjYHIoWlJ9TUPWUvY6vtXtTS94EQxhqWvhtaRcyR0VA5IKkmrCzzV5QuAw83Rc FhUXzB4mhNqA3htQTgT4RB5w0THRFVuFBENCCC0QSVUzlQSXYclRtPn4l+fw4JN172YX 2olJjMMWJCZ14fn+8inJ6YX717q+4iERiQeX7zXM2K6TaFFaovCZbz8cQj0hDk0pVmRS BThm94ORT9Lz5G7m2TrrdlCLZuQBJdd6+dSOCC2eTSyEp/4lsalXblnP6wdhvSNllWMm qjlA== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=Ozb5PuMIZdsqagwbp/IYOMYWWOwC8ObSgQZuuvWYiSM=; fh=WiTmwIj1iivjUzxVMaakurwdigti3No5g5Jn00Bebyw=; b=VdBfjNfQwj3SsmEIQOMaELNERBkQwZydwVST2Xx/igHBrDXht5pkRYHFrHYAa77Y6S kNO1TZaddw2Wletmf3VmQKiOgM1ntdE/g+yHZSH9wEHyQDIrXzh90TE9lyOO0V8GAcgL S0V6kei95JUw5qEvU7UGOQDXLIn/ly/3jkvSWUHZbl3asu8KxiFShGCz6tiEFm+LGkPG KdX1LSybKts9Ra/ZOP0TUxNhqKB1pSFapyn9EvPIW5DGBJZkb1jwy2AmTffc9l2gbKau XaamXLmO0K4dy4DH/6uOlwQBdMUaG8XW96o1Qf27xSOjmMLEzL3nR4gZb3wm4irmGe/O TdNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=je5Ptmdi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id y17-20020a637d11000000b005859c1e41a0si843445pgc.201.2023.10.19.19.29.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 19:29:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=je5Ptmdi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id A28F681F32A6; Thu, 19 Oct 2023 19:29:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346836AbjJTC3E (ORCPT + 99 others); Thu, 19 Oct 2023 22:29:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235585AbjJTC3C (ORCPT ); Thu, 19 Oct 2023 22:29:02 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1E021A8 for ; Thu, 19 Oct 2023 19:28:10 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1ca6809fb8aso2630085ad.1 for ; Thu, 19 Oct 2023 19:28:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1697768890; x=1698373690; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Ozb5PuMIZdsqagwbp/IYOMYWWOwC8ObSgQZuuvWYiSM=; b=je5PtmdiXoFhlg0YcBVeo7UvuUI/tifjb6UgMRDnhFF6/tOJT5NQtjv4LpodA7eVMa r+tyLaW3BBLTBXSx6jr2V1mHcOeHilhc/i8i64z8hUo+yoRkFl1yuP564p7e++5VrSmi 9IOm3+aOLyOUNFPO1b2mXwkoRrcjsr+hSgTBAOdBjVBEAHIg14P9VY584r4zm1G20842 aRDm34OCAO4VUY0pMxONyCTZP7iYN0fmYvfxPHlm+kHBCcanRSMmzLFbiXGmkCq+w71q OYAtAKtKxh73NyqJK7tjfXR5+ytRWDuJoHE4FSNX4uMgRTUvTaIZOgoLdO37kborLh1o dJfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697768890; x=1698373690; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ozb5PuMIZdsqagwbp/IYOMYWWOwC8ObSgQZuuvWYiSM=; b=tvWag+mJB7S/78ydw8A/dVhfR5rsRwJVu0UrsDo2XFDGW1EVeeDpMa8mxjzQQPhdLm jaI1jGVftxhtdEFCNNNhmr5AKHaIfHSEJyywjNjoej5cLYoxdHhatcBqxEOobLfDsIjo yd/d185LXKy3Tyu/tALeomCeobWtx5veoDXjd/Ui2OEnJIHeXf4/gLoDQRexV+vZ+XH8 Ha/p7GtXs1MBlZhThen/K3VBgXenQBpUqLJ3meRWg8Da9vwvTmjM9HWI/88+MIDLeP6g 6Dr+SeDg9sBhWdK+jP4WlhgZSudAO463jDMD7Set+o4CNLxOJLxOMRbaCa93YM/WXYB1 98fg== X-Gm-Message-State: AOJu0YyxNA242m1oIkcXnS56SKK1zypHm9eC1Fkmq4Qz1xSdAynidnw/ cr7+1ZWxxJm2MhMPc8y6AmEyRFnDFkPVeAiFt+w= X-Received: by 2002:a17:902:ea09:b0:1c5:de06:9e5a with SMTP id s9-20020a170902ea0900b001c5de069e5amr606142plg.21.1697768890168; Thu, 19 Oct 2023 19:28:10 -0700 (PDT) Received: from [10.3.43.196] ([61.213.176.12]) by smtp.gmail.com with ESMTPSA id iy20-20020a170903131400b001c5fc11c085sm384506plb.264.2023.10.19.19.28.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Oct 2023 19:28:09 -0700 (PDT) Message-ID: Date: Fri, 20 Oct 2023 10:23:33 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Re: PING: [PATCH] virtio-blk: fix implicit overflow on virtio_max_dma_size Content-Language: en-US To: "Michael S. Tsirkin" Cc: jasowang@redhat.com, xuanzhuo@linux.alibaba.com, virtualization@lists.linux-foundation.org, axboe@kernel.dk, linux-kernel@vger.kernel.org, Paolo Bonzini , Stefan Hajnoczi , Xuan Zhuo , linux-block@vger.kernel.org References: <20230904061045.510460-1-pizhenwei@bytedance.com> <20231019055134-mutt-send-email-mst@kernel.org> From: zhenwei pi In-Reply-To: <20231019055134-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 19 Oct 2023 19:29:16 -0700 (PDT) Cc Paolo, Stefan, Xuan and linux-block. On 10/19/23 17:52, Michael S. Tsirkin wrote: > On Thu, Oct 19, 2023 at 05:43:55PM +0800, zhenwei pi wrote: >> Hi Michael, >> >> This seems to have been ignored as you suggested. >> >> LINK: https://www.spinics.net/lists/linux-virtualization/msg63015.html > > Pls Cc more widely then: > > Paolo Bonzini (reviewer:VIRTIO BLOCK AND SCSI DRIVERS) > Stefan Hajnoczi (reviewer:VIRTIO BLOCK AND SCSI DRIVERS) > Xuan Zhuo (reviewer:VIRTIO CORE AND NET DRIVERS) > Jens Axboe (maintainer:BLOCK LAYER) > linux-block@vger.kernel.org (open list:BLOCK LAYER) > > would all be good people to ask to review this. > > >> On 9/4/23 14:10, zhenwei pi wrote: >>> The following codes have an implicit conversion from size_t to u32: >>> (u32)max_size = (size_t)virtio_max_dma_size(vdev); >>> >>> This may lead overflow, Ex (size_t)4G -> (u32)0. Once >>> virtio_max_dma_size() has a larger size than U32_MAX, use U32_MAX >>> instead. >>> >>> Signed-off-by: zhenwei pi >>> --- >>> drivers/block/virtio_blk.c | 4 +++- >>> 1 file changed, 3 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c >>> index 1fe011676d07..4a4b9bad551e 100644 >>> --- a/drivers/block/virtio_blk.c >>> +++ b/drivers/block/virtio_blk.c >>> @@ -1313,6 +1313,7 @@ static int virtblk_probe(struct virtio_device *vdev) >>> u16 min_io_size; >>> u8 physical_block_exp, alignment_offset; >>> unsigned int queue_depth; >>> + size_t max_dma_size; >>> if (!vdev->config->get) { >>> dev_err(&vdev->dev, "%s failure: config access disabled\n", >>> @@ -1411,7 +1412,8 @@ static int virtblk_probe(struct virtio_device *vdev) >>> /* No real sector limit. */ >>> blk_queue_max_hw_sectors(q, UINT_MAX); >>> - max_size = virtio_max_dma_size(vdev); >>> + max_dma_size = virtio_max_dma_size(vdev); >>> + max_size = max_dma_size > U32_MAX ? U32_MAX : max_dma_size; >>> /* Host can optionally specify maximum segment size and number of >>> * segments. */ >> >> -- >> zhenwei pi > -- zhenwei pi