Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp534572pxb; Wed, 13 Jan 2021 09:26:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJxBWK1qPwsw6W+W8gXDsN8BXjQyMaxbDJam6F7BtGY+XPo9IlhbmjGcjYR9kyFPMUbQ3NtJ X-Received: by 2002:a05:6402:100c:: with SMTP id c12mr2766944edu.356.1610558812552; Wed, 13 Jan 2021 09:26:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610558812; cv=none; d=google.com; s=arc-20160816; b=BwkgCMSiF2eKDjdI/tj3ixgjhH4/EpMNBLnoC3ti4bPHqxyYJlM6IQPAVHcNbrEtpE 15n7YM8F4eBm5t+D3fd0d9whY23HsGNfzib3+lfU4KwWv17x9/bH1T9nSVkjNY3qFbDb MCWEgcZpFKriOH/tYl6U+byNpOuJVVdHF78zmXE6NHQB2iFl0ftyRlqikCJymTmbfu84 SYwi6qb0STACYofY99kOVL0HGNXrVhLQh0mVao2IKNn8Am+nVrI9R8RonSCZejngwGu2 mjqcG0BukWFuMhGS9TuHb2I9ki3jXScz6B16KNzJuUwk/dkR37l8kcqVK+oC4HYqq7CF AvKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=D1vwl0f2mresUg2Scd/Va0+q+JfPdFFKQF2Jvx8WJCA=; b=WSXL7irbJtHP+TB2qNA6KznBg+nBujtdRbfcdbqkhA3WYbg0vZdLEKpU5PADSidIDu i9LeVgfu9NYOjxgPj4MUXO8/4RdqL3gg0qmsqB5GGGM2xZZuNjjm50NJmIx4NqlLUgi0 vrNMt3uzR6WsHOyE9aOMlqZQDrDOvEcp8n0y633OE3Un75tjMLs+cHWedTEmeJG7QfM9 pC+q2a3jVYy863WFKljf94l1Adp1RSNEJge6UtRWByXRFLAREJ3n9dHKkYx+c8Yv93TB ffk9nZ9UcoKxqUgb+gpFBBqHv4nkK0EAdP43/HfdN+n1pkraqNS4vumr7CE3WtkIe6WW 3pAw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p22si1170437eji.449.2021.01.13.09.26.28; Wed, 13 Jan 2021 09:26:52 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727915AbhAMRZl (ORCPT + 99 others); Wed, 13 Jan 2021 12:25:41 -0500 Received: from mx2.suse.de ([195.135.220.15]:37528 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727896AbhAMRZk (ORCPT ); Wed, 13 Jan 2021 12:25:40 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 023E0ACF5; Wed, 13 Jan 2021 17:24:59 +0000 (UTC) Subject: Re: [PATCH 1/2] kasan, mm: fix conflicts with init_on_alloc/free To: Andrey Konovalov , Catalin Marinas , Vincenzo Frascino , Dmitry Vyukov , Alexander Potapenko , Marco Elver Cc: Andrew Morton , Will Deacon , Andrey Ryabinin , Peter Collingbourne , Evgenii Stepanov , Branislav Rankov , Kevin Brodsky , kasan-dev@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <7fbac00e4d155cf529517a165a48351dcf3c3156.1610553774.git.andreyknvl@google.com> From: Vlastimil Babka Message-ID: <25aa25d6-080c-ccfa-9367-fc60f46ff10f@suse.cz> Date: Wed, 13 Jan 2021 18:24:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <7fbac00e4d155cf529517a165a48351dcf3c3156.1610553774.git.andreyknvl@google.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/13/21 5:03 PM, Andrey Konovalov wrote: > A few places where SLUB accesses object's data or metadata were missed in > a previous patch. This leads to false positives with hardware tag-based > KASAN when bulk allocations are used with init_on_alloc/free. > > Fix the false-positives by resetting pointer tags during these accesses. > > Link: https://linux-review.googlesource.com/id/I50dd32838a666e173fe06c3c5c766f2c36aae901 > Fixes: aa1ef4d7b3f67 ("kasan, mm: reset tags when accessing metadata") > Reported-by: Dmitry Vyukov > Signed-off-by: Andrey Konovalov Acked-by: Vlastimil Babka > --- > mm/slub.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/mm/slub.c b/mm/slub.c > index dc5b42e700b8..75fb097d990d 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -2791,7 +2791,8 @@ static __always_inline void maybe_wipe_obj_freeptr(struct kmem_cache *s, > void *obj) > { > if (unlikely(slab_want_init_on_free(s)) && obj) > - memset((void *)((char *)obj + s->offset), 0, sizeof(void *)); > + memset((void *)((char *)kasan_reset_tag(obj) + s->offset), > + 0, sizeof(void *)); > } > > /* > @@ -2883,7 +2884,7 @@ static __always_inline void *slab_alloc_node(struct kmem_cache *s, > stat(s, ALLOC_FASTPATH); > } > > - maybe_wipe_obj_freeptr(s, kasan_reset_tag(object)); > + maybe_wipe_obj_freeptr(s, object); And in that case the reset was unnecessary, right. (commit log only mentions adding missing resets). > if (unlikely(slab_want_init_on_alloc(gfpflags, s)) && object) > memset(kasan_reset_tag(object), 0, s->object_size); > @@ -3329,7 +3330,7 @@ int kmem_cache_alloc_bulk(struct kmem_cache *s, gfp_t flags, size_t size, > int j; > > for (j = 0; j < i; j++) > - memset(p[j], 0, s->object_size); > + memset(kasan_reset_tag(p[j]), 0, s->object_size); > } > > /* memcg and kmem_cache debug support */ >