Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2799830pxv; Mon, 12 Jul 2021 02:06:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7b2WStdp8BwHtmaYijo8ivcb3sWcmqDt9QyYZ4thoqY3R+66QysETKADMxSFLQUgb5aa8 X-Received: by 2002:a05:6402:90a:: with SMTP id g10mr63652841edz.365.1626080816882; Mon, 12 Jul 2021 02:06:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626080816; cv=none; d=google.com; s=arc-20160816; b=z21or2fVrpiEFml9SwvjPDZrogFqH+KmVOnBZ3naibnoEA8jfJOdU29pwEYbVn8YQL Gz2h5kvsKLXXrUdKLfzT3zdLYPrp5Mc675dbzpcZ9G3/A99IJYJQ1tU4H7QmahB5eBHb Mh48a3ypS5Elm7oLAv1A1MpVmQTf56qjQH/3C3XhSqUYO6H8gLu6i7bVQ6RQkHindwIv QYzM26Ro2Rz03YQzMGohPya/08NwCNV+Ng/KlcqHgg2+gRWJnVYJ2x5r003oX4x907Au XKp9AnEobOVl3gU2kr/B+VY0JNp2U/p/XzQDpXLWRyUDeLObEK253aGMZrqpGaEi2M1O lRTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=GgE0FWkO8JWUO4cVKUcqsm8tHbhPiWes0Rs6BBjbla0=; b=p7MTGCfbtPvO0DL9XoJ33FP1PI1GrAhruhAa+4KpE5Jq7gEKptSuu154pYnG9Vubiv dCJdM8XoPBGKjGNoAZALXSruq0BwoMtRVrAi6gtiPbxv9lfC/WBvolqo03YyqZGQyYsv 35knPpZBYChWlYOHAp6qCZe6s2aFTgXw/KRQWk2QR+rKpCAOMEItq8KQK10YWFdxdzH4 aVsluMYV4OE+7ArvEK9fIu831lc9qMSm3YCrXjf85g0KR47znzu28heey2hcXjumbp2a sL/47Ra6F8SUej4KZ/Ro1J2l3bKgKnHzexx/iOtrpDPMXl0gUgFOqAMVw7uJ1+Np9osA 6klA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lc12si6080674ejc.671.2021.07.12.02.06.34; Mon, 12 Jul 2021 02:06:56 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354205AbhGLJIX (ORCPT + 99 others); Mon, 12 Jul 2021 05:08:23 -0400 Received: from foss.arm.com ([217.140.110.172]:50646 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378130AbhGLIkR (ORCPT ); Mon, 12 Jul 2021 04:40:17 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B82071FB; Mon, 12 Jul 2021 01:37:28 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.2.95]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D21A03F694; Mon, 12 Jul 2021 01:37:25 -0700 (PDT) Date: Mon, 12 Jul 2021 09:37:17 +0100 From: Mark Rutland To: Andrey Konovalov Cc: Sam Tebbs , Robin Murphy , Andrew Morton , Linux ARM , LKML , Catalin Marinas , Dmitry Vyukov , Alexander Potapenko , Andrey Ryabinin , Will Deacon , Marco Elver Subject: Re: [PATCH] kasan: fix build for CONFIG_KASAN_HW_TAGS Message-ID: <20210712083455.GA85732@C02TD0UTHF1T.local> References: <20210708144411.25467-1-mark.rutland@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 10, 2021 at 09:16:14PM +0200, Andrey Konovalov wrote: > On Thu, Jul 8, 2021 at 4:44 PM Mark Rutland wrote: > > > > When CONFIG_KASAN_HW_TAGS is selected, uses _RET_IP_, > > but doesn't explicitly include where this is defined. > > > > We used to get this via a transitive include, but since commit: > > > > f39650de687e3576 ("kernel.h: split out panic and oops helpers") > > > > ... this is no longer the case, and so we get a build failure: > > > > | CC arch/arm64/mm/kasan_init.o > > | In file included from arch/arm64/mm/kasan_init.c:10: > > | ./include/linux/kasan.h: In function 'kasan_slab_free': > > | ./include/linux/kasan.h:211:39: error: '_RET_IP_' undeclared (first use in this function) > > | 211 | return __kasan_slab_free(s, object, _RET_IP_, init); > > | | ^~~~~~~~ > > | ./include/linux/kasan.h:211:39: note: each undeclared identifier is reported only once for each function it appears in > > | ./include/linux/kasan.h: In function 'kasan_kfree_large': > > | ./include/linux/kasan.h:219:28: error: '_RET_IP_' undeclared (first use in this function) > > | 219 | __kasan_kfree_large(ptr, _RET_IP_); > > | | ^~~~~~~~ > > | ./include/linux/kasan.h: In function 'kasan_slab_free_mempool': > > | ./include/linux/kasan.h:226:34: error: '_RET_IP_' undeclared (first use in this function) > > | 226 | __kasan_slab_free_mempool(ptr, _RET_IP_); > > | | ^~~~~~~~ > > | ./include/linux/kasan.h: In function 'kasan_check_byte': > > | ./include/linux/kasan.h:277:35: error: '_RET_IP_' undeclared (first use in this function) > > | 277 | return __kasan_check_byte(addr, _RET_IP_); > > | | ^~~~~~~~ > > > > Fix this by including explicitly. > > Hi Mark, > > Marco already sent a fix for this. It should be in the mm tree. > (Although the link to it in the Andrew's notification email doesn't > work. But they rarely do :) > > > As a heads-up, there are some unrelated runtime issues with > > CONFIG_KASAN_HW_TAGS and the recent arm64 string routines rework, which > > I'm looking into now. If you boot-test with this applied, you should > > expect to see those. > > +Sam, +Robin > > Looks like the new strlen routine is making accesses past the allocated buffer. > > The guilty commit is 325a1de81287 ("arm64: Import updated version of > Cortex Strings' strlen"). FWIW, I already have a fix for this, I'm just cleaning it up and will post shortly. The issue is that the new strlen() will make unaligned 16-byte accesses within a naturally-aligned 4096-byte window and over-read by up to 15 bytes; we can fiddle with its alignment fixup to always align to 16 bytes when MTE is in use so any over-read is within the same MTE granule as the final byte of the string. I've checked the other routines, and AFAICT they never make accesses which staddle a 16-byte boundary. Thanks, Mark.