.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2017 Google, Inc. |
---|
3 | | - * |
---|
4 | | - * This software is licensed under the terms of the GNU General Public |
---|
5 | | - * License version 2, as published by the Free Software Foundation, and |
---|
6 | | - * may be copied, distributed, and modified under those terms. |
---|
7 | | - * |
---|
8 | | - * This program is distributed in the hope that it will be useful, |
---|
9 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
11 | | - * GNU General Public License for more details. |
---|
12 | | - * |
---|
13 | 4 | */ |
---|
14 | 5 | |
---|
15 | 6 | #ifndef _LINUX_BINDER_ALLOC_H |
---|
.. | .. |
---|
32 | 23 | * @entry: entry alloc->buffers |
---|
33 | 24 | * @rb_node: node for allocated_buffers/free_buffers rb trees |
---|
34 | 25 | * @free: %true if buffer is free |
---|
| 26 | + * @clear_on_free: %true if buffer must be zeroed after use |
---|
35 | 27 | * @allow_user_free: %true if user is allowed to free buffer |
---|
36 | 28 | * @async_transaction: %true if buffer is in use for an async txn |
---|
| 29 | + * @oneway_spam_suspect: %true if total async allocate size just exceed |
---|
| 30 | + * spamming detect threshold |
---|
37 | 31 | * @debug_id: unique ID for debugging |
---|
38 | 32 | * @transaction: pointer to associated struct binder_transaction |
---|
39 | 33 | * @target_node: struct binder_node associated with this buffer |
---|
.. | .. |
---|
50 | 44 | struct rb_node rb_node; /* free entry by size or allocated entry */ |
---|
51 | 45 | /* by address */ |
---|
52 | 46 | unsigned free:1; |
---|
| 47 | + unsigned clear_on_free:1; |
---|
53 | 48 | unsigned allow_user_free:1; |
---|
54 | 49 | unsigned async_transaction:1; |
---|
55 | | - unsigned debug_id:29; |
---|
| 50 | + unsigned oneway_spam_suspect:1; |
---|
| 51 | + unsigned debug_id:27; |
---|
56 | 52 | |
---|
57 | 53 | struct binder_transaction *transaction; |
---|
58 | 54 | |
---|
.. | .. |
---|
94 | 90 | * @buffer_size: size of address space specified via mmap |
---|
95 | 91 | * @pid: pid for associated binder_proc (invariant after init) |
---|
96 | 92 | * @pages_high: high watermark of offset in @pages |
---|
| 93 | + * @oneway_spam_detected: %true if oneway spam detection fired, clear that |
---|
| 94 | + * flag once the async buffer has returned to a healthy state |
---|
97 | 95 | * |
---|
98 | 96 | * Bookkeeping structure for per-proc address space management for binder |
---|
99 | 97 | * buffers. It is normally initialized during binder_init() and binder_mmap() |
---|
.. | .. |
---|
114 | 112 | uint32_t buffer_free; |
---|
115 | 113 | int pid; |
---|
116 | 114 | size_t pages_high; |
---|
| 115 | + bool oneway_spam_detected; |
---|
117 | 116 | }; |
---|
118 | 117 | |
---|
119 | 118 | #ifdef CONFIG_ANDROID_BINDER_IPC_SELFTEST |
---|
.. | .. |
---|
132 | 131 | int pid); |
---|
133 | 132 | extern void binder_alloc_init(struct binder_alloc *alloc); |
---|
134 | 133 | extern int binder_alloc_shrinker_init(void); |
---|
| 134 | +extern void binder_alloc_shrinker_exit(void); |
---|
135 | 135 | extern void binder_alloc_vma_close(struct binder_alloc *alloc); |
---|
136 | 136 | extern struct binder_buffer * |
---|
137 | 137 | binder_alloc_prepare_to_free(struct binder_alloc *alloc, |
---|
.. | .. |
---|
171 | 171 | const void __user *from, |
---|
172 | 172 | size_t bytes); |
---|
173 | 173 | |
---|
174 | | -void binder_alloc_copy_to_buffer(struct binder_alloc *alloc, |
---|
175 | | - struct binder_buffer *buffer, |
---|
176 | | - binder_size_t buffer_offset, |
---|
177 | | - void *src, |
---|
178 | | - size_t bytes); |
---|
| 174 | +int binder_alloc_copy_to_buffer(struct binder_alloc *alloc, |
---|
| 175 | + struct binder_buffer *buffer, |
---|
| 176 | + binder_size_t buffer_offset, |
---|
| 177 | + void *src, |
---|
| 178 | + size_t bytes); |
---|
179 | 179 | |
---|
180 | | -void binder_alloc_copy_from_buffer(struct binder_alloc *alloc, |
---|
181 | | - void *dest, |
---|
182 | | - struct binder_buffer *buffer, |
---|
183 | | - binder_size_t buffer_offset, |
---|
184 | | - size_t bytes); |
---|
| 180 | +int binder_alloc_copy_from_buffer(struct binder_alloc *alloc, |
---|
| 181 | + void *dest, |
---|
| 182 | + struct binder_buffer *buffer, |
---|
| 183 | + binder_size_t buffer_offset, |
---|
| 184 | + size_t bytes); |
---|
185 | 185 | |
---|
186 | 186 | #endif /* _LINUX_BINDER_ALLOC_H */ |
---|
187 | 187 | |
---|