Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3004414imu; Sun, 9 Dec 2018 14:53:16 -0800 (PST) X-Google-Smtp-Source: AFSGD/X/eb4klpyJpPGpfJBPgK8SImzCqNjQEaptayGyGq+RAKfJ26bv83W7mCrVRPJK+fXyJDkV X-Received: by 2002:a17:902:7d90:: with SMTP id a16mr9504049plm.249.1544395996566; Sun, 09 Dec 2018 14:53:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544395996; cv=none; d=google.com; s=arc-20160816; b=jvwBiosIXcj8C1/JdzliidoOJhAZhAXpE0FnsjBRjJiN25uF0wZ5vPt4XR8/YwcRZp OgpX1WHnkTHe6WRcGoho1VL5eZPFR5Y0Ea2yhRIQLrr5QDfH3N899j1pyd77QP70rprD EXAVQgjI6lQHmCOek3JoT4FfTd6lQVBz10fBTb6EzZfDwG4eRy804QsxL1ToqwA0iwyz SVrKo1/YjGveJ4OaU3Bq/uLOh1sMel7R7hS9ear0fHJRoEl64FsdAT//Ek431DYyZqe2 y3BGYKTyONznhT3bL5/JhRMNpbljDxDUQ2wT5cpBffld0QPtJDRrzlhpVFZpU3vBZkwH bKhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=0Fnh+1Es90bGwFBgka4GRkKtrncUgNdwiG66OwK1Pbs=; b=Phi0bV8ZGJWxP3H8E+WahgOcyhtJtlDphfrnCcIprveYBQzc6xse7u8EnnedQKwZiK vms0suEkYsIhXioTcBHME/AGu5WEMjRnS5ISL48fBhmZBX9tmHLFcMw2XVpm9a0Bh/w3 k52cDF6hKCROh7/fdgdgaNiAuHTp0mn6qD7fH7i4zYQDwhU2nCIB09By1swnrcuwhUqI yT0sV4q3Dj8UoFj3lrIYrWntToINLvk5K8uyQuTyHlfjEJCibiFMhfgmuWNEQzdMTica mjXz8ubkaDljXX+at1URWaQroflg7cUlAd5vYoJRVxs0eggCoMwhldgGQb8h2G9iMq4f tj7A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z4si8074082pgl.16.2018.12.09.14.53.01; Sun, 09 Dec 2018 14:53:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727682AbeLIWFz (ORCPT + 99 others); Sun, 9 Dec 2018 17:05:55 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:37012 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726870AbeLIWFw (ORCPT ); Sun, 9 Dec 2018 17:05:52 -0500 Received: from pub.yeoldevic.com ([81.174.156.145] helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gW73H-0002ic-KJ; Sun, 09 Dec 2018 21:55:51 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gW72c-0003ML-I6; Sun, 09 Dec 2018 21:55:10 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Michal Suchanek" , "Mahesh Salgaonkar" , "Michael Ellerman" Date: Sun, 09 Dec 2018 21:50:33 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 114/328] powerpc/pseries: Avoid using the size greater than RTAS_ERROR_LOG_MAX. In-Reply-To: X-SA-Exim-Connect-IP: 81.174.156.145 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.62-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Mahesh Salgaonkar 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 Signed-off-by: Mahesh Salgaonkar Signed-off-by: Michael Ellerman Signed-off-by: Ben Hutchings --- arch/powerpc/platforms/pseries/ras.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- 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_ 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;