Merge "Merge android11-5.4.61+ (dc2d5a0) into msm-5.4"

This commit is contained in:
qctecmdr 2020-11-16 19:15:08 -08:00 • committed by Gerrit - the friendly Code Review server
commit 8b249d7cb9
45 changed files with 10476 additions and 9846 deletions

View file

@ -1 +1 @@
LTS_5.4.61_874de1d962e8
LTS_5.4.61_dc2d5a0ace05

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -38,6 +38,7 @@
__cpuhp_setup_state
__cpuhp_setup_state_cpuslocked
__dev_kfree_skb_any
__dev_kfree_skb_irq
__devm_iio_device_register
__devm_irq_alloc_descs
__devm_of_phy_provider_register
@ -70,6 +71,7 @@
__ioread32_copy
__ioremap
__iowrite32_copy
__ipv6_addr_type
__irq_alloc_descs
__irq_domain_add
__irq_set_handler
@ -115,6 +117,7 @@
__pm_runtime_suspend
__pm_runtime_use_autosuspend
__pm_stay_awake
__printk_ratelimit
__pskb_pull_tail
__put_cred
__put_page
@ -136,6 +139,7 @@
__sdhci_add_host
__sg_page_iter_next
__sg_page_iter_start
__skb_get_hash
__skb_pad
__spi_alloc_controller
__spi_register_driver
@ -149,13 +153,17 @@
__tasklet_hi_schedule
__tasklet_schedule
__trace_bprintk
__trace_puts
__tracepoint_android_vh_ipi_stop
__tracepoint_android_vh_is_fpsimd_save
__tracepoint_android_vh_kfree_skb
__tracepoint_android_vh_ptype_head
__tracepoint_device_pm_callback_end
__tracepoint_device_pm_callback_start
__tracepoint_gpu_mem_total
__tracepoint_pelt_cfs_tp
__tracepoint_suspend_resume
__tty_alloc_driver
__tty_insert_flip_char
__udelay
__uio_register_device
@ -253,6 +261,7 @@
bitmap_zalloc
blk_execute_rq_nowait
blk_get_request
blk_lookup_devt
blk_mq_rq_cpu
blk_put_request
blk_queue_bounce_limit
@ -262,6 +271,7 @@
blk_rq_map_user_iov
blk_rq_unmap_user
blk_verify_command
blkdev_get_by_dev
blkdev_get_by_path
blkdev_put
blocking_notifier_call_chain
@ -289,10 +299,12 @@
bus_unregister
bus_unregister_notifier
cache_line_size
call_rcu
cancel_delayed_work
cancel_delayed_work_sync
cancel_work_sync
capable
cdc_parse_cdc_header
cdev_add
cdev_alloc
cdev_del
@ -428,6 +440,7 @@
cpufreq_register_notifier
cpufreq_table_index_unsorted
cpufreq_unregister_driver
cpufreq_unregister_notifier
cpuhp_tasks_frozen
cpuidle_pause_and_lock
cpuidle_resume_and_unlock
@ -435,6 +448,7 @@
cpumask_next_and
cpus_read_lock
cpus_read_unlock
crc16
crc32_le
crc8
crc8_populate_msb
@ -444,10 +458,12 @@
crypto_register_rngs
crypto_shash_digest
crypto_unregister_rngs
csum_partial
d_add
d_drop
d_instantiate
d_make_root
d_path
dapm_pinctrl_event
dapm_regulator_event
datagram_poll
@ -702,6 +718,7 @@
downgrade_write
dput
drain_workqueue
driver_attach
driver_find
driver_find_device
driver_register
@ -935,7 +952,9 @@
eth_type_trans
eth_validate_addr
ether_setup
ethtool_convert_legacy_u32_to_link_mode
ethtool_op_get_link
ethtool_op_get_ts_info
event_triggers_call
extcon_find_edev_by_node
extcon_get_edev_by_phandle
@ -949,6 +968,8 @@
fb_mode_option
fd_install
fget
filp_close
filp_open
find_get_pid
find_last_bit
find_next_bit
@ -972,6 +993,7 @@
free_pages_exact
free_percpu
free_percpu_irq
free_reserved_area
freezing_slow_path
freq_qos_add_request
freq_qos_remove_request
@ -1000,6 +1022,7 @@
generic_file_read_iter
generic_file_splice_read
generic_handle_irq
generic_mii_ioctl
generic_read_dir
generic_shutdown_super
genl_register_family
@ -1013,6 +1036,8 @@
get_pid_task
get_random_bytes
get_random_u32
get_task_exe_file
get_task_mm
get_task_pid
get_thermal_instance
get_unmapped_area
@ -1145,6 +1170,9 @@
idr_preload
idr_remove
idr_replace
ieee80211_channel_to_freq_khz
ieee80211_freq_khz_to_channel
ieee80211_get_channel_khz
iget5_locked
ignore_console_lock_warning
ihold
@ -1161,6 +1189,7 @@
import_iovec
in_aton
in_egroup_p
in6_pton
init_dummy_netdev
init_net
init_task
@ -1243,6 +1272,7 @@
ion_query_heaps_kernel
iounmap
iput
ipv6_stub
irq_chip_ack_parent
irq_chip_disable_parent
irq_chip_enable_parent
@ -1297,6 +1327,7 @@
jiffies_64_to_clock_t
jiffies_to_msecs
jiffies_to_usecs
jiffies64_to_msecs
kasprintf
kern_path
kernel_bind
@ -1344,6 +1375,7 @@
kset_unregister
kstat
kstrdup
kstrdup_quotable
kstrndup
kstrtobool
kstrtobool_from_user
@ -1428,6 +1460,7 @@
media_entity_pads_init
media_entity_remove_links
media_remove_intf_links
memblock_free
memchr
memcmp
memcpy
@ -1441,6 +1474,9 @@
memweight
mfd_add_devices
mfd_remove_devices
mii_check_media
mii_ethtool_gset
mii_nway_restart
mipi_dsi_create_packet
mipi_dsi_dcs_set_display_brightness
mipi_dsi_dcs_set_tear_off
@ -1464,6 +1500,7 @@
mmc_request_done
mmc_send_tuning
mmc_wait_for_req
mmput
mod_delayed_work_on
mod_node_page_state
mod_timer
@ -1482,7 +1519,11 @@
napi_gro_flush
napi_gro_receive
napi_schedule_prep
netdev_err
netdev_info
netdev_state_change
netdev_update_features
netdev_warn
netif_carrier_off
netif_carrier_on
netif_device_attach
@ -1490,8 +1531,10 @@
netif_napi_add
netif_napi_del
netif_receive_skb
netif_receive_skb_list
netif_rx
netif_rx_ni
netif_schedule_queue
netif_tx_wake_queue
netlink_broadcast
netlink_kernel_release
@ -1558,6 +1601,7 @@
of_get_child_by_name
of_get_cpu_node
of_get_dma_window
of_get_mac_address
of_get_named_gpio_flags
of_get_next_available_child
of_get_next_child
@ -1625,6 +1669,7 @@
panic_timeout
param_array_ops
param_get_int
param_get_uint
param_ops_bool
param_ops_byte
param_ops_charp
@ -1780,8 +1825,12 @@
proc_symlink
proto_register
proto_unregister
pskb_expand_head
public_key_verify_signature
put_device
put_disk
put_pid
put_tty_driver
put_unused_fd
pwm_apply_state
pwm_get_chip_data
@ -1937,13 +1986,17 @@
rtnl_is_locked
rtnl_lock
rtnl_unlock
rt_mutex_lock
rt_mutex_unlock
save_stack_trace
save_stack_trace_tsk
sched_clock
sched_setscheduler
sched_setscheduler_nocheck
sched_show_task
schedule
schedule_timeout
schedule_timeout_interruptible
schedule_timeout_uninterruptible
scmd_printk
scnprintf
@ -1997,6 +2050,7 @@
seq_putc
seq_puts
seq_read
seq_release
set_anon_super
set_cpus_allowed_ptr
set_normalized_timespec64
@ -2202,6 +2256,7 @@
sock_release
sock_unregister
sock_wfree
softnet_data
sort
spi_bus_type
spi_controller_resume
@ -2293,6 +2348,12 @@
system_wq
tasklet_init
tasklet_kill
tcp_register_congestion_control
tcp_reno_cong_avoid
tcp_reno_ssthresh
tcp_reno_undo_cwnd
tcp_slow_start
tcp_unregister_congestion_control
thermal_cdev_update
thermal_cooling_device_unregister
thermal_of_cooling_device_register
@ -2321,10 +2382,33 @@
truncate_inode_pages
try_module_get
try_wait_for_completion
tty_encode_baud_rate
tty_flip_buffer_push
tty_hangup
tty_insert_flip_string_fixed_flag
tty_kref_put
tty_ldisc_deref
tty_ldisc_ref
tty_port_close
tty_port_destroy
tty_port_hangup
tty_port_init
tty_port_open
tty_port_put
tty_port_register_device
tty_port_tty_get
tty_port_tty_hangup
tty_port_tty_wakeup
tty_register_driver
tty_set_operations
tty_standard_install
tty_std_termios
tty_termios_baud_rate
tty_termios_copy_hw
tty_termios_hw_change
tty_unregister_device
tty_unregister_driver
tty_vhangup
typec_altmode_get_partner
typec_altmode_update_active
typec_get_drvdata
@ -2408,6 +2492,7 @@
usb_alloc_dev
usb_alloc_streams
usb_alloc_urb
usb_altnum_to_altsetting
usb_amd_dev_put
usb_amd_pt_check_port
usb_amd_quirk_pll_check
@ -2417,8 +2502,10 @@
usb_asmedia_modifyflowcontrol
usb_assign_descriptors
usb_autopm_get_interface
usb_autopm_get_interface_async
usb_autopm_get_interface_no_resume
usb_autopm_put_interface
usb_autopm_put_interface_async
usb_autopm_put_interface_no_suspend
usb_bulk_msg
usb_choose_configuration
@ -2469,6 +2556,7 @@
usb_get_current_frame_number
usb_get_dev
usb_get_dr_mode
usb_get_from_anchor
usb_get_intf
usb_get_maximum_speed
usb_get_urb
@ -2497,6 +2585,7 @@
usb_kill_anchored_urbs
usb_kill_urb
usb_lock_device_for_reset
usb_match_id
usb_match_one_id
usb_os_desc_prepare_interf_dir
usb_otg_state_string
@ -2522,15 +2611,51 @@
usb_sg_cancel
usb_sg_init
usb_sg_wait
usb_show_dynids
usb_speed_string
usb_store_new_id
usb_string
usb_string_id
usb_submit_urb
usb_unanchor_urb
usb_unlink_urb
usb_unpoison_urb
usb_unregister_notify
usb_wait_anchor_empty_timeout
usb_wakeup_notification
usbnet_cdc_unbind
usbnet_change_mtu
usbnet_defer_kevent
usbnet_device_suggests_idle
usbnet_disconnect
usbnet_generic_cdc_bind
usbnet_get_drvinfo
usbnet_get_endpoints
usbnet_get_ethernet_addr
usbnet_get_link
usbnet_get_link_ksettings
usbnet_get_msglevel
usbnet_get_stats64
usbnet_link_change
usbnet_manage_power
usbnet_nway_reset
usbnet_open
usbnet_probe
usbnet_read_cmd
usbnet_read_cmd_nopm
usbnet_resume
usbnet_set_link_ksettings
usbnet_set_msglevel
usbnet_skb_return
usbnet_start_xmit
usbnet_stop
usbnet_suspend
usbnet_tx_timeout
usbnet_unlink_rx_urbs
usbnet_update_max_qlen
usbnet_write_cmd
usbnet_write_cmd_async
usbnet_write_cmd_nopm
user_path_at_empty
usleep_range
v4l_bound_align_image
@ -2668,6 +2793,7 @@
wake_up_process
wakeup_source_add
wakeup_source_register
wakeup_source_remove
wakeup_source_unregister
watchdog_init_timeout
watchdog_register_device

