mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Roberto Sassu <roberto.sassu@huawei.com>
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
	kpsingh@kernel.org, john.fastabend@gmail.com,
	songliubraving@fb.com, kafai@fb.com, yhs@fb.com,
	bpf@vger.kernel.org, netdev@vger.kernel.org,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RESEND][PATCH v4 4/4] selftests/bpf: Add test for bpf_verify_pkcs7_signature() helper
Date: Thu, 16 Jun 2022 20:59:08 -0700	[thread overview]
Message-ID: <20220617035908.iw4426f3h4ecpvvp@MacBook-Pro-3.local> (raw)
In-Reply-To: <20220614130621.1976089-5-roberto.sassu@huawei.com>

On Tue, Jun 14, 2022 at 03:06:21PM +0200, Roberto Sassu wrote:
> +
> +	if (child_pid == 0) {
> +		snprintf(path, sizeof(path), "%s/signing_key.pem", tmp_dir);
> +
> +		return execlp("./sign-file", "./sign-file", "sha256",
> +			      path, path, signed_file_template, NULL);

Please use sign_only option,
so it saves the signature and doesn't do 'struct module_signature' append.
Parsing of that is unnecessary for the purpose of the helper.
Checking MODULE_SIG_STRING is unnecessary, etc, etc.
Long term we won't be following mod sig approach anyway.
bpf maps and progs will have a different format.

> +	}
> +
> +	waitpid(child_pid, &child_status, 0);
> +
> +	ret = WEXITSTATUS(child_status);
> +	if (ret)
> +		goto out;
> +
> +	ret = stat(signed_file_template, &st);
> +	if (ret == -1) {
> +		ret = -errno;
> +		goto out;
> +	}
> +
> +	if (st.st_size > sizeof(data_item->payload) - sizeof(u32)) {
> +		ret = -EINVAL;
> +		goto out;
> +	}
> +
> +	*(u32 *)data_item->payload = __cpu_to_be32(st.st_size);
> +
> +	fd = open(signed_file_template, O_RDONLY);
> +	if (fd == -1) {
> +		ret = -errno;
> +		goto out;
> +	}
> +
> +	ret = read(fd, data_item->payload + sizeof(u32), st.st_size);
> +
> +	close(fd);
> +
> +	if (ret != st.st_size) {
> +		ret = -EIO;
> +		goto out;
> +	}
> +
> +	ret = 0;
> +out:
> +	unlink(signed_file_template);
> +	return ret;
> +}
> +
> +void test_verify_pkcs7_sig(void)
> +{
> +	char tmp_dir_template[] = "/tmp/verify_sigXXXXXX";
> +	char *tmp_dir;
> +	char *buf = NULL;
> +	struct test_verify_pkcs7_sig *skel = NULL;
> +	struct bpf_map *map;
> +	struct data data;
> +	u32 saved_len;
> +	int ret, zero = 0;
> +
> +	LIBBPF_OPTS(bpf_object_open_opts, opts);
> +
> +	/* Trigger creation of session keyring. */
> +	syscall(__NR_request_key, "keyring", "_uid.0", NULL,
> +		KEY_SPEC_SESSION_KEYRING);

My understanding that user space can receive a specific id here.
It should pass it to bpf prog via global variable and prog
should use that id instead of max_ulong hack.


      reply	other threads:[~2022-06-17  3:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-14 13:06 [RESEND][PATCH v4 0/4] bpf: Add " Roberto Sassu
2022-06-14 13:06 ` [RESEND][PATCH v4 1/4] bpf: Export bpf_dynptr_get_size() Roberto Sassu
2022-06-14 13:06 ` [RESEND][PATCH v4 2/4] bpf: Add bpf_request_key_by_id() helper Roberto Sassu
2022-06-17  3:46   ` Alexei Starovoitov
2022-06-17  9:11     ` Roberto Sassu
2022-06-17 17:06       ` Alexei Starovoitov
2022-06-14 13:06 ` [RESEND][PATCH v4 3/4] bpf: Add bpf_verify_pkcs7_signature() helper Roberto Sassu
2022-06-14 13:06 ` [RESEND][PATCH v4 4/4] selftests/bpf: Add test for " Roberto Sassu
2022-06-17  3:59   ` Alexei Starovoitov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220617035908.iw4426f3h4ecpvvp@MacBook-Pro-3.local \
    --to=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=roberto.sassu@huawei.com \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®