Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp236190ybi; Fri, 7 Jun 2019 07:16:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqzudVdK+uScGksFYGPhV1xmeaoh6y04b1X09XM68NrzdSIw9e/qxFZfBDVmiwUPYkYgnGWV X-Received: by 2002:a62:d149:: with SMTP id t9mr37227550pfl.173.1559916963321; Fri, 07 Jun 2019 07:16:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559916963; cv=none; d=google.com; s=arc-20160816; b=FuUi5kcjqKROB8LErNz7QmeSql/MhU9KjJaUTQ4iU7SeujmpL+4PfinCzcK/TJjwe2 hL/WzhLXoinBzDgahU24fVjxjSGxflwOT0SoJ5WsGbJZrsVqU9WFDsiSiyfXmTU+AKCY TxSuS1aed8iWTi4XIHOQ2o+zRJFHNqNyxtNXS3NACpSu5mYnk4mf6q9NaXjv96/dwh2s XvWo2zi6rMAit5VQFi5Cq+8SEtG0rBwW5oKWcobgPCpgmW7W4DBDBwoUylAmRujvMqkh LAogXh4RfVf/G2dqhoOnVVGfpLeB2o3DU4DDST3W4iJZkhSgXN8iIoiXQdmh18L8tvyt /hFg== 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=jVqXUKslhEuZrckBZPIGDYa/1C2p5LrGbm6Wof7eOI8SjMIq+kt4Ny34dVFIFj2owR ItC6ZiXZu4Nvz8I6fDRy1JAJKd4m2p53U+diTk4CzKeKnIS4E0I8PylqJ4+7LxQGQUSD 4edMZU4P6ZIlOL3NgzW8yUxp8p5Z5M/vaMLWkE/n5ciOudAydsDwDdzxEkiAYigug3x8 RlqOdroEYpQAxU+bXzjUX5bKaikPObnslYTkGzZsOqXjqRgmkRMpg6E97PJyyVgKTT/y ktJbTIprWKwQHRbF1P2YYDfIB+83B7DhZjVRcHQF7qdJK7xCZXMpJJXsg7dZnGw3CI/0 KS+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kinvolk.io header.s=google header.b="A52/UPha"; 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 b6si1794498pgq.465.2019.06.07.07.15.45; Fri, 07 Jun 2019 07:16:03 -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="A52/UPha"; 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 S1729548AbfFGOLh (ORCPT + 99 others); Fri, 7 Jun 2019 10:11:37 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:42421 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729472AbfFGOLR (ORCPT ); Fri, 7 Jun 2019 10:11:17 -0400 Received: by mail-ed1-f66.google.com with SMTP id z25so3213788edq.9 for ; Fri, 07 Jun 2019 07:11:16 -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=A52/UPhaDFmKTtTG9exlP6gH+yrRJmVwrdz56ohUfKW1gwkj+x4/Dq2PHUdpuj6YZT 3/pvcYZolg2Xqok2Jijpnu95I/Og/Kfeehoz+bDcnwAmyAxlDjhYJnx0Xz2dbAz90qQP Fa2uO6BTJrDA/X2hHq0xwrOt4Te63fRj1iUjA= 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=hFsUW8S37tJisbsa9zfkrc573JSPQ0eqbzxqWV94TF7kHP7ezAvHqTqTUezUXHDjZ9 lMNDwEnPRWeJSvbna6bM4N1UsbeqfFVW25FiUQrlaw9yiPwt93vjgsKQnL6ncYkMTUvE n+DR/Pyz9Lv7vjOh8IJ/Ty4ge9aLJkMxgXOzN5npcUsYu5em1zAPregmjCema0JMEyXt S9NPTB548tHAeibMu5u8PoVYubIPjHipCmIkO5HmnG0haAnyCHKJYGCtmydwlbKnmzbn RZ+Usmp1cn0bS2z/x3t/Pi5f3vUXEaoe/VqrW/SGNSfKUPCVhimTZvtudNJx8G8qjKlY yacA== X-Gm-Message-State: APjAAAW89gpo+41q6ZrpYqxWTSHwfRFHOKO7LsSU8/T88ah13jq4zYb0 4BcAVX9hUZFGq06kujdPyq2nUQ== X-Received: by 2002:a17:906:7388:: with SMTP id f8mr47614254ejl.231.1559916675852; Fri, 07 Jun 2019 07:11:15 -0700 (PDT) Received: from locke-xps13.fritz.box (dslb-002-205-069-198.002.205.pools.vodafone-ip.de. [2.205.69.198]) by smtp.gmail.com with ESMTPSA id a40sm546116edd.1.2019.06.07.07.11.14 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 07:11:15 -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 v5 4/4] selftests: bpf: verifier: read netns_dev and netns_ino from struct bpf_sock_ops Date: Fri, 7 Jun 2019 16:11:06 +0200 Message-Id: <20190607141106.32148-5-iago@kinvolk.io> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190607141106.32148-1-iago@kinvolk.io> References: <20190607141106.32148-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