[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] libxg: shrink variable scope in xc_core_arch_map_p2m_list_rw()


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Date: Wed, 14 Jun 2023 16:08:15 +0100
  • Authentication-results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Wed, 14 Jun 2023 15:08:37 +0000
  • Ironport-data: A9a23:7SkRsq1HYFgjQce1r/bD5fVxkn2cJEfYwER7XKvMYLTBsI5bpzEGn 2scDWuEPKqJY2OhLYp/bYiw/UgCupfdyoNjSQM4pC1hF35El5HIVI+TRqvS04F+DeWYFR46s J9OAjXkBJppJpMJjk71atANlVEliefTAOK6ULWeUsxIbVcMYD87jh5+kPIOjIdtgNyoayuAo tq3qMDEULOf82cc3lk8teTb8HuDgNyo4GlD5gJnOagS1LPjvyJ94Kw3dPnZw0TQGuG4LsbiL 87fwbew+H/u/htFIrtJRZ6iLyXm6paLVeS/oiI+t5qK23CulQRrukoPD9IOaF8/ttm8t4sZJ OOhF3CHYVxB0qXkwIzxWvTDes10FfUuFLTveRBTvSEPpqFvnrSFL/hGVSkL0YMkFulfKEVQ1 KZGdmAxci+tjtCfwKqrTrJTr5F2RCXrFNt3VnBIyDjYCbAtQIzZQrWM7thdtNsyrpkQR7CEP ZNfMGcxKk2aOHWjOX9OYH46tO6umnn4dSwesF+PrLA7y2PS0BZwwP7mN9+9ltmiHJwMwx/I+ jmcl4j/KhMaG+LY+xO6yX2TqMTymAX/ZY1VJpTto5aGh3XMnzdOWXX6T2CTo/O0l0q/UNJ3M FEP92wlqq1a3FymSJzxUgO1pFaAvwUAQJxAHusi8gaPx6HIpQGDCQAsUTppeNEg8sgsSlQC1 FCTmMjyLSdyq7DTQnWYnp+dtT6oMDIZBXMDbyQDCwAC5rHeTJob10yVCIw5Sejs04OzQGurq 9yXkMQgr5w3k+9RifvrwUz4rTuej5jRXgpu2SyCCwpJ8ThFiJ6Zi52AsAaLs6gacN7GEjFtr 1BfxZHAsblm4YWl0XXUHb5TROzBC+OtamW0vLJ5I3U2G91BEVaHdJsY3jxxLVwB3i0sKW6wO x+7Ve+8CfZu0JqWgUxfOdjZ5zwCl/SIKDgcfqm8giBySpZwbhSb2ypleFSd2Wvg+GB1z/FhZ 8fCK5r0UyZHYUiC8NZRb71EuYLHOwhknT+DLXwF50nPPUWiiI69Fu5ebQrmghER56KYugTFm +uzxOPToyizpNbWO3GNmaZKdABiEJTOLcyuwyChXrLZc1UO9aBII6O5/I7NjKQ/wv4EybqSr y7nMqKaoXKm7UD6xcyxQigLQNvSsVxX9xrX4QRE0Y6U5kUe
  • Ironport-hdrordr: A9a23:pKddOa8/9q74c86PRy1uk+Gddb1zdoMgy1knxilNoH1uA7mlfq WV95omPHDP6Ar5J0tQ5exoVJPgfZq+z+8H3WBuB8bBYOCOggLBRr2KhrGSoAEIdReOk9K03s 9bAtdD4LWbNzRHZa2R2maF+xlL+rS62ZHtvMOb60pECThtbaQI1XYKNu5YeHcGOjWvwfACZe qhDg8snUvQRZ1tVLXeOlA1G9LbosHNltbPeAduPW9f1CC+yQmw7aL8EVyywhcaXlp0sMof2F mAqRX9+qKg99ayzhO07R61071m3OH5z8dFBoirlM8YMVzX+2CVTbUkYaSGoDc25NuOxT8R4a HxiiZlBd1393TSOlu4ugTgwC7p1DpG0Q6Y9XaoxUH7pND/RnYEB9FahYRfGyGpkXYdgA==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, Jun 14, 2023 at 09:02:56AM +0200, Jan Beulich wrote:
> This in particular allows to drop a dead assignment to "ptes" from near
> the end of the function.
> 
> Coverity ID: 1532314
> Fixes: bd7a29c3d0b9 ("tools/libs/ctrl: fix xc_core_arch_map_p2m() to support 
> linear p2m table")
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> ---
> v2: Much bigger change to limit the scope of "ptes" and other variables.

The change of scope of all variables isn't too hard to review with
--word-diff option and they all look fine.

> --- a/tools/libs/guest/xg_core_x86.c
> +++ b/tools/libs/guest/xg_core_x86.c
> @@ -169,18 +169,21 @@ xc_core_arch_map_p2m_list_rw(xc_interfac
>          if ( !mfns )
>          {
>              ERROR("Cannot allocate memory for array of %u mfns", idx);
> +        out_unmap:
> +            munmap(ptes, n_pages * PAGE_SIZE);
>              goto out;
>          }
>  

I guess it's not that great to have the label out_unmap in the middle of
the for loop (at least it's near the beginning), but at least that mean
that the mapping need to be gone once out of the loop. So if someone
edit the for loop and introduce a `goto out` instead of `goto out_unmap`
there's just a potential leak rather than potential use-after-free or
double-free, so I guess that better.

So:
Acked-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>

Cheers,

-- 
Anthony PERARD



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.