mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jamie Lokier <lk@tantalophile.demon.co.uk>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Ingo Molnar <mingo@elte.hu>, linux-kernel@vger.kernel.org
Subject: [patch] complain about unknown CLONE_* flags
Date: Thu, 15 Aug 2002 23:38:02 +0100	[thread overview]
Message-ID: <20020815233802.A30018@kushida.apsleyroad.org> (raw)
In-Reply-To: <Pine.LNX.4.44.0208132025530.6752-100000@localhost.localdomain>; from mingo@elte.hu on Tue, Aug 13, 2002 at 08:32:06PM +0200

About new clone() flags...

One of the obvious things for a thread library is to:

    (a) try clone() with lots of snazzy flags
    (b) if that returns -EINVAL, we must be running on an older kernel;
        try with fewer flags and more workarounds

However, I don't see any code in sys_clone() that rejects a call that
specifies unknown flags.  So, code that uses e.g. CLONE_SETTID will
appear to run perfectly well on an old kernel... except that it will
behave incorrectly.

That leads to having to write some silly test for each feature prior to
using it, instead of trying it and falling back.  E.g. I'd need to
do the silly signal-blocking workaround when creating the second thread
in a program, just to find out whether CLONE_SETTID actually worked.
Either that, or check the kernel version.

Ingo, how do you handle this sort of backward compatibility in your
latest pthreads library, or don't you do backward compatibility?

For future-proofing, here's a patch:

diff -u linux-2.5/kernel/fork.c.orig linux-2.5/kernel/fork.c
--- linux-2.5/kernel/fork.c
+++ linux-2.5/kernel/fork.c	Thu Aug 15 23:35:00 2002
@@ -619,6 +619,11 @@
 	struct task_struct *p = NULL;
 	struct completion vfork;
 
+	if ((clone_flags & ~(0UL|CSIGNAL|CLONE_VM|CLONE_FS|CLONE_FILES
+			     |CLONE_SIGHAND|CLONE_PID|CLONE_PTRACE|CLONE_VFORK
+			     |CLONE_PARENT|CLONE_THREAD)))
+		return ERR_PTR (-EINVAL);
+
 	if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
 		return ERR_PTR(-EINVAL);
 

  parent reply	other threads:[~2002-08-16  2:38 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-13 15:09 [patch] clone_startup(), 2.5.31-A0 Ingo Molnar
2002-08-13 15:30 ` Linus Torvalds
2002-08-13 15:44 ` Christoph Hellwig
2002-08-13 16:01   ` Linus Torvalds
2002-08-13 16:05     ` Christoph Hellwig
2002-08-13 16:20       ` Linus Torvalds
2002-08-13 18:32         ` [patch] CLONE_SETTLS, CLONE_SETTID, 2.5.31-BK Ingo Molnar
2002-08-13 18:41           ` Linus Torvalds
2002-08-13 19:09             ` Ingo Molnar
2002-08-13 19:41               ` Linus Torvalds
2002-08-13 19:41                 ` Ingo Molnar
2002-08-13 19:35             ` Ingo Molnar
2002-08-15 22:38           ` Jamie Lokier [this message]
2002-08-16 10:17             ` [patch] complain about unknown CLONE_* flags Ingo Molnar
2001-11-02  5:55               ` Pavel Machek
2002-08-13 16:09   ` [patch] clone_startup(), 2.5.31-A0 Erik Andersen
2002-08-13 16:11     ` Christoph Hellwig
2002-08-13 16:32       ` David Mosberger
2002-08-13 16:44         ` John Levon
2002-08-13 19:52         ` H. Peter Anvin
2002-08-13 20:19           ` David Mosberger
2002-08-13 20:27             ` H. Peter Anvin
2002-08-13 20:52               ` David Mosberger
2002-08-13 20:57                 ` H. Peter Anvin
2002-08-13 16:56       ` Ruth Ivimey-Cook
2002-08-13 17:42       ` Richard B. Johnson
2002-08-13 17:19     ` Ingo Molnar
2002-08-13 20:35       ` Kai Henningsen
2002-08-15 21:24         ` Thunder from the hill
2002-08-13 17:27   ` Ingo Molnar
2002-08-14 13:48     ` Rusty Russell
2002-08-14 18:47       ` Jamie Lokier

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=20020815233802.A30018@kushida.apsleyroad.org \
    --to=lk@tantalophile.demon.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=torvalds@transmeta.com \
    /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

all inboxes | Powered by JetHome®