Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7953483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:10:13+00:00 2026-06-04T03:10:13+00:00

I have a device driver that allows a user-space app to perform various operations

  • 0

I have a device driver that allows a user-space app to perform various operations using the ioctl mechanism. Returned as part of an initial ioctl call is a handle that is supposed to be opaque to the user-space app which the app provides in other ioctl calls.

Internally in the driver, the handle is the address of some control/context block in kernel space. If the app could be trusted to pass back faithfully the handle returned, all is well. Concern is what if the app is malicious and passes back some aribitrary handle which the driver then casts to appropriate pointer type and de-references it.

One sanity check I was thinking of is to compare with PAGE_OFFSET and reject if less than (to ensure address at-least points to kernel memory). What if it page faults which I believe is not legal in kernel space? A simple scheme could be to check whether the handle was previously returned to user-space but overhead to search could be high (since there can be a lot of these handles).

Is there a robust and efficient way to validate the handle? Any help is appreciated.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:10:14+00:00Added an answer on June 4, 2026 at 3:10 am

    Never accept a pointer from an untrusted program.
    There’s no end to the attacks this enables, on your code and on other (e.g. using you to peek into memory the process must not access).

    There are ways to do validate it, but they’re complicated or expensive. For example:
    1. Place all the handles in a single array. Verify that the pointer is within the array, and properly aligned. But then you could use the array index as handle.
    2. Scan your handle database and compare pointers to the one given from the user. Don’t dereference the handle until you find it in the database. But again, using some ID for the lookup, instead of the pointer, can simplify it.

    There are more things you may need to validate:
    1. As Alex commented, if there are several possible handle types, verify that you get the right type (i.e. prevent h = get_handle_typeA(); use_handle_typeB(h)).
    2. Make sure each process uses only handles it created. So a process won’t be able to guess handle values and hope to catch a valid one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have intensive processing that I need to perform in a device driver, at
i have to make a device driver that returns a random number between 1
I have noticed that when I call lseek64 on my block device driver file
I have a Linux device driver that interfaces to a device that, in theory,
I have a device driver that uses the following algorithm to convert a value
I've set up a user agent using WebDriver and a FireFox Driver. I have
I created the list that have device detected, and I want to send data
I have a device on a network that I am attempting to ping through
We have a device that uses Exchange web services to download mail and calendar
I have a device that sends data to COM port. And I'd like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.