lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAC1kPDNPGdZzypz=a7N-dtewxRzEJBPZKOGm5iFkj2o9uk5XsA@mail.gmail.com>
Date: Mon, 23 Jun 2025 13:00:19 +0800
From: Chen Linxuan <chenlinxuan@...ontech.com>
To: Muhammad Usama Anjum <usama.anjum@...labora.com>
Cc: Chen Linxuan <chenlinxuan@...ontech.com>, Shuah Khan <shuah@...nel.org>, 
	Christian Brauner <brauner@...nel.org>, Amir Goldstein <amir73il@...il.com>, 
	John Hubbard <jhubbard@...dia.com>, Miklos Szeredi <mszeredi@...hat.com>, Jan Kara <jack@...e.cz>, 
	zhanjun@...ontech.com, niecheng1@...ontech.com, 
	linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] selftests/filesystems/mount-notify: fix unused unused
 result warning

On Mon, Jun 23, 2025 at 12:22 PM Muhammad Usama Anjum
<usama.anjum@...labora.com> wrote:
>
> On 6/20/25 7:55 PM, Chen Linxuan wrote:
> > On Fri, Jun 20, 2025 at 10:46 PM Muhammad Usama Anjum
> > <usama.anjum@...labora.com> wrote:
> >>
> >> On 6/20/25 8:50 AM, Chen Linxuan wrote:
> >>> When running `make kselftest`, the following compilation warning was encountered:
> >>>
> >>> mount-notify_test.c: In function ‘fanotify_rmdir’:
> >>> mount-notify_test.c:490:17: warning: ignoring return value of ‘chdir’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
> >>>   490 |                 chdir("/");
> >>>       |                 ^~~~~~~~~~
> >>>
> >>> Signed-off-by: Chen Linxuan <chenlinxuan@...ontech.com>
> >>> ---
> >>> Changes in v2:
> >>> - Apply changes suggested by Shuah Khan
> >>> - Link to v1: https://lore.kernel.org/all/20250610020758.2798787-2-chenlinxuan@uniontech.com/
> >>> ---
> >>>  .../filesystems/mount-notify/mount-notify_test.c  | 15 ++++++++++-----
> >>>  .../mount-notify/mount-notify_test_ns.c           | 15 ++++++++++-----
> >>>  2 files changed, 20 insertions(+), 10 deletions(-)
> >>>
> >>> diff --git a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
> >>> index 5a3b0ace1a88c..f8e0c6b06e2d9 100644
> >>> --- a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
> >>> +++ b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
> >>> @@ -458,12 +458,17 @@ TEST_F(fanotify, rmdir)
> >>>       ASSERT_GE(ret, 0);
> >>>
> >>>       if (ret == 0) {
> >>> -             chdir("/");
> >>> -             unshare(CLONE_NEWNS);
> >>> -             mount("", "/", NULL, MS_REC|MS_PRIVATE, NULL);
> >>> -             umount2("/a", MNT_DETACH);
> >>> +             if (chdir("/"))
> >> Please use the APIs provided by the kselftest_harness.h instead of checking
> >> return types manually. For example:
> >> use ASSERT_EQ(chdir("/", 0)).
> >
> > Are you sure?We're in a forked sub process here.
> ASSERT_* are macros. They can be used anywhere. Please give it a try.

V3: https://lore.kernel.org/all/20250623045711.3564655-2-chenlinxuan@uniontech.com/

>
> >
> >>
> >>> +                     exit(-1);
> >>> +             if (unshare(CLONE_NEWNS))
> >>> +                     exit(-1);
> >>> +             if (mount("", "/", NULL, MS_REC|MS_PRIVATE, NULL))
> >>> +                     exit(-1);
> >>> +             if (umount2("/a", MNT_DETACH))
> >>> +                     exit(-1);
> >>>               // This triggers a detach in the other namespace
> >>> -             rmdir("/a");
> >>> +             if (rmdir("/a"))
> >>> +                     exit(-1);
> >>>               exit(0);
> >>>       }
> >>>       wait(NULL);
> >>> diff --git a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c
> >>> index d91946e69591a..d6a6a7ee87028 100644
> >>> --- a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c
> >>> +++ b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_ns.c
> >>> @@ -486,12 +486,17 @@ TEST_F(fanotify, rmdir)
> >>>       ASSERT_GE(ret, 0);
> >>>
> >>>       if (ret == 0) {
> >>> -             chdir("/");
> >>> -             unshare(CLONE_NEWNS);
> >>> -             mount("", "/", NULL, MS_REC|MS_PRIVATE, NULL);
> >>> -             umount2("/a", MNT_DETACH);
> >>> +             if (chdir("/"))
> >>> +                     exit(-1);
> >>> +             if (unshare(CLONE_NEWNS))
> >>> +                     exit(-1);
> >>> +             if (mount("", "/", NULL, MS_REC|MS_PRIVATE, NULL))
> >>> +                     exit(-1);
> >>> +             if (umount2("/a", MNT_DETACH))
> >>> +                     exit(-1);
> >>>               // This triggers a detach in the other namespace
> >>> -             rmdir("/a");
> >>> +             if (rmdir("/a"))
> >>> +                     exit(-1);
> >>>               exit(0);
> >>>       }
> >>>       wait(NULL);
> >>
> >>
> >>
>
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