/* First, test not _locked version of the kfuncs with getxattr. */
/* Read security.bpf.foo and trigger test_inode_getxattr. This * bpf program will set security.bpf.bar to "world".
*/
read_and_validate_foo(skel);
validate_bar_match(skel);
/* Read security.bpf.foo and trigger test_inode_getxattr again. * This will remove xattr security.bpf.bar.
*/
read_and_validate_foo(skel);
validate_bar_removed(skel);
/* Second, test _locked version of the kfuncs, with setxattr */
/* Set security.bpf.foo and trigger test_inode_setxattr. This * bpf program will set security.bpf.bar to "world".
*/
set_foo(skel);
validate_bar_match(skel);
/* Set security.bpf.foo and trigger test_inode_setxattr again. * This will remove xattr security.bpf.bar.
*/
set_foo(skel);
validate_bar_removed(skel);
/* Write random buffer, so the file is not empty */
err = write(fd, buffer, 4096); if (!ASSERT_EQ(err, 4096, "write_file")) goto out;
close(fd);
/* Reopen read-only, otherwise FS_IOC_ENABLE_VERITY will fail */
fd = open(testfile, O_RDONLY, 0644); if (!ASSERT_GE(fd, 0, "open_file1")) return;
/* Enable fsverity for the file. * If the file system doesn't support verity, this will fail. Skip * the test in such case.
*/
arg.version = 1;
arg.hash_algorithm = FS_VERITY_HASH_ALG_SHA256;
arg.block_size = 4096;
err = ioctl(fd, FS_IOC_ENABLE_VERITY, &arg); if (err) {
printf("%s:SKIP:local fs doesn't support fsverity (%d)\n" "To run this test, try enable CONFIG_FS_VERITY and enable FSVerity for the filesystem.\n",
__func__, errno);
test__skip(); goto out;
}
skel = test_fsverity__open_and_load(); if (!ASSERT_OK_PTR(skel, "test_fsverity__open_and_load")) goto out;
/* Get fsverity_digest from ioctl */
d = (struct fsverity_digest *)skel->bss->expected_digest;
d->digest_algorithm = FS_VERITY_HASH_ALG_SHA256;
d->digest_size = SHA256_DIGEST_SIZE;
err = ioctl(fd, FS_IOC_MEASURE_VERITY, skel->bss->expected_digest); if (!ASSERT_OK(err, "ioctl_FS_IOC_MEASURE_VERITY")) goto out;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.