Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1558522imw; Tue, 5 Jul 2022 11:31:21 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sWczLP6ZIjseAKrsfTp9bnV3w70tJ9UMTk0F4tMTbtTdZXatk1mb+vkicZ+kfEinJaL8t4 X-Received: by 2002:aa7:c0c7:0:b0:43a:79b9:5cd1 with SMTP id j7-20020aa7c0c7000000b0043a79b95cd1mr5401629edp.282.1657045881592; Tue, 05 Jul 2022 11:31:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657045881; cv=none; d=google.com; s=arc-20160816; b=qQZWFQK9XuSgtHgHgY5XiVFqU4HW+ZHlSE7RzM7yX7E8Xp/YXNvvXTKosyCzol+HwF yCW8wa+SXdaxftUhQTngTZvoUO96/TYNrPwPJRZ8a8A7BrGUNsoxfxa2HsA5af+owG1u HlUohJxqG89zt7a6x0y0h6Xt8o/XFT5LYQnm0EMfhomcxt0yayrWeQ5EBtmFpOS6s+mZ ExU1S+pv9EJPx1hRFkQH3VSjLuoYLJwdvwB7b6lIKOxcmi/BEAbRfKv4n9WR/QtMFMXQ LUx4JemQvUOyOzUnh1dRbl1QrH6E80XI3VGC17kQryxSNFkcKf0MUAxeDxs7xNVsMGmc IwSg== 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=NBfVoJSUJjdQQlb25uPxwtrVG2zP5XJD8q80sb5lV4A=; b=jpbCDJZzbS1LtPg+NhJPZzPo9eHDhzYLkhSXd2MPSL+VF9pFTcpsatOLyvMxNulmtF qYd7PLf/jj7Rhe8zFu83w8cgRLoFhteuOWlkN/wyFGq1/aXzz/GrWE0IPNFwqju0LXgx XzA1YDcsAPL6/l+ArqC5UoJEZ/+IFvZ0bUqLuuWKMWSoMgw0foebuaYjXZSwLfnM2AKv dw1LnH+oSjlohz5U35EwGfupvqOxsC/snTVu8iI3eSf1dRPyyaARtJKOHO0SGgOIY3Ta S1h4PAbPr1zjff+4+kxYoYNzrnUJXNW8Z2gr2skak1vkRd01OSKxxDPAlp98LNgZA5RX GHvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=QbXbIjGW; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id js6-20020a17090797c600b0072ab62adfc6si12863719ejc.410.2022.07.05.11.30.56; Tue, 05 Jul 2022 11:31:21 -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=@ziepe.ca header.s=google header.b=QbXbIjGW; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231971AbiGESGy (ORCPT + 99 others); Tue, 5 Jul 2022 14:06:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229866AbiGESGw (ORCPT ); Tue, 5 Jul 2022 14:06:52 -0400 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91B521CFDF for ; Tue, 5 Jul 2022 11:06:51 -0700 (PDT) Received: by mail-qk1-x72c.google.com with SMTP id p11so9289939qkg.12 for ; Tue, 05 Jul 2022 11:06:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=NBfVoJSUJjdQQlb25uPxwtrVG2zP5XJD8q80sb5lV4A=; b=QbXbIjGWJFR+vFj17KgXaWRRm9RVaUzey5ETHrNx1L1E4Y6/IIPUz6tWo/LsvxFUEr 4sFAAU1qp1ba2RESZKKr8qk1sqglr8vWSJMskPCRS4d6dqav4StSexv3Yz1Wpu9d42T9 sx5vqagJhApayuqVLlqblgUhC9atwJF7xReaVTKbE007GkuyOi9am0XjnV0SLOj4megt tdOzfWNqnwJXJs8m6EFjBAXznAczO6SgooHn0073jjOTupESoQRFlbDCj55ZoCnTkhnZ Zyc1OZNDoYSDFs4h01UNG7ay5CAcM3i+qvf/pd9geSTMoAXBNE23C2xssZzj4ha/PUvN cwoA== 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:in-reply-to; bh=NBfVoJSUJjdQQlb25uPxwtrVG2zP5XJD8q80sb5lV4A=; b=NOSGW0Ql3MeK/JNEgjjo/vFviQZOAjg7HaneGUNI+55gtKt2fTr1jRqZumi+T2PAnY x/WAvo952DYafMsV96i7x+hMkH8Sc2ATymofmhsU/s1cXfEQSM01t5Kw/fPzRBB+UTyP zuXqrnbjhEumhwyfqkP6cG16L5jxCSWKaYhe4Jj9iW0hg/PYU0mHXMtGLJcivx30lwH7 1AHumBW5IuTb9yAaTtZWcKBedIh0+rdlP9qkfHEKfZu7C3Wl1ipI+YWLnHKlI0a6O6bN DaBjthHbFu3Wk2d9yACflmAAZXQVvkWMBvpqimEK191MJss88NkGOL5VmXU+bKGw9eAw /LNg== X-Gm-Message-State: AJIora89HmBGT1rtpraANH76yaCZo6Zmn0r240V2hRbw9+DgTDINM6hW doGRcOIx6Zob3JoQFkNvE7WpyA== X-Received: by 2002:a05:620a:7f6:b0:6af:2bef:2f67 with SMTP id k22-20020a05620a07f600b006af2bef2f67mr24446278qkk.595.1657044410618; Tue, 05 Jul 2022 11:06:50 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-162-113-129.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.113.129]) by smtp.gmail.com with ESMTPSA id bm14-20020a05620a198e00b006b2849cdd37sm7277258qkb.113.2022.07.05.11.06.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 11:06:50 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1o8mwj-006aGy-Kt; Tue, 05 Jul 2022 15:06:49 -0300 Date: Tue, 5 Jul 2022 15:06:49 -0300 From: Jason Gunthorpe To: Dan Carpenter Cc: Longfang Liu , Yishai Hadas , Shameer Kolothum , Kevin Tian , Alex Williamson , Cornelia Huck , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] vfio: hisi_acc_vfio_pci: fix integer overflow check in hisi_acc_vf_resume_write() Message-ID: <20220705180649.GI23621@ziepe.ca> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Tue, Jul 05, 2022 at 12:05:28PM +0300, Dan Carpenter wrote: > The casting on this makes the integer overflow check slightly wrong. > "len" is an unsigned long. "*pos" and "requested_length" are signed > long longs. Imagine "len" is ULONG_MAX and "*pos" is 2. > "ULONG_MAX + 2 = 1". I wonder if this can happen, len is a kernel controlled value bounded by a memory allocation.. > Fixes: b0eed085903e ("hisi_acc_vfio_pci: Add support for VFIO live migration") > Signed-off-by: Dan Carpenter > --- This code was copy and pasted from drivers/vfio/pci/mlx5/main.c, so it should be fixed too > It is strange that we are doing: > > pos = &filp->f_pos; > > instead of using the passed in value of pos. IIRC the way we have the struct file configured the pos argument is NULL. Jason