From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02838C43461 for ; Thu, 10 Sep 2020 16:20:52 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9B0712075A for ; Thu, 10 Sep 2020 16:20:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="2/R2qsqb"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="qio5Y/ng" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B0712075A Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vN62JwkmBicuR/0ieojiSnjnMzY9Czp+ZWUT8HQ+YvY=; b=2/R2qsqbYVTalgF2GlsYeh38n lAo7yrzjd7F/2GZ2yj/vV7wqcuFWnQv6pKjre6ALIMvn6lhGY6dEv5YDu6pMNNMZGIETsh6UGyn9W Kq4IQky+zcezA4u7UOM6jySOdvZehwFF/Ls/5Wb7RBkSYEXdmi8M/RfdvaotiTv8rmDmSrodYVX0Z 00wwaNRigdMjeB+BcQxr5hX+lF2nZFg0WydAgdW889W79OySSwbpXj5KRFVb7gMqi+S2tMqg5MKhc tShPp5kv0S/OCHN214PQO5M5+tEHt8vjUMu8Q49DxjvpuDd3gLBcTZohYGbZQuD8vKNN7mEnoI2+i qjyQDMfMw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGPII-0003eS-Pb; Thu, 10 Sep 2020 16:19:30 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGPIE-0003bM-ED for linux-arm-kernel@lists.infradead.org; Thu, 10 Sep 2020 16:19:27 +0000 Received: by mail-wm1-x343.google.com with SMTP id l9so656187wme.3 for ; Thu, 10 Sep 2020 09:19:23 -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=FMPZ+VzJ+cGDOwRKaJNQBA78kSsKgAl4Rh0tiwYlTzE=; b=qio5Y/ngq6hLvVhm2468rrq1KMTKqMD6reAUvBjeUZg28PU5pE4JmNKzEpw8Dq+ZXy +EBIltpVv7QGDdAn4nxre70MoBcYp+ZbE2Ys3VULwUK1yP0HL3DasnxQfvmF0gkR+Q2w XXXT1jlovgPhzmb2Azi56ku1TTdNZxdn+K+kr78m2GsuiuQXY9gX12qF88KkpZnemGhJ MJssQE/2khIJzxVKek0/2AchROZlEnhoQlFEPM6sUEfKgfy2CAq/Yh22tkigFm698koO mMAoFZxYY/mBcRNr6lIqxmYIA0Po3F0jG8at5Ra3VRYBbSP1Kv4QWYrVQtLIm0bvwx1e m4lg== 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=FMPZ+VzJ+cGDOwRKaJNQBA78kSsKgAl4Rh0tiwYlTzE=; b=SgkVx4kU3CKZLRFpkUf2a/ml4cg7wXb9FgcHY4KIe3ZFqNXoyOaBafFHlX/fZXDiRi NFRvH7rOgdp6Kw2SpyFvi9lq5Ei78abQ+iU0CrVe72ArOvLX7ns7k8l/QXqLKY4Halzz +Yh+8ZCtMPwPIw8yuKNujwuKhKumfBlIN1bS6HJvXHiEciQCm6ONznAj3ndEV3vfSUOY o4RgcZ72+NV2wFwiCz6N/vXIdqLQonVsWRyw0XmZbxUFAVR4vqhJznmIys7uGjYoJ0Fw IWu2cdVgZq/mDclv5r0TeKhMxqu27glNLcSX+kc2DmVKoTIegLCX61Ge8u4iPSieRWsy WsLA== X-Gm-Message-State: AOAM533GD5LMrYnpMXzes1kjeTpByTFhIYHvZOqzTaf0gq8Jm2PiAjko uMAwQEhTPHXFGq3QZGPKpwM+WW6t/YSSohplTG9ERA== X-Google-Smtp-Source: ABdhPJyoPsL8Lmtmn7sZD3Htvbk1/voqEAiS4Xrou0lgQ0ny/1SONHlnFGvvgkm/zl3krXuPxJMxMt2fP0vpplN7tBI= X-Received: by 2002:a7b:cd93:: with SMTP id y19mr760920wmj.112.1599754762218; Thu, 10 Sep 2020 09:19:22 -0700 (PDT) MIME-Version: 1.0 References: <20200907134055.2878499-1-elver@google.com> <20200907134055.2878499-2-elver@google.com> In-Reply-To: From: Alexander Potapenko Date: Thu, 10 Sep 2020 18:19:10 +0200 Message-ID: Subject: Re: [PATCH RFC 01/10] mm: add Kernel Electric-Fence infrastructure To: Dmitry Vyukov X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200910_121926_533362_3FA0D421 X-CRM114-Status: GOOD ( 25.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , "open list:DOCUMENTATION" , Peter Zijlstra , Catalin Marinas , Dave Hansen , Linux-MM , Eric Dumazet , "H. Peter Anvin" , Christoph Lameter , Will Deacon , Jonathan Corbet , the arch/x86 maintainers , kasan-dev , Ingo Molnar , David Rientjes , Andrey Ryabinin , Marco Elver , Kees Cook , "Paul E. McKenney" , Jann Horn , Andrey Konovalov , Borislav Petkov , Andy Lutomirski , Thomas Gleixner , Andrew Morton , Linux ARM , Greg Kroah-Hartman , LKML , Pekka Enberg , Qian Cai , Joonsoo Kim Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Sep 10, 2020 at 5:43 PM Dmitry Vyukov wrote: > > + /* Calculate address for this allocation. */ > > + if (right) > > + meta->addr += PAGE_SIZE - size; > > + meta->addr = ALIGN_DOWN(meta->addr, cache->align); > > I would move this ALIGN_DOWN under the (right) if. > Do I understand it correctly that it will work, but we expect it to do > nothing for !right? If cache align is >PAGE_SIZE, nothing good will > happen anyway, right? > The previous 2 lines look like part of the same calculation -- "figure > out the addr for the right case". Yes, makes sense. > > + > > + schedule_delayed_work(&kfence_timer, 0); > > + WRITE_ONCE(kfence_enabled, true); > > Can toggle_allocation_gate run before we set kfence_enabled? If yes, > it can break. If not, it's still somewhat confusing. Correct, it should go after we enable KFENCE. We'll fix that in v2. > > +void __kfence_free(void *addr) > > +{ > > + struct kfence_metadata *meta = addr_to_metadata((unsigned long)addr); > > + > > + if (unlikely(meta->cache->flags & SLAB_TYPESAFE_BY_RCU)) > > This may deserve a comment as to why we apply rcu on object level > whereas SLAB_TYPESAFE_BY_RCU means slab level only. Sorry, what do you mean by "slab level"? SLAB_TYPESAFE_BY_RCU means we have to wait for possible RCU accesses in flight before freeing objects from that slab - that's basically what we are doing here below: > > + call_rcu(&meta->rcu_head, rcu_guarded_free); > > + else > > + kfence_guarded_free(addr, meta); > > +} > > +void kfence_print_object(struct seq_file *seq, const struct kfence_metadata *meta) > > +{ > > + const int size = abs(meta->size); > > This negative encoding is somewhat confusing. We do lots of abs, but > do we even look at the sign anywhere? I can't find any use that is not > abs. I think initially there was a reason for this, but now we don't seem to use it anywhere. Nice catch! Alex _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel