Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp533821imn; Wed, 3 Aug 2022 14:32:01 -0700 (PDT) X-Google-Smtp-Source: AA6agR4/oQU9zxVw+oPbrd48ZU6ZZqmAtnoJLlbWJ3ywsckdJJOn9LKPIRDyjqTQuzSaWhapkSF2 X-Received: by 2002:a17:90b:1e08:b0:1f5:3874:492e with SMTP id pg8-20020a17090b1e0800b001f53874492emr6945941pjb.82.1659562321448; Wed, 03 Aug 2022 14:32:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659562321; cv=none; d=google.com; s=arc-20160816; b=i3M8ZgGFneZhNd7DnxYj9f8E4++sKPz8aaouYQfkoBoDJW3dryAzh+JaAWnQ3lyVyT qCx/RWv421QIZEL/6HYJ9Uabnbs3mZAnxlY5m1xsiSxSVXQwWX2gSYCgBuSrdlwWCfC7 KT7iUPC959T6l8EcfDR4/rUiZkmqbVnbDP5RWSa7K62LfBPCJ4zkaKFN/t6ublkPKvkc muyfuqloLVGUh4oIWITX7cIFEa5vEGiRS0/jvG2hjSTx47JzGxlywwcGCDBVEuC9nv5z BZ7FkiUpy9wT/vRiMebiKg47jEQVwzfqYRv4b1y4YqZ5KawseAK0ca3wBhHTfaFboVSB 17BQ== 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=C8saFETww7GFwNaVKj2+9mgk73FWbmx4D6GhCwjyv5M=; b=k/hLQXQvd1LlQJ1WjQKESRnis9KrmVIzIgcCmMMDwseKVKukGjFyPVvgp3cgQwK2FX fnyQwSLDDp881TviiDfhfZ6VughJWnWGS2lRyo7ggSrZ+EVr1dNVNicPnTa1MwxnpSNp KtL2+CT7gpVRzf4qRV2rdBiRzEZxmu07qpXRH8qVIf9SnUj53Oj1j+aTUimHjGVmSreA QrQzRQuXyVvaXro7ondRDY/mFbPL97JZgtYPY+FoSzYGErvZ38MsGbqWmJtWeLcy3SCc Ee09viMlQg1KFIAiyWfhiJykRxSFxIUlqu9PhWUKnp/AO9+G9GvqtVAK533IZIq4QyYc Mbcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=dtquUVtE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h7-20020a170902f54700b0016ef8a85941si3834884plf.496.2022.08.03.14.31.46; Wed, 03 Aug 2022 14:32:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=dtquUVtE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S238716AbiHCU3c (ORCPT + 99 others); Wed, 3 Aug 2022 16:29:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238725AbiHCU32 (ORCPT ); Wed, 3 Aug 2022 16:29:28 -0400 Received: from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com [IPv6:2607:f8b0:4864:20::b34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C91E25B7B1 for ; Wed, 3 Aug 2022 13:29:26 -0700 (PDT) Received: by mail-yb1-xb34.google.com with SMTP id 123so30107733ybv.7 for ; Wed, 03 Aug 2022 13:29:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=C8saFETww7GFwNaVKj2+9mgk73FWbmx4D6GhCwjyv5M=; b=dtquUVtEm7eDqX1KhcLh8OG00MYA9mSMXcpdMJAmFidFvZzAXptIdhxhQ9CDvUoxzd vU2nams+2CWA6TGpDhOXwF9jzfex88IXhKUPhevREfzcXVgK/lSzcKgHaLbTSoRzH98Q rxSLgycwNz21N88HbezJz6PPxhZEH9nLZ54Elmy4gTO19Xo5ues1xh9ivwU288T7Omli SlgkEIqVMn/Qko2uEeTHptGkLznvws+vwtK3WMCI7EATm7GDNYnwT7WIdMP9pXtU/wJ8 YX+dOjm5ODwXpGv+Itz40X1uo4tzK5WdLxIS/2ibk9ju+OCNIamGs3uJAhyqHfEK7GdR T9ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=C8saFETww7GFwNaVKj2+9mgk73FWbmx4D6GhCwjyv5M=; b=BhVlIJKh+QxvKj+6q/rWG3oCCJyTl0tdlcYiQW/foxHmZXjmoHsBjYNNY3X4PCsMNA Wor2tIHtYFy65N4mnrA8o5L4HYbXhOzFR8VT+eTp//zx/6a7p7+BdiQCbuGeVQEWePZ+ PAlY71IMYyMuve3HF2hxTap7e0oxSERJc2959N8r7a2Ksc9unTRHm/S5qr2xmZFskgsF 7aha54rzrEqYHw5B4TFztAglN/Zos4MViPO4UVVNmdOp4q10aKQs5KAr0/BzCIFX1CrD KIgMxAaVxacEMbt7h2SnAG2WMeu7KNL+nCaQsZ+aQlT+hhOSEl32FOikccAnvirwhaN1 gVjQ== X-Gm-Message-State: ACgBeo2+hDRoDjYH8015U8o3AwBcvgn3ss+z4J6NmOVnUielRpAvr5kS zUKX7RzOkM/fOwObZ+46atmFEJ1g+dugs/eT/hP5Dw== X-Received: by 2002:a25:2454:0:b0:67a:7426:25d9 with SMTP id k81-20020a252454000000b0067a742625d9mr3223631ybk.93.1659558565851; Wed, 03 Aug 2022 13:29:25 -0700 (PDT) MIME-Version: 1.0 References: <0e910197bfbcf505122f6dae2ee9b90ff8ee31f7.1658189199.git.andreyknvl@google.com> In-Reply-To: From: Marco Elver Date: Wed, 3 Aug 2022 22:28:49 +0200 Message-ID: Subject: Re: [PATCH mm v2 30/33] kasan: implement stack ring for tag-based modes To: Andrey Konovalov Cc: andrey.konovalov@linux.dev, Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , kasan-dev , Peter Collingbourne , Evgenii Stepanov , Florian Mayer , Andrew Morton , Linux Memory Management List , LKML , Andrey Konovalov Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2 Aug 2022 at 22:45, Andrey Konovalov wrote: > > On Thu, Jul 21, 2022 at 10:41 PM Andrey Konovalov wrote: > > > > On Tue, Jul 19, 2022 at 1:41 PM Marco Elver wrote: > > > > > > > + for (u64 i = pos - 1; i != pos - 1 - KASAN_STACK_RING_SIZE; i--) { > > > > + if (alloc_found && free_found) > > > > + break; > > > > + > > > > + entry = &stack_ring.entries[i % KASAN_STACK_RING_SIZE]; > > > > + > > > > + /* Paired with smp_store_release() in save_stack_info(). */ > > > > + ptr = (void *)smp_load_acquire(&entry->ptr); > > > > + > > > > + if (kasan_reset_tag(ptr) != info->object || > > > > + get_tag(ptr) != get_tag(info->access_addr)) > > > > + continue; > > > > + > > > > + pid = READ_ONCE(entry->pid); > > > > + stack = READ_ONCE(entry->stack); > > > > + is_free = READ_ONCE(entry->is_free); > > > > + > > > > + /* Try detecting if the entry was changed while being read. */ > > > > + smp_mb(); > > > > + if (ptr != (void *)READ_ONCE(entry->ptr)) > > > > + continue; > > > > > > I thought the re-validation is no longer needed because of the rwlock > > > protection? > > > > Oh, yes, forgot to remove this. Will either do in v3 if there are more > > things to fix, or will just send a small fix-up patch if the rest of > > the series looks good. > > > > > The rest looks fine now. > > > > Thank you, Marco! > > Hi Marco, > > I'm thinking of sending a v3. > > Does your "The rest looks fine now" comment refer only to this patch > or to the whole series? If it's the former, could you PTAL at the > other patches? I just looked again. Apart from the comments I just sent, overall it looks fine (whole series). Does test_kasan exercise the ring wrapping around? One thing that might be worth doing is adding a multi-threaded stress test, where you have 2+ threads doing lots of allocations, frees, and generating reports.