From patchwork Thu Dec 8 16:01:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 13068569 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCC3FC63708 for ; Thu, 8 Dec 2022 16:01:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229894AbiLHQBk (ORCPT ); Thu, 8 Dec 2022 11:01:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229734AbiLHQBb (ORCPT ); Thu, 8 Dec 2022 11:01:31 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 133C598EB1; Thu, 8 Dec 2022 08:01:31 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id co23so2151464wrb.4; Thu, 08 Dec 2022 08:01:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=jDcHlWQmOBs6fq97eWYyCWmnhTKwKkbq9TW3BkoAdgk=; b=akK0Itw7UZDiPCGNugJ6Q1GnqlnJJTDd1vXt+WQ9zf1TH8cAVfQ0mbiKGsQ9QbDuRS sY5p2g3dqVmXHz8rROxtbN6puHX1cr/s9g8O7Vm3HxXxe3dyo/MntNaeylRAF+26c4vQ AwdFi2TtkNr+I3qucl5SZjS3g8htewF+NfJ/z/IzQI4D9UnRZ3ws1PYHOfiwREJ+oReT 30LP1Klvh9WdKFk73WuwcqddvZJ2JoWmz1OdIKMm3XlA7wEWXQ4DSRuhV4QkhL3QIDjS kAd0EVslldcx1YLYnWFayfu9Mbpo3GdtAgHnpLgEXiTVicQVUTPRA16Z+6x/zsTa5vcq IphQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jDcHlWQmOBs6fq97eWYyCWmnhTKwKkbq9TW3BkoAdgk=; b=vhqj+e/YubUVsacyLBntoMgO4t2GOVxFhYe0d9ZDZI2nQmFTAxfPwNPiDqyDRmeZ7d wX6g66Clb5aTQl1HJAxLNxS4KqjHI2u8m2l1I4JsI6acKX9Ikasrpp6WhukFDc0FhI/P 665EfowzLk6SS4wEPGSl7yu5fD696G5vtOef3uzePJk27pWYKT/T3Hn/dshSPNaQacSM sAKfAGVjn5yZglAzwdxfsfaySdb5IblPlZZoLGsttPFm4/7o9kCf1jm0k/rIRUAfwMcy WCqsSUa4tWxTwS2zsrN5jYpWDn3O0jPbptb279TX+pRx21s5VF7pi127cYdCD8qRRH2C OSaw== X-Gm-Message-State: ANoB5pnr1qu39fk6DKA2Pu596/smXlgED24hjbV7ReX90UtI0ai5CS1K 27YPCq33D+ynATalxya+sUw= X-Google-Smtp-Source: AA0mqf74k0Swnm7Giy6+WouOkPunXbKWA+HNpqTfHRISsoqFPiPqbBOfn2O7ER0LxLlRLXWxfjlRcw== X-Received: by 2002:adf:e410:0:b0:242:32d7:8605 with SMTP id g16-20020adfe410000000b0024232d78605mr1807365wrm.47.1670515289245; Thu, 08 Dec 2022 08:01:29 -0800 (PST) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id ay5-20020a5d6f05000000b00242710c9910sm9688970wrb.8.2022.12.08.08.01.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 08:01:28 -0800 (PST) Date: Thu, 8 Dec 2022 19:01:26 +0300 From: Dan Carpenter To: Jason Gunthorpe , Yishai Hadas Cc: Shameer Kolothum , Kevin Tian , Alex Williamson , Cornelia Huck , Shay Drory , kvm@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH 1/2] vfio/mlx5: fix error code in mlx5vf_precopy_ioctl() Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The copy_to_user() function returns the number of bytes remaining to be copied but we want to return a negative error code here. Fixes: 0dce165b1adf ("vfio/mlx5: Introduce vfio precopy ioctl implementation") Signed-off-by: Dan Carpenter Reviewed-by: Yishai Hadas --- drivers/vfio/pci/mlx5/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/vfio/pci/mlx5/main.c b/drivers/vfio/pci/mlx5/main.c index befdb0de32a1..83137228352e 100644 --- a/drivers/vfio/pci/mlx5/main.c +++ b/drivers/vfio/pci/mlx5/main.c @@ -404,7 +404,10 @@ static long mlx5vf_precopy_ioctl(struct file *filp, unsigned int cmd, done: mlx5vf_state_mutex_unlock(mvdev); - return copy_to_user((void __user *)arg, &info, minsz); + if (copy_to_user((void __user *)arg, &info, minsz)) + return -EFAULT; + return 0; + err_migf_unlock: mutex_unlock(&migf->lock); err_state_unlock: From patchwork Thu Dec 8 16:02:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 13068571 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0803CC3A5A7 for ; Thu, 8 Dec 2022 16:02:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229795AbiLHQC3 (ORCPT ); Thu, 8 Dec 2022 11:02:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229966AbiLHQCZ (ORCPT ); Thu, 8 Dec 2022 11:02:25 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD8709D2FD; Thu, 8 Dec 2022 08:02:21 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id d1so2126055wrs.12; Thu, 08 Dec 2022 08:02:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=+upKZf2dVdk/UxAtWyh1oWLSgNq0wwxbyFaq7JE/2d8=; b=Q44swHCZKzaZk3wZ/4tWkIvan1eLvsEiQW7rNIsOHb7fsy0lRHKtKLn2K/vwcQ9c1p kIvp+9JrZ9UIhJZOHKnFFn6oZhAqcBTAuajF5GNjSTE8NUE3ytFTPCG4l9I7w4N20lcN mcL3LJ5E5cwcJlU+tNZpCrtYeK3R6iejM/i/Iy2qo/jGOGyZ4a2mPOaZbo3RhlkZ+d0M fmhjeue1qH8ZumemCJBnu8YUbk9YRzHTTP9bEtt+daUoGkfialkFTXaZA9mI4Zz31e1i f0K091Mb0TDdLLiRO0h1qhZKCpWoJLkQaMUancARgTdkOxJCbX3mgaDK24a+ol4W6viz xEmA== 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:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+upKZf2dVdk/UxAtWyh1oWLSgNq0wwxbyFaq7JE/2d8=; b=xnTdlwu+l1fncpV2muHEaklIiWq6S2BDbfPbdTpaSMleu0fPW90gcFUz2/cEQCNsR/ o3FHd7QHDR79JQp18qUmBTAm6kTwUC860vmLilF1Ymbzws11roAUQxKK06QH2bSlz6zD sVgF3a1ptwH47Xydr5o3jZHHGGhIT9OM8zeWqSB3g0LHajB81FiiYnEzy3Vj0/2CXJ/C 8EwmXF+YrjpRYCJxH9sG0F/gvSnZhXBfWIYYS0U0rPC6+Poo5ZUjKzY+SHGRSif9fiHO i3glqgA5PYvbs2klk8l6BdmCAZzRh3FEXiNFHJgCCuGCpaMtaZisB3Qy6YI2z8I3HyYS ypxg== X-Gm-Message-State: ANoB5pltVR8ceHhsiBTmVefqf2lG1DIH80zpCoDukSPtf7Bqj92X/EJP xijAdtnSy0O2cY8CPp0Dd9E8V4VVodOGyWCC X-Google-Smtp-Source: AA0mqf6cVDconk+NrqZYCtCxzkB8M9gK+LbspUehJ3DlRyW6zfhGopBADDFnhNtDQcH9zshOojkuWw== X-Received: by 2002:adf:e743:0:b0:242:1c58:8ea7 with SMTP id c3-20020adfe743000000b002421c588ea7mr1834127wrn.46.1670515340150; Thu, 08 Dec 2022 08:02:20 -0800 (PST) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id d18-20020adfe892000000b002425be3c9e2sm12558272wrm.60.2022.12.08.08.02.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 08:02:19 -0800 (PST) Date: Thu, 8 Dec 2022 19:02:17 +0300 From: Dan Carpenter To: Jason Gunthorpe , Yishai Hadas Cc: Shameer Kolothum , Kevin Tian , Alex Williamson , Cornelia Huck , kvm@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH 2/2] vfio/mlx5: error pointer dereference in error handling Message-ID: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email haha only kidding Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This code frees the wrong "buf" variable and results in an error pointer dereference. Fixes: 34e2f27143d1 ("vfio/mlx5: Introduce multiple loads") Signed-off-by: Dan Carpenter Reviewed-by: Yishai Hadas --- Why did get_maintainer.pl not add Yishai to the CC list? drivers/vfio/pci/mlx5/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/vfio/pci/mlx5/main.c b/drivers/vfio/pci/mlx5/main.c index 83137228352e..9feb89c6d939 100644 --- a/drivers/vfio/pci/mlx5/main.c +++ b/drivers/vfio/pci/mlx5/main.c @@ -826,7 +826,7 @@ mlx5vf_pci_resume_device_data(struct mlx5vf_pci_core_device *mvdev) spin_lock_init(&migf->list_lock); return migf; out_buf: - mlx5vf_free_data_buffer(buf); + mlx5vf_free_data_buffer(migf->buf); out_pd: mlx5vf_cmd_dealloc_pd(migf); out_free: