linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Mahesh J Salgaonkar <mahesh@linux.vnet.ibm.com>
To: linuxppc-dev <linuxppc-dev@ozlabs.org>
Cc: Michal Suchanek <msuchanek@suse.com>,
	Nicholas Piggin <npiggin@gmail.com>,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
	Laurent Dufour <ldufour@linux.vnet.ibm.com>,
	Michal Suchanek <msuchanek@suse.com>
Subject: [PATCH v5 1/7] powerpc/pseries: Avoid using the size greater than
Date: Mon, 02 Jul 2018 11:16:18 +0530	[thread overview]
Message-ID: <153051036692.30541.14416412581134892363.stgit@jupiter.in.ibm.com> (raw)
In-Reply-To: <153051022088.30541.5610525713141009848.stgit@jupiter.in.ibm.com>

From: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>

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>
---
 arch/powerpc/platforms/pseries/ras.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
index 5e1ef9150182..ef104144d4bc 100644
--- a/arch/powerpc/platforms/pseries/ras.c
+++ b/arch/powerpc/platforms/pseries/ras.c
@@ -371,7 +371,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;

  reply	other threads:[~2018-07-02  5:46 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-02  5:45 [PATCH v5 0/7] powerpc/pseries: Machien check handler improvements Mahesh J Salgaonkar
2018-07-02  5:46 ` Mahesh J Salgaonkar [this message]
2018-07-02  5:46 ` [PATCH v5 2/7] powerpc/pseries: Defer the logging of rtas error to irq work queue Mahesh J Salgaonkar
2018-07-03  3:25   ` Nicholas Piggin
2018-07-03 10:32     ` Mahesh Jagannath Salgaonkar
2018-07-02  5:46 ` [PATCH v5 3/7] powerpc/pseries: Fix endainness while restoring of r3 in MCE handler Mahesh J Salgaonkar
2018-07-02  5:46 ` [PATCH v5 4/7] powerpc/pseries: Define MCE error event section Mahesh J Salgaonkar
2018-07-02  5:47 ` [PATCH v5 5/7] powerpc/pseries: flush SLB contents on SLB MCE errors Mahesh J Salgaonkar
2018-07-02 22:08   ` Nicholas Piggin
2018-07-03  7:20     ` Mahesh Jagannath Salgaonkar
2018-07-03 10:37     ` Michal Suchánek
2018-07-04 13:15       ` Michael Ellerman
2018-07-12 13:41     ` Michal Suchánek
2018-07-19 13:08       ` Michael Ellerman
2018-08-01  5:49       ` Nicholas Piggin
2018-07-02  5:47 ` [PATCH v5 6/7] powerpc/pseries: Display machine check error details Mahesh J Salgaonkar
2018-07-02  5:47 ` [PATCH v5 7/7] powerpc/pseries: Dump the SLB contents on SLB MCE errors Mahesh J Salgaonkar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=153051036692.30541.14416412581134892363.stgit@jupiter.in.ibm.com \
    --to=mahesh@linux.vnet.ibm.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=ldufour@linux.vnet.ibm.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=msuchanek@suse.com \
    --cc=npiggin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).