Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2643267pxj; Mon, 31 May 2021 07:14:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnBMDQseiXfectLlY3oRFe5+aNm+3ugatpGAbZhawaOirjSTiJfJBD1bC54o9+h89huImw X-Received: by 2002:a5e:c311:: with SMTP id a17mr17378674iok.34.1622470469403; Mon, 31 May 2021 07:14:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622470469; cv=none; d=google.com; s=arc-20160816; b=SAj6MxNzNt3bZ5H6fN1mNPtEJ2YXOfjkm7n2E8WyPsouzxMdX2G1rMWWZ7v60TTT2u t4z9thZ0LkXIsM+QGJgXmcB7tI5HogWKlR/vCeA6X1quPqv5/xmlrhIfVQHDeYD3bx9i OGN1N7rBA76ESDqKgo2CqS/iha4yw8U0JXAGNKEY38hO/ashXF0MhgSapivirmxIa8Wa DJ3BeoAGd656uslOGdODLWUv5DDGBeLFj+P6tIvn2Za1xjy/tWSRMQtSv8XNOhDk0ONJ dx9PQ2KKL84DZZXNSkLRql4wvp4boWgfvBrTa3TL2ohbYAS+XN96p6PTojloBdQ8InAE BkPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fMP5cqoXSmTNpjcxtPNAc3t77NGLHhGW0FFSJALpcUc=; b=H6mQ527r9wbksG/FO8zYl5Ays8fZhcibn3/BDPRYxc+tlZ0g/9Vuy1LiOXqBpo1UtR 7l7X5ECTwOi1vDtRzo1RA02t0qsInDb8y5qTqm3eOY3fpMXNOGcs2WmQEaMFyp0QdL6C BQ9R5e27l+ehYFSJktNBA0UX5Jz59MzTgw1nnU6tZP5sURtU9D1sYMQomF1pB+2IeeTF hPxECnGumIy1ZaKKXS18A3DvqSZoYluVL8fs9pmhLb7dYbQOF1844gT3LY18y7LY9kZ3 HMagJqIHYxmb5MH+xNpmjpMkbTi0sORDACRIhRVHm4jb5A3GNcg5gPEuDPlQaE46u8h3 w05A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gP6WAQrA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g3si9885791ila.154.2021.05.31.07.14.15; Mon, 31 May 2021 07:14:29 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gP6WAQrA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232924AbhEaOL7 (ORCPT + 99 others); Mon, 31 May 2021 10:11:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:49706 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230308AbhEaNpK (ORCPT ); Mon, 31 May 2021 09:45:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3F87A6141E; Mon, 31 May 2021 13:29:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622467784; bh=KHU6nK91ps5fgJ0M+8gUgacb8bal347koAIiWci8V5k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gP6WAQrANAtfMi3zQZeBByLmUbCPhp0ElpfUH1p3fnaCsKp8J/iD0OA+mKW2DJGtj 4iLHt2JG2RlW2sJlTHNqSQQ+Yh2DOE7zBdAGSbWFOU0vtEq82wgYJzgfIt/Q58JL49 KaMea4XAqE5PmVM3S5Alqa/VXRQ8NljnEeFUMStw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+b4d3fd1dfd53e90afd79@syzkaller.appspotmail.com, Jean Delvare , Andy Shevchenko , Jarkko Nikula , Wolfram Sang Subject: [PATCH 4.14 43/79] i2c: i801: Dont generate an interrupt on bus reset Date: Mon, 31 May 2021 15:14:28 +0200 Message-Id: <20210531130637.392721855@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130636.002722319@linuxfoundation.org> References: <20210531130636.002722319@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jean Delvare commit e4d8716c3dcec47f1557024add24e1f3c09eb24b upstream. Now that the i2c-i801 driver supports interrupts, setting the KILL bit in a attempt to recover from a timed out transaction triggers an interrupt. Unfortunately, the interrupt handler (i801_isr) is not prepared for this situation and will try to process the interrupt as if it was signaling the end of a successful transaction. In the case of a block transaction, this can result in an out-of-range memory access. This condition was reproduced several times by syzbot: https://syzkaller.appspot.com/bug?extid=ed71512d469895b5b34e https://syzkaller.appspot.com/bug?extid=8c8dedc0ba9e03f6c79e https://syzkaller.appspot.com/bug?extid=c8ff0b6d6c73d81b610e https://syzkaller.appspot.com/bug?extid=33f6c360821c399d69eb https://syzkaller.appspot.com/bug?extid=be15dc0b1933f04b043a https://syzkaller.appspot.com/bug?extid=b4d3fd1dfd53e90afd79 So disable interrupts while trying to reset the bus. Interrupts will be enabled again for the following transaction. Fixes: 636752bcb517 ("i2c-i801: Enable IRQ for SMBus transactions") Reported-by: syzbot+b4d3fd1dfd53e90afd79@syzkaller.appspotmail.com Signed-off-by: Jean Delvare Acked-by: Andy Shevchenko Cc: Jarkko Nikula Tested-by: Jarkko Nikula Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-i801.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -379,11 +379,9 @@ static int i801_check_post(struct i801_p dev_err(&priv->pci_dev->dev, "Transaction timeout\n"); /* try to stop the current command */ dev_dbg(&priv->pci_dev->dev, "Terminating the current operation\n"); - outb_p(inb_p(SMBHSTCNT(priv)) | SMBHSTCNT_KILL, - SMBHSTCNT(priv)); + outb_p(SMBHSTCNT_KILL, SMBHSTCNT(priv)); usleep_range(1000, 2000); - outb_p(inb_p(SMBHSTCNT(priv)) & (~SMBHSTCNT_KILL), - SMBHSTCNT(priv)); + outb_p(0, SMBHSTCNT(priv)); /* Check if it worked */ status = inb_p(SMBHSTSTS(priv));