Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2668037pxj; Mon, 31 May 2021 07:50:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPfaEiT4kQ877s83yfiRtitLH+ebcalfQiaEQUijZdxAOAC4iYtjavp8jkTT15tXH2AIFg X-Received: by 2002:a05:6402:27cf:: with SMTP id c15mr25856134ede.130.1622472621642; Mon, 31 May 2021 07:50:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622472621; cv=none; d=google.com; s=arc-20160816; b=NCzOzniP+r+s9J+hyfY8X/LoUihOxvcSMCpsi3+VSwpR36UA4pCLVkj2s0jLDxTrjw LWLlIP/+rnzHdAoYfWuqCl9cjF9CNwxR8cAb1lq+9j3wkSaih04GLbyEVj3pi/k65FdB B/bqC2xnlpb0omf/VDYMJb+lKuk89RfK6RWB6/3gcDQ7inPddu5p/zwzxStQu6dGoCTE IyLnKY0zjGL/Sv9rmJG7Bt3X5OxEHerejI+JUm7AB5k8G3OW0BXRCdDYvPEvhOOYVEZL gVQIQLL0qfHp5xaAswfKnI556lNfaMRDCarYR5TU3+7E6fo0tfnIU5iKkPRM5YgD2Dxl fA9Q== 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=4y1AYTjTfP6Eoki1fKUmOt9UyEO+2LMYvxD/0Ub7yLI=; b=PO9C/NrsXHH94RWmercwokE82p0LuS+W/Pv1gvBCDEou2L9wT/+oafKR0AQ3oKtr0Y QFPz4b5Qsngow9QsUPThyfgp5cHzOCTkJX7OajHbEi/RzLc1e1LyGWwBf49b9J4cgQ8X Q0rthsN5o9haOsIgQD8ZvVvAN9TPaVtgNlpSAeRBE10C/rzjiPaG2VtW8KTZswUiDmse 0Hzscusce6Y/iTNq5avo7+4kEx+G8tPT6uN57ARUt2fPpSF3k/YG8djEH2Trmu+d6LmP W+b/ukKFz01aThqEW6I3uzjgxCMFEP0kUf2eC7JXlCh7YOU8u1F7a9bUMJltlHfizQ7J qYXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CeHK+aNp; 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 g8si13028351edb.70.2021.05.31.07.49.58; Mon, 31 May 2021 07:50:21 -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=CeHK+aNp; 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 S234096AbhEaOtY (ORCPT + 99 others); Mon, 31 May 2021 10:49:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:36870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232775AbhEaOBW (ORCPT ); Mon, 31 May 2021 10:01:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3FFD661946; Mon, 31 May 2021 13:36:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468206; bh=hJioXbNkRjbaQfSnF3a1N7TLMXw8gCIegzDRoHUU3DQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CeHK+aNp8mgg7eaAMMfJr1Phg/JzcidsS2lwyVfEU5OJJE91ZKmDAXcji0z2x5Sg7 PP3KSGL9rm87QoDfS/x7l8j+VQaavkLD6NmMz9Km59t3457BmHVHuGOC8tnyGRu5ix 7A/t+bb+OxOtOEmwvacZPZ3oLAgzQ/+XWWOtjxMY= 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.10 122/252] i2c: i801: Dont generate an interrupt on bus reset Date: Mon, 31 May 2021 15:13:07 +0200 Message-Id: <20210531130702.144134040@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130657.971257589@linuxfoundation.org> References: <20210531130657.971257589@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 @@ -391,11 +391,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));