Skip to contentSkip to conversation

linux/uio.h: cleanup for userspace

PATCH Superseded Mike Frysinger 3 participants 6 messages Dec 27, 2008 – Dec 29, 2008 Userspace copyin/copyout (uiovec)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux/uio.h: cleanup for userspace

Hide iov_shorten() behind __KERNEL__ since it's a prototype only. Use the __inline__ form for iov_length() since it's usable by userspace.

---
 include/linux/uio.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
include/linux/uio.h +3 -1
index b7fe138..2faeea6 100644
@@ -42,7 +42,7 @@ struct kvec {
  * segment lengths have been validated.  Because the individual lengths can
  * overflow a size_t when added together.
  */
-static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs)
+static __inline__ size_t iov_length(const struct iovec *iov, unsigned long nr_segs)
 {
 	unsigned long seg;
 	size_t ret = 0;
@@ -52,6 +52,8 @@ static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs)
 	return ret;
 }
 
+#ifdef __KERNEL__
 unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to);
+#endif
 
 #endif
Signature · 1 line
1.6.0.6
#1 lore raw

PATCH v2 1/1 linux/uio.h: cleanup for userspace

Hide iov_shorten() behind __KERNEL__ since it's a prototype only. Use the __inline__ form for iov_length() since it's usable by userspace.

---
v2
- drop inline conversion stuff

 include/linux/uio.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/linux/uio.h +2 -0
index b7fe138..bd1661b 100644
@@ -52,6 +52,8 @@ static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs)
 	return ret;
 }
 
+#ifdef __KERNEL__
 unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to);
+#endif
 
 #endif
Signature · 1 line
1.6.0.6
#2 lore raw
Quoted 16 lines · Mike Frysinger

Hide iov_shorten() behind __KERNEL__ since it's a prototype only. Use the __inline__ form for iov_length() since it's usable by userspace.

---
v2
- drop inline conversion stuff

 include/linux/uio.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/linux/uio.h +0 -0
index b7fe138..bd1661b 100644

include/linux/uio.h static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs) · line 59

Quoted 8 lines
include/linux/uio.h +2 -0
@@ -52,6 +52,8 @@ static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs)
 	return ret;
 }
 
+#ifdef __KERNEL__
 unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to);
+#endif
 
 #endif

Could we rearrange stuff in this file so we only get one #ifdef __KERNEL__ / endif pair?

Sam

#3 lore raw

PATCH v3 1/1 linux/uio.h: cleanup for userspace

Hide iov_shorten() behind __KERNEL__ since it's a prototype only. Use the __inline__ form for iov_length() since it's usable by userspace.

---
v3
- keep all __KERNEL__ stuff in one place
v2
- drop inline conversion stuff

 include/linux/uio.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
include/linux/uio.h +2 -2
index b7fe138..3debd89 100644
@@ -26,6 +26,8 @@ struct kvec {
 	size_t iov_len;
 };
 
+unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to);
+
 #endif
 
 /*
@@ -52,6 +54,4 @@ static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs)
 	return ret;
 }
 
-unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to);
-
 #endif
Signature · 1 line
1.6.0.6
#4 lore raw
Quoted 27 lines · Mike Frysinger

Hide iov_shorten() behind __KERNEL__ since it's a prototype only. Use the __inline__ form for iov_length() since it's usable by userspace.

---
v3
- keep all __KERNEL__ stuff in one place
v2
- drop inline conversion stuff

 include/linux/uio.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
include/linux/uio.h +2 -0
index b7fe138..3debd89 100644
@@ -26,6 +26,8 @@ struct kvec {
 	size_t iov_len;
 };
 
+unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to);
+
 #endif
 
 /*

include/linux/uio.h static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs) · line 57

Quoted 6 lines
include/linux/uio.h +0 -2
@@ -52,6 +54,4 @@ static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs)
 	return ret;
 }
 
-unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to);
-
 #endif

Umm, iov_length is another kernel-only thing and should not be left user-visible. And struct kvec is in another __KERNEL__ block.

Just move UIO_FASTIOV and UIO_MAXIOV up and have a single __KERNEL__ block for the rest.

#5 lore raw

PATCH v4 1/1 linux/uio.h: cleanup for userspace

Hide iov_shorten() behind __KERNEL__ since it's a prototype only. Use the __inline__ form for iov_length() since it's usable by userspace.

---
v4
- hide all funcs behind __KERNEL__
v3
- keep all __KERNEL__ stuff in one place
v2
- drop inline conversion stuff

 include/linux/uio.h |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)
include/linux/uio.h +9 -9
index b7fe138..31d75cd 100644
@@ -19,6 +19,13 @@ struct iovec
 	__kernel_size_t iov_len; /* Must be size_t (1003.1g) */
 };
 
+/*
+ *	UIO_MAXIOV shall be at least 16 1003.1g (5.4.1.1)
+ */
+
+#define UIO_FASTIOV	8
+#define UIO_MAXIOV	1024
+
 #ifdef __KERNEL__
 
 struct kvec {
@@ -26,15 +33,6 @@ struct kvec {
 	size_t iov_len;
 };
 
-#endif
-
-/*
- *	UIO_MAXIOV shall be at least 16 1003.1g (5.4.1.1)
- */
- 
-#define UIO_FASTIOV	8
-#define UIO_MAXIOV	1024
-
 /*
  * Total number of bytes covered by an iovec.
  *
@@ -55,3 +53,5 @@ static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs)
 unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to);
 
 #endif
+
+#endif
Signature · 1 line
1.6.0.6