From patchwork Mon Jun 24 08:52:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 1121168 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=2001:1418:10:5::2; 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="WzcDKsGc"; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45XNNV10w1z9s7h for ; Mon, 24 Jun 2019 18:52:56 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 863403C14C2 for ; Mon, 24 Jun 2019 10:52:53 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) by picard.linux.it (Postfix) with ESMTP id 965003C034E for ; Mon, 24 Jun 2019 10:52:50 +0200 (CEST) Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 0CF071400044 for ; Mon, 24 Jun 2019 10:52:50 +0200 (CEST) Received: by mail-wm1-x342.google.com with SMTP id u8so12458175wmm.1 for ; Mon, 24 Jun 2019 01:52:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=WXFk1khXw7w9JayWCtJqPeCIfdpFk03EWcfew3oQchA=; b=WzcDKsGclsbXqhxOu/tvyyZzP5isS9NYXiD/OFYWEjnymXxtJxrtprGIJL29u+UPEZ /sAb8r1KAYqJ05+ZV9EDaVOS4+E9znb+uSWTCkvfLTcOVvAbwePdOhy9sz7xjjjvYYk2 9nBQ+FZ2FjbfxtRRP44QEJlyDiE1DcXuAQaDkJ7XGkmOJQQG2muUc/bWRbeiNocW2Qud M7FypdvpUg4EILNM036p8F+qgol/YvW7jLIlfdjIaWlM9XjRg+yrIgHniDaZ2YRLynKc E6mNeBamLIyRomVYSrv+boJuRvsptxXvXF1UyL6ocwOwQnIPj3/KMxHiKZFPFYumgsMd 2Bsg== 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; bh=WXFk1khXw7w9JayWCtJqPeCIfdpFk03EWcfew3oQchA=; b=GSSSi6fwRSolpAwT9lOv6FzCLuvW23w+MA0Ue+AyON2Cj0d7OsomgzuFpdsZk0s8YE qc55fFWpLYP7Tf0kGq6CzBgXZagTkW7lOBmbrm/31IQOF3LefJcSa4EEv5CX6i/+Eelg XUXURosxjddhdcMNYe557QXT95kU0D7xxoX1dH2vxNAIAm5FXhHlHkSRADqA+JWkkWYk ZP9Ifa0bCruETHszeNhekvQzCKgy/awf5akMGwAw3IhtER+1odPyW2GeZhkm6gBz4CkI DqW41XpSvqEkEx/N4I5f19fKVZNNM9CbljHguT8bhV9ZJhFg/Hm38YfWZmbfGWWV6GgX 16nw== X-Gm-Message-State: APjAAAXn0RGgXHDYeUzNWENZw0gAEusUBjxfvcAtDkKCg7Lo449th6Pm oY8o8C6N4WJxLDcjLie4XPyJv6Gs X-Google-Smtp-Source: APXvYqwBa/wBZT9UjKR566d5IuoTulFV34gCeYjl2ClQc8YgFiYbH6Fw3C1G1IdEsGJFT+pzeRjiPg== X-Received: by 2002:a7b:cb84:: with SMTP id m4mr15754574wmi.50.1561366369392; Mon, 24 Jun 2019 01:52:49 -0700 (PDT) Received: from amir-ThinkPad-T480.ctera.local (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id c15sm15298065wrd.88.2019.06.24.01.52.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Jun 2019 01:52:48 -0700 (PDT) From: Amir Goldstein To: Cyril Hrubis Date: Mon, 24 Jun 2019 11:52:41 +0300 Message-Id: <20190624085241.32276-1-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 X-Virus-Scanned: clamav-milter 0.99.2 at in-6.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_HELO_NONE, SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-6.smtp.seeweb.it Cc: Jan Kara , ltp@lists.linux.it Subject: [LTP] [PATCH] syscalls/fanotify13: add test coverage for fsid cache bug 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" This bug was reported by syzbot: https://lore.kernel.org/linux-fsdevel/CAOQ4uxhsnOXXVCuOT4p4c_koBMFfprWwdtCPGNGhzprFaJZwRA@mail.gmail.com/T/#t And fixed by kernel commit c285a2f01d69 ("fanotify: update connector fsid cache on add mark") Signed-off-by: Amir Goldstein --- Cyril, Here is a re-send of the patch you missed. I also added the kernel fix commit for reference. Thanks, Amir. .../kernel/syscalls/fanotify/fanotify13.c | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/testcases/kernel/syscalls/fanotify/fanotify13.c b/testcases/kernel/syscalls/fanotify/fanotify13.c index 3e4778e68..e5681c804 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify13.c +++ b/testcases/kernel/syscalls/fanotify/fanotify13.c @@ -85,6 +85,7 @@ static struct test_case_t { } }; +static int nofid_fd; static int fanotify_fd; static char events_buf[BUF_SIZE]; static struct event_t event_set[EVENT_MAX]; @@ -281,21 +282,32 @@ out: static void do_setup(void) { - int fd; - /* Check for kernel fanotify support */ - fd = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF, O_RDONLY); - SAFE_CLOSE(fd); + nofid_fd = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF, O_RDONLY); /* Create file and directory objects for testing */ create_objects(); + /* + * Create a mark on first inode without FAN_REPORT_FID, to test + * uninitialized connector->fsid cache. This mark remains for all test + * cases and is not expected to get any events (no writes in this test). + */ + if (fanotify_mark(nofid_fd, FAN_MARK_ADD, FAN_CLOSE_WRITE, AT_FDCWD, + FILE_PATH_ONE) == -1) { + tst_brk(TBROK | TERRNO, + "fanotify_mark(%d, FAN_MARK_ADD, FAN_CLOSE_WRITE, " + "AT_FDCWD, "FILE_PATH_ONE") failed", + nofid_fd); + } + /* Get the filesystem fsid and file handle for each created object */ get_object_stats(); } static void do_cleanup(void) { + SAFE_CLOSE(nofid_fd); if (fanotify_fd > 0) SAFE_CLOSE(fanotify_fd); }