From: David Gibson Date: Tue, 05 Jun 2018 02:18:55 +0000 Subject: Re: [PATCH kernel v2 3/3] KVM: PPC: Check KVM_CREATE_SPAPR_TCE_64 parameters Message-Id: <20180605021855.GN5140@umbus.fritz.box> MIME-Version: 1 Content-Type: multipart/mixed; boundary="7fwXp2o0gOrkU5lS" List-Id: References: <20180514100029.32910-4-aik@ozlabs.ru> In-Reply-To: <20180514100029.32910-4-aik@ozlabs.ru> To: kvm-ppc@vger.kernel.org --7fwXp2o0gOrkU5lS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, May 14, 2018 at 08:00:29PM +1000, Alexey Kardashevskiy wrote: > Although it does not seem possible to break the host by passing bad > parameters when creating a TCE table in KVM, it is still better to get > an early clear indication of that than debugging weird effect this might > bring. >=20 > This adds some sanity checks that the page size is 4KB..16GB as this is > what the actual LoPAPR supports and that the window actually fits 64bit > space. >=20 > Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson > --- > arch/powerpc/kvm/book3s_64_vio.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) >=20 > diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/powerpc/kvm/book3s_6= 4_vio.c > index 984f197..80ead38 100644 > --- a/arch/powerpc/kvm/book3s_64_vio.c > +++ b/arch/powerpc/kvm/book3s_64_vio.c > @@ -300,7 +300,8 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm, > int ret =3D -ENOMEM; > int i; > =20 > - if (!args->size) > + if (!args->size || args->page_shift < 12 || args->page_shift > 34 || > + (args->offset + args->size > (ULLONG_MAX >> args->page_shift))) > return -EINVAL; > =20 > size =3D _ALIGN_UP(args->size, PAGE_SIZE >> 3); --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --7fwXp2o0gOrkU5lS Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAlsV8wwACgkQbDjKyiDZ s5I0oBAArkIDlg8ZltD0nLe5ACt0D5z2AmtI8kTaFQw4zi0kGt8wSFM3qAJ3AJYx ybc9MfFd5MaVi2wJkOczrjAwpmgQCW1BbZh3kpqp0yPmd/BuDE3VFPB8Do9U0q1i XOcqzRdpDrRoLTPzTj/oUPgB93sPQPtvGr/bwDGtNNz484Nv6mMF3qGRjwYJs8Jz r88p7Hs+AJiqJOAM53TxVlYB/khWN3FQ7nEJGAxVtqavtEhTJJ38SR8GI+jzyZWt kaHMEvF3uAprvZoh3hihW7D19txGK0iDow7r9wQWM6dESDq3vuERWTF4EHKuvS5X yx8Iz6BpuRo5UfnrnrWXQIBqtVWzzMF81koc2tK5jesd+SQOv3aEO2cfaYf9zxnx SYsVuQJTvOKjqJDQvu93j2I3i67zMt3Gc/Cr/xGTPbEyBhrZMugGx/j05/IYOfEU /QX+j8uf8FkX2vWbwoeIN+cIULINGW5zaXd9+y3MkxT9H2SaL2k9koLfqbZUjCcm GnxpYdOtKoF+Bkzu/2LuMl3U3nuXscMHwYL9ebMQ0kKWnd6dXul/wikKDg+rcxWD UkFudQPht9P9geEieJsrGjD9/QML1Zsgc1oyDQrwTpa7wA20r4gFcP5/k9dkPAtS /541YuzO9zwr99VfKbXIUhLhq0xhuWVJZRiGGt3A+WEtLQz2duA= =NiI4 -----END PGP SIGNATURE----- --7fwXp2o0gOrkU5lS--