From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 76F54A0C47; Wed, 27 Oct 2021 16:49:21 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5C93D40E0F; Wed, 27 Oct 2021 16:49:21 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id D6DEC407FF for ; Wed, 27 Oct 2021 16:49:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635346159; 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=hThd4hXXkC/Dn5uLJidPP1ngnhCKHmsKej+tHDn1cvU=; b=ZcYpnKFB2lOE8FlCR4xoZeeIOIED3LG3lSj9pqByYQJ/wCM1gREHw85KXIhPy9tWhNciC4 iAy7ibmzTbYprQnUmWms1rVV+WVFh5KOSrm5e3blYWZ6X67vbIwfDejt7+Y/S88o9S3rJ5 O40IPEXVZy1X0RoXYCBj2lGO0OMVaoM= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-250-aSgPn0-_PaS1vHusBiWCUQ-1; Wed, 27 Oct 2021 10:49:18 -0400 X-MC-Unique: aSgPn0-_PaS1vHusBiWCUQ-1 Received: by mail-lf1-f72.google.com with SMTP id bq29-20020a056512151d00b003ffce2467adso1527608lfb.3 for ; Wed, 27 Oct 2021 07:49:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hThd4hXXkC/Dn5uLJidPP1ngnhCKHmsKej+tHDn1cvU=; b=byXaXnZxTaqFIjW3qwqQ4YedjhWKtLfC8ABjVXrfoE9a7OSpTV9sxv80tU1VmgYKFm d9SePFC4X+p6KD/d+X8LlCOmUWh5J1G49FbVPqY5yULbLB3TPJaje1EK5faQPSXvN3XA /OsgCb5peCZ/fHQ4f7MfYyrg9szdEgQJ5dLSWla4si81+j4+XQgogrwDGd0D8sw6uPUd AiXLYhqaRVKVERCxj6fcGYVGpKtSIILFeRHJF/eO2m3q1sE3d7a7Il63V5rnwDlmxW6+ i/mLKFKkv6DyBLfsJMkkwYBb6CBN/WRk2FZW+Z9s0L+NkgF0QSUjplaowHUf4G+qeTqU BITA== X-Gm-Message-State: AOAM5327YERGNlYgQe22LDiRIMjMaKrD9G4KrvxsTuzDk3K62lMsH+bS n4uiziTyOnaROc5XjeW0Mjb/TIX+X4mgYKJbQFsKTo9IyrAKG8XeuApvBn6BfN71SXG6HamNZAl VeTLaqYmQH98AybmXXGM= X-Received: by 2002:a05:6512:3f28:: with SMTP id y40mr29972604lfa.499.1635346156545; Wed, 27 Oct 2021 07:49:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoAuHv5glfo5BNA331iro18We1nIRRLrcMrmoIe7vKGd7oh5VanSteF1y+ytQ104t8Dx19PzH7sezOFzZcccg= X-Received: by 2002:a05:6512:3f28:: with SMTP id y40mr29972573lfa.499.1635346156304; Wed, 27 Oct 2021 07:49:16 -0700 (PDT) MIME-Version: 1.0 References: <8079312ba39435a0ac92e084cc1a3fe291008a47.1635254797.git.anatoly.burakov@intel.com> In-Reply-To: <8079312ba39435a0ac92e084cc1a3fe291008a47.1635254797.git.anatoly.burakov@intel.com> From: David Marchand Date: Wed, 27 Oct 2021 16:49:05 +0200 Message-ID: To: Anatoly Burakov , Xuan Ding Cc: dev , Maxime Coquelin Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH v1 1/1] vfio: fix partial unmap check X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Tue, Oct 26, 2021 at 3:30 PM Anatoly Burakov wrote: > > Partial unmap support was introduced in commit c13ca4e81cac, and with it > was added a check that dereferenced the IOMMU type to determine whether > partial ummapping is supported for currently configured IOMMU type. In > certain circumstances (such as when VFIO is supported, but no devices > were bound to the VFIO driver), the IOMMU type pointer can be NULL. > > However, dereferencing of IOMMU type was guarded by access to the user > maps list - that is, we were always checking the user map list first, > and then, if we found a memory region that encloses the one we're trying > to unmap, we would have performed the IOMMU type check. > > This ensured that the IOMMU type check will not cause any NULL pointer > dereferences, because in order for an IOMMU type check to have been > performed, there necessarily must have been at least one memory region > that was previously mapped successfully, and that implies having a > defined IOMMU type. > > When 56259f7fc010 was introduced, the IOMMU type check was moved to > before we were traversing the user mem maps list, thereby introducing a > potential NULL dereference, because the IOMMU type access was no longer > guarded by the user mem maps list traversal. > > Fix the issue by moving the IOMMU type check to after the user mem maps > traversal, thereby ensuring that by the time the check happens, the > IOMMU type is always valid. > > Fixes: 56259f7fc010 ("vfio: allow partially unmapping adjacent memory") > Cc: xuan.ding@intel.com > > Signed-off-by: Anatoly Burakov Reviewed-by: David Marchand I guess Xuan tested it too, since we have a vhost patch on top of this vfio patch. Can you just confirm it is ok to merge? Thanks. -- David Marchand