Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751400AbdIEHJ4 (ORCPT ); Tue, 5 Sep 2017 03:09:56 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37108 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751316AbdIEHJy (ORCPT ); Tue, 5 Sep 2017 03:09:54 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephen Douthit , Dan Priamo , Neil Horman , Wolfram Sang Subject: [PATCH 3.18 2/9] i2c: ismt: Return EMSGSIZE for block reads with bogus length Date: Tue, 5 Sep 2017 09:09:36 +0200 Message-Id: <20170905070902.008477031@linuxfoundation.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170905070901.809390741@linuxfoundation.org> References: <20170905070901.809390741@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1229 Lines: 40 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stephen Douthit commit ba201c4f5ebe13d7819081756378777d8153f23e upstream. Compare the number of bytes actually seen on the wire to the byte count field returned by the slave device. Previously we just overwrote the byte count returned by the slave with the real byte count and let the caller figure out if the message was sane. Signed-off-by: Stephen Douthit Tested-by: Dan Priamo Acked-by: Neil Horman Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-ismt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/i2c/busses/i2c-ismt.c +++ b/drivers/i2c/busses/i2c-ismt.c @@ -340,8 +340,10 @@ static int ismt_process_desc(const struc break; case I2C_SMBUS_BLOCK_DATA: case I2C_SMBUS_I2C_BLOCK_DATA: + if (desc->rxbytes != dma_buffer[0] + 1) + return -EMSGSIZE; + memcpy(data->block, dma_buffer, desc->rxbytes); - data->block[0] = desc->rxbytes - 1; break; } return 0;