Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp637926ybi; Fri, 24 May 2019 09:02:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqw6BFL4STYXYK5v5nbzOuzdWm4fI8os/SzTO7/c5WwbAQEPxxKyhjyeDB52uVY0vLW77pxb X-Received: by 2002:a17:902:24c7:: with SMTP id l7mr57828939plg.192.1558713778567; Fri, 24 May 2019 09:02:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558713778; cv=none; d=google.com; s=arc-20160816; b=RQhijb+BYGbeQGLXQCX+0wLELJfdTTkgVf+b4c7U1B1Pl8W8FeUdvqdW3hGAym5/PC WxgGhE7QbXRiyf4JsAd7e+zAF1HMN3pFsqXQfGmxHZxLuxL9nzH0hc1Sd+tPLjOqBN7d xv2+jJWhuhpKxdkCViGhoq2XIVXgKyRYPiHFRV+Rvm03263v+SY5XN5V/cCzb+1r0xOX E3qX++Pwx/o355eXExmM9jLiF0aidJSHvhFvtDdB+JQa1Cg3O4STEFz3KEy/Ph9Chi5i GIWaQHwOQrzGawfQy/MAzgit6OvekMRLIjIGkZEDIxI537BWn5ZVpQWAPBo2ppiVBbaH LmQw== 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=a4BYbY0H/gJ/SBV0pW9HBq0oWfzuEg4LxLjaui3637c=; b=rUPXm0U/pjVoKT47/o5wMuN52m1O796aCkpvEhJ4lV44/zrrK4t9Imfzp4P+WyesuG j8DPXLQ8a/OmmlcNoMOdCcAzqQMvqv+iLKreGrOeqKMrHgd4qCbcgLWbEsIlbnhRqLN5 10wJAYVIPUWUQFavXMWwNTokBk2LplJmZNGLbsoqt8MR3PK5OoeiiXjMsUX1Z0BXD54k Mk7Vw6QpOwFKX/Z6t5uNvxweCdbpOwuUfTJW6ZgSxSDfGwz+p7SN0o/WtVhFZ0yILMZC RGz67HBHSPi0EjVpEnKPSoxjdpU1IcS0y8/hxyjaSO+b7UNS+eU3Uv9GxIXEK5mHXe2Y /Mcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kinvolk.io header.s=google header.b=E9gKK7Ym; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d8si932995pls.208.2019.05.24.09.02.43; Fri, 24 May 2019 09:02:58 -0700 (PDT) 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=@kinvolk.io header.s=google header.b=E9gKK7Ym; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390662AbfEXP7z (ORCPT + 99 others); Fri, 24 May 2019 11:59:55 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:38736 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390657AbfEXP7u (ORCPT ); Fri, 24 May 2019 11:59:50 -0400 Received: by mail-wr1-f67.google.com with SMTP id d18so10548660wrs.5 for ; Fri, 24 May 2019 08:59:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kinvolk.io; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a4BYbY0H/gJ/SBV0pW9HBq0oWfzuEg4LxLjaui3637c=; b=E9gKK7YmH0pR7gk3fLXm/ealfjAQNJ0sgX7bsR0M8h9rsjPzo2jBg/Dit9A2OTUzGU XZmGXfZ3u/SFQ8a7AdJZUk8tqhFc5M9wKvDy1/TBykNAv77+kYmhe8JPB0Cmh19SrITx GGKi/V+syqcDUQVs9V3ZxOt0Dom732G+0ESyE= 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=a4BYbY0H/gJ/SBV0pW9HBq0oWfzuEg4LxLjaui3637c=; b=hxxgooH+3PgnNRCJpJ6QrUHHirCa1W/3tzhrELztl2MFN4b7OCdkZrzgTF0Y8Kfrt2 qKg5lafWrULgM65kG3aUYyGiTlXUtWLVIsChLc5UQDx6Wl4wDomJYla70tXGk7fWkNra ZymMrf3xISEnDjUopTpzUv3ZQpKby1MKBWvQClHx7WoRwRMaYbV6H0bfsnebfuygru+T 4HGKLai+FY8M53SK9IlucEGAd6h/vybXhoLHeIG641wBSXNbokhoANhA7dICjSDKggAn HkwKtIGMiEVM14qsMedDVjAS6KP2zyyK5hZTurO3C8PDf+HsGtqhCjZXkRS8yUO2jKak VPXQ== X-Gm-Message-State: APjAAAWLhXfp9DvMkz3oT6ua2zfVlh+6nLIxBhAGSeedKYSBTl5xXV9m dClPk82jNe9m8PYmWrn863Vg/Q== X-Received: by 2002:adf:f988:: with SMTP id f8mr3227533wrr.254.1558713588616; Fri, 24 May 2019 08:59:48 -0700 (PDT) Received: from locke-xps13.localdomain (69.pool85-58-237.dynamic.orange.es. [85.58.237.69]) by smtp.gmail.com with ESMTPSA id i185sm4535054wmg.32.2019.05.24.08.59.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 May 2019 08:59:47 -0700 (PDT) From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= To: john.fastabend@gmail.com, ast@kernel.org, daniel@iogearbox.net Cc: alban@kinvolk.io, krzesimir@kinvolk.io, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next v4 4/4] selftests: bpf: verifier: read netns_dev and netns_ino from struct bpf_sock_ops Date: Fri, 24 May 2019 17:59:31 +0200 Message-Id: <20190524155931.7946-5-iago@kinvolk.io> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190524155931.7946-1-iago@kinvolk.io> References: <20190524155931.7946-1-iago@kinvolk.io> 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 From: Alban Crequy Tested with: > $ sudo ./test_verifier > ... > #905/p sockops accessing bpf_sock_ops->netns_dev, ok OK > #906/p sockops accessing bpf_sock_ops->netns_ino, ok OK > ... > Summary: 1421 PASSED, 0 SKIPPED, 0 FAILED Signed-off-by: Alban Crequy --- Changes since v1: - This is a new selftest (review from Song) Changes since v2: - test partial reads on netns_dev (review from Y Song) - split in two tests --- .../testing/selftests/bpf/verifier/var_off.c | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tools/testing/selftests/bpf/verifier/var_off.c b/tools/testing/selftests/bpf/verifier/var_off.c index 8504ac937809..9e4c6c78eb9d 100644 --- a/tools/testing/selftests/bpf/verifier/var_off.c +++ b/tools/testing/selftests/bpf/verifier/var_off.c @@ -246,3 +246,56 @@ .result = ACCEPT, .prog_type = BPF_PROG_TYPE_LWT_IN, }, +{ + "sockops accessing bpf_sock_ops->netns_dev, ok", + .insns = { + BPF_LDX_MEM(BPF_DW, BPF_REG_4, BPF_REG_1, offsetof(struct bpf_sock_ops, + netns_dev)), + + BPF_LDX_MEM(BPF_W, BPF_REG_4, BPF_REG_1, offsetof(struct bpf_sock_ops, + netns_dev)), + BPF_LDX_MEM(BPF_W, BPF_REG_4, BPF_REG_1, offsetof(struct bpf_sock_ops, + netns_dev) + 4), + + BPF_LDX_MEM(BPF_H, BPF_REG_4, BPF_REG_1, offsetof(struct bpf_sock_ops, + netns_dev)), + BPF_LDX_MEM(BPF_H, BPF_REG_4, BPF_REG_1, offsetof(struct bpf_sock_ops, + netns_dev) + 2), + BPF_LDX_MEM(BPF_H, BPF_REG_4, BPF_REG_1, offsetof(struct bpf_sock_ops, + netns_dev) + 4), + BPF_LDX_MEM(BPF_H, BPF_REG_4, BPF_REG_1, offsetof(struct bpf_sock_ops, + netns_dev) + 6), + + BPF_LDX_MEM(BPF_B, BPF_REG_4, BPF_REG_1, offsetof(struct bpf_sock_ops, + netns_dev)), + BPF_LDX_MEM(BPF_B, BPF_REG_4, BPF_REG_1, offsetof(struct bpf_sock_ops, + netns_dev) + 1), + BPF_LDX_MEM(BPF_B, BPF_REG_4, BPF_REG_1, offsetof(struct bpf_sock_ops, + netns_dev) + 2), + BPF_LDX_MEM(BPF_B, BPF_REG_4, BPF_REG_1, offsetof(struct bpf_sock_ops, + netns_dev) + 3), + BPF_LDX_MEM(BPF_B, BPF_REG_4, BPF_REG_1, offsetof(struct bpf_sock_ops, + netns_dev) + 4), + BPF_LDX_MEM(BPF_B, BPF_REG_4, BPF_REG_1, offsetof(struct bpf_sock_ops, + netns_dev) + 5), + BPF_LDX_MEM(BPF_B, BPF_REG_4, BPF_REG_1, offsetof(struct bpf_sock_ops, + netns_dev) + 6), + BPF_LDX_MEM(BPF_B, BPF_REG_4, BPF_REG_1, offsetof(struct bpf_sock_ops, + netns_dev) + 7), + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }, + .result = ACCEPT, + .prog_type = BPF_PROG_TYPE_SOCK_OPS, +}, +{ + "sockops accessing bpf_sock_ops->netns_ino, ok", + .insns = { + BPF_LDX_MEM(BPF_DW, BPF_REG_4, BPF_REG_1, offsetof(struct bpf_sock_ops, + netns_ino)), + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }, + .result = ACCEPT, + .prog_type = BPF_PROG_TYPE_SOCK_OPS, +}, -- 2.21.0