public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: lustre: fix pointer declarations
@ 2014-11-25 20:44 Zahari Doychev
  2014-11-26  2:05 ` Joe Perches
  2014-11-26 12:45 ` Al Viro
  0 siblings, 2 replies; 3+ messages in thread
From: Zahari Doychev @ 2014-11-25 20:44 UTC (permalink / raw)
  To: linux-kernel, dan.carpenter
  Cc: devel, oleg.drokin, andreas.dilger, gregkh, bergwolf

This patch fixes pointer declarations from void * to void __user * in order
to remove some sparse warnings.

lib-lnet.h:798:48: warning: incorrect type in initializer (different address spaces)
lib-lnet.h:798:48:    expected void [noderef] <asn:1>*iov_base
lib-lnet.h:798:48:    got void *dest
lib-lnet.h:787:47: warning: incorrect type in initializer (different address spaces)
lib-lnet.h:787:47:    expected void [noderef] <asn:1>*iov_base
lib-lnet.h:787:47:    got void *dest
lib-lnet.h:819:48: warning: incorrect type in initializer (different address spaces)
lib-lnet.h:819:48:    expected void [noderef] <asn:1>*iov_base
lib-lnet.h:819:48:    got void *src
lib-lnet.h:808:47: warning: incorrect type in initializer (different address spaces)
lib-lnet.h:808:47:    expected void [noderef] <asn:1>*iov_base
lib-lnet.h:808:47:    got void *src

Signed-off-by: Zahari Doychev <zahari.doychev@linux.com>
---
 drivers/staging/lustre/include/linux/lnet/lib-lnet.h | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
index 7e89b3b..e60ce56 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
@@ -780,22 +780,22 @@ void lnet_copy_kiov2kiov(unsigned int ndkiov, lnet_kiov_t *dkiov,
 			  unsigned int soffset, unsigned int nob);
 
 static inline void
