Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5E2AC6FD19 for ; Fri, 10 Mar 2023 23:42:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231994AbjCJXmo (ORCPT ); Fri, 10 Mar 2023 18:42:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231666AbjCJXmj (ORCPT ); Fri, 10 Mar 2023 18:42:39 -0500 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C007214B034 for ; Fri, 10 Mar 2023 15:42:31 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id a9so7265065plh.11 for ; Fri, 10 Mar 2023 15:42:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678491751; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=wv3F+wk4tZoGruUyDBY8Tbrsyth/dVYvCaYEldiyh3Q=; b=Ox7KVgJBLb9rm6JsETuakuJHSMU4Mye5N60VAL63b35LCFpVCrZ47RZ0YdDZoYyHas 9YzjOVH9kE0nUEmlXwchoURKM1YdQliIP/EIjmxVJdBKhNGiR7X1dCRALCWX7rRukyYL flT+6syTcuWzDCYeZWxfRg2ILWqpMcg/qW77ZFx8xRsLrx2nEb2rQgTV22a4Jd4bYmKz 11MKl2YV5qc2bYvsFFtgBCuy4gMyQgp7UVANzzkhprmkUra2ihlfT1K1Jo5pKaHFFhWe jdNlxfBqSIGSSK9s+eLNAEpJhKeys66ZyqvJ9xMPMzOVlg35+1xgnAUzQLnnnixVIZu9 uoSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678491751; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wv3F+wk4tZoGruUyDBY8Tbrsyth/dVYvCaYEldiyh3Q=; b=KnGgG8L68Xi+yKlUW1WGctwDLui9oHMw2vvd5lQai1eVVAjeNL1a90Pgm63SIAsRvN yRf8ySIl9raut38+x5vxXapt8Nx5qlnuC5pVkFoJ3GBb63fvO92chkqVE4I18pViZoyq Bf+U9KLzKiLk480vIFiyLl2fEopF5fSXsDg7rHBZj2p1BhTyzbzNHYqo8Cxd8z+6vkLZ VsSNtNVLIAnfMw/imzWUPWwtH+IXPMlLpOjfoMHsJFDULwBmHYUkto/AElttiIw5qXT8 8xL8ZpC/8KZh1wnintIhyTMBtUhEpU18S4n+aFp8bBJRQ0za95kwkJeSCdFS3Fb0GnVW pZsg== X-Gm-Message-State: AO0yUKVBCvBclsWgQcnrZV7cI2TVFFd4h2C/KkBrDNdx+Dc0GUnLd182 AmudF3JvxO9Y6/rSA4GFA7GvOVQPaSEzNnTiGcU= X-Google-Smtp-Source: AK7set+hMsDT01qnTcZNSkZv8IN+Geb7gdC+irQyVitodhIBGuYBI+MPnGGTeTlyBp1qcNpZQf2s3JgHZXtwQ7n4hVU= X-Received: by 2002:a17:903:2581:b0:19a:8bc7:d814 with SMTP id jb1-20020a170903258100b0019a8bc7d814mr10009307plb.13.1678491751206; Fri, 10 Mar 2023 15:42:31 -0800 (PST) MIME-Version: 1.0 References: <20230209031159.2337445-1-ouyangweizhao@zeku.com> <93b94f59016145adbb1e01311a1103f8@zeku.com> <2b57491a9fab4ce9a643bd0922e03e73@zeku.com> In-Reply-To: From: Andrey Konovalov Date: Sat, 11 Mar 2023 00:42:20 +0100 Message-ID: Subject: Re: [PATCH v2] kasan: fix deadlock in start_report() To: Catalin Marinas , Peter Collingbourne Cc: =?UTF-8?B?6KKB5biFKFNodWFpIFl1YW4p?= , Dmitry Vyukov , =?UTF-8?B?5qyn6Ziz54Kc6ZKKKFdlaXpoYW8gT3V5YW5nKQ==?= , Andrey Ryabinin , Alexander Potapenko , Vincenzo Frascino , Andrew Morton , "kasan-dev@googlegroups.com" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Weizhao Ouyang , =?UTF-8?B?5Lu756uL6bmPKFBlbmcgUmVuKQ==?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 1, 2023 at 6:00=E2=80=AFPM Catalin Marinas wrote: > > Yes. I'm including Vincenzo's patch below (part of fixing some potential > strscpy() faults with its unaligned accesses eager reading; we'll get to > posting that eventually). You can add some arch_kasan_enable/disable() > macros on top and feel free to include the patch below. Ah, perfect! I'll send a patchset soon. Thanks! > Now, I wonder whether we should link those into kasan_disable_current(). > These functions only deal with the depth for KASAN_SW_TAGS but it would > make sense for KASAN_HW_TAGS to enable tag-check-override so that we > don't need to bother with a match-all tags on pointer dereferencing. Using these TCO routines requires having (at least) migration disabled, rig= ht? It's not a problem for KASAN reporting code, as it already disables preemption anyway. The question is with the other kasan_disable/enable_current() call sites. But as within all of them, the code does either a single access or a memcpy or something similar, I think we can disable preemption for that duration. On a related note, I recalled that we also have a bug about using supporting no_sanitize_address for HW_TAGS KASAN. And Peter suggested using TCO entry/exit instrumentation to resolve it [2]. However, we will also need to disable preemption for the duration of no_sanitize_address-annotated functions, and I'm not sure if it's a good idea to do that via compiler instrumentation. Any thoughts? In the mean time, I'll send a simpler patchset without converting all kasan_disable/enable_current(). [1] https://bugzilla.kernel.org/show_bug.cgi?id=3D212513 [2] https://bugzilla.kernel.org/show_bug.cgi?id=3D212513#c2