diff options
author | Dmitry V. Levin <ldv@strace.io> | 2023-02-07 08:00:00 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2023-02-07 08:00:00 +0000 |
commit | c6b614438be4e61f24467ae7bca48a68d13efd75 (patch) | |
tree | c18e55116a882a3f34eefcaab502962647532cfd | |
parent | ad5ec9706b6485223ae9e96b6dfda9fff1c333bf (diff) | |
download | strace-c6b614438be4e61f24467ae7bca48a68d13efd75.tar.gz |
tests: check umovestr return value when the string crosses a page boundary
* tests/ioctl_kd.c (check_kbdsent): New check.
-rw-r--r-- | tests/ioctl_kd.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/ioctl_kd.c b/tests/ioctl_kd.c index 42ba519cc..37dd27982 100644 --- a/tests/ioctl_kd.c +++ b/tests/ioctl_kd.c @@ -359,6 +359,25 @@ check_kbdsent(unsigned int c, const char *s) errno = saved_errno; printf("}) = " RETVAL); } + + if (DEFAULT_STRLEN < sizeof(kbse->kb_string) && + (RETVAL_INJECTED || c == KDSKBSENT)) { + /* + * Check how struct kbsentry.kb_string is printed when it + * starts DEFAULT_STRLEN / 2 bytes before the page boundary. + */ + struct kbsentry *const k = + tail_alloc(get_page_size() + + DEFAULT_STRLEN / 2 + sizeof(k->kb_func)); + fill_memory_ex(k->kb_string, DEFAULT_STRLEN - 1, '0', 10); + k->kb_string[DEFAULT_STRLEN - 1] = '\0'; + + sys_ioctl(-1, c, (uintptr_t) k); + printf("ioctl(-1, " XLAT_FMT ", {kb_func=" + XLAT_KNOWN(0xff, "KVAL(K_UNDO)") + ", kb_string=\"%s\"}) = " RETVAL, + XLAT_SEL(c, s), k->kb_string); + } } /* KDGKBDIACR, KDSKBDIACR */ |