mirror of
https://github.com/LineageOS/android_kernel_fxtec_sm6115.git
synced 2026-08-19 00:31:12 +00:00
version 4.19.325-cip131 * tag 'v4.19.325-cip131' of https://git.kernel.org/pub/scm/linux/kernel/git/cip/linux-cip: CIP: Bump version suffix to -cip131 after merge from cip/linux-4.19.y-st tree Update localversion-st, tree is up-to-date with 5.10.252. nfsd: fix return error code for nfsd_map_name_to_[ug]id net: usb: pegasus: enable basic endpoint checking Bluetooth: L2CAP: Fix not checking l2cap_chan security level Bluetooth: Enforce key size of 16 bytes on FIPS level xfrm6: fix uninitialized saddr in xfrm6_get_saddr() netfilter: nf_conntrack: Add allow_clash to generic protocol handler ext4: don't cache extent during splitting extent NTB: ntb_transport: Fix too small buffer for debugfs_name net: ethernet: ec_bhf: Fix dma_free_coherent() dma handle fbdev: ffb: fix corrupted video output on Sun FFB1 fbdev: of: display_timing: fix refcount leak in of_get_display_timings() atm: fore200e: fix use-after-free in tasklets during device removal net: wan/fsl_ucc_hdlc: Fix dma_free_coherent() in uhdlc_memclean() net: ethernet: marvell: skge: remove incorrect conflicting PCI ID ceph: supply snapshot context in ceph_zero_partial_object() MIPS: rb532: Fix MMIO UART resource registration parisc: kernel: replace kfree() with put_device() in create_tree_node() drm/amdkfd: Fix out-of-bounds write in kfd_event_page_set() usb: dwc2: fix resume failure if dr_mode is host btrfs: continue trimming remaining devices on failure kexec: derive purgatory entry from symbol ocfs2: fix reflink preserve cleanup issue ocfs2: fix xattr array entry __counted_by error rapidio: replace rio_free_net() with kfree() in rio_scan_alloc_net() iio: gyro: itg3200: Fix unchecked return value in read_raw dm mpath: make pg_init_delay_msecs settable bus: fsl-mc: fix an error handling in fsl_mc_device_add() md/bitmap: fix GPF in write_page caused by resize race xfs: fix remote xattr valuelblk check xfs: fix freemap adjustments when adding xattrs to leaf blocks xfs: delete attr leaf freemap entries when empty xfs: mark data structures corrupt on EIO and ENODATA mm, page_alloc, thp: prevent reclaim for __GFP_THISNODE THP allocations drm: of: drm_of_panel_bridge_remove(): fix device_node leak dm-unstripe: fix mapping bug when there are multiple targets in a table clk: tegra: tegra124-emc: Fix potential memory leak in tegra124_clk_register_emc() dm: clear cloned request bio pointer when last clone bio completes media: i2c/tw9906: Fix potential memory leak in tw9906_probe() media: i2c/tw9903: Fix potential memory leak in tw9903_probe() media: cx25821: Add missing unmap in snd_cx25821_hw_params() media: cx23885: Add missing unmap in snd_cx23885_hw_params() media: cx88: Add missing unmap in snd_cx88_hw_params() media: radio-keene: fix memory leak in error path HID: prodikeys: Check presence of pm->input_ep82 HID: magicmouse: Do not crash on missing msc->input HID: hid-pl: handle probe errors media: mtk-mdp: Fix a reference leak bug in mtk_mdp_remove() dm-verity: correctly handle dm_bufio_client_create() failure fpga: dfl: use subsys_initcall to allow built-in drivers to be added rpmsg: core: fix race in driver_override_show() and use core helper netfilter: nf_conntrack_h323: fix OOB read in decode_choice() net: consume xmit errors of GSO frames Bluetooth: L2CAP: Fix missing key size check for L2CAP_LE_CONN_REQ Bluetooth: l2cap: Check encryption key size on incoming connection wifi: cfg80211: wext: fix IGTK key ID off-by-one net: usb: lan78xx: scan all MDIO addresses on LAN7801 lan78xx: Fix memory allocation bug lan78xx: Fix race condition in disconnect handling lan78xx: Remove unused pause frame queue net: usb: kaweth: remove TX queue manipulation in kaweth_set_rx_mode ntb: ntb_hw_switchtec: Fix shift-out-of-bounds for 0 mw lut ntb: ntb_hw_switchtec: Fix array-index-out-of-bounds access drm/radeon: Add HAINAN clock adjustment drm/amdgpu: Add HAINAN clock adjustment ARM: 9467/1: mm: Don't use %pK through printk include: uapi: netfilter_bridge.h: Cover for musl libc iio: magnetometer: Remove IRQF_ONESHOT Revert "mfd: da9052-spi: Change read-mask to write-mask" binder: don't use %pK through printk serial: 8250_dw: handle clock enable errors in runtime_resume m68k: nommu: fix memmove() with differently aligned src and dest for 68000 clk: microchip: core: correct return value on *_get_parent() nfc: nxp-nci: remove interrupt trigger type myri10ge: avoid uninitialized variable use PCI: Mark Nvidia GB10 to avoid bus reset PCI: Fix pci_slot_lock () device locking PCI: Mark ASM1164 SATA controller to avoid bus reset net/rds: Clear reconnect pending bit vmw_vsock: bypass false-positive Wnonnull warning with gcc-16 net: usb: sr9700: remove code to drive nonexistent multicast filter Bluetooth: btusb: Add device ID for Realtek RTL8761BU Bluetooth: hci_conn: use mod_delayed_work for active mode timeout ipv4: fib: Annotate access to struct fib_alias.fa_state. wifi: iwlegacy: add missing mutex protection in il3945_store_measurement() wifi: iwlegacy: add missing mutex protection in il4965_store_tx_power() net/rds: No shortcut out of RDS_CONN_ERROR net: usb: r8152: fix transmit queue timeout openrisc: define arch-specific version of nop() netfilter: xt_tcpmss: check remaining length before reading optlen wifi: libertas: fix WARNING in usb_tx_block jfs: nlink overflow in jfs_rename jfs: Add missing set_freezable() for freezable kthread modpost: Amend ppc64 save/restfpr symnames for -Os build ASoC: es8328: Add error unwind in resume HID: multitouch: add eGalaxTouch EXC3188 support drm/atmel-hlcdc: fix use-after-free of drm_crtc_commit after release drm/atmel-hlcdc: fix memory leak from the atomic_destroy_state callback virt: vbox: uapi: Mark inner unions in packed structs as packed hyper-v: Mark inner union in hv_kvp_exchg_msg_value as packed drm: Account property blob allocations to memcg media: cx25821: Fix a resource leak in cx25821_dev_setup() media: solo6x10: Check for out of bounds chip_id media: pvrusb2: fix URB leak in pvr2_send_request_ex media: adv7180: fix frame interval in progressive mode ASoC: wm8962: Add WM8962_ADC_MONOMIX to "3D Coefficients" mask media: omap3isp: set initial format media: omap3isp: isppreview: always clamp in preview_try_format() media: omap3isp: isp_video_mbus_to_pix/pix_to_mbus fixes media: dvb-core: dmxdevfilter must always flush bufs parisc: Prevent interrupts during reboot arm64: tegra: smaug: Add usb-role-switch support pstore: ram_core: fix incorrect success return when vmap() fails mailbox: bcm-ferxrm-mailbox: Use default primary handler clocksource/drivers/sh_tmu: Always leave device running after probe sparc: don't reference obsolete termio struct for TC* constants xenbus: Use .freeze/.thaw to handle xenbus devices ACPICA: Abort AML bytecode execution when executing AML_FATAL_OP EFI/CPER: don't go past the ARM processor CPER record buffer x86/xen/pvh: Enable PAE mode for 32-bit guest only when CONFIG_X86_PAE is set s390/purgatory: Add -Wno-default-const-init-unsafe to KBUILD_CFLAGS tools/power cpupower: Reset errno before strtoull() minix: Add required sanity checking to minix_check_superblock() hfsplus: pretend special inodes as regular files audit: add missing syscalls to read class hfsplus: fix volume corruption issue for generic/498 audit: add fchmodat2() to change attributes class rtc: interface: Alarm race handling should not discard preceding error SUNRPC: fix gss_auth kref leak in gss_alloc_msg error path SUNRPC: auth_gss: fix memory leaks in XDR decoding error paths ata: pata_ftide010: Fix some DMA timings ext4: fix memory leak in ext4_ext_shift_extents() MIPS: Work around LLVM bug when gp is used as global register variable apparmor: fix invalid deref of rawdata when export_binary is unset apparmor: fix rlimit for posix cpu timers apparmor: fix NULL sock in aa_sock_file_perm bonding: alb: fix UAF in rlb_arp_recv during bond up/down macvlan: observe an RCU grace period in macvlan_common_newlink() error path netfilter: nf_conntrack_h323: don't pass uninitialised l3num value net/rds: rds_sendmsg should not discard payload_len xen-netback: reject zero-queue configuration from guest net: usb: catc: enable basic endpoint checking usbb: catc: use correct API for MAC addresses cpuidle: Skip governor when only one idle state is available pinctrl: single: fix refcount leak in pcs_add_gpio_func() iio: sca3000: Fix a resource leak in sca3000_probe() ovl: Fix uninit-value in ovl_fill_real drivers: iio: mpu3050: use dev_err_probe for regulator request mfd: arizona: Fix regulator resource leak on wm5102_clear_write_sequencer() failure Revert "mmc: rtsx_pci_sdmmc: increase power-on settling delay to 5ms" mmc: rtsx_pci_sdmmc: increase power-on settling delay to 5ms mmc: core: Initial support for SD express card/host serial: SH_SCI: improve "DMA support" prompt staging: greybus: lights: avoid NULL deref fbdev: au1200fb: Fix a memory leak in au1200fb_drv_probe() tracing: Remove duplicate ENABLE_EVENT_STR and DISABLE_EVENT_STR macros scsi: csiostor: Fix dereference of null pointer rn pNFS: fix a missing wake up while waiting on NFS_LAYOUT_DRAIN svcrdma: Remove queue-shortening warnings RDMA/core: Fix a couple of obvious typos in comments power: supply: wm97xx_battery: Convert to GPIO descriptor power: supply: bq27xxx: fix wrong errno when bus ops are unsupported power: supply: sbs-battery: Fix use-after-free in power_supply_changed() power: supply: rt9455: Fix use-after-free in power_supply_changed() power: supply: act8945a: Fix use-after-free in power_supply_changed() serial: caif: fix use-after-free in caif_serial ldisc_close() net: atm: fix crash due to unvalidated vcc pointer in sigd_send() procfs: fix missing RCU protection when reading real_parent in do_task_stat() netfilter: nft_set_rbtree: check for partial overlaps in anonymous sets netfilter: nft_set_hash: fix get operation on big endian bonding: only set speed/duplex to unknown, if getting speed failed ucount: check for CAP_SYS_RESOURCE using ns_capable_noaudit() tcp: tcp_tx_timestamp() must look at the rtx queue fat: avoid parent link count underflow in rmdir PCI: Mark 3ware-9650SA Root Port Extended Tags as broken netfilter: nf_conncount: fix tracking of connections from localhost netfilter: nf_conncount: increase the connection clean up limit to 64 netfilter: nf_conncount: make nf_conncount_gc_list() to disable BH wifi: cfg80211: stop NAN and P2P in cfg80211_leave PCI/portdrv: Fix potential resource leak PCI: Do not attempt to set ExtTag for VFs PCI: mediatek: Fix IRQ domain leak when MSI allocation fails Revert "hwmon: (ibmpex) fix use-after-free in high/low store" spi: tools: Add include folder to .gitignore regulator: Flag uncontrollable regulators as always_on regulator: core: Respect off_on_delay at startup smack: /smack/doi: accept previously used values smack: /smack/doi must be > 0 arm64: dts: amlogic: gx: assign the MMC signal clocks ARM: dts: allwinner: sun5i-a13-utoo-p66: delete "power-gpios" property EDAC/i5400: Fix snprintf() limit calculation in calculate_dimm_size() EDAC/i5000: Fix snprintf() size calculation in calculate_dimm_size() pstore/ram: fix buffer overflow in persistent_ram_save_old() sched/rt: Skip currently executing CPU in rto_next_cpu() mfd: wm8350-core: Use IRQF_ONESHOT EDAC/altera: Remove IRQF_ONESHOT hrtimer: Fix trace oddity crypto: cavium - fix dma_free_coherent() size s390/cio: Fix device lifecycle handling in css_alloc_subchannel() PM: sleep: wakeirq: harden dev_pm_clear_wake_irq() against races md/raid10: fix any_working flag handling in raid10_sync_request tpm: st33zp24: Fix missing cleanup on get_burstcount() error tpm: tpm_i2c_infineon: Fix locality leak on get_burstcount() failure gfs2: Add metapath_dibh helper gfs2: Add wrapper for iomap_file_buffered_write fs: add <linux/init_task.h> for 'init_fs' hfsplus: return error when node already exists in hfs_bnode_create auxdisplay: arm-charlcd: fix release_mem_region() size RDMA/umad: Reject negative data_len in ib_umad_write Change-Id: Ice1efa8b2faaaab14d1d1563e5aa6ae36549682b
259 lines
5.7 KiB
C
259 lines
5.7 KiB
C
/*
|
|
* AppArmor security module
|
|
*
|
|
* This file contains AppArmor network mediation
|
|
*
|
|
* Copyright (C) 1998-2008 Novell/SUSE
|
|
* Copyright 2009-2017 Canonical Ltd.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License as
|
|
* published by the Free Software Foundation, version 2 of the
|
|
* License.
|
|
*/
|
|
|
|
#include "include/apparmor.h"
|
|
#include "include/audit.h"
|
|
#include "include/cred.h"
|
|
#include "include/label.h"
|
|
#include "include/net.h"
|
|
#include "include/policy.h"
|
|
#include "include/secid.h"
|
|
|
|
#include "net_names.h"
|
|
|
|
|
|
struct aa_sfs_entry aa_sfs_entry_network[] = {
|
|
AA_SFS_FILE_STRING("af_mask", AA_SFS_AF_MASK),
|
|
{ }
|
|
};
|
|
|
|
static const char * const net_mask_names[] = {
|
|
"unknown",
|
|
"send",
|
|
"receive",
|
|
"unknown",
|
|
|
|
"create",
|
|
"shutdown",
|
|
"connect",
|
|
"unknown",
|
|
|
|
"setattr",
|
|
"getattr",
|
|
"setcred",
|
|
"getcred",
|
|
|
|
"chmod",
|
|
"chown",
|
|
"chgrp",
|
|
"lock",
|
|
|
|
"mmap",
|
|
"mprot",
|
|
"unknown",
|
|
"unknown",
|
|
|
|
"accept",
|
|
"bind",
|
|
"listen",
|
|
"unknown",
|
|
|
|
"setopt",
|
|
"getopt",
|
|
"unknown",
|
|
"unknown",
|
|
|
|
"unknown",
|
|
"unknown",
|
|
"unknown",
|
|
"unknown",
|
|
};
|
|
|
|
|
|
/* audit callback for net specific fields */
|
|
void audit_net_cb(struct audit_buffer *ab, void *va)
|
|
{
|
|
struct common_audit_data *sa = va;
|
|
|
|
audit_log_format(ab, " family=");
|
|
if (address_family_names[sa->u.net->family])
|
|
audit_log_string(ab, address_family_names[sa->u.net->family]);
|
|
else
|
|
audit_log_format(ab, "\"unknown(%d)\"", sa->u.net->family);
|
|
audit_log_format(ab, " sock_type=");
|
|
if (sock_type_names[aad(sa)->net.type])
|
|
audit_log_string(ab, sock_type_names[aad(sa)->net.type]);
|
|
else
|
|
audit_log_format(ab, "\"unknown(%d)\"", aad(sa)->net.type);
|
|
audit_log_format(ab, " protocol=%d", aad(sa)->net.protocol);
|
|
|
|
if (aad(sa)->request & NET_PERMS_MASK) {
|
|
audit_log_format(ab, " requested_mask=");
|
|
aa_audit_perm_mask(ab, aad(sa)->request, NULL, 0,
|
|
net_mask_names, NET_PERMS_MASK);
|
|
|
|
if (aad(sa)->denied & NET_PERMS_MASK) {
|
|
audit_log_format(ab, " denied_mask=");
|
|
aa_audit_perm_mask(ab, aad(sa)->denied, NULL, 0,
|
|
net_mask_names, NET_PERMS_MASK);
|
|
}
|
|
}
|
|
if (aad(sa)->peer) {
|
|
audit_log_format(ab, " peer=");
|
|
aa_label_xaudit(ab, labels_ns(aad(sa)->label), aad(sa)->peer,
|
|
FLAGS_NONE, GFP_ATOMIC);
|
|
}
|
|
}
|
|
|
|
/* Generic af perm */
|
|
int aa_profile_af_perm(struct aa_profile *profile, struct common_audit_data *sa,
|
|
u32 request, u16 family, int type)
|
|
{
|
|
struct aa_perms perms = { };
|
|
unsigned int state;
|
|
__be16 buffer[2];
|
|
|
|
AA_BUG(family >= AF_MAX);
|
|
AA_BUG(type < 0 || type >= SOCK_MAX);
|
|
|
|
if (profile_unconfined(profile))
|
|
return 0;
|
|
state = PROFILE_MEDIATES(profile, AA_CLASS_NET);
|
|
if (!state)
|
|
return 0;
|
|
|
|
buffer[0] = cpu_to_be16(family);
|
|
buffer[1] = cpu_to_be16((u16) type);
|
|
state = aa_dfa_match_len(profile->policy.dfa, state, (char *) &buffer,
|
|
4);
|
|
aa_compute_perms(profile->policy.dfa, state, &perms);
|
|
aa_apply_modes_to_perms(profile, &perms);
|
|
|
|
return aa_check_perms(profile, &perms, request, sa, audit_net_cb);
|
|
}
|
|
|
|
int aa_af_perm(struct aa_label *label, const char *op, u32 request, u16 family,
|
|
int type, int protocol)
|
|
{
|
|
struct aa_profile *profile;
|
|
DEFINE_AUDIT_NET(sa, op, NULL, family, type, protocol);
|
|
|
|
return fn_for_each_confined(label, profile,
|
|
aa_profile_af_perm(profile, &sa, request, family,
|
|
type));
|
|
}
|
|
|
|
static int aa_label_sk_perm(struct aa_label *label, const char *op, u32 request,
|
|
struct sock *sk)
|
|
{
|
|
int error = 0;
|
|
|
|
AA_BUG(!label);
|
|
AA_BUG(!sk);
|
|
|
|
if (!unconfined(label)) {
|
|
struct aa_profile *profile;
|
|
DEFINE_AUDIT_SK(sa, op, sk);
|
|
|
|
error = fn_for_each_confined(label, profile,
|
|
aa_profile_af_sk_perm(profile, &sa, request, sk));
|
|
}
|
|
|
|
return error;
|
|
}
|
|
|
|
int aa_sk_perm(const char *op, u32 request, struct sock *sk)
|
|
{
|
|
struct aa_label *label;
|
|
int error;
|
|
|
|
AA_BUG(!sk);
|
|
AA_BUG(in_interrupt());
|
|
|
|
/* TODO: switch to begin_current_label ???? */
|
|
label = begin_current_label_crit_section();
|
|
error = aa_label_sk_perm(label, op, request, sk);
|
|
end_current_label_crit_section(label);
|
|
|
|
return error;
|
|
}
|
|
|
|
|
|
int aa_sock_file_perm(struct aa_label *label, const char *op, u32 request,
|
|
struct socket *sock)
|
|
{
|
|
AA_BUG(!label);
|
|
|
|
/* sock && sock->sk can be NULL for sockets being set up or torn down */
|
|
if (!sock || !sock->sk)
|
|
return 0;
|
|
|
|
return aa_label_sk_perm(label, op, request, sock->sk);
|
|
}
|
|
|
|
static int apparmor_secmark_init(struct aa_secmark *secmark)
|
|
{
|
|
struct aa_label *label;
|
|
|
|
if (secmark->label[0] == '*') {
|
|
secmark->secid = AA_SECID_WILDCARD;
|
|
return 0;
|
|
}
|
|
|
|
label = aa_label_strn_parse(&root_ns->unconfined->label,
|
|
secmark->label, strlen(secmark->label),
|
|
GFP_ATOMIC, false, false);
|
|
|
|
if (IS_ERR(label))
|
|
return PTR_ERR(label);
|
|
|
|
secmark->secid = label->secid;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int aa_secmark_perm(struct aa_profile *profile, u32 request, u32 secid,
|
|
struct common_audit_data *sa, struct sock *sk)
|
|
{
|
|
int i, ret;
|
|
struct aa_perms perms = { };
|
|
|
|
if (profile->secmark_count == 0)
|
|
return 0;
|
|
|
|
for (i = 0; i < profile->secmark_count; i++) {
|
|
if (!profile->secmark[i].secid) {
|
|
ret = apparmor_secmark_init(&profile->secmark[i]);
|
|
if (ret)
|
|
return ret;
|
|
}
|
|
|
|
if (profile->secmark[i].secid == secid ||
|
|
profile->secmark[i].secid == AA_SECID_WILDCARD) {
|
|
if (profile->secmark[i].deny)
|
|
perms.deny = ALL_PERMS_MASK;
|
|
else
|
|
perms.allow = ALL_PERMS_MASK;
|
|
|
|
if (profile->secmark[i].audit)
|
|
perms.audit = ALL_PERMS_MASK;
|
|
}
|
|
}
|
|
|
|
aa_apply_modes_to_perms(profile, &perms);
|
|
|
|
return aa_check_perms(profile, &perms, request, sa, audit_net_cb);
|
|
}
|
|
|
|
int apparmor_secmark_check(struct aa_label *label, char *op, u32 request,
|
|
u32 secid, struct sock *sk)
|
|
{
|
|
struct aa_profile *profile;
|
|
DEFINE_AUDIT_SK(sa, op, sk);
|
|
|
|
return fn_for_each_confined(label, profile,
|
|
aa_secmark_perm(profile, request, secid,
|
|
&sa, sk));
|
|
}
|