From patchwork Mon Oct 12 13:26:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 270401 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4324CC433E7 for ; Mon, 12 Oct 2020 13:32:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DB0E82087E for ; Mon, 12 Oct 2020 13:32:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602509529; bh=CU2iw3b6Eixu2oQ+2Yk4LKv+dyXLOZXsx9c/YQcPLw4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=j1BbNuuVdatr+6ds9qJ8V+/OigJbPw3S8IoSdogKcGVvhSk0rVp5kqnfbPD2Nf1hu 401w1yqR0F3yRNOgyC3MLucotAbq2ZubK1oKSf21BlxOGJFI4dwsgI4BId8BNUb/cr xYZkxdU3eKg53bA9u6JR2ReAXz6TkQbZMr/Tfyk4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730073AbgJLNcD (ORCPT ); Mon, 12 Oct 2020 09:32:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:33772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730032AbgJLNcB (ORCPT ); Mon, 12 Oct 2020 09:32:01 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A6025204EA; Mon, 12 Oct 2020 13:32:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602509521; bh=CU2iw3b6Eixu2oQ+2Yk4LKv+dyXLOZXsx9c/YQcPLw4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DB2BpscsGcSf1MxVd+xxcOuEMchGPE+fSaLSkfOHeEZ5o+2edsnXT8G4U0W18DkyG ecnf2Hvm+Z06NF+t1nIk9aaC1+gsUQHn9CpTpH4/0Ntrcimbn9gWNIMxX4WmIab1Lk Ov9u/HweVkP//tMoh9SEJDHXJw5qpVI/NNy4lk1M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas VINCENT , Jochen Friedrich , Christophe Leroy , Wolfram Sang , Sasha Levin Subject: [PATCH 4.4 11/39] i2c: cpm: Fix i2c_ram structure Date: Mon, 12 Oct 2020 15:26:41 +0200 Message-Id: <20201012132628.679679830@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012132628.130632267@linuxfoundation.org> References: <20201012132628.130632267@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Nicolas VINCENT [ Upstream commit a2bd970aa62f2f7f80fd0d212b1d4ccea5df4aed ] the i2c_ram structure is missing the sdmatmp field mentionned in datasheet for MPC8272 at paragraph 36.5. With this field missing, the hardware would write past the allocated memory done through cpm_muram_alloc for the i2c_ram structure and land in memory allocated for the buffers descriptors corrupting the cbd_bufaddr field. Since this field is only set during setup(), the first i2c transaction would work and the following would send data read from an arbitrary memory location. Fixes: 61045dbe9d8d ("i2c: Add support for I2C bus on Freescale CPM1/CPM2 controllers") Signed-off-by: Nicolas VINCENT Acked-by: Jochen Friedrich Acked-by: Christophe Leroy Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-cpm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c index b167ab25310a3..34a35e927fc6d 100644 --- a/drivers/i2c/busses/i2c-cpm.c +++ b/drivers/i2c/busses/i2c-cpm.c @@ -74,6 +74,9 @@ struct i2c_ram { char res1[4]; /* Reserved */ ushort rpbase; /* Relocation pointer */ char res2[2]; /* Reserved */ + /* The following elements are only for CPM2 */ + char res3[4]; /* Reserved */ + uint sdmatmp; /* Internal */ }; #define I2COM_START 0x80