Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3961258ybb; Mon, 23 Mar 2020 10:52:59 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvVbHGLbz0IadIrrj72GPIczDehdLj/2aMNyaTD6wlPgA8Qcy9idKvxqAt1cIXL9eUhYtYe X-Received: by 2002:a9d:708a:: with SMTP id l10mr19788292otj.152.1584985978934; Mon, 23 Mar 2020 10:52:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584985978; cv=none; d=google.com; s=arc-20160816; b=sCkJE3tw2umKRumJ8SrX+55ThQ+N0QuGYb9ClB+W/i7lx6u9vt3Tl1Ix4gSH9CqL1v 5rfj+9fia+SH/5AyYHwNf0c458/+pmyYUB4/OG2pzFXJS2iDZSpk9nGzTw0M+FERvTGO mQaacPdCE4/INQR9BdivrXStEEyNzyR4YaZZR/YCY2FhNMuTPVkM0z58F34K3CFtu7Uu dBCXs8lNBXhRqRJt7I4awMr/c2x0r9Uw7UaGB37BsrcmCtIOtVLEuy30qbkC4XkU8VDz 5pqgyaVA/Z2G4hlEd5wC8F3wNJwDHJXKIDoeq+nrr/VmcwCG0xACCxMM+BB7IJ9vPvWf xP6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=LHKF9dJuaIwYSwVXm4FR8tNWEvLuZ3goOL/q83QgEYw=; b=tvm5w0DIk2tspW7l46o18tk06RanP/qFTIBVevWw3SF9UHHj1ZyPUF5K5nGUQ3yEys YxGGkjEyV7ZBW91fUvUTyWX1f42iL/ZDCvu8cKO873+DqIR9bkg0LvcnFQEQXcNrPdzz 2X1KeN6kL3cKWsT77vcVbZih/oOwtyqTxfebREYrUAtNeqsXGVLU/rvFOQfLJ1qgOLZZ wG1HkAtGfyi3UeGzZq5n5hNZjMl3Yl4t/dj6fGl6ZsGX0ndYHUV/tLS4hcr2kJQvvwak JDznQtR89FtZPiq7kE1/Hvrffq8mwflNORtUCu1qmlIHhQMKjb2XkGV9tvwkkoCKep+J 6i3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x2si7313300oix.42.2020.03.23.10.52.45; Mon, 23 Mar 2020 10:52:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727611AbgCWRvX (ORCPT + 99 others); Mon, 23 Mar 2020 13:51:23 -0400 Received: from mx2.suse.de ([195.135.220.15]:44468 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727160AbgCWRvX (ORCPT ); Mon, 23 Mar 2020 13:51:23 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 5AE11AE89; Mon, 23 Mar 2020 17:51:21 +0000 (UTC) Date: Mon, 23 Mar 2020 18:51:20 +0100 From: Jean Delvare To: Dan Carpenter Cc: Daniel Kurtz , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot Subject: Re: [PATCH] i2c: i801: Fix memory corruption in i801_isr_byte_done() Message-ID: <20200323185120.1a5cd734@endymion> In-Reply-To: <20200323093733.GA26299@kadam> References: <0000000000009586b2059c13c7e1@google.com> <20200114073406.qaq3hbrhtx76fkes@kili.mountain> <20200322231106.3d431ced@endymion> <20200323093733.GA26299@kadam> Organization: SUSE Linux X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 23 Mar 2020 12:37:33 +0300, Dan Carpenter wrote: > On Sun, Mar 22, 2020 at 11:11:06PM +0100, Jean Delvare wrote: > > Definitely not correct. The first byte of the block data array MUST be > > the size of the block read. Even if the code above does not do the > > right thing, removing the line will not help. > > > > Yeah. I misread the code. > > > Is it possible that kasan got this wrong due to the convoluted logic? > > It's late and I'll check again tomorrow morning but the code looks OK > > to me. > > KASan doesn't work like that. It works at runtime and doesn't care > about the logic. > > https://syzkaller.appspot.com/bug?id=426fc8b1c1b63fb0af524d839dfcf452f2d858e2 > > At the bottom of the report it shows that we're in a field of f9 > poisoned data so it's not priv->len which is wrong. (My patch was way > off). > > mm/kasan/kasan.h:#define KASAN_VMALLOC_INVALID 0xF9 /* unallocated space in vmapped page */ > > The logic looks okay to me too. So possibly this was a race condition > or even memory corruption in an unrelated part of the kernel. I checked out the exact kernel version this report was generated for, and the faulty line is: 592: priv->data[priv->count++] = inb(SMBBLKDAT(priv)); This would suggest the problem is with priv->count growing beyond the end of the array, however the fact that we land in a memory spot full of 0xF9 kind of excludes this possibility (the data before the spot would contain different data if it was the case). The other option is that priv->count wasn't initialized at the time it is used. However I can't see how this could happen, given that the priv structure is kzalloc'd. So, to be honest I can't really see how priv->count can get wrong. So I would be tempted to lend towards the theory that the i2c-i801 driver was a collateral victim of a memory corruption happening somewhere else in the kernel. Wouldn't Kasan catch this too? Is it possible to access the other Kasan reports from the same test run? -- Jean Delvare SUSE L3 Support