Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6129173pxv; Thu, 29 Jul 2021 07:12:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPXtobn2/SNiDrpH3nVf3664+CWHURXgB2Rr+Mgka53xuPgvbugIXS2L0IWgncJ+TB/j71 X-Received: by 2002:a92:db4c:: with SMTP id w12mr4089524ilq.306.1627567935854; Thu, 29 Jul 2021 07:12:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627567935; cv=none; d=google.com; s=arc-20160816; b=EzwM+bg1Bfj5Qng9EGGoQaXHsGcdszwXLILdcOFlPNMcbrTM/XQnPy5vrsy52W18i0 R3lTN6S5159ipY5n8pDlzgfML2RzHbWn4r0KjYF4h/yhfPaOthg7njdGzgJ75A1LeQ6a 4U5gnpbcKUjRYZSXF0fueFwHJzW6sbCZ+nPxp94YH1vD5SJG+7xltUKgA03vMRssqJ1w 35KtABYT9GYXfS6kUpAYkdlO0caQS0hB42CWX5bjMvoF0qN6Sl2hwhZTsT5vrFoENn4i NJh1eoCP8M14wsjocsB7geW6tuQq1L1ZK9RlWBVZRmNR6Auvbu5LBwkpidbBhURL+dxv LYBQ== 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=KUvzSeTHiMYYDqDJxB7rJ4PNsknIyxmHg+DiEVHfwLI=; b=UQHkhUx3wS4WIsQv38W5o6nNiV7I0AeqHxR/3gdFvX5DQ8rQ5A5uEqxsS6vGh4q1dP F1QhspMvn5+gpbj+VF98TFAsSDfCjWXxJUWmz3+NtDRDd4vwzwjt5FZEXmLWKwOkNvki D3FWHqCRPuaj8kgSY1TlYoJOMnGKsdf6hL3XJA1oNVciH/pnMte92bAJ3DrV3+hLMwe0 0ZidtszxOn1UkMe45ICjgZj0GFM4ptoZ8Sd3Bxj/oZ9AcYem1ueeUQrpaE6X1HMNIZ+U Z0TyQG2LEFcAbcl3U1vmCqCeRyXUakh0uL3oh884+Ply2YD7fn9q2ISmlhqxFlXEiSQ/ jNtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=iOwiVk+5; 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 f7si3140540ioj.68.2021.07.29.07.12.04; Thu, 29 Jul 2021 07:12:15 -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=iOwiVk+5; 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 S238840AbhG2OLR (ORCPT + 99 others); Thu, 29 Jul 2021 10:11:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238495AbhG2OHG (ORCPT ); Thu, 29 Jul 2021 10:07:06 -0400 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5A99C0619E5 for ; Thu, 29 Jul 2021 06:59:58 -0700 (PDT) Received: by mail-qk1-x731.google.com with SMTP id t68so6004240qkf.8 for ; Thu, 29 Jul 2021 06:59:58 -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=KUvzSeTHiMYYDqDJxB7rJ4PNsknIyxmHg+DiEVHfwLI=; b=iOwiVk+59SLzINH9AVvJnCRQz3piAW2z7tpru53kHm1k8PiIusFJtd0SQ4xDI4FFc3 bZRCI6YMKhRT2u+U7GBQrmyv91J8yRGOkgseXRyYp7xA0e9h6yRbXixo5JdSxDfEAs4W sPxNOOwyfZFAAikVc79dsioyppviL3Wil4CQGo+DfLT7Ue0Gg4uRNRiJvoVSesolCxYI r/ec+r0NELHo0Yq/AxQB2kqG6MJ2iDFiU4M6evSHPfKc/MiE8MpoaypA8dItdSXeMmzY m1RgqdrArXNTrH/8k9p75lPGfzFckmisE2hIDyzz9R9qUOJcypGIT0WoDmlU3RJ+PCvi xp8g== 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=KUvzSeTHiMYYDqDJxB7rJ4PNsknIyxmHg+DiEVHfwLI=; b=BAy0EaSy0tEkmw5qLlRluTsyQ0fq44IqlSQnlR3nqMMYep7nl3XIzJImaCAPXa60WQ /KsmMLY5ZYyCfkmIWtTgc5EEDQ7zcVXGTZJgUTbxFFbOCGGDSOn8/h/dlbIlBs7VX8Do awG7o5//Q3MVzlyzTB4JKysWrnhGa8yQCcuTuSKHBnKo2eNd7tU0/3QI0UApb6vS5lKV mw06nlmLCXZJce1M+pLQbSkS76joEyN3CrMkuvUgCV1i9orasyx2bVKRpD5lQSL0Lorx arqr+XNSDB4/yBYqC25M/SHKmMh9XPgJAMJmZoJAifA++dQDusBlkQ9e2ugAC5308I9R Hz3A== X-Gm-Message-State: AOAM533cPwSnafV0OcBrLXanrYy9xPtnkDm5dtxMNX44u17wEYrRcVAG UlXt+WABxTuHgZhv2Kivs/L60fhjbXfJ8oLexU5hjQ== X-Received: by 2002:a37:a5ca:: with SMTP id o193mr5414456qke.352.1627567197517; Thu, 29 Jul 2021 06:59:57 -0700 (PDT) MIME-Version: 1.0 References: <20210728190254.3921642-1-hca@linux.ibm.com> <20210728190254.3921642-3-hca@linux.ibm.com> In-Reply-To: From: Alexander Potapenko Date: Thu, 29 Jul 2021 15:59:21 +0200 Message-ID: Subject: Re: [PATCH 2/4] kfence: add function to mask address bits To: Sven Schnelle Cc: Heiko Carstens , Marco Elver , Vasily Gorbik , Christian Borntraeger , kasan-dev , Linux Memory Management List , LKML , linux-s390 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 29, 2021 at 3:47 PM Sven Schnelle wrote: > > Alexander Potapenko writes: > > > On Wed, Jul 28, 2021 at 9:03 PM Heiko Carstens wrote: > >> > >> From: Sven Schnelle > >> > >> s390 only reports the page address during a translation fault. > >> To make the kfence unit tests pass, add a function that might > >> be implemented by architectures to mask out address bits. > >> > >> Signed-off-by: Sven Schnelle > >> Signed-off-by: Heiko Carstens > >> --- > >> mm/kfence/kfence_test.c | 13 ++++++++++++- > >> 1 file changed, 12 insertions(+), 1 deletion(-) > >> > >> diff --git a/mm/kfence/kfence_test.c b/mm/kfence/kfence_test.c > >> index 942cbc16ad26..eb6307c199ea 100644 > >> --- a/mm/kfence/kfence_test.c > >> +++ b/mm/kfence/kfence_test.c > >> @@ -23,8 +23,15 @@ > >> #include > >> #include > >> > >> +#include > >> + > >> #include "kfence.h" > >> > >> +/* May be overridden by . */ > >> +#ifndef arch_kfence_test_address > >> +#define arch_kfence_test_address(addr) (addr) > >> +#endif > >> + > >> /* Report as observed from console. */ > >> static struct { > >> spinlock_t lock; > >> @@ -82,6 +89,7 @@ static const char *get_access_type(const struct expect_report *r) > >> /* Check observed report matches information in @r. */ > >> static bool report_matches(const struct expect_report *r) > >> { > >> + unsigned long addr = (unsigned long)r->addr; > >> bool ret = false; > >> unsigned long flags; > >> typeof(observed.lines) expect; > >> @@ -131,22 +139,25 @@ static bool report_matches(const struct expect_report *r) > >> switch (r->type) { > >> case KFENCE_ERROR_OOB: > >> cur += scnprintf(cur, end - cur, "Out-of-bounds %s at", get_access_type(r)); > >> + addr = arch_kfence_test_address(addr); > > > > Can we normalize addr once before (or after) this switch? > > > > I don't think so. When reporing corrupted memory or an invalid free the > address is not generated by hardware but kfence itself, and therefore we > would strip valid bits. Ah, sorry, I missed that.