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 9251615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:44:50+00:00 2026-06-18T10:44:50+00:00

This is my lab assignment: I am a beginner in kernel space. I did

  • 0

This is my lab assignment: I am a beginner in kernel space.

I did a simple system call implementation and it works as expected. But, I wanted to go a level further and look into giving incorrect data to my system call and see if it handles it.

For eg., I used access_ok in my system call. I really want to pass a invalid user space pointer and see if I used the access_ok appropriately inside my system call.

How to do this? I saw that, access_ok will fail if I pass kernel space pointer. But how do I write a driver program to do this?

  • 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-18T10:44:51+00:00Added an answer on June 18, 2026 at 10:44 am

    As you are trying to pass an invalid user space pointer to the macro access_ok(type,addr,size);.

    so it just checks that the provided pointer is not in kernel-space area if it’s in kernel-space memory then will return zero(0) else it will return true so in this way you can check your desired result.. And if you are providing any address outside kernel-memory may be accepted(its possible that the provided address is not it the address-space of the process which is calling this system call in this case the type provided as VERIFY_READ or VERIFY_WRITE will decide what to do).

    From man page of access_ok() refer to http://mirror.linux.org.au/linux-mandocs/2.6.12.6/access_ok.html. Note that, depending on architecture, this function probably just checks that the pointer is in the user space range – after calling this function, memory access functions may still return -EFAULT

    If you want to pass the pointer to the kernel then you can do it as
    1-> define one structure which will contain pointer address.
    2-> add the same structure in your kernel module or driver. So the kernel & user know about the structure.
    3-> Add one parameter in your system call as char __user var.
    4-> create one structure variable in your user space of the defined structure & pass it in the system call as you call in your user-space application.
    5-> Inside kernel-module or driver where the code is defined for your system-call, create a structure variable of the same structure as you used in user-space. And now do what-ever you want.

    `

    struct new_struct
    {
       void *p;  //set this pointer which you want to send...
    };
        //from user-application...
    
        int main()
        {
           ....
           struct new_struct req_kernel;
           your_system_call_function(...,(void *)&req_kernel,...);
        }
    
        //this is inside your kernel...
             your_system_call(...,char __user optval,...)
             {
                    .....
                    struct new_struct req;
                    if (copy_from_user(&req, optval, sizeof(req)))
    
                    return -EFAULT;
                    //now you have the address or pointer which you want in kernel with struct req...
            }
    

    `

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

Sidebar

Related Questions

I am having trouble with this simple loop for a uni lab. It wont
This is a lab assignment I am stuck on. I need to accept this
This is part of a lab assignment I have to implement the following function...
I'm doing this very basic and simple Swing tutorial as the first assignment from
I have this program which worked find in my college lab, but when I
In a C lab this uber simple code appears: #include <stdio.h> int suma (int
My professor posted this online for a lab this week, but I missed the
I am completing a lab assignment for school and get this error when I
I try this query in mysql and it works fine but the Query took
This is for a homework assignment, so I don't want the exact code, but

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.