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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:12:51+00:00 2026-06-03T10:12:51+00:00

I am reading the Linux kernel code for copy_fom_user, which is architecture dependent and

  • 0

I am reading the Linux kernel code for copy_fom_user, which is architecture dependent and I focus on x86 architectures.

But I got two pieces of implementation for it.

One is here (in arch/x86/lib/usercopy_32.c), while the other is here (in include/asm-generic/uaccess.h).

Which one will be finally compiled into the kernel. I guess the former is the real one, but I am not sure. What is more strange is that the former has the function name _copy_from_user instead of copy_from_user

I always have this kind of confusions when reading the kernel code. For example, due to the conditional compiling, the same function may have multiple implementation and I cannot determine which one will be used in general. Is there any tool that, given a complied kernel and a function of interest, tells you the corresponding binary code, so that you can disassemble it? Or it would be even better if it can tell you the source code that the binary code corresponds to.

  • 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-03T10:12:52+00:00Added an answer on June 3, 2026 at 10:12 am

    Generally, if there is a module present in the architecture-specific subdirectory, that is the one being used. Otherwise, the generic one is it.

    For the modules given, the .c is the correct one. Rarely is there any executable code in a .h. I have 2.6.27.8’s uaccess.h handy:

    #ifndef _ASM_GENERIC_UACCESS_H_
    #define _ASM_GENERIC_UACCESS_H_
    
    /*
     * This macro should be used instead of __get_user() when accessing
     * values at locations that are not known to be aligned.
     */
    #define __get_user_unaligned(x, ptr)                                    \
    ({                                                                      \
            __typeof__ (*(ptr)) __x;                                        \
            __copy_from_user(&__x, (ptr), sizeof(*(ptr))) ? -EFAULT : 0;    \
            (x) = __x;                                                      \
    })
    
    
    /*
     * This macro should be used instead of __put_user() when accessing
     * values at locations that are not known to be aligned.
     */
    #define __put_user_unaligned(x, ptr)                                    \
    ({                                                                      \
            __typeof__ (*(ptr)) __x = (x);                                  \
            __copy_to_user((ptr), &__x, sizeof(*(ptr))) ? -EFAULT : 0;      \
    })
    
    #endif /* _ASM_GENERIC_UACCESS_H */
    

    Look at that carefully. These are macro wrappers to call the underlying __copy_from_user() and __copy_to_user() functions, which are implemented differently on each architecture.

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

Sidebar

Related Questions

I'm reading Understanding Linux Kernel. Paging for 64-bit Architectures As we have seen in
I was just reading The Linux Kernel Module Programming Guide and and got stuck
I've been reading up on Linux's "swappiness" tuneable, which controls how aggressive the kernel
Okay, I'm reading about Linux kernel development and there are some code snippets using
I'm reading linux kernel code and I encounter something like the following: typedef void
I've been reading through the Linux kernel (specifically, 2.6.11). I came across the following
I'm learning the Linux kernel and reading the book The Linux Kernel . Can
I'm reading Understanding Linux Kernel. This is the snippet that explains how Linux uses
I've encoutered these to instructions IN & OUT while reading Understanding Linux Kernel book.
A program is massively reading from the disk but I don't know which file

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.