Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7440059rwi; Mon, 24 Oct 2022 14:50:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM613Dq5oGUgg/w5ug/ctW9sqatGkqQGkUjB+EIEGzPwjcGZ5pZQHWWFOl+TNa8Xa1BWNq9C X-Received: by 2002:a17:903:183:b0:184:8c1a:7a95 with SMTP id z3-20020a170903018300b001848c1a7a95mr35603429plg.137.1666648256405; Mon, 24 Oct 2022 14:50:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666648256; cv=none; d=google.com; s=arc-20160816; b=09I/kFkR2swEqDliqrW3YRyFm2tFz9BGUGZ1u/sgurBgatTFQxaNxvqisA5+ZDqGS/ B9vVmBrNF1seGNIl+0xKXtLXhkp34KEivXrs6tUaG7orZly+/XQvYgOw4aZa5HmZTuyY 8plB0TXPhfpCKiyUUTXS1HXgRy9DOI3zqo9hbp5w+yvN0XW3xCOINsu0+WFYeyBJVLYH zKySuS31/S7yKtpRuRlHs3oqBk6Z3xEiga9kAznA92RKdJIggs8v0CJPDhdznUMjuKpN 9O2SN/D5Jeepzg+0SCtbO6SUFejMP45zqutxD+SUayxKuWwNeZEGbuImD3X87vnepztd uZFQ== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Co+mZwrA6BtWICFuluqHpcYHUEFY3CVy1+yDBlYoNG0=; b=BL8879UeeImVM/zRHaVDrMiQHX4WThFgqRpnoi4oTRoYQBPCQhr7Is9h4SxJ7PxQQ2 /Z3KUwNHx3vUom4N7aYOKyi3MY0Une38MBTQOaCGiPbJ+EdT2agZ/GH51Lgt2DArRrNh FNZ8Sn8a1qV3Q/Wk/m6xUwKmoNOOknJxQDhOurTk8hrGTnvvqv7W30HIHclm2wEYYC/y nbp4p7SMdY3lx2a3tAB1ak0zO1KEuT83THd1HqZ9Gl4BIiq1kTqwrv0oD8AU6wIM9cMT 1Djqwk1jWSl59kiCPjfTGluIKX+QVyTJVJkruWl9bBB9SSiVW4+OfRo1ZfeZIHXWyKwR f6cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Q479hDSt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u4-20020a17090282c400b001867d1a71a6si631641plz.473.2022.10.24.14.50.44; Mon, 24 Oct 2022 14:50:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Q479hDSt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S235273AbiJXUzn (ORCPT + 99 others); Mon, 24 Oct 2022 16:55:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233306AbiJXUzX (ORCPT ); Mon, 24 Oct 2022 16:55:23 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51B95254353 for ; Mon, 24 Oct 2022 12:01:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666638039; 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=Co+mZwrA6BtWICFuluqHpcYHUEFY3CVy1+yDBlYoNG0=; b=Q479hDStkpcI9RDfyNllK/cMRaOjc3NUIFuDF+FAc0TSFCnxT0SwsaaTNKg2B5/V7/QtJo 8PD35LxGPLkbqE3xUsuRWwVE4SBcSpVbmmzSmRi4mYyu49DX8AP1C8OBMSLds3/LQvInE4 OiL0d6a3L518ERDTeZRjn3vWboedjCE= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-148-RTQ_oMKVP72m1fEpNNDXFA-1; Mon, 24 Oct 2022 09:33:53 -0400 X-MC-Unique: RTQ_oMKVP72m1fEpNNDXFA-1 Received: by mail-qv1-f70.google.com with SMTP id q17-20020a056214019100b004b1d3c9f3acso5241157qvr.0 for ; Mon, 24 Oct 2022 06:33:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Co+mZwrA6BtWICFuluqHpcYHUEFY3CVy1+yDBlYoNG0=; b=mY8D+SO3+MUniwpVPNNkfv3RYhWZxLk6VGee1Uh4fm+LfgB7cUqQvFMhf9j/G1TBpx 1O/Xrv4oxJWKpX1SZC2azToPVMNyhLQYko8LSGmmiSb597bObs72WXClrfouS9Ahvhfk zjf8kKT5d4qmqHtdbbFHIEFP8kJXwzDO7BJZ8USi/vJXcUwJeufv4LRL9Sg7lGWf9oOK g2q73/N66VvlEr9XsmfArNu6OUwqsYQBN7aM8FtgdORTIk1+oVqtZCtKZxBwWhUExaSb RXzk3eBs1TJgftJP8LXLYPaWJdm+d3JOkGafMeKBJxU1oxSBRbmh/+FcUVi6ZXzvL+Cw WCfA== X-Gm-Message-State: ACrzQf2faRdaLyV6bkZopy7gzM92aoUymQzUkmx54TZpIxDTG0TNI9Vz KzNriWI8UKHLahH5AFG9LebGALJAPYnazIdPPLmkwqNOcESb0GflpKq7wxSbdMXf1ru8lUSk2SA dO3rbcfV+h6Kfj5CnQzA+X6pJ X-Received: by 2002:a05:620a:2991:b0:6ee:92ee:5165 with SMTP id r17-20020a05620a299100b006ee92ee5165mr23277314qkp.177.1666618432976; Mon, 24 Oct 2022 06:33:52 -0700 (PDT) X-Received: by 2002:a05:620a:2991:b0:6ee:92ee:5165 with SMTP id r17-20020a05620a299100b006ee92ee5165mr23277283qkp.177.1666618432728; Mon, 24 Oct 2022 06:33:52 -0700 (PDT) Received: from sgarzare-redhat (host-87-11-6-34.retail.telecomitalia.it. [87.11.6.34]) by smtp.gmail.com with ESMTPSA id ay11-20020a05620a178b00b006ee96d82188sm13005230qkb.1.2022.10.24.06.33.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 06:33:52 -0700 (PDT) Date: Mon, 24 Oct 2022 15:33:46 +0200 From: Stefano Garzarella To: Rafael Mendonca Cc: "Michael S. Tsirkin" , Jason Wang , Paolo Bonzini , Stefan Hajnoczi , Jens Axboe , Chaitanya Kulkarni , Suwan Kim , virtualization@lists.linux-foundation.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] virtio_blk: Fix signedness bug in virtblk_prep_rq() Message-ID: <20221024133346.whuejusy333o3vqd@sgarzare-redhat> References: <20221021204126.927603-1-rafaelmendsr@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20221021204126.927603-1-rafaelmendsr@gmail.com> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 21, 2022 at 05:41:26PM -0300, Rafael Mendonca wrote: >The virtblk_map_data() function returns negative error codes, however, the >'nents' field of vbr->sg_table is an unsigned int, which causes the error >handling not to work correctly. > >Fixes: 0e9911fa768f ("virtio-blk: support mq_ops->queue_rqs()") >Signed-off-by: Rafael Mendonca >--- > drivers/block/virtio_blk.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) Good catch! Reviewed-by: Stefano Garzarella > >diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c >index 19da5defd734..291f705e61a8 100644 >--- a/drivers/block/virtio_blk.c >+++ b/drivers/block/virtio_blk.c >@@ -321,16 +321,18 @@ static blk_status_t virtblk_prep_rq(struct blk_mq_hw_ctx *hctx, > struct virtblk_req *vbr) > { > blk_status_t status; >+ int num; > > status = virtblk_setup_cmd(vblk->vdev, req, vbr); > if (unlikely(status)) > return status; > >- vbr->sg_table.nents = virtblk_map_data(hctx, req, vbr); >- if (unlikely(vbr->sg_table.nents < 0)) { >+ num = virtblk_map_data(hctx, req, vbr); >+ if (unlikely(num < 0)) { > virtblk_cleanup_cmd(req); > return BLK_STS_RESOURCE; > } >+ vbr->sg_table.nents = num; > > blk_mq_start_request(req); > >-- >2.34.1 >