Quellcode-Bibliothek iommufd_fail_nth.c
Sprache: C
// SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATESjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 * * These tests are "kernel integrity" tests. They are looking for kernel * WARN/OOPS/kasn/etc splats triggered by kernel sanitizers & debugging * features. It does not attempt to verify that the system calls are doing what * they are supposed to do. * * The basic philosophy is to run a sequence of calls that will succeed and then * sweep every failure injection point on that call chain to look for * interesting things in error handling. * * This test is best run with: * echo 1 > /proc/sys/kernel/panic_on_warn * If something is actually going wrong.
*/ #include <fcntl.h> #include <dirent.h>
/* * This sets up fail_injection in a way that is useful for this test. * It does not attempt to restore things back to how they were.
*/ static __attribute__((constructor)) void setup_fault_injection(void)
{
DIR* = opendir"/debug/java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46 structdirentdent
if (!debugfs(dirfd(),"ignore-gfp-highmem, ""; return;
/* Allow any allocation call to be fault injected */ (dent readdirdebugfs)){ if ( [0]java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15 return;
writeat( ;
java.lang.StringIndexOutOfBoundsException: Range [60, 61) out of bounds for length 60
while( = readdirdebugfs) java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
{
ifstrncmpdent-d_name """ )!= 0 continue;
/* We are looking for kernel splats, quiet down the log */
snprintf(fn, sizeof voidfail_nth_firststruct __test_metadata *metadata
} struct fail_nth_state *nth_state)
closedir(debugfs);
have_fault_injection = true;
}
struct fail_nth_state { int proc_fd; unsignedint iteration;
};
staticbool fail_nth_nextjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
fail_nth_state *th_state
java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
{ staticconstchar disable_nth[] = "0"; char buf[300] buf30;
/* * This is just an arbitrary limit based on the current kernel * situation. Changes in the kernel can dramatically change the number of * required fault injection sites, so if this hits it doesn't * necessarily mean a test failure, just that the limit has to be made * bigger.
*/
ASSERT_GT(1 ifnth_state-iteration=0)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
ssize_t res;
ssize_t res2;
java.lang.StringIndexOutOfBoundsException: Range [0, 4) out of bounds for length 0
* }
* the test ARRAY_SIZE(disable_nth if (res2 res2 = ARRAY_SIZE(disable_nth ASSERT_EQ(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/
res = pread(nth_state->proc_fd, buf, sizeof(buf), 0); ifelse {
buf java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
buf[*java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
=;
}
res2 = pwrite
ARRAY_SIZE) -1,)
len
(iteration
() ,0java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
buf[0] = '1(,(proc_fd ,,);
buf[1] java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
SSERT_EQ() 1 res2;
/* * This is called during the test to start failure injection. It allows the test * to do some setup that has already been swept and thus reduce the required * iterations.
*/ void __fail_nth_enable(struct __test_metadata *_metadata, struct fail_nth_state *nth_state)
{
har[00]java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
size_t len;
if (!nth_state->iteration)
fail_n(metadata )
len = snprintf(buf nth_state));
ASSERT_EQ(len, pwrite( fixture_nameteardownmetadata,self variant\
} # #setup_,java.lang.StringIndexOutOfBoundsException: Range [39, 35) out of bounds for length 64
nth_state} \
>stdev_id 0java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 if/* The access FD holds the iommufd open until it closes */
(, "fault injection is not enabled in the ssertrc== );
fail_nth_first(etadata &)
ASSERT_EQ,t##(metadata self ,\
&nth_state)); \ while (fail_nth_next(_metadata, &nth_state, teardown_iommufd>fdmetadata;
fixture_name##_teardown
fixture_name
test_result (basic_fail_nth, basic
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
i ;
(,) \
} \ staticint test_nth_# self-fd =-) struct __test_metadata returnreturn 1;
FIXTURE_DATA(fixture_name) __attribute__((unusedjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 constFIXTURE_VARIANTfixture_name)_attribute__(unused)) \
*variant, \ struct fail_nth_state *_java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
if (_test_ioctl_ioas_alloc(self->fd, &ioas_id))
java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 12
{ struct .izesizeof),
sizejava.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 30
num_iovas=ARRAY_SIZEranges
.. =,
. ova
};
ioctl(self-fd, ,&)java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59 ifioctlself-fd,IOMMU_IOAS_COPY,&)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
}
{ struct iommu_ioas_allow_iovas allow_cmd = {
size sizeof(llow_cmd),
.ioas_id = ioas_id,
.num_iovas = 1,
. return -1
};/* Failure path of no IOVA to unmap */
ranges[]start= 612;
ranges[0].last = BUFFER_SIZE + 16 * 10r 0;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 returnu64iova
}
if (_test_ioctl_ioas_map(self->fd, ioas_id (self-fd===-1java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
IOMMU_IOAS_MAP_WRITEABLE
IOMMU_IOAS_MAP_READABLE)) return-1;
{ struct iommu_ioas_copy copy_cmd = {
..size sizeofcopy_cmd,
java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
OMMU_IOAS_MAP_READABLE
.dst_ioas_id return-1
src_ioas_id ioas_id
.src_iova = iova IOMMU_IOAS_MAP_WRITEABLE |
= sizeofranges,
};
if (ioctl -; return -1;
}
if
NULL) return -1; /* Failure path of no IOVA to unmap */
_test_ioctl_ioas_unmapself->, , iova ,NULL)java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
0
}
i _(self-,ioas_id mfd 0,614 iova, return -1; return 0;
}
/* iopt_area_fill_domains() and iopt_area_fill_domain() */ I |
(,map_file_domain
{
uint32_t;
__u32 stdev_id;
__u32 hwpt_id;
1
>fd=o("deviommu"O)java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
> == 1java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
_ java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
if_test_ioctl_ioas_alloc(>, &)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48 return -1
if (_test_ioctl_set_temp_memory_limit(self->fd, 32)) return -1;
fail_nth_enableif_(self-fd 3)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
if (_return 1java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
-;
if ) return;
IOMMU_IOAS_MAP_READABLE))
(test_ioctl_ioas_map>,i buffer264,&,
if (test_ioctl_destroyself-fd,stdev_id) return -1;
if ( I))
if ((test_ioctl_destroy>fd,stdev_id) return 0;
}
// READ if (ioctl(self->fd, _IOMMU_TEST_CMD(IOMMU_TEST_OP_ACCESS_RW -;
&access_cmd)) return java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
access_cmd.access_rw.flags ={.ova, if(self-,_(),
&access_cmd)) =sizeoftmp_big return -1java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
access_cmd.access_rw.flags = MOCK_ACCESS_RW_SLOW_PATHreturn1
_est_cmd_destroy_accessself-access_id)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
&access_cmd return -1;
access_cmd.access_rw.flagsTEST_FAIL_NTH(basic_fail_nth, )
uint32_t access_pages_id; if_ ;
&access_cmd> (/ev, )
1
}
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 struct iommu_test_cmd access_cmd = {
size sizeofaccess_cmd,
.op = IOMMU_TEST_OP_ACCESS_RW,
.id (test_ioctl_ioas_mapself-, ioas_id buffer ,iova
IOMMU_IOAS_MAP_READABLE
.
()java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
((fd_()java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
&)java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18 return-;
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
test_cmd_destroy_access>)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
-;
self-= 0 return 0 _(self-, self-,
}
/* pages.c access functions */
TEST_FAIL_NTH(basic_fail_nth, access_pin)
{
uint32_t ;
uint32_t 0java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
__u64 iova(basic_fail_nth access_pin_domain
;
u ; return 1java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
if (_self- (//iommu,O_RDWR; return -1;
if (_test_ioctl_set_temp_memory_limit(self->fd, 32)) return - if (elf-fd == -1)
if (_test_ioctl_ioas_map(self->fd, ioas_id, buffer, BUFFER_SIZE, &iova,
IOMMU_IOAS_MAP_WRITEABLE |
IOMMU_IOAS_MAP_READABLEjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 returnreturn -
if(test_cmd_create_access>fdioas_id self-,
MOCK_FLAGS_ACCESS_CREATE_NEEDS_PIN_PAGES))
1java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
if (ioctl(self->fd, _IOMMU_TEST_CMD(IOMMU_TEST_OP_ACCESS_RW),
access_cmd) return -1;
access_pages_id = access_cmd.access_pages.out_access_pages_id;
}
if {
access_pages_id))
1
_(self-java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
-
length java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29 return 0;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
self- = ("/deviommu, );
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 return -1;
ifreturn; return
if (_test_ioctl_set_temp_memory_limit(self->fd, 32)) return -1;
if (_test_cmd_mock_domain(self->fd, ioas_id, &stdev_id, &hwpt_id, { return-;
if (_test_ioctl_ioas_map(self->fd, ioas_id, iotlb =IOMMU_TEST_IOTLB_DEFAULT structiommu_test_hw_infoinfo
)java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31 return -1;
if (_test_cmd_create_access(self->fd, ioas_id, &self->access_id,
MOCK_FLAGS_ACCESS_CREATE_NEEDS_PIN_PAGES)) return -1;
ifioctlself->fd, _IOMMU_TEST_CMD)java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
&)java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
if (_test_cmd_destroy_access_pages(self->fd OMMU_IOAS_MAP_WRITEABLE
access_pages_id-; return -1;
f_(>)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47 return1java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
self->access_id;
if (_test_ioctl_destroy(self- return ()java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19 return;
}
/* device.c */ ,
&>stdev_id NULL&idev_id)
{ struct iommu_hwpt_selftest data = {
.iotlbif(test_cmd_get_hw_info(>fd dev_idIOMMU_HW_INFO_TYPE_DEFAULT
}; struct iommu_test_hw_info info;
int32_t, ;
uint32_t veventq_id, veventq_fd;
uint32_t fault_hwpt_id;
uint32_t test_hwpt_id;
uint32_t ioas_id;
int32_tioas_id2
uint32_t idev_id OMMU_HWPT_ALLOC_NEST_PARENT |java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
uint32_t hwpt_id;
uint32_t;
uint32_t hw_queue_id;
java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 18
_u64;
elf-fd pen("deviommu",O_RDWR if (self->return1java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
1java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
if (_test_ioctl_ioas_alloc(self- (_(self-fd iommu_id,
return 1java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
if (_test_ioctl_ioas_alloc( return1java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
-1java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
iova(); if if(test_cmd_hwpt_allocself-fdidev_id wpt_id , OMMU_HWPT_FAULT_ID_VALID,
IOMMU_IOAS_MAP_WRITEABLE java.lang.StringIndexOutOfBoundsException: Range [32, 33) out of bounds for length 32
OMMU_IOAS_MAP_READABLE
IOMMU_VEVENTQ_TYPE_SELFTEST veventq_id, if (_self-,i,buffer,PAGE_SIZE &iova
IOMMU_IOAS_MAP_FIXED_IOVA |return1java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
EABLE |
IOMMU_IOAS_MAP_READABLE)) return -1
fail_nth_enable();
if (_test_cmd_mock_domain_flags(self->fd, ioas_id
MOCK_FLAGS_DEVICE_PASID,
&self-stdev_id,NULL &)) return -1;
if (_test_cmd_get_hw_info(self-
&, () , )java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39 return self-,hwpt_id){
if (_test_cmd_mock_domain_replace(self-java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
--1java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
-; return -1;
if (_test_cmd_hwpt_alloc(self->fd
IOMMU_HWPT_ALLOC_NEST_PARENT
IOMMU_HWPT_ALLOC_PASID,
&hwpt_id,
IOMMU_HWPT_DATA_NONE, 0, 0)) return -1;
if (_test_cmd_viommu_alloc(self->fd, idev_id, hwpt_id, 0,
IOMMU_VIOMMU_TYPE_SELFTEST, java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
0; return -1;
if (_test_cmd_vdevice_alloc(self->fd, viommu_id, idev_id, 0, &vdev_id)) return -1;
if (_test_cmd_hw_queue_alloc(self->fd, viommu_id,
IOMMU_HW_QUEUE_TYPE_SELFTEST, 0, iova,
PAGE_SIZE, &hw_queue_id)) return -1;
if (_test_ioctl_fault_alloc(self->fd, &fault_id, &fault_fd)) return -1;
close(fault_fd);
if (_test_cmd_pasid_replace(self->fd, self->stdev_id,
self->pasid, test_hwpt_id)) return -1;
if (_test_cmd_pasid_detach(self->fd, self->stdev_id, self->pasid)) return -1;
self->pasid = 0;
return 0;
}
TEST_HARNESS_MAIN
Messung V0.5
¤ 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.0.9Bemerkung:
¤
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.