View file

@ -1197,6 +1197,8 @@
irq_set_chained_handler_and_data
irq_set_chip_and_handler_name
irq_set_chip_data
__irq_set_handler
irq_set_handler_data
irq_set_irqchip_state
irq_set_irq_type
irq_set_irq_wake
@ -1225,6 +1227,9 @@
kern_path
keyslot_manager_create
keyslot_manager_private
keyslot_manager_set_max_dun_bytes
keyslot_manager_reprogram_all_keys
keyslot_manager_destroy
__kfifo_in
__kfifo_out
kfree
@ -1522,6 +1527,7 @@
of_get_named_gpio_flags
of_get_next_available_child
of_get_next_child
of_get_next_parent
of_get_parent
of_get_property
of_get_regulator_init_data
@ -1728,6 +1734,7 @@
__pm_relax
pm_relax
pm_runtime_allow
pm_runtime_autosuspend_expiration
pm_runtime_barrier
__pm_runtime_disable
pm_runtime_enable

View file

@ -129,6 +129,7 @@
__class_create
class_destroy
class_find_device
class_for_each_device
class_interface_unregister
__class_register
class_unregister
@ -287,6 +288,7 @@
device_register
device_remove_bin_file
device_remove_file
device_set_of_node_from_dev
device_set_wakeup_capable
device_set_wakeup_enable
device_show_int
@ -329,6 +331,7 @@
devm_kmemdup
devm_kstrdup
devm_led_classdev_register_ext
devm_led_classdev_unregister
devm_nvmem_cell_get
devm_nvmem_device_get
devm_nvmem_register
@ -1417,6 +1420,7 @@
pinconf_generic_dt_node_to_map
pinctrl_dev_get_drvdata
pinctrl_get
pinctrl_gpio_free
pinctrl_lookup_state
pinctrl_pm_select_default_state
pinctrl_pm_select_sleep_state
@ -1770,6 +1774,8 @@
sg_pcopy_from_buffer
sg_pcopy_to_buffer
sg_scsi_ioctl
sha_init
sha_transform
shmem_truncate_range
sigprocmask
simple_read_from_buffer
@ -2016,6 +2022,7 @@
typec_altmode_update_active
typec_get_drvdata
typec_partner_register_altmode
typec_partner_set_identity
typec_port_register_altmode
typec_register_partner
typec_register_port

View file

@ -562,6 +562,7 @@ CONFIG_DMA_CMA=y
CONFIG_PRINTK_TIME=y
CONFIG_DYNAMIC_DEBUG_CORE=y
CONFIG_DEBUG_INFO=y
CONFIG_DEBUG_INFO_DWARF4=y
# CONFIG_ENABLE_MUST_CHECK is not set
# CONFIG_SECTION_MISMATCH_WARN_ONLY is not set
CONFIG_MAGIC_SYSRQ=y

View file

@ -932,7 +932,7 @@ void handle_IPI(int ipinr, struct pt_regs *regs)
break;
case IPI_CPU_STOP:
trace_android_vh_ipi_stop(regs);
trace_android_vh_ipi_stop_rcuidle(regs);
irq_enter();
local_cpu_stop();
irq_exit();

View file

@ -491,6 +491,7 @@ CONFIG_XZ_DEC=y
CONFIG_DMA_CMA=y
CONFIG_PRINTK_TIME=y
CONFIG_DEBUG_INFO=y
CONFIG_DEBUG_INFO_DWARF4=y
# CONFIG_ENABLE_MUST_CHECK is not set
# CONFIG_SECTION_MISMATCH_WARN_ONLY is not set
CONFIG_MAGIC_SYSRQ=y

View file

@ -1,5 +1,5 @@
BRANCH=android11-5.4
KMI_GENERATION=1
KMI_GENERATION=2
CC=clang
LD=ld.lld

View file

@ -47,6 +47,10 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_write_wait_finish);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sched_show_task);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ptype_head);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_kfree_skb);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_sk_alloc);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_sk_free);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_nf_conn_alloc);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_nf_conn_free);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_arch_set_freq_scale);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_transaction_init);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_set_priority);
@ -62,4 +66,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_printk_store);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_show_regs);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_wq_lockup_pool);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sysrq_crash);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_find_busiest_group);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_find_busiest_group);

View file

@ -60,7 +60,7 @@ static DEFINE_MUTEX(misc_mtx);
/*
* Assigned numbers, used for dynamic minors
*/
#define DYNAMIC_MINORS 64 /* like dynamic majors */
#define DYNAMIC_MINORS 128 /* like dynamic majors */
static DECLARE_BITMAP(misc_minors, DYNAMIC_MINORS);
#ifdef CONFIG_PROC_FS

View file

@ -11,6 +11,7 @@
#ifndef _FSCRYPT_PRIVATE_H
#define _FSCRYPT_PRIVATE_H
#define FSCRYPT_NEED_OPS
#include <linux/fscrypt.h>
#include <linux/siphash.h>
#include <crypto/hash.h>

View file

@ -40,6 +40,7 @@
#include <linux/compat.h>
#endif
#define FSCRYPT_NEED_OPS
#include <linux/fscrypt.h>
#include <linux/fsverity.h>

View file

@ -24,6 +24,7 @@
#include <linux/quotaops.h>
#include <crypto/hash.h>
#define FSCRYPT_NEED_OPS
#include <linux/fscrypt.h>
#include <linux/fsverity.h>

View file

@ -14,6 +14,7 @@
#include <linux/sched/signal.h>
#include <linux/uio.h>
#include <linux/miscdevice.h>
#include <linux/namei.h>
#include <linux/pagemap.h>
#include <linux/file.h>
#include <linux/slab.h>
@ -1899,6 +1900,12 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud,
err = copy_out_args(cs, req->args, nbytes);
fuse_copy_finish(cs);
if (!err && req->in.h.opcode == FUSE_CANONICAL_PATH) {
char *path = (char *)req->args->out_args[0].value;
path[req->args->out_args[0].size - 1] = 0;
req->out.h.error = kern_path(path, 0, req->args->canonical_path);
}
spin_lock(&fpq->lock);
clear_bit(FR_LOCKED, &req->flags);
if (!fpq->connected)

View file

