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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:46:42+00:00 2026-05-29T15:46:42+00:00

purpose:i want to limit the times that a task can make syscall. so,i add

  • 0

purpose:i want to limit the times that a task can make syscall.
so,i add a variable,noexec_count,in the task_struct in the file:
include/linux/sched.h,like:

int exec_count;/*inserted by KaiwingHo line:861*/

by the way,exec_count’s default value is -1,it means there will no limit for the syscall.And when i set a postive integer,it means how many times a task can make the syscall.And 0 means the syscall will never been made by a task.

From above,u know,i should set the default value,-1,to the every task’s exec_count.
And i do this,in the file,kernel/fork.c:
method copy_process():

p->pid = pid;
    p->exec_count=-1;/*line:929inserted by KaiwingHo;the value of noexec shows how many times one task can be called
    by method exec();default value is -1;and so on*/
    retval = -EFAULT;

And as i know,every syscall will finally comes to the method,do_execve() in the file,fs/exec.c.So,i add the following in this method,like:

/**
 * inserted by KaiwiiHo
 * the usage of the noexec is shown in sched.h line:695
 */
if(!current->exec_count)
goto out_ret;
if(current->exec_count > 0)
current->exec_count--;

And finally i add my own syscall,like:
/**
* inserted by KaiwiiHo
* set the value of the task’s noexec
*
*/

asmlinkage long sys_noexec(int times)
{
    int ret=current->exec_count;
    if(ret>=-1)
    current->exec_count=times;
    return ret;
}

Everything,like recompile and also reboot,runs ok.
So,i take a test,like:

#include <stdio.h>
#include <sys/types.h>
#include <linux/unistd.h>
#include </usr/include/errno.h>

#define __NR_noexec 294

_syscall1(long,noexec,int,times);

int main()
{
    int ret;
    ret=noexec(0);
    printf("exec_count=%d\n",ret);
    int pid;
    pid=fork();
    if(pid>0)
    {
        int val;
        val=noexec(0);
        printf("val:noexec=%d.\n",val);
        int i;
        i=5;

        if(i=fork()>0)
            printf("i can fork()!\n");

    }

    return 0;
}

And the output is:

exec_count=-1
exec_count=-1
val:noexec=0.
exec_count=-1
val:noexec=0.
i can fork()!

According the output,i think that the syscall,noexec() definitely take effects.And the task’s exec_count has been revised.But,the fork()can also been called.So i wonder that i can not limit the time.And i wonder whether what i add in the do_exeve() method does not take effect.
Anyone can show me why?thx

  • 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-29T15:46:43+00:00Added an answer on May 29, 2026 at 3:46 pm

    And as I know,every syscall will finally comes to the method
    do_execve() in the file fs/exec.c.

    This is incorrect.

    Only the execve() syscall ends up here.

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

Sidebar

Related Questions

I want to make a mysql union search. My purpose is: my total results
Just for the trial purpose i want to make an app for my iphone/iPad
I am building a custom web panel control for specific purpose.I want the control
I want to create a purpose built device capable of running a java vm
For performance purposes I want to write to memory, where an external application can
I want to write a long running process (linux daemon) that serves two purposes:
Purpose: I plan to Create a XML file with XmlTextWriter and Modify/Update some Existing
I am developing a Qt application that can play the videos and shows some
I want to build an application that will allow the user to upload a
I am working on an SMS Sending application and for login purpose i want

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.