Re: Unsized Arrays in Structures, and user space



First it is a security hole, second how do you know when it is time to
unmap? For instance what happens if the application crashes, you will not
get a notification yet you have a lot of memory reservered. Also, once you
have data you still need to tell the application, with the buffers passed in
by an IOCTL for instance this is part of the completion.

Basically, the Windows model assumes the application passes them in, yes you
can do it another way, but you are likely to be creating more problems than
you solve.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply




"Hesham Desouky" <hesham> wrote in message
news:udA448IAGHA.356@xxxxxxxxxxxxxxxxxxxxxxx
> just for knowledge,
> why mapping to user space is a bad idea?
> "Don Burn" <burn@xxxxxxxxxxxxxxxx> wrote in message
> news:ODXqGg$$FHA.272@xxxxxxxxxxxxxxxxxxxxxxx
>> Well if you possibly can have the application pass the buffers in and
>> have
>> the driver lock them down.
>>
>>
>> --
>> Don Burn (MVP, Windows DDK)
>> Windows 2k/XP/2k3 Filesystem and Driver Consulting
>> Remove StopSpam from the email to reply
>>
>>
>>
>> "Hesham Desouky" <hesham> wrote in message
>> news:uP60oa$$FHA.292@xxxxxxxxxxxxxxxxxxxxxxx
>> > Thanks for reply
>> >
>> > I am using Compuware Driverworks for driver development and it is c++.
>> >
>> > Anyhow, what are you suggesting for sharing memory between the driver
> and
>> > the application?
>> >
>> > The driver needs to allocate large amount of locked memory to stream
> high
>> > rate data from hardware device. So what mechanism you sugges?
>> >
>> > Sorry for double post
>> >
>> > Thanks
>> >
>> > "Don Burn" <burn@xxxxxxxxxxxxxxxx> wrote in message
>> > news:uT994W$$FHA.3872@xxxxxxxxxxxxxxxxxxxxxxx
>> >> Well first mapping anything to user space that was allocated in the
>> >> kernel
>> >> is a bad idea. Second, mapping ps does not map memory it points to.
>> > Third,
>> >> asking the level of questions you are, I would not recomend C++ in the
>> >> kernel.
>> >>
>> >>
>> >> --
>> >> Don Burn (MVP, Windows DDK)
>> >> Windows 2k/XP/2k3 Filesystem and Driver Consulting
>> >> Remove StopSpam from the email to reply
>> >>
>> >>
>> >>
>> >>
>> >> "Hesham Desouky" <hesham> wrote in message
>> >> news:uuNWSS$$FHA.3392@xxxxxxxxxxxxxxxxxxxxxxx
>> >> > Hello all
>> >> > I have the following:
>> >> >
>> >> > struct mystruct
>> >> > {
>> >> > int a;
>> >> > UCHAR d[];
>> >> > };
>> >> >
>> >> > this structure is allocated in the driver from the heap with the
>> > following
>> >> > code:
>> >> >
>> >> > PUCHAR p = new(NonPagedPool)UCHAR[sizeof(s) + 512];
>> >> >
>> >> > mystruct* ps = (mystruct*)ps;
>> >> > so now ps->d points to 512 bytes;
>> >> >
>> >> > If I mapped the ps structure to the user space, is d will have the
>> > coorect
>> >> > mapped use space address to point to the allocated memory?
>> >> >
>> >> > Thanks for support
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>


.



Relevant Pages

  • Re: IRP_MJ_READ/IRP_MJ_WRITE
    ... I hope you did not put the scenario in a production driver. ... Don Burn (MVP, Windows DDK) ... Neither IO means that you touch user mode memory from kernel ...
    (microsoft.public.development.device.drivers)
  • Re: How to verify a user space pointer passed to kernel driver?
    ... and then the turkey tries to use the memory and it blows up. ... ProbeForRead/Write does not protect the driver, ... Don Burn (MVP, Windows DDK) ... Windows Filesystem and Driver Consulting ...
    (microsoft.public.development.device.drivers)
  • Re: can this be my drivers bug
    ... It absolutely can, someone has trashed a kernel stack, probably your driver. ... Don Burn (MVP, Windows DDK) ... > Invalid system memory was referenced. ...
    (microsoft.public.development.device.drivers)
  • Re: about driver architecture.
    ... Don Burn (MVP, Windows DDK) ... Windows 2k/XP/2k3 Filesystem and Driver Consulting ... Remove StopSpam to reply ... but I gonna have a try to go KMDF. ...
    (microsoft.public.development.device.drivers)
  • Re: need a strategy for communication.
    ... Don Burn (MVP, Windows DDK) ... Windows 2k/XP/2k3 Filesystem and Driver Consulting ... > Once my driver and a user mode app get set up I would like the Kernel mode ... > Can I get my driver and the user to share memory? ...
    (microsoft.public.development.device.drivers)

Loading