Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2739117pxj; Mon, 31 May 2021 09:31:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwms0iDBKdTaG61ADeBE8+PDS1tA1HSfs7d73vcmddimrb9bfbvwuK7o6Og1NAkzu2oXMEh X-Received: by 2002:a05:6402:2044:: with SMTP id bc4mr27335363edb.282.1622478670906; Mon, 31 May 2021 09:31:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622478670; cv=none; d=google.com; s=arc-20160816; b=JokVqdeuh5eXqyCEbN7JGa3cWYNXlvtkwrnKqTPTZN3WFPCTcc0K0LZ/ZBRQf89NMH Q3U67hmI/SDka5ZM2LyfXydVclCqZKtrkOly8WKf0sPiRCAYPeR4cR63Lx1fOtBpWNtW CYb9hKLK1Bguq+03/XN4Vwvi24LinBZH9XnxzurzyZspb31DVXmrpIFM0H0QTVkwlt9k wYNtJJkPbDawma19U5BFSxNJI6QU7XeOPNPjFmhtW8CIMyecbQ0AvECctBAWrbsE26dp /UU+jVIbuCY/W/fkSgxz+eWKhpEY5PZG8LkHZY620aQjt48h2VsASBfT5N0EY9ZAmEaR ip2A== 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=hHOwQRRSCruG0z/fj5ISIWZXY0Q3iXc0twmLH3AHCCk=; b=mAfMA89+tLdrtOvufSWD/2NxLPRYHwjA0ff6JQqz5ARqAbizeJFbZMs/cEhwVmMIpe QkcSSi7VxB64sdb3ajTXM7bI01ea8b84xEXs6FpqH2mxFDMcCXV9AHr+rZFn5xcNiH3A xUvMGnRk2rJpIz6zm1WeAx0wr89P5Lv4LP2WX1In+ugDNJ8Or8CmpUMm4EmCydf8w7w2 Jo+oc+XaZiu/A1Q4zaAYgFujB/MEK/6u//UQNKdQtrkpGz7mWPEpFLrOWl5+7XWOMz2R dddaBNr+b1fSXs0e4N7ujzs293xhR3PnjryzBFiLjSsdRU3xKrDd3c2GiJCkUtaZLToe wcoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=i6a3JRwm; 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 ao10si13162534ejc.33.2021.05.31.09.30.44; Mon, 31 May 2021 09:31:10 -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=i6a3JRwm; 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 S233754AbhEaQ3H (ORCPT + 99 others); Mon, 31 May 2021 12:29:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:39874 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234248AbhEaOpL (ORCPT ); Mon, 31 May 2021 10:45:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1C568613F0; Mon, 31 May 2021 13:55:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622469315; bh=M5Vqk5ugMIIh4h20ZWW0tucgDHWgiPHKo6LZY12DEQ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i6a3JRwm89OZ54RQUg5kBJMDt5Y0JVV9cm//xvw3K/RMFpao3zO1nn3jvEQJi7kRG MYjhAPYT5Kd2RXswo+4Xuo+D8aF0eQH/SOuCcmrlSJgA2kynZ7iJjvRQ4/oXz7U1bk v1GIeVBKpM59qfv31CvpaSSek1lJPVJrLsqt3bns= 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.12 151/296] i2c: i801: Dont generate an interrupt on bus reset Date: Mon, 31 May 2021 15:13:26 +0200 Message-Id: <20210531130708.944797002@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130703.762129381@linuxfoundation.org> References: <20210531130703.762129381@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 @@ -395,11 +395,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));