Re: [PATCH 3/4] add ksm kernel shared memory driver

Izik Eidus
2008-11-11T22:38:57Z

Jonathan Corbet wrote:
> [Let's see if I can get through the rest without premature sends...]
>
> On Wed, 12 Nov 2008 00:17:39 +0200
> Izik Eidus <ieidus@redhat.com> wrote:
>
>
>>> Actually, it occurs to me that there's no sanity checks on any of
>>> the values passed in by ioctl(). What happens if the user tells
>>> KSM to scan a bogus range of memory?
>>>
>>>
>> Well get_user_pages() run in context of the process, therefore it
>> should fail in "bogus range of memory"
>>
>
> But it will fail in a totally silent and mysterious way. Doesn't it
> seem better to verify the values when you can return a meaningful error
> code to the caller?
>
>

Well I dont mind insert it (the above for sure is not a bug)
but even with that, the user can still free the memory that he gave to us
so this check if "nice to have check", we have nothing to do but to relay on
get_user_pages return value :)

> The other ioctl() calls have the same issue; you can start the thread
> with nonsensical values for the number of pages to scan and the sleep
> time.
>

well about this i agree, here it make alot of logic to check the values!