From: Xie XiuQi <xiexiuqi(a)huawei.com>
commit 5942ec9b5dafaec45770276f0eae7f6b457cd4d7 openEuler-1.0
hulk inclusion
category: bugfix
bugzilla: 16633
CVE: NA
snprintf is more safe than sprintf, it is recommended
to use snprintf.
Signed-off-by: Xie XiuQi <xiexiuqi(a)huawei.com>
Reviewed-by: Yang Yingliang <yangyingliang(a)huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang(a)huawei.com>
Signed-off-by: Xin Hao <haoxing990(a)gmail.com>
---
arch/arm64/kernel/mpam_ctrlmon.c | 2 +-
fs/resctrlfs.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/kernel/mpam_ctrlmon.c b/arch/arm64/kernel/mpam_ctrlmon.c
index 02623c1c23e8..86e50fd19309 100644
--- a/arch/arm64/kernel/mpam_ctrlmon.c
+++ b/arch/arm64/kernel/mpam_ctrlmon.c
@@ -415,7 +415,7 @@ static int mkdir_mondata_subdir(struct kernfs_node *parent_kn,
md.u.partid = prgrp->closid;
md.u.pmg = prgrp->mon.rmid;
- sprintf(name, "mon_%s_%02d", r->name, d->id);
+ snprintf(name, sizeof(name), "mon_%s_%02d", r->name, d->id);
kn = __kernfs_create_file(parent_kn, name, 0444,
GLOBAL_ROOT_UID, GLOBAL_ROOT_GID, 0,
&kf_mondata_ops, md.priv, NULL, NULL);
diff --git a/fs/resctrlfs.c b/fs/resctrlfs.c
index 6277cb04c472..2bba5b7d5a9f 100644
--- a/fs/resctrlfs.c
+++ b/fs/resctrlfs.c
@@ -199,7 +199,7 @@ static int resctrl_group_create_info_dir(struct kernfs_node
*parent_kn)
for_each_resctrl_resource(r) {
if (r->mon_enabled) {
fflags = r->fflags | RF_MON_INFO;
- sprintf(name, "%s_MON", r->name);
+ snprintf(name, sizeof(name), "%s_MON", r->name);
ret = resctrl_group_mkdir_info_resdir(r, name, fflags);
if (ret)
goto out_destroy;
--
2.31.0