1 Star 0 Fork 48

疯言疯语/systemd

forked from src-anolis-os/systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0260-journald-check-whether-sscanf-has-changed-the-value-.patch 1.92 KB
一键复制 编辑 原始数据 按行查看 历史
张彬琛 提交于 2021-01-20 13:59 . import systemd-239-29.el8.src.rpm
From bef599d1a0e41afe4b6f1d6dfb6fbc86896ab8c5 Mon Sep 17 00:00:00 2001
From: Evgeny Vereshchagin <evvers@ya.ru>
Date: Fri, 16 Nov 2018 23:32:31 +0100
Subject: [PATCH] journald: check whether sscanf has changed the value
corresponding to %n
It's possible for sscanf to receive strings containing all three fields
and not matching the template at the same time. When this happens the
value of k doesn't change, which basically means that process_audit_string
tries to access memory randomly. Sometimes it works and sometimes it doesn't :-)
See also https://bugzilla.redhat.com/show_bug.cgi?id=1059314.
(cherry picked from commit 1dab14aba749b9c5ab8176c5730107b70834240b)
Resolves: #1764560
---
src/journal/journald-audit.c | 3 ++-
test/fuzz/fuzz-journald-audit/crash | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
create mode 100644 test/fuzz/fuzz-journald-audit/crash
diff --git a/src/journal/journald-audit.c b/src/journal/journald-audit.c
index 7810a0139a..0fd6ab2a84 100644
--- a/src/journal/journald-audit.c
+++ b/src/journal/journald-audit.c
@@ -341,11 +341,12 @@ void process_audit_string(Server *s, int type, const char *data, size_t size) {
if (!p)
return;
+ k = 0;
if (sscanf(p, "(%" PRIu64 ".%" PRIu64 ":%" PRIu64 "):%n",
&seconds,
&msec,
&id,
- &k) != 3)
+ &k) != 3 || k == 0)
return;
p += k;
diff --git a/test/fuzz/fuzz-journald-audit/crash b/test/fuzz/fuzz-journald-audit/crash
new file mode 100644
index 0000000000..91bd85ca6e
--- /dev/null
+++ b/test/fuzz/fuzz-journald-audit/crash
@@ -0,0 +1 @@
+audit(1542398162.211:744) pid=7376 uid=1000 auid=1000 ses=6 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:accounting grantors=pam_unix,pam_localuser acct="vagrant" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/1 res=success'
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/devttl/systemd.git
git@gitee.com:devttl/systemd.git
devttl
systemd
systemd
a8

搜索帮助