Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp468042pxt; Thu, 12 Aug 2021 02:43:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0r+5hVRReyls0NwRJn7t61rdEluEaZKvHj5IphT+DBVWsb00qiwkjNa04gGF36DXDOjZ1 X-Received: by 2002:a05:6e02:1308:: with SMTP id g8mr2322230ilr.190.1628761402111; Thu, 12 Aug 2021 02:43:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628761402; cv=none; d=google.com; s=arc-20160816; b=caXQ74kq//92+emnxWwdb8C3srSPUjRIGME5U8yjIV2JItTFdA7HwJKbmNf9jTTcZJ VQkb+d6ZbB0ir+VfVK9ds62tHistJG141GykltO1QiWT2fKFN2Y3R+DQariJbviMe8dM Ia8COkEMTORr8lYCNBlTgredSUuOPiIs622ahqrVsMVj48hMkU9fyMqmn6aVVSR6sPTX 5n06Ff60Oqa6xRXeb7V5EoHOopvy4U3RNeAcadRPqrAuXD42Tz9QRYgN1WJXMU799u1G Jc4OLIqsG7yzdZA4t7zka2rBKFFgxQ5GP9b2noFH+wgb7igz1jN7BD2Gh+kndx9M810u KQxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=CpNbFyXnXHPCTrfQK9jrNKENE4zlP3yIY6h8yYZAoL0=; b=l/qfpZxAeYBgF6eZF0k82ocXiSB4TaNxHdYEtJBmD7gSXhaolm4AJSvEoelvKaGeV5 +gHKgKqvbsDDFPXvdduMNOw2/sZR9rkL8NsA4hz1w577edF6awMawvA/bTbyqV2T3r7G xdoqSTawB9oo5fYGpS5rcPrtmEjAMmyc9I3IVBMrQHqgn4WI9uqjoRyjKEimIHkfrbWF PNm6iqK0y6xx8WBwJEwnGDO1IGHQIaUeEIJorWSI/zcJDRtlmLUwUaDPWPItEukJAKSh trksSSv3/twK22hYZVnMKPk5IHa7aIZLEcYwED9DDRGWUmKMfCkAdWNgc2IFBsFBvp8w D6nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=XKyvMwXf; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t16si2191491ilm.159.2021.08.12.02.43.11; Thu, 12 Aug 2021 02:43:22 -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=@google.com header.s=20161025 header.b=XKyvMwXf; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234184AbhHLI5X (ORCPT + 99 others); Thu, 12 Aug 2021 04:57:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231470AbhHLI5V (ORCPT ); Thu, 12 Aug 2021 04:57:21 -0400 Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87C4BC061765 for ; Thu, 12 Aug 2021 01:56:56 -0700 (PDT) Received: by mail-oi1-x230.google.com with SMTP id bf25so465483oib.10 for ; Thu, 12 Aug 2021 01:56:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CpNbFyXnXHPCTrfQK9jrNKENE4zlP3yIY6h8yYZAoL0=; b=XKyvMwXf6ld2suQ7v4o10/Mwzba2BnazQYjm/Mnva9F/4jx4nj2FjysWxq3ZQpPKs+ qcqWHbHCGNka/QHgern7puGDE0EdMCRkOYmgJw2oiPLTFMOwCXZtIiHVYjevSP70wb3y oZDKnKBtwE6F9K6DHixs8ztsAOx5w5UHCUNsVjxjqxjdp8qPp/jsqj1PDMn/oYFRpeAV I1iDgtnM1M4z7JMqs6Mio86xRD6mtDWHiAB8HVwxv5hUWbnG91XD+UOQ1NeEFqj43dJB BG46n7EmY3Zm/dbe4i4iOELegT/bA3SVUCpIYpsdvwTxQeaNb8EkPWnpLigVaQNHK713 IfGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CpNbFyXnXHPCTrfQK9jrNKENE4zlP3yIY6h8yYZAoL0=; b=exiFXGkmpblTM5s2cDr8Cr+1sioPyhIzTQfohr4KZ0iUUMSOTQDdgLm0L3QJulTsXr OJWqvpmylz632WfqAWgpHm2g01ms8Ivi/FhwBvwzHqYhr0zyEcq0kMNpl/1cBzYa1Bq3 V5iVq92pCNGTwZWpLzDNax4ovEGn39SFK/FZFywaTMz+ihv7BkhRCmRvuHJzE2Z57buT Y9myr6XkL4kHMllGb8QVg+8riOGDw2t6xYMu4Ov4bPaO/z7FC3ltraBZh4iPqPEE22GR 67t2ec0eVYNbujFPx57HWol2tIt+Hn7dcunZKr395RBvF7l4Rh/UhFb3E+EgcP1dtjDw yoxA== X-Gm-Message-State: AOAM5327gucmx9dv0RVS9jp8pqc9dSYQIFWPJEyP3krxwnzHU0a/E4pu Jpo2d06HJksWkWmlQnNhE2dKFtRNOwLJJDxEfczxjw== X-Received: by 2002:aca:2316:: with SMTP id e22mr2503665oie.172.1628758615724; Thu, 12 Aug 2021 01:56:55 -0700 (PDT) MIME-Version: 1.0 References: <6e0ddf32ce140b9e8aaf127e9e40cbfff4430995.1628709663.git.andreyknvl@gmail.com> In-Reply-To: <6e0ddf32ce140b9e8aaf127e9e40cbfff4430995.1628709663.git.andreyknvl@gmail.com> From: Marco Elver Date: Thu, 12 Aug 2021 10:56:43 +0200 Message-ID: Subject: Re: [PATCH 5/8] kasan: test: only do kmalloc_uaf_memset for generic mode To: andrey.konovalov@linux.dev Cc: Andrew Morton , Andrey Konovalov , Andrey Ryabinin , Dmitry Vyukov , Alexander Potapenko , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 11 Aug 2021 at 21:21, wrote: > From: Andrey Konovalov > > kmalloc_uaf_memset() writes to freed memory, which is only safe with the > GENERIC mode (as it uses quarantine). For other modes, this test corrupts > kernel memory, which might result in a crash. > > Only enable kmalloc_uaf_memset() for the GENERIC mode. > > Signed-off-by: Andrey Konovalov Acked-by: Marco Elver > --- > lib/test_kasan.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/lib/test_kasan.c b/lib/test_kasan.c > index 0b5698cd7d1d..efd0da5c750f 100644 > --- a/lib/test_kasan.c > +++ b/lib/test_kasan.c > @@ -528,6 +528,12 @@ static void kmalloc_uaf_memset(struct kunit *test) > char *ptr; > size_t size = 33; > > + /* > + * Only generic KASAN uses quarantine, which is required to avoid a > + * kernel memory corruption this test causes. > + */ > + KASAN_TEST_NEEDS_CONFIG_ON(test, CONFIG_KASAN_GENERIC); > + > ptr = kmalloc(size, GFP_KERNEL); > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); > > -- > 2.25.1