public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Florian Weimer <fw@deneb.enyo.de>
To: ltp@lists.linux.it
Subject: [LTP] [bug?] clone(CLONE_IO) failing after kernel commit commit ef2c41cf38a7
Date: Tue, 05 May 2020 11:05:37 +0200	[thread overview]
Message-ID: <87a72m4uqm.fsf@mid.deneb.enyo.de> (raw)
In-Reply-To: <20200505083205.qwwdiotmmjl23aje@wittgenstein> (Christian Brauner's message of "Tue, 5 May 2020 10:32:05 +0200")

* Christian Brauner:

> Hm, as you observed, the kernel always defines the flags argument as
> unsigned long and afaict this has been the case since forever. So I'm
> not sure why the userspace wrapper is defined as taking an int for
> flags in the first place(?).

We have different types in many places.  Sometimes this is required by
POSIX, sometimes not.  See the recent effort to fix the x32 interface
(mostly for size_t arguments).

Flags arguments that depend on the word size are incompatible with
portable system calls, so arguably what the kernel is doing here is
wrong: the additional bits can never be used for anything.

> And I wonder if we should just do:
>
> if (clone_flags & ~CLONE_LEGACY_FLAGS) /* 
> 	return -EINVAL;
>
> but that might be a change in behavior, as legacy clone _never_ failed
> when invalid values where passed.

Have any flags been added recently?

> (Note, that CLONE_LEGACY_FLAGS is already defined as
> #define CLONE_LEGACY_FLAGS 0xffffffffULL
> and used in clone3().)
>
> So the better option might be to do what you suggested, Florian:
> if (clone_flags & ~CLONE_LEGACY_FLAGS)
> 	clone_flags = CLONE_LEGACY_FLAGS?
> and move on?

Not sure what you are suggesting here.  Do you mean an unconditional
masking of excess bits?

  clone_flags &= CLONE_LEGACY_FLAGS;

I think I would prefer this:

  /* Userspace may have passed a sign-extended int value. */
  if (clone_flags != (int) clone_flags) /* 
 	return -EINVAL;
  clone_flags = (unsigned) clone_flags;

> (Btw, iiuc, this would've always been a problem, right? In the sense that
> userspace only got away with this because there were no additional flags
> defined and couldn't.)

It depends on how the clone system call wrapper is implemented, and
what the C function call ABI is like.  In some cases, you probably get
zero-extension, as expected by the kernel.

  parent reply	other threads:[~2020-05-05  9:05 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <100149681.11244932.1588661282331.JavaMail.zimbra@redhat.com>
2020-05-05  7:28 ` [LTP] [bug?] clone(CLONE_IO) failing after kernel commit commit ef2c41cf38a7 Jan Stancek
2020-05-05  7:49   ` Florian Weimer
2020-05-05  7:59     ` Christian Brauner
2020-05-05  8:02       ` Christian Brauner
2020-05-05  8:32     ` Christian Brauner
2020-05-05  8:58       ` Jan Stancek
2020-05-05  9:05       ` Florian Weimer [this message]
2020-05-05  9:15         ` Christian Brauner
2020-05-05  9:36           ` Florian Weimer
2020-05-05  9:58             ` Christian Brauner
2020-05-05 10:21               ` Christian Brauner
2020-05-05 11:34                 ` Florian Weimer
2020-05-05 11:35                 ` Dmitry V. Levin
2020-05-05 11:43                   ` Christian Brauner
2020-05-05 11:49                     ` Dmitry V. Levin
2020-05-05 11:57                       ` Christian Brauner
2020-05-05 11:08               ` Florian Weimer
2020-05-05 11:26                 ` Christian Brauner
2020-05-05  7:54   ` Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a72m4uqm.fsf@mid.deneb.enyo.de \
    --to=fw@deneb.enyo.de \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox