Gentoo Logo
Gentoo Spaceship

Installation:
Gentoo Handbook
Installation Docs

Documentation:
Home
Listing
About Gentoo
Philosophy
Social Contract

Resources:
Bug Tracker
Developer List
Discussion Forums
Gentoo BitTorrents
Gentoo Linux Enhancement Proposals
IRC Channels
Mailing Lists
Mirrors
Name and Logo Guidelines
Online Package Database
Security Announcements
Staffing Needs
Supporting Vendors
View our CVS

Graphics:
Logos and themes
Icons
ScreenShots

Miscellaneous Resources:
Gentoo Linux Store
Gentoo-hosted projects
IBM dW/Intel article archive




List Archive: gentoo-hardened
Navigation:
Lists: gentoo-hardened: < Prev By Thread Next > < Prev By Date Next >
Headers:
To: gentoo-hardened@g.o
From: pageexec@...
Subject: Re: grsec in qemu/kvm gives PAX: attempted to modify kernel code
Date: Thu, 05 Jul 2007 11:24:24 +0200
On 5 Jul 2007 at 10:19, Natanael Copa wrote:

> I'm tryning to run a gentoo hardened kernel as a qemu guest but PAX is
> not happy. It works fine in vmware.

'fine' is a relative word here, see below ;-).

> Any ideas how to find out what this really is?
> 
> I tried kvm-28 (with kvm-intel) and qemu-0.9 (non kvm).
[...] 
> PAX: swapper:1, uid/euid: 0/0, attempted to modify kernel code at virtual address c0551c08
>  printing eip:
> 0000e9d7

this says that the kernel wanted to write to some otherwise read-only
area (as created/enforced by KERNEXEC that the hardened kernel uses).
after some decoding of the oops code i figured that it must come from
the free_initmem() function where KERNEXEC activates the read-only
mappings for the kernel. and after a split second of reflection one
can figure out that there's indeed a bug in there in that KERNEXEC
can shoot itself in the foot so to speak.

while going through the kernel's page directory to modify the writable
entries to become read-only (covering the read-only kernel virtual
address range), it will make the page directory (swapper_p[gm]_dir)
read-only as well - even before it has modified the last needed entry
in it -> instant page fault as you reported it, but only *if* the TLBs
get flushed somehow during this short tight loop.

apparently the intercept logic in qemu/kvm does/causes this TLB flush
while vmware doesn't (or it has some extra detection logic that still
enables writes to this read-only area, not that good then as it
circumvents security, and to be honest, i've never once seen vmware
fault here for the past 4 years, so my bet is on the extra logic).

for an extra confirmation, can you post the output of

   egrep 'swapper_p|MODULES_| _data' System.map

?

in any case, thanks for the report, i'll fix it for 2.6.22.

-- 
gentoo-hardened@g.o mailing list


Replies:
Re: grsec in qemu/kvm gives PAX: attempted to modify kernel code
-- Natanael Copa
References:
grsec in qemu/kvm gives PAX: attempted to modify kernel code
-- Natanael Copa
Navigation:
Lists: gentoo-hardened: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
grsec in qemu/kvm gives PAX: attempted to modify kernel code
Next by thread:
Re: grsec in qemu/kvm gives PAX: attempted to modify kernel code
Previous by date:
grsec in qemu/kvm gives PAX: attempted to modify kernel code
Next by date:
Re: grsec in qemu/kvm gives PAX: attempted to modify kernel code


Updated Jun 17, 2009

Donate to support our development efforts.

Gentoo Centric Hosting: vr.org

VR Hosted

Tek Alchemy

Tek Alchemy

SevenL.net

SevenL.net

php|architect

php|architect

Copyright 2001-2007 Gentoo Foundation, Inc. Questions, Comments? Email www@gentoo.org.