All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Palethorpe <rpalethorpe@suse.de>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 4/5] API: Add tst_clone
Date: Thu, 11 Feb 2021 15:07:15 +0000	[thread overview]
Message-ID: <874kii63to.fsf@suse.de> (raw)
In-Reply-To: <YCVAwoQDKJWMi6hX@rei.lan>

Hello,

Cyril Hrubis <chrubis@suse.cz> writes:

> Hi!
>> >> +	int flags;
>> >> +	pid_t pid = -1;
>> >> +
>> >> +	tst_flush();
>> >> +
>> >> +	errno = ENOSYS;
>> >> +	if (__NR_clone3 != __LTP__NR_INVALID_SYSCALL)
>> >> +		pid = syscall(__NR_clone3, &args, sizeof(args));
>> >> +
>> >> +	if (pid == -1 && errno != ENOSYS)
>> >> +		return -1;
>> >
>> > As far as I can tell when kernel is too old we would get EINVAL because
>> > the syscall number is not allocated. ENOSYS happens mostly when syscall
>> > number is allocated and kernel does not implement the functionality,
>> > e.g. it's disabled in .config.
>> >
>> > I wonder if it's even menaningful to handle ENOSYS here, I doubt that
>> > clone3() can be disabled, or do I miss something?
>> 
>> AFAICT it should return ENOSYS if the syscall number is greater than the
>> current maximum. This is certainly true for riscv and also apears to be
>> true for arm64 and x86. It is also written in a kernel book I have from
>> 2010 :-p
>
> Sounds sane, so we get EINVAL if the syscall number is out of the
> syscall table. So I guess that we have to handle both.

I don't know where you are getting EINVAL from?

Try the following

#include <errno.h>
#include <unistd.h>
#include <sys/syscall.h>

int main(int argc, const char* argv[])
{
	syscall(~0ULL);

	return errno;
}

It returns ENOSYS and strace shows this is not due to any sanity
checking by glibc.

I guess it would actually be a bug if it returned EINVAL although I am
not sure this is specified anywhere.

-- 
Thank you,
Richard.

  reply	other threads:[~2021-02-11 15:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-11 11:03 [LTP] [PATCH 0/5] Add close_range01, SAFE_DUP2 and SAFE_CLONE Richard Palethorpe
2021-02-11 11:03 ` [LTP] [PATCH 1/5] close_range: Add syscall number Richard Palethorpe
2021-02-11 11:03 ` [LTP] [PATCH 2/5] API: Add SAFE_DUP2 Richard Palethorpe
2021-02-11 11:03 ` [LTP] [PATCH 3/5] API: Fix clone.h Richard Palethorpe
2021-02-11 11:03 ` [LTP] [PATCH 4/5] API: Add tst_clone Richard Palethorpe
2021-02-11 12:51   ` Cyril Hrubis
2021-02-11 14:24     ` Richard Palethorpe
2021-02-11 14:35       ` Cyril Hrubis
2021-02-11 15:07         ` Richard Palethorpe [this message]
2021-02-11 15:30           ` Cyril Hrubis
2021-02-11 11:03 ` [LTP] [PATCH 5/5] close_range: Add test Richard Palethorpe
2021-02-11 12:54   ` Cyril Hrubis

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=874kii63to.fsf@suse.de \
    --to=rpalethorpe@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.