Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3323015pxf; Mon, 15 Mar 2021 07:07:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6E4sk6PfK36X5wytn9MFJ4u/r2AXSZUxfR9WYIfQm101GBbkyI+XYzXsmnGjb+mnbhvMg X-Received: by 2002:a05:6402:1c86:: with SMTP id cy6mr29685839edb.276.1615817279751; Mon, 15 Mar 2021 07:07:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615817279; cv=none; d=google.com; s=arc-20160816; b=kPB4O87828J2m1v4TpsjTXEnmP+SYx3X5AINteysPwgbX1d+e60AovUu5ncuXdWBvi HeFHhcfNlY+YR+2gTIHBuJBasLoJMukEip916kl4GMR/HRwQ0cdMM7vPNUAtQfrC+K1o qZpG+oK3q9M3tQurjmPTACte2dZZ75GVFTkgbnv92vh/DBsyefCLsfeffWX24+SB/1iM zg3Zu7gV3TCDheUt+jWQkV1ZHICifoPAJdYund6MxAEInjwBBbBE+47WDVHMSZlj8Ki+ DRDH6mY65jf/ABbOriyhZtRtXb4CwYMjT6Q3j1vqYOn8IrmCXGWubqFea+HEN/2yvxLH DT+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sE5jnHZkGPsj2+iS4yxyfT6jgOXhy+DroU+ktXY9ICw=; b=FBLQ666YoienlYTls6L0Pl/k+UFQiAKUyy0pDNVH8baueWrWjQPlqII9XJRegF4/0M Q1hGtIZRFnaAMgxWD82+t7XzswRuYVlVl2u/VlKkTiG732AwEkBY1sbmCjUPx3mGpFxe +nXR9ydVf+6tPdZgWpBCYU6Zezx1+f87lRfQN1IiMi5+zqt5o46Mv7rmWUaBBgIpoOU3 WU/qZepvZmh83/xYBbszMRqzqvxi3KZ48jJoVbG3HfW+PmnViC1HfpMN00kEQUJoYygE Zqls6hKu2GOp0uEkg3Wd4uopvC/EwBjTjrJKelvkWmpuKY6Md6erEuivmm8Ttdn6lqAp djiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="UH8+oT/4"; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ko24si11393870ejc.407.2021.03.15.07.07.36; Mon, 15 Mar 2021 07:07:59 -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=@linuxfoundation.org header.s=korg header.b="UH8+oT/4"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234422AbhCOODV (ORCPT + 99 others); Mon, 15 Mar 2021 10:03:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:34136 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231420AbhCON5K (ORCPT ); Mon, 15 Mar 2021 09:57:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7F8FC64F37; Mon, 15 Mar 2021 13:57:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816630; bh=MRxnbr6GCvzlsTlzldQEnZM3HHwrm9aBD+N7NzrjEOA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UH8+oT/417j+79JKnzbHPJjUAWul7+P03xtN9nLUYgXUxXFSiMoP5M2Ix4HJmimnk ZO/q8bWmYaSiXT0x2p9WAvk3XB5slF3Jf/vQkwRKh5ATm8gp4US5XMleUkXvOzQB0k M16KceMg9uAtW6ts22HEPU9W1sJ+LKnp8+jM6sL4= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilya Leoshkevich , Daniel Borkmann , Heiko Carstens , Yonghong Song Subject: [PATCH 5.10 022/290] selftests/bpf: Use the last page in test_snprintf_btf on s390 Date: Mon, 15 Mar 2021 14:51:55 +0100 Message-Id: <20210315135542.681110861@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Ilya Leoshkevich commit 42a382a466a967dc053c73b969cd2ac2fec502cf upstream. test_snprintf_btf fails on s390, because NULL points to a readable struct lowcore there. Fix by using the last page instead. Error message example: printing fffffffffffff000 should generate error, got (361) Fixes: 076a95f5aff2 ("selftests/bpf: Add bpf_snprintf_btf helper tests") Signed-off-by: Ilya Leoshkevich Signed-off-by: Daniel Borkmann Acked-by: Heiko Carstens Acked-by: Yonghong Song Link: https://lore.kernel.org/bpf/20210227051726.121256-1-iii@linux.ibm.com Signed-off-by: Greg Kroah-Hartman --- tools/testing/selftests/bpf/progs/netif_receive_skb.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) --- a/tools/testing/selftests/bpf/progs/netif_receive_skb.c +++ b/tools/testing/selftests/bpf/progs/netif_receive_skb.c @@ -16,6 +16,13 @@ bool skip = false; #define STRSIZE 2048 #define EXPECTED_STRSIZE 256 +#if defined(bpf_target_s390) +/* NULL points to a readable struct lowcore on s390, so take the last page */ +#define BADPTR ((void *)0xFFFFFFFFFFFFF000ULL) +#else +#define BADPTR 0 +#endif + #ifndef ARRAY_SIZE #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #endif @@ -113,11 +120,11 @@ int BPF_PROG(trace_netif_receive_skb, st } /* Check invalid ptr value */ - p.ptr = 0; + p.ptr = BADPTR; __ret = bpf_snprintf_btf(str, STRSIZE, &p, sizeof(p), 0); if (__ret >= 0) { - bpf_printk("printing NULL should generate error, got (%d)", - __ret); + bpf_printk("printing %llx should generate error, got (%d)", + (unsigned long long)BADPTR, __ret); ret = -ERANGE; }