public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH liburing] tests; skip non-root sendmsg_fs_cve
@ 2021-08-22 12:07 Pavel Begunkov
  2021-08-22 12:43 ` Ammar Faizi
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Begunkov @ 2021-08-22 12:07 UTC (permalink / raw)
  To: Jens Axboe, io-uring

Skip sendmsg_fd_cve if we don't have enough privileges to chroot().

Signed-off-by: Pavel Begunkov <[email protected]>
---
 test/sendmsg_fs_cve.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/test/sendmsg_fs_cve.c b/test/sendmsg_fs_cve.c
index 8de220a..57347af 100644
--- a/test/sendmsg_fs_cve.c
+++ b/test/sendmsg_fs_cve.c
@@ -154,7 +154,13 @@ int main(int argc, char *argv[])
 	if (!c) {
 		close(rcv_sock);
 
-		if (chroot(tmpdir)) {
+		r = chroot(tmpdir);
+		if (r) {
+			if (r == -EPERM) {
+				fprintf(stderr, "chroot not allowed, skip\n");
+				return 0;
+			}
+
 			perror("chroot()");
 			return 1;
 		}
-- 
2.32.0


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

* Re: [PATCH liburing] tests; skip non-root sendmsg_fs_cve
  2021-08-22 12:07 [PATCH liburing] tests; skip non-root sendmsg_fs_cve Pavel Begunkov
@ 2021-08-22 12:43 ` Ammar Faizi
  2021-08-22 12:46   ` Pavel Begunkov
  0 siblings, 1 reply; 3+ messages in thread
From: Ammar Faizi @ 2021-08-22 12:43 UTC (permalink / raw)
  To: Pavel Begunkov; +Cc: Jens Axboe, io-uring

On Sun, Aug 22, 2021 at 7:08 PM Pavel Begunkov <[email protected]> wrote:
> -               if (chroot(tmpdir)) {
> +               r = chroot(tmpdir);
> +               if (r) {
> +                       if (r == -EPERM) {
> +                               fprintf(stderr, "chroot not allowed, skip\n");
> +                               return 0;
> +                       }

Hey, it's the userspace API.

chroot, on success, zero is returned. On error, -1 is returned, and errno is
set appropriately.

Did you mean if (errno == EPERM)?
Should #include <errno.h> as well.
Sorry for the duplicate, forgot to switch to plain text.
---
Ammar Faizi

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

* Re: [PATCH liburing] tests; skip non-root sendmsg_fs_cve
  2021-08-22 12:43 ` Ammar Faizi
@ 2021-08-22 12:46   ` Pavel Begunkov
  0 siblings, 0 replies; 3+ messages in thread
From: Pavel Begunkov @ 2021-08-22 12:46 UTC (permalink / raw)
  To: Ammar Faizi; +Cc: Jens Axboe, io-uring

On 8/22/21 1:43 PM, Ammar Faizi wrote:
> On Sun, Aug 22, 2021 at 7:08 PM Pavel Begunkov <[email protected]> wrote:
>> -               if (chroot(tmpdir)) {
>> +               r = chroot(tmpdir);
>> +               if (r) {
>> +                       if (r == -EPERM) {
>> +                               fprintf(stderr, "chroot not allowed, skip\n");
>> +                               return 0;
>> +                       }
> 
> Hey, it's the userspace API.
> 
> chroot, on success, zero is returned. On error, -1 is returned, and errno is
> set appropriately.

That was extremely silly indeed, thanks Ammar.

Curiously, it didn't fail because EPERM == 1

> Did you mean if (errno == EPERM)?
> Should #include <errno.h> as well.
> Sorry for the duplicate, forgot to switch to plain text.
> ---
> Ammar Faizi
> 

-- 
Pavel Begunkov

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

end of thread, other threads:[~2021-08-22 12:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-22 12:07 [PATCH liburing] tests; skip non-root sendmsg_fs_cve Pavel Begunkov
2021-08-22 12:43 ` Ammar Faizi
2021-08-22 12:46   ` Pavel Begunkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox