All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>, Brian Gerst <brgerst@gmail.com>,
	Luis Chamberlain <mcgrof@kernel.org>,
	linux-arm-kernel@lists.infradead.org, x86@kernel.org,
	linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org,
	sparclinux@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 4/6] exec: split prepare_arg_pages
Date: Thu, 18 Jun 2020 16:46:25 +0200	[thread overview]
Message-ID: <20200618144627.114057-5-hch@lst.de> (raw)
In-Reply-To: <20200618144627.114057-1-hch@lst.de>

Move counting the arguments and enviroment variables out of
prepare_arg_pages and rename the rest of the function to check_arg_limit.
This prepares for a version of do_execvat that takes kernel pointers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/exec.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/fs/exec.c b/fs/exec.c
index a5d91f8b1341d5..34781db6bf6889 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -435,20 +435,10 @@ static int count_strings(const char __user *const __user *argv)
 	return i;
 }
 
-static int prepare_arg_pages(struct linux_binprm *bprm,
-		const char __user *const __user *argv,
-		const char __user *const __user *envp)
+static int check_arg_limit(struct linux_binprm *bprm)
 {
 	unsigned long limit, ptr_size;
 
-	bprm->argc = count_strings(argv);
-	if (bprm->argc < 0)
-		return bprm->argc;
-
-	bprm->envc = count_strings(envp);
-	if (bprm->envc < 0)
-		return bprm->envc;
-
 	/*
 	 * Limit to 1/4 of the max stack size or 3/4 of _STK_LIM
 	 * (whichever is smaller) for the argv+env strings.
@@ -1886,7 +1876,19 @@ int do_execveat(int fd, struct filename *filename,
 	if (retval)
 		goto out_unmark;
 
-	retval = prepare_arg_pages(bprm, argv, envp);
+	bprm->argc = count_strings(argv);
+	if (bprm->argc < 0) {
+		retval = bprm->argc;
+		goto out;
+	}
+
+	bprm->envc = count_strings(envp);
+	if (bprm->envc < 0) {
+		retval = bprm->envc;
+		goto out;
+	}
+
+	retval = check_arg_limit(bprm);
 	if (retval < 0)
 		goto out;
 
-- 
2.26.2


WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>, Brian Gerst <brgerst@gmail.com>,
	Luis Chamberlain <mcgrof@kernel.org>,
	linux-arm-kernel@lists.infradead.org, x86@kernel.org,
	linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org,
	sparclinux@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 4/6] exec: split prepare_arg_pages
Date: Thu, 18 Jun 2020 16:46:25 +0200	[thread overview]
Message-ID: <20200618144627.114057-5-hch@lst.de> (raw)
In-Reply-To: <20200618144627.114057-1-hch@lst.de>

Move counting the arguments and enviroment variables out of
prepare_arg_pages and rename the rest of the function to check_arg_limit.
This prepares for a version of do_execvat that takes kernel pointers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/exec.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/fs/exec.c b/fs/exec.c
index a5d91f8b1341d5..34781db6bf6889 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -435,20 +435,10 @@ static int count_strings(const char __user *const __user *argv)
 	return i;
 }
 
-static int prepare_arg_pages(struct linux_binprm *bprm,
-		const char __user *const __user *argv,
-		const char __user *const __user *envp)
+static int check_arg_limit(struct linux_binprm *bprm)
 {
 	unsigned long limit, ptr_size;
 
-	bprm->argc = count_strings(argv);
-	if (bprm->argc < 0)
-		return bprm->argc;
-
-	bprm->envc = count_strings(envp);
-	if (bprm->envc < 0)
-		return bprm->envc;

WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>, Brian Gerst <brgerst@gmail.com>,
	Luis Chamberlain <mcgrof@kernel.org>,
	linux-arm-kernel@lists.infradead.org, x86@kernel.org,
	linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org,
	sparclinux@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 4/6] exec: split prepare_arg_pages
Date: Thu, 18 Jun 2020 14:46:25 +0000	[thread overview]
Message-ID: <20200618144627.114057-5-hch@lst.de> (raw)
In-Reply-To: <20200618144627.114057-1-hch@lst.de>

Move counting the arguments and enviroment variables out of
prepare_arg_pages and rename the rest of the function to check_arg_limit.
This prepares for a version of do_execvat that takes kernel pointers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/exec.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/fs/exec.c b/fs/exec.c
index a5d91f8b1341d5..34781db6bf6889 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -435,20 +435,10 @@ static int count_strings(const char __user *const __user *argv)
 	return i;
 }
 
-static int prepare_arg_pages(struct linux_binprm *bprm,
-		const char __user *const __user *argv,
-		const char __user *const __user *envp)
+static int check_arg_limit(struct linux_binprm *bprm)
 {
 	unsigned long limit, ptr_size;
 
-	bprm->argc = count_strings(argv);
-	if (bprm->argc < 0)
-		return bprm->argc;
-
-	bprm->envc = count_strings(envp);
-	if (bprm->envc < 0)
-		return bprm->envc;
-
 	/*
 	 * Limit to 1/4 of the max stack size or 3/4 of _STK_LIM
 	 * (whichever is smaller) for the argv+env strings.
@@ -1886,7 +1876,19 @@ int do_execveat(int fd, struct filename *filename,
 	if (retval)
 		goto out_unmark;
 
-	retval = prepare_arg_pages(bprm, argv, envp);
+	bprm->argc = count_strings(argv);
+	if (bprm->argc < 0) {
+		retval = bprm->argc;
+		goto out;
+	}
+
+	bprm->envc = count_strings(envp);
+	if (bprm->envc < 0) {
+		retval = bprm->envc;
+		goto out;
+	}
+
+	retval = check_arg_limit(bprm);
 	if (retval < 0)
 		goto out;
 
-- 
2.26.2

WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: linux-arch@vger.kernel.org, linux-s390@vger.kernel.org,
	linux-parisc@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	Brian Gerst <brgerst@gmail.com>,
	x86@kernel.org, linux-mips@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	Luis Chamberlain <mcgrof@kernel.org>,
	sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/6] exec: split prepare_arg_pages
Date: Thu, 18 Jun 2020 16:46:25 +0200	[thread overview]
Message-ID: <20200618144627.114057-5-hch@lst.de> (raw)
In-Reply-To: <20200618144627.114057-1-hch@lst.de>

Move counting the arguments and enviroment variables out of
prepare_arg_pages and rename the rest of the function to check_arg_limit.
This prepares for a version of do_execvat that takes kernel pointers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/exec.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/fs/exec.c b/fs/exec.c
index a5d91f8b1341d5..34781db6bf6889 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -435,20 +435,10 @@ static int count_strings(const char __user *const __user *argv)
 	return i;
 }
 
-static int prepare_arg_pages(struct linux_binprm *bprm,
-		const char __user *const __user *argv,
-		const char __user *const __user *envp)
+static int check_arg_limit(struct linux_binprm *bprm)
 {
 	unsigned long limit, ptr_size;
 
-	bprm->argc = count_strings(argv);
-	if (bprm->argc < 0)
-		return bprm->argc;
-
-	bprm->envc = count_strings(envp);
-	if (bprm->envc < 0)
-		return bprm->envc;
-
 	/*
 	 * Limit to 1/4 of the max stack size or 3/4 of _STK_LIM
 	 * (whichever is smaller) for the argv+env strings.
@@ -1886,7 +1876,19 @@ int do_execveat(int fd, struct filename *filename,
 	if (retval)
 		goto out_unmark;
 
-	retval = prepare_arg_pages(bprm, argv, envp);
+	bprm->argc = count_strings(argv);
+	if (bprm->argc < 0) {
+		retval = bprm->argc;
+		goto out;
+	}
+
+	bprm->envc = count_strings(envp);
+	if (bprm->envc < 0) {
+		retval = bprm->envc;
+		goto out;
+	}
+
+	retval = check_arg_limit(bprm);
 	if (retval < 0)
 		goto out;
 
-- 
2.26.2


WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: linux-arch@vger.kernel.org, linux-s390@vger.kernel.org,
	linux-parisc@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	Brian Gerst <brgerst@gmail.com>,
	x86@kernel.org, linux-mips@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	Luis Chamberlain <mcgrof@kernel.org>,
	sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/6] exec: split prepare_arg_pages
Date: Thu, 18 Jun 2020 16:46:25 +0200	[thread overview]
Message-ID: <20200618144627.114057-5-hch@lst.de> (raw)
In-Reply-To: <20200618144627.114057-1-hch@lst.de>

Move counting the arguments and enviroment variables out of
prepare_arg_pages and rename the rest of the function to check_arg_limit.
This prepares for a version of do_execvat that takes kernel pointers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/exec.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/fs/exec.c b/fs/exec.c
index a5d91f8b1341d5..34781db6bf6889 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -435,20 +435,10 @@ static int count_strings(const char __user *const __user *argv)
 	return i;
 }
 
-static int prepare_arg_pages(struct linux_binprm *bprm,
-		const char __user *const __user *argv,
-		const char __user *const __user *envp)
+static int check_arg_limit(struct linux_binprm *bprm)
 {
 	unsigned long limit, ptr_size;
 
-	bprm->argc = count_strings(argv);
-	if (bprm->argc < 0)
-		return bprm->argc;
-
-	bprm->envc = count_strings(envp);
-	if (bprm->envc < 0)
-		return bprm->envc;
-
 	/*
 	 * Limit to 1/4 of the max stack size or 3/4 of _STK_LIM
 	 * (whichever is smaller) for the argv+env strings.
@@ -1886,7 +1876,19 @@ int do_execveat(int fd, struct filename *filename,
 	if (retval)
 		goto out_unmark;
 
-	retval = prepare_arg_pages(bprm, argv, envp);
+	bprm->argc = count_strings(argv);
+	if (bprm->argc < 0) {
+		retval = bprm->argc;
+		goto out;
+	}
+
+	bprm->envc = count_strings(envp);
+	if (bprm->envc < 0) {
+		retval = bprm->envc;
+		goto out;
+	}
+
+	retval = check_arg_limit(bprm);
 	if (retval < 0)
 		goto out;
 
-- 
2.26.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2020-06-18 14:47 UTC|newest]

Thread overview: 120+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-18 14:46 properly support exec and wait with kernel pointers v2 Christoph Hellwig
2020-06-18 14:46 ` Christoph Hellwig
2020-06-18 14:46 ` Christoph Hellwig
2020-06-18 14:46 ` Christoph Hellwig
2020-06-18 14:46 ` [PATCH 1/6] exec: cleanup the execve wrappers Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46 ` [PATCH 2/6] exec: simplify the compat syscall handling Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46 ` [PATCH 3/6] exec: cleanup the count() function Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-19  8:28   ` Sergei Shtylyov
2020-06-19  8:28     ` Sergei Shtylyov
2020-06-19  8:28     ` Sergei Shtylyov
2020-06-19  8:28     ` Sergei Shtylyov
2020-06-18 14:46 ` Christoph Hellwig [this message]
2020-06-18 14:46   ` [PATCH 4/6] exec: split prepare_arg_pages Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46 ` [PATCH 5/6] exec: add a kernel_execveat helper Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46 ` [PATCH 6/6] kernel: add a kernel_wait helper Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-18 14:46   ` Christoph Hellwig
2020-06-19 21:17   ` Luis Chamberlain
2020-06-19 21:17     ` Luis Chamberlain
2020-06-19 21:17     ` Luis Chamberlain
2020-06-20  6:35     ` Christoph Hellwig
2020-06-20  6:35       ` Christoph Hellwig
2020-06-20  6:35       ` Christoph Hellwig
2020-06-20  6:35       ` Christoph Hellwig
2020-06-20 17:02       ` Luis Chamberlain
2020-06-20 17:02         ` Luis Chamberlain
2020-06-20 17:02         ` Luis Chamberlain
  -- strict thread matches above, loose matches on Subject: below --
2020-06-15 13:00 properly support exec and wait with kernel pointers Christoph Hellwig
2020-06-15 13:00 ` Christoph Hellwig
2020-06-15 13:00 ` Christoph Hellwig
2020-06-15 13:00 ` Christoph Hellwig
2020-06-15 13:00 ` [PATCH 1/6] exec: cleanup the execve wrappers Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00 ` [PATCH 2/6] exec: simplify the compat syscall handling Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:31   ` Arnd Bergmann
2020-06-15 13:31     ` Arnd Bergmann
2020-06-15 13:31     ` Arnd Bergmann
2020-06-15 13:31     ` Arnd Bergmann
2020-06-15 14:12     ` Christoph Hellwig
2020-06-15 14:12       ` Christoph Hellwig
2020-06-15 14:12       ` Christoph Hellwig
2020-06-15 14:12       ` Christoph Hellwig
2020-06-15 14:40       ` Arnd Bergmann
2020-06-15 14:40         ` Arnd Bergmann
2020-06-15 14:40         ` Arnd Bergmann
2020-06-15 14:40         ` Arnd Bergmann
2020-06-15 14:43         ` Christoph Hellwig
2020-06-15 14:43           ` Christoph Hellwig
2020-06-15 14:43           ` Christoph Hellwig
2020-06-15 14:43           ` Christoph Hellwig
2020-06-15 14:46           ` Arnd Bergmann
2020-06-15 14:46             ` Arnd Bergmann
2020-06-15 14:46             ` Arnd Bergmann
2020-06-15 14:46             ` Arnd Bergmann
2020-06-15 15:09             ` Christoph Hellwig
2020-06-15 15:09               ` Christoph Hellwig
2020-06-15 15:09               ` Christoph Hellwig
2020-06-15 15:09               ` Christoph Hellwig
2020-06-15 15:33               ` Brian Gerst
2020-06-15 15:33                 ` Brian Gerst
2020-06-15 15:33                 ` Brian Gerst
2020-06-15 15:33                 ` Brian Gerst
2020-06-15 15:33                 ` Brian Gerst
2020-06-15 16:41                 ` Christoph Hellwig
2020-06-15 16:41                   ` Christoph Hellwig
2020-06-15 16:41                   ` Christoph Hellwig
2020-06-15 16:41                   ` Christoph Hellwig
2020-06-15 14:48       ` Brian Gerst
2020-06-15 14:48         ` Brian Gerst
2020-06-15 14:48         ` Brian Gerst
2020-06-15 14:48         ` Brian Gerst
2020-06-15 18:47         ` Arnd Bergmann
2020-06-15 18:47           ` Arnd Bergmann
2020-06-15 18:47           ` Arnd Bergmann
2020-06-15 18:47           ` Arnd Bergmann
2020-06-15 19:45           ` Brian Gerst
2020-06-15 19:45             ` Brian Gerst
2020-06-15 19:45             ` Brian Gerst
2020-06-15 19:45             ` Brian Gerst
2020-06-15 13:00 ` [PATCH 3/6] exec: cleanup the count() function Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00 ` [PATCH 4/6] exec: split prepare_arg_pages Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00 ` [PATCH 5/6] exec: add a kernel_execveat helper Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00 ` [PATCH 6/6] kernel: add a kernel_wait helper Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:00   ` Christoph Hellwig
2020-06-15 13:42 ` properly support exec and wait with kernel pointers Arnd Bergmann
2020-06-15 13:42   ` Arnd Bergmann
2020-06-15 13:42   ` Arnd Bergmann
2020-06-15 13:42   ` Arnd Bergmann

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=20200618144627.114057-5-hch@lst.de \
    --to=hch@lst.de \
    --cc=arnd@arndb.de \
    --cc=brgerst@gmail.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mcgrof@kernel.org \
    --cc=sparclinux@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=x86@kernel.org \
    /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.