From: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
To: Jan Stancek <jstancek@redhat.com>, ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH] sched_setaffinity01: use ltp_syscall
Date: Fri, 25 Jul 2014 12:35:28 +0400 [thread overview]
Message-ID: <53D216D0.6010706@oracle.com> (raw)
In-Reply-To: <428ab3048d90dc9d998143aea2b2a624b43d5220.1406276230.git.jstancek@redhat.com>
On 07/25/2014 12:18 PM, Jan Stancek wrote:
> Using glibc wrapper on kernel with smaller CONFIG_NR_CPUS (for example
> 255) leads to segmentation fault in glibc, because it triggers check,
> which is verifying that there are no bits set beyond size of kernel cpu
> mask:
>
> int
> __sched_setaffinity_new (pid_t pid, size_t cpusetsize, const cpu_set_t *cpuset)
> ...
> /* We now know the size of the kernel cpumask_t. Make sure the user
> does not request to set a bit beyond that. */
> for (size_t cnt = __kernel_cpumask_size; cnt < cpusetsize; ++cnt)
> if (((char *) cpuset)[cnt] != '\0') --> CRASH HERE
>
> Call this syscall directly with ltp_syscall().
>
> Reported-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
> Signed-off-by: Jan Stancek <jstancek@redhat.com>
Acked-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
> ---
> .../sched_setaffinity/sched_setaffinity01.c | 11 ++++++++---
> 1 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/sched_setaffinity/sched_setaffinity01.c b/testcases/kernel/syscalls/sched_setaffinity/sched_setaffinity01.c
> index 0ac4478..33a90b8 100644
> --- a/testcases/kernel/syscalls/sched_setaffinity/sched_setaffinity01.c
> +++ b/testcases/kernel/syscalls/sched_setaffinity/sched_setaffinity01.c
> @@ -42,6 +42,7 @@
> #include "usctest.h"
> #include "safe_macros.h"
> #include "sched_setaffinity.h"
> +#include "linux_syscall_numbers.h"
>
> char *TCID = "sched_setaffinity01";
>
> @@ -151,9 +152,13 @@ int main(int argc, char *argv[])
> for (lc = 0; TEST_LOOPING(lc); lc++) {
> tst_count = 0;
> for (i = 0; i < TST_TOTAL; i++) {
> - TEST(sched_setaffinity(*(test_cases[i].pid),
> - *(test_cases[i].mask_size),
> - *(test_cases[i].mask)));
> + /* Avoid calling glibc wrapper function, as it may
> + * try to read/validate data in cpu mask. This test
> + * is passing invalid pointer on purpose. */
> + TEST(ltp_syscall(__NR_sched_setaffinity,
> + *(test_cases[i].pid),
> + *(test_cases[i].mask_size),
> + *(test_cases[i].mask)));
>
> if (TEST_RETURN != -1)
> tst_resm(TFAIL,
>
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2014-07-25 8:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-25 8:18 [LTP] [PATCH] sched_setaffinity01: use ltp_syscall Jan Stancek
2014-07-25 8:35 ` Stanislav Kholmanskikh [this message]
2014-07-25 9:58 ` Jan Stancek
2014-07-25 8:36 ` Wanlong Gao
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=53D216D0.6010706@oracle.com \
--to=stanislav.kholmanskikh@oracle.com \
--cc=jstancek@redhat.com \
--cc=ltp-list@lists.sourceforge.net \
/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