Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1775372ybt; Mon, 15 Jun 2020 09:06:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxziuSCJpC93aPpVRQxfxUiHNJy5v7WjG5ZbR9e0+x78AI1n5mEwhEnGxBCMftfUnPlWiFq X-Received: by 2002:a17:906:528b:: with SMTP id c11mr25552409ejm.407.1592237165883; Mon, 15 Jun 2020 09:06:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592237165; cv=none; d=google.com; s=arc-20160816; b=l3oId0U0f1naakT1VS2mQ2TcEnq1452CyU5fusYHjfEm5Y7jlmoNp6USBLJ+JX5LTu AGd6UGZhU7aZKO2ThFb77izuFxKQ/n5AhRuRUaYK9d49Cdzv34RON0BTpoB2QVihWtWB T65p5MWW96qZ7BAXkmwe/DA+CfoOb9hoq+b2nzEpjnX8txic3Aqy90fvFehGwotsjWAm dPBo3BA9uqU2oy9F6eFtfuBRDmMSIaFWeXhBRKyvH9K+LlBcyWQI/mZr3sMU4tKibjKF yJj6+SfOEMkfnmRQaavRI9BH/JmCape9WGYLcgqfEVdcl/+t0Kdn4A+xmtsTRHx+HI4W GgXQ== 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:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=K9MJT+eXnXmz1ilMAGWESoX9j8zjIESdzer9fDMdlfI=; b=qBTWjU0tJEhFBgsy+aUFe7rfA4WyiCJ0vvdoLHc+iaazDbs2GiAGWn6M41Ud/jx0fy AxSJNIzuyDOVlKCDU5TD91F2vQe72ze6GLh7RbRgfR+WFyhSHxUzi0ZLY2kNvCrZ3r0D hZ06OqpZzgiDl4ZAfFCGTLwMWY5L6BbDtQupRkGn+9vM7iedUOCGC5sY5btY4jhWVn1m KycfzDQ5ujZo97fvCZZUuDPT53ZdEyUJhvE9WvpDFGuoo4XgC6mwKB8oYVVFz/bJJ/wZ KBlHF0T/wExa8Q4h5L58TX9KQ56ioqOAsKPXAQxMUO9iW4+Xo2GdCxWN/EVBLwCYsTYo f3ew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dm19si11999777ejc.17.2020.06.15.09.05.42; Mon, 15 Jun 2020 09:06:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730646AbgFOQD1 (ORCPT + 99 others); Mon, 15 Jun 2020 12:03:27 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:39775 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730426AbgFOQD0 (ORCPT ); Mon, 15 Jun 2020 12:03:26 -0400 Received: by mail-pl1-f195.google.com with SMTP id v24so6974657plo.6; Mon, 15 Jun 2020 09:03:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=K9MJT+eXnXmz1ilMAGWESoX9j8zjIESdzer9fDMdlfI=; b=cnvBOS58obQFCcH0svIWTkTF3n7duV49F099UQgUDNgD7wZeSotdeh3bsW2yfXux+/ n02GHFZsHFay4091P1FsVlwlTYExAnpbxu4jz6alQj3oI2HoftHue2Xjil0KlhBlMXuz Ajl1IZ3UQTY1Sh0nHxrPSLilM1YLlysqDO3A7HLgroiEAv/ppGC4vfpL+DYyQWIDxpfF I8bQLAsIhyjZ7Wx4VNM+2lxp8lYl2Q4T4mgPSZhxiqZeqb90C677J5vClEmVP8c4lmlj j1qcyd41sZq8mokA/SxU+U8Azdv1wa+5j0ZkEaie4ZpvDnqd8fGRt9K5KigIb5rLgSPC bFvQ== X-Gm-Message-State: AOAM533dva9vCocLrNSCLSKxezpnMoIOBwUGRW840oKdlVaEm6Wmv0BN Bxli/1Iqfndmm77cZqjSjNo= X-Received: by 2002:a17:90b:28d:: with SMTP id az13mr7410pjb.67.1592237005503; Mon, 15 Jun 2020 09:03:25 -0700 (PDT) Received: from sultan-book.localdomain ([89.45.90.111]) by smtp.gmail.com with ESMTPSA id i22sm14181344pfo.92.2020.06.15.09.03.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jun 2020 09:03:24 -0700 (PDT) Date: Mon, 15 Jun 2020 09:03:20 -0700 From: Sultan Alsawaf To: Andy Shevchenko Cc: Aaron Ma , Benjamin Tissoires , Hans de Goede , HungNien Chen , Jarkko Nikula , Jiri Kosina , Kai-Heng Feng , linux-i2c@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Mika Westerberg , Pavel Balan , Tin Huynh , Wolfram Sang , You-Sheng Yang Subject: Re: [PATCH 1/2] i2c: designware: Only check the first byte for SMBus block read length Message-ID: <20200615160320.GA1949@sultan-book.localdomain> References: <20200614210255.4641-1-sultan@kerneltoast.com> <20200614210255.4641-2-sultan@kerneltoast.com> <20200615094019.GP2428291@smile.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200615094019.GP2428291@smile.fi.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 15, 2020 at 12:40:19PM +0300, Andy Shevchenko wrote: > On Sun, Jun 14, 2020 at 02:02:54PM -0700, Sultan Alsawaf wrote: > > From: Sultan Alsawaf > > > > SMBus block reads can be broken because the read function will just skip > > over bytes it doesn't like until reaching a byte that conforms to the > > length restrictions for block reads. This is problematic when it isn't > > known if the incoming payload is indeed a conforming block read. > > > > According to the SMBus specification, block reads will only send the > > payload length in the first byte, so we can fix this by only considering > > the first byte in a sequence for block read length purposes. > > I'm wondering if this overlaps with [1]. AFAIU that one is also makes sure that > the length is not a garbage. > > [1]: https://lore.kernel.org/linux-i2c/20200613104109.2989-1-mans@mansr.com/T/#u No overlap. That looks like a similar bug for a different driver. In my case, the adapter provides native SMBus support, so emulation is never used. This is clear to see by looking at i2c_transfer_buffer_flags(), which only uses the master_xfer functions provided by the adapter; it doesn't call the emulation path at all. Sultan