diff options
author | Srinivasarao P <spathi@codeaurora.org> | 2018-04-20 13:04:48 +0530 |
---|---|---|
committer | Srinivasarao P <spathi@codeaurora.org> | 2018-04-20 13:05:36 +0530 |
commit | 0382cccfeeb0206e66e75abbc9aa7fbcc13a9f6c (patch) | |
tree | e4508e5ecf923b46fc3b27a76d4baf4d0aa3b190 /kernel | |
parent | 81a6413ed7a55270dca11bca9bf76b9535e32795 (diff) | |
parent | 89904ccfe22ea5c98adf311711596f1d1fc977b8 (diff) |
Merge android-4.4.128 (89904cc) into msm-4.4
* refs/heads/tmp-89904cc
ANDROID: Add build server config for cuttlefish.
ANDROID: Add defconfig for cuttlefish.
FROMLIST: staging: Android: Add 'vsoc' driver for cuttlefish.
Revert "proc: make oom adjustment files user read-only"
Revert "fixup! proc: make oom adjustment files user read-only"
Linux 4.4.128
Revert "xhci: plat: Register shutdown for xhci_plat"
vrf: Fix use after free and double free in vrf_finish_output
ipv6: the entire IPv6 header chain must fit the first fragment
net/ipv6: Increment OUTxxx counters after netfilter hook
net sched actions: fix dumping which requires several messages to user space
r8169: fix setting driver_data after register_netdev
vti6: better validate user provided tunnel names
ip6_tunnel: better validate user provided tunnel names
ip6_gre: better validate user provided tunnel names
ipv6: sit: better validate user provided tunnel names
ip_tunnel: better validate user provided tunnel names
net: fool proof dev_valid_name()
bonding: process the err returned by dev_set_allmulti properly in bond_enslave
bonding: move dev_mc_sync after master_upper_dev_link in bond_enslave
bonding: fix the err path for dev hwaddr sync in bond_enslave
vlan: also check phy_driver ts_info for vlan's real device
vhost: correctly remove wait queue during poll failure
sky2: Increase D3 delay to sky2 stops working after suspend
sctp: sctp_sockaddr_af must check minimal addr length for AF_INET6
sctp: do not leak kernel memory to user space
pptp: remove a buggy dst release in pptp_connect()
net/sched: fix NULL dereference in the error path of tcf_bpf_init()
netlink: make sure nladdr has correct size in netlink_connect()
net/ipv6: Fix route leaking between VRFs
net: fix possible out-of-bound read in skb_network_protocol()
arp: fix arp_filter on l3slave devices
Kbuild: provide a __UNIQUE_ID for clang
futex: Remove requirement for lock_page() in get_futex_key()
random: use lockless method of accessing and updating f->reg_idx
virtio_net: check return value of skb_to_sgvec in one more location
virtio_net: check return value of skb_to_sgvec always
rxrpc: check return value of skb_to_sgvec always
ipsec: check return value of skb_to_sgvec always
perf tools: Fix copyfile_offset update of output offset
cxgb4vf: Fix SGE FL buffer initialization logic for 64K pages
EDAC, mv64x60: Fix an error handling path
tty: n_gsm: Allow ADM response in addition to UA for control dlci
blk-mq: fix kernel oops in blk_mq_tag_idle()
scsi: libsas: initialize sas_phy status according to response of DISCOVER
scsi: libsas: fix error when getting phy events
scsi: libsas: fix memory leak in sas_smp_get_phy_events()
bcache: segregate flash only volume write streams
bcache: stop writeback thread after detaching
vxlan: dont migrate permanent fdb entries during learn
s390/dasd: fix hanging safe offline
ACPICA: Disassembler: Abort on an invalid/unknown AML opcode
ACPICA: Events: Add runtime stub support for event APIs
cpuidle: dt: Add missing 'of_node_put()'
Bluetooth: Send HCI Set Event Mask Page 2 command only when needed
iio: magnetometer: st_magn_spi: fix spi_device_id table
sparc64: ldc abort during vds iso boot
sctp: fix recursive locking warning in sctp_do_peeloff
bnx2x: Allow vfs to disable txvlan offload
xen: avoid type warning in xchg_xen_ulong
skbuff: only inherit relevant tx_flags
perf tests: Decompress kernel module before objdump
net: emac: fix reset timeout with AR8035 phy
Fix loop device flush before configure v3
MIPS: kprobes: flush_insn_slot should flush only if probe initialised
MIPS: mm: adjust PKMAP location
MIPS: mm: fixed mappings: correct initialisation
perf/core: Correct event creation with PERF_FORMAT_GROUP
e1000e: Undo e1000e_pm_freeze if __e1000_shutdown fails
ARM: imx: Add MXC_CPU_IMX6ULL and cpu_is_imx6ull
net: phy: avoid genphy_aneg_done() for PHYs without clause 22 support
mceusb: sporadic RX truncation corruption fix
cx25840: fix unchecked return values
e1000e: fix race condition around skb_tstamp_tx()
tags: honor COMPILED_SOURCE with apart output directory
perf report: Ensure the perf DSO mapping matches what libdw sees
perf header: Set proper module name when build-id event found
net/mlx4: Check if Granular QoS per VF has been enabled before updating QP qos_vport
net/mlx4: Fix the check in attaching steering rules
sit: reload iphdr in ipip6_rcv
skbuff: return -EMSGSIZE in skb_to_sgvec to prevent overflow
bio-integrity: Do not allocate integrity context for bio w/o data
Fix serial console on SNI RM400 machines
cxgb4: fix incorrect cim_la output for T6
drm/omap: fix tiled buffer stride calculations
mISDN: Fix a sleep-in-atomic bug
qlcnic: Fix a sleep-in-atomic bug in qlcnic_82xx_hw_write_wx_2M and qlcnic_82xx_hw_read_wx_2M
perf trace: Add mmap alias for s390
powerpc/spufs: Fix coredump of SPU contexts
clk: Fix __set_clk_rates error print-string
clk: scpi: fix return type of __scpi_dvfs_round_rate
KVM: SVM: do not zero out segment attributes if segment is unusable or not present
net: freescale: fix potential null pointer dereference
SUNRPC: ensure correct error is reported by xs_tcp_setup_socket()
rtc: interface: Validate alarm-time before handling rollover
rtc: opal: Handle disabled TPO in opal_get_tpo_time()
cxgb4: FW upgrade fixes
net/mlx5: avoid build warning for uniprocessor
arm64: futex: Fix undefined behaviour with FUTEX_OP_OPARG_SHIFT usage
dmaengine: imx-sdma: Handle return value of clk_prepare_enable
powerpc/[booke|4xx]: Don't clobber TCR[WP] when setting TCR[DIE]
ovl: filter trusted xattr for non-admin
hdlcdrv: Fix divide by zero in hdlcdrv_ioctl
wl1251: check return from call to wl1251_acx_arp_ip_filter
ASoC: Intel: sst: Fix the return value of 'sst_send_byte_stream_mrfld()'
gpio: label descriptors using the device name
vfb: fix video mode and line_length being set when loaded
scsi: mpt3sas: Proper handling of set/clear of "ATA command pending" flag.
scsi: libiscsi: Allow sd_shutdown on bad transport
ASoC: Intel: cht_bsw_rt5645: Analog Mic support
media: videobuf2-core: don't go out of the buffer range
hwmon: (ina2xx) Make calibration register value fixed
rds; Reset rs->rs_bound_addr in rds_add_bound() failure path
l2tp: fix missing print session offset info
perf probe: Add warning message if there is unexpected event name
thermal: power_allocator: fix one race condition issue for thermal_instances list
ARM: dts: ls1021a: add "fsl,ls1021a-esdhc" compatible string to esdhc node
net: llc: add lock_sock in llc_ui_bind to avoid a race condition
KVM: nVMX: Fix handling of lmsw instruction
bonding: Don't update slave->link until ready to commit
Input: elan_i2c - clear INT before resetting controller
net: move somaxconn init from sysctl code
tcp: better validation of received ack sequences
ext4: fix off-by-one on max nr_pages in ext4_find_unwritten_pgoff()
fix race in drivers/char/random.c:get_reg()
scsi: bnx2fc: fix race condition in bnx2fc_get_host_stats()
ASoC: rsnd: SSI PIO adjust to 24bit mode
pNFS/flexfiles: missing error code in ff_layout_alloc_lseg()
netfilter: ctnetlink: fix incorrect nf_ct_put during hash resize
libceph: NULL deref on crush_decode() error path
net: ieee802154: fix net_device reference release too early
mlx5: fix bug reading rss_hash_type from CQE
block: fix an error code in add_partition()
selinux: do not check open permission on sockets
net/mlx5: Tolerate irq_set_affinity_hint() failures
sched/numa: Use down_read_trylock() for the mmap_sem
leds: pca955x: Correct I2C Functionality
ray_cs: Avoid reading past end of buffer
ARM: davinci: da8xx: Create DSP device only when assigned memory
md-cluster: fix potential lock issue in add_new_disk
ext4: handle the rest of ext4_mb_load_buddy() ENOMEM errors
iio: hi8435: cleanup reset gpio
iio: hi8435: avoid garbage event at first enable
xfrm: fix state migration copy replay sequence numbers
selftests/powerpc: Fix TM resched DSCR test with some compilers
ath5k: fix memory leak on buf on failed eeprom read
powerpc/mm: Fix virt_addr_valid() etc. on 64-bit hash
scsi: csiostor: fix use after free in csio_hw_use_fwconfig()
sh_eth: Use platform device for printing before register_netdev()
serial: sh-sci: Fix race condition causing garbage during shutdown
serial: 8250: omap: Disable DMA for console UART
USB: ene_usb6250: fix SCSI residue overwriting
net: x25: fix one potential use-after-free issue
USB: ene_usb6250: fix first command execution
usb: chipidea: properly handle host or gadget initialization failure
arp: honour gratuitous ARP _replies_
neighbour: update neigh timestamps iff update is effective
ata: libahci: properly propagate return value of platform_get_irq()
btrfs: fix incorrect error return ret being passed to mapping_set_error
usb: dwc3: keystone: check return value
async_tx: Fix DMA_PREP_FENCE usage in do_async_gen_syndrome()
ipv6: avoid dad-failures for addresses with NODAD
ARM: dts: imx6qdl-wandboard: Fix audio channel swap
x86/tsc: Provide 'tsc=unstable' boot parameter
staging: wlan-ng: prism2mgmt.c: fixed a double endian conversion before calling hfa384x_drvr_setconfig16, also fixes relative sparse warning
ARM: dts: imx53-qsrb: Pulldown PMIC IRQ pin
PowerCap: Fix an error code in powercap_register_zone()
bus: brcmstb_gisb: correct support for 64-bit address output
bus: brcmstb_gisb: Use register offsets with writes too
SMB2: Fix share type handling
vmxnet3: ensure that adapter is in proper state during force_close
KVM: PPC: Book3S PR: Check copy_to/from_user return values
Input: elantech - force relative mode on a certain module
Input: elan_i2c - check if device is there before really probing
netxen_nic: set rcode to the return status from the call to netxen_issue_cmd
net: qca_spi: Fix alignment issues in rx path
blk-mq: NVMe 512B/4K+T10 DIF/DIX format returns I/O error on dd with split op
CIFS: silence lockdep splat in cifs_relock_file()
NFSv4.1: Work around a Linux server bug...
net/mlx4_en: Avoid adding steering rules with invalid ring
s390: move _text symbol to address higher than zero
pidns: disable pid allocation if pid_ns_prepare_proc() is failed in alloc_pid()
drivers/misc/vmw_vmci/vmci_queue_pair.c: fix a couple integer overflow tests
lockd: fix lockd shutdown race
net: ethernet: ti: cpsw: adjust cpsw fifos depth for fullduplex flow control
net: cdc_ncm: Fix TX zero padding
ipmi_ssif: unlock on allocation failure
qlge: Avoid reading past end of buffer
bna: Avoid reading past end of buffer
mac80211: bail out from prep_connection() if a reconfig is ongoing
af_key: Fix slab-out-of-bounds in pfkey_compile_policy.
IB/srpt: Fix abort handling
NFSv4.1: RECLAIM_COMPLETE must handle NFS4ERR_CONN_NOT_BOUND_TO_SESSION
x86/asm: Don't use RBP as a temporary register in csum_partial_copy_generic()
rtc: snvs: fix an incorrect check of return value
md/raid5: make use of spin_lock_irq over local_irq_disable + spin_lock
cfg80211: make RATE_INFO_BW_20 the default
ANDROID: proc: add null check in proc_uid_init
f2fs/fscrypt: updates to v4.17-rc1
Reduce amount of casting in drivers/tty/goldfish.c.
Conflicts:
drivers/staging/android/Kconfig
drivers/staging/android/Makefile
Change-Id: Ic7aa3df76a0312b8d6d84f8a8e11e793311a239a
Signed-off-by: Srinivasarao P <spathi@codeaurora.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/events/core.c | 15 | ||||
-rw-r--r-- | kernel/futex.c | 98 | ||||
-rw-r--r-- | kernel/pid.c | 4 | ||||
-rw-r--r-- | kernel/sched/fair.c | 3 |
4 files changed, 106 insertions, 14 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c index 322f63370038..656d55d30f8d 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -5387,9 +5387,6 @@ static void perf_output_read_one(struct perf_output_handle *handle, __output_copy(handle, values, n * sizeof(u64)); } -/* - * XXX PERF_FORMAT_GROUP vs inherited events seems difficult. - */ static void perf_output_read_group(struct perf_output_handle *handle, struct perf_event *event, u64 enabled, u64 running) @@ -5434,6 +5431,13 @@ static void perf_output_read_group(struct perf_output_handle *handle, #define PERF_FORMAT_TOTAL_TIMES (PERF_FORMAT_TOTAL_TIME_ENABLED|\ PERF_FORMAT_TOTAL_TIME_RUNNING) +/* + * XXX PERF_SAMPLE_READ vs inherited events seems difficult. + * + * The problem is that its both hard and excessively expensive to iterate the + * child list, not to mention that its impossible to IPI the children running + * on another CPU, from interrupt/NMI context. + */ static void perf_output_read(struct perf_output_handle *handle, struct perf_event *event) { @@ -8167,9 +8171,10 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu, local64_set(&hwc->period_left, hwc->sample_period); /* - * we currently do not support PERF_FORMAT_GROUP on inherited events + * We currently do not support PERF_SAMPLE_READ on inherited events. + * See perf_output_read(). */ - if (attr->inherit && (attr->read_format & PERF_FORMAT_GROUP)) + if (attr->inherit && (attr->sample_type & PERF_SAMPLE_READ)) goto err_ns; if (!has_branch_stack(event)) diff --git a/kernel/futex.c b/kernel/futex.c index a09c1dd1f659..760a97da1050 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -470,6 +470,7 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw) unsigned long address = (unsigned long)uaddr; struct mm_struct *mm = current->mm; struct page *page, *page_head; + struct address_space *mapping; int err, ro = 0; /* @@ -555,7 +556,19 @@ again: } #endif - lock_page(page_head); + /* + * The treatment of mapping from this point on is critical. The page + * lock protects many things but in this context the page lock + * stabilizes mapping, prevents inode freeing in the shared + * file-backed region case and guards against movement to swap cache. + * + * Strictly speaking the page lock is not needed in all cases being + * considered here and page lock forces unnecessarily serialization + * From this point on, mapping will be re-verified if necessary and + * page lock will be acquired only if it is unavoidable + */ + + mapping = READ_ONCE(page_head->mapping); /* * If page_head->mapping is NULL, then it cannot be a PageAnon @@ -572,18 +585,31 @@ again: * shmem_writepage move it from filecache to swapcache beneath us: * an unlikely race, but we do need to retry for page_head->mapping. */ - if (!page_head->mapping) { - int shmem_swizzled = PageSwapCache(page_head); + if (unlikely(!mapping)) { + int shmem_swizzled; + + /* + * Page lock is required to identify which special case above + * applies. If this is really a shmem page then the page lock + * will prevent unexpected transitions. + */ + lock_page(page); + shmem_swizzled = PageSwapCache(page) || page->mapping; unlock_page(page_head); put_page(page_head); + if (shmem_swizzled) goto again; + return -EFAULT; } /* * Private mappings are handled in a simple way. * + * If the futex key is stored on an anonymous page, then the associated + * object is the mm which is implicitly pinned by the calling process. + * * NOTE: When userspace waits on a MAP_SHARED mapping, even if * it's a read-only handle, it's expected that futexes attach to * the object not the particular process. @@ -601,16 +627,74 @@ again: key->both.offset |= FUT_OFF_MMSHARED; /* ref taken on mm */ key->private.mm = mm; key->private.address = address; + + get_futex_key_refs(key); /* implies smp_mb(); (B) */ + } else { + struct inode *inode; + + /* + * The associated futex object in this case is the inode and + * the page->mapping must be traversed. Ordinarily this should + * be stabilised under page lock but it's not strictly + * necessary in this case as we just want to pin the inode, not + * update the radix tree or anything like that. + * + * The RCU read lock is taken as the inode is finally freed + * under RCU. If the mapping still matches expectations then the + * mapping->host can be safely accessed as being a valid inode. + */ + rcu_read_lock(); + + if (READ_ONCE(page_head->mapping) != mapping) { + rcu_read_unlock(); + put_page(page_head); + + goto again; + } + + inode = READ_ONCE(mapping->host); + if (!inode) { + rcu_read_unlock(); + put_page(page_head); + + goto again; + } + + /* + * Take a reference unless it is about to be freed. Previously + * this reference was taken by ihold under the page lock + * pinning the inode in place so i_lock was unnecessary. The + * only way for this check to fail is if the inode was + * truncated in parallel so warn for now if this happens. + * + * We are not calling into get_futex_key_refs() in file-backed + * cases, therefore a successful atomic_inc return below will + * guarantee that get_futex_key() will still imply smp_mb(); (B). + */ + if (WARN_ON_ONCE(!atomic_inc_not_zero(&inode->i_count))) { + rcu_read_unlock(); + put_page(page_head); + + goto again; + } + + /* Should be impossible but lets be paranoid for now */ + if (WARN_ON_ONCE(inode->i_mapping != mapping)) { + err = -EFAULT; + rcu_read_unlock(); + iput(inode); + + goto out; + } + key->both.offset |= FUT_OFF_INODE; /* inode-based key */ - key->shared.inode = page_head->mapping->host; + key->shared.inode = inode; key->shared.pgoff = basepage_index(page); + rcu_read_unlock(); } - get_futex_key_refs(key); /* implies MB (B) */ - out: - unlock_page(page_head); put_page(page_head); return err; } diff --git a/kernel/pid.c b/kernel/pid.c index b17263be9082..5fe7cdb6d05f 100644 --- a/kernel/pid.c +++ b/kernel/pid.c @@ -322,8 +322,10 @@ struct pid *alloc_pid(struct pid_namespace *ns) } if (unlikely(is_child_reaper(pid))) { - if (pid_ns_prepare_proc(ns)) + if (pid_ns_prepare_proc(ns)) { + disable_pid_allocation(ns); goto out_free; + } } get_pid_ns(ns); diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 23e37b0674df..f962ab1eb046 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2402,7 +2402,8 @@ void task_numa_work(struct callback_head *work) return; - down_read(&mm->mmap_sem); + if (!down_read_trylock(&mm->mmap_sem)) + return; vma = find_vma(mm, start); if (!vma) { reset_ptenuma_scan(p); |