Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2627921pxj; Mon, 31 May 2021 06:55:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7+lxfHtoyHIzLtIsazavbZ2rxhXUQFNJyaTMzVZyHLfBgAbpp5lts6becL4po4pjzT/t/ X-Received: by 2002:a92:c245:: with SMTP id k5mr17422891ilo.29.1622469350640; Mon, 31 May 2021 06:55:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622469350; cv=none; d=google.com; s=arc-20160816; b=UpjHlqf1IUUK2KGVIW88qEnmTBs1o/QT1Yc4tFDsTrH31vPja5EOvZ2CWzst+zJDB4 rziXA4LRRcbF/eEHxWOeGWB/bgXiIIufe0I2Cgv4B/4DQoQMZ4FhpzaTdzfo9c4BFZNC 3nta09ImIdKHTp5lIfdhs1aQLn2rwbuvDg11SLIvy5QR/h4xYFd0Dl4tLYgcql938cwr mbvplv6WjjudHnaXgW3cgHkjg8zj5++pqCwzRrrGQmBSFjp0zSbd54BcuqWbWAvNwsMp MsPPm6AAEOgk1I+EiIjTVfdPcQ4QtvkIa2N7jmLJCn1suPihiBS3FoV6erBoI9tATE9+ 2jEg== 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=kaO/oRpQIMYm4RJqLkUH0dEfYZYEi+7cSo7qXVIAFF8=; b=FfUwyOEyW3Vw4kai8IO1wwLYoMGylZ2fO3hVm9j+0iMJm9BoDekCZWzYg9Q1n/Yqtv vZME0N/1oeakaqkNDMWph5A+qg+eeFFfVdpZpjPzP5Lg+k7X8T47AeNAd0J0aHheyutx Lp6tN9KJa1yu/4NB35+Z19s0KP4Gu776Fc48s3DR2mReZaMPnTJ0nDNCJsJEZ2UNVwji +KADx900WmDFtKRhuU6xBzypFZKSZ/0EfmYbA6S6bP0RErh4zo2OOXbwdpHmjwjCEQao 7/XAe35EofsybN7c6dx+cycrCF2Jqm4Uj0zupmliYpXhcp4zgx7bEptqNnng9Z5mCefF sd+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TXH3MOUi; 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 n12si16280261jat.1.2021.05.31.06.55.37; Mon, 31 May 2021 06:55:50 -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=TXH3MOUi; 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 S232605AbhEaN40 (ORCPT + 99 others); Mon, 31 May 2021 09:56:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:40248 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232320AbhEaNg0 (ORCPT ); Mon, 31 May 2021 09:36:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CD16F61449; Mon, 31 May 2021 13:25:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622467553; bh=aeJBmWwNnCLwm4Zv5IDmFtneV/ZXvJBGnlgGuDcJeYE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TXH3MOUi/7MZQ9ncvLaeo7kKcQqQ4mN/DG30GP0yhAy0PfZJJ/pNaOvUrCSOrB5WC yFEoxTk7I60O3/akB/qh6fA367wQC+1ww4V+szqm6VzbX/7ERvhVHwHxEZQinWWLfe te+wgMZSqwhJVWQgYsXNybk9WtqjpbUid5QI5EIM= 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.19 073/116] i2c: i801: Dont generate an interrupt on bus reset Date: Mon, 31 May 2021 15:14:09 +0200 Message-Id: <20210531130642.627366636@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130640.131924542@linuxfoundation.org> References: <20210531130640.131924542@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 @@ -384,11 +384,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));