@ -298,6 +298,42 @@ static int fuse_dentry_delete(const struct dentry *dentry)
return time_before64(fuse_dentry_time(dentry), get_jiffies_64());
}
/*
* Get the canonical path. Since we must translate to a path, this must be done
* in the context of the userspace daemon, however, the userspace daemon cannot
* look up paths on its own. Instead, we handle the lookup as a special case
* inside of the write request.
*/
static void fuse_dentry_canonical_path(const struct path *path, struct path *canonical_path) {
struct inode *inode = d_inode(path->dentry);
struct fuse_conn *fc = get_fuse_conn(inode);
FUSE_ARGS(args);
char *path_name;
int err;
path_name = (char*)__get_free_page(GFP_KERNEL);
if (!path_name)
goto default_path;
args.opcode = FUSE_CANONICAL_PATH;
args.nodeid = get_node_id(inode);
args.in_numargs = 0;
args.out_numargs = 1;
args.out_args[0].size = PATH_MAX;
args.out_args[0].value = path_name;
args.canonical_path = canonical_path;
args.out_argvar = 1;
err = fuse_simple_request(fc, &args);
free_page((unsigned long)path_name);
if (err > 0)
return;
default_path:
canonical_path->dentry = path->dentry;
canonical_path->mnt = path->mnt;
path_get(canonical_path);
}
const struct dentry_operations fuse_dentry_operations = {
.d_revalidate = fuse_dentry_revalidate,
.d_delete = fuse_dentry_delete,
@ -305,6 +341,7 @@ const struct dentry_operations fuse_dentry_operations = {
.d_init = fuse_dentry_init,
.d_release = fuse_dentry_release,
#endif
.d_canonical_path = fuse_dentry_canonical_path,
};
const struct dentry_operations fuse_root_dentry_operations = {

View file

@ -253,6 +253,9 @@ struct fuse_args {
struct fuse_in_arg in_args[3];
struct fuse_arg out_args[2];
void (*end)(struct fuse_conn *fc, struct fuse_args *args, int error);
/* Path used for completing d_canonical_path */
struct path *canonical_path;
};
struct fuse_args_pages {

View file

@ -701,6 +701,8 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname,
struct fsnotify_group *group;
struct inode *inode;
struct path path;
struct path alteredpath;
struct path *canonical_path = &path;
struct fd f;
int ret;
unsigned flags = 0;
@ -747,13 +749,23 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname,
if (ret)
goto fput_and_out;
/* support stacked filesystems */
if (path.dentry && path.dentry->d_op) {
if (path.dentry->d_op->d_canonical_path) {
path.dentry->d_op->d_canonical_path(&path,
&alteredpath);
canonical_path = &alteredpath;
path_put(&path);
}
}
/* inode held in place by reference to path; group by fget on fd */
inode = path.dentry->d_inode;
inode = canonical_path->dentry->d_inode;
group = f.file->private_data;
/* create/update an inode mark */
ret = inotify_update_watch(group, inode, mask);
path_put(&path);
path_put(canonical_path);
fput_and_out:
fdput(f);
return ret;

View file

@ -31,6 +31,7 @@
#include <crypto/hash.h>
#include <crypto/algapi.h>
#define FSCRYPT_NEED_OPS
#include <linux/fscrypt.h>
#include "ubifs-media.h"

View file

@ -151,6 +151,7 @@ struct dentry_operations {
struct vfsmount *(*d_automount)(struct path *);
int (*d_manage)(const struct path *, bool);
struct dentry *(*d_real)(struct dentry *, const struct inode *);
void (*d_canonical_path)(const struct path *, struct path *);
ANDROID_KABI_RESERVE(1);
ANDROID_KABI_RESERVE(2);

View file

@ -53,6 +53,7 @@ struct fscrypt_name {
*/
#define FS_CFLG_OWN_PAGES (1U << 1)
#ifdef FSCRYPT_NEED_OPS
/*
* crypto operations for filesystems
*/
@ -74,6 +75,7 @@ struct fscrypt_operations {
void (*get_devices)(struct super_block *sb,
struct request_queue **devs);
};
#endif
static inline bool fscrypt_has_encryption_key(const struct inode *inode)
{
@ -97,6 +99,7 @@ static inline bool fscrypt_needs_contents_encryption(const struct inode *inode)
return IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode);
}
#ifdef FSCRYPT_NEED_OPS
static inline const union fscrypt_context *
fscrypt_get_dummy_context(struct super_block *sb)
{
@ -104,6 +107,7 @@ fscrypt_get_dummy_context(struct super_block *sb)
return NULL;
return sb->s_cop->get_dummy_context(sb);
}
#endif
/*
* When d_splice_alias() moves a directory's encrypted alias to its decrypted
@ -801,6 +805,7 @@ static inline int fscrypt_prepare_setattr(struct dentry *dentry,
* -ENOKEY if the encryption key is missing, or another -errno code if a problem
* occurred while setting up the encryption key.
*/
#ifdef FSCRYPT_NEED_OPS
static inline int fscrypt_prepare_symlink(struct inode *dir,
const char *target,
unsigned int len,
@ -816,6 +821,7 @@ static inline int fscrypt_prepare_symlink(struct inode *dir,
return -ENAMETOOLONG;
return 0;
}
#endif
/**
* fscrypt_encrypt_symlink() - encrypt the symlink target if needed

View file

@ -262,6 +262,7 @@ static inline void fsnotify_modify(struct file *file)
static inline void fsnotify_open(struct file *file)
{
const struct path *path = &file->f_path;
struct path lower_path;
struct inode *inode = file_inode(file);
__u32 mask = FS_OPEN;
@ -270,6 +271,12 @@ static inline void fsnotify_open(struct file *file)
if (file->f_flags & __FMODE_EXEC)
mask |= FS_OPEN_EXEC;
if (path->dentry->d_op && path->dentry->d_op->d_canonical_path) {
path->dentry->d_op->d_canonical_path(path, &lower_path);
fsnotify_parent(&lower_path, NULL, mask);
fsnotify(lower_path.dentry->d_inode, mask, &lower_path, FSNOTIFY_EVENT_PATH, NULL, 0);
path_put(&lower_path);
}
fsnotify_path(inode, path, mask);
}

View file

@ -318,7 +318,7 @@ struct pcmcia_device_id {
#define INPUT_DEVICE_ID_LED_MAX 0x0f
#define INPUT_DEVICE_ID_SND_MAX 0x07
#define INPUT_DEVICE_ID_FF_MAX 0x7f
#define INPUT_DEVICE_ID_SW_MAX 0x10
#define INPUT_DEVICE_ID_SW_MAX 0x3f
#define INPUT_DEVICE_ID_PROP_MAX 0x1f
#define INPUT_DEVICE_ID_MATCH_BUS 1

View file

@ -346,11 +346,6 @@ struct klp_modinfo {
};
#endif
struct module_kabi_preserve_1 {
u64 using_gplonly_symbols:1;
u64 free:63;
};
struct module {
enum module_state state;
@ -387,6 +382,7 @@ struct module {
unsigned int num_gpl_syms;
const struct kernel_symbol *gpl_syms;
const s32 *gpl_crcs;
bool using_gplonly_symbols;
#ifdef CONFIG_UNUSED_SYMBOLS
/* unused exported symbols. */
@ -520,7 +516,7 @@ struct module {
struct error_injection_entry *ei_funcs;
unsigned int num_ei_funcs;
#endif
ANDROID_KABI_USE(1, struct module_kabi_preserve_1 m1);
ANDROID_KABI_RESERVE(1);
ANDROID_KABI_RESERVE(2);
ANDROID_KABI_RESERVE(3);
ANDROID_KABI_RESERVE(4);

View file

@ -41,6 +41,7 @@
#include <linux/netfilter/nf_conntrack_common.h>
#endif
#include <linux/android_kabi.h>
#include <linux/android_vendor.h>
/* The interface for checksum offload between the stack and networking drivers
* is as follows...
@ -530,6 +531,8 @@ struct skb_shared_info {
* remains valid until skb destructor */
void * destructor_arg;
ANDROID_VENDOR_DATA_ARRAY(1, 3);
/* must be last field, see pskb_expand_head() */
skb_frag_t frags[MAX_SKB_FRAGS];
};

View file

@ -15,6 +15,8 @@
#include <linux/bitops.h>
#include <linux/compiler.h>
#include <linux/android_kabi.h>
#include <linux/android_vendor.h>
#include <linux/netfilter/nf_conntrack_common.h>
#include <linux/netfilter/nf_conntrack_tcp.h>
@ -114,6 +116,11 @@ struct nf_conn {
/* Storage reserved for other modules, must be the last member */
union nf_conntrack_proto proto;
ANDROID_KABI_RESERVE(1);
ANDROID_KABI_RESERVE(2);
ANDROID_VENDOR_DATA(1);
};
static inline struct nf_conn *

View file

@ -69,6 +69,7 @@
#include <net/smc.h>
#include <net/l3mdev.h>
#include <linux/android_kabi.h>
#include <linux/android_vendor.h>
/*
* This structure really needs to be cleaned up.
@ -521,6 +522,8 @@ struct sock {
ANDROID_KABI_RESERVE(6);
ANDROID_KABI_RESERVE(7);
ANDROID_KABI_RESERVE(8);
ANDROID_VENDOR_DATA(1);
};
enum sk_pacing {

View file

@ -1999,4 +1999,38 @@ static inline int xfrm_tunnel_check(struct sk_buff *skb, struct xfrm_state *x,
return 0;
}
extern const int xfrm_msg_min[XFRM_NR_MSGTYPES];
extern const struct nla_policy xfrma_policy[XFRMA_MAX+1];
struct xfrm_translator {
/* Allocate frag_list and put compat translation there */
int (*alloc_compat)(struct sk_buff *skb, const struct nlmsghdr *src);
/* Allocate nlmsg with 64-bit translaton of received 32-bit message */
struct nlmsghdr *(*rcv_msg_compat)(const struct nlmsghdr *nlh,
int maxtype, const struct nla_policy *policy,
struct netlink_ext_ack *extack);
/* Translate 32-bit user_policy from sockptr */
int (*xlate_user_policy_sockptr)(u8 **pdata32, int optlen);
struct module *owner;
};
#if IS_ENABLED(CONFIG_XFRM_USER_COMPAT)
extern int xfrm_register_translator(struct xfrm_translator *xtr);
extern int xfrm_unregister_translator(struct xfrm_translator *xtr);
extern struct xfrm_translator *xfrm_get_translator(void);
extern void xfrm_put_translator(struct xfrm_translator *xtr);
#else
static inline struct xfrm_translator *xfrm_get_translator(void)
{
return NULL;
}
static inline void xfrm_put_translator(struct xfrm_translator *xtr)
{
}
#endif
#endif /* _NET_XFRM_H */

View file

@ -21,6 +21,7 @@ DECLARE_HOOK(android_vh_printk_store,
TP_ARGS(facility, level))
#else
#define trace_android_vh_ipi_stop(regs)
#define trace_android_vh_ipi_stop_rcuidle(regs)
#define trace_android_vh_printk_store(facility, level)
#endif

View file

@ -13,14 +13,29 @@
struct packet_type;
struct list_head;
struct sk_buff;
struct sock;
struct nf_conn;
DECLARE_HOOK(android_vh_ptype_head,
TP_PROTO(const struct packet_type *pt, struct list_head *vendor_pt),
TP_ARGS(pt, vendor_pt));
DECLARE_HOOK(android_vh_kfree_skb,
TP_PROTO(struct sk_buff *skb), TP_ARGS(skb));
DECLARE_RESTRICTED_HOOK(android_rvh_sk_alloc,
TP_PROTO(struct sock *sock), TP_ARGS(sock), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_sk_free,
TP_PROTO(struct sock *sock), TP_ARGS(sock), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_nf_conn_alloc,
TP_PROTO(struct nf_conn *nf_conn), TP_ARGS(nf_conn), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_nf_conn_free,
TP_PROTO(struct nf_conn *nf_conn), TP_ARGS(nf_conn), 1);
#else
#define trace_android_vh_ptype_head(pt, vendor_pt)
#define trace_android_vh_kfree_skb(skb)
#define trace_android_rvh_sk_alloc(sock)
#define trace_android_rvh_sk_free(sock)
#define trace_android_rvh_nf_conn_alloc(nf_conn)
#define trace_android_rvh_nf_conn_free(nf_conn)
#endif
#endif /* _TRACE_HOOK_NET_VH_H */
/* This part must be outside protection */

View file

@ -465,6 +465,7 @@ enum fuse_opcode {
FUSE_COPY_FILE_RANGE = 47,
FUSE_SETUPMAPPING = 48,
FUSE_REMOVEMAPPING = 49,
FUSE_CANONICAL_PATH = 2016,
/* CUSE specific operations */
CUSE_INIT = 4096,

View file

@ -809,7 +809,7 @@
#define SW_MUTE_DEVICE 0x0e /* set = device disabled */
#define SW_PEN_INSERTED 0x0f /* set = pen inserted */
#define SW_MACHINE_COVER 0x10 /* set = cover closed */
#define SW_MAX 0x10
#define SW_MAX 0x3f
#define SW_CNT (SW_MAX+1)
/*

View file

@ -6,6 +6,7 @@
*/
#include <linux/gfp.h>
#include <linux/hardirq.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/printk.h>
@ -246,33 +247,36 @@ static inline cfi_check_fn ptr_to_check_fn(const struct cfi_shadow __rcu *s,
static inline cfi_check_fn find_module_cfi_check(void *ptr)
{
cfi_check_fn f = CFI_CHECK_FN;
struct module *mod;
preempt_disable();
mod = __module_address((unsigned long)ptr);
if (mod)
f = mod->cfi_check;
preempt_enable();
if (mod)
return mod->cfi_check;
return CFI_CHECK_FN;
return f;
}
static inline cfi_check_fn find_cfi_check(void *ptr)
{
#ifdef CONFIG_CFI_CLANG_SHADOW
bool rcu;
cfi_check_fn f;
if (!rcu_access_pointer(cfi_shadow))
return CFI_CHECK_FN; /* No loaded modules */
rcu = rcu_is_watching();
if (!rcu)
rcu_nmi_enter();
#ifdef CONFIG_CFI_CLANG_SHADOW
/* Look up the __cfi_check function to use */
rcu_read_lock();
f = ptr_to_check_fn(rcu_dereference(cfi_shadow), (unsigned long)ptr);
rcu_read_unlock();
rcu_read_lock_sched();
f = ptr_to_check_fn(rcu_dereference_sched(cfi_shadow),
(unsigned long)ptr);
rcu_read_unlock_sched();
if (f)
return f;
goto out;
/*
* Fall back to find_module_cfi_check, which works also for a larger
@ -280,7 +284,13 @@ static inline cfi_check_fn find_cfi_check(void *ptr)
*/
#endif /* CONFIG_CFI_CLANG_SHADOW */
return find_module_cfi_check(ptr);
f = find_module_cfi_check(ptr);
out:
if (!rcu)
rcu_nmi_exit();
return f;
}
void cfi_slowpath_handler(uint64_t id, void *ptr, void *diag)

View file

@ -1432,7 +1432,7 @@ static bool inherit_taint(struct module *mod, struct module *owner)
if (!owner || !test_bit(TAINT_PROPRIETARY_MODULE, &owner->taints))
return true;
if (mod->m1.using_gplonly_symbols) {
if (mod->using_gplonly_symbols) {
pr_err("%s: module using GPL-only symbols uses symbols from proprietary module %s.\n",
mod->name, owner->name);
return false;
@ -1471,7 +1471,7 @@ static const struct kernel_symbol *resolve_symbol(struct module *mod,
goto unlock;
if (license == GPL_ONLY)
mod->m1.using_gplonly_symbols = true;
mod->using_gplonly_symbols = true;
if (!inherit_taint(mod, owner)) {
sym = NULL;
@ -4006,6 +4006,8 @@ static int load_module(struct load_info *info, const char __user *uargs,
mutex_unlock(&module_mutex);
ddebug_cleanup:
/* Clean up CFI for the module. */
cfi_cleanup(mod);
ftrace_release_mod(mod);
dynamic_debug_remove(mod, info->debug);
synchronize_rcu();

View file

@ -603,6 +603,7 @@ void rcu_idle_enter(void)
lockdep_assert_irqs_disabled();
rcu_eqs_enter(false);
}
EXPORT_SYMBOL_GPL(rcu_idle_enter);
#ifdef CONFIG_NO_HZ_FULL
/**
@ -768,6 +769,7 @@ void rcu_idle_exit(void)
rcu_eqs_exit(false);
local_irq_restore(flags);
}
EXPORT_SYMBOL_GPL(rcu_idle_exit);
#ifdef CONFIG_NO_HZ_FULL
/**

View file

@ -524,6 +524,7 @@ void *__kmalloc_track_caller(size_t size, gfp_t gfp, unsigned long caller)
{
return __do_kmalloc_node(size, gfp, NUMA_NO_NODE, caller);
}
EXPORT_SYMBOL(__kmalloc_track_caller);
#ifdef CONFIG_NUMA
void *__kmalloc_node_track_caller(size_t size, gfp_t gfp,
@ -531,6 +532,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfp,
{
return __do_kmalloc_node(size, gfp, node, caller);
}
EXPORT_SYMBOL(__kmalloc_node_track_caller);
#endif
void kfree(const void *block)

View file

@ -4424,6 +4424,7 @@ void *__kmalloc_track_caller(size_t size, gfp_t gfpflags, unsigned long caller)
return ret;
}
EXPORT_SYMBOL(__kmalloc_track_caller);
#ifdef CONFIG_NUMA
void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
@ -4454,6 +4455,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
return ret;
}
EXPORT_SYMBOL(__kmalloc_node_track_caller);
#endif
#ifdef CONFIG_SYSFS

View file

@ -134,6 +134,7 @@
#include <net/bpf_sk_storage.h>
#include <trace/events/sock.h>
#include <trace/hooks/net.h>
#include <net/tcp.h>
#include <net/busy_poll.h>
@ -1608,6 +1609,8 @@ static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority,
if (security_sk_alloc(sk, family, priority))
goto out_free;
trace_android_rvh_sk_alloc(sk);
if (!try_module_get(prot->owner))
goto out_free_sec;
sk_tx_queue_clear(sk);
@ -1617,6 +1620,7 @@ static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority,
out_free_sec:
security_sk_free(sk);
trace_android_rvh_sk_free(sk);
out_free:
if (slab != NULL)
kmem_cache_free(slab, sk);
@ -1636,6 +1640,7 @@ static void sk_prot_free(struct proto *prot, struct sock *sk)
cgroup_sk_free(&sk->sk_cgrp_data);
mem_cgroup_sk_free(sk);
security_sk_free(sk);
trace_android_rvh_sk_free(sk);
if (slab != NULL)
kmem_cache_free(slab, sk);
else

View file

@ -33,6 +33,7 @@
#include <linux/mm.h>
#include <linux/nsproxy.h>
#include <linux/rculist_nulls.h>
#include <trace/hooks/net.h>
#include <net/netfilter/nf_conntrack.h>
#include <net/netfilter/nf_conntrack_l4proto.h>
@ -1396,6 +1397,9 @@ __nf_conntrack_alloc(struct net *net,
#if defined(CONFIG_IP_NF_TARGET_NATTYPE_MODULE)
ct->nattype_entry = 0;
#endif
trace_android_rvh_nf_conn_alloc(ct);
/* Because we use RCU lookups, we set ct_general.use to zero before
* this is inserted in any list.
*/
@ -1429,6 +1433,7 @@ void nf_conntrack_free(struct nf_conn *ct)
nf_ct_ext_free(ct);
kmem_cache_free(nf_conntrack_cachep, ct);
smp_mb__before_atomic();
trace_android_rvh_nf_conn_free(ct);
atomic_dec(&net->ct.count);
}
EXPORT_SYMBOL_GPL(nf_conntrack_free);

View file

@ -28,6 +28,17 @@ config XFRM_USER
If unsure, say Y.
config XFRM_USER_COMPAT
tristate "Compatible ABI support"
depends on XFRM_USER && COMPAT_FOR_U64_ALIGNMENT && \
HAVE_EFFICIENT_UNALIGNED_ACCESS
select WANT_COMPAT_NETLINK_MESSAGES
help
Transformation(XFRM) user configuration interface like IPsec
used by compatible Linux applications.
If unsure, say N.
config XFRM_INTERFACE
tristate "Transformation virtual interface"
depends on XFRM && IPV6

View file

@ -9,5 +9,6 @@ obj-$(CONFIG_XFRM) := xfrm_policy.o xfrm_state.o xfrm_hash.o \
obj-$(CONFIG_XFRM_STATISTICS) += xfrm_proc.o
obj-$(CONFIG_XFRM_ALGO) += xfrm_algo.o
obj-$(CONFIG_XFRM_USER) += xfrm_user.o
obj-$(CONFIG_XFRM_USER_COMPAT) += xfrm_compat.o
obj-$(CONFIG_XFRM_IPCOMP) += xfrm_ipcomp.o
obj-$(CONFIG_XFRM_INTERFACE) += xfrm_interface.o

625
net/xfrm/xfrm_compat.c Normal file
View file

@ -0,0 +1,625 @@
// SPDX-License-Identifier: GPL-2.0
/*
* XFRM compat layer
* Author: Dmitry Safonov <dima@arista.com>
* Based on code and translator idea by: Florian Westphal <fw@strlen.de>
*/
#include <linux/compat.h>
#include <linux/xfrm.h>
#include <net/xfrm.h>
struct compat_xfrm_lifetime_cfg {
compat_u64 soft_byte_limit, hard_byte_limit;
compat_u64 soft_packet_limit, hard_packet_limit;
compat_u64 soft_add_expires_seconds, hard_add_expires_seconds;
compat_u64 soft_use_expires_seconds, hard_use_expires_seconds;
}; /* same size on 32bit, but only 4 byte alignment required */
struct compat_xfrm_lifetime_cur {
compat_u64 bytes, packets, add_time, use_time;
}; /* same size on 32bit, but only 4 byte alignment required */
struct compat_xfrm_userpolicy_info {
struct xfrm_selector sel;
struct compat_xfrm_lifetime_cfg lft;
struct compat_xfrm_lifetime_cur curlft;
__u32 priority, index;
u8 dir, action, flags, share;
/* 4 bytes additional padding on 64bit */
};
struct compat_xfrm_usersa_info {
struct xfrm_selector sel;
struct xfrm_id id;
xfrm_address_t saddr;
struct compat_xfrm_lifetime_cfg lft;
struct compat_xfrm_lifetime_cur curlft;
struct xfrm_stats stats;
__u32 seq, reqid;
u16 family;
u8 mode, replay_window, flags;
/* 4 bytes additional padding on 64bit */
};
struct compat_xfrm_user_acquire {
struct xfrm_id id;
xfrm_address_t saddr;
struct xfrm_selector sel;
struct compat_xfrm_userpolicy_info policy;
/* 4 bytes additional padding on 64bit */
__u32 aalgos, ealgos, calgos, seq;
};
struct compat_xfrm_userspi_info {
struct compat_xfrm_usersa_info info;
/* 4 bytes additional padding on 64bit */
__u32 min, max;
};
struct compat_xfrm_user_expire {
struct compat_xfrm_usersa_info state;
/* 8 bytes additional padding on 64bit */
u8 hard;
};
struct compat_xfrm_user_polexpire {
struct compat_xfrm_userpolicy_info pol;
/* 8 bytes additional padding on 64bit */
u8 hard;
};
#define XMSGSIZE(type) sizeof(struct type)
static const int compat_msg_min[XFRM_NR_MSGTYPES] = {
[XFRM_MSG_NEWSA - XFRM_MSG_BASE] = XMSGSIZE(compat_xfrm_usersa_info),
[XFRM_MSG_DELSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_id),
[XFRM_MSG_GETSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_id),
[XFRM_MSG_NEWPOLICY - XFRM_MSG_BASE] = XMSGSIZE(compat_xfrm_userpolicy_info),
[XFRM_MSG_DELPOLICY - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_id),
[XFRM_MSG_GETPOLICY - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_id),
[XFRM_MSG_ALLOCSPI - XFRM_MSG_BASE] = XMSGSIZE(compat_xfrm_userspi_info),
[XFRM_MSG_ACQUIRE - XFRM_MSG_BASE] = XMSGSIZE(compat_xfrm_user_acquire),
[XFRM_MSG_EXPIRE - XFRM_MSG_BASE] = XMSGSIZE(compat_xfrm_user_expire),
[XFRM_MSG_UPDPOLICY - XFRM_MSG_BASE] = XMSGSIZE(compat_xfrm_userpolicy_info),
[XFRM_MSG_UPDSA - XFRM_MSG_BASE] = XMSGSIZE(compat_xfrm_usersa_info),
[XFRM_MSG_POLEXPIRE - XFRM_MSG_BASE] = XMSGSIZE(compat_xfrm_user_polexpire),
[XFRM_MSG_FLUSHSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_flush),
[XFRM_MSG_FLUSHPOLICY - XFRM_MSG_BASE] = 0,
[XFRM_MSG_NEWAE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_aevent_id),
[XFRM_MSG_GETAE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_aevent_id),
[XFRM_MSG_REPORT - XFRM_MSG_BASE] = XMSGSIZE(xfrm_user_report),
[XFRM_MSG_MIGRATE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_id),
[XFRM_MSG_NEWSADINFO - XFRM_MSG_BASE] = sizeof(u32),
[XFRM_MSG_GETSADINFO - XFRM_MSG_BASE] = sizeof(u32),
[XFRM_MSG_NEWSPDINFO - XFRM_MSG_BASE] = sizeof(u32),
[XFRM_MSG_GETSPDINFO - XFRM_MSG_BASE] = sizeof(u32),
[XFRM_MSG_MAPPING - XFRM_MSG_BASE] = XMSGSIZE(xfrm_user_mapping)
};
static const struct nla_policy compat_policy[XFRMA_MAX+1] = {
[XFRMA_SA] = { .len = XMSGSIZE(compat_xfrm_usersa_info)},
[XFRMA_POLICY] = { .len = XMSGSIZE(compat_xfrm_userpolicy_info)},
[XFRMA_LASTUSED] = { .type = NLA_U64},
[XFRMA_ALG_AUTH_TRUNC] = { .len = sizeof(struct xfrm_algo_auth)},
[XFRMA_ALG_AEAD] = { .len = sizeof(struct xfrm_algo_aead) },
[XFRMA_ALG_AUTH] = { .len = sizeof(struct xfrm_algo) },
[XFRMA_ALG_CRYPT] = { .len = sizeof(struct xfrm_algo) },
[XFRMA_ALG_COMP] = { .len = sizeof(struct xfrm_algo) },
[XFRMA_ENCAP] = { .len = sizeof(struct xfrm_encap_tmpl) },
[XFRMA_TMPL] = { .len = sizeof(struct xfrm_user_tmpl) },
[XFRMA_SEC_CTX] = { .len = sizeof(struct xfrm_sec_ctx) },
[XFRMA_LTIME_VAL] = { .len = sizeof(struct xfrm_lifetime_cur) },
[XFRMA_REPLAY_VAL] = { .len = sizeof(struct xfrm_replay_state) },
[XFRMA_REPLAY_THRESH] = { .type = NLA_U32 },
[XFRMA_ETIMER_THRESH] = { .type = NLA_U32 },
[XFRMA_SRCADDR] = { .len = sizeof(xfrm_address_t) },
[XFRMA_COADDR] = { .len = sizeof(xfrm_address_t) },
[XFRMA_POLICY_TYPE] = { .len = sizeof(struct xfrm_userpolicy_type)},
[XFRMA_MIGRATE] = { .len = sizeof(struct xfrm_user_migrate) },
[XFRMA_KMADDRESS] = { .len = sizeof(struct xfrm_user_kmaddress) },
[XFRMA_MARK] = { .len = sizeof(struct xfrm_mark) },
[XFRMA_TFCPAD] = { .type = NLA_U32 },
[XFRMA_REPLAY_ESN_VAL] = { .len = sizeof(struct xfrm_replay_state_esn) },
[XFRMA_SA_EXTRA_FLAGS] = { .type = NLA_U32 },
[XFRMA_PROTO] = { .type = NLA_U8 },
[XFRMA_ADDRESS_FILTER] = { .len = sizeof(struct xfrm_address_filter) },
[XFRMA_OFFLOAD_DEV] = { .len = sizeof(struct xfrm_user_offload) },
[XFRMA_SET_MARK] = { .type = NLA_U32 },
[XFRMA_SET_MARK_MASK] = { .type = NLA_U32 },
[XFRMA_IF_ID] = { .type = NLA_U32 },
};
static struct nlmsghdr *xfrm_nlmsg_put_compat(struct sk_buff *skb,
const struct nlmsghdr *nlh_src, u16 type)
{
int payload = compat_msg_min[type];
int src_len = xfrm_msg_min[type];
struct nlmsghdr *nlh_dst;
/* Compat messages are shorter or equal to native (+padding) */
if (WARN_ON_ONCE(src_len < payload))
return ERR_PTR(-EMSGSIZE);
nlh_dst = nlmsg_put(skb, nlh_src->nlmsg_pid, nlh_src->nlmsg_seq,
nlh_src->nlmsg_type, payload, nlh_src->nlmsg_flags);
if (!nlh_dst)
return ERR_PTR(-EMSGSIZE);
memset(nlmsg_data(nlh_dst), 0, payload);
switch (nlh_src->nlmsg_type) {
/* Compat message has the same layout as native */
case XFRM_MSG_DELSA:
case XFRM_MSG_DELPOLICY:
case XFRM_MSG_FLUSHSA:
case XFRM_MSG_FLUSHPOLICY:
case XFRM_MSG_NEWAE:
case XFRM_MSG_REPORT:
case XFRM_MSG_MIGRATE:
case XFRM_MSG_NEWSADINFO:
case XFRM_MSG_NEWSPDINFO:
case XFRM_MSG_MAPPING:
WARN_ON_ONCE(src_len != payload);
memcpy(nlmsg_data(nlh_dst), nlmsg_data(nlh_src), src_len);
break;
/* 4 byte alignment for trailing u64 on native, but not on compat */
case XFRM_MSG_NEWSA:
case XFRM_MSG_NEWPOLICY:
case XFRM_MSG_UPDSA:
case XFRM_MSG_UPDPOLICY:
WARN_ON_ONCE(src_len != payload + 4);
memcpy(nlmsg_data(nlh_dst), nlmsg_data(nlh_src), payload);
break;
case XFRM_MSG_EXPIRE: {
const struct xfrm_user_expire *src_ue = nlmsg_data(nlh_src);
struct compat_xfrm_user_expire *dst_ue = nlmsg_data(nlh_dst);
/* compat_xfrm_user_expire has 4-byte smaller state */
memcpy(dst_ue, src_ue, sizeof(dst_ue->state));
dst_ue->hard = src_ue->hard;
break;
}
case XFRM_MSG_ACQUIRE: {
const struct xfrm_user_acquire *src_ua = nlmsg_data(nlh_src);
struct compat_xfrm_user_acquire *dst_ua = nlmsg_data(nlh_dst);
memcpy(dst_ua, src_ua, offsetof(struct compat_xfrm_user_acquire, aalgos));
dst_ua->aalgos = src_ua->aalgos;
dst_ua->ealgos = src_ua->ealgos;
dst_ua->calgos = src_ua->calgos;
dst_ua->seq = src_ua->seq;
break;
}
case XFRM_MSG_POLEXPIRE: {
const struct xfrm_user_polexpire *src_upe = nlmsg_data(nlh_src);
struct compat_xfrm_user_polexpire *dst_upe = nlmsg_data(nlh_dst);
/* compat_xfrm_user_polexpire has 4-byte smaller state */
memcpy(dst_upe, src_upe, sizeof(dst_upe->pol));
dst_upe->hard = src_upe->hard;
break;
}
case XFRM_MSG_ALLOCSPI: {
const struct xfrm_userspi_info *src_usi = nlmsg_data(nlh_src);
struct compat_xfrm_userspi_info *dst_usi = nlmsg_data(nlh_dst);
/* compat_xfrm_user_polexpire has 4-byte smaller state */
memcpy(dst_usi, src_usi, sizeof(src_usi->info));
dst_usi->min = src_usi->min;
dst_usi->max = src_usi->max;
break;
}
/* Not being sent by kernel */
case XFRM_MSG_GETSA:
case XFRM_MSG_GETPOLICY:
case XFRM_MSG_GETAE:
case XFRM_MSG_GETSADINFO:
case XFRM_MSG_GETSPDINFO:
default:
WARN_ONCE(1, "unsupported nlmsg_type %d", nlh_src->nlmsg_type);
return ERR_PTR(-EOPNOTSUPP);
}
return nlh_dst;
}
static int xfrm_nla_cpy(struct sk_buff *dst, const struct nlattr *src, int len)
{
return nla_put(dst, src->nla_type, len, nla_data(src));
}
static int xfrm_xlate64_attr(struct sk_buff *dst, const struct nlattr *src)
{
switch (src->nla_type) {
case XFRMA_PAD:
/* Ignore */
return 0;
case XFRMA_ALG_AUTH:
case XFRMA_ALG_CRYPT:
case XFRMA_ALG_COMP:
case XFRMA_ENCAP:
case XFRMA_TMPL:
return xfrm_nla_cpy(dst, src, nla_len(src));
case XFRMA_SA:
return xfrm_nla_cpy(dst, src, XMSGSIZE(compat_xfrm_usersa_info));
case XFRMA_POLICY:
return xfrm_nla_cpy(dst, src, XMSGSIZE(compat_xfrm_userpolicy_info));
case XFRMA_SEC_CTX:
return xfrm_nla_cpy(dst, src, nla_len(src));
case XFRMA_LTIME_VAL:
return nla_put_64bit(dst, src->nla_type, nla_len(src),
nla_data(src), XFRMA_PAD);
case XFRMA_REPLAY_VAL:
case XFRMA_REPLAY_THRESH:
case XFRMA_ETIMER_THRESH:
case XFRMA_SRCADDR:
case XFRMA_COADDR:
return xfrm_nla_cpy(dst, src, nla_len(src));
case XFRMA_LASTUSED:
return nla_put_64bit(dst, src->nla_type, nla_len(src),
nla_data(src), XFRMA_PAD);
case XFRMA_POLICY_TYPE:
case XFRMA_MIGRATE:
case XFRMA_ALG_AEAD:
case XFRMA_KMADDRESS:
case XFRMA_ALG_AUTH_TRUNC:
case XFRMA_MARK:
case XFRMA_TFCPAD:
case XFRMA_REPLAY_ESN_VAL:
case XFRMA_SA_EXTRA_FLAGS:
case XFRMA_PROTO:
case XFRMA_ADDRESS_FILTER:
case XFRMA_OFFLOAD_DEV:
case XFRMA_SET_MARK:
case XFRMA_SET_MARK_MASK:
case XFRMA_IF_ID:
return xfrm_nla_cpy(dst, src, nla_len(src));
default:
BUILD_BUG_ON(XFRMA_MAX != XFRMA_IF_ID);
WARN_ONCE(1, "unsupported nla_type %d", src->nla_type);
return -EOPNOTSUPP;
}
}
/* Take kernel-built (64bit layout) and create 32bit layout for userspace */
static int xfrm_xlate64(struct sk_buff *dst, const struct nlmsghdr *nlh_src)
{
u16 type = nlh_src->nlmsg_type - XFRM_MSG_BASE;
const struct nlattr *nla, *attrs;
struct nlmsghdr *nlh_dst;
int len, remaining;
nlh_dst = xfrm_nlmsg_put_compat(dst, nlh_src, type);
if (IS_ERR(nlh_dst))
return PTR_ERR(nlh_dst);
attrs = nlmsg_attrdata(nlh_src, xfrm_msg_min[type]);
len = nlmsg_attrlen(nlh_src, xfrm_msg_min[type]);
nla_for_each_attr(nla, attrs, len, remaining) {
int err = xfrm_xlate64_attr(dst, nla);
if (err)
return err;
}
nlmsg_end(dst, nlh_dst);
return 0;
}
static int xfrm_alloc_compat(struct sk_buff *skb, const struct nlmsghdr *nlh_src)
{
u16 type = nlh_src->nlmsg_type - XFRM_MSG_BASE;
struct sk_buff *new = NULL;
int err;
if (WARN_ON_ONCE(type >= ARRAY_SIZE(xfrm_msg_min)))
return -EOPNOTSUPP;
if (skb_shinfo(skb)->frag_list == NULL) {
new = alloc_skb(skb->len + skb_tailroom(skb), GFP_ATOMIC);
if (!new)
return -ENOMEM;
skb_shinfo(skb)->frag_list = new;
}
err = xfrm_xlate64(skb_shinfo(skb)->frag_list, nlh_src);
if (err) {
if (new) {
kfree_skb(new);
skb_shinfo(skb)->frag_list = NULL;
}
return err;
}
return 0;
}
/* Calculates len of translated 64-bit message. */
static size_t xfrm_user_rcv_calculate_len64(const struct nlmsghdr *src,
struct nlattr *attrs[XFRMA_MAX+1])
{
size_t len = nlmsg_len(src);
switch (src->nlmsg_type) {
case XFRM_MSG_NEWSA:
case XFRM_MSG_NEWPOLICY:
case XFRM_MSG_ALLOCSPI:
case XFRM_MSG_ACQUIRE:
case XFRM_MSG_UPDPOLICY:
case XFRM_MSG_UPDSA:
len += 4;
break;
case XFRM_MSG_EXPIRE:
case XFRM_MSG_POLEXPIRE:
len += 8;
break;
default:
break;
}
if (attrs[XFRMA_SA])
len += 4;
if (attrs[XFRMA_POLICY])
len += 4;
/* XXX: some attrs may need to be realigned
* if !CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
*/
return len;
}
static int xfrm_attr_cpy32(void *dst, size_t *pos, const struct nlattr *src,
size_t size, int copy_len, int payload)
{
struct nlmsghdr *nlmsg = dst;
struct nlattr *nla;
if (WARN_ON_ONCE(copy_len > payload))
copy_len = payload;
if (size - *pos < nla_attr_size(payload))
return -ENOBUFS;
nla = dst + *pos;
memcpy(nla, src, nla_attr_size(copy_len));
nla->nla_len = nla_attr_size(payload);
*pos += nla_attr_size(payload);
nlmsg->nlmsg_len += nla->nla_len;
memset(dst + *pos, 0, payload - copy_len);
*pos += payload - copy_len;
return 0;
}
static int xfrm_xlate32_attr(void *dst, const struct nlattr *nla,
size_t *pos, size_t size,
struct netlink_ext_ack *extack)
{
int type = nla_type(nla);
u16 pol_len32, pol_len64;
int err;
if (type > XFRMA_MAX) {
BUILD_BUG_ON(XFRMA_MAX != XFRMA_IF_ID);
NL_SET_ERR_MSG(extack, "Bad attribute");
return -EOPNOTSUPP;
}
if (nla_len(nla) < compat_policy[type].len) {
NL_SET_ERR_MSG(extack, "Attribute bad length");
return -EOPNOTSUPP;
}
pol_len32 = compat_policy[type].len;
pol_len64 = xfrma_policy[type].len;
/* XFRMA_SA and XFRMA_POLICY - need to know how-to translate */
if (pol_len32 != pol_len64) {
if (nla_len(nla) != compat_policy[type].len) {
NL_SET_ERR_MSG(extack, "Attribute bad length");
return -EOPNOTSUPP;
}
err = xfrm_attr_cpy32(dst, pos, nla, size, pol_len32, pol_len64);
if (err)
return err;
}
return xfrm_attr_cpy32(dst, pos, nla, size, nla_len(nla), nla_len(nla));
}
static int xfrm_xlate32(struct nlmsghdr *dst, const struct nlmsghdr *src,
struct nlattr *attrs[XFRMA_MAX+1],
size_t size, u8 type, struct netlink_ext_ack *extack)
{
size_t pos;
int i;
memcpy(dst, src, NLMSG_HDRLEN);
dst->nlmsg_len = NLMSG_HDRLEN + xfrm_msg_min[type];
memset(nlmsg_data(dst), 0, xfrm_msg_min[type]);
switch (src->nlmsg_type) {
/* Compat message has the same layout as native */
case XFRM_MSG_DELSA:
case XFRM_MSG_GETSA:
case XFRM_MSG_DELPOLICY:
case XFRM_MSG_GETPOLICY:
case XFRM_MSG_FLUSHSA:
case XFRM_MSG_FLUSHPOLICY:
case XFRM_MSG_NEWAE:
case XFRM_MSG_GETAE:
case XFRM_MSG_REPORT:
case XFRM_MSG_MIGRATE:
case XFRM_MSG_NEWSADINFO:
case XFRM_MSG_GETSADINFO:
case XFRM_MSG_NEWSPDINFO:
case XFRM_MSG_GETSPDINFO:
case XFRM_MSG_MAPPING:
memcpy(nlmsg_data(dst), nlmsg_data(src), compat_msg_min[type]);
break;
/* 4 byte alignment for trailing u64 on native, but not on compat */
case XFRM_MSG_NEWSA:
case XFRM_MSG_NEWPOLICY:
case XFRM_MSG_UPDSA:
case XFRM_MSG_UPDPOLICY:
memcpy(nlmsg_data(dst), nlmsg_data(src), compat_msg_min[type]);
break;
case XFRM_MSG_EXPIRE: {
const struct compat_xfrm_user_expire *src_ue = nlmsg_data(src);
struct xfrm_user_expire *dst_ue = nlmsg_data(dst);
/* compat_xfrm_user_expire has 4-byte smaller state */
memcpy(dst_ue, src_ue, sizeof(src_ue->state));
dst_ue->hard = src_ue->hard;
break;
}
case XFRM_MSG_ACQUIRE: {
const struct compat_xfrm_user_acquire *src_ua = nlmsg_data(src);
struct xfrm_user_acquire *dst_ua = nlmsg_data(dst);
memcpy(dst_ua, src_ua, offsetof(struct compat_xfrm_user_acquire, aalgos));
dst_ua->aalgos = src_ua->aalgos;
dst_ua->ealgos = src_ua->ealgos;
dst_ua->calgos = src_ua->calgos;
dst_ua->seq = src_ua->seq;
break;
}
case XFRM_MSG_POLEXPIRE: {
const struct compat_xfrm_user_polexpire *src_upe = nlmsg_data(src);
struct xfrm_user_polexpire *dst_upe = nlmsg_data(dst);
/* compat_xfrm_user_polexpire has 4-byte smaller state */
memcpy(dst_upe, src_upe, sizeof(src_upe->pol));
dst_upe->hard = src_upe->hard;
break;
}
case XFRM_MSG_ALLOCSPI: {
const struct compat_xfrm_userspi_info *src_usi = nlmsg_data(src);
struct xfrm_userspi_info *dst_usi = nlmsg_data(dst);
/* compat_xfrm_user_polexpire has 4-byte smaller state */
memcpy(dst_usi, src_usi, sizeof(src_usi->info));
dst_usi->min = src_usi->min;
dst_usi->max = src_usi->max;
break;
}
default:
NL_SET_ERR_MSG(extack, "Unsupported message type");
return -EOPNOTSUPP;
}
pos = dst->nlmsg_len;
for (i = 1; i < XFRMA_MAX + 1; i++) {
int err;
if (i == XFRMA_PAD)
continue;
if (!attrs[i])
continue;
err = xfrm_xlate32_attr(dst, attrs[i], &pos, size, extack);
if (err)
return err;
}
return 0;
}
static struct nlmsghdr *xfrm_user_rcv_msg_compat(const struct nlmsghdr *h32,
int maxtype, const struct nla_policy *policy,
struct netlink_ext_ack *extack)
{
/* netlink_rcv_skb() checks if a message has full (struct nlmsghdr) */
u16 type = h32->nlmsg_type - XFRM_MSG_BASE;
struct nlattr *attrs[XFRMA_MAX+1];
struct nlmsghdr *h64;
size_t len;
int err;
BUILD_BUG_ON(ARRAY_SIZE(xfrm_msg_min) != ARRAY_SIZE(compat_msg_min));
if (type >= ARRAY_SIZE(xfrm_msg_min))
return ERR_PTR(-EINVAL);
/* Don't call parse: the message might have only nlmsg header */
if ((h32->nlmsg_type == XFRM_MSG_GETSA ||
h32->nlmsg_type == XFRM_MSG_GETPOLICY) &&
(h32->nlmsg_flags & NLM_F_DUMP))
return NULL;
err = nlmsg_parse_deprecated(h32, compat_msg_min[type], attrs,
maxtype ? : XFRMA_MAX, policy ? : compat_policy, extack);
if (err < 0)
return ERR_PTR(err);
len = xfrm_user_rcv_calculate_len64(h32, attrs);
/* The message doesn't need translation */
if (len == nlmsg_len(h32))
return NULL;
len += NLMSG_HDRLEN;
h64 = kvmalloc(len, GFP_KERNEL | __GFP_ZERO);
if (!h64)
return ERR_PTR(-ENOMEM);
err = xfrm_xlate32(h64, h32, attrs, len, type, extack);
if (err < 0) {
kvfree(h64);
return ERR_PTR(err);
}
return h64;
}
static int xfrm_user_policy_compat(u8 **pdata32, int optlen)
{
struct compat_xfrm_userpolicy_info *p = (void *)*pdata32;
u8 *src_templates, *dst_templates;
u8 *data64;
if (optlen < sizeof(*p))
return -EINVAL;
data64 = kmalloc(optlen + 4, GFP_USER | __GFP_NOWARN);
if (!data64)
return -ENOMEM;
memcpy(data64, *pdata32, sizeof(*p));
memset(data64 + sizeof(*p), 0, 4);
src_templates = *pdata32 + sizeof(*p);
dst_templates = data64 + sizeof(*p) + 4;
memcpy(dst_templates, src_templates, optlen - sizeof(*p));
kfree(*pdata32);
*pdata32 = data64;
return 0;
}
static struct xfrm_translator xfrm_translator = {
.owner = THIS_MODULE,
.alloc_compat = xfrm_alloc_compat,
.rcv_msg_compat = xfrm_user_rcv_msg_compat,
.xlate_user_policy_sockptr = xfrm_user_policy_compat,
};
static int __init xfrm_compat_init(void)
{
return xfrm_register_translator(&xfrm_translator);
}
static void __exit xfrm_compat_exit(void)
{
xfrm_unregister_translator(&xfrm_translator);
}
module_init(xfrm_compat_init);
module_exit(xfrm_compat_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Dmitry Safonov");
MODULE_DESCRIPTION("XFRM 32-bit compatibility layer");

View file

@ -2261,6 +2261,66 @@ static bool km_is_alive(const struct km_event *c)
return is_alive;
}
#if IS_ENABLED(CONFIG_XFRM_USER_COMPAT)
static DEFINE_SPINLOCK(xfrm_translator_lock);
static struct xfrm_translator __rcu *xfrm_translator;
struct xfrm_translator *xfrm_get_translator(void)
{
struct xfrm_translator *xtr;
rcu_read_lock();
xtr = rcu_dereference(xfrm_translator);
if (unlikely(!xtr))
goto out;
if (!try_module_get(xtr->owner))
xtr = NULL;
out:
rcu_read_unlock();
return xtr;
}
EXPORT_SYMBOL_GPL(xfrm_get_translator);
void xfrm_put_translator(struct xfrm_translator *xtr)
{
module_put(xtr->owner);
}
EXPORT_SYMBOL_GPL(xfrm_put_translator);
int xfrm_register_translator(struct xfrm_translator *xtr)
{
int err = 0;
spin_lock_bh(&xfrm_translator_lock);
if (unlikely(xfrm_translator != NULL))
err = -EEXIST;
else
rcu_assign_pointer(xfrm_translator, xtr);
spin_unlock_bh(&xfrm_translator_lock);
return err;
}
EXPORT_SYMBOL_GPL(xfrm_register_translator);
int xfrm_unregister_translator(struct xfrm_translator *xtr)
{
int err = 0;
spin_lock_bh(&xfrm_translator_lock);
if (likely(xfrm_translator != NULL)) {
if (rcu_access_pointer(xfrm_translator) != xtr)
err = -EINVAL;
else
RCU_INIT_POINTER(xfrm_translator, NULL);
}
spin_unlock_bh(&xfrm_translator_lock);
synchronize_rcu();
return err;
}
EXPORT_SYMBOL_GPL(xfrm_unregister_translator);
#endif
int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen)
{
int err;
@ -2282,6 +2342,23 @@ int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen
if (IS_ERR(data))
return PTR_ERR(data);
/* Use the 64-bit / untranslated format on Android, even for compat */
if (!IS_ENABLED(CONFIG_ANDROID) || IS_ENABLED(CONFIG_XFRM_USER_COMPAT)) {
if (in_compat_syscall()) {
struct xfrm_translator *xtr = xfrm_get_translator();
if (!xtr)
return -EOPNOTSUPP;
err = xtr->xlate_user_policy_sockptr(&data, optlen);
xfrm_put_translator(xtr);
if (err) {
kfree(data);
return err;
}
}
}
err = -EINVAL;
rcu_read_lock();
list_for_each_entry_rcu(km, &xfrm_km_list, list) {

View file

@ -975,6 +975,7 @@ static int dump_one_state(struct xfrm_state *x, int count, void *ptr)
struct xfrm_dump_info *sp = ptr;
struct sk_buff *in_skb = sp->in_skb;
struct sk_buff *skb = sp->out_skb;
struct xfrm_translator *xtr;
struct xfrm_usersa_info *p;
struct nlmsghdr *nlh;
int err;
@ -992,6 +993,18 @@ static int dump_one_state(struct xfrm_state *x, int count, void *ptr)
return err;
}
nlmsg_end(skb, nlh);
xtr = xfrm_get_translator();
if (xtr) {
err = xtr->alloc_compat(skb, nlh);
xfrm_put_translator(xtr);
if (err) {
nlmsg_cancel(skb, nlh);
return err;
}
}
return 0;
}
@ -1006,7 +1019,6 @@ static int xfrm_dump_sa_done(struct netlink_callback *cb)
return 0;
}
static const struct nla_policy xfrma_policy[XFRMA_MAX+1];
static int xfrm_dump_sa(struct sk_buff *skb, struct netlink_callback *cb)
{
struct net *net = sock_net(skb->sk);
@ -1083,12 +1095,24 @@ static inline int xfrm_nlmsg_multicast(struct net *net, struct sk_buff *skb,
u32 pid, unsigned int group)
{
struct sock *nlsk = rcu_dereference(net->xfrm.nlsk);
struct xfrm_translator *xtr;
if (!nlsk) {
kfree_skb(skb);
return -EPIPE;
}
xtr = xfrm_get_translator();
if (xtr) {
int err = xtr->alloc_compat(skb, nlmsg_hdr(skb));
xfrm_put_translator(xtr);
if (err) {
kfree_skb(skb);
return err;
}
}
return nlmsg_multicast(nlsk, skb, pid, group, GFP_ATOMIC);
}
@ -1308,6 +1332,7 @@ static int xfrm_alloc_userspi(struct sk_buff *skb, struct nlmsghdr *nlh,
struct net *net = sock_net(skb->sk);
struct xfrm_state *x;
struct xfrm_userspi_info *p;
struct xfrm_translator *xtr;
struct sk_buff *resp_skb;
xfrm_address_t *daddr;
int family;
@ -1358,6 +1383,17 @@ static int xfrm_alloc_userspi(struct sk_buff *skb, struct nlmsghdr *nlh,
goto out;
}
xtr = xfrm_get_translator();
if (xtr) {
err = xtr->alloc_compat(skb, nlmsg_hdr(skb));
xfrm_put_translator(xtr);
if (err) {
kfree_skb(resp_skb);
goto out;
}
}
err = nlmsg_unicast(net->xfrm.nlsk, resp_skb, NETLINK_CB(skb).portid);
out:
@ -1764,6 +1800,7 @@ static int dump_one_policy(struct xfrm_policy *xp, int dir, int count, void *ptr
struct xfrm_userpolicy_info *p;
struct sk_buff *in_skb = sp->in_skb;
struct sk_buff *skb = sp->out_skb;
struct xfrm_translator *xtr;
struct nlmsghdr *nlh;
int err;
@ -1788,6 +1825,18 @@ static int dump_one_policy(struct xfrm_policy *xp, int dir, int count, void *ptr
return err;
}
nlmsg_end(skb, nlh);
xtr = xfrm_get_translator();
if (xtr) {
err = xtr->alloc_compat(skb, nlh);
xfrm_put_translator(xtr);
if (err) {
nlmsg_cancel(skb, nlh);
return err;
}
}
return 0;
}
@ -2533,7 +2582,7 @@ static int xfrm_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
#define XMSGSIZE(type) sizeof(struct type)
static const int xfrm_msg_min[XFRM_NR_MSGTYPES] = {
const int xfrm_msg_min[XFRM_NR_MSGTYPES] = {
[XFRM_MSG_NEWSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_info),
[XFRM_MSG_DELSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_id),
[XFRM_MSG_GETSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_id),
@ -2556,10 +2605,11 @@ static const int xfrm_msg_min[XFRM_NR_MSGTYPES] = {
[XFRM_MSG_NEWSPDINFO - XFRM_MSG_BASE] = sizeof(u32),
[XFRM_MSG_GETSPDINFO - XFRM_MSG_BASE] = sizeof(u32),
};
EXPORT_SYMBOL_GPL(xfrm_msg_min);
#undef XMSGSIZE
static const struct nla_policy xfrma_policy[XFRMA_MAX+1] = {
const struct nla_policy xfrma_policy[XFRMA_MAX+1] = {
[XFRMA_SA] = { .len = sizeof(struct xfrm_usersa_info)},
[XFRMA_POLICY] = { .len = sizeof(struct xfrm_userpolicy_info)},
[XFRMA_LASTUSED] = { .type = NLA_U64},
@ -2591,6 +2641,7 @@ static const struct nla_policy xfrma_policy[XFRMA_MAX+1] = {
[XFRMA_SET_MARK_MASK] = { .type = NLA_U32 },
[XFRMA_IF_ID] = { .type = NLA_U32 },
};
EXPORT_SYMBOL_GPL(xfrma_policy);
static const struct nla_policy xfrma_spd_policy[XFRMA_SPD_MAX+1] = {
[XFRMA_SPD_IPV4_HTHRESH] = { .len = sizeof(struct xfrmu_spdhthresh) },
@ -2640,6 +2691,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
struct net *net = sock_net(skb->sk);
struct nlattr *attrs[XFRMA_MAX+1];
const struct xfrm_link *link;
struct nlmsghdr *nlh64 = NULL;
int type, err;
type = nlh->nlmsg_type;
@ -2653,32 +2705,58 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
if (!netlink_net_capable(skb, CAP_NET_ADMIN))
return -EPERM;
/* Use the 64-bit / untranslated format on Android, even for compat */
if (!IS_ENABLED(CONFIG_ANDROID) || IS_ENABLED(CONFIG_XFRM_USER_COMPAT)) {
if (in_compat_syscall()) {
struct xfrm_translator *xtr = xfrm_get_translator();
if (!xtr)
return -EOPNOTSUPP;
nlh64 = xtr->rcv_msg_compat(nlh, link->nla_max,
link->nla_pol, extack);
xfrm_put_translator(xtr);
if (IS_ERR(nlh64))
return PTR_ERR(nlh64);
if (nlh64)
nlh = nlh64;
}
}
if ((type == (XFRM_MSG_GETSA - XFRM_MSG_BASE) ||
type == (XFRM_MSG_GETPOLICY - XFRM_MSG_BASE)) &&
(nlh->nlmsg_flags & NLM_F_DUMP)) {
if (link->dump == NULL)
return -EINVAL;
struct netlink_dump_control c = {
.start = link->start,
.dump = link->dump,
.done = link->done,
};
{
struct netlink_dump_control c = {
.start = link->start,
.dump = link->dump,
.done = link->done,
};
return netlink_dump_start(net->xfrm.nlsk, skb, nlh, &c);
if (link->dump == NULL) {
err = -EINVAL;
goto err;
}
err = netlink_dump_start(net->xfrm.nlsk, skb, nlh, &c);
goto err;
}
err = nlmsg_parse_deprecated(nlh, xfrm_msg_min[type], attrs,
link->nla_max ? : XFRMA_MAX,
link->nla_pol ? : xfrma_policy, extack);
if (err < 0)
return err;
goto err;
if (link->doit == NULL)
return -EINVAL;
if (link->doit == NULL) {
err = -EINVAL;
goto err;
}
return link->doit(skb, nlh, attrs);
err = link->doit(skb, nlh, attrs);
err:
kvfree(nlh64);
return err;
}
static void xfrm_netlink_rcv(struct sk_buff *skb)