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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:25:47+00:00 2026-05-26T06:25:47+00:00

as stated in: http://www.kernel.org/doc/htmldocs/kernel-hacking.html#routines-copy this functions can sleep. So, do I always have to

  • 0

as stated in: http://www.kernel.org/doc/htmldocs/kernel-hacking.html#routines-copy this functions “can” sleep.

So, do I always have to do a lock (e.g. with mutexes) when using this functions or are there exceptions?

I’m currently working on a module and saw some Kernel Oops at my system, but cannot reproduce them. I have a feeling they are fired because I’m currently do no locking around copy_[to/from]_user(). Maybe I’m wrong, but it smells like it has something to do with it.

I have something like:

static unsigned char user_buffer[BUFFER_SIZE];
static ssize_t mcom_write (struct file *file, const char *buf, size_t length, loff_t *offset) {
    ssize_t retval;
    size_t writeCount = (length < BUFFER_SIZE) ? length : BUFFER_SIZE;
    memset((void*)&user_buffer, 0x00, sizeof user_buffer);
    if (copy_from_user((void*)&user_buffer, buf, writeCount)) {
        retval = -EFAULT;
        return retval;
    }
    *offset += writeCount;
    retval = writeCount;        
    cleanupNewline(user_buffer);    
    dispatch(user_buffer);
    return retval;
}

Is this save to do so or do I need locking it from other accesses, while copy_from_user is running?

It’s a char device I read and write from, and if a special packet in the network is received, there can be concurrent access to this buffer.

  • 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-05-26T06:25:47+00:00Added an answer on May 26, 2026 at 6:25 am

    You need to do locking iff the kernel side data structure that you are copying to or from might go away otherwise – but it is that data structure you should be taking a lock on.

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

Sidebar

Related Questions

As stated in http://www.boutell.com/newfaq/misc/urllength.html , HTTP query string have limited length. It can be
I read the explanation of the limitation at http://www.boost.org/doc/libs/1_49_0/libs/bind/bind.html#Limitations but I don't quite understand
I'm following this example: http://www.codinghorror.com/blog/2005/12/getting-started-with-indexing-service.html However, the conversion to dataset shows empty columns for
I was reading this document: http://www.fadden.com/techmisc/hdc/lesson11.htm In it he stated: Problem is, we don't
As stated here : http://codeigniter.com/user_guide/general/cli.html A page like : http://www.example.com/myController/myFunc/myParam can be run on
I am reading this: http://www.panoramio.com/api/widget/api.html#photo-widget to build a JavaScript photo widget. Under Request ->
This web page http://www.w3schools.com/ASP/prop_sessionid.asp states that a session ID is generated on the ServerSide.
I have this page of US states: http://www.comehike.com/outdoors/country.php?country_id=1&country_name=United%20States if you click on any link
From HopStop's documentation: http://www.hopstop.com/developer/?action=documentation#6.1.3 for the GetRoute function, it is stated that instead of
As stated in this question , single quotes in html has either become more

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.