mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2024-12-28 08:42:10 +00:00
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git
This commit is contained in:
commit
410a2fb2e3
@ -24,7 +24,7 @@ int main(void)
|
||||
|
||||
// Check if test is run a root
|
||||
if (geteuid()) {
|
||||
ksft_test_result_skip("This test needs root to run!\n");
|
||||
ksft_exit_skip("This test needs root to run!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1,2 +1,3 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
statmount_test_ns
|
||||
/*_test
|
||||
|
@ -194,7 +194,7 @@ int fill_msgque(struct msgque_data *msgque)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int msg, pid, err;
|
||||
int err;
|
||||
struct msgque_data msgque;
|
||||
|
||||
if (getuid() != 0)
|
||||
|
@ -18,7 +18,8 @@
|
||||
* ksft_print_msg(fmt, ...);
|
||||
* ksft_perror(msg);
|
||||
*
|
||||
* and finally report the pass/fail/skip/xfail state of the test with one of:
|
||||
* and finally report the pass/fail/skip/xfail/xpass state of the test
|
||||
* with one of:
|
||||
*
|
||||
* ksft_test_result(condition, fmt, ...);
|
||||
* ksft_test_result_report(result, fmt, ...);
|
||||
@ -26,6 +27,7 @@
|
||||
* ksft_test_result_fail(fmt, ...);
|
||||
* ksft_test_result_skip(fmt, ...);
|
||||
* ksft_test_result_xfail(fmt, ...);
|
||||
* ksft_test_result_xpass(fmt, ...);
|
||||
* ksft_test_result_error(fmt, ...);
|
||||
* ksft_test_result_code(exit_code, test_name, fmt, ...);
|
||||
*
|
||||
@ -147,6 +149,11 @@ static inline void ksft_set_plan(unsigned int plan)
|
||||
|
||||
static inline void ksft_print_cnts(void)
|
||||
{
|
||||
if (ksft_cnt.ksft_xskip > 0)
|
||||
printf(
|
||||
"# %u skipped test(s) detected. Consider enabling relevant config options to improve coverage.\n",
|
||||
ksft_cnt.ksft_xskip
|
||||
);
|
||||
if (ksft_plan != ksft_test_num())
|
||||
printf("# Planned tests != run tests (%u != %u)\n",
|
||||
ksft_plan, ksft_test_num());
|
||||
@ -227,6 +234,20 @@ static inline __printf(1, 2) void ksft_test_result_xfail(const char *msg, ...)
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static inline __printf(1, 2) void ksft_test_result_xpass(const char *msg, ...)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
va_list args;
|
||||
|
||||
ksft_cnt.ksft_xpass++;
|
||||
|
||||
va_start(args, msg);
|
||||
printf("ok %u # XPASS ", ksft_test_num());
|
||||
errno = saved_errno;
|
||||
vprintf(msg, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static inline __printf(1, 2) void ksft_test_result_skip(const char *msg, ...)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
@ -318,6 +339,9 @@ void ksft_test_result_code(int exit_code, const char *test_name,
|
||||
case KSFT_XFAIL: \
|
||||
ksft_test_result_xfail(fmt, ##__VA_ARGS__); \
|
||||
break; \
|
||||
case KSFT_XPASS: \
|
||||
ksft_test_result_xpass(fmt, ##__VA_ARGS__); \
|
||||
break; \
|
||||
case KSFT_SKIP: \
|
||||
ksft_test_result_skip(fmt, ##__VA_ARGS__); \
|
||||
break; \
|
||||
@ -403,7 +427,7 @@ static inline __noreturn __printf(1, 2) void ksft_exit_skip(const char *msg, ...
|
||||
*/
|
||||
if (ksft_plan || ksft_test_num()) {
|
||||
ksft_cnt.ksft_xskip++;
|
||||
printf("ok %d # SKIP ", 1 + ksft_test_num());
|
||||
printf("ok %u # SKIP ", 1 + ksft_test_num());
|
||||
} else {
|
||||
printf("1..0 # SKIP ");
|
||||
}
|
||||
|
@ -27,6 +27,9 @@ def set_plan(num_tests):
|
||||
|
||||
|
||||
def print_cnts():
|
||||
if ksft_cnt['skip'] > 0:
|
||||
print(f"# {ksft_cnt['skip']} skipped test(s) detected. Consider enabling relevant config options to improve coverage.")
|
||||
|
||||
print(
|
||||
f"# Totals: pass:{ksft_cnt['pass']} fail:{ksft_cnt['fail']} xfail:0 xpass:0 skip:{ksft_cnt['skip']} error:0"
|
||||
)
|
||||
|
@ -107,5 +107,9 @@ ktap_finished() {
|
||||
}
|
||||
|
||||
ktap_print_totals() {
|
||||
if [ "$KTAP_CNT_SKIP" -gt 0 ]; then
|
||||
echo "# $KTAP_CNT_SKIP skipped test(s) detected. " \
|
||||
"Consider enabling relevant config options to improve coverage."
|
||||
fi
|
||||
echo "# Totals: pass:$KTAP_CNT_PASS fail:$KTAP_CNT_FAIL xfail:0 xpass:0 skip:$KTAP_CNT_SKIP error:0"
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
Testing for regressions in Media Controller API register, ioctl, syscall,
|
||||
and unregister paths. There have a few problems that result in user-after
|
||||
and unregister paths. There have a few problems that result in use-after
|
||||
free on media_device, media_devnode, and cdev pointers when the driver is
|
||||
unbound while ioctl is in progress.
|
||||
|
||||
@ -15,11 +15,11 @@ Build media_device_test
|
||||
cd tools/testing/selftests/media_tests
|
||||
make
|
||||
|
||||
Regressions test for cdev user-after free error on /dev/mediaX when driver
|
||||
Regressions test for cdev use-after-free error on /dev/mediaX when driver
|
||||
is unbound:
|
||||
|
||||
Start media_device_test to regression test media devnode dynamic alloc
|
||||
and cdev user-after-free fixes. This opens media dev files and sits in
|
||||
and cdev use-after-free fixes. This opens media dev files and sits in
|
||||
a loop running media ioctl MEDIA_IOC_DEVICE_INFO command once every 10
|
||||
seconds. The idea is when device file goes away, media devnode and cdev
|
||||
should stick around until this test exits.
|
||||
@ -40,4 +40,4 @@ keep ioctls going while bind/unbind runs.
|
||||
Copy bind_unbind_sample.txt and make changes to specify the driver name
|
||||
and number to run bind and unbind. Start the bind_unbind.sh
|
||||
|
||||
Run dmesg looking for any user-after free errors or mutex lock errors.
|
||||
Run dmesg looking for any use-after-free errors or mutex lock errors.
|
||||
|
@ -156,8 +156,8 @@ int main(int argc, char **argv)
|
||||
/* Check everything is sane before we start switching asynchronously */
|
||||
if (do_sanity_check) {
|
||||
for (i = 0; i < count; i++) {
|
||||
printf("Validating clocksource %s\n",
|
||||
clocksource_list[i]);
|
||||
ksft_print_msg("Validating clocksource %s\n",
|
||||
clocksource_list[i]);
|
||||
if (change_clocksource(clocksource_list[i])) {
|
||||
status = -1;
|
||||
goto out;
|
||||
@ -169,7 +169,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
printf("Running Asynchronous Switching Tests...\n");
|
||||
ksft_print_msg("Running Asynchronous Switching Tests...\n");
|
||||
pid = fork();
|
||||
if (!pid)
|
||||
return run_tests(runtime);
|
||||
|
@ -53,6 +53,7 @@ static struct vdso_info
|
||||
/* Symbol table */
|
||||
ELF(Sym) *symtab;
|
||||
const char *symstrings;
|
||||
ELF(Word) *gnu_hash;
|
||||
ELF_HASH_ENTRY *bucket, *chain;
|
||||
ELF_HASH_ENTRY nbucket, nchain;
|
||||
|
||||
@ -81,6 +82,16 @@ static unsigned long elf_hash(const char *name)
|
||||
return h;
|
||||
}
|
||||
|
||||
static uint32_t gnu_hash(const char *name)
|
||||
{
|
||||
const unsigned char *s = (void *)name;
|
||||
uint32_t h = 5381;
|
||||
|
||||
for (; *s; s++)
|
||||
h += h * 32 + *s;
|
||||
return h;
|
||||
}
|
||||
|
||||
void vdso_init_from_sysinfo_ehdr(uintptr_t base)
|
||||
{
|
||||
size_t i;
|
||||
@ -123,6 +134,7 @@ void vdso_init_from_sysinfo_ehdr(uintptr_t base)
|
||||
*/
|
||||
ELF_HASH_ENTRY *hash = 0;
|
||||
vdso_info.symstrings = 0;
|
||||
vdso_info.gnu_hash = 0;
|
||||
vdso_info.symtab = 0;
|
||||
vdso_info.versym = 0;
|
||||
vdso_info.verdef = 0;
|
||||
@ -143,6 +155,11 @@ void vdso_init_from_sysinfo_ehdr(uintptr_t base)
|
||||
((uintptr_t)dyn[i].d_un.d_ptr
|
||||
+ vdso_info.load_offset);
|
||||
break;
|
||||
case DT_GNU_HASH:
|
||||
vdso_info.gnu_hash =
|
||||
(ELF(Word) *)((uintptr_t)dyn[i].d_un.d_ptr +
|
||||
vdso_info.load_offset);
|
||||
break;
|
||||
case DT_VERSYM:
|
||||
vdso_info.versym = (ELF(Versym) *)
|
||||
((uintptr_t)dyn[i].d_un.d_ptr
|
||||
@ -155,17 +172,27 @@ void vdso_init_from_sysinfo_ehdr(uintptr_t base)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!vdso_info.symstrings || !vdso_info.symtab || !hash)
|
||||
if (!vdso_info.symstrings || !vdso_info.symtab ||
|
||||
(!hash && !vdso_info.gnu_hash))
|
||||
return; /* Failed */
|
||||
|
||||
if (!vdso_info.verdef)
|
||||
vdso_info.versym = 0;
|
||||
|
||||
/* Parse the hash table header. */
|
||||
vdso_info.nbucket = hash[0];
|
||||
vdso_info.nchain = hash[1];
|
||||
vdso_info.bucket = &hash[2];
|
||||
vdso_info.chain = &hash[vdso_info.nbucket + 2];
|
||||
if (vdso_info.gnu_hash) {
|
||||
vdso_info.nbucket = vdso_info.gnu_hash[0];
|
||||
/* The bucket array is located after the header (4 uint32) and the bloom
|
||||
* filter (size_t array of gnu_hash[2] elements).
|
||||
*/
|
||||
vdso_info.bucket = vdso_info.gnu_hash + 4 +
|
||||
sizeof(size_t) / 4 * vdso_info.gnu_hash[2];
|
||||
} else {
|
||||
vdso_info.nbucket = hash[0];
|
||||
vdso_info.nchain = hash[1];
|
||||
vdso_info.bucket = &hash[2];
|
||||
vdso_info.chain = &hash[vdso_info.nbucket + 2];
|
||||
}
|
||||
|
||||
/* That's all we need. */
|
||||
vdso_info.valid = true;
|
||||
@ -209,6 +236,26 @@ static bool vdso_match_version(ELF(Versym) ver,
|
||||
&& !strcmp(name, vdso_info.symstrings + aux->vda_name);
|
||||
}
|
||||
|
||||
static bool check_sym(ELF(Sym) *sym, ELF(Word) i, const char *name,
|
||||
const char *version, unsigned long ver_hash)
|
||||
{
|
||||
/* Check for a defined global or weak function w/ right name. */
|
||||
if (ELF64_ST_TYPE(sym->st_info) != STT_FUNC)
|
||||
return false;
|
||||
if (ELF64_ST_BIND(sym->st_info) != STB_GLOBAL &&
|
||||
ELF64_ST_BIND(sym->st_info) != STB_WEAK)
|
||||
return false;
|
||||
if (strcmp(name, vdso_info.symstrings + sym->st_name))
|
||||
return false;
|
||||
|
||||
/* Check symbol version. */
|
||||
if (vdso_info.versym &&
|
||||
!vdso_match_version(vdso_info.versym[i], version, ver_hash))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void *vdso_sym(const char *version, const char *name)
|
||||
{
|
||||
unsigned long ver_hash;
|
||||
@ -216,29 +263,36 @@ void *vdso_sym(const char *version, const char *name)
|
||||
return 0;
|
||||
|
||||
ver_hash = elf_hash(version);
|
||||
ELF(Word) chain = vdso_info.bucket[elf_hash(name) % vdso_info.nbucket];
|
||||
ELF(Word) i;
|
||||
|
||||
for (; chain != STN_UNDEF; chain = vdso_info.chain[chain]) {
|
||||
ELF(Sym) *sym = &vdso_info.symtab[chain];
|
||||
if (vdso_info.gnu_hash) {
|
||||
uint32_t h1 = gnu_hash(name), h2, *hashval;
|
||||
|
||||
/* Check for a defined global or weak function w/ right name. */
|
||||
if (ELF64_ST_TYPE(sym->st_info) != STT_FUNC)
|
||||
continue;
|
||||
if (ELF64_ST_BIND(sym->st_info) != STB_GLOBAL &&
|
||||
ELF64_ST_BIND(sym->st_info) != STB_WEAK)
|
||||
continue;
|
||||
if (sym->st_shndx == SHN_UNDEF)
|
||||
continue;
|
||||
if (strcmp(name, vdso_info.symstrings + sym->st_name))
|
||||
continue;
|
||||
|
||||
/* Check symbol version. */
|
||||
if (vdso_info.versym
|
||||
&& !vdso_match_version(vdso_info.versym[chain],
|
||||
version, ver_hash))
|
||||
continue;
|
||||
|
||||
return (void *)(vdso_info.load_offset + sym->st_value);
|
||||
i = vdso_info.bucket[h1 % vdso_info.nbucket];
|
||||
if (i == 0)
|
||||
return 0;
|
||||
h1 |= 1;
|
||||
hashval = vdso_info.bucket + vdso_info.nbucket +
|
||||
(i - vdso_info.gnu_hash[1]);
|
||||
for (;; i++) {
|
||||
ELF(Sym) *sym = &vdso_info.symtab[i];
|
||||
h2 = *hashval++;
|
||||
if (h1 == (h2 | 1) &&
|
||||
check_sym(sym, i, name, version, ver_hash))
|
||||
return (void *)(vdso_info.load_offset +
|
||||
sym->st_value);
|
||||
if (h2 & 1)
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
i = vdso_info.bucket[elf_hash(name) % vdso_info.nbucket];
|
||||
for (; i; i = vdso_info.chain[i]) {
|
||||
ELF(Sym) *sym = &vdso_info.symtab[i];
|
||||
if (sym->st_shndx != SHN_UNDEF &&
|
||||
check_sym(sym, i, name, version, ver_hash))
|
||||
return (void *)(vdso_info.load_offset +
|
||||
sym->st_value);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
2
tools/testing/selftests/zram/.gitignore
vendored
Normal file
2
tools/testing/selftests/zram/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
err.log
|
Loading…
Reference in New Issue
Block a user