Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp15005pxb; Tue, 12 Jan 2021 18:32:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJyG+ab1nKRSum+X5L25Z69jqbAQfysSzGvH1titXTpKV1+j62ivDEXiyuuw2MxXkBBA0S1A X-Received: by 2002:a50:9e8b:: with SMTP id a11mr8417edf.276.1610505146596; Tue, 12 Jan 2021 18:32:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610505146; cv=none; d=google.com; s=arc-20160816; b=jZfFbGshFKjGN4Biqj412R0AkV6YCkzRWdEhDlnFFRS59QCFvWq5wgKpxD5hGRR5Fh gJIRXGkdqAcocAw9N86V+XWxSfIHY8xNhNiwKxajbhdd0oTj0FO41JU60QA3HciVKYx5 MPv/laVPbI0mFmG/jdzNZcqwCNAkMNHgVhgKdepKj9O4QQONXBNJM/QAWy/FovBAuniV dZsqY9MVbP414bKMEFmggYSw+//C6sRwpWOuVq6eQIs4PG1yYkQandSxxL5Y2M+U6hj1 hrZmfozvEoq5E0h4nx9xDNe83a4ee20iilgijcOlFZUuOpxl+NEZmhomCus6Ul+sogYJ 31mA== 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=hLTG8Xi/M9/KLF1jIe2hcQQ+UFUOXooQujW3N5lnPGo=; b=qwuweRzYS6NuwT8gqsZxWBsWvnr4kRwARKg23lNLdzh1W5nR2KOpXnegHbWCQqajli UJ1fJei+ZLC+4J/1VMtyM9RW0RRD/zEyvl+sLPkkzmOU2UAX51r3p9fDYUTPEM+5NRHb ejDYotZqbah+915OnZJspegPS2LfLgVzfPr57aXnMnI13UjHm7VbxyY4od16KlgaYQs4 /4hdGHfny/9QpPcozOtQZBgEY5fGuwWXQuTChgdgQWSmLUuba2rFOqwmCLdfvEAnDETo hrPxqg9piTTr0ppuIhpUCYCTdPTxin7ch15p/PGo6AlrFhg7lAl6Ci4dNRq8WlAMmgv/ SjUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Cs+4su4T; 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 f6si276919edm.128.2021.01.12.18.32.02; Tue, 12 Jan 2021 18:32:26 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=Cs+4su4T; 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 S2437207AbhALVeP (ORCPT + 99 others); Tue, 12 Jan 2021 16:34:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436608AbhALUF0 (ORCPT ); Tue, 12 Jan 2021 15:05:26 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4474CC061794 for ; Tue, 12 Jan 2021 12:04:46 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id b5so2401275pjl.0 for ; Tue, 12 Jan 2021 12:04:46 -0800 (PST) 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=hLTG8Xi/M9/KLF1jIe2hcQQ+UFUOXooQujW3N5lnPGo=; b=Cs+4su4TJkM8QcOSmf0OcuHbESzt6w52kRbeUZamzlyoFwYvoll9zEhkOZveAYuCM+ Eu4sCnw4sn8/zHQxtY9yGVm1ndHlBVJ+/wsmnusUu0SvtVkGlIaOo8AHfduaWZao5NOw C2tq0o4CVrk60JxPesRFOB7f3uMf4a2Kk018t70tas3/41eADOJiuVyckst7tIkX05RJ qYtJW/L6l6mHyYAG0ds7lphmJbHYhQAtvUgy0RjYIX8XPh/psWdZdPHKWnPH1ajqUjUC wy+D5JV2GlFUC2NcGOq0Grm/S1ejHC7clYhKUFUceykGabKD9o4Tzy4VRGHs1Eh9IShM nyLQ== 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=hLTG8Xi/M9/KLF1jIe2hcQQ+UFUOXooQujW3N5lnPGo=; b=qOBW4W+DU19XszAHR/S9dWox4gCV4heQhurPsjICE/+RyRqN7J3MN7K+v3agFsTset ILmvtRSBBBfHeiqMTbVUd6hk5Q6eMXRJNkUaFQ2vEdd3j3yArE5E51vYxl65eThYdX5i WbefSjD5axIiU93lDiSG+8L54Xh4LPtVYAWMm/zUgXFQaDN/7UsHr79uL1f73PcrT4Tn XG4QZ36l2ZRwF9rkOBT10suV2c1Cbz4OQ3D/jBW+27mAg60IWt6ZeuO5MysM8DO/e/qg r3Oc0h5r4s5cRZHfNwfc2Z/1EG9W0rfUZ/wXNPLZa0EbQSHHybCS/gBvswpwzrUp20fK jS6Q== X-Gm-Message-State: AOAM530zK6Q4XtGmVel3b0QBKDjfaZ87ANXyRZR6mB1aQWFRclD7/9Hq DCt/Fs/vSKXLL0TImjnKVibPf28sS0o2/0rymNRXyg== X-Received: by 2002:a17:902:c144:b029:dc:292e:a8a1 with SMTP id 4-20020a170902c144b02900dc292ea8a1mr826431plj.13.1610481885659; Tue, 12 Jan 2021 12:04:45 -0800 (PST) MIME-Version: 1.0 References: <9a4f47fe8717b4b249591b307cdd1f26c46dcb82.1609871239.git.andreyknvl@google.com> In-Reply-To: From: Andrey Konovalov Date: Tue, 12 Jan 2021 21:04:34 +0100 Message-ID: Subject: Re: [PATCH 08/11] kasan: adopt kmalloc_uaf2 test to HW_TAGS mode To: Alexander Potapenko Cc: Catalin Marinas , Vincenzo Frascino , Dmitry Vyukov , Marco Elver , Andrew Morton , Will Deacon , Andrey Ryabinin , Evgenii Stepanov , Branislav Rankov , Kevin Brodsky , kasan-dev , Linux ARM , Linux Memory Management List , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 12, 2021 at 9:26 AM Alexander Potapenko wrote: > > Nit: s/adopt/adapt in the title. > > > > +again: > > ptr1 = kmalloc(size, GFP_KERNEL); > > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr1); > > > > @@ -384,6 +386,13 @@ static void kmalloc_uaf2(struct kunit *test) > > ptr2 = kmalloc(size, GFP_KERNEL); > > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr2); > > > > + /* > > + * For tag-based KASAN ptr1 and ptr2 tags might happen to be the same. > > + * Allow up to 4 attempts at generating different tags. > > + */ > > + if (!IS_ENABLED(CONFIG_KASAN_GENERIC) && ptr1 == ptr2 && counter++ < 4) > > + goto again; > > + > > Looks like we are leaking memory allocated for ptr2 here? Will fix in v2, thanks!