
Changes in 5.10.191
wireguard: allowedips: expand maximum node depth
mmc: moxart: read scr register without changing byte order
ipv6: adjust ndisc_is_useropt() to also return true for PIO
bpf: allow precision tracking for programs with subprogs
bpf: stop setting precise in current state
bpf: aggressively forget precise markings during state checkpointing
selftests/bpf: make test_align selftest more robust
selftests/bpf: Workaround verification failure for fexit_bpf2bpf/func_replace_return_code
selftests/bpf: Fix sk_assign on s390x
dmaengine: pl330: Return DMA_PAUSED when transaction is paused
riscv,mmio: Fix readX()-to-delay() ordering
drm/nouveau/gr: enable memory loads on helper invocation on all channels
drm/shmem-helper: Reset vma->vm_ops before calling dma_buf_mmap()
drm/amd/display: check attr flag before set cursor degamma on DCN3+
hwmon: (pmbus/bel-pfe) Enable PMBUS_SKIP_STATUS_CHECK for pfe1100
radix tree test suite: fix incorrect allocation size for pthreads
x86/pkeys: Revert a5eff72597
("x86/pkeys: Add PKRU value to init_fpstate")
nilfs2: fix use-after-free of nilfs_root in dirtying inodes via iput
io_uring: correct check for O_TMPFILE
iio: cros_ec: Fix the allocation size for cros_ec_command
binder: fix memory leak in binder_init()
usb-storage: alauda: Fix uninit-value in alauda_check_media()
usb: dwc3: Properly handle processing of pending events
usb: common: usb-conn-gpio: Prevent bailing out if initial role is none
x86/srso: Fix build breakage with the LLVM linker
x86/cpu/amd: Enable Zenbleed fix for AMD Custom APU 0405
x86/mm: Fix VDSO and VVAR placement on 5-level paging machines
x86/speculation: Add cpu_show_gds() prototype
x86: Move gds_ucode_mitigated() declaration to header
drm/nouveau/disp: Revert a NULL check inside nouveau_connector_get_modes
selftests/rseq: Fix build with undefined __weak
selftests: forwarding: Add a helper to skip test when using veth pairs
selftests: forwarding: ethtool: Skip when using veth pairs
selftests: forwarding: ethtool_extended_state: Skip when using veth pairs
selftests: forwarding: Skip test when no interfaces are specified
selftests: forwarding: Switch off timeout
selftests: forwarding: tc_flower: Relax success criterion
mISDN: Update parameter type of dsp_cmx_send()
net/packet: annotate data-races around tp->status
tunnels: fix kasan splat when generating ipv4 pmtu error
bonding: Fix incorrect deletion of ETH_P_8021AD protocol vid from slaves
dccp: fix data-race around dp->dccps_mss_cache
drivers: net: prevent tun_build_skb() to exceed the packet size limit
IB/hfi1: Fix possible panic during hotplug remove
wifi: cfg80211: fix sband iftype data lookup for AP_VLAN
net: phy: at803x: remove set/get wol callbacks for AR8032
net: hns3: refactor hclge_mac_link_status_wait for interface reuse
net: hns3: add wait until mac link down
dmaengine: mcf-edma: Fix a potential un-allocated memory access
net/mlx5: Allow 0 for total host VFs
ibmvnic: Enforce stronger sanity checks on login response
ibmvnic: Unmap DMA login rsp buffer on send login fail
ibmvnic: Handle DMA unmapping of login buffs in release functions
btrfs: don't stop integrity writeback too early
btrfs: set cache_block_group_error if we find an error
nvme-tcp: fix potential unbalanced freeze & unfreeze
nvme-rdma: fix potential unbalanced freeze & unfreeze
netfilter: nf_tables: report use refcount overflow
scsi: core: Fix legacy /proc parsing buffer overflow
scsi: storvsc: Fix handling of virtual Fibre Channel timeouts
scsi: 53c700: Check that command slot is not NULL
scsi: snic: Fix possible memory leak if device_add() fails
scsi: core: Fix possible memory leak if device_add() fails
scsi: qedi: Fix firmware halt over suspend and resume
scsi: qedf: Fix firmware halt over suspend and resume
alpha: remove __init annotation from exported page_is_ram()
sch_netem: fix issues in netem_change() vs get_dist_table()
Linux 5.10.191
Change-Id: Ice1868f0a7b328bb0e56985ac0bb5af9434fd073
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
188 lines
6.5 KiB
C
188 lines
6.5 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (C) 2017 Google, Inc.
|
|
*/
|
|
|
|
#ifndef _LINUX_BINDER_ALLOC_H
|
|
#define _LINUX_BINDER_ALLOC_H
|
|
|
|
#include <linux/rbtree.h>
|
|
#include <linux/list.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/rtmutex.h>
|
|
#include <linux/vmalloc.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/list_lru.h>
|
|
#include <uapi/linux/android/binder.h>
|
|
|
|
extern struct list_lru binder_alloc_lru;
|
|
struct binder_transaction;
|
|
|
|
/**
|
|
* struct binder_buffer - buffer used for binder transactions
|
|
* @entry: entry alloc->buffers
|
|
* @rb_node: node for allocated_buffers/free_buffers rb trees
|
|
* @free: %true if buffer is free
|
|
* @clear_on_free: %true if buffer must be zeroed after use
|
|
* @allow_user_free: %true if user is allowed to free buffer
|
|
* @async_transaction: %true if buffer is in use for an async txn
|
|
* @oneway_spam_suspect: %true if total async allocate size just exceed
|
|
* spamming detect threshold
|
|
* @debug_id: unique ID for debugging
|
|
* @transaction: pointer to associated struct binder_transaction
|
|
* @target_node: struct binder_node associated with this buffer
|
|
* @data_size: size of @transaction data
|
|
* @offsets_size: size of array of offsets
|
|
* @extra_buffers_size: size of space for other objects (like sg lists)
|
|
* @user_data: user pointer to base of buffer space
|
|
* @pid: pid to attribute the buffer to (caller)
|
|
*
|
|
* Bookkeeping structure for binder transaction buffers
|
|
*/
|
|
struct binder_buffer {
|
|
struct list_head entry; /* free and allocated entries by address */
|
|
struct rb_node rb_node; /* free entry by size or allocated entry */
|
|
/* by address */
|
|
unsigned free:1;
|
|
unsigned clear_on_free:1;
|
|
unsigned allow_user_free:1;
|
|
unsigned async_transaction:1;
|
|
unsigned oneway_spam_suspect:1;
|
|
unsigned debug_id:27;
|
|
|
|
struct binder_transaction *transaction;
|
|
|
|
struct binder_node *target_node;
|
|
size_t data_size;
|
|
size_t offsets_size;
|
|
size_t extra_buffers_size;
|
|
void __user *user_data;
|
|
int pid;
|
|
};
|
|
|
|
/**
|
|
* struct binder_lru_page - page object used for binder shrinker
|
|
* @page_ptr: pointer to physical page in mmap'd space
|
|
* @lru: entry in binder_alloc_lru
|
|
* @alloc: binder_alloc for a proc
|
|
*/
|
|
struct binder_lru_page {
|
|
struct list_head lru;
|
|
struct page *page_ptr;
|
|
struct binder_alloc *alloc;
|
|
};
|
|
|
|
/**
|
|
* struct binder_alloc - per-binder proc state for binder allocator
|
|
* @vma: vm_area_struct passed to mmap_handler
|
|
* (invarient after mmap)
|
|
* @tsk: tid for task that called init for this proc
|
|
* (invariant after init)
|
|
* @vma_vm_mm: copy of vma->vm_mm (invarient after mmap)
|
|
* @buffer: base of per-proc address space mapped via mmap
|
|
* @buffers: list of all buffers for this proc
|
|
* @free_buffers: rb tree of buffers available for allocation
|
|
* sorted by size
|
|
* @allocated_buffers: rb tree of allocated buffers sorted by address
|
|
* @free_async_space: VA space available for async buffers. This is
|
|
* initialized at mmap time to 1/2 the full VA space
|
|
* @pages: array of binder_lru_page
|
|
* @buffer_size: size of address space specified via mmap
|
|
* @pid: pid for associated binder_proc (invariant after init)
|
|
* @pages_high: high watermark of offset in @pages
|
|
* @oneway_spam_detected: %true if oneway spam detection fired, clear that
|
|
* flag once the async buffer has returned to a healthy state
|
|
*
|
|
* Bookkeeping structure for per-proc address space management for binder
|
|
* buffers. It is normally initialized during binder_init() and binder_mmap()
|
|
* calls. The address space is used for both user-visible buffers and for
|
|
* struct binder_buffer objects used to track the user buffers
|
|
*/
|
|
struct binder_alloc {
|
|
struct mutex mutex;
|
|
struct vm_area_struct *vma;
|
|
struct mm_struct *vma_vm_mm;
|
|
void __user *buffer;
|
|
struct list_head buffers;
|
|
struct rb_root free_buffers;
|
|
struct rb_root allocated_buffers;
|
|
size_t free_async_space;
|
|
struct binder_lru_page *pages;
|
|
size_t buffer_size;
|
|
uint32_t buffer_free;
|
|
int pid;
|
|
size_t pages_high;
|
|
bool oneway_spam_detected;
|
|
};
|
|
|
|
#ifdef CONFIG_ANDROID_BINDER_IPC_SELFTEST
|
|
void binder_selftest_alloc(struct binder_alloc *alloc);
|
|
#else
|
|
static inline void binder_selftest_alloc(struct binder_alloc *alloc) {}
|
|
#endif
|
|
enum lru_status binder_alloc_free_page(struct list_head *item,
|
|
struct list_lru_one *lru,
|
|
spinlock_t *lock, void *cb_arg);
|
|
extern struct binder_buffer *binder_alloc_new_buf(struct binder_alloc *alloc,
|
|
size_t data_size,
|
|
size_t offsets_size,
|
|
size_t extra_buffers_size,
|
|
int is_async,
|
|
int pid);
|
|
extern void binder_alloc_init(struct binder_alloc *alloc);
|
|
extern int binder_alloc_shrinker_init(void);
|
|
extern void binder_alloc_shrinker_exit(void);
|
|
extern void binder_alloc_vma_close(struct binder_alloc *alloc);
|
|
extern struct binder_buffer *
|
|
binder_alloc_prepare_to_free(struct binder_alloc *alloc,
|
|
uintptr_t user_ptr);
|
|
extern void binder_alloc_free_buf(struct binder_alloc *alloc,
|
|
struct binder_buffer *buffer);
|
|
extern int binder_alloc_mmap_handler(struct binder_alloc *alloc,
|
|
struct vm_area_struct *vma);
|
|
extern void binder_alloc_deferred_release(struct binder_alloc *alloc);
|
|
extern int binder_alloc_get_allocated_count(struct binder_alloc *alloc);
|
|
extern void binder_alloc_print_allocated(struct seq_file *m,
|
|
struct binder_alloc *alloc);
|
|
void binder_alloc_print_pages(struct seq_file *m,
|
|
struct binder_alloc *alloc);
|
|
|
|
/**
|
|
* binder_alloc_get_free_async_space() - get free space available for async
|
|
* @alloc: binder_alloc for this proc
|
|
*
|
|
* Return: the bytes remaining in the address-space for async transactions
|
|
*/
|
|
static inline size_t
|
|
binder_alloc_get_free_async_space(struct binder_alloc *alloc)
|
|
{
|
|
size_t free_async_space;
|
|
|
|
mutex_lock(&alloc->mutex);
|
|
free_async_space = alloc->free_async_space;
|
|
mutex_unlock(&alloc->mutex);
|
|
return free_async_space;
|
|
}
|
|
|
|
unsigned long
|
|
binder_alloc_copy_user_to_buffer(struct binder_alloc *alloc,
|
|
struct binder_buffer *buffer,
|
|
binder_size_t buffer_offset,
|
|
const void __user *from,
|
|
size_t bytes);
|
|
|
|
int binder_alloc_copy_to_buffer(struct binder_alloc *alloc,
|
|
struct binder_buffer *buffer,
|
|
binder_size_t buffer_offset,
|
|
void *src,
|
|
size_t bytes);
|
|
|
|
int binder_alloc_copy_from_buffer(struct binder_alloc *alloc,
|
|
void *dest,
|
|
struct binder_buffer *buffer,
|
|
binder_size_t buffer_offset,
|
|
size_t bytes);
|
|
|
|
#endif /* _LINUX_BINDER_ALLOC_H */
|
|
|