- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: accessing user address in a kernel driver
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2011 03:05 AM
тАО05-06-2011 03:05 AM
accessing user address in a kernel driver
xxxioctl(dev_t device, int cmd, caddr_t arg, int flags);
Inside of this routine, is there a way to find out the userspace address of the ioctl argument that the calling (userspace) program would have passed to the "ioctl" function in userspace?
I know that for fixed size ioctl args, HP-UX internally does a copyin of the arg before calling the driver routine, and does a copyout after wards. Is there a way to handle variable sized args, e.g.:
struct arg_2_some_ioctl {
unisgned int num_entries;
unsigned char entry[1];
}
Can we use the above declaration & still have an ioctl that can use the entry array in a way that the length is provided by num_entries?
Regards,
Tarun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2011 05:41 AM
тАО05-06-2011 05:41 AM
Re: accessing user address in a kernel driver
Could you expand on this comment please?
"..The prototype of the ioctl routine a device driver registers with HP-UX is:..."
Question: Are you rewriting the Hpux kernel device driver?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2011 05:53 AM
тАО05-06-2011 05:53 AM
Re: accessing user address in a kernel driver
declare it as _IO('z',x)
where z and x are youre values
if you declare it as _IO the 3rd ioctl param will be passed to your driver ioctl directly.
toto_ioctl(dev_t dev, int command, caddr_t * data, int flags)
u.u_error = copyin( *data, buffer, size);
will copy the user buffer pointed by the 3rd param of ioctl.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2011 12:19 AM
тАО05-07-2011 12:19 AM
Re: accessing user address in a kernel driver
You need a search engine that understands wildcards?
>Are you rewriting the HP-UX kernel device driver?
Exactly, Tarun should have mentioned this.
I know what he was asking but not the details that Laurent provided.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-08-2011 01:40 AM
тАО05-08-2011 01:40 AM
Re: accessing user address in a kernel driver
toto_ioctl(dev_t dev, int command, caddr_t * data, int flags)
{
unsigned int numentries;
struct targer *buffer;
u.u_error = copyin( *data, &numentries, sizeof(numentries));
////: test error cases , numentries limit val uerrors ....
allocate your buffer
u.u_error =copyin(*data+sizeof(numentries), buffer,numentries*sizeofentries);
Just a remark, if there are any elements in your entries which alignement is larger than 4 bytes ( like double, long long ...)
you may have padding in the structure.
Also think that the ioctl can be called by a 32 bit application or a 64bit application an that the kernel is always 64bits
so if there are "long" or size_t or any type which is based on "long", the structure will not be the same in the user space and in the kernel space.