linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests/filesystems:fix build error in overlayfs
@ 2024-01-12  7:40 Hu Yadi
  2024-01-15 14:26 ` Günther Noack
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Hu Yadi @ 2024-01-12  7:40 UTC (permalink / raw)
  To: jmorris, serge, shuah, mathieu.desnoyers, mic, amir73il, brauner,
	avagin
  Cc: linux-api, linux-kernel, linux-security-module, linux-kselftest,
	514118380, Hu Yadi

One build issue comes up due to both mount.h included dev_in_maps.c

In file included from dev_in_maps.c:10:
/usr/include/sys/mount.h:35:3: error: expected identifier before numeric constant
   35 |   MS_RDONLY = 1,  /* Mount read-only.  */
      |   ^~~~~~~~~
In file included from dev_in_maps.c:13:

Remove one of them to solve conflict, another error comes up:

dev_in_maps.c:170:6: error: implicit declaration of function ‘mount’ [-Werror=implicit-function-declaration]
  170 |  if (mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL) == -1) {
      |      ^~~~~
cc1: all warnings being treated as errors

and then , add sys_mount definition to solve it
After both above, dev_in_maps.c can be built correctly on my mache(gcc 10.2,glibc-2.32,kernel-5.10)

Signed-off-by: Hu Yadi <hu.yadi@h3c.com>
---
 .../selftests/filesystems/overlayfs/dev_in_maps.c      | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c b/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
index e19ab0e85709..759f86e7d263 100644
--- a/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
+++ b/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
@@ -10,7 +10,6 @@
 #include <linux/mount.h>
 #include <sys/syscall.h>
 #include <sys/stat.h>
-#include <sys/mount.h>
 #include <sys/mman.h>
 #include <sched.h>
 #include <fcntl.h>
@@ -32,7 +31,11 @@ static int sys_fsmount(int fd, unsigned int flags, unsigned int attr_flags)
 {
 	return syscall(__NR_fsmount, fd, flags, attr_flags);
 }
-
+static int sys_mount(const char *src, const char *tgt, const char *fst,
+		unsigned long flags, const void *data)
+{
+	return syscall(__NR_mount, src, tgt, fst, flags, data);
+}
 static int sys_move_mount(int from_dfd, const char *from_pathname,
 			  int to_dfd, const char *to_pathname,
 			  unsigned int flags)
@@ -166,8 +169,7 @@ int main(int argc, char **argv)
 		ksft_test_result_skip("unable to create a new mount namespace\n");
 		return 1;
 	}
-
-	if (mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL) == -1) {
+	if (sys_mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL) == -1) {
 		pr_perror("mount");
 		return 1;
 	}
-- 
2.39.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests/filesystems:fix build error in overlayfs
  2024-01-12  7:40 [PATCH] selftests/filesystems:fix build error in overlayfs Hu Yadi
@ 2024-01-15 14:26 ` Günther Noack
  2024-01-16  3:15   ` 回复: " Huyadi
  2024-01-17  1:43 ` Andrei Vagin
  2024-01-17 13:23 ` Christian Brauner
  2 siblings, 1 reply; 5+ messages in thread
From: Günther Noack @ 2024-01-15 14:26 UTC (permalink / raw)
  To: Hu Yadi
  Cc: jmorris, serge, shuah, mathieu.desnoyers, mic, amir73il, brauner,
	avagin, linux-api, linux-kernel, linux-security-module,
	linux-kselftest, 514118380

Hello!

On Fri, Jan 12, 2024 at 03:40:59PM +0800, Hu Yadi wrote:
> One build issue comes up due to both mount.h included dev_in_maps.c
> 
> In file included from dev_in_maps.c:10:
> /usr/include/sys/mount.h:35:3: error: expected identifier before numeric constant
>    35 |   MS_RDONLY = 1,  /* Mount read-only.  */
>       |   ^~~~~~~~~
> In file included from dev_in_maps.c:13:
> 
> Remove one of them to solve conflict, another error comes up:
> 
> dev_in_maps.c:170:6: error: implicit declaration of function ‘mount’ [-Werror=implicit-function-declaration]
>   170 |  if (mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL) == -1) {
>       |      ^~~~~
> cc1: all warnings being treated as errors
> 
> and then , add sys_mount definition to solve it
> After both above, dev_in_maps.c can be built correctly on my mache(gcc 10.2,glibc-2.32,kernel-5.10)

This is apparently the same error as in
https://lore.kernel.org/all/11cdac1e-e96c-405f-63e8-35b0e2926337@arm.com/

I'm getting the impression that we are fixing the issue at the wrong layer here?
After all, the mount() syscall is supposed to be used with <sys/mount.h>
according to the mount(2) man page?  It feels a bit like cheating to resort to
sys_mount() instead...?

Do you have any deeper thoughts on what could be the underlying issue here?
With my newer GCC toolchains, I have been unable to reproduce this.

Thanks,
—Günther


^ permalink raw reply	[flat|nested] 5+ messages in thread

* 回复: [PATCH] selftests/filesystems:fix build error in overlayfs
  2024-01-15 14:26 ` Günther Noack
