From patchwork Thu Mar 7 07:28:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 1052676 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Vu/o2oGU"; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44FMhP20YNz9sDn for ; Thu, 7 Mar 2019 18:29:25 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id D1727294ADF for ; Thu, 7 Mar 2019 08:29:22 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [IPv6:2001:4b78:1:20::7]) by picard.linux.it (Postfix) with ESMTP id 45C363EA2BA for ; Thu, 7 Mar 2019 08:29:20 +0100 (CET) Received: from mail-yw1-xc44.google.com (mail-yw1-xc44.google.com [IPv6:2607:f8b0:4864:20::c44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 988002003BA for ; Thu, 7 Mar 2019 08:29:19 +0100 (CET) Received: by mail-yw1-xc44.google.com with SMTP id u200so12507003ywu.10 for ; Wed, 06 Mar 2019 23:29:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zLfJ9CBWMRNXOyE54GG54r6drWa8CqkGDZwYHZGeEuw=; b=Vu/o2oGU2l6a4GbMHlaCs5+zSsjkAEBdGPyTcLCrcofh4oE0gzvpxnMpMnNgi1M+mB arDMZB4+ZpW9XSpHhnRpSeqgg/0yFsHTkI+SjSYBPHRrj0v1XILQF6x9/LvJZUdFq1Ah c25t8Dl2vGWi+zkLZ4nvm91M739zYf7HG56dOxe2gGIELn0k0slktgqyp5Ycn+uUAQBk 77oqCTeSRikbfsGZMe1SLFNjp3i/P4v80RJc4hhZAUzHqT+nT/QDrtzgLLoD4hMBaP0D cu1W4sCxuB33DTFZf/umSqmYT48HDrpGgwRh0jS9IbzqlVB7s0TLXTOw9McpcDmWzhfi eXrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zLfJ9CBWMRNXOyE54GG54r6drWa8CqkGDZwYHZGeEuw=; b=Izd55LDjfIjNe3HRtvop5UG1aOpWIFhg8/FRirSeuf35mLQMJKucvqnmooJtUxKLUT YdG2dNtW1jmF8UlkIgzzFhE0HfyAEC0458qaboCIOgBV1X4UW+3jir8zM5aw0alPxx5i irV9jYwKK9/jq42MKgF3jIQoulloDLoohQQAJeMP1vK6xBeMSmpxguwCYy3qewHSeM8N AXC5qbOpbLMbpyPG+KAe1jpHRokbO7B6vX6AdRzL/+1TeboUjKMPXRLGrv61C2PidZI+ FBaImgM1hgaDIf4M5wkkWnQRGRVHFatUrjGnJo6Uux9a8UqDpIXQd0kE6VeMjPiXhItl 95cQ== X-Gm-Message-State: APjAAAWAeo/Ad7INnFgqJBCxEIyO+vW5kIQweaB9OVHPfDnuXj65ft4X JoTe4ox5rs4m758eBt0Kn+wPJQZwxQo= X-Google-Smtp-Source: APXvYqy+PC69G2GvTNujWlTkdU2hVlUPlpIA1Bf2wOgsr1spsay+GMGonW0DYdh+19RNf9burmg19Q== X-Received: by 2002:a25:d3c3:: with SMTP id e186mr4845342ybf.493.1551943758334; Wed, 06 Mar 2019 23:29:18 -0800 (PST) Received: from localhost.localdomain ([117.252.64.200]) by smtp.gmail.com with ESMTPSA id v6sm1464108ywc.107.2019.03.06.23.29.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Mar 2019 23:29:18 -0800 (PST) From: Sumit Garg To: ltp@lists.linux.it Date: Thu, 7 Mar 2019 12:58:47 +0530 Message-Id: <1551943728-16222-3-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1551943728-16222-1-git-send-email-sumit.garg@linaro.org> References: <1551943728-16222-1-git-send-email-sumit.garg@linaro.org> X-Virus-Scanned: clamav-milter 0.99.2 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-7.smtp.seeweb.it Cc: daniel.thompson@linaro.org, Greg Hackmann Subject: [LTP] [PATCH 2/3] syscalls/tgkill02: add new test X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Greg Hackmann tgkill() should fail with EAGAIN when RLIMIT_SIGPENDING is reached with a real-time signal. Test this by starting a child thread with SIGRTMIN blocked and a limit of 0 pending signals, then attempting to deliver SIGRTMIN from the parent thread. Signed-off-by: Greg Hackmann Signed-off-by: Sumit Garg --- runtest/syscalls | 1 + testcases/kernel/syscalls/tgkill/.gitignore | 1 + testcases/kernel/syscalls/tgkill/tgkill02.c | 80 +++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 testcases/kernel/syscalls/tgkill/tgkill02.c diff --git a/runtest/syscalls b/runtest/syscalls index 9ed1214..fef45fd 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -1396,6 +1396,7 @@ syslog11 syslog11 syslog12 syslog12 tgkill01 tgkill01 +tgkill02 tgkill02 time01 time01 time02 time02 diff --git a/testcases/kernel/syscalls/tgkill/.gitignore b/testcases/kernel/syscalls/tgkill/.gitignore index f4566fd..42be2bb 100644 --- a/testcases/kernel/syscalls/tgkill/.gitignore +++ b/testcases/kernel/syscalls/tgkill/.gitignore @@ -1 +1,2 @@ tgkill01 +tgkill02 diff --git a/testcases/kernel/syscalls/tgkill/tgkill02.c b/testcases/kernel/syscalls/tgkill/tgkill02.c new file mode 100644 index 0000000..a121992 --- /dev/null +++ b/testcases/kernel/syscalls/tgkill/tgkill02.c @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2018 Google, Inc. + * + * tgkill() should fail with EAGAIN when RLIMIT_SIGPENDING is reached with a + * real-time signal. Test this by starting a child thread with SIGRTMIN + * blocked and a limit of 0 pending signals, then attempting to deliver + * SIGRTMIN from the parent thread. + */ + +#include +#include + +#include "tst_safe_pthread.h" +#include "tst_test.h" +#include "tgkill.h" + +static int test_running; +static pthread_cond_t test_running_cond = PTHREAD_COND_INITIALIZER; +static pthread_mutex_t test_running_mutex = PTHREAD_MUTEX_INITIALIZER; + +static void *thread_func(void *arg) +{ + const struct rlimit sigpending = { + .rlim_cur = 0, + .rlim_max = 0, + }; + sigset_t sigrtmin; + int err; + pid_t *tid = arg; + + sigemptyset(&sigrtmin); + sigaddset(&sigrtmin, SIGRTMIN); + + err = pthread_sigmask(SIG_BLOCK, &sigrtmin, NULL); + if (err) + tst_brk(TBROK, "pthread_sigmask() failed: %s", + tst_strerrno(err)); + + SAFE_SETRLIMIT(RLIMIT_SIGPENDING, &sigpending); + *tid = sys_gettid(); + + TST_CHECKPOINT_WAKE(0); + + pthread_mutex_lock(&test_running_mutex); + while (test_running) + pthread_cond_wait(&test_running_cond, &test_running_mutex); + pthread_mutex_unlock(&test_running_mutex); + + return arg; +} + +static void run(void) +{ + pthread_t thread; + pid_t tid = -1; + + test_running = 1; + + SAFE_PTHREAD_CREATE(&thread, NULL, thread_func, &tid); + + TST_CHECKPOINT_WAIT(0); + + TEST(sys_tgkill(getpid(), tid, SIGRTMIN)); + if (TST_RET && TST_ERR == EAGAIN) + tst_res(TPASS, "tgkill() failed with EAGAIN as expected"); + else + tst_res(TFAIL | TTERRNO, + "tgkill() should have failed with EAGAIN"); + + test_running = 0; + pthread_cond_broadcast(&test_running_cond); + + SAFE_PTHREAD_JOIN(thread, NULL); +} + +static struct tst_test test = { + .needs_checkpoints = 1, + .test_all = run, +};