summaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorMahesh Salgaonkar <mahesh@linux.vnet.ibm.com>2018-07-04 23:27:02 +0530
committerBen Hutchings <ben@decadent.org.uk>2018-12-16 22:08:38 +0000
commit20a334b403478c0fe7e4f27712b645f5a51174b2 (patch)
tree823b472ec88bd2c3abde5fc0bbf22cf0154d5b84 /arch/powerpc
parent29002321516dd7a79e4840d3800a86f2aaa070c3 (diff)
downloadlinux-stable-20a334b403478c0fe7e4f27712b645f5a51174b2.tar.gz
linux-stable-20a334b403478c0fe7e4f27712b645f5a51174b2.tar.bz2
linux-stable-20a334b403478c0fe7e4f27712b645f5a51174b2.zip
powerpc/pseries: Avoid using the size greater than RTAS_ERROR_LOG_MAX.
commit 74e96bf44f430cf7a01de19ba6cf49b361cdfd6e upstream. The global mce data buffer that used to copy rtas error log is of 2048 (RTAS_ERROR_LOG_MAX) bytes in size. Before the copy we read extended_log_length from rtas error log header, then use max of extended_log_length and RTAS_ERROR_LOG_MAX as a size of data to be copied. Ideally the platform (phyp) will never send extended error log with size > 2048. But if that happens, then we have a risk of buffer overrun and corruption. Fix this by using min_t instead. Fixes: d368514c3097 ("powerpc: Fix corruption when grabbing FWNMI data") Reported-by: Michal Suchanek <msuchanek@suse.com> Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/platforms/pseries/ras.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
index 55cbad443500..02d9e5f323fb 100644
--- a/arch/powerpc/platforms/pseries/ras.c
+++ b/arch/powerpc/platforms/pseries/ras.c
@@ -309,7 +309,7 @@ static struct rtas_error_log *fwnmi_get_errinfo(struct pt_regs *regs)
int len, error_log_length;
error_log_length = 8 + rtas_error_extended_log_length(h);
- len = max_t(int, error_log_length, RTAS_ERROR_LOG_MAX);
+ len = min_t(int, error_log_length, RTAS_ERROR_LOG_MAX);
memset(global_mce_data_buf, 0, RTAS_ERROR_LOG_MAX);
memcpy(global_mce_data_buf, h, len);
errhdr = (struct rtas_error_log *)global_mce_data_buf;