1 Star 0 Fork 37

zhang/shadow

forked from src-openEuler/shadow 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-lib-idmapping.c--Use-long-constants-in-prctl-2.patch 1.56 KB
一键复制 编辑 原始数据 按行查看 历史
zhangxingrong 提交于 2024-09-26 16:01 +08:00 . backprot patches from upstream
From 80efeebaf296dc4814e15d67977726b3ee93c048 Mon Sep 17 00:00:00 2001
From: Alejandro Colomar <alx@kernel.org>
Date: Fri, 31 May 2024 18:30:16 +0200
Subject: [PATCH] lib/idmapping.c: Use long constants in prctl(2), and remove
0s
The prctl(2) system-call wrapper is implemented as a variadic function.
This makes it important to pass arguments to it of the right type (and
more importantly of the right width), to avoid undefined behavior.
While at it, check errors with ==-1, not <0, which is more explicit.
Also, PR_SET_KEEPCAPS(2const) doesn't need all arguments, so it can be
called with just two of them; remove unnecessary 0s.
See-also: prctl(2), PR_SET_KEEPCAPS(2const)
Link: <https://lore.kernel.org/linux-man/ddbdyaiptesjalgfmztxideej67e3yaob7ucsmbf6qvriwxiif@dohhxrqgwhrf/T/#med306b5b003f9cc7cc2de69fcdd7ee2d056d0954>
Cc: Xi Ruoyao <xry111@xry111.site>
Cc: Lukas Slebodnik <lslebodn@fedoraproject.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
---
lib/idmapping.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/idmapping.c b/lib/idmapping.c
index fe3ccdfe3..5cbb6fefc 100644
--- a/lib/idmapping.c
+++ b/lib/idmapping.c
@@ -159,7 +159,7 @@ void write_mapping(int proc_dir_fd, int ranges, const struct map_range *mappings
/* Align setuid- and fscaps-based new{g,u}idmap behavior. */
if (geteuid() == 0 && geteuid() != ruid) {
- if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) < 0) {
+ if (prctl(PR_SET_KEEPCAPS, 1L) == -1) {
fprintf(log_get_logfd(), _("%s: Could not prctl(PR_SET_KEEPCAPS)\n"), log_get_progname());
exit(EXIT_FAILURE);
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fatboyer/shadow.git
git@gitee.com:fatboyer/shadow.git
fatboyer
shadow
shadow
master

搜索帮助