Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp852882pxb; Thu, 5 Nov 2020 15:03:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJwvRAqYmkdkeS5qRhtjqFvBUmrwttZqg6kdLzVlOWWp4VBWqw5nwZmEjExd0GSEQ2Fz+oU0 X-Received: by 2002:a50:ace6:: with SMTP id x93mr5217585edc.368.1604617380573; Thu, 05 Nov 2020 15:03:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604617380; cv=none; d=google.com; s=arc-20160816; b=whOYhFvQfVjk8Nq+VlcxhXyhwhqLWAJwKMnJyhDaw3MGnMrU1jJ5o/l6wk3cGKxB7s dO0gi+46ky6Ex4uHk49D3A8YPa3C5HUN6OK8+JUE0KMO+uqcvPq1EY4pNO5LgJZ0ARPU QQzxXFq3U0RzTYH9quJkRi+smdAcLI+VjYAMJQNbbl4w2WwAQgVwpcqd4fpd6Oqy5ReZ LNPBcJLTVbK7oX+YVANl0CV6V6mJE1Ts683ezqfZj3aszjjm0VWfudUD1OTKw2tDFtb4 uc2VfCp+gIKvUU7dsRokqkP0VTqLdoqa5vgyuZm1rejRoF5IMkQrZUwZaLMjiEK24A8S k1Sw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Pm0NxoA/7Z6v/tkb4U6GU+e1eqN4wR4f0rR2Wx/opQk=; b=n9BGojrVFSMCIKzOzhHBbJds26U8IIZ3QABI8FiEzCNf4CQD515sxg9Ea3QOC/2Xzm Pwya53JcOjGQUg6jQ5n1ma86kso5l7pexPM1MfBugM/GeOPO4JbtsyaKZv/vslm0IBjI c4OQfRp71pjuGnOsa/Q1MUj/5RX5vKJz9OM+J7gy0DkaNndgwGC/no3BhPQgsZyjX8Xq ijW5x4HjU84+FbiEZJH82siRyRWjRK0ylbIDK45MJQC9uP8f4aSWefUOtZYkoMDQr+Zw yAzH+mSx4THEdoewTZ34SVfklZS/z2z8Siax+M9h5zFCP/SXz9k8DlTM+LSPMeSKYqeI 15HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XvrVChY3; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w3si2258098edf.354.2020.11.05.15.02.38; Thu, 05 Nov 2020 15:03:00 -0800 (PST) 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=@chromium.org header.s=google header.b=XvrVChY3; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732505AbgKEW6m (ORCPT + 99 others); Thu, 5 Nov 2020 17:58:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732506AbgKEW6l (ORCPT ); Thu, 5 Nov 2020 17:58:41 -0500 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1337C0401C2 for ; Thu, 5 Nov 2020 14:58:39 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id p22so3147445wmg.3 for ; Thu, 05 Nov 2020 14:58:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Pm0NxoA/7Z6v/tkb4U6GU+e1eqN4wR4f0rR2Wx/opQk=; b=XvrVChY3HLu0cF1X2Yq8eJggFsDulo6GgswvD06X4r+9gZXTKDp5SDIWVoXAZcWISE l1flqo2T1PkPfnrR5U51gBmtbA0Gpw6vaEzAr6yzGSXbbaXwho/E9IpsBs5Xqchb18cp qlBcGtqxKoHrKdKMxWP7UPCDaTVTQICWjlqy8= 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=Pm0NxoA/7Z6v/tkb4U6GU+e1eqN4wR4f0rR2Wx/opQk=; b=tecXlacdQx9qDPMzmBD75a6v3ZwZYDcpGfM5Gc0pTHHNaQua4r0RFgpk/dPifaF16o bMHXS3yPyy+/4qSo/RXFzxR1ybC00oNFuJMapi6HDbDIxGXqe+ZcUylUypocAkrjtgFi htRvZ9UNNt2sn5amYuJ8SmdzhthSqbWKVdiWa/vhUdUK8HSQkXlFnGZVB06oQSQAT2GS w4Th4tuwYXA9G5kCl6u7nKny3kN+4l3XAATcOD3TTueS4lQIZgEaLFBB/gbDA0k6n7as CKwCwHyVYgLaZcHhs2LKTsccjwduVNNHoSlvr1bCi3lcgTTTGPHAGTMLPqUNzKCO8EaG 9tvg== X-Gm-Message-State: AOAM533iKm/FHz2OL4Y/Q/L9JO2M/UVjj63g/yk53WZVMtXCw1rqEmxl WH0JVZGJNVq6LrDl0bVctjyewu7xqRWt/hgJ X-Received: by 2002:a7b:cf05:: with SMTP id l5mr4891609wmg.81.1604617118393; Thu, 05 Nov 2020 14:58:38 -0800 (PST) Received: from kpsingh.c.googlers.com.com (203.75.199.104.bc.googleusercontent.com. [104.199.75.203]) by smtp.gmail.com with ESMTPSA id f19sm3977366wml.21.2020.11.05.14.58.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 14:58:37 -0800 (PST) From: KP Singh To: linux-kernel@vger.kernel.org, bpf@vger.kernel.org Cc: Martin KaFai Lau , Alexei Starovoitov , Daniel Borkmann , Song Liu , Paul Turner , Jann Horn , Hao Luo Subject: [PATCH bpf-next v5 9/9] bpf: Exercise syscall operations for inode and sk storage Date: Thu, 5 Nov 2020 22:58:27 +0000 Message-Id: <20201105225827.2619773-10-kpsingh@chromium.org> X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog In-Reply-To: <20201105225827.2619773-1-kpsingh@chromium.org> References: <20201105225827.2619773-1-kpsingh@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: KP Singh Use the check_syscall_operations added for task_local_storage to exercise syscall operations for other local storage maps: * Check the absence of an element for the given fd. * Create a new element, retrieve and compare its value. * Delete the element and check again for absence. Acked-by: Martin KaFai Lau Signed-off-by: KP Singh --- .../bpf/prog_tests/test_local_storage.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/test_local_storage.c b/tools/testing/selftests/bpf/prog_tests/test_local_storage.c index 5b4788b97d96..2c1b4e9c9a76 100644 --- a/tools/testing/selftests/bpf/prog_tests/test_local_storage.c +++ b/tools/testing/selftests/bpf/prog_tests/test_local_storage.c @@ -152,7 +152,7 @@ static bool check_syscall_operations(int map_fd, int obj_fd) void test_test_local_storage(void) { char tmp_exec_path[PATH_MAX] = "/tmp/copy_of_rmXXXXXX"; - int err, serv_sk = -1, task_fd = -1; + int err, serv_sk = -1, task_fd = -1, rm_fd = -1; struct local_storage *skel = NULL; skel = local_storage__open_and_load(); @@ -176,6 +176,15 @@ void test_test_local_storage(void) if (CHECK(err < 0, "copy_rm", "err %d errno %d\n", err, errno)) goto close_prog; + rm_fd = open(tmp_exec_path, O_RDONLY); + if (CHECK(rm_fd < 0, "open", "failed to open %s err:%d, errno:%d", + tmp_exec_path, rm_fd, errno)) + goto close_prog; + + if (!check_syscall_operations(bpf_map__fd(skel->maps.inode_storage_map), + rm_fd)) + goto close_prog; + /* Sets skel->bss->monitored_pid to the pid of the forked child * forks a child process that executes tmp_exec_path and tries to * unlink its executable. This operation should be denied by the loaded @@ -204,11 +213,15 @@ void test_test_local_storage(void) CHECK(skel->data->sk_storage_result != 0, "sk_storage_result", "sk_local_storage not set\n"); - close(serv_sk); + if (!check_syscall_operations(bpf_map__fd(skel->maps.sk_storage_map), + serv_sk)) + goto close_prog; close_prog_unlink: unlink(tmp_exec_path); close_prog: + close(serv_sk); + close(rm_fd); close(task_fd); local_storage__destroy(skel); } -- 2.29.1.341.ge80a0c044ae-goog