Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6112435pxv; Thu, 29 Jul 2021 06:51:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoy+UPn01vSMauDEmzvsn3iv3vmz1V19FsJWUwJuh5BlgF3sHU00HWSxVjnQf465W4VZf/ X-Received: by 2002:a17:906:b351:: with SMTP id cd17mr4908502ejb.36.1627566683450; Thu, 29 Jul 2021 06:51:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627566683; cv=none; d=google.com; s=arc-20160816; b=mBHo4uqQnLk+AY15wpnbePMrqWNcn7jjJ3nmZ6MHWJ1jDM40uzk00faOItXCrwnqbi 004A+t//urPLw+vyamBq7Ig2JBVrtoud4DHY0k+bA+74V7P2aw9zWKcZvqdUaGrAiRb7 l1IRxmnGHGgkNA43ncWI2AQGuJ7r84gYN7JIkdVzq3b6ywBxXUlGo9IqCZ2Cj1Vl5bKb m9Z1p2wSH+NzhHNmHzNUB0FSp4g51sj5tEBPLJOvFLoVKoxi9tFeg60JTo+Ughek+3H6 jYzJLoplp3qEQlPm/9iPp2r5wLWXl992QTn55WCKsgAkNPD13i4XE+h73KOExr4ZBG2w TKHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=9O/GEXoZTqlR+xJfXv/WGh/M7l0aIVQd0qAa+HW+Jb4=; b=AIbL4KRcPBEBHiN+DCBZZj4Ley/bUKoVnqqL3iomjZKA9TaSHelaHjMguVxhSw1bkN CWY979X/MKdIU6VdZBv8rik/Q+rusQR4ssYeq0tiRc1xhlmoYWkJeO7opEMJGSjK3Tlg BvL7DQmMeQ2C4tQ/XtRhDYlhyDVRzHnf7iLHoTfkPxDfL6z5Bu8pQ6FuNdcpr+xpzB1X HxlBuusiJoT3Gs2jUx22wnTBiJjYmuPAko7hjiVlPHbQ1owhGbBwSYSXrFR1Vf4f0tzr Wf8rga5FZq4IPUF13tbo16Y3eUC1uV9vaarklWD1xYPCcTTpeNlUK9muCnJs7e8lO+q7 7Q6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="coJYu/Zt"; 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=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j20si2926819edt.37.2021.07.29.06.51.00; Thu, 29 Jul 2021 06:51:23 -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=@ibm.com header.s=pp1 header.b="coJYu/Zt"; 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=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237730AbhG2Nrk (ORCPT + 99 others); Thu, 29 Jul 2021 09:47:40 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:48540 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237503AbhG2Nri (ORCPT ); Thu, 29 Jul 2021 09:47:38 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16TDXWBw110609; Thu, 29 Jul 2021 09:47:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : references : date : in-reply-to : message-id : mime-version : content-type; s=pp1; bh=9O/GEXoZTqlR+xJfXv/WGh/M7l0aIVQd0qAa+HW+Jb4=; b=coJYu/Zt4KQyNuAJsFjZKgC2d9R85IJRz0q/e8r6/5m+RSV6IN9G1K0a6XkBIy9TP2OI fHwl3ccbMPd9m7nrH6gj+FLL8b98Z+DpQ0NQ1wRg4HUj7imZ42r/KwjNtXzMowZDHzFU VYo+Z8PPrFE4wBMrIbtFHN+WxhKoUBH+CYZ/wfgtuBn3hCs1LKuQf/TC6pv1x2J/GzOX kP6EsMclJkS6Z9KLjUdYk7Cq3Anv6yQOgRhIB/db6pYmF8sbq8j9GqUJACk80o/FdzPV esdO0Dl/NErjdG3p59+3Jl1fiTXMjuf9G+qeUASNY78+uLBRiM7URIkK8UdWFHxl0EsL YQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3a3tw7nkue-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Jul 2021 09:47:32 -0400 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 16TDYInm117541; Thu, 29 Jul 2021 09:47:32 -0400 Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 3a3tw7nktt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Jul 2021 09:47:32 -0400 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 16TDZnjZ002896; Thu, 29 Jul 2021 13:47:30 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma03fra.de.ibm.com with ESMTP id 3a235ks4ry-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Jul 2021 13:47:30 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 16TDigBD25428294 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jul 2021 13:44:42 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BF0C6A4051; Thu, 29 Jul 2021 13:47:25 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 58190A4080; Thu, 29 Jul 2021 13:47:25 +0000 (GMT) Received: from tuxmaker.linux.ibm.com (unknown [9.152.85.9]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Thu, 29 Jul 2021 13:47:25 +0000 (GMT) From: Sven Schnelle To: Alexander Potapenko Cc: Heiko Carstens , Marco Elver , Vasily Gorbik , Christian Borntraeger , kasan-dev , Linux Memory Management List , LKML , linux-s390 Subject: Re: [PATCH 2/4] kfence: add function to mask address bits References: <20210728190254.3921642-1-hca@linux.ibm.com> <20210728190254.3921642-3-hca@linux.ibm.com> Date: Thu, 29 Jul 2021 15:47:24 +0200 In-Reply-To: (Alexander Potapenko's message of "Thu, 29 Jul 2021 14:43:51 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 1Grps8gXUt09Y6zVx3mspHN6fv6-rv4W X-Proofpoint-GUID: dN18rwQmbCZAayJ0xzHHDeX5X82kCHcf X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-07-29_10:2021-07-29,2021-07-29 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 spamscore=0 impostorscore=0 malwarescore=0 phishscore=0 priorityscore=1501 clxscore=1011 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2107290087 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. >> break; >> case KFENCE_ERROR_UAF: >> cur += scnprintf(cur, end - cur, "Use-after-free %s at", get_access_type(r)); >> + addr = arch_kfence_test_address(addr); >> break; >> case KFENCE_ERROR_CORRUPTION: >> cur += scnprintf(cur, end - cur, "Corrupted memory at"); >> break; >> case KFENCE_ERROR_INVALID: >> cur += scnprintf(cur, end - cur, "Invalid %s at", get_access_type(r)); >> + addr = arch_kfence_test_address(addr); >> break; >> case KFENCE_ERROR_INVALID_FREE: >> cur += scnprintf(cur, end - cur, "Invalid free of"); >> break; >> } >> >> - cur += scnprintf(cur, end - cur, " 0x%p", (void *)r->addr); >> + cur += scnprintf(cur, end - cur, " 0x%p", (void *)addr); >> >> spin_lock_irqsave(&observed.lock, flags); >> if (!report_available()) >> -- >> 2.25.1 >>