[RAMEN9610-13333][COMMON] soc: samsung: seclog: add code which check valdation of...
authorJang Hyunsung <hs79.jang@samsung.com>
Wed, 31 Oct 2018 04:15:45 +0000 (13:15 +0900)
committerCosmin Tanislav <demonsingur@gmail.com>
Mon, 22 Apr 2024 17:23:20 +0000 (20:23 +0300)
code which checks validation of v_log_addr address has been added.

Change-Id: Ia26ebdf8200fa3538fa3f27d03334df1cc716927
Signed-off-by: Jang Hyunsung <hs79.jang@samsung.com>
drivers/soc/samsung/exynos-seclog.c

index 1bc639c1045ce5f555d4aee6369c9ce98fd80b7d..32b563fa85c20503efcc3333bb5b6cf0de9375c2 100644 (file)
@@ -41,6 +41,16 @@ static struct seclog_data ldata;
 static struct seclog_ctx slog_ctx;
 static struct sec_log_info *sec_log[NR_CPUS];
 
+static inline uint32_t exynos_seclog_check_va_validation(uint64_t ptr)
+{
+       uint64_t base = (uint64_t)ldata.virt_addr;
+       uint64_t end = base + ldata.size;
+
+       if (base <= ptr && end > ptr)
+               return 0;
+
+       return -1;
+}
 
 static void exynos_ldfw_error(struct platform_device *pdev,
                                int error)
@@ -127,6 +137,30 @@ static void exynos_seclog_worker(struct work_struct *work)
                                }
                        }
 
+                       if (exynos_seclog_check_va_validation((uint64_t)v_log_addr)) {
+                               /* v_log_addr is not valid. print debugging info  */
+                               pr_err("[SECLOG_ERR C%d] read_cnt[%d]\n",
+                                               cpu, sec_log[cpu]->log_read_cnt);
+                               pr_err("[SECLOG_ERR C%d] write_cnt[%d]\n",
+                                               cpu, sec_log[cpu]->log_write_cnt);
+                               pr_err("[SECLOG_ERR C%d] return_cnt[%d]\n",
+                                               cpu, sec_log[cpu]->log_return_cnt);
+                               pr_err("[SECLOG_ERR C%d] v_log_addr[%#lx]\n",
+                                               cpu, v_log_addr);
+                               pr_err("[SECLOG_ERR C%d] start_log_addr[%#lx]\n",
+                                               cpu, sec_log[cpu]->start_log_addr);
+                               pr_err("[SECLOG_ERR C%d] initial_log_addr[%#lx]\n",
+                                               cpu, sec_log[cpu]->initial_log_addr);
+                               pr_err("[SECLOG_ERR C%d] p_log_addr[%#lx]\n",
+                                               cpu,
+                                               v_log_addr
+                                               - (unsigned long)ldata.virt_addr
+                                               + ldata.phys_addr);
+
+                               /* make panic for debugging */
+                               BUG();
+                       }
+
                        /* For debug */
                        pr_debug("[SECLOG_DEBUG C%d] read_cnt[%d]\n",
                                        cpu, sec_log[cpu]->log_read_cnt);
@@ -320,8 +354,8 @@ detect_ldfw_err:
        }
 
        dev_info(&pdev->dev,
-               "Message buffer address[%#lx], Message buffer size[%#lx]\n",
-               ldata.phys_addr, ldata.size);
+               "Message buffer address[PA : %#lx, VA : %#lx], Message buffer size[%#lx]\n",
+               ldata.phys_addr, ldata.virt_addr, ldata.size);
        dev_info(&pdev->dev, "Exynos Secure Log driver probe done!\n");
 
        return 0;