From patchwork Fri Aug 21 00:10:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris J Arges X-Patchwork-Id: 509208 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id F03E41402A2; Fri, 21 Aug 2015 10:11:12 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1ZSZvE-0000NS-Lt; Fri, 21 Aug 2015 00:11:04 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1ZSZv9-0000N3-L1 for kernel-team@lists.ubuntu.com; Fri, 21 Aug 2015 00:10:59 +0000 Received: from cpe-173-174-67-34.austin.res.rr.com ([173.174.67.34] helo=mindstream.lan) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1ZSZv9-0001qJ-4D for kernel-team@lists.ubuntu.com; Fri, 21 Aug 2015 00:10:59 +0000 From: Chris J Arges To: kernel-team@lists.ubuntu.com Subject: [Vivid][SRU][PATCH] powerpc/powernv: Fix the overflow of OPAL message notifiers head array Date: Thu, 20 Aug 2015 17:10:38 -0700 Message-Id: <1440115838-16896-1-git-send-email-chris.j.arges@canonical.com> X-Mailer: git-send-email 2.5.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Neelesh Gupta BugLink: http://bugs.launchpad.net/bugs/1487085 Fixes the condition check of incoming message type which can otherwise shoot beyond the message notifiers head array. Signed-off-by: Neelesh Gupta Reviewed-by: Vasant Hegde Reviewed-by: Anshuman Khandual Signed-off-by: Benjamin Herrenschmidt (backported from commit 792f96e9a769b799a2944e9369e4ea1e467135b2) Some of this commit was merged into 9b42c07. This backport covers the remaining parts. Signed-off-by: Chris J Arges --- arch/powerpc/platforms/powernv/opal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c index 8375bf3..3f34413 100644 --- a/arch/powerpc/platforms/powernv/opal.c +++ b/arch/powerpc/platforms/powernv/opal.c @@ -313,6 +313,7 @@ int opal_message_notifier_register(enum opal_msg_type msg_type, __func__, msg_type); return -EINVAL; } + return atomic_notifier_chain_register( &opal_msg_notifier_head[msg_type], nb); } @@ -358,7 +359,7 @@ static void opal_handle_message(void) type = be32_to_cpu(msg.msg_type); /* Sanity check */ - if (type > OPAL_MSG_TYPE_MAX) { + if (type >= OPAL_MSG_TYPE_MAX) { pr_warning("%s: Unknown message type: %u\n", __func__, type); return; }