[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <46DD30CC.4060907@aitel.hist.no>
Date: Tue, 04 Sep 2007 12:17:48 +0200
From: Helge Hafting <helge.hafting@...el.hist.no>
To: Clemens Kolbitsch <clemens.kol@....at>
CC: Valdis.Kletnieks@...edu, linux-kernel@...r.kernel.org
Subject: Re: Forbid deletion of memory mappings
Clemens Kolbitsch wrote:
> On Thursday 30 August 2007 23:50:21 Valdis.Kletnieks@...edu wrote:
>
>> On Thu, 30 Aug 2007 23:41:09 +0200, Clemens Kolbitsch said:
>>
>>> On Thursday 30 August 2007 23:34:52 you wrote:
>>>
>>>> On Thu, 30 Aug 2007, Clemens Kolbitsch wrote:
>>>>
>>>>> is there no way to tell the kernel, that a certain mapping must not
>>>>> be removed, no matter what (except of course an explicit call to
>>>>> sys_unmap, of course)?
>>>>>
>>>> I don't seem to get what is the issue here. Your mapping is not
>>>> removed, only the VMAs are merged together into one larger VMA if they
>>>> have neighbouring address ranges and compatible protection bits. See
>>>> vma_merge().
>>>>
>>> the thing is that they are not. the kernel chooses to REPLACE my mapping.
>>>
>>> consider the user-space code:
>>>
>>> mmap(0xaaaa0000, 0x3000, MAP_FIXED, ...);
>>> mmap(0xaaaa1000, 0x4000, MAP_FIXED, ...);
>>>
>>> here, the second call to mmap will shorten the first mapping to 0x1000
>>> bytes and create one big vma with size 0x5000 bytes.
>>>
>>> is there a way to tell it that the second mmap MUST fail?
>>>
>> There's an LSM exit point for mmap, you could perhaps do something there.
>>
>> What are you trying to achieve by forcing the second one to fail?
>>
>
> puh... that is a good question :-)
>
> I'm writing my master's thesis on a new model of memory protection and need to
> have every memory mapping in userspace duplicated. I also have kind of a
> second PGD/PTD that allows finding this mirrored mapping.
>
> However, as the number of original mappings grows, I suddenly have the problem
> that the kernel tries to allocate a new mapping and picks the address of a
> mirrored memory page, which it shouldn't.
>
> Honestly, I don't understand why it does so,
The "why" is easy: Having many mappings is expensive,
so merging them (when this cause no problems) is
a smart thing to do. So that is what linux does.
It means fewer mappings to keep track of. Less resources in
use means that linux moves faster.
If you are doing research, consider these methods:
1. Change vma_merge() so it always fail to merge mappings
or
2. Set up your "mappings duplicated in userspace" so
they too merge in the same way.
Helge Hafting
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists