diff options
| author | David S. Miller <davem@davemloft.net> | 2015-04-13 18:18:05 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2015-04-13 18:18:05 -0400 |
| commit | 6e8a9d9148b6dc2305fcaaf60550b81cbb6319c6 (patch) | |
| tree | 60a235b136b1a3b2d0d7f3eef903fa13c319e1e9 /include | |
| parent | 789f558cfb3680aeb52de137418637f6b04b7d22 (diff) | |
| parent | 01e97e6517053d7c0b9af5248e944a9209909cf5 (diff) | |
Merge branch 'for-davem' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Al Viro says:
====================
netdev-related stuff in vfs.git
There are several commits sitting in vfs.git that probably ought to go in
via net-next.git. First of all, there's merge with vfs.git#iocb - that's
Christoph's aio rework, which has triggered conflicts with the ->sendmsg()
and ->recvmsg() patches a while ago. It's not so much Christoph's stuff
that ought to be in net-next, as (pretty simple) conflict resolution on merge.
The next chunk is switch to {compat_,}import_iovec/import_single_range - new
safer primitives for initializing iov_iter. The primitives themselves come
from vfs/git#iov_iter (and they are used quite a lot in vfs part of queue),
conversion of net/socket.c syscalls belongs in net-next, IMO. Next there's
afs and rxrpc stuff from dhowells. And then there's sanitizing kernel_sendmsg
et.al. + missing inlined helper for "how much data is left in msg->msg_iter" -
this stuff is used in e.g. cifs stuff, but it belongs in net-next.
That pile is pullable from
git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git for-davem
I'll post the individual patches in there in followups; could you take a look
and tell if everything in there is OK with you?
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/aio.h | 70 | ||||
| -rw-r--r-- | include/linux/fs.h | 22 | ||||
| -rw-r--r-- | include/linux/net.h | 2 | ||||
| -rw-r--r-- | include/linux/socket.h | 5 | ||||
| -rw-r--r-- | include/linux/uio.h | 14 | ||||
| -rw-r--r-- | include/net/compat.h | 2 | ||||
| -rw-r--r-- | include/net/sock.h | 1 | ||||
| -rw-r--r-- | include/rxrpc/packet.h | 3 |
8 files changed, 46 insertions, 73 deletions
diff --git a/include/linux/aio.h b/include/linux/aio.h index d9c92daa3944..9eb42dbc5582 100644 --- a/include/linux/aio.h +++ b/include/linux/aio.h | |||
| @@ -1,86 +1,23 @@ | |||
| 1 | #ifndef __LINUX__AIO_H | 1 | #ifndef __LINUX__AIO_H |
| 2 | #define __LINUX__AIO_H | 2 | #define __LINUX__AIO_H |
| 3 | 3 | ||
| 4 | #include <linux/list.h> | ||
| 5 | #include <linux/workqueue.h> | ||
| 6 | #include <linux/aio_abi.h> | 4 | #include <linux/aio_abi.h> |
| 7 | #include <linux/uio.h> | ||
| 8 | #include <linux/rcupdate.h> | ||
| 9 | |||
| 10 | #include <linux/atomic.h> | ||
| 11 | 5 | ||
| 12 | struct kioctx; | 6 | struct kioctx; |
| 13 | struct kiocb; | 7 | struct kiocb; |
| 8 | struct mm_struct; | ||
| 14 | 9 | ||
| 15 | #define KIOCB_KEY 0 | 10 | #define KIOCB_KEY 0 |
| 16 | 11 | ||
| 17 | /* | ||
| 18 | * We use ki_cancel == KIOCB_CANCELLED to indicate that a kiocb has been either | ||
| 19 | * cancelled or completed (this makes a certain amount of sense because | ||
| 20 | * successful cancellation - io_cancel() - does deliver the completion to | ||
| 21 | * userspace). | ||
| 22 | * | ||
| 23 | * And since most things don't implement kiocb cancellation and we'd really like | ||
| 24 | * kiocb completion to be lockless when possible, we use ki_cancel to | ||
| 25 | * synchronize cancellation and completion - we only set it to KIOCB_CANCELLED | ||
| 26 | * with xchg() or cmpxchg(), see batch_complete_aio() and kiocb_cancel(). | ||
| 27 | */ | ||
| 28 | #define KIOCB_CANCELLED ((void *) (~0ULL)) | ||
| 29 | |||
| 30 | typedef int (kiocb_cancel_fn)(struct kiocb *); | 12 | typedef int (kiocb_cancel_fn)(struct kiocb *); |
| 31 | 13 | ||
| 32 | struct kiocb { | ||
| 33 | struct file *ki_filp; | ||
| 34 | struct kioctx *ki_ctx; /* NULL for sync ops */ | ||
| 35 | kiocb_cancel_fn *ki_cancel; | ||
| 36 | void *private; | ||
| 37 | |||
| 38 | union { | ||
| 39 | void __user *user; | ||
| 40 | struct task_struct *tsk; | ||
| 41 | } ki_obj; | ||
| 42 | |||
| 43 | __u64 ki_user_data; /* user's data for completion */ | ||
| 44 | loff_t ki_pos; | ||
| 45 | size_t ki_nbytes; /* copy of iocb->aio_nbytes */ | ||
| 46 | |||
| 47 | struct list_head ki_list; /* the aio core uses this | ||
| 48 | * for cancellation */ | ||
| 49 | |||
| 50 | /* | ||
| 51 | * If the aio_resfd field of the userspace iocb is not zero, | ||
| 52 | * this is the underlying eventfd context to deliver events to. | ||
| 53 | */ | ||
| 54 | struct eventfd_ctx *ki_eventfd; | ||
| 55 | }; | ||
| 56 | |||
| 57 | static inline bool is_sync_kiocb(struct kiocb *kiocb) | ||
| 58 | { | ||
| 59 | return kiocb->ki_ctx == NULL; | ||
| 60 | } | ||
| 61 | |||
| 62 | static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp) | ||
| 63 | { | ||
| 64 | *kiocb = (struct kiocb) { | ||
| 65 | .ki_ctx = NULL, | ||
| 66 | .ki_filp = filp, | ||
| 67 | .ki_obj.tsk = current, | ||
| 68 | }; | ||
| 69 | } | ||
| 70 | |||
| 71 | /* prototypes */ | 14 | /* prototypes */ |
| 72 | #ifdef CONFIG_AIO | 15 | #ifdef CONFIG_AIO |
| 73 | extern ssize_t wait_on_sync_kiocb(struct kiocb *iocb); | ||
| 74 | extern void aio_complete(struct kiocb *iocb, long res, long res2); | ||
| 75 | struct mm_struct; | ||
| 76 | extern void exit_aio(struct mm_struct *mm); | 16 | extern void exit_aio(struct mm_struct *mm); |
| 77 | extern long do_io_submit(aio_context_t ctx_id, long nr, | 17 | extern long do_io_submit(aio_context_t ctx_id, long nr, |
| 78 | struct iocb __user *__user *iocbpp, bool compat); | 18 | struct iocb __user *__user *iocbpp, bool compat); |
| 79 | void kiocb_set_cancel_fn(struct kiocb *req, kiocb_cancel_fn *cancel); | 19 | void kiocb_set_cancel_fn(struct kiocb *req, kiocb_cancel_fn *cancel); |
| 80 | #else | 20 | #else |
| 81 | static inline ssize_t wait_on_sync_kiocb(struct kiocb *iocb) { return 0; } | ||
| 82 | static inline void aio_complete(struct kiocb *iocb, long res, long res2) { } | ||
| 83 | struct mm_struct; | ||
| 84 | static inline void exit_aio(struct mm_struct *mm) { } | 21 | static inline void exit_aio(struct mm_struct *mm) { } |
| 85 | static inline long do_io_submit(aio_context_t ctx_id, long nr, | 22 | static inline long do_io_submit(aio_context_t ctx_id, long nr, |
| 86 | struct iocb __user * __user *iocbpp, | 23 | struct iocb __user * __user *iocbpp, |
| @@ -89,11 +26,6 @@ static inline void kiocb_set_cancel_fn(struct kiocb *req, | |||
| 89 | kiocb_cancel_fn *cancel) { } | 26 | kiocb_cancel_fn *cancel) { } |
| 90 | #endif /* CONFIG_AIO */ | 27 | #endif /* CONFIG_AIO */ |
| 91 | 28 | ||
| 92 | static inline struct kiocb *list_kiocb(struct list_head *h) | ||
| 93 | { | ||
| 94 | return list_entry(h, struct kiocb, ki_list); | ||
| 95 | } | ||
| 96 | |||
| 97 | /* for sysctl: */ | 29 | /* for sysctl: */ |
| 98 | extern unsigned long aio_nr; | 30 | extern unsigned long aio_nr; |
| 99 | extern unsigned long aio_max_nr; | 31 | extern unsigned long aio_max_nr; |
diff --git a/include/linux/fs.h b/include/linux/fs.h index f4131e8ead74..fdce1ddf230c 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
| @@ -314,6 +314,28 @@ struct page; | |||
| 314 | struct address_space; | 314 | struct address_space; |
| 315 | struct writeback_control; | 315 | struct writeback_control; |
| 316 | 316 | ||
| 317 | #define IOCB_EVENTFD (1 << 0) | ||
| 318 | |||
| 319 | struct kiocb { | ||
| 320 | struct file *ki_filp; | ||
| 321 | loff_t ki_pos; | ||
| 322 | void (*ki_complete)(struct kiocb *iocb, long ret, long ret2); | ||
| 323 | void *private; | ||
| 324 | int ki_flags; | ||
| 325 | }; | ||
| 326 | |||
| 327 | static inline bool is_sync_kiocb(struct kiocb *kiocb) | ||
| 328 | { | ||
| 329 | return kiocb->ki_complete == NULL; | ||
| 330 | } | ||
| 331 | |||
| 332 | static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp) | ||
| 333 | { | ||
| 334 | *kiocb = (struct kiocb) { | ||
| 335 | .ki_filp = filp, | ||
| 336 | }; | ||
| 337 | } | ||
| 338 | |||
| 317 | /* | 339 | /* |
| 318 | * "descriptor" for what we're up to with a read. | 340 | * "descriptor" for what we're up to with a read. |
| 319 | * This allows us to use the same read code yet | 341 | * This allows us to use the same read code yet |
diff --git a/include/linux/net.h b/include/linux/net.h index e74114bcca68..738ea48be889 100644 --- a/include/linux/net.h +++ b/include/linux/net.h | |||
| @@ -211,7 +211,7 @@ int sock_create(int family, int type, int proto, struct socket **res); | |||
| 211 | int sock_create_kern(int family, int type, int proto, struct socket **res); | 211 | int sock_create_kern(int family, int type, int proto, struct socket **res); |
| 212 | int sock_create_lite(int family, int type, int proto, struct socket **res); | 212 | int sock_create_lite(int family, int type, int proto, struct socket **res); |
| 213 | void sock_release(struct socket *sock); | 213 | void sock_release(struct socket *sock); |
| 214 | int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t len); | 214 | int sock_sendmsg(struct socket *sock, struct msghdr *msg); |
| 215 | int sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, | 215 | int sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, |
| 216 | int flags); | 216 | int flags); |
| 217 | struct file *sock_alloc_file(struct socket *sock, int flags, const char *dname); | 217 | struct file *sock_alloc_file(struct socket *sock, int flags, const char *dname); |
diff --git a/include/linux/socket.h b/include/linux/socket.h index c9852ef7e317..5bf59c8493b7 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h | |||
| @@ -139,6 +139,11 @@ static inline struct cmsghdr * cmsg_nxthdr (struct msghdr *__msg, struct cmsghdr | |||
| 139 | return __cmsg_nxthdr(__msg->msg_control, __msg->msg_controllen, __cmsg); | 139 | return __cmsg_nxthdr(__msg->msg_control, __msg->msg_controllen, __cmsg); |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | static inline size_t msg_data_left(struct msghdr *msg) | ||
| 143 | { | ||
| 144 | return iov_iter_count(&msg->msg_iter); | ||
| 145 | } | ||
| 146 | |||
| 142 | /* "Socket"-level control message types: */ | 147 | /* "Socket"-level control message types: */ |
| 143 | 148 | ||
| 144 | #define SCM_RIGHTS 0x01 /* rw: access rights (array of int) */ | 149 | #define SCM_RIGHTS 0x01 /* rw: access rights (array of int) */ |
diff --git a/include/linux/uio.h b/include/linux/uio.h index 71880299ed48..1f4a37f1f025 100644 --- a/include/linux/uio.h +++ b/include/linux/uio.h | |||
| @@ -139,4 +139,18 @@ static inline void iov_iter_reexpand(struct iov_iter *i, size_t count) | |||
| 139 | size_t csum_and_copy_to_iter(void *addr, size_t bytes, __wsum *csum, struct iov_iter *i); | 139 | size_t csum_and_copy_to_iter(void *addr, size_t bytes, __wsum *csum, struct iov_iter *i); |
| 140 | size_t csum_and_copy_from_iter(void *addr, size_t bytes, __wsum *csum, struct iov_iter *i); | 140 | size_t csum_and_copy_from_iter(void *addr, size_t bytes, __wsum *csum, struct iov_iter *i); |
| 141 | 141 | ||
| 142 | int import_iovec(int type, const struct iovec __user * uvector, | ||
| 143 | unsigned nr_segs, unsigned fast_segs, | ||
| 144 | struct iovec **iov, struct iov_iter *i); | ||
| 145 | |||
| 146 | #ifdef CONFIG_COMPAT | ||
| 147 | struct compat_iovec; | ||
| 148 | int compat_import_iovec(int type, const struct compat_iovec __user * uvector, | ||
| 149 | unsigned nr_segs, unsigned fast_segs, | ||
| 150 | struct iovec **iov, struct iov_iter *i); | ||
| 151 | #endif | ||
| 152 | |||
| 153 | int import_single_range(int type, void __user *buf, size_t len, | ||
| 154 | struct iovec *iov, struct iov_iter *i); | ||
| 155 | |||
| 142 | #endif | 156 | #endif |
diff --git a/include/net/compat.h b/include/net/compat.h index 42a9c8431177..48103cf94e97 100644 --- a/include/net/compat.h +++ b/include/net/compat.h | |||
| @@ -40,7 +40,7 @@ int compat_sock_get_timestampns(struct sock *, struct timespec __user *); | |||
| 40 | #define compat_mmsghdr mmsghdr | 40 | #define compat_mmsghdr mmsghdr |
| 41 | #endif /* defined(CONFIG_COMPAT) */ | 41 | #endif /* defined(CONFIG_COMPAT) */ |
| 42 | 42 | ||
| 43 | ssize_t get_compat_msghdr(struct msghdr *, struct compat_msghdr __user *, | 43 | int get_compat_msghdr(struct msghdr *, struct compat_msghdr __user *, |
| 44 | struct sockaddr __user **, struct iovec **); | 44 | struct sockaddr __user **, struct iovec **); |
| 45 | asmlinkage long compat_sys_sendmsg(int, struct compat_msghdr __user *, | 45 | asmlinkage long compat_sys_sendmsg(int, struct compat_msghdr __user *, |
| 46 | unsigned int); | 46 | unsigned int); |
diff --git a/include/net/sock.h b/include/net/sock.h index bd6f523f2251..3a4898ec8c67 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
| @@ -57,7 +57,6 @@ | |||
| 57 | #include <linux/page_counter.h> | 57 | #include <linux/page_counter.h> |
| 58 | #include <linux/memcontrol.h> | 58 | #include <linux/memcontrol.h> |
| 59 | #include <linux/static_key.h> | 59 | #include <linux/static_key.h> |
| 60 | #include <linux/aio.h> | ||
| 61 | #include <linux/sched.h> | 60 | #include <linux/sched.h> |
| 62 | 61 | ||
| 63 | #include <linux/filter.h> | 62 | #include <linux/filter.h> |
diff --git a/include/rxrpc/packet.h b/include/rxrpc/packet.h index f2902ef7ab75..4dce116bfd80 100644 --- a/include/rxrpc/packet.h +++ b/include/rxrpc/packet.h | |||
| @@ -47,7 +47,8 @@ struct rxrpc_header { | |||
| 47 | #define RXRPC_PACKET_TYPE_CHALLENGE 6 /* connection security challenge (SRVR->CLNT) */ | 47 | #define RXRPC_PACKET_TYPE_CHALLENGE 6 /* connection security challenge (SRVR->CLNT) */ |
| 48 | #define RXRPC_PACKET_TYPE_RESPONSE 7 /* connection secutity response (CLNT->SRVR) */ | 48 | #define RXRPC_PACKET_TYPE_RESPONSE 7 /* connection secutity response (CLNT->SRVR) */ |
| 49 | #define RXRPC_PACKET_TYPE_DEBUG 8 /* debug info request */ | 49 | #define RXRPC_PACKET_TYPE_DEBUG 8 /* debug info request */ |
| 50 | #define RXRPC_N_PACKET_TYPES 9 /* number of packet types (incl type 0) */ | 50 | #define RXRPC_PACKET_TYPE_VERSION 13 /* version string request */ |
| 51 | #define RXRPC_N_PACKET_TYPES 14 /* number of packet types (incl type 0) */ | ||
| 51 | 52 | ||
| 52 | uint8_t flags; /* packet flags */ | 53 | uint8_t flags; /* packet flags */ |
| 53 | #define RXRPC_CLIENT_INITIATED 0x01 /* signifies a packet generated by a client */ | 54 | #define RXRPC_CLIENT_INITIATED 0x01 /* signifies a packet generated by a client */ |
