From patchwork Fri Nov 16 06:51:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 998774 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=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gWnTzm+l"; 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 42x8696qT0z9s8F for ; Fri, 16 Nov 2018 17:51:45 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 76D293E76A2 for ; Fri, 16 Nov 2018 07:51:43 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [IPv6:2001:4b78:1:20::5]) by picard.linux.it (Postfix) with ESMTP id 213723E6557 for ; Fri, 16 Nov 2018 07:51:34 +0100 (CET) Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id C4956600F9E for ; Fri, 16 Nov 2018 07:51:33 +0100 (CET) Received: by mail-wr1-x443.google.com with SMTP id p4so14511834wrt.7 for ; Thu, 15 Nov 2018 22:51:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=++NJ8AiPokSvA68QWNKKM90Y53x27D+SfhRFM+f2uFQ=; b=gWnTzm+lE1M8jQhlAR0MUSIldNSMwG075h25FF1cEkodSf7oltOHCT7Oph0Kz4XG1u S/7VNfU4od8MT3UF/X9vVSpOZJ9P+A6FVh/Z6i3+qkFEvOJPTerk6+aIoc8OuEYmFb3f ruGYxP6sKp5tMLIFMtv6TUXjW7WW7dDO1wELWIusHGEI5bDQ1pT8EDk7Wb3FMmyAMYO6 4qyFvEIdXlTtdcPaP7hQMQ1GLw82OLcSjZs0k8rfjuY3luQ66hIXiGn8h1TZhbzgYQ4v 3XWvyrFvyCMPcNRbRzggpkePyMUDUg9765YuI+llGOojjxscEWKVGsb34EqyzOQXPp8+ 1TCA== 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=++NJ8AiPokSvA68QWNKKM90Y53x27D+SfhRFM+f2uFQ=; b=LSmt34/hkMNfKjnjXC1KBAd67w6dVx5qANmjxatvZnoYtIBlH6S6zeIGy4tz4EfLoK GiEMASWXY6Li0c4rXthtAwoNuxnYXdXtH2cfRDnHhYF//qw+g7b9iCVllmLvATCk6/8L iFU3mQvYb4dXvYp4upe4nODGEZi0ll442Y4xd2mHVBJN31HwYen/obBgkFBpu6bvzJso esIIBPX5i0xAhaKRz6jhWfRdXom6Xxkeqyz1FcJHE3nRMpsC22gHWkskMrgu+FOfF9WC tklq/P5ViYcn7SrVWQp5GUFEAYIJuteMRoYfHkkpv0c/aUhP2FXL8G0doT4TehbikmLi 0MYw== X-Gm-Message-State: AA+aEWaEaIXVcriXMi5onXRYKgiTwQybH9C+ql8/bZEN7uELNSruCNhG q4gMZGpl6ylut18vWun57z6sYd81 X-Google-Smtp-Source: AFSGD/Vqe2Yt/gQsy3rIfejWyPKq3GF6jxTJN6S64hARqE9P3Thw2S3OOdAE99GNiRDag5EUxyX9gQ== X-Received: by 2002:a5d:410e:: with SMTP id l14mr162836wrp.61.1542351093315; Thu, 15 Nov 2018 22:51:33 -0800 (PST) Received: from localhost.localdomain ([37.46.46.74]) by smtp.gmail.com with ESMTPSA id z8sm8200598wrr.52.2018.11.15.22.51.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 22:51:32 -0800 (PST) From: Amir Goldstein To: Cyril Hrubis Date: Fri, 16 Nov 2018 08:51:16 +0200 Message-Id: <20181116065119.6912-3-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181116065119.6912-1-amir73il@gmail.com> References: <20181116065119.6912-1-amir73il@gmail.com> X-Virus-Scanned: clamav-milter 0.99.2 at in-5.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, FREEMAIL_FROM, SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-5.smtp.seeweb.it Cc: Jan Kara , ltp@lists.linux.it Subject: [LTP] [PATCH 2/5] syscalls/fanotify03: check permission events also on mountpoint mark 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" Add index to test and repeat it for mark types inode and mountpoint. Signed-off-by: Amir Goldstein --- .../kernel/syscalls/fanotify/fanotify03.c | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/testcases/kernel/syscalls/fanotify/fanotify03.c b/testcases/kernel/syscalls/fanotify/fanotify03.c index 42aac813e..19daf57ef 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify03.c +++ b/testcases/kernel/syscalls/fanotify/fanotify03.c @@ -47,6 +47,20 @@ static unsigned int event_resp[EVENT_MAX]; static char event_buf[EVENT_BUF_LEN]; +static struct tcase { + const char *tname; + struct fanotify_mark_type mark; +} tcases[] = { + { + "inode mark permission events", + INIT_FANOTIFY_MARK_TYPE(INODE), + }, + { + "mount mark permission events", + INIT_FANOTIFY_MARK_TYPE(MOUNT), + }, +}; + static void generate_events(void) { int fd; @@ -120,11 +134,14 @@ static void check_child(void) tst_res(TFAIL, "child %s", tst_strstatus(child_ret)); } -static void setup_mark(void) +static void setup_mark(unsigned int n) { + struct tcase *tc = &tcases[n]; + struct fanotify_mark_type *mark = &tc->mark; + fd_notify = SAFE_FANOTIFY_INIT(FAN_CLASS_CONTENT, O_RDONLY); - if (fanotify_mark(fd_notify, FAN_MARK_ADD, + if (fanotify_mark(fd_notify, FAN_MARK_ADD | mark->flag, FAN_ACCESS_PERM | FAN_OPEN_PERM, AT_FDCWD, fname) < 0) { if (errno == EINVAL) { @@ -133,20 +150,22 @@ static void setup_mark(void) "configured in kernel?"); } else { tst_brk(TBROK | TERRNO, - "fanotify_mark (%d, FAN_MARK_ADD, " + "fanotify_mark (%d, FAN_MARK_ADD | %s, " "FAN_ACCESS_PERM | FAN_OPEN_PERM, " "AT_FDCWD, %s) failed.", - fd_notify, fname); + fd_notify, mark->name, fname); } } + + tst_res(TINFO, "Test #%d: %s", n, tc->tname); } -void test01(void) +static void test_fanotify(unsigned int n) { int tst_count; int ret, len = 0, i = 0, test_num = 0; - setup_mark(); + setup_mark(n); run_child(); tst_count = 0; @@ -247,7 +266,8 @@ static void cleanup(void) } static struct tst_test test = { - .test_all = test01, + .test = test_fanotify, + .tcnt = ARRAY_SIZE(tcases), .setup = setup, .cleanup = cleanup, .needs_tmpdir = 1,