Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3320142pxf; Mon, 15 Mar 2021 07:05:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4aV8qLtkixe4n4AlwCluLEkRdoawLpg+648gg1E7nVeCfYHyz3eGGQKrEcBiQG7fRTVTw X-Received: by 2002:a50:ec81:: with SMTP id e1mr29871376edr.0.1615817108832; Mon, 15 Mar 2021 07:05:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615817108; cv=none; d=google.com; s=arc-20160816; b=yz8AnJc6jWjCZ7AMpLG6wJ+m9Rw/f6zgk8y0/+gSSPLqzSiqHSK9CsYEBx8ZPEiLgx 5Ld3sxmevA1Z+WEW1G5wrAoaKLmHH94iLiwEryC83/OlXWWJbFsd+cb5gDdv8OzALRUe Y5BfDvtErhmpDpg8ZaDa7IDGuA5di3qsVKDWhF9kQB+Oq5EoqdgsgGZvK0FB/O4E0Z2Z ZQykRj7mz14G8IoDKhNxsXz1EElIVZY6Xv8j6Uw4cTrLXMtl7cWjIYDwUzvIE9onIwWl MvvS4BqekXCHM6fZCl598fO4a86Pl+jd4KXqdT53Sq1jCWvzEhI0C2H6OUIv9GBr0pGf Rsww== 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=/JbT797yZTup6xHHYjoEefkNgxKy4NKtRfnbYD7FSG8=; b=P6OWcvA/rjJ9vD241fQCKlvdeYas13SFB6ci9WE3hRdgqI3wzDRNLeTChl0J9ucQ77 q7sUKwxQ550TfEZBDTRxl1PEanS8Gl2Z+0G79fj2nHI2HaYb5VQ/HylsZHuRNjFgD7HO Saf42dwqr1PBoJ2RVXh4Ocru5r8clVbD7i5uYwZFjNyOxxIpu7WMPJFQuBMQlICLQfdQ bYVaFvm8eE01A4PnigAtlHr9doV4vQweNzLF3eJM72bT/KKFrRgAjNDRXBuMSMonSHAT bwkeOPfDss1na8yLzLLd36MIUSEpiFCCcsbGGyD0LH7C95K7FqKQJpXpfQkcfkzy6dje o3DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=v0bZvNhH; 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 c10si10390555edv.12.2021.03.15.07.04.45; Mon, 15 Mar 2021 07:05:08 -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=v0bZvNhH; 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 S234460AbhCOODX (ORCPT + 99 others); Mon, 15 Mar 2021 10:03:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:34792 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229900AbhCON5N (ORCPT ); Mon, 15 Mar 2021 09:57:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 212E264EEE; Mon, 15 Mar 2021 13:57:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816633; bh=brXWXpnYW6YQL0ESqPRMZqTazFW2xCed+nZ3A+nBLeU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v0bZvNhH93Buf0tddVffN/+OF6Gf/zqR4BURUGFQbSadmf7OY3TzeCq3WxlD3+W23 yOBUGI+O/fmIOYVOsG8DqW8WTOTJYmec+O0TYPO7lXQo5iSjrnQdqompZHOO2y2N7v jbxrqvuHzrtCDYKwxC2WDjew6V77i9zH1FXt6bWM= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yauheni Kaliuta , Daniel Borkmann Subject: [PATCH 5.10 024/290] selftests/bpf: Mask bpf_csum_diff() return value to 16 bits in test_verifier Date: Mon, 15 Mar 2021 14:51:57 +0100 Message-Id: <20210315135542.755067257@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: Yauheni Kaliuta commit 6185266c5a853bb0f2a459e3ff594546f277609b upstream. The verifier test labelled "valid read map access into a read-only array 2" calls the bpf_csum_diff() helper and checks its return value. However, architecture implementations of csum_partial() (which is what the helper uses) differ in whether they fold the return value to 16 bit or not. For example, x86 version has ... if (unlikely(odd)) { result = from32to16(result); result = ((result >> 8) & 0xff) | ((result & 0xff) << 8); } ... while generic lib/checksum.c does: result = from32to16(result); if (odd) result = ((result >> 8) & 0xff) | ((result & 0xff) << 8); This makes the helper return different values on different architectures, breaking the test on non-x86. To fix this, add an additional instruction to always mask the return value to 16 bits, and update the expected return value accordingly. Fixes: fb2abb73e575 ("bpf, selftest: test {rd, wr}only flags and direct value access") Signed-off-by: Yauheni Kaliuta Signed-off-by: Daniel Borkmann Link: https://lore.kernel.org/bpf/20210228103017.320240-1-yauheni.kaliuta@redhat.com Signed-off-by: Greg Kroah-Hartman --- tools/testing/selftests/bpf/verifier/array_access.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/tools/testing/selftests/bpf/verifier/array_access.c +++ b/tools/testing/selftests/bpf/verifier/array_access.c @@ -250,12 +250,13 @@ BPF_MOV64_IMM(BPF_REG_5, 0), BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_csum_diff), + BPF_ALU64_IMM(BPF_AND, BPF_REG_0, 0xffff), BPF_EXIT_INSN(), }, .prog_type = BPF_PROG_TYPE_SCHED_CLS, .fixup_map_array_ro = { 3 }, .result = ACCEPT, - .retval = -29, + .retval = 65507, }, { "invalid write map access into a read-only array 1",