Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2700994pxj; Mon, 31 May 2021 08:34:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwH+bqyB0fLktDsDUVmxCRPhwCnEfX+uMVhVw6OPD1v2v79JF+n+zK7O2AdpfLlUoTRIeHj X-Received: by 2002:a6b:7901:: with SMTP id i1mr17528887iop.41.1622475297884; Mon, 31 May 2021 08:34:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622475297; cv=none; d=google.com; s=arc-20160816; b=Sb5l7U5vxCcpaKFe8piVqoJjxZvemaGrzzhgTteHPn3SdzSkfXG6OYFyt/CItH3unQ 8HVFptKsRPP/jYqQLXnwAuCWb5jrGjyAdFSDjJlU6NHGlez6QSaMyYPWeIcM1sw0nLQM loNqHCcazNRWfL6jeXLGgLnEI0de47gjV1DniUIq5heIzoacxQSxRnjSUfe2Xc0W5P1b FQ4fscApxk/PfvPC+MWR4GH5gbFtJwyFXuj0mU3Ol6IPzPBvcb0CdXMFE0SW/ogkbM+7 y7rRlWeR2/Zw/cZ0mI3kgh72MRZCWJk/eLK6z37EChuJNF/G8j29NxNgFp/hZMu1zWWF lwOQ== 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=j8ICDFBPwBton6u0px5JzqtlCtmuHYIbXxTUXnqqJgdw1mKyw2nHJeSy4i6Rr4Q7kv s0BkrS5almFyZfpXDz4PPO85Bb1LRSJitRJ1GHGtFDYmbKlyA6SOC4dr3miVpnng3F4l LmlPZiWvjxmoGTZefDNctXpnn4frl6LwpX6m16Ee7yD37q0ErixU6PIcj7IyuEO1tenf /yTosB//nKbK0v4DzI4HVcXNezaEMKT/AZE5msqRRpSiVmqK1hNXRpA5CpvVKFeS/q/R QIb3IHrMhTmUGv5Jh2+alL3LWonh4vEKMJA1K1+b1MnaYu5hVbS8Nm+ph0NZsy8fvSo9 RZIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="s7TZu4/q"; 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 m125si8818118iof.57.2021.05.31.08.34.45; Mon, 31 May 2021 08:34:57 -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="s7TZu4/q"; 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 S234557AbhEaPfq (ORCPT + 99 others); Mon, 31 May 2021 11:35:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:47640 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233635AbhEaOV1 (ORCPT ); Mon, 31 May 2021 10:21:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 56A16619B5; Mon, 31 May 2021 13:44:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468678; bh=KHU6nK91ps5fgJ0M+8gUgacb8bal347koAIiWci8V5k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s7TZu4/qAOymrqL9Ltq6xzAk9h+QlcCwF7iEKYcwlZkRbrKCxZzL101IW/EFpPgkS IkIOv/fLvvzGqBnh+B5snC+3vxQQ8LEJUueQ3PK1SCwKaHle50mmEat1kPU8O7cgad RwQtlhEbbuHty7b3VuGpddHJyFMzy2zbHYG1GaKk= 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 5.4 083/177] i2c: i801: Dont generate an interrupt on bus reset Date: Mon, 31 May 2021 15:14:00 +0200 Message-Id: <20210531130650.769485625@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130647.887605866@linuxfoundation.org> References: <20210531130647.887605866@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));