Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp6215327ybf; Thu, 5 Mar 2020 15:46:28 -0800 (PST) X-Google-Smtp-Source: ADFU+vsE3hWTCTVXNOrebh07Nn4mtMMu3bSDiDAhST5idqUAabufFE9/eEbJVvi/fJF90asOq9kR X-Received: by 2002:a9d:77c3:: with SMTP id w3mr289713otl.245.1583451988019; Thu, 05 Mar 2020 15:46:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583451988; cv=none; d=google.com; s=arc-20160816; b=Z5LnS4fuBNCBh+2NgNEYhsczunjDr5tRb+919l1egL/xwOmTwnYeQJpt4AHua5R9zS 2fsZQLbexwTX2iSk/M3YnnafB6HsZ2didLE9fTEkZpcC3KNcqbyrnqvfysHGPCYbr/0i 9n4YoCCmJh9wxh8q1Rwpxh2zx2gYOKxDDWAFUMi0ofg/epGEX5BEKNohqIro78pMOj9P QmnG1Q6XYpBxNCnTQCTsun81SCMJZxrv5u/pOc42icEH8loLD3AnNr5FPwS3YYe27MUn Y7xwF9ErSfvzxTasyPS//CRX3SjobQnbRXcqiVhOY4YO2y7WKLtaEfm7LPoI/GBKEBv0 CI4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8CXMX6fYDwGAYuQgw3gIIoEsDSy+htyQIvrI+wvb2+8=; b=qJXXCm4yIdCbJC00rrZq7vZp6F8wKpa84YVrsCHTsvEhaE1i2GIf+TKT9kr1kCeuxA P+I/ypfEwnN7kVihOw4yYSgIvZKnbPDxzLXwh3p3bveQulNIQaS99hjGTF5ktKKbueG0 Sj5/1h+U0NTke1IwNpg+qJeR4cBLuFAwsUnKNe/w/3MRbP4YQONx6STRYsVmahhXgpU+ WtJ8DSE+tFSy99n/egK01Ddoes4esr5xiVe+ZzN/t4iwAxKEHcI4r6ik+fVzYPrDAbDv S3zfKRtCv1BBhO99tboz7NYQ+RKPD6DtV6dynXAJR79lDmVAgovTQ6M0/3xghf1XydbE Vzew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cs.washington.edu header.s=goo201206 header.b=Gjc6mRDc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cs.washington.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e26si271361otk.251.2020.03.05.15.46.14; Thu, 05 Mar 2020 15:46:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@cs.washington.edu header.s=goo201206 header.b=Gjc6mRDc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cs.washington.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726533AbgCEXo0 (ORCPT + 99 others); Thu, 5 Mar 2020 18:44:26 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:33976 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726178AbgCEXo0 (ORCPT ); Thu, 5 Mar 2020 18:44:26 -0500 Received: by mail-pf1-f193.google.com with SMTP id y21so164598pfp.1 for ; Thu, 05 Mar 2020 15:44:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.washington.edu; s=goo201206; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8CXMX6fYDwGAYuQgw3gIIoEsDSy+htyQIvrI+wvb2+8=; b=Gjc6mRDcST67ch0F2d8snDJxaX0MY/pG5uwlIGr31+nbXp8S0uE3YwChQ1qHzuQLxL P6vxhKDB5gDhglRfvnEYHG0bCTQo2prlA1AIn/BGmKqFUo8ZR4Pibv0u9NO8/pFdRN8J d5CvL4rE2OsCeveuUbpV8Ki2YiPQsBHoatL1Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8CXMX6fYDwGAYuQgw3gIIoEsDSy+htyQIvrI+wvb2+8=; b=gxBUjQRxZOazbFAmQeF1vXvTPB6AoX0JpTy2kmpPQmR+ZE3aoqPVlRPudn9XVX6wLz zxgHn3hUvadJhhAasK3C919r49O67/xLKK5r0byeRr9hOG6pj93U3U4vLDQQRS5KmESo dfNAyL8lsaVAzg8NSv3R9J1hAVKrmGN9QdneEJhKrIJYfT5ZOveaJBJoD0ZhmWAljx9M +JOQsuinG8WTgQw8aIbtOguAD0q+DSvJ9qb+p6iDjkZuqzAjvX3IiSnaNBfQorbQiqro m0m2C33e/IztcPWPSPgYh2CMiyZVldZgs80AZOUP9lAHeN3PM6neeWpiZZLIGNM1ZP+l 8qDg== X-Gm-Message-State: ANhLgQ0vFJQOqxgeq23Ow3KTk9FRzD9wM1knDa+qGbD+IDgGveHX4j6V /VWtzu0GUyszdDZbISMfcyrchQ== X-Received: by 2002:a63:1a5b:: with SMTP id a27mr546605pgm.249.1583451864784; Thu, 05 Mar 2020 15:44:24 -0800 (PST) Received: from ryzen.cs.washington.edu ([2607:4000:200:11:60e4:c000:39d0:c5af]) by smtp.gmail.com with ESMTPSA id s123sm30103856pfs.21.2020.03.05.15.44.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2020 15:44:24 -0800 (PST) From: Luke Nelson X-Google-Original-From: Luke Nelson To: bpf@vger.kernel.org Cc: Luke Nelson , Xi Wang , Wang YanQing , "David S. Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , Shuah Khan , Jiong Wang , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH bpf 2/2] selftests: bpf: add test for JMP32 JSET BPF_X with upper bits set Date: Thu, 5 Mar 2020 15:44:13 -0800 Message-Id: <20200305234416.31597-2-luke.r.nels@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200305234416.31597-1-luke.r.nels@gmail.com> References: <20200305234416.31597-1-luke.r.nels@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The existing tests attempt to check that JMP32 JSET ignores the upper bits in the operand registers. However, the tests missed one such bug in the x32 JIT that is only uncovered when a previous instruction pollutes the upper 32 bits of the registers. This patch adds a new test case that catches the bug by first executing a 64-bit JSET to pollute the upper 32-bits of the temporary registers, followed by a 32-bit JSET which should ignore the upper 32 bits. Co-developed-by: Xi Wang Signed-off-by: Xi Wang Signed-off-by: Luke Nelson --- tools/testing/selftests/bpf/verifier/jmp32.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/testing/selftests/bpf/verifier/jmp32.c b/tools/testing/selftests/bpf/verifier/jmp32.c index bf0322eb5346..bd5cae4a7f73 100644 --- a/tools/testing/selftests/bpf/verifier/jmp32.c +++ b/tools/testing/selftests/bpf/verifier/jmp32.c @@ -61,6 +61,21 @@ }, .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, }, +{ + "jset32: ignores upper bits", + .insns = { + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_LD_IMM64(BPF_REG_7, 0x8000000000000000), + BPF_LD_IMM64(BPF_REG_8, 0x8000000000000000), + BPF_JMP_REG(BPF_JSET, BPF_REG_7, BPF_REG_8, 1), + BPF_EXIT_INSN(), + BPF_JMP32_REG(BPF_JSET, BPF_REG_7, BPF_REG_8, 1), + BPF_MOV64_IMM(BPF_REG_0, 2), + BPF_EXIT_INSN(), + }, + .result = ACCEPT, + .retval = 2, +}, { "jset32: min/max deduction", .insns = { -- 2.20.1