@ 2024-01-16  3:15   ` Huyadi
  0 siblings, 0 replies; 5+ messages in thread
From: Huyadi @ 2024-01-16  3:15 UTC (permalink / raw)
  To: 'Günther Noack'
  Cc: jmorris@namei.org, serge@hallyn.com, shuah@kernel.org,
	mathieu.desnoyers@efficios.com, mic@digikod.net,
	amir73il@gmail.com, brauner@kernel.org, avagin@google.com,
	linux-api@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	linux-kselftest@vger.kernel.org, 514118380@qq.com




>On Fri, Jan 12, 2024 at 03:40:59PM +0800, Hu Yadi wrote:
>> One build issue comes up due to both mount.h included dev_in_maps.c
>> 
>> In file included from dev_in_maps.c:10:
>> /usr/include/sys/mount.h:35:3: error: expected identifier before numeric constant
>>    35 |   MS_RDONLY = 1,  /* Mount read-only.  */
>>       |   ^~~~~~~~~
>> In file included from dev_in_maps.c:13:
>> 
>> Remove one of them to solve conflict, another error comes up:
>> 
>> dev_in_maps.c:170:6: error: implicit declaration of function ‘mount’ [-Werror=implicit-function-declaration]
>>   170 |  if (mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL) == -1) {
>>       |      ^~~~~
>> cc1: all warnings being treated as errors
>> 
>> and then , add sys_mount definition to solve it After both above, 
>> dev_in_maps.c can be built correctly on my mache(gcc 
>> 10.2,glibc-2.32,kernel-5.10)
>
>This is apparently the same error as in
>https://lore.kernel.org/all/11cdac1e-e96c-405f-63e8-35b0e2926337@arm.com/
>
>I'm getting the impression that we are fixing the issue at the wrong layer here?
>After all, the mount() syscall is supposed to be used with <sys/mount.h> according to the mount(2) man page?  It feels a bit like cheating to resort to
>sys_mount() instead...?

Headers conflict is known issue due to https://sourceware.org/glibc/wiki/Synchronizing_Headers
<linux/mount.h> and <sys/mount.h> (Note: no workaround)
So, it is incorrect to use both them.

>
>Do you have any deeper thoughts on what could be the underlying issue here?
>With my newer GCC toolchains, I have been unable to reproduce this.
>
gcc version 10.2.1 20200825 (Alibaba 10.2.1-3.5 2.32) (GCC)
ldd (GNU libc) 2.32
kernel 5.10.134-16.1.al8.x86_64
"Alibaba Cloud Linux 3(the most biggest public cloud provider's OS)


>Thanks,


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests/filesystems:fix build error in overlayfs
  2024-01-12  7:40 [PATCH] selftests/filesystems:fix build error in overlayfs Hu Yadi
  2024-01-15 14:26 ` Günther Noack
@ 2024-01-17  1:43 ` Andrei Vagin
  2024-01-17 13:23 ` Christian Brauner
  2 siblings, 0 replies; 5+ messages in thread
From: Andrei Vagin @ 2024-01-17  1:43 UTC (permalink / raw)
  To: Hu Yadi
  Cc: jmorris, serge, shuah, mathieu.desnoyers, mic, amir73il, brauner,
	linux-api, linux-kernel, linux-security-module, linux-kselftest,
	514118380

On Thu, Jan 11, 2024 at 11:45 PM Hu Yadi <hu.yadi@h3c.com> wrote:
>
> One build issue comes up due to both mount.h included dev_in_maps.c
>
> In file included from dev_in_maps.c:10:
> /usr/include/sys/mount.h:35:3: error: expected identifier before numeric constant
>    35 |   MS_RDONLY = 1,  /* Mount read-only.  */
>       |   ^~~~~~~~~
> In file included from dev_in_maps.c:13:
>
> Remove one of them to solve conflict, another error comes up:
>
> dev_in_maps.c:170:6: error: implicit declaration of function ‘mount’ [-Werror=implicit-function-declaration]
>   170 |  if (mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL) == -1) {
>       |      ^~~~~
> cc1: all warnings being treated as errors
>
> and then , add sys_mount definition to solve it
> After both above, dev_in_maps.c can be built correctly on my mache(gcc 10.2,glibc-2.32,kernel-5.10)
>
> Signed-off-by: Hu Yadi <hu.yadi@h3c.com>
Acked-by: Andrei Vagin <avagin@google.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests/filesystems:fix build error in overlayfs
  2024-01-12  7:40 [PATCH] selftests/filesystems:fix build error in overlayfs Hu Yadi
  2024-01-15 14:26 ` Günther Noack
  2024-01-17  1:43 ` Andrei Vagin
@ 2024-01-17 13:23 ` Christian Brauner
  2 siblings, 0 replies; 5+ messages in thread
From: Christian Brauner @ 2024-01-17 13:23 UTC (permalink / raw)
  To: jmorris, serge, shuah, mathieu.desnoyers, mic, amir73il, avagin,
	Hu Yadi
  Cc: Christian Brauner, linux-api, linux-kernel, linux-security-module,
	linux-kselftest, 514118380

On Fri, 12 Jan 2024 15:40:59 +0800, Hu Yadi wrote:
> One build issue comes up due to both mount.h included dev_in_maps.c
> 
> In file included from dev_in_maps.c:10:
> /usr/include/sys/mount.h:35:3: error: expected identifier before numeric constant
>    35 |   MS_RDONLY = 1,  /* Mount read-only.  */
>       |   ^~~~~~~~~
> In file included from dev_in_maps.c:13:
> 
> [...]

Applied to the vfs.misc branch of the vfs/vfs.git tree.
Patches in the vfs.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.misc

[1/1] selftests/filesystems:fix build error in overlayfs
      https://git.kernel.org/vfs/vfs/c/f67dae6ba174

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-01-17 13:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-12  7:40 [PATCH] selftests/filesystems:fix build error in overlayfs Hu Yadi
2024-01-15 14:26 ` Günther Noack
2024-01-16  3:15   ` 回复: " Huyadi
2024-01-17  1:43 ` Andrei Vagin
2024-01-17 13:23 ` Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).