Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FagYu-0003Vo-CL for qemu-devel@nongnu.org; Mon, 01 May 2006 18:08:12 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FagYs-0003Up-6I for qemu-devel@nongnu.org; Mon, 01 May 2006 18:08:11 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FagYs-0003Um-2S for qemu-devel@nongnu.org; Mon, 01 May 2006 18:08:10 -0400 Received: from [212.247.155.44] (helo=swip.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FagYs-0000CW-Nu for qemu-devel@nongnu.org; Mon, 01 May 2006 18:08:11 -0400 Received: from d213-103-35-236.cust.tele2.fr ([213.103.35.236] verified) by mailfe10.swip.net (CommuniGate Pro SMTP 5.0.8) with ESMTP id 19143697 for qemu-devel@nongnu.org; Tue, 02 May 2006 00:08:07 +0200 From: Even Rouault Subject: Re: [Qemu-devel] bug report : kqemu and self-writing code Date: Tue, 2 May 2006 00:08:02 +0200 References: <200605012153.51699.even.rouault@mines-paris.org> <44567DD2.8040708@bellard.org> In-Reply-To: <44567DD2.8040708@bellard.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200605020008.04274.even.rouault@mines-paris.org> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org You're absolutely right. SELinux was enabled on the host. I disabled it and= =20 now the self modying code runs with kqemu enabled. So, I guess the current behaviour of qemu (without kqemu) is not really=20 wanted. Le Lundi 1 Mai 2006 23:29, Fabrice Bellard a =E9crit=A0: > Are you sure that the bug is really in kqemu ? It is possible that your > guest kernel implements a security system which prevents self modifying > code using segment limits which QEMU does not check (but kqemu checks > them !). > > Regards, > > Fabrice. > > Even Rouault wrote: > > Guest OS : Linux 2.6.15-1.2054_FC5 i686 (Fedora Core 5 i386) > > Host OS: Linux 2.6.12-10-amd64-k8 #1 x86_64 (Ubuntu 5.10 amd64) > > QEMU Version : today CVS compiled with kqemu support > > KQEMU : 1.3.0pre6 > > Binary used : qemu-system-x86-64 (so kqemu user-mode is used) > > > > I'm running the simple C code attached. With kqemu user-mode, this fails > > (sigsegv) with the following warning in dmesg : > > > > audit(1146505373.813:12): avc: denied { execheap } for pid=3D1860 > > comm=3D"selfmodifying scontext=3Duser_u:system_r:unconfined_t:s0 > > tcontext=3Duser_u:system_r:unconfined_t:s0 tclass=3Dprocess > > Erreur de segmentation > > > > Without kqemu enabled, it runs fine. > > > > > > > > ------------------------------------------------------------------------ > > > > #define _XOPEN_SOURCE 600 > > #include > > #include > > #include > > #include > > > > int main(int argc, char** argv) > > { > > int pagesize =3D getpagesize(); > > unsigned char* addr =3D NULL; > > posix_memalign((void**)&addr, pagesize, pagesize); > > mprotect(addr, pagesize, PROT_WRITE | PROT_READ | PROT_EXEC); > > addr[0] =3D 0x8b; addr[1] =3D 0x44; addr[2] =3D 0x24; addr[3] =3D 0x0= 4; /* mov=20 > > 0x4(%esp),%eax */ addr[4] =3D 0x83; addr[5] =3D 0xc0; addr[6] =3D 0x0= 1; /* > > add $0x1,%eax */ addr[7] =3D 0xc3; /* ret */ > > > > printf("10+1=3D%d\n", ((int (*)(int))addr)(10)); > > free(addr); > > return 0; > > } > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > Qemu-devel mailing list > > Qemu-devel@nongnu.org > > http://lists.nongnu.org/mailman/listinfo/qemu-devel > > _______________________________________________ > Qemu-devel mailing list > Qemu-devel@nongnu.org > http://lists.nongnu.org/mailman/listinfo/qemu-devel