Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2721630ybl; Mon, 19 Aug 2019 06:36:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxR+vyr1zKLeLgOVbjVh86H727LnZj6b4DD9d4mzPGN6CZzymS7XXL6Im6Do5cMGFfJSvsT X-Received: by 2002:a17:90a:fb8e:: with SMTP id cp14mr20321433pjb.54.1566221760979; Mon, 19 Aug 2019 06:36:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566221760; cv=none; d=google.com; s=arc-20160816; b=wsuTCLpIjESn8jAOxFazlats4iaGavNQdQ68zcSo5nOZ4rjbkqP4KqyWd+cURDVV8I VgJqlz3f7USll8WvJ0d3w+fdDauZs4b7LjUsaM4iGma64SE8ZKytEchhsJFR5v92wHec 5EGC4CY9hzyCvSRFxaNG3fEzFs8WmWA5/7Ekb/StSGAIdjxWGf20JeyYdB5CzroQT1CO QqmxnTrC+yS2Bb+byA583P3cynQ0bz9tZtWCjZgUBg4mMTS3IOMfUNZ90y2Mh3/nt2CY bZGQ/DFntz45d1ADbbk9jNeY5ZJHPiglTKB7Em8srDM6g86lPe5SFreDTYPp593G7nEX 0QgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=pk5oeETTspbM2Xu8ms+3yCnr7yu2efWo8trV1ib5KgU=; b=rrcjsN6/nsT1xiA/k7zwF85cNlPYQrsY+GyDOTL3exUhA9b+1snvVPnRG+MPVk96wd O5g1wfrPA3eCvHF14ldKdmx2ImJdE27q+9dcA5BRO5ABu7oVKFOI9QTqi5OmIR3Z/OdA XTnRkxKtoFryi9YO5208zqE3G/cR0lBsgWFdaNkDUpWSsQFCNzqPqi4qqi6bE4Te81J/ ECZQV7CYwFdbDdNELB2JP8fKmlFmFZPkfq7wxFTniRGWv7wv/I4R6mVk2mJut/jAWTSy 7jUYSlNOBladAcjjzUfm22g0mj2U58UhYUAX6riM3G5fWNNj5x8pjS2DwiJrPs8BP+7W cvig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mAkOdid7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u191si9752789pgd.281.2019.08.19.06.35.45; Mon, 19 Aug 2019 06:36:00 -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; dkim=pass header.i=@kernel.org header.s=default header.b=mAkOdid7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727512AbfHSNes (ORCPT + 99 others); Mon, 19 Aug 2019 09:34:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:49172 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727301AbfHSNes (ORCPT ); Mon, 19 Aug 2019 09:34:48 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3BF452085A; Mon, 19 Aug 2019 13:34:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566221687; bh=hKfeHuAsZv5gzXScdBCBmBovA3PHWMaHm8gHzstZO+Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mAkOdid7IAxnHFy+Few0/wS0kb50BeKhhXaCcF0XKsC019eIDOW2udcMISL+o/l3R ytR1sMp8Nsjgu4b0yXw8FGZLKBi1JGA9RLTfRtzvlGHN6i8A6mmT35uy8k1NFnMitj B/nGRJ+H6Z7TWGEGUN0zll1eIQ/FKo+Nlu22qki8= Date: Mon, 19 Aug 2019 14:34:42 +0100 From: Will Deacon To: Mark Rutland Cc: Walter Wu , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Catalin Marinas , Will Deacon , Matthias Brugger , Andrew Morton , Andrey Konovalov , wsd_upstream@mediatek.com, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] arm64: kasan: fix phys_to_virt() false positive on tag-based kasan Message-ID: <20190819133441.ejomv6cprdcz7hh6@willie-the-truck> References: <20190819114420.2535-1-walter-zh.wu@mediatek.com> <20190819125625.bu3nbrldg7te5kwc@willie-the-truck> <20190819132347.GB9927@lakrids.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190819132347.GB9927@lakrids.cambridge.arm.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 19, 2019 at 02:23:48PM +0100, Mark Rutland wrote: > On Mon, Aug 19, 2019 at 01:56:26PM +0100, Will Deacon wrote: > > On Mon, Aug 19, 2019 at 07:44:20PM +0800, Walter Wu wrote: > > > __arm_v7s_unmap() call iopte_deref() to translate pyh_to_virt address, > > > but it will modify pointer tag into 0xff, so there is a false positive. > > > > > > When enable tag-based kasan, phys_to_virt() function need to rewrite > > > its original pointer tag in order to avoid kasan report an incorrect > > > memory corruption. > > > > Hmm. Which tree did you see this on? We've recently queued a load of fixes > > in this area, but I /thought/ they were only needed after the support for > > 52-bit virtual addressing in the kernel. > > I'm seeing similar issues in the virtio blk code (splat below), atop of > the arm64 for-next/core branch. I think this is a latent issue, and > people are only just starting to test with KASAN_SW_TAGS. > > It looks like the virtio blk code will round-trip a SLUB-allocated pointer from > virt->page->virt, losing the per-object tag in the process. > > Our page_to_virt() seems to get a per-page tag, but this only makes > sense if you're dealing with the page allocator, rather than something > like SLUB which carves a page into smaller objects giving each object a > distinct tag. > > Any round-trip of a pointer from SLUB is going to lose the per-object > tag. Urgh, I wonder how this is supposed to work? If we end up having to check the KASAN shadow for *_to_virt(), then why do we need to store anything in the page flags at all? Andrey? Will