Documentation/translations/zh_CN/security/credentials.rst
Source file repositories/reference/linux-study-clean/Documentation/translations/zh_CN/security/credentials.rst
File Facts
- System
- Linux kernel
- Corpus path
Documentation/translations/zh_CN/security/credentials.rst- Extension
.rst- Size
- 18494 bytes
- Lines
- 480
- Domain
- Support Tooling And Documentation
- Bucket
- Documentation
- Inferred role
- Support Tooling And Documentation: documentation
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
function foofunction alter_suid
Annotated Snippet
if (ret < 0) {
abort_creds(new);
return ret;
}
return commit_creds(new);
}
管理凭据
--------
有一些函数用来辅助凭据管理:
- ``void put_cred(const struct cred *cred);``
这将释放对给定凭据集的引用。如果引用计数为零,凭据集将由
RCU系统安排进行销毁。
- ``const struct cred *get_cred(const struct cred *cred);``
这将获取对活动凭据集的引用。返回指向凭据集的指针。
- ``struct cred *get_new_cred(struct cred *cred);``
这将获取对当前正在构建且可变的凭据集的引用。返回指向凭据集的指针。
打开文件凭据
============
当打开新文件时,会获取对打开任务凭据的引用,并将其附加到文件结构体的
``f_cred`` 字段中,替代原来的 ``f_uid`` 和 ``f_gid`` 。原来访问
``file->f_uid`` 和 ``file->f_gid`` 的代码现在应访问 ``file->f_cred->fsuid``
和 ``file->f_cred->fsgid`` 。
安全访问 ``f_cred`` 的情况下可以不使用RCU或加锁,因为指向凭据的指针
以及指向的凭据结构的内容在文件结构的整个生命周期中保持不变,除非是
上述列出的例外情况(参阅任务凭据部分)。
为了避免“混淆代理”权限提升攻击,在打开的文件后续操作时,访问控制检查
应该使用这些凭据,而不是使用“当前”的凭据,因为该文件可能已经被传递给
一个更具特权的进程。
覆盖VFS对凭据的使用
===================
在某些情况下,需要覆盖VFS使用的凭据,可以通过使用不同的凭据集调用
如 ``vfs_mkdir()`` 来实现。以下是一些进行此操作的位置:
* ``sys_faccessat()``.
* ``vfs_coredump()``.
* nfs4recover.c.
Annotation
- Detected declarations: `function foo`, `function alter_suid`.
- Atlas domain: Support Tooling And Documentation / Documentation.
- Implementation status: atlas-only.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.