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

  • Home
  • SEARCH
  • 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 7519015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:50:04+00:00 2026-05-30T01:50:04+00:00

I am trying to write a /proc file created by a loadable kernel module.

  • 0

I am trying to write a /proc file created by a loadable kernel module. I am using fopen() to open the file for write but am getting errno : 13 (permission denied).

FILE *fp;
fp = fopen("/proc/file1","w");
if(fp == NULL){
     printf("Errno : %d",errno); // prints 13
}

The LKM contains the following code:

static struct proc_dir_entry *proc_entry;

static ssize_t proc_write(struct file *filp, const char __user *buff, unsigned long len, void *data)
{  
    // code writes from buffer to local variable

    return len;
}

static ssize_t proc_read(char *page, char **start, off_t off, int count, int *eof, void *data)
{
    // code for reading file

    return 0;
}


int proc_open(struct inode *inode, struct file *file)
{
    try_module_get(THIS_MODULE);
    return 0;
}

int proc_close(struct inode *inode, struct file *file)
{
    module_put(THIS_MODULE);
    return 0;
}

Any suggestions on how to overcome this?

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-05-30T01:50:05+00:00Added an answer on May 30, 2026 at 1:50 am

    The most probable answer is that the procfs node that is created does not have the correct permissions for the user.

    When run as root, it bypasses most of the permission checking for the node, so you do not receive an error (there are exceptions; this is the general case).

    in the kernel loadable module, where it creates the procfs node (somewhere in the .c file):

    create_proc_entry(...)
    

    You need to make sure that the second parameter, the mode is set to something that permits opening for writing by users other than root in order to support your desired open option; e.g. 0666 makes the file globally openable as R/W by anyone.

    Generally, nodes in procfs are created with the flags 0444 (i.e. R/O only for all users). Some are created in mode 0644 (R/W by root, R/O for all other users), some are created with permissions 0400 (R/O for root, all others stay away).

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

Sidebar

Related Questions

So I'm trying to write a kernel module that uses the linux/timer.h file. I
I' trying to write an xml file from Excel VBA using Microsoft XML 6.0.
Trying to write a couple of functions that will encrypt or decrypt a file
Im trying to write a single byte at a certain location in a file.
I have a stored proc I am trying to write , where I want
I'm currently trying to create a kernel module that will produce data based on
I'm trying to run an external problem from C# by using Process.Start, but am
I'm trying to get a user-level program to communicate with the kernel via /proc.
I need to write some kernel module for my university classes and now I'm
I'm trying to mmap a file, and it seems to succeed but when I

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.