-lnet_copy_iov2flat(int dlen, void *dest, unsigned int doffset,
+lnet_copy_iov2flat(int dlen, void __user *dest, unsigned int doffset,
 		   unsigned int nsiov, struct iovec *siov, unsigned int soffset,
 		   unsigned int nob)
 {
-	struct iovec diov = {/*.iov_base = */ dest, /*.iov_len = */ dlen};
+	struct iovec diov = {.iov_base = dest, .iov_len = dlen};
 
 	lnet_copy_iov2iov(1, &diov, doffset,
 			  nsiov, siov, soffset, nob);
 }
 
 static inline void
-lnet_copy_kiov2flat(int dlen, void *dest, unsigned int doffset,
+lnet_copy_kiov2flat(int dlen, void __user *dest, unsigned int doffset,
 		    unsigned int nsiov, lnet_kiov_t *skiov,
 		    unsigned int soffset, unsigned int nob)
 {
-	struct iovec diov = {/* .iov_base = */ dest, /* .iov_len = */ dlen};
+	struct iovec diov = {.iov_base = dest, .iov_len = dlen};
 
 	lnet_copy_kiov2iov(1, &diov, doffset,
 			   nsiov, skiov, soffset, nob);
@@ -803,9 +803,10 @@ lnet_copy_kiov2flat(int dlen, void *dest, unsigned int doffset,
 
 static inline void
 lnet_copy_flat2iov(unsigned int ndiov, struct iovec *diov, unsigned int doffset,
-		   int slen, void *src, unsigned int soffset, unsigned int nob)
+		   int slen, void __user *src, unsigned int soffset,
+		   unsigned int nob)
 {
-	struct iovec siov = {/*.iov_base = */ src, /*.iov_len = */slen};
+	struct iovec siov = {.iov_base =  src, .iov_len = slen};
 
 	lnet_copy_iov2iov(ndiov, diov, doffset,
 			  1, &siov, soffset, nob);
@@ -813,10 +814,10 @@ lnet_copy_flat2iov(unsigned int ndiov, struct iovec *diov, unsigned int doffset,
 
 static inline void
 lnet_copy_flat2kiov(unsigned int ndiov, lnet_kiov_t *dkiov,
-		    unsigned int doffset, int slen, void *src,
+		    unsigned int doffset, int slen, void __user *src,
 		    unsigned int soffset, unsigned int nob)
 {
-	struct iovec siov = {/* .iov_base = */ src, /* .iov_len = */ slen};
+	struct iovec siov = {.iov_base = src, .iov_len = slen};
 
 	lnet_copy_iov2kiov(ndiov, dkiov, doffset,
 			   1, &siov, soffset, nob);
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: lustre: fix pointer declarations
  2014-11-25 20:44 [PATCH] staging: lustre: fix pointer declarations Zahari Doychev
@ 2014-11-26  2:05 ` Joe Perches
  2014-11-26 12:45 ` Al Viro
  1 sibling, 0 replies; 3+ messages in thread
From: Joe Perches @ 2014-11-26  2:05 UTC (permalink / raw)
  To: Zahari Doychev
  Cc: linux-kernel, dan.carpenter, devel, oleg.drokin, andreas.dilger,
	gregkh, bergwolf

On Tue, 2014-11-25 at 21:44 +0100, Zahari Doychev wrote:
> This patch fixes pointer declarations from void * to void __user * in order
> to remove some sparse warnings.

This patch does more than that.

Please make sure to describe all of the changes
in a patch in the commit message.

> diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
[]
> @@ -780,22 +780,22 @@ void lnet_copy_kiov2kiov(unsigned int ndkiov, lnet_kiov_t *dkiov,
>  			  unsigned int soffset, unsigned int nob);
>  
>  static inline void
> -lnet_copy_iov2flat(int dlen, void *dest, unsigned int doffset,
> +lnet_copy_iov2flat(int dlen, void __user *dest, unsigned int doffset,
>  		   unsigned int nsiov, struct iovec *siov, unsigned int soffset,
>  		   unsigned int nob)
>  {
> -	struct iovec diov = {/*.iov_base = */ dest, /*.iov_len = */ dlen};
> +	struct iovec diov = {.iov_base = dest, .iov_len = dlen};

Now using named initializers too.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: lustre: fix pointer declarations
  2014-11-25 20:44 [PATCH] staging: lustre: fix pointer declarations Zahari Doychev
  2014-11-26  2:05 ` Joe Perches
@ 2014-11-26 12:45 ` Al Viro
  1 sibling, 0 replies; 3+ messages in thread
From: Al Viro @ 2014-11-26 12:45 UTC (permalink / raw)
  To: Zahari Doychev
  Cc: linux-kernel, dan.carpenter, devel, oleg.drokin, andreas.dilger,
	gregkh, bergwolf

On Tue, Nov 25, 2014 at 09:44:21PM +0100, Zahari Doychev wrote:
> This patch fixes pointer declarations from void * to void __user * in order
> to remove some sparse warnings.

_Are_ those userland addresses, though?  Quick grep shows that in the
only caller of lnet_copy_iov2flat() we have something called ibmsg passed
as the second argument *AND* *RIGHT* *BEFORE* *THAT* *CALL* *WE* *HAVE*
        ibmsg = tx->tx_msg;
        ibmsg->ibm_u.immediate.ibim_hdr = *hdr;
Go ahead, explain how does that manage to work if ibmsg is a userland pointer.
Either you have discovered an exploitable hole (direct store to userland
address), or it's not a userland pointer, after all.

Al, sick and tired of the "remove some warnings" as the sole rationale for
patches, without even an attempt to figure out what those warnings are
about.  Magic box makes noises, magic box must be appeased...

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-11-26 12:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-25 20:44 [PATCH] staging: lustre: fix pointer declarations Zahari Doychev
2014-11-26  2:05 ` Joe Perches
2014-11-26 12:45 ` Al Viro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox