Skip to contentSkip to conversation

nfstest_posix: add check for EINVAL when open(2) called with O_DIRECTORY|O_CREAT

PATCH In review Dai Ngo 3 participants 5 messages Jan 17, 2024 – Feb 22, 2024

Subsystems (2)
lore
Share & tools
lore

Dai Ngo

author reviewer
#0 lore raw

PATCH 1/1 nfstest_posix: add check for EINVAL when open(2) called with O_DIRECTORY|O_CREAT

The 'open' tests of nfstest_posix failed with 6.7 kernel with these errors:

FAIL: open - opening existent file should return an error when O_EXCL|O_CREAT is used (256 passed, 256 failed)
FAIL: open - opening symbolic link should return an error when O_EXCL|O_CREAT is used (256 passed, 256 failed)

These tests failed due to the commit 43b450632676 that fixes problems with VFS API:

43b450632676: open: return EINVAL for O_DIRECTORY | O_CREAT

This patch fixes the problem by adding a check for EINVAL when the open(2) was called with O_DIRECTORY | O_CREAT.

---
 test/nfstest_posix | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
test/nfstest_posix +6 -1
index 57db5d69b072..6d5fd0dfffee 100755
@@ -1232,7 +1232,12 @@ class PosixTest(TestUtil):
                         fstat = posix.fstat(fd)
 
                     if ftype in [EXISTENT, SYMLINK]:
-                        if posix.O_EXCL in flags and posix.O_CREAT in flags:
+                        if posix.O_CREAT in flags and posix.O_DIRECTORY in flags:
+                            # O_CREAT and O_DIRECTORY are set
+                            (expr, fmsg) = self._oserror(openerr, errno.EINVAL)
+                            msg = "open - opening %s should return EINVAL error when O_CREAT|O_DIRECTORY is used" % fmap[ftype]
+                            self.test(expr, msg, subtest=flag_str, failmsg=fmsg)
+                        elif posix.O_EXCL in flags and posix.O_CREAT in flags:
                             # O_EXCL and O_CREAT are set
                             (expr, fmsg) = self._oserror(openerr, errno.EEXIST)
                             msg = "open - opening %s should return an error when O_EXCL|O_CREAT is used" % fmap[ftype]
Signature · 1 line
2.9.5
#1 lore raw
Quoted 8 lines · Dai Ngo

The 'open' tests of nfstest_posix failed with 6.7 kernel with these errors:

FAIL: open - opening existent file should return an error when O_EXCL|O_CREAT is used (256 passed, 256 failed)
FAIL: open - opening symbolic link should return an error when O_EXCL|O_CREAT is used (256 passed, 256 failed)

These tests failed due to the commit 43b450632676 that fixes problems with VFS API:

Quoted 7 lines

43b450632676: open: return EINVAL for O_DIRECTORY | O_CREAT

This patch fixes the problem by adding a check for EINVAL when the open(2) was called with O_DIRECTORY | O_CREAT.

---

Thank you!

author reviewer
#2 lore raw
In reply to Dai Ngo

Hi Jorge,

Have you had a chance to take a look at this patch?

Thanks,
-Dai

Quoted 36 lines · Dai Ngo

The 'open' tests of nfstest_posix failed with 6.7 kernel with these errors:

FAIL: open - opening existent file should return an error when O_EXCL|O_CREAT is used (256 passed, 256 failed)
FAIL: open - opening symbolic link should return an error when O_EXCL|O_CREAT is used (256 passed, 256 failed)

These tests failed due to the commit 43b450632676 that fixes problems with VFS API:

43b450632676: open: return EINVAL for O_DIRECTORY | O_CREAT

This patch fixes the problem by adding a check for EINVAL when the open(2) was called with O_DIRECTORY | O_CREAT.

---
  test/nfstest_posix | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
test/nfstest_posix +6 -1
index 57db5d69b072..6d5fd0dfffee 100755
@@ -1232,7 +1232,12 @@ class PosixTest(TestUtil):
                          fstat = posix.fstat(fd)
 
                      if ftype in [EXISTENT, SYMLINK]:
-                        if posix.O_EXCL in flags and posix.O_CREAT in flags:
+                        if posix.O_CREAT in flags and posix.O_DIRECTORY in flags:
+                            # O_CREAT and O_DIRECTORY are set
+                            (expr, fmsg) = self._oserror(openerr, errno.EINVAL)
+                            msg = "open - opening %s should return EINVAL error when O_CREAT|O_DIRECTORY is used" % fmap[ftype]
+                            self.test(expr, msg, subtest=flag_str, failmsg=fmsg)
+                        elif posix.O_EXCL in flags and posix.O_CREAT in flags:
                              # O_EXCL and O_CREAT are set
                              (expr, fmsg) = self._oserror(openerr, errno.EEXIST)
                              msg = "open - opening %s should return an error when O_EXCL|O_CREAT is used" % fmap[ftype]
#3 lore raw

Hello Dai,

Looks good, I have pushed it upstream.

Thanks,

--Jorge

________________________________________
From: [email protected] <[email protected]>
Sent: Tuesday, February 20, 2024 2:25 PM
To: Mora, Jorge
Cc: [email protected]; [email protected]
Subject: Re: [PATCH 1/1] nfstest_posix: add check for EINVAL when open(2) called with O_DIRECTORY|O_CREAT

EXTERNAL EMAIL - USE CAUTION when clicking links or attachments

Hi Jorge,

Have you had a chance to take a look at this patch?

Thanks,
-Dai

Quoted 36 lines · Dai Ngo

The 'open' tests of nfstest_posix failed with 6.7 kernel with these errors:

FAIL: open - opening existent file should return an error when O_EXCL|O_CREAT is used (256 passed, 256 failed)
FAIL: open - opening symbolic link should return an error when O_EXCL|O_CREAT is used (256 passed, 256 failed)

These tests failed due to the commit 43b450632676 that fixes problems with VFS API:

43b450632676: open: return EINVAL for O_DIRECTORY | O_CREAT

This patch fixes the problem by adding a check for EINVAL when the open(2) was called with O_DIRECTORY | O_CREAT.

---
  test/nfstest_posix | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
test/nfstest_posix +6 -1
index 57db5d69b072..6d5fd0dfffee 100755
@@ -1232,7 +1232,12 @@ class PosixTest(TestUtil):
                          fstat = posix.fstat(fd)
 
                      if ftype in [EXISTENT, SYMLINK]:
-                        if posix.O_EXCL in flags and posix.O_CREAT in flags:
+                        if posix.O_CREAT in flags and posix.O_DIRECTORY in flags:
+                            # O_CREAT and O_DIRECTORY are set
+                            (expr, fmsg) = self._oserror(openerr, errno.EINVAL)
+                            msg = "open - opening %s should return EINVAL error when O_CREAT|O_DIRECTORY is used" % fmap[ftype]
+                            self.test(expr, msg, subtest=flag_str, failmsg=fmsg)
+                        elif posix.O_EXCL in flags and posix.O_CREAT in flags:
                              # O_EXCL and O_CREAT are set
                              (expr, fmsg) = self._oserror(openerr, errno.EEXIST)
                              msg = "open - opening %s should return an error when O_EXCL|O_CREAT is used" % fmap[ftype]
author reviewer
#4 lore raw

Thank you Jorge!

-Dai

Quoted 64 lines · Jorge

Hello Dai,

Looks good, I have pushed it upstream.

Thanks,

--Jorge

________________________________________
From: [email protected] <[email protected]>
Sent: Tuesday, February 20, 2024 2:25 PM
To: Mora, Jorge
Cc: [email protected]; [email protected]
Subject: Re: [PATCH 1/1] nfstest_posix: add check for EINVAL when open(2) called with O_DIRECTORY|O_CREAT

EXTERNAL EMAIL - USE CAUTION when clicking links or attachments

Hi Jorge,

Have you had a chance to take a look at this patch?

Thanks,
-Dai

Quoted 36 lines · Dai Ngo

The 'open' tests of nfstest_posix failed with 6.7 kernel with these errors:

FAIL: open - opening existent file should return an error when O_EXCL|O_CREAT is used (256 passed, 256 failed)
FAIL: open - opening symbolic link should return an error when O_EXCL|O_CREAT is used (256 passed, 256 failed)

These tests failed due to the commit 43b450632676 that fixes problems with VFS API:

43b450632676: open: return EINVAL for O_DIRECTORY | O_CREAT

This patch fixes the problem by adding a check for EINVAL when the open(2) was called with O_DIRECTORY | O_CREAT.

---
   test/nfstest_posix | 7 ++++++-
   1 file changed, 6 insertions(+), 1 deletion(-)
test/nfstest_posix +6 -1
index 57db5d69b072..6d5fd0dfffee 100755
@@ -1232,7 +1232,12 @@ class PosixTest(TestUtil):
                           fstat = posix.fstat(fd)
 
                       if ftype in [EXISTENT, SYMLINK]:
-                        if posix.O_EXCL in flags and posix.O_CREAT in flags:
+                        if posix.O_CREAT in flags and posix.O_DIRECTORY in flags:
+                            # O_CREAT and O_DIRECTORY are set
+                            (expr, fmsg) = self._oserror(openerr, errno.EINVAL)
+                            msg = "open - opening %s should return EINVAL error when O_CREAT|O_DIRECTORY is used" % fmap[ftype]
+                            self.test(expr, msg, subtest=flag_str, failmsg=fmsg)
+                        elif posix.O_EXCL in flags and posix.O_CREAT in flags:
                               # O_EXCL and O_CREAT are set
                               (expr, fmsg) = self._oserror(openerr, errno.EEXIST)
                               msg = "open - opening %s should return an error when O_EXCL|O_CREAT is used" % fmap[ftype]