Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1588318

[RFC] ERR_USER_PTR

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From Matthew Wilcox <willy@infradead.org>
Newsgroups linux.kernel
Subject [RFC] ERR_USER_PTR
Date Sun, 26 Feb 2017 13:00:01 +0100
Message-ID <tf5EB-6fD-1@gated-at.bofh.it> (permalink)
Dkim-Signature v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Type:MIME-Version:Message-ID: Subject:To:From:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=92E5A+W0D9UZuDO7G9D55U9CZJwi6J4N65Kv2Qda8tg=; b=T+2XfUy5C55kwzG8lwdpEtpNKV 3Nh9hBpTr184LoIMQDRcES4sPW6HqkcJzayn51Px2oOfXzyFg3f7/Ug/oU/6qZDnb6a/S1cjqgJTr xm4C/j4ONkSs1/Wj3P0/hm6cmiADdt6nPmO3vyktuOJFaHDmpN7Em8cAGffWiFymhdiYthXQ50H76 dsK+xFMZDR81vKK1m6612DQyMzpPAAjgQtON0pI8Eu411FHhR+I7XPy17Nc+TQJqcO5dqfg+2NBnD By3dKKdKscpy8drjCpVOkySODi/DLMN8sWgTW44ZwgWLP+AXImzyfKxpLVSt75I+JbqFF20d+wqtR anBNeoFQ==;
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
User-Agent Mutt/1.7.1 (2016-10-04)
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 53
Organization linux.* mail to news gateway
X-Original-Date Sun, 26 Feb 2017 03:29:13 -0800
X-Original-Message-ID <20170226112913.GD16328@bombadil.infradead.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1588318

Show key headers only | View raw


In an attempt to clean up sparse warnings, I offer this small patch.
The two warnings it fixes are:

fs/exec.c:424:39: warning: incorrect type in return expression (different address spaces)
fs/exec.c:424:39:    expected char const [noderef] <asn:1>*
fs/exec.c:424:39:    got void *
fs/exec.c:431:31: warning: incorrect type in return expression (different address spaces)
fs/exec.c:431:31:    expected char const [noderef] <asn:1>*
fs/exec.c:431:31:    got void *

It seems cleaner to me to have a new ERR_USER_PTR macro than to add casts
in get_user_ptr_arg().

Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>

diff --git a/fs/exec.c b/fs/exec.c
index b148ad241792..0d1678a3e284 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -421,14 +421,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
 		compat_uptr_t compat;
 
 		if (get_user(compat, argv.ptr.compat + nr))
-			return ERR_PTR(-EFAULT);
+			return ERR_USER_PTR(-EFAULT);
 
 		return compat_ptr(compat);
 	}
 #endif
 
 	if (get_user(native, argv.ptr.native + nr))
-		return ERR_PTR(-EFAULT);
+		return ERR_USER_PTR(-EFAULT);
 
 	return native;
 }
diff --git a/include/linux/err.h b/include/linux/err.h
index 1e3558845e4c..14bd9864acbd 100644
--- a/include/linux/err.h
+++ b/include/linux/err.h
@@ -25,6 +25,11 @@ static inline void * __must_check ERR_PTR(long error)
 	return (void *) error;
 }
 
+static inline void __user * __must_check ERR_USER_PTR(long error)
+{
+	return (void __user *) error;
+}
+
 static inline long __must_check PTR_ERR(__force const void *ptr)
 {
 	return (long) ptr;

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[RFC] ERR_USER_PTR Matthew Wilcox <willy@infradead.org> - 2017-02-26 13:00 +0100

csiph-web