首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Linux如何知道是否允许进程发出系统调用?

Linux如何知道是否允许进程发出系统调用?
EN

Unix & Linux用户
提问于 2019-02-26 13:09:07
回答 1查看 1.2K关注 0票数 0

假设某个进程希望发出只能由特权进程发出的系统调用。

Linux如何知道是否允许进程发出这样的系统调用? Linux是查看进程的fsuid (文件系统用户ID)以查看它是否是根进程,还是查看进程的功能是否具有发出系统调用所需的能力,或者Linux是否以其他方式知道?

EN

回答 1

Unix & Linux用户

发布于 2019-02-27 14:12:07

通常,内核会查看流程的功能,以确定它是否具有所需的功能。您将在相关系统调用的手册页中找到这些信息,该页面将注意到“流程需要功能CAP_XYZ”以执行操作。例如,查看kill(2)的手册页面,我们看到:

代码语言:javascript
复制
   For  a process to have permission to send a signal, it must either
   be privileged (under Linux: have the CAP_KILL  capability  in  the
   user  namespace  of  the target process), or the real or effective
   user ID of the sending process must equal the real or  saved  set-
   user-ID  of  the  target process.

类似地,在create_module(2)页面中,我们看到:

代码语言:javascript
复制
DESCRIPTION
   create_module()  attempts  to  create  a loadable module entry and
   reserve the kernel memory that will be needed to hold the  module.
   This system call requires privilege.
...
ERRORS
...
   EPERM  The   caller   was   not   privileged  (did  not  have  the
          CAP_SYS_MODULE capability).

内核能够进行这些检查,因为功能是内核在其内部数据结构中记录的每个进程属性。

票数 1
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/503130

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档