From: Heiko Carstens Subject: Re: [patch 10/12] [PATCH] kvm-s390: storage key interface Date: Thu, 15 Dec 2011 17:11:06 +0100 Message-ID: <20111215161106.GA2742@osiris.boeblingen.de.ibm.com> References: <20111214122347.275452567@de.ibm.com> <20111214123127.030416104@de.ibm.com> <4EE9CBB3.3000707@de.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Avi Kivity , Marcelo Tossati , borntrae@linux.vnet.ibm.com, heicars2@linux.vnet.ibm.com, mschwid2@linux.vnet.ibm.com, huckc@linux.vnet.ibm.com, KVM , Joachim von Buttlar , Jens Freimann , agraf@suse.de To: Carsten Otte Return-path: Received: from e06smtp18.uk.ibm.com ([195.75.94.114]:42952 "EHLO e06smtp18.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753769Ab1LOQLn (ORCPT ); Thu, 15 Dec 2011 11:11:43 -0500 Received: from /spool/local by e06smtp18.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 15 Dec 2011 16:11:40 -0000 Received: from d06av03.portsmouth.uk.ibm.com (d06av03.portsmouth.uk.ibm.com [9.149.37.213]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pBFGB7qo2752608 for ; Thu, 15 Dec 2011 16:11:07 GMT Received: from d06av03.portsmouth.uk.ibm.com (localhost.localdomain [127.0.0.1]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pBFGB6If029032 for ; Thu, 15 Dec 2011 09:11:07 -0700 Content-Disposition: inline In-Reply-To: <4EE9CBB3.3000707@de.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: On Thu, Dec 15, 2011 at 11:28:03AM +0100, Carsten Otte wrote: > New version below. Changes: > - __pmdp_for_addr and ptep_for_addr now take a vma as argument > - check if a vma exists has moved to gmap_fault and kvm_s390_keyop > - kvm_s390_keyop verifies that a vma is writable so that it's safe to > set the SWC bit oh.. cool. [...] > + spin_lock(¤t->mm->page_table_lock); > + pgste = pgste_get_lock(ptep); > + > + switch (kop->operation) { > + case KVM_S390_KEYOP_SSKE: > + if (!(vma->vm_flags & (VM_WRITE | VM_MAYWRITE))) { > + r = -EACCES; > + break; > + } Why again is this needed? Or put in other words: what prevents a guest to change the storage key contents via sske of a page that is mapped read-only into the guest address space? As far as I can see: nothing. Interestingly I could -in theory- do some nice stuff like: - map a file from a read-only filesystem (which doesn't have a writepage aops function) into guest address space - let the guest set the change bit in the storage key of a page that belongs to that file mapping via sske - watch the fun that happens when the host tries to write the page back But of course I could be totally wrong ;) This doesn't have to do anything with your patch, it's just that I think you shouldn't check if the vma is writable or not. It doesn't matter.