From patchwork Tue Mar 19 06:49:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 160528 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp3526506jad; Mon, 18 Mar 2019 23:50:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqztmDc8A33Qyiey+nD4wf8jA8hinp922K91VI7VcvoPkpkJ+LIaPPi/EaB9bcVYq71MP+5D X-Received: by 2002:adf:e50d:: with SMTP id j13mr5234731wrm.165.1552978226927; Mon, 18 Mar 2019 23:50:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552978226; cv=none; d=google.com; s=arc-20160816; b=dVpAoZSv5L7aRgW6OeAsMmhuNS/fPGscKLrlcMPTWQT2d1uA6J6c4cU7f/Yk9Prc0B /QchETG1PXIH6ovsSszzUQs4h8u7w7AjeFzkzE7w4AmTWmgPcYC7I8rT7qon+IbhNaRZ YnT/2gi/mTLGAD1Pm6aL7tBWfWbaaGxjVF1JxY9PWgd8ZbKGC9rWn39+i0K7xKHckitB 24DouPnjQrBRPL8+xqYRFZmuuyo5jpMtvtIXfyaIv3FaJfInlZ1FQZ0qS24r2JrjGbwM 87oogA1BIG6VRCAFuBTp9/s9PoS82vyBdsf623t62FUFj3GTF9LLtcKUvP3VirJlAxCu I0qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=+HtKaSYKl6EeaDSWsW06j81LUp7crUYv1F+wDI1rWPk=; b=eNMdKS4bIe50tjPcF1i2mrw/P1Ds5LWRh2sIYFJCG17xOHpXU8Q3tqTvztcL+vhPSL prq3tYHjHEaaB70Wq5QsnMzkIxMPaq1DzOAD9Lv7RV2YcnNd8nl4zx38JTA2Z3NiOvbE S/kTrSVoK6IhGa7CO4pZxltTetO5N8EBNkeIYGL4vSfKnlaE7hJtl+6tWn1XZfXaLmMV JixJBOvyI4ZlhXm7IMLu9nhFmoBZEy8hQGUjNq0f6qoQhgwy63HnwyWvDAwfaTftdW91 CzsQlASaP1/fY7p8Y9vgsTm/2Ld4i7D3SHomva9hXiOmirXX456RaKuIYzsCa6teE/Nk QfKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=aXXoJA6F; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 2001:1418:10:5::2 as permitted sender) smtp.mailfrom="ltp-bounces+patch=linaro.org@lists.linux.it"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from picard.linux.it (picard.linux.it. [2001:1418:10:5::2]) by mx.google.com with ESMTPS id y14si7851869wro.331.2019.03.18.23.50.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Mar 2019 23:50:26 -0700 (PDT) Received-SPF: pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 2001:1418:10:5::2 as permitted sender) client-ip=2001:1418:10:5::2; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=aXXoJA6F; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 2001:1418:10:5::2 as permitted sender) smtp.mailfrom="ltp-bounces+patch=linaro.org@lists.linux.it"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 6E684294AD2 for ; Tue, 19 Mar 2019 07:50:26 +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 [217.194.8.7]) by picard.linux.it (Postfix) with ESMTP id 1BB5A3EAEC7 for ; Tue, 19 Mar 2019 07:50:16 +0100 (CET) Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (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 073C620E756 for ; Tue, 19 Mar 2019 07:50:16 +0100 (CET) Received: by mail-pf1-x444.google.com with SMTP id v21so13026039pfm.12 for ; Mon, 18 Mar 2019 23:50:15 -0700 (PDT) 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=OiBK8Wt1vg2VhPn24Nuj9SzmSRrI+ADUEWGHxxtIbXk=; b=aXXoJA6FijHLUA47GY3aKWiQflbNf8pyh5Q1gBTkqjWz6HPRBSuNbl2wmCc+zQ9vJs 6I9hau5Tq7bQ7YownaHtiIP8bhL2jq0sNrS8VocRK+0Qy4vzxRjTdZGqvS7mgQLTAj4+ KOQ1+NihBKGNAuaT5uqPtSdPvJgTa7oM5akOj/87zl0n0WRwNSADs/Ix8i5IrX7A1B0N 3n1B2QC/YBairwYX+d6cC+mBUs0gY6/8o0lt1NezynSEWFfLaZV5+4+JhynMM0BLS+Gu PJdN+XsGBCros5T31eMUJzrZyX4hFgTQpTFL/iLDnP4nR6M2AnW4BUuvAMgY6WjiZvGr DSjQ== 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=OiBK8Wt1vg2VhPn24Nuj9SzmSRrI+ADUEWGHxxtIbXk=; b=KgibTY+dCfwMBZV1YAB7coO53NFzNxWBiSskmTRJlyfKb6OiOaAoF5PL29q3w9jyXX 00wduEvyHTwVYc3lhi5DPAHPCgWRUsu4V/Dwug4g528mhSALy8E6iNi+RNSgGki7TtvM gRjYUhXo5hqQIk2/GzcIIJo+8inXrMWdSGr1tka66hVovh8ArjQ20pnPBsLEhVaoHK/P t6zhwRHvuSHMAtfjlqecjF4poTjjikE26KnLUwn7N/Di4HOA3PgPGq7zcTcKPmRVG92f CDNPRd9Aq+L8IVw8rNV482M7Be+BuvBH2Zv3RZWDyQMwsoWbreQ6IpJKrhZgtQvQSdIa 9z9w== X-Gm-Message-State: APjAAAUIP8qElRHRInEcno1dwIU373ohIC7cYInAn2UQRuUTusGIsqWd 4SbFe8KDlE9WOagsq5WhSZRAIUb7IjrAHg== X-Received: by 2002:aa7:8c8c:: with SMTP id p12mr628002pfd.0.1552978214375; Mon, 18 Mar 2019 23:50:14 -0700 (PDT) Received: from localhost.localdomain ([117.196.233.204]) by smtp.gmail.com with ESMTPSA id 16sm12452852pfz.106.2019.03.18.23.50.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Mar 2019 23:50:13 -0700 (PDT) From: Sumit Garg To: ltp@lists.linux.it, chrubis@suse.cz Date: Tue, 19 Mar 2019 12:19:40 +0530 Message-Id: <1552978181-27748-3-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1552978181-27748-1-git-send-email-sumit.garg@linaro.org> References: <1552978181-27748-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 v3 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+patch=linaro.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 Reviewed-by: Li Wang --- runtest/syscalls | 1 + testcases/kernel/syscalls/tgkill/.gitignore | 1 + testcases/kernel/syscalls/tgkill/tgkill02.c | 68 +++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 testcases/kernel/syscalls/tgkill/tgkill02.c diff --git a/runtest/syscalls b/runtest/syscalls index d6999f0..7af9136 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -1401,6 +1401,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..88f3842 --- /dev/null +++ b/testcases/kernel/syscalls/tgkill/tgkill02.c @@ -0,0 +1,68 @@ +// 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 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_AND_WAIT(0); + + return arg; +} + +static void run(void) +{ + pthread_t thread; + pid_t tid = -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"); + + TST_CHECKPOINT_WAKE(0); + + SAFE_PTHREAD_JOIN(thread, NULL); +} + +static struct tst_test test = { + .needs_checkpoints = 1, + .test_all = run, +};