• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 #ifndef _LINUX_IO_URING_H
3 #define _LINUX_IO_URING_H
4 
5 #include <linux/sched.h>
6 #include <linux/xarray.h>
7 
8 #ifdef __GENKSYMS__
9 /*
10  * ANDROID ABI HACK
11  *
12  * In the 5.10.162 release, the io_uring code was synced with the version
13  * that is in the 5.15.y kernel tree in order to resolve a huge number of
14  * potential, and known, problems with the codebase.  This makes for a more
15  * secure and easier-to-update-and-maintain 5.10.y kernel tree, so this is
16  * a great thing, however this caused some issues when it comes to the
17  * Android KABI preservation and checking tools.
18  *
19  * A number of the io_uring structures get used in other core kernel
20  * structures, only as "opaque" pointers, so there is not any real ABI
21  * breakage.  But, due to the visibility of the structures going away, the
22  * CRC values of many scheduler variables and functions were changed.
23  *
24  * In order to preserve the CRC values, to prevent all device kernels to be
25  * forced to rebuild for no reason whatsoever from a functional point of
26  * view, we need to keep around the "old" io_uring structures for the CRC
27  * calculation only.  This is done by the following definitions of struct
28  * io_identity and struct io_uring_task which will only be visible when the
29  * CRC calculation build happens, not in any functional kernel build.
30  *
31  * Yes, this all is a horrible hack, and these really are not the true
32  * structures that any code uses, but so life is in the world of stable
33  * apis...
34  * The real structures are in io_uring/io_uring.c, see the ones there if
35  * you need to touch or do anything with it.
36  *
37  * NEVER touch these structure definitions, they are fake and not valid code.
38  */
39 struct io_identity {
40 	struct files_struct		*files;
41 	struct mm_struct		*mm;
42 #ifdef CONFIG_BLK_CGROUP
43 	struct cgroup_subsys_state	*blkcg_css;
44 #endif
45 	const struct cred		*creds;
46 	struct nsproxy			*nsproxy;
47 	struct fs_struct		*fs;
48 	unsigned long			fsize;
49 #ifdef CONFIG_AUDIT
50 	kuid_t				loginuid;
51 	unsigned int			sessionid;
52 #endif
53 	refcount_t			count;
54 };
55 
56 struct io_uring_task {
57 	/* submission side */
58 	struct xarray		xa;
59 	struct wait_queue_head	wait;
60 	struct file		*last;
61 	struct percpu_counter	inflight;
62 	struct io_identity	__identity;
63 	struct io_identity	*identity;
64 	atomic_t		in_idle;
65 	bool			sqpoll;
66 };
67 #endif	/* ANDROID ABI HACK */
68 
69 
70 #if defined(CONFIG_IO_URING)
71 struct sock *io_uring_get_socket(struct file *file);
72 void __io_uring_cancel(bool cancel_all);
73 void __io_uring_free(struct task_struct *tsk);
74 
io_uring_files_cancel(void)75 static inline void io_uring_files_cancel(void)
76 {
77 	if (current->io_uring)
78 		__io_uring_cancel(false);
79 }
io_uring_task_cancel(void)80 static inline void io_uring_task_cancel(void)
81 {
82 	if (current->io_uring)
83 		__io_uring_cancel(true);
84 }
io_uring_free(struct task_struct * tsk)85 static inline void io_uring_free(struct task_struct *tsk)
86 {
87 	if (tsk->io_uring)
88 		__io_uring_free(tsk);
89 }
90 #else
io_uring_get_socket(struct file * file)91 static inline struct sock *io_uring_get_socket(struct file *file)
92 {
93 	return NULL;
94 }
io_uring_task_cancel(void)95 static inline void io_uring_task_cancel(void)
96 {
97 }
io_uring_files_cancel(void)98 static inline void io_uring_files_cancel(void)
99 {
100 }
io_uring_free(struct task_struct * tsk)101 static inline void io_uring_free(struct task_struct *tsk)
102 {
103 }
104 #endif
105 
106 #endif
107