diff --git a/fix-write-file-return-code-bug.patch b/fix-write-file-return-code-bug.patch new file mode 100644 index 0000000000000000000000000000000000000000..f059224778ee237bfb84a006f72ca8580b6a730f --- /dev/null +++ b/fix-write-file-return-code-bug.patch @@ -0,0 +1,69 @@ +From cea094acea79b88e6458cfa264a03c51f08c72fc Mon Sep 17 00:00:00 2001 +From: luckky +Date: Mon, 4 Nov 2024 20:18:05 +0800 +Subject: [PATCH] fix write file return code bug +Set the return code 0 to -EINVAL to unify the processing of return code. + +--- + .../hbm_online_repair/non-standard-hbm-repair.c | 17 ++++++++++------- + 1 file changed, 10 insertions(+), 7 deletions(-) + +diff --git a/src/c/hbm_online_repair/non-standard-hbm-repair.c b/src/c/hbm_online_repair/non-standard-hbm-repair.c +index b8dde7a..97cb9a7 100644 +--- a/src/c/hbm_online_repair/non-standard-hbm-repair.c ++++ b/src/c/hbm_online_repair/non-standard-hbm-repair.c +@@ -112,7 +112,7 @@ static void parse_fault_addr_info(struct fault_addr_info* info_struct, unsigned + info_struct->row_id = fault_addr & FAULT_ADDR_ROW_ID_MASK; + fault_addr >>= FAULT_ADDR_ROW_ID_LEN; + info_struct->column_id = fault_addr & FAULT_ADDR_COLUMN_ID_MASK; +- fault_addr >>= FAULT_ADDR_CHANNEL_ID_LEN; ++ fault_addr >>= FAULT_ADDR_COLUMN_ID_LEN; + info_struct->error_type = fault_addr & FAULT_ADDR_ERROR_TYPE_MASK; + fault_addr >>= FAULT_ADDR_ERROR_TYPE_LEN; + info_struct->repair_type = fault_addr & FAULT_ADDR_REPAIR_TYPE_MASK; +@@ -371,7 +371,12 @@ static int write_file(char *path, const char *name, unsigned long long value) + fname, value, strerror(errno)); + + close(fd); +- return ret > 0 ? 0 : -errno; ++ if (ret == 0) { ++ ret = -EINVAL; ++ } else if (ret < 0) { ++ ret = -errno; ++ } ++ return ret; + } + + static int get_hardware_corrupted_size() +@@ -560,7 +565,7 @@ static int hbmc_hbm_page_isolate(const struct hisi_common_error_section *err) + static uint8_t hbmc_hbm_after_repair(bool is_acls, const int repair_ret, const unsigned long long paddr) + { + int ret; +- if (repair_ret <= 0) { ++ if (repair_ret < 0) { + log(LOG_WARNING, "HBM %s: Keep page (0x%llx) offline\n", is_acls ? "ACLS" : "SPPR", paddr); + /* not much we can do about errors here */ + (void)write_file("/sys/kernel/page_eject", "remove_page", paddr); +@@ -594,8 +599,7 @@ static int hbmc_hbm_repair(const struct hisi_common_error_section *err, char *pa + + ret = write_file(path, is_acls ? "acls_query" : "sppr_query", paddr); + +- /* Only positive num means the error is supported to repair */ +- if (ret <= 0) { ++ if (ret < 0) { + if (ret != -ENXIO) { + notice_BMC(err, get_repair_failed_result_code(ret)); + log(LOG_WARNING, "HBM: Address 0x%llx is not supported to %s repair\n", paddr, is_acls ? "ACLS" : "SPPR"); +@@ -624,8 +628,7 @@ static int hbmc_hbm_repair(const struct hisi_common_error_section *err, char *pa + all_online_success = false; + } + } +- /* The ret is from the acls/sppr repair, and only positive num means the error is repaired successfully */ +- if (ret <= 0) { ++ if (ret < 0) { + notice_BMC(err, get_repair_failed_result_code(ret)); + return ret; + } else if (all_online_success) { +-- +2.43.0 + diff --git a/sysSentry.spec b/sysSentry.spec index cef9db621d4c143ffd232ebb68f50016d86ef1a1..dfdc0a321fed4845bc7d4e7971d58e9de0407ecb 100644 --- a/sysSentry.spec +++ b/sysSentry.spec @@ -4,7 +4,7 @@ Summary: System Inspection Framework Name: sysSentry Version: 1.0.2 -Release: 18 +Release: 19 License: Mulan PSL v2 Group: System Environment/Daemons Source0: https://gitee.com/openeuler/sysSentry/releases/download/v%{version}/%{name}-%{version}.tar.gz @@ -29,6 +29,7 @@ Patch16: remove-threshold-max-cpu-cores.patch Patch17: add-hbm-online-repair.patch Patch18: fix-hbm-online-repair-notice-and-efi-create.patch Patch19: fix-uint8-bug-and-change-isolation-default-value.patch +Patch20: fix-write-file-return-code-bug.patch BuildRequires: cmake gcc-c++ BuildRequires: python3 python3-setuptools @@ -218,6 +219,12 @@ rm -rf %{buildroot} %attr(0550,root,root) %{python3_sitelib}/syssentry/bmc_alarm.py %changelog +* Mon Nov 4 2024 luckky - 1.0.2-19 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:fix write file return code bug + * Fri Nov 1 2024 luckky - 1.0.2-18 - Type:bugfix - CVE:NA