From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753962AbdA3SQu (ORCPT ); Mon, 30 Jan 2017 13:16:50 -0500 Received: from dougal.metanate.com ([90.155.101.14]:30387 "EHLO metanate.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753921AbdA3SQt (ORCPT ); Mon, 30 Jan 2017 13:16:49 -0500 Date: Mon, 30 Jan 2017 18:16:36 +0000 From: John Keeping To: Sean Paul Cc: Mark Yao , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, Chris Zhong , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v3 06/24] drm/rockchip: dw-mipi-dsi: avoid out-of-bounds read on tx_buf Message-ID: <20170130181636.1bc81e86.john@metanate.com> In-Reply-To: <20170130180146.GG20076@art_vandelay> References: <20170129132444.25251-1-john@metanate.com> <20170129132444.25251-7-john@metanate.com> <20170130180146.GG20076@art_vandelay> Organization: Metanate Ltd X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 30 Jan 2017 13:01:46 -0500, Sean Paul wrote: > On Sun, Jan 29, 2017 at 01:24:26PM +0000, John Keeping wrote: > > As a side-effect of this, encode the endianness explicitly rather than > > casting a u16. > > > > Signed-off-by: John Keeping > > Reviewed-by: Chris Zhong > > --- > > v3: > > - Add Chris' Reviewed-by > > Unchanged in v2 > > > > drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 9 +++++++-- > > 1 file changed, 7 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c > > index 4be1ff3a42bb..2e6ad4591ebf 100644 > > --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c > > +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c > > @@ -572,8 +572,13 @@ static int dw_mipi_dsi_gen_pkt_hdr_write(struct dw_mipi_dsi *dsi, u32 hdr_val) > > static int dw_mipi_dsi_dcs_short_write(struct dw_mipi_dsi *dsi, > > const struct mipi_dsi_msg *msg) > > { > > - const u16 *tx_buf = msg->tx_buf; > > - u32 val = GEN_HDATA(*tx_buf) | GEN_HTYPE(msg->type); > > + const u8 *tx_buf = msg->tx_buf; > > + u32 val = GEN_HTYPE(msg->type); > > + > > + if (msg->tx_len > 0) > > + val |= GEN_HDATA(tx_buf[0]); > > + if (msg->tx_len > 1) > > + val |= GEN_HDATA(tx_buf[1] << 8); > > You should probably update the mask inside GEN_HDATA to mask off 8 bits instead of > 16. Won't that mask off the data written by "tx_buf[1] << 8"?