3.16.46-rc1 review
Subsystems (3)
cover 3.16.46-rc1 review
This is the start of the stable review cycle for the 3.16.46 release. There are 178 patches in this series, which will be posted as responses to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Tue Jul 18 13:56:44 UTC 2017. Anything received after that time might be too late.
A combined patch relative to 3.16.45 will be posted as an additional response to this. A shortlog and diffstat can be found below.
Ben.
-------------
Adrian Hunter (1):
mmc: sdhci: Do not disable interrupts while waiting for clock
[e2ebfb2142acefecc2496e71360f50d25726040b]
Al Viro (1):
p9_client_readdir() fix
[71d6ad08379304128e4bdfaf0b4185d54375423e]Alan Stern (1):
USB: fix linked-list corruption in rh_call_control()
[1633682053a7ee8058e10c76722b9b28e97fb73f]
Alexey Kodanev (1):
udp: avoid ufo handling on IP payload compression packets
[4b3b45edba9222e518a1ec72df841eba3609fe34]
Andrey Ulanov (1):
net: unix: properly re-increment inflight counter of GC discarded candidates
[7df9c24625b9981779afb8fcdbe2bb4765e61147]
Andy Shevchenko (1):
x86/platform/intel-mid: Correct MSI IRQ line for watchdog device
[80354c29025833acd72ddac1ffa21c6cb50128cd]
Ankur Arora (1):
xen/acpi: upload PM state from init-domain to Xen
[1914f0cd203c941bba72f9452c8290324f1ef3dc]
Anssi Hannula (1):
mmc: sdhci-of-arasan: fix incorrect timeout clock
[16681037e75ce08f2980ac5dbb03414429c7a55d]
Anton Blanchard (1):
scsi: lpfc: Add shutdown method for kexec
[85e8a23936ab3442de0c42da97d53b29f004ece1]
Arnd Bergmann (4):
ACPI / power: Avoid maybe-uninitialized warning
[fe8c470ab87d90e4b5115902dd94eced7e3305c3]
IB/qib: fix false-postive maybe-uninitialized warning
[f6aafac184a3e46e919769dd4faa8bf0dc436534]
hwmon: (asus_atk0110) fix uninitialized data access
[a2125d02443e9a4e68bcfd9f8004fa23239e8329]
virtio_balloon: prevent uninitialized variable use
[f0bb2d50dfcc519f06f901aac88502be6ff1df2c]
Ben Hutchings (1):
cpupower: Fix turbo frequency reporting for pre-Sandy Bridge cores
[4cca0457686e4ee1677d69469e4ddfd94d389a80]
Benjamin Herrenschmidt (1):
powerpc: Disable HFSCR[TM] if TM is not supported
[7ed23e1bae8bf7e37fd555066550a00b95a3a98b]
Bjørn Mork (1):
USB: serial: qcserial: add Dell DW5811e
[436ecf5519d892397af133a79ccd38a17c25fa51]
[email protected] (1):
ptrace: fix PTRACE_LISTEN race corrupting task->state
[5402e97af667e35e54177af8f6575518bf251d51]Chris Leech (1):
scsi: libiscsi: add lock around task lists to fix list corruption regression
[6f8830f5bbab16e54f261de187f3df4644a5b977]
Christian Borntraeger (1):
s390/mm: fix CMMA vs KSM vs others
[a8f60d1fadf7b8b54449fcc9d6b15248917478ba]
Dan Carpenter (2):
bna: integer overflow bug in debugfs
[13e2d5187f6b965ba3556caedb914baf81b98ed2]
net: tc35815: move free after the dereference
[11faa7b0359aaf7efd406b7a6a077fda2b037d8e]
Dan Streetman (1):
xen: do not re-use pirq number cached in pci device msi msg data
[c74fd80f2f41d05f350bb478151021f88551afe8]
Dan Williams (1):
USB: serial: option: add Quectel UC15, UC20, EC21, and EC25 modems
[6e9f44eaaef0df7b846e9316fa9ca72a02025d44]
Daniel Borkmann (2):
bpf: try harder on clones when writing into skb
[3697649ff29e0f647565eed04b27a7779c646a22]
perf symbols: Fix symbols__fixup_end heuristic for corner cases
[e7ede72a6d40cb3a30c087142d79381ca8a31dab]
David Ahern (2):
net: ipv6: send unsolicited NA if enabled for all interfaces
[fc1f8f4f310ac65b1337e2d7ba52ae4ff2b7c849]
net: ipv6: set route type for anycast routes
[4ee39733fbecf04cf9f346de2d64788c35028079]
David Hildenbrand (1):
KVM: kvm_io_bus_unregister_dev() should never fail
[90db10434b163e46da413d34db8d0e77404cc645]
David Howells (1):
KEYS: Change the name of the dead type to ".dead" to prevent user access
[c1644fe041ebaf6519f6809146a77c3ead9193af]
Dmitry Torokhov (1):
Input: i8042 - add Clevo P650RS to the i8042 reset list
[7c5bb4ac2b76d2a09256aec8a7d584bf3e2b0466]
Doug Berger (4):
net: bcmgenet: Power up the internal PHY before probing the MII
[6be371b053dc86f11465cc1abce2e99bda0a0574]
net: bcmgenet: correct MIB access of UniMAC RUNT counters
[1ad3d225e5a40ca6c586989b4baaca710544c15a]
net: bcmgenet: correct the RBUF_OVFL_CNT and RBUF_ERR_CNT MIB values
[ffff71328a3c321f7c14cc1edd33577717037744]
net: bcmgenet: synchronize irq0 status between the isr and task
[07c52d6a0b955a8a28834f9354793cfc4b81d0e9]
Edwin Chan (1):
net: bcmgenet: add begin/complete ethtool ops
[89316fa34ab8afac8d693f41a5bc268673f1da15]
Eric Biggers (1):
ext4: mark inode dirty after converting inline directory
[b9cf625d6ecde0d372e23ae022feead72b4228a6]
Eric Dumazet (5):
cx82310_eth: use skb_cow_head() to deal with cloned skbs
[a9e840a2081ed28c2b7caa6a9a0041c950b3c37d]
net: properly release sk_frag.page
[22a0e18eac7a9e986fec76c60fa4a2926d1291e2]
sch_dsmark: fix invalid skb_cow() usage
[aea92fb2e09e29653b023d4254ac9fbf94221538]
smsc75xx: use skb_cow_head() to deal with cloned skbs
[b7c6d2675899cfff0180412c63fc9cbd5bacdb4d]
sr9700: use skb_cow_head() to deal with cloned skbs
[d532c1082f68176363ed766d09bf187616e282fe]
Felipe Balbi (2):
usb: dwc3: gadget: make Set Endpoint Configuration macros safe
[7369090a9fb57c3fc705ce355d2e4523a5a24716]
usb: gadget: function: f_fs: pass companion descriptor along
[2bfa0719ac2a9b2f3c91345873d3cdebd0296ba9]
Florian Fainelli (1):
net: phy: Do not perform software reset for Generic PHY
[0878fff1f42c18e448ab5b8b4f6a3eb32365b5b6]
Florian Westphal (1):
xfrm: policy: init locks early
[c282222a45cb9503cbfbebfdb60491f06ae84b49]
Gao Feng (1):
netfilter: nf_nat_snmp: Fix panic when snmp_trap_helper fails to register
[75c689dca98851d65ef5a27e5ce26b625b68751c]
Germano Percossi (1):
CIFS: remove bad_network_name flag
[a0918f1ce6a43ac980b42b300ec443c154970979]
Guenter Roeck (1):
usb: hub: Fix crash after failure to read BOS descriptor
[7b2db29fbb4e766fcd02207eb2e2087170bd6ebc]
Guillaume Nault (8):
l2tp: don't mask errors in pppol2tp_getsockopt()
[321a52a39189d5e4af542f7dcdc07bba4545cf5d]
l2tp: don't mask errors in pppol2tp_setsockopt()
[364700cf8fd54f54ad08313464105a414e3bccb7]
l2tp: ensure session can't get removed during pppol2tp_session_ioctl()
[57377d63547861919ee634b845c7caa38de4a452]
l2tp: fix duplicate session creation
[dbdbc73b44782e22b3b4b6e8b51e7a3d245f3086]
l2tp: fix race in l2tp_recv_common()
[61b9a047729bb230978178bca6729689d0c50ca2]
l2tp: purge socket queues in the .destruct() callback
[e91793bb615cf6cdd59c0b6749fe173687bb0947]
l2tp: take a reference on sessions used in genetlink handlers
[2777e2ab5a9cf2b4524486c6db1517a6ded25261]
l2tp: take reference on sessions being dumped
[e08293a4ccbcc993ded0fdc46f1e57926b833d63]
Hans de Goede (1):
mmc: sdhci: Disable runtime pm when the sdio_irq is enabled
[923713b357455cfb9aca2cd3429cb0806a724ed2]
Heiko Carstens (1):
s390/uaccess: get_user() should zero on failure (again)
[d09c5373e8e4eaaa09233552cbf75dc4c4f21203]
Herbert Xu (1):
macvlan: Fix device ref leak when purging bc_queue
[f6478218e6edc2a587b8f132f66373baa7b2497c]
Horia Geantă (1):
crypto: caam - fix RNG deinstantiation error checking
[40c98cb57cdbc377456116ad4582c89e329721b0]
Ilya Dryomov (2):
libceph: don't set weight to IN when OSD is destroyed
[b581a5854eee4b7851dedb0f8c2ceb54fb902c06]
libceph: force GFP_NOIO for socket allocations
[633ee407b9d15a75ac9740ba9d3338815e1fcb95]
James Hogan (8):
MIPS: KGDB: Use kernel context for sleeping threads
[162b270c664dca2e0944308e92f9fcc887151a72]
metag/usercopy: Add early abort to copy_to_user
[fb8ea062a8f2e85256e13f55696c5c5f0dfdcc8b]
metag/usercopy: Add missing fixups
[b884a190afcecdbef34ca508ea5ee88bb7c77861]
metag/usercopy: Drop unused macros
[ef62a2d81f73d9cddef14bc3d9097a57010d551c]
metag/usercopy: Fix alignment error checking
[2257211942bbbf6c798ab70b487d7e62f7835a1a]
metag/usercopy: Fix src fixup in from user rapf loops
[2c0b1df88b987a12d95ea1d6beaf01894f3cc725]
metag/usercopy: Set flags before ADDZ
[fd40eee1290ad7add7aa665e3ce6b0f9fe9734b4]
metag/usercopy: Zero rest of buffer from copy_from_user
[563ddc1076109f2b3f88e6d355eab7b6fd4662cb]
James Morse (1):
ACPI / APEI: Add missing synchronize_rcu() on NOTIFY_SCI removal
[7d64f82cceb21e6d95db312d284f5f195e120154]
Jan Beulich (1):
xen-blkback: don't leak stack data via response ring
[089bc0143f489bd3a4578bdff5f4ca68fb26f341]
Jan-Marek Glogowski (1):
Reset TreeId to zero on SMB2 TREE_CONNECT
[806a28efe9b78ffae5e2757e1ee924b8e50c08ab]
Janosch Frank (1):
KVM: s390: Fix guest migration for huge guests resulting in panic
[2e4d88009f57057df7672fa69a32b5224af54d37]
Joerg Roedel (1):
ACPI: Do not create a platform_device for IOAPIC/IOxAPIC
[08f63d97749185fab942a3a47ed80f5bd89b8b7d]
Johan Hovold (20):
Input: cm109 - validate number of endpoints before using them
[ac2ee9ba953afe88f7a673e1c0c839227b1d7891]
Input: hanwang - validate number of endpoints before using them
[ba340d7b83703768ce566f53f857543359aa1b98]
Input: iforce - validate number of endpoints before using them
[59cf8bed44a79ec42303151dd014fdb6434254bb]
Input: ims-pcu - validate number of endpoints before using them
[1916d319271664241b7aa0cd2b05e32bdb310ce9]
Input: kbtab - validate number of endpoints before using them
[cb1b494663e037253337623bf1ef2df727883cb7]
Input: sur40 - validate number of endpoints before using them
[92461f5d723037530c1f36cce93640770037812c]
Input: yealink - validate number of endpoints before using them
[5cc4a1a9f5c179795c8a1f2b0f4361829d6a070e]
USB: idmouse: fix NULL-deref at probe
[b0addd3fa6bcd119be9428996d5d4522479ab240]
USB: iowarrior: fix NULL-deref in write
[de46e56653de7b3b54baa625bd582635008b8d05]
USB: serial: digi_acceleport: fix OOB-event processing
[2e46565cf622dd0534a9d8bffe152a577b48d7aa]
USB: serial: io_ti: fix NULL-deref in interrupt callback
[0b1d250afb8eb9d65afb568bac9b9f9253a82b49]
USB: serial: safe_serial: fix information leak in completion handler
[8c76d7cd520ebffc1ea9ea0850d87a224a50c7f2]
USB: usbtmc: add missing endpoint sanity check
[687e0687f71ec00e0132a21fef802dee88c2f1ad]
USB: uss720: fix NULL-deref at probe
[f259ca3eed6e4b79ac3d5c5c9fb259fb46e86217]
USB: wusbcore: fix NULL-deref at probe
[03ace948a4eb89d1cf51c06afdfc41ebca5fdb27]
isdn/gigaset: fix NULL-deref at probe
[68c32f9c2a36d410aa242e661506e5b2c2764179]
mmc: ushc: fix NULL-deref at probe
[181302dc7239add8ab1449c23ecab193f52ee6ab]
net: wimax/i2400m: fix NULL-deref at probe
[6e526fdff7be4f13b24f929a04c0e9ae6761291e]
uwb: hwa-rc: fix NULL-deref at probe
[daf229b15907fbfdb6ee183aac8ca428cb57e361]
uwb: i1480-dfu: fix NULL-deref at probe
[4ce362711d78a4999011add3115b8f4b0bc25e8c]
Johannes Berg (2):
mac80211: reject ToDS broadcast data frames
[3018e947d7fd536d57e2b550c33e456d921fff8c]
nl80211: fix dumpit error path RTNL deadlocks
[ea90e0dc8cecba6359b481e24d9c37160f6f524f]
John Garry (1):
scsi: libsas: fix ata xfer length
[9702c67c6066f583b629cf037d2056245bb7a8e6]
Jon Mason (1):
ARM: dts: BCM5301X: Correct GIC_PPI interrupt flags
[0c2bf9f95983fe30aa2f6463cb761cd42c2d521a]
Jon Maxwell (1):
dccp/tcp: fix routing redirect race
[45caeaa5ac0b4b11784ac6f932c0ad4c6b67cda0]
Josh Poimboeuf (2):
ACPI: Fix incompatibility with mcount-based function graph tracing
[61b79e16c68d703dde58c25d3935d67210b7d71b]
ftrace/x86: Fix triple fault with graph tracing and suspend-to-ram
[34a477e5297cbaa6ecc6e17c042a866e1cbe80d6]
Juergen Gross (1):
xen, fbfront: fix connecting to backend
[9121b15b5628b38b4695282dc18c553440e0f79b]
Kai-Heng Feng (1):
Input: i8042 - add noloop quirk for Dell Embedded Box PC 3000
[45838660e34d90db8d4f7cbc8fd66e8aff79f4fe]
Kees Cook (2):
fs/exec.c: account for argv/envp pointers
[98da7d08850fb8bdeb395d6368ed15753304aa0c]
mm: Tighten x86 /dev/mem with zeroing reads
[a4866aa812518ed1a37d8ea0c881dc946409de94]
Kinglong Mee (1):
NFSv4: fix a reference leak caused WARNING messages
[366a1569bff3fe14abfdf9285e31e05e091745f5]
Ladi Prosek (1):
virtio_balloon: init 1st buffer in stats vq
[fc8653228c8588a120f6b5dad6983b7b61ff669e]
Laurent Pinchart (1):
usb: gadget: uvc: Fix endianness mismatches
[e102609f107269fbc04af21548e78e99c02b6204]
Maor Gottlieb (1):
net/mlx5: Increase number of max QPs in default profile
[5f40b4ed975c26016cf41953b7510fe90718e21c]
Marcelo Henrique Cerri (1):
s390/decompressor: fix initrd corruption caused by bss clear
[d82c0d12c92705ef468683c9b7a8298dd61ed191]
Martin K. Petersen (2):
scsi: sd: Fix capacity calculation with 32-bit sector_t
[7c856152cb92f8eee2df29ef325a1b1f43161aff]
scsi: sr: Sanity check returned mode data
[a00a7862513089f17209b732f230922f1942e0b9]
Masami Hiramatsu (1):
kprobes/x86: Fix kernel panic when certain exception-handling addresses are probed
[75013fb16f8484898eaa8d0b08fed942d790f029]
Mathias Krause (1):
x86/vdso: Ensure vdso32_enabled gets set to valid values only
[c06989da39cdb10604d572c8c7ea8c8c97f3c483]
Mathias Nyman (1):
xhci: Manually give back cancelled URB if we can't queue it for cancel
[d3519b9d9606991a1305596348b6d690bfa3eb27]
Matt Fleming (1):
sched/loadavg: Avoid loadavg spikes caused by delayed NO_HZ accounting
[6e5f32f7a43f45ee55c401c0b9585eb01f9629a8]
Mauro Carvalho Chehab (1):
[media] dvb-usb: don't use stack for firmware load
[43fab9793c1f44e665b4f98035a14942edf03ddc]
Max Lohrmann (1):
target: Fix VERIFY_16 handling in sbc_parse_cdb
[13603685c1f12c67a7a2427f00b63f39a2b6f7c9]
Michael Ellerman (1):
powerpc/boot: Fix zImage TOC alignment
[97ee351b50a49717543533cfb85b4bf9d88c9680]
Michael Engl (1):
iio: adc: ti_am335x_adc: fix fifo overrun recovery
[e83bb3e6f3efa21f4a9d883a25d0ecd9dfb431e1]
Michael S. Tsirkin (1):
virtio_console: fix uninitialized variable use
[2055997f983c6db7b5c3940ce5f8f822657d5bc3]
Michal Nazarewicz (2):
include/linux/kernel.h: change abs() macro so it uses consistent return type
[8f57e4d930d48217268315898212518d4d3e0773]
kernel.h: make abs() work with 64-bit types
[c8299cb605b27dd5a49f7a69e48fd23e5a206298]
Minchan Kim (1):
zram: do not use copy_page with non-page aligned address
[d72e9a7a93e4f8e9e52491921d99e0c8aa89eb4e]
Murray McAllister (1):
drm/vmwgfx: avoid calling vzalloc with a 0 size in vmw_get_cap_3d_ioctl()
[63774069d9527a1aeaa4aa20e929ef5e8e9ecc38]
Nathan Sullivan (1):
net: phy: handle state correctly in phy_stop_machine
[49d52e8108a21749dc2114b924c907db43358984]
Nicholas Bellinger (3):
iscsi-target: Drop work-around for legacy GlobalSAN initiator
[1c99de981f30b3e7868b8d20ce5479fa1c0fea46]
iscsi-target: Fix TMR reference leak during session shutdown
[efb2ea770bb3b0f40007530bc8b0c22f36e1c5eb]
target/pscsi: Fix TYPE_TAPE + TYPE_MEDIMUM_CHANGER export
[a04e54f2c35823ca32d56afcd5cea5b783e2f51a]
Nicholas Piggin (1):
powerpc/kernel: Use kprobe blacklist for asm functions
[6f698df10cb24d466b9a790b9daedb9e7bcd5d2a]
Nikolaus Schulz (1):
iio: core: Fix IIO_VAL_FRACTIONAL_LOG2 for negative values
[7fd6592d1287046f61bfd3cda3c03cd35be490f7]
Oliver Neukum (1):
ACM gadget: fix endianness in notifications
[cdd7928df0d2efaa3270d711963773a08a4cc8ab]
Oliver O'Halloran (1):
powerpc/64: Fix flush_(d|i)cache_range() called from modules
[8f5f525d5b83f7d76a6baf9c4e94d4bf312ea7f6]
Pan Bian (1):
team: fix memory leaks
[72ec0bc64b9a5d8e0efcb717abfc757746b101b7]
Paolo Abeni (1):
ipv6: move stub initialization after ipv6 setup completion
[b7d6df57516f8e6a1c847b822ec2a62555455f88]
Paul Burton (1):
MIPS: End spinlocks with .insn
[4b5347a24a0f2d3272032c120664b484478455de]
Paul Mackerras (1):
powerpc: Don't try to fix up misaligned load-with-reservation instructions
[48fe9e9488743eec9b7c1addd3c93f12f2123d54]
Pavel Shilovsky (1):
CIFS: Handle mismatched open calls
[38bd49064a1ecb67baad33598e3d824448ab11ec]
Peter Xu (1):
KVM: x86: clear bus pointer when destroyed
[df630b8c1e851b5e265dc2ca9c87222e342c093b]
Peter Zijlstra (4):
futex: Add missing error handling to FUTEX_REQUEUE_PI
[9bbb25afeb182502ca4f2c4f3f88af0681b34cae]
futex: Fix potential use-after-free in FUTEX_REQUEUE_PI
[c236c8e95a3d395b0494e7108f0d41cf36ec107c]
perf/core: Fix event inheritance on fork()
[e7cc4865f0f31698ef2f7aac01a50e78968985b7]
perf/x86: Avoid exposing wrong/stale data in intel_pmu_lbr_read_32()
[f2200ac311302fcdca6556fd0c5127eab6c65a3e]
Raghava Aditya Renukunta (1):
scsi: aacraid: Fix typo in blink status
[934767c56b0d9dbb95a40e9e6e4d9dcdc3a165ad]
Rik van Riel (1):
tracing: Add #undef to fix compile error
[bf7165cfa23695c51998231c4efa080fe1d3548d]
Robert Middleton (1):
gpio:mcp23s08 Fixed missing interrupts
[2cd29f2387be70de9feb4c9f8dbc7c0bd55748ce]
Roger Quadros (1):
usb: gadget: f_uvc: Fix SuperSpeed companion descriptor's wBytesPerInterval
[09424c50b7dff40cb30011c09114404a4656e023]
Sabrina Dubroca (1):
ipv6: make ECMP route replacement less greedy
[67e194007be08d071294456274dd53e0a04fdf90]
Sachin Prabhu (1):
cifs: Do not send echoes before Negotiate is complete
[62a6cfddcc0a5313e7da3e8311ba16226fe0ac10]
Samuel Thibault (1):
usb-core: Add LINEAR_FRAME_INTR_BINTERVAL USB quirk
[3243367b209faed5c320a4e5f9a565ee2a2ba958]
Sebastian Siewior (1):
ubi/upd: Always flush after prepared for an update
[9cd9a21ce070be8a918ffd3381468315a7a76ba6]
Shaohua Li (1):
md/raid1/10: fix potential deadlock
[61eb2b43b99ebdc9bc6bc83d9792257b243e7cb3]
Sinclair Yeh (1):
drm/vmwgfx: Make sure backup_handle is always valid
[07678eca2cf9c9a18584e546c2b2a0d0c9a3150c]
Song Hongyan (1):
iio: hid-sensor-attributes: Fix sensor property setting failure.
[bba6d9e47f3ea894e501f94b086a59ffe28241ac]
Stefan Brüns (1):
[media] dvb-usb-firmware: don't do DMA on stack
[67b0503db9c29b04eadfeede6bebbfe5ddad94ef]
Stefan Wahren (1):
serial: mxs-auart: fix baud rate range
[df57cf6a879502cd6e5559c1f2d6db12128e074f]
Steven Rostedt (2):
ring-buffer: Have ring_buffer_iter_empty() return true when empty
[78f7a45dac2a2d2002f98a3a95f7979867868d73]
tracing: Allocate the snapshot buffer before enabling probe
[df62db5be2e5f070ecd1a5ece5945b590ee112e0]
Suzuki K Poulose (1):
kvm: arm/arm64: Fix locking for kvm_free_stage2_pgd
[8b3405e345b5a098101b0c31b264c812bba045d9]
Sven Eckelmann (1):
batman-adv: Keep fragments equally sized
[1c2bcc766be44467809f1798cd4ceacafe20a852]
Takashi Iwai (6):
ALSA: ctxfi: Fix the incorrect check of dma_set_mask() call
[f363a06642f28caaa78cb6446bbad90c73fe183c]
ALSA: seq: Don't break snd_use_lock_sync() loop by timeout
[4e7655fd4f47c23e5249ea260dc802f909a64611]
ALSA: seq: Fix race during FIFO resize
[2d7d54002e396c180db0c800c1046f0a3c471597]
ALSA: seq: Fix racy cell insertions during snd_seq_pool_done()
[c520ff3d03f0b5db7146d9beed6373ad5d2a5e0e]
ALSA: timer: Fix missing queue indices reset at SNDRV_TIMER_IOCTL_SELECT
[ba3021b2c79b2fa9114f92790a99deb27a65b728]
ALSA: timer: Fix race between read and ioctl
[d11662f4f798b50d8c8743f433842c3e40fe3378]
Theodore Ts'o (1):
ext4: lock the xattr block before checksuming it
[dac7a4b4b1f664934e8b713f529b629f67db313c]
Thomas Gleixner (1):
x86/vdso: Plug race between mapping and ELF header setup
[6fdc6dd90272ce7e75d744f71535cfbd8d77da81]
Thomas Hellstrom (3):
drm/ttm, drm/vmwgfx: Relax permission checking when opening surfaces
[fe25deb7737ce6c0879ccf79c99fa1221d428bf2]
drm/vmwgfx: Remove getparam error message
[53e16798b0864464c5444a204e1bb93ae246c429]
drm/vmwgfx: Type-check lookups of fence objects
[f7652afa8eadb416b23eb57dec6f158529942041]
Thorsten Leemhuis (1):
Input: elantech - add Fujitsu Lifebook E547 to force crc_enabled
[704de489e0e3640a2ee2d0daf173e9f7375582ba]
Uwe Kleine-König (1):
serial: mxs-auart: Fix baudrate calculation
[a6040bc610554c66088fda3608ae5d6307c548e4]
Wei Yongjun (1):
ring-buffer: Fix return value check in test_ringbuffer()
[62277de758b155dc04b78f195a1cb5208c37b2df]
Willy Tarreau (1):
char: lp: fix possible integer overflow in lp_setup()
[3e21f4af170bebf47c187c1ff8bf155583c9f3b1]
Yuejie Shi (1):
af_key: Add lock to key dump
[89e357d83c06b6fac581c3ca7f0ee3ae7e67109e]
Zheng Yan (1):
ceph: fix recursion between ceph_set_acl() and __ceph_setattr()
[8179a101eb5f4ef0ac9a915fcea9a9d3109efa90]
Makefile | 4 +- arch/arm/boot/dts/bcm5301x.dtsi | 4 +- arch/arm/kvm/mmu.c | 10 + arch/metag/include/asm/uaccess.h | 15 +- arch/metag/lib/usercopy.c | 312 ++++++++------------- arch/mips/include/asm/spinlock.h | 8 +- arch/mips/kernel/kgdb.c | 48 +++- arch/powerpc/boot/zImage.lds.S | 1 + arch/powerpc/include/asm/ppc_asm.h | 40 +-- arch/powerpc/kernel/align.c | 27 +- arch/powerpc/kernel/misc_32.S | 4 +- arch/powerpc/kernel/misc_64.S | 7 +- arch/powerpc/kernel/setup_64.c | 9 + arch/s390/boot/compressed/misc.c | 35 +-- arch/s390/include/asm/pgtable.h | 2 + arch/s390/include/asm/uaccess.h | 2 +- arch/s390/mm/pgtable.c | 19 +- arch/x86/include/asm/elf.h | 2 +- arch/x86/kernel/cpu/perf_event_intel_lbr.c | 2 + arch/x86/kernel/ftrace.c | 12 + arch/x86/kernel/kprobes/common.h | 2 +- arch/x86/kernel/kprobes/core.c | 6 +- arch/x86/kernel/kprobes/opt.c | 2 +- arch/x86/mm/init.c | 41 ++- arch/x86/pci/xen.c | 23 +- .../platform/intel-mid/device_libs/platform_wdt.c | 2 +- arch/x86/vdso/vdso32-setup.c | 11 +- drivers/acpi/Makefile | 1 - drivers/acpi/acpi_platform.c | 8 +- drivers/acpi/apei/ghes.c | 1 + drivers/acpi/power.c | 1 + drivers/block/xen-blkback/blkback.c | 23 +- drivers/block/xen-blkback/common.h | 25 +- drivers/block/zram/zram_drv.c | 6 +- drivers/char/lp.c | 6 +- drivers/char/mem.c | 82 ++++-- drivers/char/virtio_console.c | 6 +- drivers/crypto/caam/ctrl.c | 3 +- drivers/gpio/gpio-mcp23s08.c | 60 +++- drivers/gpu/drm/ttm/ttm_object.c | 10 +- drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 79 ++++-- drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c | 4 +- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 4 +- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 26 +- drivers/hwmon/asus_atk0110.c | 3 + drivers/iio/adc/ti_am335x_adc.c | 13 +- .../iio/common/hid-sensors/hid-sensor-attributes.c | 10 + drivers/iio/industrialio-core.c | 16 +- drivers/infiniband/hw/mlx5/main.c | 2 +- drivers/infiniband/hw/qib/qib_iba7322.c | 2 +- drivers/input/joystick/iforce/iforce-usb.c | 3 + drivers/input/misc/cm109.c | 4 + drivers/input/misc/ims-pcu.c | 4 + drivers/input/misc/yealink.c | 4 + drivers/input/mouse/elantech.c | 8 + drivers/input/serio/i8042-x86ia64io.h | 14 + drivers/input/tablet/hanwang.c | 3 + drivers/input/tablet/kbtab.c | 3 + drivers/input/touchscreen/sur40.c | 3 + drivers/isdn/gigaset/bas-gigaset.c | 3 + drivers/md/raid10.c | 18 ++ drivers/media/usb/dvb-usb/dvb-usb-firmware.c | 33 ++- drivers/mmc/host/sdhci-of-arasan.c | 16 +- drivers/mmc/host/sdhci.c | 10 +- drivers/mmc/host/ushc.c | 3 + drivers/mtd/ubi/upd.c | 8 +- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 167 ++++++++--- drivers/net/ethernet/broadcom/genet/bcmgenet.h | 14 +- drivers/net/ethernet/brocade/bna/bnad_debugfs.c | 2 +- drivers/net/ethernet/toshiba/tc35815.c | 2 +- drivers/net/macvlan.c | 11 +- drivers/net/phy/phy.c | 2 +- drivers/net/phy/phy_device.c | 2 +- drivers/net/team/team.c | 8 +- drivers/net/usb/cx82310_eth.c | 7 +- drivers/net/usb/smsc75xx.c | 8 +- drivers/net/usb/sr9700.c | 9 +- drivers/net/wimax/i2400m/usb.c | 3 + drivers/net/wireless/iwlwifi/dvm/calib.c | 2 +- drivers/scsi/aacraid/src.c | 2 +- drivers/scsi/libiscsi.c | 26 +- drivers/scsi/libsas/sas_ata.c | 2 +- drivers/scsi/lpfc/lpfc_init.c | 1 + drivers/scsi/sd.c | 20 +- drivers/scsi/sr.c | 6 +- drivers/target/iscsi/iscsi_target_parameters.c | 16 -- drivers/target/iscsi/iscsi_target_util.c | 12 +- drivers/target/target_core_pscsi.c | 47 +--- drivers/target/target_core_sbc.c | 10 +- drivers/tty/serial/mxs-auart.c | 10 +- drivers/usb/class/usbtmc.c | 9 +- drivers/usb/core/config.c | 10 + drivers/usb/core/hcd.c | 7 +- drivers/usb/core/hub.c | 2 +- drivers/usb/core/quirks.c | 8 + drivers/usb/dwc3/gadget.h | 14 +- drivers/usb/gadget/f_acm.c | 4 +- drivers/usb/gadget/f_fs.c | 15 +- drivers/usb/gadget/f_uvc.c | 12 +- drivers/usb/host/xhci.c | 43 +-- drivers/usb/misc/idmouse.c | 3 + drivers/usb/misc/iowarrior.c | 8 + drivers/usb/misc/uss720.c | 5 + drivers/usb/serial/digi_acceleport.c | 2 +- drivers/usb/serial/io_ti.c | 6 + drivers/usb/serial/option.c | 17 +- drivers/usb/serial/qcserial.c | 2 + drivers/usb/serial/safe_serial.c | 5 + drivers/usb/wusbcore/wa-hc.c | 3 + drivers/uwb/hwa-rc.c | 3 + drivers/uwb/i1480/dfu/usb.c | 3 + drivers/video/fbdev/xen-fbfront.c | 4 +- drivers/virtio/virtio_balloon.c | 4 + drivers/xen/xen-acpi-processor.c | 34 ++- fs/ceph/inode.c | 14 +- fs/cifs/cifsglob.h | 12 +- fs/cifs/cifssmb.c | 4 + fs/cifs/connect.c | 13 +- fs/cifs/smb1ops.c | 10 + fs/cifs/smb2misc.c | 44 +++ fs/cifs/smb2ops.c | 3 + fs/cifs/smb2pdu.c | 9 +- fs/cifs/smb2proto.h | 7 + fs/cifs/smb2transport.c | 58 +++- fs/cifs/transport.c | 2 + fs/exec.c | 28 +- fs/ext4/inline.c | 5 +- fs/ext4/xattr.c | 65 ++--- fs/nfs/nfs4proc.c | 2 - include/drm/ttm/ttm_object.h | 5 +- include/linux/kernel.h | 45 +-- include/linux/kvm_host.h | 4 +- include/linux/phy.h | 4 + include/linux/skbuff.h | 7 + include/linux/usb/quirks.h | 6 + include/scsi/libiscsi.h | 1 + include/trace/events/syscalls.h | 1 + kernel/events/core.c | 5 +- kernel/futex.c | 22 +- kernel/ptrace.c | 14 +- kernel/sched/proc.c | 4 +- kernel/trace/ring_buffer.c | 24 +- kernel/trace/trace.c | 8 +- net/9p/client.c | 4 + net/batman-adv/fragmentation.c | 20 +- net/ceph/messenger.c | 6 + net/ceph/osdmap.c | 1 - net/core/sock.c | 10 +- net/dccp/ipv4.c | 3 +- net/dccp/ipv6.c | 8 +- net/ipv4/ip_output.c | 2 +- net/ipv4/netfilter/nf_nat_snmp_basic.c | 19 +- net/ipv4/tcp_ipv4.c | 3 +- net/ipv6/af_inet6.c | 6 +- net/ipv6/ip6_fib.c | 2 + net/ipv6/ip6_output.c | 2 +- net/ipv6/ndisc.c | 3 +- net/ipv6/route.c | 2 + net/ipv6/tcp_ipv6.c | 8 +- net/key/af_key.c | 46 ++- net/l2tp/l2tp_core.c | 160 ++++++++--- net/l2tp/l2tp_core.h | 9 +- net/l2tp/l2tp_debugfs.c | 10 +- net/l2tp/l2tp_eth.c | 10 +- net/l2tp/l2tp_ip.c | 17 +- net/l2tp/l2tp_ip6.c | 18 +- net/l2tp/l2tp_netlink.c | 46 ++- net/l2tp/l2tp_ppp.c | 101 ++++--- net/mac80211/rx.c | 24 ++ net/sched/act_csum.c | 8 +- net/sched/act_nat.c | 18 +- net/sched/sch_dsmark.c | 10 +- net/unix/garbage.c | 18 +- net/wireless/nl80211.c | 52 ++-- net/xfrm/xfrm_policy.c | 10 +- security/keys/gc.c | 2 +- sound/core/seq/seq_clientmgr.c | 1 + sound/core/seq/seq_fifo.c | 7 + sound/core/seq/seq_lock.c | 9 +- sound/core/seq/seq_memory.c | 17 +- sound/core/seq/seq_memory.h | 1 + sound/core/timer.c | 7 +- sound/pci/ctxfi/cthw20k1.c | 2 +- tools/perf/util/symbol.c | 2 +- tools/power/cpupower/utils/helpers/cpuid.c | 1 + virt/kvm/eventfd.c | 3 +- virt/kvm/kvm_main.c | 40 ++- 187 files changed, 1916 insertions(+), 1048 deletions(-)
Signature · 2 lines
Ben Hutchings If the facts do not conform to your theory, they must be disposed of.
PATCH 1/178 xfrm: policy: init locks early
3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
commit c282222a45cb9503cbfbebfdb60491f06ae84b49 upstream.
Dmitry reports following splat:
INFO: trying to register non-static key.
the code is fine but needs lockdep annotation.
turning off the locking correctness validator.
CPU: 0 PID: 13059 Comm: syz-executor1 Not tainted 4.10.0-rc7-next-20170207 #1 [..] spin_lock_bh include/linux/spinlock.h:304 [inline] xfrm_policy_flush+0x32/0x470 net/xfrm/xfrm_policy.c:963 xfrm_policy_fini+0xbf/0x560 net/xfrm/xfrm_policy.c:3041 xfrm_net_init+0x79f/0x9e0 net/xfrm/xfrm_policy.c:3091 ops_init+0x10a/0x530 net/core/net_namespace.c:115 setup_net+0x2ed/0x690 net/core/net_namespace.c:291 copy_net_ns+0x26c/0x530 net/core/net_namespace.c:396 create_new_namespaces+0x409/0x860 kernel/nsproxy.c:106 unshare_nsproxy_namespaces+0xae/0x1e0 kernel/nsproxy.c:205 SYSC_unshare kernel/fork.c:2281 [inline]
Problem is that when we get error during xfrm_net_init we will call xfrm_policy_fini which will acquire xfrm_policy_lock before it was initialized. Just move it around so locks get set up first.
--- net/xfrm/xfrm_policy.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
net/xfrm/xfrm_policy.c +5 -5
@@ -2878,6 +2878,11 @@ static int __net_init xfrm_net_init(stru {int rv; +/* Initialize the per-net locks here */ +spin_lock_init (&net->xfrm.xfrm_state_lock); +rwlock_init (&net->xfrm.xfrm_policy_lock); +mutex_init (&net->xfrm.xfrm_cfg_mutex); + rv =xfrm_statistics_init (net);if (rv <0 ) goto out_statistics;
@@ -2894,11 +2899,6 @@ static int __net_init xfrm_net_init(struif (rv <0 ) goto out; -/* Initialize the per-net locks here */ -spin_lock_init (&net->xfrm.xfrm_state_lock); -rwlock_init (&net->xfrm.xfrm_policy_lock); -mutex_init (&net->xfrm.xfrm_cfg_mutex); -return 0 ; out:
PATCH 2/178 xen: do not re-use pirq number cached in pci device msi msg data
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dan Streetman <[email protected]>
commit c74fd80f2f41d05f350bb478151021f88551afe8 upstream.
Revert the main part of commit:af42b8d12f8a ("xen: fix MSI setup and teardown for PV on HVM guests")
That commit introduced reading the pci device's msi message data to see if a pirq was previously configured for the device's msi/msix, and re-use that pirq. At the time, that was the correct behavior. However, a later change to Qemu caused it to call into the Xen hypervisor to unmap all pirqs for a pci device, when the pci device disables its MSI/MSIX vectors; specifically the Qemu commit:c976437c7dba9c7444fb41df45468968aaa326ad
("qemu-xen: free all the pirqs for msi/msix when driver unload")
Once Qemu added this pirq unmapping, it was no longer correct for the kernel to re-use the pirq number cached in the pci device msi message data. All Qemu releases since 2.1.0 contain the patch that unmaps the pirqs when the pci device disables its MSI/MSIX vectors.
This bug is causing failures to initialize multiple NVMe controllers under Xen, because the NVMe driver sets up a single MSIX vector for each controller (concurrently), and then after using that to talk to the controller for some configuration data, it disables the single MSIX vector and re-configures all the MSIX vectors it needs. So the MSIX setup code tries to re-use the cached pirq from the first vector for each controller, but the hypervisor has already given away that pirq to another controller, and its initialization fails.
This is discussed in more detail at:
https://lists.xen.org/archives/html/xen-devel/2017-01/msg00447.html
--- arch/x86/pci/xen.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-)
arch/x86/pci/xen.c +7 -16
@@ -228,23 +228,14 @@ static int xen_hvm_setup_msi_irqs(structreturn 1 ;list_for_each_entry (msidesc, &dev->msi_list, list) { -__read_msi_msg (msidesc, &msg); - pirq =MSI_ADDR_EXT_DEST_ID (msg.address_hi) | - ((msg.address_lo >>MSI_ADDR_DEST_ID_SHIFT ) &0xff ); -if (msg.data !=XEN_PIRQ_MSI_DATA || -xen_irq_from_pirq (pirq) <0 ) { - pirq =xen_allocate_pirq_msi (dev, msidesc); -if (pirq <0 ) { - irq = -ENODEV ; - goto error; - } -xen_msi_compose_msg (dev, pirq, &msg); -__write_msi_msg (msidesc, &msg); -dev_dbg (&dev->dev,"xen: msi bound to pirq=%d\n" , pirq); - }else { -dev_dbg (&dev->dev, -"xen: msi already bound to pirq=%d\n" , pirq); + pirq =xen_allocate_pirq_msi (dev, msidesc); +if (pirq <0 ) { + irq = -ENODEV ; + goto error; } +xen_msi_compose_msg (dev, pirq, &msg); +__write_msi_msg (msidesc, &msg); +dev_dbg (&dev->dev,"xen: msi bound to pirq=%d\n" , pirq); irq = xen_bind_pirq_msi_to_irq(dev, msidesc, pirq, (type == PCI_CAP_ID_MSI) ? nvec : 1, (type == PCI_CAP_ID_MSIX) ?
PATCH 3/178 scsi: libiscsi: add lock around task lists to fix list corruption regression
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Chris Leech <[email protected]>
commit 6f8830f5bbab16e54f261de187f3df4644a5b977 upstream.
There's a rather long standing regression from the commit "libiscsi:
Reduce locking contention in fast path"
Depending on iSCSI target behavior, it's possible to hit the case in iscsi_complete_task where the task is still on a pending list (!list_empty(&task->running)). When that happens the task is removed from the list while holding the session back_lock, but other task list modification occur under the frwd_lock. That leads to linked list corruption and eventually a panicked system.
Rather than back out the session lock split entirely, in order to try and keep some of the performance gains this patch adds another lock to maintain the task lists integrity.
Major enterprise supported kernels have been backing out the lock split for while now, thanks to the efforts at IBM where a lab setup has the most reliable reproducer I've seen on this issue. This patch has been tested there successfully.
--- drivers/scsi/libiscsi.c | 26 +++++++++++++++++++++++++- include/scsi/libiscsi.h | 1 + 2 files changed, 26 insertions(+), 1 deletion(-)
drivers/scsi/libiscsi.c +25 -1
@@ -560,8 +560,12 @@ static void iscsi_complete_task(struct iWARN_ON_ONCE (task->state ==ISCSI_TASK_FREE ); task->state = state; -if (!list_empty (&task->running)) +spin_lock_bh (&conn->taskqueuelock); +if (!list_empty (&task->running)) { +pr_debug_once ("%s while task on list" , __func__);list_del_init (&task->running); + } +spin_unlock_bh (&conn->taskqueuelock);if (conn->task == task) conn->task =NULL ;
@@ -783,7 +787,9 @@ __iscsi_conn_send_pdu(struct iscsi_connif (session->tt->xmit_task (task)) goto free_task; }else { +spin_lock_bh (&conn->taskqueuelock);list_add_tail (&task->running, &conn->mgmtqueue); +spin_unlock_bh (&conn->taskqueuelock);iscsi_conn_queue_work (conn); }
@@ -1474,8 +1480,10 @@ void iscsi_requeue_task(struct iscsi_tas* this may be on the requeue list already if the xmit_task callout * is handling the r2ts while we are adding new ones */ +spin_lock_bh (&conn->taskqueuelock);if (list_empty (&task->running))list_add_tail (&task->running, &conn->requeue); +spin_unlock_bh (&conn->taskqueuelock);iscsi_conn_queue_work (conn); }EXPORT_SYMBOL_GPL (iscsi_requeue_task);
@@ -1512,22 +1520,26 @@ static int iscsi_data_xmit(struct iscsi_* only have one nop-out as a ping from us and targets should not * overflow us with nop-ins */ +spin_lock_bh (&conn->taskqueuelock); check_mgmt:while (!list_empty (&conn->mgmtqueue)) { conn->task =list_entry (conn->mgmtqueue.next, struct iscsi_task, running);list_del_init (&conn->task->running); +spin_unlock_bh (&conn->taskqueuelock);if (iscsi_prep_mgmt_task (conn, conn->task)) {/* regular RX path uses back_lock */ spin_lock_bh (&conn->session->back_lock);__iscsi_put_task (conn->task);spin_unlock_bh (&conn->session->back_lock); conn->task =NULL ; +spin_lock_bh (&conn->taskqueuelock);continue ; } rc =iscsi_xmit_task (conn);if (rc) goto done; +spin_lock_bh (&conn->taskqueuelock); }/* process pending command queue */
@@ -1535,19 +1547,24 @@ check_mgmt: conn->task = list_entry(conn->cmdqueue.next, struct iscsi_task, running);list_del_init (&conn->task->running); +spin_unlock_bh (&conn->taskqueuelock);if (conn->session->state ==ISCSI_STATE_LOGGING_OUT ) {fail_scsi_task (conn->task,DID_IMM_RETRY ); +spin_lock_bh (&conn->taskqueuelock);continue ; } rc =iscsi_prep_scsi_cmd_pdu (conn->task);if (rc) {if (rc == -ENOMEM || rc == -EACCES ) { +spin_lock_bh (&conn->taskqueuelock);list_add_tail (&conn->task->running, &conn->cmdqueue); conn->task =NULL ; +spin_unlock_bh (&conn->taskqueuelock); goto done; }else fail_scsi_task (conn->task,DID_ABORT ); +spin_lock_bh (&conn->taskqueuelock);continue ; } rc =iscsi_xmit_task (conn);
@@ -1558,6 +1575,7 @@ check_mgmt:* we need to check the mgmt queue for nops that need to * be sent to aviod starvation */ +spin_lock_bh (&conn->taskqueuelock);if (!list_empty (&conn->mgmtqueue)) goto check_mgmt; }
@@ -1577,12 +1595,15 @@ check_mgmt: conn->task = task;list_del_init (&conn->task->running); conn->task->state =ISCSI_TASK_RUNNING ; +spin_unlock_bh (&conn->taskqueuelock); rc =iscsi_xmit_task (conn);if (rc) goto done; +spin_lock_bh (&conn->taskqueuelock);if (!list_empty (&conn->mgmtqueue)) goto check_mgmt; } +spin_unlock_bh (&conn->taskqueuelock);spin_unlock_bh (&conn->session->frwd_lock);return -ENODATA ;
@@ -1738,7 +1759,9 @@ int iscsi_queuecommand(struct Scsi_Host goto prepd_reject; } }else { +spin_lock_bh (&conn->taskqueuelock);list_add_tail (&task->running, &conn->cmdqueue); +spin_unlock_bh (&conn->taskqueuelock);iscsi_conn_queue_work (conn); }
@@ -2917,6 +2940,7 @@ iscsi_conn_setup(struct iscsi_cls_sessioINIT_LIST_HEAD (&conn->mgmtqueue);INIT_LIST_HEAD (&conn->cmdqueue);INIT_LIST_HEAD (&conn->requeue); +spin_lock_init (&conn->taskqueuelock);INIT_WORK (&conn->xmitwork, iscsi_xmitworker);/* allocate login_task used for the login/text sequences */
include/scsi/libiscsi.h +1 -0
@@ -196,6 +196,7 @@ struct iscsi_conn {struct iscsi_task *task;/* xmit task in progress */ /* xmit */ +spinlock_t taskqueuelock;/* protects the next three lists */ struct list_head mgmtqueue;/* mgmt (control) xmit queue */ struct list_head cmdqueue;/* data-path cmd queue */ struct list_head requeue;/* tasks needing another run */
PATCH 4/178 kprobes/x86: Fix kernel panic when certain exception-handling addresses are probed
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu <[email protected]>
commit 75013fb16f8484898eaa8d0b08fed942d790f029 upstream.
Fix to the exception table entry check by using probed address instead of the address of copied instruction.
This bug may cause unexpected kernel panic if user probe an address where an exception can happen which should be fixup by __ex_table (e.g. copy_from_user.)
Unless user puts a kprobe on such address, this doesn't cause any problem.
This bug has been introduced years ago, by commit:
464846888d9a ("x86/kprobes: Fix a bug which can modify kernel code permanently").
--- arch/x86/kernel/kprobes/common.h | 2 +- arch/x86/kernel/kprobes/core.c | 6 +++--- arch/x86/kernel/kprobes/opt.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
arch/x86/kernel/kprobes/common.h +1 -1
@@ -67,7 +67,7 @@#endif /* Ensure if the instruction can be boostable */ -extern int can_boost (kprobe_opcode_t *instruction); +extern int can_boost (kprobe_opcode_t *instruction,void *addr);/* Recover instruction if given address is probed */ extern unsigned long recover_probed_instruction (kprobe_opcode_t *buf,unsigned long addr);
arch/x86/kernel/kprobes/core.c +3 -3
@@ -163,12 +163,12 @@ NOKPROBE_SYMBOL(skip_prefixes);* Returns non-zero if opcode is boostable. * RIP relative instructions are adjusted at copying time in 64 bits mode */ -int can_boost (kprobe_opcode_t *opcodes) +int can_boost (kprobe_opcode_t *opcodes,void *addr) {kprobe_opcode_t opcode;kprobe_opcode_t *orig_opcodes = opcodes; -if (search_exception_tables ((unsigned long )opcodes)) +if (search_exception_tables ((unsigned long )addr))return 0 ;/* Page fault may occur on this address. */ retry:
@@ -385,7 +385,7 @@ static int arch_copy_kprobe(struct kprob* __copy_instruction can modify the displacement of the instruction, * but it doesn't affect boostable check. */ -if (can_boost (p->ainsn.insn)) +if (can_boost (p->ainsn.insn, p->addr)) p->ainsn.boostable =0 ;else p->ainsn.boostable =-1 ;
arch/x86/kernel/kprobes/opt.c +1 -1
@@ -177,7 +177,7 @@ static int copy_optimized_instructions(uwhile (len <RELATIVEJUMP_SIZE ) { ret =__copy_instruction (dest + len, src + len); -if (!ret || !can_boost (dest + len)) +if (!ret || !can_boost (dest + len, src + len))return -EINVAL ; len += ret; }
PATCH 5/178 KVM: s390: Fix guest migration for huge guests resulting in panic
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Janosch Frank <[email protected]>
commit 2e4d88009f57057df7672fa69a32b5224af54d37 upstream.
While we can technically not run huge page guests right now, we can setup a guest with huge pages. Trying to migrate it will trigger a VM_BUG_ON and, if the kernel is not configured to panic on a BUG, it will happily try to work on non-existing page table entries.
With this patch, we always return "dirty" if we encounter a large page when migrating. This at least fixes the immediate problem until we have proper handling for both kind of pages.
[bwh: Backported to 3.16:
- Use respectively gmap->mm, address and pte instead of mm, addr and ptep
- Adjust context]
--- arch/s390/mm/pgtable.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
arch/s390/mm/pgtable.c +18 -1
@@ -1411,11 +1411,28 @@ EXPORT_SYMBOL_GPL(s390_enable_skey);*/ bool gmap_test_and_clear_dirty (unsigned long address,struct gmap *gmap) { +pgd_t *pgd; +pud_t *pud; +pmd_t *pmd;pte_t *pte;spinlock_t *ptl;bool dirty = false; - pte =get_locked_pte (gmap->mm, address, &ptl); + pgd =pgd_offset (gmap->mm, address); + pud =pud_alloc (gmap->mm, pgd, address); +if (!pud) +return false; + pmd =pmd_alloc (gmap->mm, pud, address); +if (!pmd) +return false; +/* We can't run guests backed by huge pages, but userspace can +* still set them up and then try to migrate them without any +* migration support. +*/ +if (pmd_large (*pmd)) +return true; + + pte =pte_alloc_map_lock (gmap->mm, pmd, address, &ptl);if (unlikely (!pte))return false;
PATCH 6/178 tracing: Add #undef to fix compile error
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Rik van Riel <[email protected]>
commit bf7165cfa23695c51998231c4efa080fe1d3548d upstream.
There are several trace include files that define TRACE_INCLUDE_FILE.
Include several of them in the same .c file (as I currently have in some code I am working on), and the compile will blow up with a "warning: "TRACE_INCLUDE_FILE" redefined #define TRACE_INCLUDE_FILE syscalls"
Every other include file in include/trace/events/ avoids that issue by having a #undef TRACE_INCLUDE_FILE before the #define; syscalls.h should have one, too.
--- include/trace/events/syscalls.h | 1 + 1 file changed, 1 insertion(+)
include/trace/events/syscalls.h +1 -0
@@ -1,5 +1,6 @@#undef TRACE_SYSTEM#define TRACE_SYSTEM raw_syscalls +#undef TRACE_INCLUDE_FILE#define TRACE_INCLUDE_FILE syscalls#if !defined(_TRACE_EVENTS_SYSCALLS_H) || defined(TRACE_HEADER_MULTI_READ )
PATCH 7/178 batman-adv: Keep fragments equally sized
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit 1c2bcc766be44467809f1798cd4ceacafe20a852 upstream.
The batman-adv fragmentation packets have the design problem that they cannot be refragmented and cannot handle padding by the underlying link. The latter often leads to problems when networks are incorrectly configured and don't use a common MTU.
The sender could for example fragment a 1271 byte frame (plus external ethernet header (14) and batadv unicast header (10)) to fit in a 1280 bytes large MTU of the underlying link (max. 1294 byte frames). This would create a 1294 bytes large frame (fragment 2) and a 55 bytes large frame (fragment 1). The extra 54 bytes are the fragment header (20) added to each fragment and the external ethernet header (14) for the second fragment.
Let us assume that the next hop is then not able to transport 1294 bytes to its next hop. The 1294 byte large frame will be dropped but the 55 bytes large fragment will still be forwarded to its destination.
Or let us assume that the underlying hardware requires that each frame has a minimum size (e.g. 60 bytes). Then it will pad the 55 bytes frame to 60 bytes. The receiver of the 60 bytes frame will no longer be able to correctly assemble the two frames together because it is not aware that 5 bytes of the 60 bytes frame are padding and don't belong to the reassembled frame.
This can partly be avoided by splitting frames more equally. In this example, the 675 and 674 bytes large fragment frames could both potentially reach its destination without being too large or too small.
--- net/batman-adv/fragmentation.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
net/batman-adv/fragmentation.c +13 -7
@@ -377,7 +377,7 @@ out:* batadv_frag_create - create a fragment from skb * @skb: skb to create fragment from * @frag_head: header to use in new fragment -* @mtu: size of new fragment +* @fragment_size: size of new fragment * * Split the passed skb into two fragments: A new one with size matching the * passed mtu and the old one with the rest. The new skb contains data from the
@@ -387,11 +387,11 @@ out:*/ static struct sk_buff *batadv_frag_create (struct sk_buff *skb,struct batadv_frag_packet *frag_head, -unsigned int mtu) +unsigned int fragment_size) {struct sk_buff *skb_fragment;unsigned header_size =sizeof (*frag_head); -unsigned fragment_size = mtu - header_size; +unsigned int mtu = fragment_size + header_size; skb_fragment =netdev_alloc_skb (NULL , mtu +ETH_HLEN );if (!skb_fragment)
@@ -429,7 +429,7 @@ bool batadv_frag_send_packet(struct sk_bstruct sk_buff *skb_fragment;unsigned mtu = neigh_node->if_incoming->net_dev->mtu;unsigned header_size =sizeof (frag_header); -unsigned max_fragment_size, max_packet_size; +unsigned int max_fragment_size, num_fragments;bool ret = false;/* To avoid merge and refragmentation at next-hops we never send
@@ -437,10 +437,15 @@ bool batadv_frag_send_packet(struct sk_b*/ mtu =min_t (unsigned, mtu,BATADV_FRAG_MAX_FRAG_SIZE ); max_fragment_size = mtu - header_size; - max_packet_size = max_fragment_size *BATADV_FRAG_MAX_FRAGMENTS ; + +if (skb->len ==0 || max_fragment_size ==0 ) +return -EINVAL ; + + num_fragments = (skb->len -1 ) / max_fragment_size +1 ; + max_fragment_size = (skb->len -1 ) / num_fragments +1 ;/* Don't even try to fragment, if we need more than 16 fragments */ -if (skb->len > max_packet_size) +if (num_fragments >BATADV_FRAG_MAX_FRAGMENTS ) goto out_err; bat_priv = orig_node->bat_priv;
@@ -465,7 +470,8 @@ bool batadv_frag_send_packet(struct sk_bif (unlikely (frag_header.no ==BATADV_FRAG_MAX_FRAGMENTS -1 )) goto out_err; - skb_fragment =batadv_frag_create (skb, &frag_header, mtu); + skb_fragment =batadv_frag_create (skb, &frag_header, + max_fragment_size);if (!skb_fragment) goto out_err;
PATCH 8/178 ARM: dts: BCM5301X: Correct GIC_PPI interrupt flags
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jon Mason <[email protected]>
commit 0c2bf9f95983fe30aa2f6463cb761cd42c2d521a upstream.
GIC_PPI flags were misconfigured for the timers, resulting in errors like:
[ 0.000000] GIC: PPI11 is secure or misconfigured
Changing them to being edge triggered corrects the issue
--- arch/arm/boot/dts/bcm5301x.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/boot/dts/bcm5301x.dtsi +2 -2
@@ -52,14 +52,14 @@ timer@0200 { compatible = "arm,cortex-a9-global-timer"; reg = <0x0200 0x100>; - interrupts = <GIC_PPI 11 IRQ_TYPE_LEVEL_HIGH>; + interrupts = <GIC_PPI 11 IRQ_TYPE_EDGE_RISING>; clocks = <&clk_periph>; }; local-timer@0600 { compatible = "arm,cortex-a9-twd-timer"; reg = <0x0600 0x100>; - interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_HIGH>; + interrupts = <GIC_PPI 13 IRQ_TYPE_EDGE_RISING>; clocks = <&clk_periph>; };
PATCH 9/178 net: phy: Do not perform software reset for Generic PHY
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
commit 0878fff1f42c18e448ab5b8b4f6a3eb32365b5b6 upstream.
The Generic PHY driver is a catch-all PHY driver and it should preserve whatever prior initialization has been done by boot loader or firmware agents. For specific PHY device configuration it is expected that a specialized PHY driver would take over that role.
Resetting the generic PHY was a bad idea that has lead to several complaints and downstream workarounds e.g: in OpenWrt/LEDE so restore the behavior prior to 87aa9f9c61ad ("net: phy: consolidate PHY reset in phy_init_hw()").
--- drivers/net/phy/phy_device.c | 2 +- include/linux/phy.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/net/phy/phy_device.c +1 -1
@@ -1339,7 +1339,7 @@ static struct phy_driver genphy_driver[] .phy_id = 0xffffffff, .phy_id_mask = 0xffffffff, .name = "Generic PHY", - .soft_reset = genphy_soft_reset, + .soft_reset = genphy_no_soft_reset, .config_init = genphy_config_init, .features =PHY_GBIT_FEATURES |SUPPORTED_MII | SUPPORTED_AUI | SUPPORTED_FIBRE |
include/linux/phy.h +4 -0
@@ -692,6 +692,10 @@ int genphy_read_status(struct phy_deviceint genphy_suspend (struct phy_device *phydev);int genphy_resume (struct phy_device *phydev);int genphy_soft_reset (struct phy_device *phydev); +static inline int genphy_no_soft_reset (struct phy_device *phydev) +{ +return 0 ; +}void phy_driver_unregister (struct phy_driver *drv);void phy_drivers_unregister (struct phy_driver *drv,int n);int phy_driver_register (struct phy_driver *new_driver);
PATCH 10/178 usb: dwc3: gadget: make Set Endpoint Configuration macros safe
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Felipe Balbi <[email protected]>
commit 7369090a9fb57c3fc705ce355d2e4523a5a24716 upstream.
Some gadget drivers are bad, bad boys. We notice that ADB was passing bad Burst Size which caused top bits of param0 to be overwritten which confused DWC3 when running this command.
In order to avoid future issues, we're going to make sure values passed by macros are always safe for the controller. Note that ADB still needs a fix to *not* pass bad values.
--- drivers/usb/dwc3/gadget.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/usb/dwc3/gadget.h +7 -7
@@ -28,23 +28,23 @@ struct dwc3;#define gadget_to_dwc (g) (container_of(g, struct dwc3, gadget))/* DEPCFG parameter 1 */ -#define DWC3_DEPCFG_INT_NUM (n) ((n) << 0) +#define DWC3_DEPCFG_INT_NUM (n) (((n) & 0x1f) << 0)#define DWC3_DEPCFG_XFER_COMPLETE_EN (1 << 8)#define DWC3_DEPCFG_XFER_IN_PROGRESS_EN (1 << 9)#define DWC3_DEPCFG_XFER_NOT_READY_EN (1 << 10)#define DWC3_DEPCFG_FIFO_ERROR_EN (1 << 11)#define DWC3_DEPCFG_STREAM_EVENT_EN (1 << 13) -#define DWC3_DEPCFG_BINTERVAL_M1 (n) ((n) << 16) +#define DWC3_DEPCFG_BINTERVAL_M1 (n) (((n) & 0xff) << 16)#define DWC3_DEPCFG_STREAM_CAPABLE (1 << 24) -#define DWC3_DEPCFG_EP_NUMBER (n) ((n) << 25) +#define DWC3_DEPCFG_EP_NUMBER (n) (((n) & 0x1f) << 25)#define DWC3_DEPCFG_BULK_BASED (1 << 30)#define DWC3_DEPCFG_FIFO_BASED (1 << 31)/* DEPCFG parameter 0 */ -#define DWC3_DEPCFG_EP_TYPE (n) ((n) << 1) -#define DWC3_DEPCFG_MAX_PACKET_SIZE (n) ((n) << 3) -#define DWC3_DEPCFG_FIFO_NUMBER (n) ((n) << 17) -#define DWC3_DEPCFG_BURST_SIZE (n) ((n) << 22) +#define DWC3_DEPCFG_EP_TYPE (n) (((n) & 0x3) << 1) +#define DWC3_DEPCFG_MAX_PACKET_SIZE (n) (((n) & 0x7ff) << 3) +#define DWC3_DEPCFG_FIFO_NUMBER (n) (((n) & 0x1f) << 17) +#define DWC3_DEPCFG_BURST_SIZE (n) (((n) & 0xf) << 22)#define DWC3_DEPCFG_DATA_SEQ_NUM (n) ((n) << 26)/* This applies for core versions earlier than 1.94a */ #define DWC3_DEPCFG_IGN_SEQ_NUM (1 << 31)
PATCH 11/178 usb: gadget: function: f_fs: pass companion descriptor along
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Felipe Balbi <[email protected]>
commit 2bfa0719ac2a9b2f3c91345873d3cdebd0296ba9 upstream.
If we're dealing with SuperSpeed endpoints, we need to make sure to pass along the companion descriptor and initialize fields needed by the Gadget API. Eventually, f_fs.c should be converted to use config_ep_by_speed() like all other functions, though.
--- drivers/usb/gadget/f_fs.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/usb/gadget/f_fs.c +13 -2
@@ -1619,11 +1619,14 @@ static int ffs_func_eps_enable(struct ffspin_lock_irqsave (&func->ffs->eps_lock, flags); do { struct usb_endpoint_descriptor *ds; + struct usb_ss_ep_comp_descriptor *comp_desc = NULL; + int needs_comp_desc = false; int desc_idx; - if (ffs->gadget->speed == USB_SPEED_SUPER) + if (ffs->gadget->speed == USB_SPEED_SUPER) { desc_idx = 2; - else if (ffs->gadget->speed == USB_SPEED_HIGH) + needs_comp_desc = true; + } else if (ffs->gadget->speed == USB_SPEED_HIGH) desc_idx = 1; else desc_idx = 0;
@@ -1640,6 +1643,14 @@ static int ffs_func_eps_enable(struct ff ep->ep->driver_data = ep; ep->ep->desc = ds; + + comp_desc = (struct usb_ss_ep_comp_descriptor *)(ds + +USB_DT_ENDPOINT_SIZE ); + ep->ep->maxburst = comp_desc->bMaxBurst +1 ; + +if (needs_comp_desc) + ep->ep->comp_desc = comp_desc; + ret =usb_ep_enable (ep->ep);if (likely (!ret)) { epfile->ep = ep;
PATCH 12/178 USB: serial: digi_acceleport: fix OOB-event processing
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 2e46565cf622dd0534a9d8bffe152a577b48d7aa upstream.
A recent change claimed to fix an off-by-one error in the OOB-port completion handler, but instead introduced such an error. This could specifically led to modem-status changes going unnoticed, effectively breaking TIOCMGET.
Note that the offending commit fixes a loop-condition underflow and is marked for stable, but should not be backported without this fix.
check")
--- drivers/usb/serial/digi_acceleport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/serial/digi_acceleport.c +1 -1
@@ -1501,7 +1501,7 @@ static int digi_read_oob_callback(structreturn -1 ;/* handle each oob command */ -for (i =0 ; i < urb->actual_length -4 ; i +=4 ) { +for (i =0 ; i < urb->actual_length -3 ; i +=4 ) { opcode = buf[i]; line = buf[i +1 ]; status = buf[i +2 ];
PATCH 13/178 scsi: aacraid: Fix typo in blink status
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Raghava Aditya Renukunta <[email protected]>
commit 934767c56b0d9dbb95a40e9e6e4d9dcdc3a165ad upstream.
The return status of the adapter check on KERNEL_PANIC is supposed to be the upper 16 bits of the OMR status register.
--- drivers/scsi/aacraid/src.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/aacraid/src.c +1 -1
@@ -390,7 +390,7 @@ err_out:return -1 ; err_blink: -return (status >16 ) &0xFF ; +return (status >>16 ) &0xFF ; }/**
PATCH 14/178 libceph: don't set weight to IN when OSD is destroyed
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Dryomov <[email protected]>
commit b581a5854eee4b7851dedb0f8c2ceb54fb902c06 upstream.
Since ceph.git commit 4e28f9e63644 ("osd/OSDMap: clear osd_info, osd_xinfo on osd deletion"), weight is set to IN when OSD is deleted. This changes the result of applying an incremental for clients, not just OSDs. Because CRUSH computations are obviously affected, pre-4e28f9e63644 servers disagree with post-4e28f9e63644 clients on object placement, resulting in misdirected requests.
Mirrors ceph.git commit a6009d1039a55e2c77f431662b3d6cc5a8e8e63f.
--- net/ceph/osdmap.c | 1 - 1 file changed, 1 deletion(-)
net/ceph/osdmap.c +0 -1
@@ -1240,7 +1240,6 @@ static int decode_new_up_state_weight(voif ((map->osd_state[osd] &CEPH_OSD_EXISTS ) && (xorstate &CEPH_OSD_EXISTS )) {pr_info ("osd%d does not exist\n" , osd); - map->osd_weight[osd] =CEPH_OSD_IN ; ret =set_primary_affinity (map, osd,CEPH_OSD_DEFAULT_PRIMARY_AFFINITY );if (ret)
PATCH 15/178 Input: i8042 - add noloop quirk for Dell Embedded Box PC 3000
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Kai-Heng Feng <[email protected]>
commit 45838660e34d90db8d4f7cbc8fd66e8aff79f4fe upstream.
The aux port does not get detected without noloop quirk, so external PS/2 mouse cannot work as result.
The PS/2 mouse can work with this quirk.
--- drivers/input/serio/i8042-x86ia64io.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/input/serio/i8042-x86ia64io.h +7 -0
@@ -120,6 +120,13 @@ static const struct dmi_system_id __init }, }, { +/* Dell Embedded Box PC 3000 */ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), + DMI_MATCH(DMI_PRODUCT_NAME, "Embedded Box PC 3000"), + }, + }, + {/* OQO Model 01 */ .matches = { DMI_MATCH(DMI_SYS_VENDOR, "OQO"),
PATCH 16/178 powerpc/boot: Fix zImage TOC alignment
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Michael Ellerman <[email protected]>
commit 97ee351b50a49717543533cfb85b4bf9d88c9680 upstream.
Recent toolchains force the TOC to be 256 byte aligned. We need to enforce this alignment in the zImage linker script, otherwise pointers to our TOC variables (__toc_start) could be incorrect. If the actual start of the TOC and __toc_start don't have the same value we crash early in the zImage wrapper.
--- arch/powerpc/boot/zImage.lds.S | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/boot/zImage.lds.S +1 -0
@@ -68,6 +68,7 @@ SECTIONS } #ifdef CONFIG_PPC64_BOOT_WRAPPER + . = ALIGN(256); .got : { __toc_start = .;
PATCH 17/178 scsi: lpfc: Add shutdown method for kexec
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Anton Blanchard <[email protected]>
commit 85e8a23936ab3442de0c42da97d53b29f004ece1 upstream.
We see lpfc devices regularly fail during kexec. Fix this by adding a shutdown method which mirrors the remove method.
--- drivers/scsi/lpfc/lpfc_init.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/lpfc/lpfc_init.c +1 -0
@@ -11255,6 +11255,7 @@ static struct pci_driver lpfc_driver = { .id_table = lpfc_id_table, .probe = lpfc_pci_probe_one, .remove = lpfc_pci_remove_one, + .shutdown = lpfc_pci_remove_one, .suspend = lpfc_pci_suspend_one, .resume = lpfc_pci_resume_one, .err_handler = &lpfc_err_handler,
PATCH 18/178 target/pscsi: Fix TYPE_TAPE + TYPE_MEDIMUM_CHANGER export
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Bellinger <[email protected]>
commit a04e54f2c35823ca32d56afcd5cea5b783e2f51a upstream.
The following fixes a divide by zero OOPs with TYPE_TAPE due to pscsi_tape_read_blocksize() failing causing a zero sd->sector_size being propigated up via dev_attrib.hw_block_size.
It also fixes another long-standing bug where TYPE_TAPE and TYPE_MEDIMUM_CHANGER where using pscsi_create_type_other(), which does not call scsi_device_get() to take the device reference. Instead, rename pscsi_create_type_rom() to pscsi_create_type_nondisk() and use it for all cases.
Finally, also drop a dump_stack() in pscsi_get_blocks() for non TYPE_DISK, which in modern target-core can get invoked via target_sense_desc_format() during CHECK_CONDITION.
[bwh: Backported to 3.16:
- Deleted log format is slightly different
- Cast Scsi_Host::max_sectors from unsigned short to unsigned int, to avoid a warning about differing types in min_not_zero()]
--- drivers/target/target_core_pscsi.c | 47 ++++++++++---------------------------- 1 file changed, 12 insertions(+), 35 deletions(-)
drivers/target/target_core_pscsi.c +12 -35
@@ -157,7 +157,7 @@ static void pscsi_tape_read_blocksize(st buf =kzalloc (12 ,GFP_KERNEL );if (!buf) -return ; + goto out_free;memset (cdb,0 ,MAX_COMMAND_SIZE ); cdb[0 ] =MODE_SENSE ;
@@ -172,9 +172,10 @@ static void pscsi_tape_read_blocksize(st* If MODE_SENSE still returns zero, set the default value to 1024. */ sdev->sector_size = (buf[9 ] <<16 ) | (buf[10 ] <<8 ) | (buf[11 ]); +out_free:if (!sdev->sector_size) sdev->sector_size =1024 ; -out_free: +kfree (buf); }
@@ -317,9 +318,10 @@ static int pscsi_add_device_to_list(stru sd->lun, sd->queue_depth); } - dev->dev_attrib.hw_block_size = sd->sector_size; + dev->dev_attrib.hw_block_size = +min_not_zero ((int )sd->sector_size,512 ); dev->dev_attrib.hw_max_sectors = -min_t (int, sd->host->max_sectors,queue_max_hw_sectors (q)); +min_not_zero ((unsigned int )sd->host->max_sectors,queue_max_hw_sectors (q)); dev->dev_attrib.hw_queue_depth = sd->queue_depth;/*
@@ -342,8 +344,10 @@ static int pscsi_add_device_to_list(stru/* * For TYPE_TAPE, attempt to determine blocksize with MODE_SENSE. */ -if (sd->type ==TYPE_TAPE ) +if (sd->type ==TYPE_TAPE ) {pscsi_tape_read_blocksize (dev, sd); + dev->dev_attrib.hw_block_size = sd->sector_size; + }return 0 ; }
@@ -409,7 +413,7 @@ static int pscsi_create_type_disk(struct/* * Called with struct Scsi_Host->host_lock called. */ -static int pscsi_create_type_rom (struct se_device *dev,struct scsi_device *sd) +static int pscsi_create_type_nondisk (struct se_device *dev,struct scsi_device *sd) __releases(sh->host_lock) {struct pscsi_hba_virt *phv = dev->se_hba->hba_ptr;
@@ -436,28 +440,6 @@ static int pscsi_create_type_rom(structreturn 0 ; } -/* -* Called with struct Scsi_Host->host_lock called. -*/ -static int pscsi_create_type_other (struct se_device *dev, -struct scsi_device *sd) - __releases(sh->host_lock) -{ -struct pscsi_hba_virt *phv = dev->se_hba->hba_ptr; -struct Scsi_Host *sh = sd->host; -int ret; - -spin_unlock_irq (sh->host_lock); - ret =pscsi_add_device_to_list (dev, sd); -if (ret) -return ret; - -pr_debug ("CORE_PSCSI[%d] - Added Type: %s for %d:%d:%d:%d\n" , - phv->phv_host_id,scsi_device_type (sd->type), sh->host_no, - sd->channel, sd->id, sd->lun); -return 0 ; -} -static int pscsi_configure_device (struct se_device *dev) {struct se_hba *hba = dev->se_hba;
@@ -545,11 +527,8 @@ static int pscsi_configure_device(structcase TYPE_DISK : ret =pscsi_create_type_disk (dev, sd);break ; -case TYPE_ROM : - ret =pscsi_create_type_rom (dev, sd); -break ;default : - ret =pscsi_create_type_other (dev, sd); + ret =pscsi_create_type_nondisk (dev, sd);break ; }
@@ -606,8 +585,7 @@ static void pscsi_free_device(struct se_else if (pdv->pdv_lld_host)scsi_host_put (pdv->pdv_lld_host); -if ((sd->type ==TYPE_DISK ) || (sd->type ==TYPE_ROM )) -scsi_device_put (sd); +scsi_device_put (sd); pdv->pdv_sd =NULL ; }
@@ -1125,7 +1103,6 @@ static sector_t pscsi_get_blocks(structif (pdv->pdv_bd && pdv->pdv_bd->bd_part)return pdv->pdv_bd->bd_part->nr_sects; -dump_stack ();return 0 ; }
PATCH 19/178 target: Fix VERIFY_16 handling in sbc_parse_cdb
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Max Lohrmann <[email protected]>
commit 13603685c1f12c67a7a2427f00b63f39a2b6f7c9 upstream.
As reported by Max, the Windows 2008 R2 chkdsk utility expects VERIFY_16 to be supported, and does not handle the returned CHECK_CONDITION properly, resulting in an infinite loop.
The kernel will log huge amounts of this error:
kernel: TARGET_CORE[iSCSI]: Unsupported SCSI Opcode 0x8f, sending CHECK_CONDITION.
--- drivers/target/target_core_sbc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/target/target_core_sbc.c +8 -2
@@ -950,9 +950,15 @@ sbc_parse_cdb(struct se_cmd *cmd, structreturn ret;break ;case VERIFY : +case VERIFY_16 : size =0 ; - sectors =transport_get_sectors_10 (cdb); - cmd->t_task_lba =transport_lba_32 (cdb); +if (cdb[0 ] ==VERIFY ) { + sectors =transport_get_sectors_10 (cdb); + cmd->t_task_lba =transport_lba_32 (cdb); + }else { + sectors =transport_get_sectors_16 (cdb); + cmd->t_task_lba =transport_lba_64 (cdb); + } cmd->execute_cmd = sbc_emulate_noop; goto check_lba;case REZERO_UNIT :
PATCH 20/178 MIPS: End spinlocks with .insn
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paul Burton <[email protected]>
commit 4b5347a24a0f2d3272032c120664b484478455de upstream.
When building for microMIPS we need to ensure that the assembler always knows that there is code at the target of a branch or jump. Recent toolchains will fail to link a microMIPS kernel when this isn't the case due to what it thinks is a branch to non-microMIPS code.
mips-mti-linux-gnu-ld kernel/built-in.o: .spinlock.text+0x2fc: Unsupported branch between ISA modes. mips-mti-linux-gnu-ld final link failed: Bad value
This is due to inline assembly labels in spinlock.h not being followed by an instruction mnemonic, either due to a .subsection pseudo-op or the end of the inline asm block.
Fix this with a .insn direction after such labels.
Patchwork: https://patchwork.linux-mips.org/patch/15325/
--- arch/mips/include/asm/spinlock.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/mips/include/asm/spinlock.h +4 -4
@@ -73,7 +73,7 @@ static inline void arch_spin_lock(arch_s" andi %[ticket], %[ticket], 0xffff \n" " bne %[ticket], %[my_ticket], 4f \n" " subu %[ticket], %[my_ticket], %[ticket] \n" -"2: \n" +"2: .insn \n" " .subsection 2 \n" "4: andi %[ticket], %[ticket], 0xffff \n" " sll %[ticket], 5 \n"
@@ -181,7 +181,7 @@ static inline unsigned int arch_spin_try" sc %[ticket], %[ticket_ptr] \n" " beqz %[ticket], 1b \n" " li %[ticket], 1 \n" -"2: \n" +"2: .insn \n" " .subsection 2 \n" "3: b 2b \n" " li %[ticket], 0 \n"
@@ -364,7 +364,7 @@ static inline int arch_read_trylock(arch " .set reorder \n" __WEAK_LLSC_MB " li %2, 1 \n" - "2: \n" + "2: .insn \n" : "=m" (rw->lock), "=&r" (tmp), "=&r" (ret) : "m" (rw->lock) : "memory");
@@ -404,7 +404,7 @@ static inline int arch_write_trylock(arc " lui %1, 0x8000 \n" " sc %1, %0 \n" " li %2, 1 \n" - "2: \n" + "2: .insn \n" : "=m" (rw->lock), "=&r" (tmp), "=&r" (ret) : "m" (rw->lock) : "memory");
PATCH 21/178 USB: serial: io_ti: fix NULL-deref in interrupt callback
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 0b1d250afb8eb9d65afb568bac9b9f9253a82b49 upstream.
Fix a NULL-pointer dereference in the interrupt callback should a malicious device send data containing a bad port number by adding the missing sanity check.
--- drivers/usb/serial/io_ti.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/usb/serial/io_ti.c +6 -0
@@ -1550,6 +1550,12 @@ static void edge_interrupt_callback(stru function =TIUMP_GET_FUNC_FROM_CODE (data[0 ]);dev_dbg (dev,"%s - port_number %d, function %d, info 0x%x\n" , __func__, port_number, function, data[1 ]); + +if (port_number >= edge_serial->serial->num_ports) { +dev_err (dev,"bad port number %d\n" , port_number); + goto exit; + } + port = edge_serial->serial->port[port_number]; edge_port =usb_get_serial_port_data (port);if (!edge_port) {
PATCH 22/178 USB: serial: safe_serial: fix information leak in completion handler
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 8c76d7cd520ebffc1ea9ea0850d87a224a50c7f2 upstream.
Add missing sanity check to the bulk-in completion handler to avoid an integer underflow that could be triggered by a malicious device.
This avoids leaking up to 56 bytes from after the URB transfer buffer to user space.
--- drivers/usb/serial/safe_serial.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/serial/safe_serial.c +5 -0
@@ -205,6 +205,11 @@ static void safe_process_read_urb(structif (!safe) goto out; +if (length <2 ) { +dev_err (&port->dev,"malformed packet\n" ); +return ; + } + fcs =fcs_compute10 (data, length,CRC10_INITFCS );if (fcs) {dev_err (&port->dev,"%s - bad CRC %x\n" , __func__, fcs);
PATCH 23/178 dvb-usb: don't use stack for firmware load
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mauro Carvalho Chehab <[email protected]>
commit 43fab9793c1f44e665b4f98035a14942edf03ddc upstream.
As reported by Marc Duponcheel <[email protected]>, firmware load on dvb-usb is using the stack, with is not allowed anymore on default Kernel configurations:
[ 1025.958836] dvb-usb: found a 'WideView WT-220U PenType Receiver (based on ZL353)' in cold state, will try to load a firmware [ 1025.958853] dvb-usb: downloading firmware from file 'dvb-usb-wt220u-zl0353-01.fw' [ 1025.958855] dvb-usb: could not stop the USB controller CPU. [ 1025.958856] dvb-usb: error while transferring firmware (transferred size: -11, block size: 3) [ 1025.958856] dvb-usb: firmware download failed at 8 with -22 [ 1025.958867] usbcore: registered new interface driver dvb_usb_dtt200u
[ 2.789902] dvb-usb: downloading firmware from file 'dvb-usb-wt220u-zl0353-01.fw' [ 2.789905] ------------[ cut here ]------------ [ 2.789911] WARNING: CPU: 3 PID: 2196 at drivers/usb/core/hcd.c:1584 usb_hcd_map_urb_for_dma+0x430/0x560 [usbcore] [ 2.789912] transfer buffer not dma capable [ 2.789912] Modules linked in: btusb dvb_usb_dtt200u(+) dvb_usb_af9035(+) btrtl btbcm dvb_usb dvb_usb_v2 btintel dvb_core bluetooth rc_core rfkill x86_pkg_temp_thermal intel_powerclamp coretemp crc32_pclmul aesni_intel aes_x86_64 glue_helper lrw gf128mul ablk_helper cryptd drm_kms_helper syscopyarea sysfillrect pcspkr i2c_i801 sysimgblt fb_sys_fops drm i2c_smbus i2c_core r8169 lpc_ich mfd_core mii thermal fan rtc_cmos video button acpi_cpufreq processor snd_hda_codec_realtek snd_hda_codec_generic snd_hda_intel snd_hda_codec snd_hwdep snd_hda_core snd_pcm snd_timer snd crc32c_intel ahci libahci libata xhci_pci ehci_pci xhci_hcd ehci_hcd usbcore usb_common dm_mirror dm_region_hash dm_log dm_mod [ 2.789936] CPU: 3 PID: 2196 Comm: systemd-udevd Not tainted 4.9.0-gentoo #1 [ 2.789937] Hardware name: ASUS All Series/H81I-PLUS, BIOS 0401 07/23/2013 [ 2.789938] ffffc9000339b690 ffffffff812bd397 ffffc9000339b6e0 0000000000000000 [ 2.789939] ffffc9000339b6d0 ffffffff81055c86 000006300339b6a0 ffff880116c0c000 [ 2.789941] 0000000000000000 0000000000000000 0000000000000001 ffff880116c08000 [ 2.789942] Call Trace: [ 2.789945] [<ffffffff812bd397>] dump_stack+0x4d/0x66 [ 2.789947] [<ffffffff81055c86>] __warn+0xc6/0xe0 [ 2.789948] [<ffffffff81055cea>] warn_slowpath_fmt+0x4a/0x50 [ 2.789952] [<ffffffffa006d460>] usb_hcd_map_urb_for_dma+0x430/0x560 [usbcore] [ 2.789954] [<ffffffff814ed5a8>] ? io_schedule_timeout+0xd8/0x110 [ 2.789956] [<ffffffffa006e09c>] usb_hcd_submit_urb+0x9c/0x980 [usbcore] [ 2.789958] [<ffffffff812d0ebf>] ? copy_page_to_iter+0x14f/0x2b0 [ 2.789960] [<ffffffff81126818>] ? pagecache_get_page+0x28/0x240 [ 2.789962] [<ffffffff8118c2a0>] ? touch_atime+0x20/0xa0 [ 2.789964] [<ffffffffa006f7c4>] usb_submit_urb+0x2c4/0x520 [usbcore] [ 2.789967] [<ffffffffa006feca>] usb_start_wait_urb+0x5a/0xe0 [usbcore] [ 2.789969] [<ffffffffa007000c>] usb_control_msg+0xbc/0xf0 [usbcore] [ 2.789970] [<ffffffffa067903d>] usb_cypress_writemem+0x3d/0x40 [dvb_usb] [ 2.789972] [<ffffffffa06791cf>] usb_cypress_load_firmware+0x4f/0x130 [dvb_usb] [ 2.789973] [<ffffffff8109dbbe>] ? console_unlock+0x2fe/0x5d0 [ 2.789974] [<ffffffff8109e10c>] ? vprintk_emit+0x27c/0x410 [ 2.789975] [<ffffffff8109e40a>] ? vprintk_default+0x1a/0x20 [ 2.789976] [<ffffffff81124d76>] ? printk+0x43/0x4b [ 2.789977] [<ffffffffa0679310>] dvb_usb_download_firmware+0x60/0xd0 [dvb_usb] [ 2.789979] [<ffffffffa0679898>] dvb_usb_device_init+0x3d8/0x610 [dvb_usb] [ 2.789981] [<ffffffffa069e302>] dtt200u_usb_probe+0x92/0xd0 [dvb_usb_dtt200u] [ 2.789984] [<ffffffffa007420c>] usb_probe_interface+0xfc/0x270 [usbcore] [ 2.789985] [<ffffffff8138bf95>] driver_probe_device+0x215/0x2d0 [ 2.789986] [<ffffffff8138c0e6>] __driver_attach+0x96/0xa0 [ 2.789987] [<ffffffff8138c050>] ? driver_probe_device+0x2d0/0x2d0 [ 2.789988] [<ffffffff81389ffb>] bus_for_each_dev+0x5b/0x90 [ 2.789989] [<ffffffff8138b7b9>] driver_attach+0x19/0x20 [ 2.789990] [<ffffffff8138b33c>] bus_add_driver+0x11c/0x220 [ 2.789991] [<ffffffff8138c91b>] driver_register+0x5b/0xd0 [ 2.789994] [<ffffffffa0072f6c>] usb_register_driver+0x7c/0x130 [usbcore] [ 2.789994] [<ffffffffa06a5000>] ? 0xffffffffa06a5000 [ 2.789996] [<ffffffffa06a501e>] dtt200u_usb_driver_init+0x1e/0x20 [dvb_usb_dtt200u] [ 2.789997] [<ffffffff81000408>] do_one_initcall+0x38/0x140 [ 2.789998] [<ffffffff8116001c>] ? __vunmap+0x7c/0xc0 [ 2.789999] [<ffffffff81124fb0>] ? do_init_module+0x22/0x1d2 [ 2.790000] [<ffffffff81124fe8>] do_init_module+0x5a/0x1d2 [ 2.790002] [<ffffffff810c96b1>] load_module+0x1e11/0x2580 [ 2.790003] [<ffffffff810c68b0>] ? show_taint+0x30/0x30 [ 2.790004] [<ffffffff81177250>] ? kernel_read_file+0x100/0x190 [ 2.790005] [<ffffffff810c9ffa>] SyS_finit_module+0xba/0xc0 [ 2.790007] [<ffffffff814f13e0>] entry_SYSCALL_64_fastpath+0x13/0x94 [ 2.790008] ---[ end trace c78a74e78baec6fc ]---
So, allocate the structure dynamically.
--- drivers/media/usb/dvb-usb/dvb-usb-firmware.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/media/usb/dvb-usb/dvb-usb-firmware.c +13 -6
@@ -35,29 +35,34 @@ static int usb_cypress_writemem(struct uint usb_cypress_load_firmware (struct usb_device *udev,const struct firmware *fw,int type) { -struct hexline hx; +struct hexline *hx;u8 reset;int ret,pos=0 ; + hx =kmalloc (sizeof (*hx),GFP_KERNEL ); +if (!hx) +return -ENOMEM ; +/* stop the CPU */ reset =1 ;if ((ret =usb_cypress_writemem (udev,cypress[type].cpu_cs_register,&reset,1 )) !=1 )err ("could not stop the USB controller CPU." ); -while ((ret =dvb_usb_get_hexline (fw,&hx,&pos)) >0 ) { -deb_fw ("writing to address 0x%04x (buffer: 0x%02x %02x)\n" ,hx.addr,hx.len,hx.chk); - ret =usb_cypress_writemem (udev,hx.addr,hx.data,hx.len); +while ((ret =dvb_usb_get_hexline (fw, hx, &pos)) >0 ) { +deb_fw ("writing to address 0x%04x (buffer: 0x%02x %02x)\n" , hx->addr, hx->len, hx->chk); + ret =usb_cypress_writemem (udev, hx->addr, hx->data, hx->len); -if (ret != hx.len) { +if (ret != hx->len) {err ("error while transferring firmware " "(transferred size: %d, block size: %d)" , - ret,hx.len); + ret, hx->len); ret = -EINVAL ;break ; } }if (ret <0 ) {err ("firmware download failed at %d with %d" ,pos,ret); +kfree (hx);return ret; }
@@ -71,6 +76,8 @@ int usb_cypress_load_firmware(struct usb }else ret = -EIO ; +kfree (hx); +return ret; }EXPORT_SYMBOL (usb_cypress_load_firmware);
PATCH 24/178 dvb-usb-firmware: don't do DMA on stack
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Brüns <[email protected]>
commit 67b0503db9c29b04eadfeede6bebbfe5ddad94ef upstream.
The buffer allocation for the firmware data was changed in commit 43fab9793c1f ("[media] dvb-usb: don't use stack for firmware load") but the same applies for the reset value.
--- drivers/media/usb/dvb-usb/dvb-usb-firmware.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/media/usb/dvb-usb/dvb-usb-firmware.c +12 -10
@@ -36,16 +36,18 @@ static int usb_cypress_writemem(struct uint usb_cypress_load_firmware (struct usb_device *udev,const struct firmware *fw,int type) {struct hexline *hx; -u8 reset; -int ret,pos=0 ; +u8 *buf; +int ret, pos =0 ; +u16 cpu_cs_register = cypress[type].cpu_cs_register; - hx =kmalloc (sizeof (*hx),GFP_KERNEL ); -if (!hx) + buf =kmalloc (sizeof (*hx),GFP_KERNEL ); +if (!buf)return -ENOMEM ; + hx = (struct hexline *)buf;/* stop the CPU */ - reset =1 ; -if ((ret =usb_cypress_writemem (udev,cypress[type].cpu_cs_register,&reset,1 )) !=1 ) + buf[0 ] =1 ; +if (usb_cypress_writemem (udev, cpu_cs_register, buf,1 ) !=1 )err ("could not stop the USB controller CPU." );while ((ret =dvb_usb_get_hexline (fw, hx, &pos)) >0 ) {
@@ -62,21 +64,21 @@ int usb_cypress_load_firmware(struct usb }if (ret <0 ) {err ("firmware download failed at %d with %d" ,pos,ret); -kfree (hx); +kfree (buf);return ret; }if (ret ==0 ) {/* restart the CPU */ - reset =0 ; -if (ret ||usb_cypress_writemem (udev,cypress[type].cpu_cs_register,&reset,1 ) !=1 ) { + buf[0 ] =0 ; +if (usb_cypress_writemem (udev, cpu_cs_register, buf,1 ) !=1 ) {err ("could not restart the USB controller CPU." ); ret = -EINVAL ; } }else ret = -EIO ; -kfree (hx); +kfree (buf);return ret; }
PATCH 25/178 USB: iowarrior: fix NULL-deref in write
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit de46e56653de7b3b54baa625bd582635008b8d05 upstream.
Make sure to verify that we have the required interrupt-out endpoint for IOWarrior56 devices to avoid dereferencing a NULL-pointer in write should a malicious device lack such an endpoint.
--- drivers/usb/misc/iowarrior.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/usb/misc/iowarrior.c +8 -0
@@ -804,6 +804,14 @@ static int iowarrior_probe(struct usb_in goto error; } +if (dev->product_id ==USB_DEVICE_ID_CODEMERCS_IOW56 ) { +if (!dev->int_out_endpoint) { +dev_err (&interface->dev,"no interrupt-out endpoint found\n" ); + retval = -ENODEV ; + goto error; + } + } +/* we have to check the report_size often, so remember it in the endianness suitable for our machine */ dev->report_size =usb_endpoint_maxp (dev->int_in_endpoint); if ((dev->interface->cur_altsetting->desc.bInterfaceNumber == 0) &&
PATCH 26/178 md/raid1/10: fix potential deadlock
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Shaohua Li <[email protected]>
commit 61eb2b43b99ebdc9bc6bc83d9792257b243e7cb3 upstream.
Neil Brown pointed out a potential deadlock in raid 10 code with bio_split/chain. The raid1 code could have the same issue, but recent barrier rework makes it less likely to happen. The deadlock happens in below sequence:
1. generic_make_request(bio), this will set current->bio_list
2. raid10_make_request will split bio to bio1 and bio2
3. __make_request(bio1), wait_barrer, add underlayer disk bio to current->bio_list
4. __make_request(bio2), wait_barrer
If raise_barrier happens between 3 & 4, since wait_barrier runs at 3, raise_barrier waits for IO completion from 3. And since raise_barrier sets barrier, 4 waits for raise_barrier. But IO from 3 can't be dispatched because raid10_make_request() doesn't finished yet.
The solution is to adjust the IO ordering. Quotes from Neil:
"
It is much safer to:
if (need to split) {
split = bio_split(bio, ...)
bio_chain(...)
make_request_fn(split);
generic_make_request(bio);
} else
make_request_fn(mddev, bio);This way we first process the initial section of the bio (in 'split') which will queue some requests to the underlying devices. These requests will be queued in generic_make_request.
Then we queue the remainder of the bio, which will be added to the end of the generic_make_request queue.
Then we return.generic_make_request() will pop the lower-level device requests off the queue and handle them first. Then it will process the remainder of the original bio once the first section has been fully processed. "
Note, this only happens in read path. In write path, the bio is flushed to underlaying disks either by blk flush (from schedule) or offladed to raid1/10d. It's queued in current->bio_list.
---
drivers/md/raid10.c +18 -0
@@ -1580,7 +1580,25 @@ static void make_request(struct mddev *m split = bio; } +/* +* If a bio is splitted, the first part of bio will pass +* barrier but the bio is queued in current->bio_list (see +* generic_make_request). If there is a raise_barrier() called +* here, the second part of bio can't pass barrier. But since +* the first part bio isn't dispatched to underlaying disks +* yet, the barrier is never released, hence raise_barrier will +* alays wait. We have a deadlock. +* Note, this only happens in read path. For write path, the +* first part of bio is dispatched in a schedule() call +* (because of blk plug) or offloaded to raid10d. +* Quitting from the function immediately can change the bio +* order queued in bio_list and avoid the deadlock. +*/ __make_request (mddev, split); +if (split != bio &&bio_data_dir (bio) ==READ ) { +generic_make_request (bio); +break ; + } }while (split != bio);/* In case raid10d snuck in to freeze_array */
PATCH 27/178 udp: avoid ufo handling on IP payload compression packets
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Kodanev <[email protected]>
commit 4b3b45edba9222e518a1ec72df841eba3609fe34 upstream.
commit c146066ab802 ("ipv4: Don't use ufo handling on later transformed packets") and commit f89c56ce710a ("ipv6: Don't use ufo handling on later transformed packets") added a check that 'rt->dst.header_len' isn't zero in order to skip UFO, but it doesn't include IPcomp in transport mode where it equals zero.
Packets, after payload compression, may not require further fragmentation, and if original length exceeds MTU, later compressed packets will be transmitted incorrectly. This can be reproduced with LTP udp_ipsec.sh test on veth device with enabled UFO, MTU is 1500 and UDP payload is 2000:
* IPv4 case, offset is wrong + unnecessary fragmentation
udp_ipsec.sh -p comp -m transport -s 2000 &
tcpdump -ni ltp_ns_veth2
...
IP (tos 0x0, ttl 64, id 45203, offset 0, flags [+],
proto Compressed IP (108), length 49)
10.0.0.2 > 10.0.0.1: IPComp(cpi=0x1000)
IP (tos 0x0, ttl 64, id 45203, offset 1480, flags [none],
proto UDP (17), length 21) 10.0.0.2 > 10.0.0.1: ip-proto-17* IPv6 case, sending small fragments
udp_ipsec.sh -6 -p comp -m transport -s 2000 &
tcpdump -ni ltp_ns_veth2
...
IP6 (flowlabel 0x6b9ba, hlim 64, next-header Compressed IP (108)
payload length: 37) fd00::2 > fd00::1: IPComp(cpi=0x1000)
IP6 (flowlabel 0x6b9ba, hlim 64, next-header Compressed IP (108)
payload length: 21) fd00::2 > fd00::1: IPComp(cpi=0x1000)Fix it by checking 'rt->dst.xfrm' pointer to 'xfrm_state' struct, skip UFO if xfrm is set. So the new check will include both cases: IPcomp and IPsec.
--- net/ipv4/ip_output.c | 2 +- net/ipv6/ip6_output.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/ipv4/ip_output.c +1 -1
@@ -887,7 +887,7 @@ static int __ip_append_data(struct sock cork->length += length;if (((length > mtu) || (skb &&skb_is_gso (skb))) && (sk->sk_protocol ==IPPROTO_UDP ) && - (rt->dst.dev->features &NETIF_F_UFO ) && !rt->dst.header_len && + (rt->dst.dev->features &NETIF_F_UFO ) && !dst_xfrm (&rt->dst) && (sk->sk_type ==SOCK_DGRAM )) { err = ip_ufo_append_data(sk, queue, getfrag, from, length, hh_len, fragheaderlen, transhdrlen,
net/ipv6/ip6_output.c +1 -1
@@ -1294,7 +1294,7 @@ emsgsize:if (((length > mtu) || (skb &&skb_is_gso (skb))) && (sk->sk_protocol ==IPPROTO_UDP ) && - (rt->dst.dev->features &NETIF_F_UFO ) && !rt->dst.header_len && + (rt->dst.dev->features &NETIF_F_UFO ) && !dst_xfrm (&rt->dst) && (sk->sk_type ==SOCK_DGRAM )) { err = ip6_ufo_append_data(sk, getfrag, from, length, hh_len, fragheaderlen, exthdrlen,
PATCH 28/178 net: bcmgenet: correct the RBUF_OVFL_CNT and RBUF_ERR_CNT MIB values
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Doug Berger <[email protected]>
commit ffff71328a3c321f7c14cc1edd33577717037744 upstream.
The location of the RBUF overflow and error counters has moved between different version of the GENET MAC. This commit corrects the driver to read from the correct locations depending on the version of the GENET MAC.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 60 +++++++++++++++++++++++--- drivers/net/ethernet/broadcom/genet/bcmgenet.h | 10 +++-- 2 files changed, 60 insertions(+), 10 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +53 -7
@@ -1,7 +1,7 @@/* * Broadcom GENET (Gigabit Ethernet) controller driver * -* Copyright (c) 2014 Broadcom Corporation +* Copyright (c) 2014-2017 Broadcom * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
@@ -617,8 +617,9 @@ static const struct bcmgenet_stats bcmgeSTAT_GENET_RUNT ("rx_runt_bytes" , mib.rx_runt_bytes),/* Misc UniMAC counters */ STAT_GENET_MISC ("rbuf_ovflow_cnt" , mib.rbuf_ovflow_cnt, -UMAC_RBUF_OVFL_CNT ), -STAT_GENET_MISC ("rbuf_err_cnt" , mib.rbuf_err_cnt,UMAC_RBUF_ERR_CNT ), +UMAC_RBUF_OVFL_CNT_V1 ), +STAT_GENET_MISC ("rbuf_err_cnt" , mib.rbuf_err_cnt, +UMAC_RBUF_ERR_CNT_V1 ), STAT_GENET_MISC("mdf_err_cnt", mib.mdf_err_cnt, UMAC_MDF_ERR_CNT), };
@@ -659,6 +660,45 @@ static void bcmgenet_get_strings(struct } } +static u32 bcmgenet_update_stat_misc (struct bcmgenet_priv *priv,u16 offset) +{ +u16 new_offset; +u32 val; + +switch (offset) { +case UMAC_RBUF_OVFL_CNT_V1 : +if (GENET_IS_V2 (priv)) + new_offset =RBUF_OVFL_CNT_V2 ; +else + new_offset =RBUF_OVFL_CNT_V3PLUS ; + + val =bcmgenet_rbuf_readl (priv, new_offset); +/* clear if overflowed */ +if (val == ~0 ) +bcmgenet_rbuf_writel (priv,0 , new_offset); +break ; +case UMAC_RBUF_ERR_CNT_V1 : +if (GENET_IS_V2 (priv)) + new_offset =RBUF_ERR_CNT_V2 ; +else + new_offset =RBUF_ERR_CNT_V3PLUS ; + + val =bcmgenet_rbuf_readl (priv, new_offset); +/* clear if overflowed */ +if (val == ~0 ) +bcmgenet_rbuf_writel (priv,0 , new_offset); +break ; +default : + val =bcmgenet_umac_readl (priv, offset); +/* clear if overflowed */ +if (val == ~0 ) +bcmgenet_umac_writel (priv,0 , offset); +break ; + } + +return val; +} +static void bcmgenet_update_mib_counters (struct bcmgenet_priv *priv) {int i, j =0 ;
@@ -682,10 +722,16 @@ static void bcmgenet_update_mib_counters j + offset);break ;case BCMGENET_STAT_MISC : - val =bcmgenet_umac_readl (priv, s->reg_offset); -/* clear if overflowed */ -if (val == ~0 ) -bcmgenet_umac_writel (priv,0 , s->reg_offset); +if (GENET_IS_V1 (priv)) { + val =bcmgenet_umac_readl (priv, s->reg_offset); +/* clear if overflowed */ +if (val == ~0 ) +bcmgenet_umac_writel (priv,0 , + s->reg_offset); + }else { + val =bcmgenet_update_stat_misc (priv, + s->reg_offset); + }break ; }
drivers/net/ethernet/broadcom/genet/bcmgenet.h +7 -3
@@ -1,5 +1,5 @@/* -* Copyright (c) 2014 Broadcom Corporation +* Copyright (c) 2014-2017 Broadcom * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
@@ -206,7 +206,9 @@ struct bcmgenet_mib_counters {#define MDIO_REG_SHIFT 16#define MDIO_REG_MASK 0x1F -#define UMAC_RBUF_OVFL_CNT 0x61C +#define UMAC_RBUF_OVFL_CNT_V1 0x61C +#define RBUF_OVFL_CNT_V2 0x80 +#define RBUF_OVFL_CNT_V3PLUS 0x94#define UMAC_MPD_CTRL 0x620#define MPD_EN (1 << 0)
@@ -216,7 +218,9 @@ struct bcmgenet_mib_counters {#define UMAC_MPD_PW_MS 0x624#define UMAC_MPD_PW_LS 0x628 -#define UMAC_RBUF_ERR_CNT 0x634 +#define UMAC_RBUF_ERR_CNT_V1 0x634 +#define RBUF_ERR_CNT_V2 0x84 +#define RBUF_ERR_CNT_V3PLUS 0x98#define UMAC_MDF_ERR_CNT 0x638#define UMAC_MDF_CTRL 0x650#define UMAC_MDF_ADDR 0x654
PATCH 29/178 net: bcmgenet: correct MIB access of UniMAC RUNT counters
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Doug Berger <[email protected]>
commit 1ad3d225e5a40ca6c586989b4baaca710544c15a upstream.
The gap between the Tx status counters and the Rx RUNT counters is now being added to allow correct reporting of the registers.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +7 -4
@@ -713,13 +713,16 @@ static void bcmgenet_update_mib_countersswitch (s->type) {case BCMGENET_STAT_NETDEV :continue ; -case BCMGENET_STAT_MIB_RX : -case BCMGENET_STAT_MIB_TX :case BCMGENET_STAT_RUNT : -if (s->type !=BCMGENET_STAT_MIB_RX ) - offset =BCMGENET_STAT_OFFSET ; + offset +=BCMGENET_STAT_OFFSET ; +/* fall through */ +case BCMGENET_STAT_MIB_TX : + offset +=BCMGENET_STAT_OFFSET ; +/* fall through */ +case BCMGENET_STAT_MIB_RX : val =bcmgenet_umac_readl (priv,UMAC_MIB_START + j + offset); + offset =0 ;/* Reset Offset */ break ;case BCMGENET_STAT_MISC :if (GENET_IS_V1 (priv)) {
PATCH 30/178 net: bcmgenet: synchronize irq0 status between the isr and task
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Doug Berger <[email protected]>
commit 07c52d6a0b955a8a28834f9354793cfc4b81d0e9 upstream.
Add a spinlock to ensure that irq0_stat is not unintentionally altered as the result of preemption. Also removed unserviced irq0 interrupts and removed irq1_stat since there is no bottom half service for those interrupts.
[bwh: Backported to 3.16:
- bcmgenet_irq_task() only handles UMAC_IRQ_LINK_UP and UMAC_IRQ_LINK_DOWN status flags
- Adjust context]
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 73 ++++++++++++++------------ drivers/net/ethernet/broadcom/genet/bcmgenet.h | 6 ++- 2 files changed, 44 insertions(+), 35 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +38 -32
@@ -1858,42 +1858,46 @@ static int bcmgenet_poll(struct napi_str/* Interrupt bottom half */ static void bcmgenet_irq_task (struct work_struct *work) { +unsigned long flags; +unsigned int status;struct bcmgenet_priv *priv =container_of ( work, struct bcmgenet_priv, bcmgenet_irq_work);netif_dbg (priv, intr, priv->dev,"%s\n" , __func__); +spin_lock_irqsave (&priv->lock, flags); + status = priv->irq0_stat; + priv->irq0_stat =0 ; +spin_unlock_irqrestore (&priv->lock, flags); +/* Link UP/DOWN event */ if ((priv->hw_params->flags &GENET_HAS_MDIO_INTR ) && - (priv->irq0_stat & (UMAC_IRQ_LINK_UP |UMAC_IRQ_LINK_DOWN ))) { + (status & (UMAC_IRQ_LINK_UP |UMAC_IRQ_LINK_DOWN )))phy_mac_interrupt (priv->phydev, - priv->irq0_stat &UMAC_IRQ_LINK_UP ); - priv->irq0_stat &= ~(UMAC_IRQ_LINK_UP |UMAC_IRQ_LINK_DOWN ); - } + status &UMAC_IRQ_LINK_UP ); }/* bcmgenet_isr1: interrupt handler for ring buffer. */ static irqreturn_t bcmgenet_isr1 (int irq,void *dev_id) {struct bcmgenet_priv *priv = dev_id; -unsigned int index; +unsigned int index, status; -/* Save irq status for bottom-half processing. */ - priv->irq1_stat = -bcmgenet_intrl2_1_readl (priv,INTRL2_CPU_STAT ) & +/* Read irq status */ + status =bcmgenet_intrl2_1_readl (priv,INTRL2_CPU_STAT ) & ~priv->int1_mask;/* clear inerrupts*/ -bcmgenet_intrl2_1_writel (priv, priv->irq1_stat,INTRL2_CPU_CLEAR ); +bcmgenet_intrl2_1_writel (priv, status,INTRL2_CPU_CLEAR );netif_dbg (priv, intr, priv->dev, -"%s: IRQ=0x%x\n" , __func__, priv->irq1_stat); +"%s: IRQ=0x%x\n" , __func__, status);/* Check the MBDONE interrupts. * packet is done, reclaim descriptors */ -if (priv->irq1_stat &0x0000ffff ) { +if (status &0x0000ffff ) { index =0 ;for (index =0 ; index <16 ; index++) { -if (priv->irq1_stat & (1 << index)) +if (status & (1 << index))bcmgenet_tx_reclaim (priv->dev, &priv->tx_rings[index]); }
@@ -1905,18 +1909,19 @@ static irqreturn_t bcmgenet_isr1(int irqstatic irqreturn_t bcmgenet_isr0 (int irq,void *dev_id) {struct bcmgenet_priv *priv = dev_id; +unsigned int status; +unsigned long flags; -/* Save irq status for bottom-half processing. */ - priv->irq0_stat = -bcmgenet_intrl2_0_readl (priv,INTRL2_CPU_STAT ) & +/* Read irq status */ + status =bcmgenet_intrl2_0_readl (priv,INTRL2_CPU_STAT ) & ~bcmgenet_intrl2_0_readl (priv,INTRL2_CPU_MASK_STATUS );/* clear inerrupts*/ -bcmgenet_intrl2_0_writel (priv, priv->irq0_stat,INTRL2_CPU_CLEAR ); +bcmgenet_intrl2_0_writel (priv, status,INTRL2_CPU_CLEAR );netif_dbg (priv, intr, priv->dev, -"IRQ=0x%x\n" , priv->irq0_stat); +"IRQ=0x%x\n" , status); -if (priv->irq0_stat & (UMAC_IRQ_RXDMA_BDONE |UMAC_IRQ_RXDMA_PDONE )) { +if (status & (UMAC_IRQ_RXDMA_BDONE |UMAC_IRQ_RXDMA_PDONE )) {/* We use NAPI(software interrupt throttling, if * Rx Descriptor throttling is not used. * Disable interrupt, will be enabled in the poll method.
@@ -1927,28 +1932,27 @@ static irqreturn_t bcmgenet_isr0(int irq__napi_schedule (&priv->napi); } } -if (priv->irq0_stat & +if (status & (UMAC_IRQ_TXDMA_BDONE |UMAC_IRQ_TXDMA_PDONE )) {/* Tx reclaim */ bcmgenet_tx_reclaim (priv->dev, &priv->tx_rings[DESC_INDEX ]); } -if (priv->irq0_stat & (UMAC_IRQ_PHY_DET_R | -UMAC_IRQ_PHY_DET_F | -UMAC_IRQ_LINK_UP | -UMAC_IRQ_LINK_DOWN | -UMAC_IRQ_HFB_SM | -UMAC_IRQ_HFB_MM | -UMAC_IRQ_MPD_R )) { -/* all other interested interrupts handled in bottom half */ -schedule_work (&priv->bcmgenet_irq_work); - } -if ((priv->hw_params->flags &GENET_HAS_MDIO_INTR ) && - priv->irq0_stat & (UMAC_IRQ_MDIO_DONE |UMAC_IRQ_MDIO_ERROR )) { - priv->irq0_stat &= ~(UMAC_IRQ_MDIO_DONE |UMAC_IRQ_MDIO_ERROR ); + status & (UMAC_IRQ_MDIO_DONE |UMAC_IRQ_MDIO_ERROR )) {wake_up (&priv->wq); } +/* all other interested interrupts handled in bottom half */ + status &=UMAC_IRQ_LINK_UP |UMAC_IRQ_LINK_DOWN ; +if (status) { +/* Save irq status for bottom-half processing. */ +spin_lock_irqsave (&priv->lock, flags); + priv->irq0_stat |= status; +spin_unlock_irqrestore (&priv->lock, flags); + +schedule_work (&priv->bcmgenet_irq_work); + } +return IRQ_HANDLED ; }
@@ -2531,6 +2535,8 @@ static int bcmgenet_probe(struct platfor goto err; } +spin_lock_init (&priv->lock); +SET_NETDEV_DEV (dev, &pdev->dev);dev_set_drvdata (&pdev->dev, dev);ether_addr_copy (dev->dev_addr, macaddr);
drivers/net/ethernet/broadcom/genet/bcmgenet.h +3 -1
@@ -571,8 +571,10 @@ struct bcmgenet_priv {struct work_struct bcmgenet_irq_work;int irq0;int irq1; + +/* shared status */ +spinlock_t lock;unsigned int irq0_stat; -unsigned int irq1_stat;/* HW descriptors/checksum variables */ bool desc_64b_en;
PATCH 31/178 net: bcmgenet: Power up the internal PHY before probing the MII
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Doug Berger <[email protected]>
commit 6be371b053dc86f11465cc1abce2e99bda0a0574 upstream.
When using the internal PHY it must be powered up when the MII is probed or the PHY will not be detected. Since the PHY is powered up at reset this has not been a problem. However, when the kernel is restarted with kexec the PHY will likely be powered down when the kernel starts so it will not be detected and the Ethernet link will not be established.
This commit explicitly powers up the internal PHY when the GENET driver is probed to correct this behavior.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +8 -0
@@ -2500,6 +2500,7 @@ static int bcmgenet_probe(struct platforconst void *macaddr;struct resource *r;int err = -EIO ; +const char *phy_mode_str;/* Up to GENET_MAX_MQ_CNT + 1 TX queues and a single RX queue */ dev =alloc_etherdev_mqs (sizeof (*priv),GENET_MAX_MQ_CNT +1 ,1 );
@@ -2581,6 +2582,13 @@ static int bcmgenet_probe(struct platforif (!IS_ERR (priv->clk))clk_prepare_enable (priv->clk); +/* If this is an internal GPHY, power it on now, before UniMAC is +* brought out of reset as absolutely no UniMAC activity is allowed +*/ +if (dn && !of_property_read_string (dn,"phy-mode" , &phy_mode_str) && + !strcasecmp (phy_mode_str,"internal" )) +bcmgenet_power_up (priv,GENET_POWER_PASSIVE ); + err =reset_umac (priv);if (err) goto err_clk_disable;
PATCH 32/178 net: bcmgenet: add begin/complete ethtool ops
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Edwin Chan <[email protected]>
commit 89316fa34ab8afac8d693f41a5bc268673f1da15 upstream.
Make sure clock is enabled for ethtool ops.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +18 -0
@@ -370,6 +370,22 @@ static inline void bcmgenet_rdma_ring_wr genet_dma_ring_regs[r]); } +static int bcmgenet_begin (struct net_device *dev) +{ +struct bcmgenet_priv *priv =netdev_priv (dev); + +/* Turn on the clock */ +return clk_prepare_enable (priv->clk); +} + +static void bcmgenet_complete (struct net_device *dev) +{ +struct bcmgenet_priv *priv =netdev_priv (dev); + +/* Turn off the clock */ +clk_disable_unprepare (priv->clk); +} +static int bcmgenet_get_settings (struct net_device *dev,struct ethtool_cmd *cmd) {
@@ -774,6 +790,8 @@ static void bcmgenet_get_ethtool_stats(s/* standard ethtool support functions. */ static struct ethtool_ops bcmgenet_ethtool_ops = { + .begin = bcmgenet_begin, + .complete = bcmgenet_complete, .get_strings = bcmgenet_get_strings, .get_sset_count = bcmgenet_get_sset_count, .get_ethtool_stats = bcmgenet_get_ethtool_stats,
PATCH 33/178 x86/platform/intel-mid: Correct MSI IRQ line for watchdog device
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
commit 80354c29025833acd72ddac1ffa21c6cb50128cd upstream.
The interrupt line used for the watchdog is 12, according to the official Intel Edison BSP code.
And indeed after fixing it we start getting an interrupt and thus the watchdog starts working again:
[ 191.699951] Kernel panic - not syncing: Kernel Watchdog
--- arch/x86/platform/intel-mid/device_libs/platform_wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/platform/intel-mid/device_libs/platform_wdt.c +1 -1
@@ -17,7 +17,7 @@#include <asm/intel-mid.h> #include <asm/io_apic.h> -#define TANGIER_EXT_TIMER0_MSI 15 +#define TANGIER_EXT_TIMER0_MSI 12static struct platform_device wdt_dev = { .name ="intel_mid_wdt" ,
PATCH 34/178 NFSv4: fix a reference leak caused WARNING messages
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Kinglong Mee <[email protected]>
commit 366a1569bff3fe14abfdf9285e31e05e091745f5 upstream.
Because nfs4_opendata_access() has close the state when access is denied, so the state isn't leak.
Rather than revert the commit a974deee47, I'd like clean the strange state close.
[ 1615.094218] ------------[ cut here ]------------ [ 1615.094607] WARNING: CPU: 0 PID: 23702 at lib/list_debug.c:31 __list_add_valid+0x8e/0xa0 [ 1615.094913] list_add double add: new=ffff9d7901d9f608, prev=ffff9d7901d9f608, next=ffff9d7901ee8dd0. [ 1615.095458] Modules linked in: nfsv4(E) nfs(E) nfsd(E) tun bridge stp llc fuse ip_set nfnetlink vmw_vsock_vmci_transport vsock f2fs snd_seq_midi snd_seq_midi_event fscrypto coretemp ppdev crct10dif_pclmul crc32_pclmul ghash_clmulni_intel intel_rapl_perf vmw_balloon snd_ens1371 joydev gameport snd_ac97_codec ac97_bus snd_seq snd_pcm snd_rawmidi snd_timer snd_seq_device snd soundcore nfit parport_pc parport acpi_cpufreq tpm_tis tpm_tis_core tpm i2c_piix4 vmw_vmci shpchp auth_rpcgss nfs_acl lockd(E) grace sunrpc(E) xfs libcrc32c vmwgfx drm_kms_helper ttm drm crc32c_intel mptspi e1000 serio_raw scsi_transport_spi mptscsih mptbase ata_generic pata_acpi fjes [last unloaded: nfs] [ 1615.097663] CPU: 0 PID: 23702 Comm: fstest Tainted: G W E 4.11.0-rc1+ #517 [ 1615.098015] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 07/02/2015 [ 1615.098807] Call Trace: [ 1615.099183] dump_stack+0x63/0x86 [ 1615.099578] __warn+0xcb/0xf0 [ 1615.099967] warn_slowpath_fmt+0x5f/0x80 [ 1615.100370] __list_add_valid+0x8e/0xa0 [ 1615.100760] nfs4_put_state_owner+0x75/0xc0 [nfsv4] [ 1615.101136] __nfs4_close+0x109/0x140 [nfsv4] [ 1615.101524] nfs4_close_state+0x15/0x20 [nfsv4] [ 1615.101949] nfs4_close_context+0x21/0x30 [nfsv4] [ 1615.102691] __put_nfs_open_context+0xb8/0x110 [nfs] [ 1615.103155] put_nfs_open_context+0x10/0x20 [nfs] [ 1615.103586] nfs4_file_open+0x13b/0x260 [nfsv4] [ 1615.103978] do_dentry_open+0x20a/0x2f0 [ 1615.104369] ? nfs4_copy_file_range+0x30/0x30 [nfsv4] [ 1615.104739] vfs_open+0x4c/0x70 [ 1615.105106] ? may_open+0x5a/0x100 [ 1615.105469] path_openat+0x623/0x1420 [ 1615.105823] do_filp_open+0x91/0x100 [ 1615.106174] ? __alloc_fd+0x3f/0x170 [ 1615.106568] do_sys_open+0x130/0x220 [ 1615.106920] ? __put_cred+0x3d/0x50 [ 1615.107256] SyS_open+0x1e/0x20 [ 1615.107588] entry_SYSCALL_64_fastpath+0x1a/0xa9 [ 1615.107922] RIP: 0033:0x7fab599069b0 [ 1615.108247] RSP: 002b:00007ffcf0600d78 EFLAGS: 00000246 ORIG_RAX: 0000000000000002 [ 1615.108575] RAX: ffffffffffffffda RBX: 00007fab59bcfae0 RCX: 00007fab599069b0 [ 1615.108896] RDX: 0000000000000200 RSI: 0000000000000200 RDI: 00007ffcf060255e [ 1615.109211] RBP: 0000000000040010 R08: 0000000000000000 R09: 0000000000000016 [ 1615.109515] R10: 00000000000006a1 R11: 0000000000000246 R12: 0000000000041000 [ 1615.109806] R13: 0000000000040010 R14: 0000000000001000 R15: 0000000000002710 [ 1615.110152] ---[ end trace 96ed63b1306bf2f3 ]---
--- fs/nfs/nfs4proc.c | 2 -- 1 file changed, 2 deletions(-)
fs/nfs/nfs4proc.c +0 -2
@@ -1980,8 +1980,6 @@ static int nfs4_opendata_access(struct rif ((mask & ~cache.mask & (MAY_READ |MAY_EXEC )) ==0 )return 0 ; -/* even though OPEN succeeded, access is denied. Close the file */ -nfs4_close_state (state, fmode);return -EACCES ; }
PATCH 35/178 ipv6: make ECMP route replacement less greedy
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
commit 67e194007be08d071294456274dd53e0a04fdf90 upstream.
Commit 27596472473a ("ipv6: fix ECMP route replacement") introduced a loop that removes all siblings of an ECMP route that is being replaced. However, this loop doesn't stop when it has replaced siblings, and keeps removing other routes with a higher metric. We also end up triggering the WARN_ON after the loop, because after this nsiblings < 0.
Instead, stop the loop when we have taken care of all routes with the same metric as the route being replaced.
Reproducer:
===========
#!/bin/sh
ip netns add ns1
ip netns add ns2
ip -net ns1 link set lo up
for x in 0 1 2 ; do
ip link add veth$x netns ns2 type veth peer name eth$x netns ns1 ip -net ns1 link set eth$x up
ip -net ns2 link set veth$x up
done
ip -net ns1 -6 r a 2000::/64 nexthop via fe80::0 dev eth0 \
nexthop via fe80::1 dev eth1 nexthop via fe80::2 dev eth2
ip -net ns1 -6 r a 2000::/64 via fe80::42 dev eth0 metric 256 ip -net ns1 -6 r a 2000::/64 via fe80::43 dev eth0 metric 2048
echo "before replace, 3 routes"
ip -net ns1 -6 r | grep -v '^fe80\|^ff00'
echo
ip -net ns1 -6 r c 2000::/64 nexthop via fe80::4 dev eth0 \
nexthop via fe80::5 dev eth1 nexthop via fe80::6 dev eth2
echo "after replace, only 2 routes, metric 2048 is gone" ip -net ns1 -6 r | grep -v '^fe80\|^ff00'
--- net/ipv6/ip6_fib.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv6/ip6_fib.c +2 -0
@@ -862,6 +862,8 @@ add: ins = &rt->dst.rt6_next; iter = *ins;while (iter) { +if (iter->rt6i_metric > rt->rt6i_metric) +break ;if (rt6_qualify_for_ecmp (iter)) { *ins = iter->dst.rt6_next;fib6_purge_rt (iter, fn, info->nl_net);
PATCH 36/178 isdn/gigaset: fix NULL-deref at probe
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 68c32f9c2a36d410aa242e661506e5b2c2764179 upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer should a malicious device lack endpoints.
direct USB connection")
Cc: Hansjoerg Lipp <[email protected]>
--- drivers/isdn/gigaset/bas-gigaset.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/isdn/gigaset/bas-gigaset.c +3 -0
@@ -2317,6 +2317,9 @@ static int gigaset_probe(struct usb_intereturn -ENODEV ; } +if (hostif->desc.bNumEndpoints <1 ) +return -ENODEV ; + dev_info(&udev->dev, "%s: Device matched (Vendor: 0x%x, Product: 0x%x)\n", __func__, le16_to_cpu(udev->descriptor.idVendor),
PATCH 37/178 net: wimax/i2400m: fix NULL-deref at probe
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 6e526fdff7be4f13b24f929a04c0e9ae6761291e upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer or accessing memory beyond the endpoint array should a malicious device lack the expected endpoints.
The endpoints are specifically dereferenced in the i2400m_bootrom_init path during probe (e.g. in i2400mu_tx_bulk_out).
and reset backends")
Cc: Inaky Perez-Gonzalez <[email protected]>
--- drivers/net/wimax/i2400m/usb.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wimax/i2400m/usb.c +3 -0
@@ -467,6 +467,9 @@ int i2400mu_probe(struct usb_interface *struct i2400mu *i2400mu;struct usb_device *usb_dev =interface_to_usbdev (iface); +if (iface->cur_altsetting->desc.bNumEndpoints <4 ) +return -ENODEV ; +if (usb_dev->speed !=USB_SPEED_HIGH )dev_err (dev,"device not connected as high speed\n" );
PATCH 38/178 dccp/tcp: fix routing redirect race
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jon Maxwell <[email protected]>
commit 45caeaa5ac0b4b11784ac6f932c0ad4c6b67cda0 upstream.
As Eric Dumazet pointed out this also needs to be fixed in IPv6.
v2: Contains the IPv6 tcp/Ipv6 dccp patches as well.
We have seen a few incidents lately where a dst_enty has been freed with a dangling TCP socket reference (sk->sk_dst_cache) pointing to that dst_entry. If the conditions/timings are right a crash then ensues when the freed dst_entry is referenced later on. A Common crashing back trace is:
#8 [] page_fault at ffffffff8163e648
[exception RIP: __tcp_ack_snd_check+74]
.
.
#9 [] tcp_rcv_established at ffffffff81580b64
#10 [] tcp_v4_do_rcv at ffffffff8158b54a
#11 [] tcp_v4_rcv at ffffffff8158cd02
#12 [] ip_local_deliver_finish at ffffffff815668f4 #13 [] ip_local_deliver at ffffffff81566bd9
#14 [] ip_rcv_finish at ffffffff8156656d
#15 [] ip_rcv at ffffffff81566f06
#16 [] __netif_receive_skb_core at ffffffff8152b3a2 #17 [] __netif_receive_skb at ffffffff8152b608
#18 [] netif_receive_skb at ffffffff8152b690
#19 [] vmxnet3_rq_rx_complete at ffffffffa015eeaf [vmxnet3] #20 [] vmxnet3_poll_rx_only at ffffffffa015f32a [vmxnet3] #21 [] net_rx_action at ffffffff8152bac2
#22 [] __do_softirq at ffffffff81084b4f
#23 [] call_softirq at ffffffff8164845c
#24 [] do_softirq at ffffffff81016fc5
#25 [] irq_exit at ffffffff81084ee5
#26 [] do_IRQ at ffffffff81648ff8
Of course it may happen with other NIC drivers as well.
It's found the freed dst_entry here:
224 static bool tcp_in_quickack_mode(struct sock *sk)↩ 225 {↩
226 ▹ const struct inet_connection_sock *icsk = inet_csk(sk);↩
227 ▹ const struct dst_entry *dst = __sk_dst_get(sk);↩
228 ↩
229 ▹ return (dst && dst_metric(dst, RTAX_QUICKACK)) ||↩
230 ▹ ▹ (icsk->icsk_ack.quick && !icsk->icsk_ack.pingpong);↩
231 }↩
But there are other backtraces attributed to the same freed dst_entry in netfilter code as well.
All the vmcores showed 2 significant clues:
- Remote hosts behind the default gateway had always been redirected to a different gateway. A rtable/dst_entry will be added for that host. Making more dst_entrys with lower reference counts. Making this more probable.
- All vmcores showed a postitive LockDroppedIcmps value, e.g:
LockDroppedIcmps 267
A closer look at the tcp_v4_err() handler revealed that do_redirect() will run regardless of whether user space has the socket locked. This can result in a race condition where the same dst_entry cached in sk->sk_dst_entry can be decremented twice for the same socket via:
do_redirect()->__sk_dst_check()-> dst_release().
Which leads to the dst_entry being prematurely freed with another socket pointing to it via sk->sk_dst_cache and a subsequent crash.
To fix this skip do_redirect() if usespace has the socket locked. Instead let the redirect take place later when user space does not have the socket locked.
The dccp/IPv6 code is very similar in this respect, so fixing it there too.
As Eric Garver pointed out the following commit now invalidates routes. Which can set the dst->obsolete flag so that ipv4_dst_check() returns null and triggers the dst_release().
--- net/dccp/ipv4.c | 3 ++- net/dccp/ipv6.c | 8 +++++--- net/ipv4/tcp_ipv4.c | 3 ++- net/ipv6/tcp_ipv6.c | 8 +++++--- 4 files changed, 14 insertions(+), 8 deletions(-)
net/dccp/ipv4.c +2 -1
@@ -264,7 +264,8 @@ static void dccp_v4_err(struct sk_buff *switch (type) {case ICMP_REDIRECT : -dccp_do_redirect (skb, sk); +if (!sock_owned_by_user (sk)) +dccp_do_redirect (skb, sk); goto out;case ICMP_SOURCE_QUENCH :/* Just silently ignore these. */
net/dccp/ipv6.c +5 -3
@@ -132,10 +132,12 @@ static void dccp_v6_err(struct sk_buff * np =inet6_sk (sk);if (type ==NDISC_REDIRECT ) { -struct dst_entry *dst =__sk_dst_check (sk, np->dst_cookie); +if (!sock_owned_by_user (sk)) { +struct dst_entry *dst =__sk_dst_check (sk, np->dst_cookie); -if (dst) - dst->ops->redirect (dst, sk, skb); +if (dst) + dst->ops->redirect (dst, sk, skb); + } goto out; }
net/ipv4/tcp_ipv4.c +2 -1
@@ -391,7 +391,8 @@ void tcp_v4_err(struct sk_buff *icmp_skbswitch (type) {case ICMP_REDIRECT : -do_redirect (icmp_skb, sk); +if (!sock_owned_by_user (sk)) +do_redirect (icmp_skb, sk); goto out;case ICMP_SOURCE_QUENCH :/* Just silently ignore these. */
net/ipv6/tcp_ipv6.c +5 -3
@@ -386,10 +386,12 @@ static void tcp_v6_err(struct sk_buff *s np =inet6_sk (sk);if (type ==NDISC_REDIRECT ) { -struct dst_entry *dst =__sk_dst_check (sk, np->dst_cookie); +if (!sock_owned_by_user (sk)) { +struct dst_entry *dst =__sk_dst_check (sk, np->dst_cookie); -if (dst) - dst->ops->redirect (dst, sk, skb); +if (dst) + dst->ops->redirect (dst, sk, skb); + } goto out; }
PATCH 39/178 USB: idmouse: fix NULL-deref at probe
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit b0addd3fa6bcd119be9428996d5d4522479ab240 upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer should a malicious device lack endpoints.
--- drivers/usb/misc/idmouse.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/misc/idmouse.c +3 -0
@@ -346,6 +346,9 @@ static int idmouse_probe(struct usb_inteif (iface_desc->desc.bInterfaceClass !=0x0A )return -ENODEV ; +if (iface_desc->desc.bNumEndpoints <1 ) +return -ENODEV ; +/* allocate memory for our device state and initialize it */ dev =kzalloc (sizeof (*dev),GFP_KERNEL );if (dev ==NULL )
PATCH 40/178 USB: uss720: fix NULL-deref at probe
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit f259ca3eed6e4b79ac3d5c5c9fb259fb46e86217 upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer or accessing memory beyond the endpoint array should a malicious device lack the expected endpoints.
Note that the endpoint access that causes the NULL-deref is currently only used for debugging purposes during probe so the oops only happens when dynamic debugging is enabled. This means the driver could be rewritten to continue to accept device with only two endpoints, should such devices exist.
--- drivers/usb/misc/uss720.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/misc/uss720.c +5 -0
@@ -715,6 +715,11 @@ static int uss720_probe(struct usb_inter interface = intf->cur_altsetting; +if (interface->desc.bNumEndpoints <3 ) { +usb_put_dev (usbdev); +return -ENODEV ; + } +/* * Allocate parport interface */
PATCH 41/178 USB: wusbcore: fix NULL-deref at probe
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 03ace948a4eb89d1cf51c06afdfc41ebca5fdb27 upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer or accessing memory beyond the endpoint array should a malicious device lack the expected endpoints.
This specifically fixes the NULL-pointer dereference when probing HWA HC devices.
--- drivers/usb/wusbcore/wa-hc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/wusbcore/wa-hc.c +3 -0
@@ -39,6 +39,9 @@ int wa_create(struct wahc *wa, struct usint result;struct device *dev = &iface->dev; +if (iface->cur_altsetting->desc.bNumEndpoints <3 ) +return -ENODEV ; + result =wa_rpipes_create (wa);if (result <0 ) goto error_rpipes_create;
PATCH 42/178 uwb: hwa-rc: fix NULL-deref at probe
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit daf229b15907fbfdb6ee183aac8ca428cb57e361 upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer should a malicious device lack endpoints.
Note that the dereference happens in the start callback which is called during probe.
--- drivers/uwb/hwa-rc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/uwb/hwa-rc.c +3 -0
@@ -825,6 +825,9 @@ static int hwarc_probe(struct usb_interfstruct hwarc *hwarc;struct device *dev = &iface->dev; +if (iface->cur_altsetting->desc.bNumEndpoints <1 ) +return -ENODEV ; + result = -ENOMEM ; uwb_rc =uwb_rc_alloc ();if (uwb_rc ==NULL ) {
PATCH 43/178 uwb: i1480-dfu: fix NULL-deref at probe
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 4ce362711d78a4999011add3115b8f4b0bc25e8c upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer should a malicious device lack endpoints.
Note that the dereference happens in the cmd and wait_init_done callbacks which are called during probe.
--- drivers/uwb/i1480/dfu/usb.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/uwb/i1480/dfu/usb.c +3 -0
@@ -362,6 +362,9 @@ int i1480_usb_probe(struct usb_interface result); } +if (iface->cur_altsetting->desc.bNumEndpoints <1 ) +return -ENODEV ; + result = -ENOMEM ; i1480_usb =kzalloc (sizeof (*i1480_usb),GFP_KERNEL );if (i1480_usb ==NULL ) {
PATCH 44/178 usb-core: Add LINEAR_FRAME_INTR_BINTERVAL USB quirk
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Samuel Thibault <[email protected]>
commit 3243367b209faed5c320a4e5f9a565ee2a2ba958 upstream.
Some USB 2.0 devices erroneously report millisecond values in bInterval. The generic config code manages to catch most of them, but in some cases it's not completely enough.
The case at stake here is a USB 2.0 braille device, which wants to announce 10ms and thus sets bInterval to 10, but with the USB 2.0 computation that yields to 64ms. It happens that one can type fast enough to reach this interval and get the device buffers overflown, leading to problematic latencies. The generic config code does not catch this case because the 64ms is considered a sane enough value.
This change thus adds a USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL quirk to mark devices which actually report milliseconds in bInterval, and marks Vario Ultra devices as needing it.
--- drivers/usb/core/config.c | 10 ++++++++++ drivers/usb/core/quirks.c | 8 ++++++++ include/linux/usb/quirks.h | 6 ++++++ 3 files changed, 24 insertions(+)
drivers/usb/core/config.c +10 -0
@@ -245,6 +245,16 @@ static int usb_parse_endpoint(struct dev/* * Adjust bInterval for quirked devices. +*/ +/* +* This quirk fixes bIntervals reported in ms. +*/ +if (to_usb_device (ddev)->quirks & +USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL ) { + n =clamp (fls (d->bInterval) +3 , i, j); + i = j = n; + } +/* * This quirk fixes bIntervals reported in * linear microframes. */
drivers/usb/core/quirks.c +8 -0
@@ -167,6 +167,14 @@ static const struct usb_device_id usb_qu/* M-Systems Flash Disk Pioneers */ { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME }, + /* Baum Vario Ultra */ + { USB_DEVICE(0x0904, 0x6101), .driver_info = + USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL }, + { USB_DEVICE(0x0904, 0x6102), .driver_info = + USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL }, + { USB_DEVICE(0x0904, 0x6103), .driver_info = + USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL }, + /* Keytouch QWERTY Panel keyboard */ { USB_DEVICE(0x0926, 0x3333), .driver_info = USB_QUIRK_CONFIG_INTF_STRINGS },
include/linux/usb/quirks.h +6 -0
@@ -50,4 +50,10 @@/* device can't handle Link Power Management */ #define USB_QUIRK_NO_LPM BIT(10) +/* +* Device reports its bInterval as linear frames instead of the +* USB 2.0 calculation. +*/ +#define USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL BIT(11) +#endif /* __LINUX_USB_QUIRKS_H */
PATCH 45/178 USB: serial: option: add Quectel UC15, UC20, EC21, and EC25 modems
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dan Williams <[email protected]>
commit 6e9f44eaaef0df7b846e9316fa9ca72a02025d44 upstream.
Add Quectel UC15, UC20, EC21, and EC25. The EC20 is handled by qcserial due to a USB VID/PID conflict with an existing Acer device.
--- drivers/usb/serial/option.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/usb/serial/option.c +16 -1
@@ -234,6 +234,14 @@ static void option_instat_callback(struc#define BANDRICH_PRODUCT_1012 0x1012#define QUALCOMM_VENDOR_ID 0x05C6 +/* These Quectel products use Qualcomm's vendor ID */ +#define QUECTEL_PRODUCT_UC20 0x9003 +#define QUECTEL_PRODUCT_UC15 0x9090 + +#define QUECTEL_VENDOR_ID 0x2c7c +/* These Quectel products use Quectel's vendor ID */ +#define QUECTEL_PRODUCT_EC21 0x0121 +#define QUECTEL_PRODUCT_EC25 0x0125#define SIERRA_VENDOR_ID 0x1199
@@ -1180,7 +1188,14 @@ static const struct usb_device_id option .driver_info = (kernel_ulong_t)&sierra_mc73xx_blacklist }, /* MC73xx */ { USB_DEVICE_INTERFACE_CLASS(SIERRA_VENDOR_ID, 0x9041, 0xff), .driver_info = (kernel_ulong_t)&sierra_mc73xx_blacklist }, /* MC7305/MC7355 */ - { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9003), /* Quectel UC20 */ +/* Quectel products using Qualcomm vendor ID */ + { USB_DEVICE(QUALCOMM_VENDOR_ID, QUECTEL_PRODUCT_UC15)}, + { USB_DEVICE(QUALCOMM_VENDOR_ID, QUECTEL_PRODUCT_UC20), + .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, + /* Quectel products using Quectel vendor ID */ + { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC21), + .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, + { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC25), .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) }, { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) },
PATCH 46/178 mmc: sdhci-of-arasan: fix incorrect timeout clock
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Anssi Hannula <[email protected]>
commit 16681037e75ce08f2980ac5dbb03414429c7a55d upstream.
sdhci_arasan_get_timeout_clock() divides the frequency it has with (1 << (13 + divisor)).
However, the divisor is not some Arasan-specific value, but instead is just the Data Timeout Counter Value from the SDHCI Timeout Control Register.
Applying it here like this is wrong as the sdhci driver already takes that value into account when calculating timeouts, and in fact it *sets* that register value based on how long a timeout is wanted.
Additionally, sdhci core interprets the .get_timeout_clock callback return value as if it were read from hardware registers, i.e. the unit should be kHz or MHz depending on SDHCI_TIMEOUT_CLK_UNIT capability bit. This bit is set at least on the tested Zynq-7000 SoC.
With the tested hardware (SDHCI_TIMEOUT_CLK_UNIT set) this results in too high a timeout clock rate being reported, causing the core to use longer-than-needed timeouts. Additionally, on a partitioned MMC (therefore having erase_group_def bit set) mmc_calc_max_discard() disables discard support as it looks like controller does not support the long timeouts needed for that.
Do not apply the extra divisor and return the timeout clock in the expected unit.
Tested with a Zynq-7000 SoC and a partitioned Toshiba THGBMAG5A1JBAWR eMMC card.
---
drivers/mmc/host/sdhci-of-arasan.c +5 -11
@@ -22,12 +22,6 @@#include <linux/module.h> #include "sdhci-pltfm.h" -#define SDHCI_ARASAN_CLK_CTRL_OFFSET 0x2c - -#define CLK_CTRL_TIMEOUT_SHIFT 16 -#define CLK_CTRL_TIMEOUT_MASK (0xf << CLK_CTRL_TIMEOUT_SHIFT) -#define CLK_CTRL_TIMEOUT_MIN_EXP 13 -/** * struct sdhci_arasan_data * @clk_ahb: Pointer to the AHB clock
@@ -38,15 +32,15 @@ struct sdhci_arasan_data {static unsigned int sdhci_arasan_get_timeout_clock (struct sdhci_host *host) { -u32 div;unsigned long freq;struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); - div =readl (host->ioaddr +SDHCI_ARASAN_CLK_CTRL_OFFSET ); - div = (div &CLK_CTRL_TIMEOUT_MASK ) >>CLK_CTRL_TIMEOUT_SHIFT ; +/* SDHCI timeout clock is in kHz */ + freq =DIV_ROUND_UP (clk_get_rate (pltfm_host->clk),1000 ); - freq =clk_get_rate (pltfm_host->clk); - freq /=1 << (CLK_CTRL_TIMEOUT_MIN_EXP + div); +/* or in MHz */ +if (host->caps &SDHCI_TIMEOUT_CLK_UNIT ) + freq =DIV_ROUND_UP (freq,1000 );return freq; }
PATCH 47/178 futex: Fix potential use-after-free in FUTEX_REQUEUE_PI
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <[email protected]>
commit c236c8e95a3d395b0494e7108f0d41cf36ec107c upstream.
While working on the futex code, I stumbled over this potential use-after-free scenario. Dmitry triggered it later with syzkaller.
pi_mutex is a pointer into pi_state, which we drop the reference on in unqueue_me_pi(). So any access to that pointer after that is bad.
Since other sites already do rt_mutex_unlock() with hb->lock held, see for example futex_lock_pi(), simply move the unlock before unqueue_me_pi().
--- kernel/futex.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
kernel/futex.c +11 -9
@@ -2578,7 +2578,6 @@ static int futex_wait_requeue_pi(u32 __u {struct hrtimer_sleeper timeout, *to =NULL ;struct rt_mutex_waiter rt_waiter; -struct rt_mutex *pi_mutex =NULL ;struct futex_hash_bucket *hb;union futex_key key2 =FUTEX_KEY_INIT ;struct futex_q q = futex_q_init;
@@ -2670,6 +2669,8 @@ static int futex_wait_requeue_pi(u32 __uspin_unlock (q.lock_ptr); } }else { +struct rt_mutex *pi_mutex; +/* * We have been woken up by futex_unlock_pi(), a timeout, or a * signal. futex_unlock_pi() will not destroy the lock_ptr nor
@@ -2693,18 +2694,19 @@ static int futex_wait_requeue_pi(u32 __uif (res) ret = (res <0 ) ? res :0 ; +/* +* If fixup_pi_state_owner() faulted and was unable to handle +* the fault, unlock the rt_mutex and return the fault to +* userspace. +*/ +if (ret &&rt_mutex_owner (pi_mutex) == current) +rt_mutex_unlock (pi_mutex); +/* Unqueue and drop the lock. */ unqueue_me_pi (&q); } -/* -* If fixup_pi_state_owner() faulted and was unable to handle the -* fault, unlock the rt_mutex and return the fault to userspace. -*/ -if (ret == -EFAULT ) { -if (pi_mutex &&rt_mutex_owner (pi_mutex) == current) -rt_mutex_unlock (pi_mutex); - }else if (ret == -EINTR ) { +if (ret == -EINTR ) {/* * We've already been requeued, but cannot restart by calling * futex_lock_pi() directly. We could restart this syscall, but
PATCH 48/178 futex: Add missing error handling to FUTEX_REQUEUE_PI
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <[email protected]>
commit 9bbb25afeb182502ca4f2c4f3f88af0681b34cae upstream.
Thomas spotted that fixup_pi_state_owner() can return errors and we fail to unlock the rt_mutex in that case.
--- kernel/futex.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/futex.c +2 -0
@@ -2661,6 +2661,8 @@ static int futex_wait_requeue_pi(u32 __uif (q.pi_state && (q.pi_state->owner != current)) {spin_lock (q.lock_ptr); ret =fixup_pi_state_owner (uaddr2, &q, current); +if (ret &&rt_mutex_owner (&q.pi_state->pi_mutex) == current) +rt_mutex_unlock (&q.pi_state->pi_mutex);/* * Drop the reference to the pi state which * the requeue_pi() code acquired for us.
PATCH 49/178 ext4: mark inode dirty after converting inline directory
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit b9cf625d6ecde0d372e23ae022feead72b4228a6 upstream.
If ext4_convert_inline_data() was called on a directory with inline data, the filesystem was left in an inconsistent state (as considered by e2fsck) because the file size was not increased to cover the new block. This happened because the inode was not marked dirty after i_disksize was updated. Fix this by marking the inode dirty at the end of ext4_finish_convert_inline_dir().
This bug was probably not noticed before because most users mark the inode dirty afterwards for other reasons. But if userspace executed FS_IOC_SET_ENCRYPTION_POLICY with invalid parameters, as exercised by 'kvm-xfstests -c adv generic/396', then the inode was never marked dirty after updating i_disksize.
--- fs/ext4/inline.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/ext4/inline.c +2 -3
@@ -1158,10 +1158,9 @@ static int ext4_finish_convert_inline_diset_buffer_uptodate (dir_block); err =ext4_handle_dirty_dirent_node (handle, inode, dir_block);if (err) - goto out; +return err;set_buffer_verified (dir_block); -out: -return err; +return ext4_mark_inode_dirty (handle, inode); } static int ext4_convert_inline_data_nolock(handle_t *handle,
PATCH 50/178 iio: adc: ti_am335x_adc: fix fifo overrun recovery
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Michael Engl <[email protected]>
commit e83bb3e6f3efa21f4a9d883a25d0ecd9dfb431e1 upstream.
The tiadc_irq_h(int irq, void *private) function is handling FIFO overruns by clearing flags, disabling and enabling the ADC to recover.
If the ADC is running in continuous mode a FIFO overrun happens regularly. If the disabling of the ADC happens concurrently with a new conversion. It might happen that the enabling of the ADC is ignored by the hardware. This stops the ADC permanently. No more interrupts are triggered.
According to the AM335x Reference Manual (SPRUH73H October 2011 - Revised April 2013 - Chapter 12.4 and 12.5) it is necessary to check the ADC FSM bits in REG_ADCFSM before enabling the ADC again. Because the disabling of the ADC is done right after the current conversion has been finished.
To trigger this bug it is necessary to run the ADC in continuous mode. The ADC values of all channels need to be read in an endless loop. The bug appears within the first 6 hours (~5.4 million handled FIFO overruns). The user space application will hang on reading new values from the character device.
support")
--- drivers/iio/adc/ti_am335x_adc.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/iio/adc/ti_am335x_adc.c +12 -1
@@ -123,7 +123,9 @@ static irqreturn_t tiadc_irq_h(int irq, {struct iio_dev *indio_dev = private;struct tiadc_device *adc_dev =iio_priv (indio_dev); -unsigned int status, config; +unsigned int status, config, adc_fsm; +unsigned short count =0 ; + status =tiadc_readl (adc_dev,REG_IRQSTATUS );/*
@@ -137,6 +139,15 @@ static irqreturn_t tiadc_irq_h(int irq,tiadc_writel (adc_dev,REG_CTRL , config);tiadc_writel (adc_dev,REG_IRQSTATUS ,IRQENB_FIFO1OVRRUN |IRQENB_FIFO1UNDRFLW |IRQENB_FIFO1THRES ); + +/* wait for idle state. +* ADC needs to finish the current conversion +* before disabling the module +*/ +do { + adc_fsm =tiadc_readl (adc_dev,REG_ADCFSM ); + }while (adc_fsm !=0x10 && count++ <100 ); +tiadc_writel (adc_dev,REG_CTRL , (config |CNTRLREG_TSCSSENB ));return IRQ_HANDLED ; }else if (status &IRQENB_FIFO1THRES ) {
PATCH 51/178 net: properly release sk_frag.page
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit 22a0e18eac7a9e986fec76c60fa4a2926d1291e2 upstream.
I mistakenly added the code to release sk->sk_frag in sk_common_release() instead of sk_destruct()
TCP sockets using sk->sk_allocation == GFP_ATOMIC do no call sk_common_release() at close time, thus leaking one (order-3) page.
iSCSI is using such sockets.
--- net/core/sock.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
net/core/sock.c +5 -5
@@ -1448,6 +1448,11 @@ static void __sk_free(struct sock *sk)pr_debug ("%s: optmem leakage (%d bytes) detected\n" , __func__,atomic_read (&sk->sk_omem_alloc)); +if (sk->sk_frag.page) { +put_page (sk->sk_frag.page); + sk->sk_frag.page =NULL ; + } +if (sk->sk_peer_cred)put_cred (sk->sk_peer_cred);put_pid (sk->sk_peer_pid);
@@ -2685,11 +2690,6 @@ void sk_common_release(struct sock *sk)sk_refcnt_debug_release (sk); -if (sk->sk_frag.page) { -put_page (sk->sk_frag.page); - sk->sk_frag.page =NULL ; - } -sock_put (sk); }EXPORT_SYMBOL (sk_common_release);
PATCH 52/178 sched/loadavg: Avoid loadavg spikes caused by delayed NO_HZ accounting
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Matt Fleming <[email protected]>
commit 6e5f32f7a43f45ee55c401c0b9585eb01f9629a8 upstream.
If we crossed a sample window while in NO_HZ we will add LOAD_FREQ to the pending sample window time on exit, setting the next update not one window into the future, but two.
This situation on exiting NO_HZ is described by:
this_rq->calc_load_update < jiffies < calc_load_update
In this scenario, what we should be doing is:
this_rq->calc_load_update = calc_load_update [ next window ]
But what we actually do is:
this_rq->calc_load_update = calc_load_update + LOAD_FREQ [ next+1 window ]
This has the effect of delaying load average updates for potentially up to ~9seconds.
This can result in huge spikes in the load average values due to per-cpu uninterruptible task counts being out of sync when accumulated across all CPUs.
It's safe to update the per-cpu active count if we wake between sample windows because any load that we left in 'calc_load_idle' will have been zero'd when the idle load was folded in calc_global_load().
This issue is easy to reproduce before,
commit 9d89c257dfb9 ("sched/fair: Rewrite runnable load and utilization average tracking")
just by forking short-lived process pipelines built from ps(1) and grep(1) in a loop. I'm unable to reproduce the spikes after that commit, but the bug still seems to be present from code review.
--- kernel/sched/proc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/proc.c +2 -2
@@ -205,8 +205,9 @@ void calc_load_exit_idle(void)struct rq *this_rq =this_rq ();/* -* If we're still before the sample window, we're done. +* If we're still before the pending sample window, we're done. */ + this_rq->calc_load_update = calc_load_update;if (time_before (jiffies, this_rq->calc_load_update))return ;
@@ -215,7 +216,6 @@ void calc_load_exit_idle(void)* accounted through the nohz accounting, so skip the entire deal and * sync up for the next window. */ - this_rq->calc_load_update = calc_load_update;if (time_before (jiffies, this_rq->calc_load_update +10 )) this_rq->calc_load_update +=LOAD_FREQ ; }
PATCH 53/178 nl80211: fix dumpit error path RTNL deadlocks
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit ea90e0dc8cecba6359b481e24d9c37160f6f524f upstream.
Sowmini pointed out Dmitry's RTNL deadlock report to me, and it turns out to be perfectly accurate - there are various error paths that miss unlock of the RTNL.
To fix those, change the locking a bit to not be conditional in all those nl80211_prepare_*_dump() functions, but make those require the RTNL to start with, and fix the buggy error paths. This also let me use sparse (by appropriately overriding the rtnl_lock/rtnl_unlock functions) to validate the changes.
[bwh: Backported to 3.16:
- Drop changes to nl80211_dump_interface(), nl80211_dump_mpp(), nl80211_prepare_vendor_dump(), nl80211_vendor_cmd_dump()
- Adjust context]
--- net/wireless/nl80211.c | 127 ++++++++++++++++++++++--------------------------- 1 file changed, 56 insertions(+), 71 deletions(-)
net/wireless/nl80211.c +21 -31
@@ -471,21 +471,17 @@ static int nl80211_prepare_wdev_dump(str {int err; -rtnl_lock (); -if (!cb->args[0 ]) { err =nlmsg_parse (cb->nlh,GENL_HDRLEN + nl80211_fam.hdrsize, nl80211_fam.attrbuf, nl80211_fam.maxattr, nl80211_policy);if (err) - goto out_unlock; +return err; *wdev =__cfg80211_wdev_from_attrs (sock_net (skb->sk), nl80211_fam.attrbuf); -if (IS_ERR (*wdev)) { - err =PTR_ERR (*wdev); - goto out_unlock; - } +if (IS_ERR (*wdev)) +return PTR_ERR (*wdev); *rdev =wiphy_to_rdev ((*wdev)->wiphy);/* 0 is the first index - add 1 to parse only once */ cb->args[0 ] = (*rdev)->wiphy_idx +1 ;
@@ -495,10 +491,8 @@ static int nl80211_prepare_wdev_dump(strstruct wiphy *wiphy =wiphy_idx_to_wiphy (cb->args[0 ] -1 );struct wireless_dev *tmp; -if (!wiphy) { - err = -ENODEV ; - goto out_unlock; - } +if (!wiphy) +return -ENODEV ; *rdev =wiphy_to_rdev (wiphy); *wdev =NULL ;
@@ -509,21 +503,11 @@ static int nl80211_prepare_wdev_dump(str } } -if (!*wdev) { - err = -ENODEV ; - goto out_unlock; - } +if (!*wdev) +return -ENODEV ; }return 0 ; - out_unlock: -rtnl_unlock (); -return err; -} - -static void nl80211_finish_wdev_dump (struct cfg80211_registered_device *rdev) -{ -rtnl_unlock (); }/* IE validation */
@@ -3727,9 +3711,10 @@ static int nl80211_dump_station(struct sint sta_idx = cb->args[2 ];int err; +rtnl_lock (); err =nl80211_prepare_wdev_dump (skb, cb, &rdev, &wdev);if (err) -return err; + goto out_err;if (!wdev->netdev) { err = -EINVAL ;
@@ -3765,7 +3750,7 @@ static int nl80211_dump_station(struct s cb->args[2 ] = sta_idx; err = skb->len; out_err: -nl80211_finish_wdev_dump (rdev); +rtnl_unlock ();return err; }
@@ -4443,9 +4428,10 @@ static int nl80211_dump_mpath(struct sk_int path_idx = cb->args[2 ];int err; +rtnl_lock (); err =nl80211_prepare_wdev_dump (skb, cb, &rdev, &wdev);if (err) -return err; + goto out_err;if (!rdev->ops->dump_mpath) { err = -EOPNOTSUPP ;
@@ -4479,7 +4465,7 @@ static int nl80211_dump_mpath(struct sk_ cb->args[2 ] = path_idx; err = skb->len; out_err: -nl80211_finish_wdev_dump (rdev); +rtnl_unlock ();return err; }
@@ -6157,9 +6143,12 @@ static int nl80211_dump_scan(struct sk_bint start = cb->args[2 ], idx =0 ;int err; +rtnl_lock (); err =nl80211_prepare_wdev_dump (skb, cb, &rdev, &wdev); -if (err) +if (err) { +rtnl_unlock ();return err; + }wdev_lock (wdev);spin_lock_bh (&rdev->bss_lock);
@@ -6182,7 +6171,7 @@ static int nl80211_dump_scan(struct sk_bwdev_unlock (wdev); cb->args[2 ] = idx; -nl80211_finish_wdev_dump (rdev); +rtnl_unlock ();return skb->len; }
@@ -6255,9 +6244,10 @@ static int nl80211_dump_survey(struct skint survey_idx = cb->args[2 ];int res; +rtnl_lock (); res =nl80211_prepare_wdev_dump (skb, cb, &rdev, &wdev);if (res) -return res; + goto out_err;if (!wdev->netdev) { res = -EINVAL ;
@@ -6303,7 +6293,7 @@ static int nl80211_dump_survey(struct sk cb->args[2 ] = survey_idx; res = skb->len; out_err: -nl80211_finish_wdev_dump (rdev); +rtnl_unlock ();return res; }
PATCH 54/178 perf/core: Fix event inheritance on fork()
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <[email protected]>
commit e7cc4865f0f31698ef2f7aac01a50e78968985b7 upstream.
While hunting for clues to a use-after-free, Oleg spotted that perf_event_init_context() can loose an error value with the result that fork() can succeed even though we did not fully inherit the perf event context.
--- kernel/events/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/events/core.c +3 -2
@@ -8177,7 +8177,7 @@ int perf_event_init_context(struct task_ ret =inherit_task_group (event, parent, parent_ctx, child, ctxn, &inherited_all);if (ret) -break ; + goto out_unlock; }/*
@@ -8193,7 +8193,7 @@ int perf_event_init_context(struct task_ ret =inherit_task_group (event, parent, parent_ctx, child, ctxn, &inherited_all);if (ret) -break ; + goto out_unlock; }raw_spin_lock_irqsave (&parent_ctx->lock, flags);
@@ -8221,6 +8221,7 @@ int perf_event_init_context(struct task_ }raw_spin_unlock_irqrestore (&parent_ctx->lock, flags); +out_unlock:mutex_unlock (&parent_ctx->mutex);perf_unpin_context (parent_ctx);
PATCH 55/178 mmc: ushc: fix NULL-deref at probe
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 181302dc7239add8ab1449c23ecab193f52ee6ab upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer should a malicious device lack endpoints.
--- drivers/mmc/host/ushc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mmc/host/ushc.c +3 -0
@@ -426,6 +426,9 @@ static int ushc_probe(struct usb_interfastruct ushc_data *ushc;int ret; +if (intf->cur_altsetting->desc.bNumEndpoints <1 ) +return -ENODEV ; + mmc =mmc_alloc_host (sizeof (struct ushc_data ), &intf->dev);if (mmc ==NULL )return -ENOMEM ;
PATCH 56/178 Input: iforce - validate number of endpoints before using them
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 59cf8bed44a79ec42303151dd014fdb6434254bb upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer or accessing memory that lie beyond the end of the endpoint array should a malicious device lack the expected endpoints.
--- drivers/input/joystick/iforce/iforce-usb.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/input/joystick/iforce/iforce-usb.c +3 -0
@@ -141,6 +141,9 @@ static int iforce_usb_probe(struct usb_i interface = intf->cur_altsetting; +if (interface->desc.bNumEndpoints <2 ) +return -ENODEV ; + epirq = &interface->endpoint[0 ].desc; epout = &interface->endpoint[1 ].desc;
PATCH 57/178 Input: cm109 - validate number of endpoints before using them
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit ac2ee9ba953afe88f7a673e1c0c839227b1d7891 upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer should a malicious device lack endpoints.
--- drivers/input/misc/cm109.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/input/misc/cm109.c +4 -0
@@ -675,6 +675,10 @@ static int cm109_usb_probe(struct usb_inint error = -ENOMEM ; interface = intf->cur_altsetting; + +if (interface->desc.bNumEndpoints <1 ) +return -ENODEV ; + endpoint = &interface->endpoint[0 ].desc;if (!usb_endpoint_is_int_in (endpoint))
PATCH 58/178 Input: ims-pcu - validate number of endpoints before using them
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 1916d319271664241b7aa0cd2b05e32bdb310ce9 upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer should a malicious device lack control-interface endpoints.
--- drivers/input/misc/ims-pcu.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/input/misc/ims-pcu.c +4 -0
@@ -1667,6 +1667,10 @@ static int ims_pcu_parse_cdc_data(structreturn -EINVAL ; alt = pcu->ctrl_intf->cur_altsetting; + +if (alt->desc.bNumEndpoints <1 ) +return -ENODEV ; + pcu->ep_ctrl = &alt->endpoint[0 ].desc; pcu->max_ctrl_size =usb_endpoint_maxp (pcu->ep_ctrl);
PATCH 59/178 Input: yealink - validate number of endpoints before using them
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 5cc4a1a9f5c179795c8a1f2b0f4361829d6a070e upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer should a malicious device lack endpoints.
--- drivers/input/misc/yealink.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/input/misc/yealink.c +4 -0
@@ -875,6 +875,10 @@ static int usb_probe(struct usb_interfacint ret, pipe, i; interface = intf->cur_altsetting; + +if (interface->desc.bNumEndpoints <1 ) +return -ENODEV ; + endpoint = &interface->endpoint[0 ].desc;if (!usb_endpoint_is_int_in (endpoint))return -ENODEV ;
PATCH 60/178 Input: hanwang - validate number of endpoints before using them
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit ba340d7b83703768ce566f53f857543359aa1b98 upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer should a malicious device lack endpoints.
--- drivers/input/tablet/hanwang.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/input/tablet/hanwang.c +3 -0
@@ -340,6 +340,9 @@ static int hanwang_probe(struct usb_inteint error;int i; +if (intf->cur_altsetting->desc.bNumEndpoints <1 ) +return -ENODEV ; + hanwang =kzalloc (sizeof (struct hanwang ),GFP_KERNEL ); input_dev =input_allocate_device ();if (!hanwang || !input_dev) {
PATCH 61/178 Input: kbtab - validate number of endpoints before using them
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit cb1b494663e037253337623bf1ef2df727883cb7 upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer should a malicious device lack endpoints.
--- drivers/input/tablet/kbtab.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/input/tablet/kbtab.c +3 -0
@@ -122,6 +122,9 @@ static int kbtab_probe(struct usb_interfstruct input_dev *input_dev;int error = -ENOMEM ; +if (intf->cur_altsetting->desc.bNumEndpoints <1 ) +return -ENODEV ; + kbtab =kzalloc (sizeof (struct kbtab ),GFP_KERNEL ); input_dev =input_allocate_device ();if (!kbtab || !input_dev)
PATCH 62/178 Input: sur40 - validate number of endpoints before using them
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 92461f5d723037530c1f36cce93640770037812c upstream.
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer or accessing memory that lie beyond the end of the endpoint array should a malicious device lack the expected endpoints.
--- drivers/input/touchscreen/sur40.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/input/touchscreen/sur40.c +3 -0
@@ -361,6 +361,9 @@ static int sur40_probe(struct usb_interfif (iface_desc->desc.bInterfaceClass !=0xFF )return -ENODEV ; +if (iface_desc->desc.bNumEndpoints <5 ) +return -ENODEV ; +/* Use endpoint #4 (0x86). */ endpoint = &iface_desc->endpoint[4 ].desc;if (endpoint->bEndpointAddress !=TOUCH_ENDPOINT )
PATCH 63/178 net: ipv6: set route type for anycast routes
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: David Ahern <[email protected]>
commit 4ee39733fbecf04cf9f346de2d64788c35028079 upstream.
Anycast routes have the RTF_ANYCAST flag set, but when dumping routes for userspace the route type is not set to RTN_ANYCAST. Make it so.
--- net/ipv6/route.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv6/route.c +2 -0
@@ -2582,6 +2582,8 @@ static int rt6_fill_node(struct net *net }else if (rt->rt6i_flags &RTF_LOCAL ) rtm->rtm_type =RTN_LOCAL ; +else if (rt->rt6i_flags &RTF_ANYCAST ) + rtm->rtm_type =RTN_ANYCAST ;else if (rt->dst.dev && (rt->dst.dev->flags &IFF_LOOPBACK )) rtm->rtm_type =RTN_LOCAL ;else
PATCH 64/178 USB: usbtmc: add missing endpoint sanity check
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 687e0687f71ec00e0132a21fef802dee88c2f1ad upstream.
USBTMC devices are required to have a bulk-in and a bulk-out endpoint, but the driver failed to verify this, something which could lead to the endpoint addresses being taken from uninitialised memory.
Make sure to zero all private data as part of allocation, and add the missing endpoint sanity check.
Note that this also addresses a more recently introduced issue, where the interrupt-in-presence flag would also be uninitialised whenever the optional interrupt-in endpoint is not present. This in turn could lead to an interrupt urb being allocated, initialised and submitted based on uninitialised values.
--- drivers/usb/class/usbtmc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/usb/class/usbtmc.c +8 -1
@@ -1104,7 +1104,7 @@ static int usbtmc_probe(struct usb_interdev_dbg (&intf->dev,"%s called\n" , __func__); - data =kmalloc (sizeof (*data),GFP_KERNEL ); + data =kzalloc (sizeof (*data),GFP_KERNEL );if (!data) {dev_err (&intf->dev,"Unable to allocate kernel memory\n" );return -ENOMEM ;
@@ -1164,6 +1164,12 @@ static int usbtmc_probe(struct usb_inter } } +if (!data->bulk_out || !data->bulk_in) { +dev_err (&intf->dev,"bulk endpoints not found\n" ); + retcode = -ENODEV ; + goto err_put; + } + retcode =get_capabilities (data);if (retcode)dev_err (&intf->dev,"can't read capabilities\n" );
@@ -1187,6 +1193,7 @@ static int usbtmc_probe(struct usb_inter error_register:sysfs_remove_group (&intf->dev.kobj, &capability_attr_grp);sysfs_remove_group (&intf->dev.kobj, &data_attr_grp); +err_put:kref_put (&data->kref, usbtmc_delete);return retcode; }
PATCH 65/178 ACM gadget: fix endianness in notifications
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit cdd7928df0d2efaa3270d711963773a08a4cc8ab upstream.
The gadget code exports the bitfield for serial status changes over the wire in its internal endianness. The fix is to convert to little endian before sending it over the wire.
--- drivers/usb/gadget/f_acm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/gadget/f_acm.c +3 -1
@@ -535,13 +535,15 @@ static int acm_notify_serial_state(struc {struct usb_composite_dev *cdev = acm->port.func.config->cdev;int status; +__le16 serial_state;spin_lock (&acm->lock);if (acm->notify_req) {DBG (cdev,"acm ttyGS%d serial state %04x\n" , acm->port_num, acm->serial_state); + serial_state =cpu_to_le16 (acm->serial_state); status =acm_cdc_notify (acm,USB_CDC_NOTIFY_SERIAL_STATE , -0 , &acm->serial_state,sizeof (acm->serial_state)); +0 , &serial_state,sizeof (acm->serial_state)); }else { acm->pending = true; status =0 ;
PATCH 66/178 usb: hub: Fix crash after failure to read BOS descriptor
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
commit 7b2db29fbb4e766fcd02207eb2e2087170bd6ebc upstream.
If usb_get_bos_descriptor() returns an error, usb->bos will be NULL. Nevertheless, it is dereferenced unconditionally in hub_set_initial_usb2_lpm_policy() if usb2_hw_lpm_capable is set. This results in a crash.
usb 5-1: unable to get BOS descriptor
...
Unable to handle kernel NULL pointer dereference at virtual address 00000008 pgd = ffffffc00165f000 [00000008] *pgd=000000000174f003, *pud=000000000174f003, *pmd=0000000001750003, *pte=00e8000001751713 Internal error: Oops: 96000005 [#1] PREEMPT SMP Modules linked in: uinput uvcvideo videobuf2_vmalloc cmac [ ... ] CPU: 5 PID: 3353 Comm: kworker/5:3 Tainted: G B 4.4.52 #480 Hardware name: Google Kevin (DT) Workqueue: events driver_set_config_work task: ffffffc0c3690000 ti: ffffffc0ae9a8000 task.ti: ffffffc0ae9a8000 PC is at hub_port_init+0xc3c/0xd10 LR is at hub_port_init+0xc3c/0xd10 ... Call trace: [<ffffffc0007fbbfc>] hub_port_init+0xc3c/0xd10 [<ffffffc0007fbe2c>] usb_reset_and_verify_device+0x15c/0x82c [<ffffffc0007fc5e0>] usb_reset_device+0xe4/0x298 [<ffffffbffc0e3fcc>] rtl8152_probe+0x84/0x9b0 [r8152] [<ffffffc00080ca8c>] usb_probe_interface+0x244/0x2f8 [<ffffffc000774a24>] driver_probe_device+0x180/0x3b4 [<ffffffc000774e48>] __device_attach_driver+0xb4/0xe0 [<ffffffc000772168>] bus_for_each_drv+0xb4/0xe4 [<ffffffc0007747ec>] __device_attach+0xd0/0x158 [<ffffffc000775080>] device_initial_probe+0x24/0x30 [<ffffffc0007739d4>] bus_probe_device+0x50/0xe4 [<ffffffc000770bd0>] device_add+0x414/0x738 [<ffffffc000809fe8>] usb_set_configuration+0x89c/0x914 [<ffffffc00080a120>] driver_set_config_work+0xc0/0xf0 [<ffffffc000249bb8>] process_one_work+0x390/0x6b8 [<ffffffc00024abcc>] worker_thread+0x480/0x610 [<ffffffc000251a80>] kthread+0x164/0x178 [<ffffffc0002045d0>] ret_from_fork+0x10/0x40
Since we don't know anything about LPM capabilities without BOS descriptor, don't attempt to enable LPM if it is not available.
--- drivers/usb/core/hub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/core/hub.c +1 -1
@@ -4148,7 +4148,7 @@ static void hub_set_initial_usb2_lpm_polstruct usb_hub *hub =usb_hub_to_struct_hub (udev->parent);int connect_type =USB_PORT_CONNECT_TYPE_UNKNOWN ; -if (!udev->usb2_hw_lpm_capable) +if (!udev->usb2_hw_lpm_capable || !udev->bos)return ;if (hub)
PATCH 67/178 gpio:mcp23s08 Fixed missing interrupts
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Robert Middleton <[email protected]>
commit 2cd29f2387be70de9feb4c9f8dbc7c0bd55748ce upstream.
When an interrupt occurs on an MCP23S08 chip, the INTF register will only contain one bit as causing the interrupt. If more than two pins change at the same time on the chip, this causes one of the pins to not be reported. This patch fixes the logic for checking if a pin has changed, so that multiple pins will always cause more than one change.
[bwh: Backported to 3.16:
- No support for level-triggered interrupts
- Use mcp->ops->read instead of mcp_read()
- Device pointer for logging is mcp->chip.dev]
---
drivers/gpio/gpio-mcp23s08.c +56 -4
@@ -340,8 +340,10 @@ mcp23s08_direction_output(struct gpio_chstatic irqreturn_t mcp23s08_irq (int irq,void *data) {struct mcp23s08 *mcp = data; -int intcap, intf, i; +int intcap, intf, i, gpio, gpio_orig, intcap_mask;unsigned int child_irq; +bool intf_set, intcap_changed, gpio_bit_changed, + gpio_set;mutex_lock (&mcp->lock); intf = mcp->ops->read (mcp,MCP_INTF );
@@ -359,13 +361,63 @@ static irqreturn_t mcp23s08_irq(int irq, } mcp->cache[MCP_INTCAP ] = intcap; + +/* This clears the interrupt(configurable on S18) */ +if ((gpio = mcp->ops->read (mcp,MCP_GPIO )) <0 ) { +mutex_unlock (&mcp->lock); +return IRQ_HANDLED ; + } + gpio_orig = mcp->cache[MCP_GPIO ]; + mcp->cache[MCP_GPIO ] = gpio;mutex_unlock (&mcp->lock); +if (mcp->cache[MCP_INTF ] ==0 ) { +/* There is no interrupt pending */ +return IRQ_HANDLED ; + } + +dev_dbg (mcp->chip.dev, +"intcap 0x%04X intf 0x%04X gpio_orig 0x%04X gpio 0x%04X\n" , + intcap, intf, gpio_orig, gpio);for (i =0 ; i < mcp->chip.ngpio; i++) { -if ((BIT (i) & mcp->cache[MCP_INTF ]) && - ((BIT (i) & intcap & mcp->irq_rise) || - (mcp->irq_fall & ~intcap &BIT (i)))) { +/* We must check all of the inputs on the chip, +* otherwise we may not notice a change on >=2 pins. +* +* On at least the mcp23s17, INTCAP is only updated +* one byte at a time(INTCAPA and INTCAPB are +* not written to at the same time - only on a per-bank +* basis). +* +* INTF only contains the single bit that caused the +* interrupt per-bank. On the mcp23s17, there is +* INTFA and INTFB. If two pins are changed on the A +* side at the same time, INTF will only have one bit +* set. If one pin on the A side and one pin on the B +* side are changed at the same time, INTF will have +* two bits set. Thus, INTF can't be the only check +* to see if the input has changed. +*/ + + intf_set =BIT (i) & mcp->cache[MCP_INTF ]; +if (i <8 && intf_set) + intcap_mask =0x00FF ; +else if (i >=8 && intf_set) + intcap_mask =0xFF00 ; +else + intcap_mask =0x00 ; + + intcap_changed = (intcap_mask & + (BIT (i) & mcp->cache[MCP_INTCAP ])) != + (intcap_mask & (BIT (i) & gpio_orig)); + gpio_set =BIT (i) & mcp->cache[MCP_GPIO ]; + gpio_bit_changed = (BIT (i) & gpio_orig) != + (BIT (i) & mcp->cache[MCP_GPIO ]); + +if (((gpio_bit_changed || intcap_changed) && + (BIT (i) & mcp->irq_rise) && gpio_set) || + ((gpio_bit_changed || intcap_changed) && + (BIT (i) & mcp->irq_fall) && !gpio_set)) { child_irq =irq_find_mapping (mcp->irq_domain, i);handle_nested_irq (child_irq); }
PATCH 68/178 perf symbols: Fix symbols__fixup_end heuristic for corner cases
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
commit e7ede72a6d40cb3a30c087142d79381ca8a31dab upstream.
The current symbols__fixup_end() heuristic for the last entry in the rb tree is suboptimal as it leads to not being able to recognize the symbol in the call graph in a couple of corner cases, for example:
i) If the symbol has a start address (f.e. exposed via kallsyms)
that is at a page boundary, then the roundup(curr->start, 4096)
for the last entry will result in curr->start == curr->end with
a symbol length of zero.ii) If the symbol has a start address that is shortly before a page
boundary, then also here, curr->end - curr->start will just be very few bytes, where it's unrealistic that we could perform a match against.
Instead, change the heuristic to roundup(curr->start, 4096) + 4096, so that we can catch such corner cases and have a better chance to find that specific symbol. It's still just best effort as the real end of the symbol is unknown to us (and could even be at a larger offset than the current range), but better than the current situation.
Alexei reported that he recently run into case i) with a JITed eBPF program (these are all page aligned) as the last symbol which wasn't properly shown in the call graph (while other eBPF program symbols in the rb tree were displayed correctly). Since this is a generic issue, lets try to improve the heuristic a bit.
--- tools/perf/util/symbol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/symbol.c +1 -1
@@ -188,7 +188,7 @@ void symbols__fixup_end(struct rb_root */* Last entry */ if (curr->end == curr->start) - curr->end =roundup (curr->start,4096 ); + curr->end =roundup (curr->start,4096 ) +4096 ; }void __map_groups__fixup_end (struct map_groups *mg,enum map_type type)
PATCH 69/178 USB: serial: qcserial: add Dell DW5811e
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Bjørn Mork <[email protected]>
commit 436ecf5519d892397af133a79ccd38a17c25fa51 upstream.
This is a Dell branded Sierra Wireless EM7455.
--- drivers/usb/serial/qcserial.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/serial/qcserial.c +2 -0
@@ -167,6 +167,8 @@ static const struct usb_device_id id_tab {DEVICE_SWI(0x413c, 0x81a9)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card */ {DEVICE_SWI(0x413c, 0x81b1)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card */ {DEVICE_SWI(0x413c, 0x81b3)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card (rev3) */ + {DEVICE_SWI(0x413c, 0x81b5)}, /* Dell Wireless 5811e QDL */ + {DEVICE_SWI(0x413c, 0x81b6)}, /* Dell Wireless 5811e QDL *//* Huawei devices */ {DEVICE_HWI(0x03f0, 0x581d)}, /* HP lt4112 LTE/HSPA+ Gobi 4G Modem (Huawei me906e) */
PATCH 70/178 ALSA: ctxfi: Fix the incorrect check of dma_set_mask() call
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit f363a06642f28caaa78cb6446bbad90c73fe183c upstream.
In the commit [15c75b09f8d1: ALSA: ctxfi: Fallback DMA mask to 32bit], I forgot to put "!" at dam_set_mask() call check in cthw20k1.c (while cthw20k2.c is OK). This patch fixes that obvious bug.
(As a side note: although the original commit was completely wrong,
it's still working for most of machines, as it sets to 32bit DMA mask in the end. So the bug severity is low.)
--- sound/pci/ctxfi/cthw20k1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/ctxfi/cthw20k1.c +1 -1
@@ -1904,7 +1904,7 @@ static int hw_card_start(struct hw *hw)return err;/* Set DMA transfer mask */ -if (dma_set_mask (&pci->dev,DMA_BIT_MASK (dma_bits))) { +if (!dma_set_mask (&pci->dev,DMA_BIT_MASK (dma_bits))) {dma_set_coherent_mask (&pci->dev,DMA_BIT_MASK (dma_bits)); }else {dma_set_mask (&pci->dev,DMA_BIT_MASK (32 ));
PATCH 71/178 scsi: libsas: fix ata xfer length
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: John Garry <[email protected]>
commit 9702c67c6066f583b629cf037d2056245bb7a8e6 upstream.
The total ata xfer length may not be calculated properly, in that we do not use the proper method to get an sg element dma length.
According to the code comment, sg_dma_len() should be used after dma_map_sg() is called.
This issue was found by turning on the SMMUv3 in front of the hisi_sas controller in hip07. Multiple sg elements were being combined into a single element, but the original first element length was being use as the total xfer length.
--- drivers/scsi/libsas/sas_ata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/libsas/sas_ata.c +1 -1
@@ -219,7 +219,7 @@ static unsigned int sas_ata_qc_issue(str task->num_scatter = qc->n_elem; }else {for_each_sg (qc->sg, sg, qc->n_elem, si) - xfer += sg->length; + xfer +=sg_dma_len (sg); task->total_xfer_len = xfer; task->num_scatter = si;
PATCH 72/178 ALSA: seq: Fix racy cell insertions during snd_seq_pool_done()
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit c520ff3d03f0b5db7146d9beed6373ad5d2a5e0e upstream.
When snd_seq_pool_done() is called, it marks the closing flag to refuse the further cell insertions. But snd_seq_pool_done() itself doesn't clear the cells but just waits until all cells are cleared by the caller side. That is, it's racy, and this leads to the endless stall as syzkaller spotted.
This patch addresses the racy by splitting the setup of pool->closing flag out of snd_seq_pool_done(), and calling it properly before snd_seq_pool_done().
--- sound/core/seq/seq_clientmgr.c | 1 + sound/core/seq/seq_fifo.c | 3 +++ sound/core/seq/seq_memory.c | 17 +++++++++++++---- sound/core/seq/seq_memory.h | 1 + 4 files changed, 18 insertions(+), 4 deletions(-)
sound/core/seq/seq_clientmgr.c +1 -0
@@ -1921,6 +1921,7 @@ static int snd_seq_ioctl_set_client_pool info.output_pool != client->pool->size)) {if (snd_seq_write_pool_allocated (client)) {/* remove all existing cells */ +snd_seq_pool_mark_closing (client->pool);snd_seq_queue_client_leave_cells (client->number);snd_seq_pool_done (client->pool); }
sound/core/seq/seq_fifo.c +3 -0
@@ -70,6 +70,9 @@ void snd_seq_fifo_delete(struct snd_seq_return ; *fifo =NULL ; +if (f->pool) +snd_seq_pool_mark_closing (f->pool); +snd_seq_fifo_clear (f);/* wake up clients if any */
sound/core/seq/seq_memory.c +13 -4
@@ -414,6 +414,18 @@ int snd_seq_pool_init(struct snd_seq_pooreturn 0 ; } +/* refuse the further insertion to the pool */ +void snd_seq_pool_mark_closing (struct snd_seq_pool *pool) +{ +unsigned long flags; + +if (snd_BUG_ON (!pool)) +return ; +spin_lock_irqsave (&pool->lock, flags); + pool->closing =1 ; +spin_unlock_irqrestore (&pool->lock, flags); +} +/* remove events */ int snd_seq_pool_done (struct snd_seq_pool *pool) {
@@ -424,10 +436,6 @@ int snd_seq_pool_done(struct snd_seq_pooreturn -EINVAL ;/* wait for closing all threads */ -spin_lock_irqsave (&pool->lock, flags); - pool->closing =1 ; -spin_unlock_irqrestore (&pool->lock, flags); -if (waitqueue_active (&pool->output_sleep))wake_up (&pool->output_sleep);
@@ -484,6 +492,7 @@ int snd_seq_pool_delete(struct snd_seq_p *ppool =NULL ;if (pool ==NULL )return 0 ; +snd_seq_pool_mark_closing (pool);snd_seq_pool_done (pool);kfree (pool);return 0 ;
sound/core/seq/seq_memory.h +1 -0
@@ -84,6 +84,7 @@ static inline int snd_seq_total_cells(stint snd_seq_pool_init (struct snd_seq_pool *pool);/* done pool - free events */ +void snd_seq_pool_mark_closing (struct snd_seq_pool *pool);int snd_seq_pool_done (struct snd_seq_pool *pool);/* create pool */
PATCH 73/178 net: unix: properly re-increment inflight counter of GC discarded candidates
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Ulanov <[email protected]>
commit 7df9c24625b9981779afb8fcdbe2bb4765e61147 upstream.
Dmitry has reported that a BUG_ON() condition in unix_notinflight() may be triggered by a simple code that forwards unix socket in an SCM_RIGHTS message.
That is caused by incorrect unix socket GC implementation in unix_gc().
The GC first collects list of candidates, then (a) decrements their "children's" inflight counter, (b) checks which inflight counters are now 0, and then (c) increments all inflight counters back.
(a) and (c) are done by calling scan_children() with inc_inflight or dec_inflight as the second argument.
Commit 6209344f5a37 ("net: unix: fix inflight counting bug in garbage collector") changed scan_children() such that it no longer considers sockets that do not have UNIX_GC_CANDIDATE flag. It also added a block of code that that unsets this flag _before_ invoking scan_children(, dec_iflight, ). This may lead to incorrect inflight counters for some sockets.
This change fixes this bug by changing order of operations:UNIX_GC_CANDIDATE is now unset only after all inflight counters are restored to the original state.
kernel BUG at net/unix/garbage.c:149!
RIP: 0010:[<ffffffff8717ebf4>] [<ffffffff8717ebf4>] unix_notinflight+0x3b4/0x490 net/unix/garbage.c:149 Call Trace: [<ffffffff8716cfbf>] unix_detach_fds.isra.19+0xff/0x170 net/unix/af_unix.c:1487 [<ffffffff8716f6a9>] unix_destruct_scm+0xf9/0x210 net/unix/af_unix.c:1496 [<ffffffff86a90a01>] skb_release_head_state+0x101/0x200 net/core/skbuff.c:655 [<ffffffff86a9808a>] skb_release_all+0x1a/0x60 net/core/skbuff.c:668 [<ffffffff86a980ea>] __kfree_skb+0x1a/0x30 net/core/skbuff.c:684 [<ffffffff86a98284>] kfree_skb+0x184/0x570 net/core/skbuff.c:705 [<ffffffff871789d5>] unix_release_sock+0x5b5/0xbd0 net/unix/af_unix.c:559 [<ffffffff87179039>] unix_release+0x49/0x90 net/unix/af_unix.c:836 [<ffffffff86a694b2>] sock_release+0x92/0x1f0 net/socket.c:570 [<ffffffff86a6962b>] sock_close+0x1b/0x20 net/socket.c:1017 [<ffffffff81a76b8e>] __fput+0x34e/0x910 fs/file_table.c:208 [<ffffffff81a771da>] ____fput+0x1a/0x20 fs/file_table.c:244 [<ffffffff81483ab0>] task_work_run+0x1a0/0x280 kernel/task_work.c:116 [< inline >] exit_task_work include/linux/task_work.h:21 [<ffffffff8141287a>] do_exit+0x183a/0x2640 kernel/exit.c:828 [<ffffffff8141383e>] do_group_exit+0x14e/0x420 kernel/exit.c:931 [<ffffffff814429d3>] get_signal+0x663/0x1880 kernel/signal.c:2307 [<ffffffff81239b45>] do_signal+0xc5/0x2190 arch/x86/kernel/signal.c:807 [<ffffffff8100666a>] exit_to_usermode_loop+0x1ea/0x2d0 arch/x86/entry/common.c:156 [< inline >] prepare_exit_to_usermode arch/x86/entry/common.c:190 [<ffffffff81009693>] syscall_return_slowpath+0x4d3/0x570 arch/x86/entry/common.c:259 [<ffffffff881478e6>] entry_SYSCALL_64_fastpath+0xc4/0xc6
--- net/unix/garbage.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
net/unix/garbage.c +9 -9
@@ -152,6 +152,7 @@ void unix_notinflight(struct user_structif (s) {struct unix_sock *u =unix_sk (s); +BUG_ON (!atomic_long_read (&u->inflight));BUG_ON (list_empty (&u->link));if (atomic_long_dec_and_test (&u->inflight))list_del_init (&u->link);
@@ -358,6 +359,14 @@ void unix_gc(void) }list_del (&cursor); +/* Now gc_candidates contains only garbage. Restore original +* inflight counters for these as well, and remove the skbuffs +* which are creating the cycle(s). +*/ +skb_queue_head_init (&hitlist); +list_for_each_entry (u, &gc_candidates, link) +scan_children (&u->sk, inc_inflight, &hitlist); +/* * not_cycle_list contains those sockets which do not make up a * cycle. Restore these to the inflight list.
@@ -368,15 +377,6 @@ void unix_gc(void)list_move_tail (&u->link, &gc_inflight_list); } -/* -* Now gc_candidates contains only garbage. Restore original -* inflight counters for these as well, and remove the skbuffs -* which are creating the cycle(s). -*/ -skb_queue_head_init (&hitlist); -list_for_each_entry (u, &gc_candidates, link) -scan_children (&u->sk, inc_inflight, &hitlist); -spin_unlock (&unix_gc_lock);/* Here we are. Hitlist is filled. Die. */
PATCH 74/178 bpf: try harder on clones when writing into skb
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
commit 3697649ff29e0f647565eed04b27a7779c646a22 upstream.
When we're dealing with clones and the area is not writeable, try harder and get a copy via pskb_expand_head(). Replace also other occurences in tc actions with the new skb_try_make_writable().
---
include/linux/skbuff.h +7 -0
@@ -2307,6 +2307,13 @@ static inline int skb_clone_writable(conskb_headroom (skb) + len <= skb->hdr_len; } +static inline int skb_try_make_writable (struct sk_buff *skb, +unsigned int write_len) +{ +return skb_cloned (skb) && !skb_clone_writable (skb, write_len) && +pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC ); +} +static inline int __skb_cow (struct sk_buff *skb,unsigned int headroom,int cloned) {
net/sched/act_csum.c +2 -6
@@ -104,9 +104,7 @@ static void *tcf_csum_skb_nextlayer(struint hl = ihl + jhl;if (!pskb_may_pull (skb, ipl + ntkoff) || (ipl < hl) || - (skb_cloned (skb) && - !skb_clone_writable (skb, hl + ntkoff) && -pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC ))) +skb_try_make_writable (skb, hl + ntkoff))return NULL ;else return (void *)(skb_network_header (skb) + ihl);
@@ -364,9 +362,7 @@ static int tcf_csum_ipv4(struct sk_buff }if (update_flags &TCA_CSUM_UPDATE_FLAG_IPV4HDR ) { -if (skb_cloned (skb) && - !skb_clone_writable (skb,sizeof (*iph) + ntkoff) && -pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC )) +if (skb_try_make_writable (skb,sizeof (*iph) + ntkoff)) goto fail;ip_send_check (ip_hdr (skb));
net/sched/act_nat.c +5 -13
@@ -125,9 +125,7 @@ static int tcf_nat(struct sk_buff *skb, addr = iph->daddr;if (!((old_addr ^ addr) & mask)) { -if (skb_cloned (skb) && - !skb_clone_writable (skb,sizeof (*iph) + noff) && -pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC )) +if (skb_try_make_writable (skb,sizeof (*iph) + noff)) goto drop; new_addr &= mask;
@@ -155,9 +153,7 @@ static int tcf_nat(struct sk_buff *skb,struct tcphdr *tcph;if (!pskb_may_pull (skb, ihl +sizeof (*tcph) + noff) || - (skb_cloned (skb) && - !skb_clone_writable (skb, ihl +sizeof (*tcph) + noff) && -pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC ))) +skb_try_make_writable (skb, ihl +sizeof (*tcph) + noff)) goto drop; tcph = (void *)(skb_network_header (skb) + ihl);
@@ -169,9 +165,7 @@ static int tcf_nat(struct sk_buff *skb,struct udphdr *udph;if (!pskb_may_pull (skb, ihl +sizeof (*udph) + noff) || - (skb_cloned (skb) && - !skb_clone_writable (skb, ihl +sizeof (*udph) + noff) && -pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC ))) +skb_try_make_writable (skb, ihl +sizeof (*udph) + noff)) goto drop; udph = (void *)(skb_network_header (skb) + ihl);
@@ -211,10 +205,8 @@ static int tcf_nat(struct sk_buff *skb,if ((old_addr ^ addr) & mask)break ; -if (skb_cloned (skb) && - !skb_clone_writable (skb, ihl +sizeof (*icmph) + -sizeof (*iph) + noff) && -pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC )) +if (skb_try_make_writable (skb, ihl +sizeof (*icmph) + +sizeof (*iph) + noff)) goto drop; icmph = (void *)(skb_network_header (skb) + ihl);
PATCH 75/178 sch_dsmark: fix invalid skb_cow() usage
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit aea92fb2e09e29653b023d4254ac9fbf94221538 upstream.
skb_cow(skb, sizeof(ip header)) is not very helpful in this context.
First we need to use pskb_may_pull() to make sure the ip header is in skb linear part, then use skb_try_make_writable() to address clones issues.
--- net/sched/sch_dsmark.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
net/sched/sch_dsmark.c +8 -2
@@ -197,9 +197,13 @@ static int dsmark_enqueue(struct sk_buffpr_debug ("%s(skb %p,sch %p,[qdisc %p])\n" , __func__, skb, sch, p);if (p->set_tc_index) { +int wlen =skb_network_offset (skb); +switch (skb->protocol) {case htons (ETH_P_IP ): -if (skb_cow_head (skb,sizeof (struct iphdr ))) + wlen +=sizeof (struct iphdr ); +if (!pskb_may_pull (skb, wlen) || +skb_try_make_writable (skb, wlen)) goto drop; skb->tc_index =ipv4_get_dsfield (ip_hdr (skb))
@@ -207,7 +211,9 @@ static int dsmark_enqueue(struct sk_buffbreak ;case htons (ETH_P_IPV6 ): -if (skb_cow_head (skb,sizeof (struct ipv6hdr ))) + wlen +=sizeof (struct ipv6hdr ); +if (!pskb_may_pull (skb, wlen) || +skb_try_make_writable (skb, wlen)) goto drop; skb->tc_index =ipv6_get_dsfield (ipv6_hdr (skb))
PATCH 76/178 bna: integer overflow bug in debugfs
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 13e2d5187f6b965ba3556caedb914baf81b98ed2 upstream.
We could allocate less memory than intended because we do:
bnad->regdata = kzalloc(len << 2, GFP_KERNEL);
The shift can overflow leading to a crash. This is debugfs code so the impact is very small.
--- drivers/net/ethernet/brocade/bna/bnad_debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/brocade/bna/bnad_debugfs.c +1 -1
@@ -331,7 +331,7 @@ bnad_debugfs_write_regrd(struct file *fi } rc =sscanf (kern_buf,"%x:%x" , &addr, &len); -if (rc <2 ) { +if (rc <2 || len >UINT_MAX >>2 ) {pr_warn ("bna %s: Failed to read user buffer\n" ,pci_name (bnad->pcidev));kfree (kern_buf);
PATCH 77/178 s390/decompressor: fix initrd corruption caused by bss clear
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Marcelo Henrique Cerri <[email protected]>
commit d82c0d12c92705ef468683c9b7a8298dd61ed191 upstream.
Reorder the operations in decompress_kernel() to ensure initrd is moved to a safe location before the bss section is zeroed.
During decompression bss can overlap with the initrd and this can corrupt the initrd contents depending on the size of the compressed kernel (which affects where the initrd is placed by the bootloader) and the size of the bss section of the decompressor.
Also use the correct initrd size when checking for overlaps with parmblock.
--- arch/s390/boot/compressed/misc.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-)
arch/s390/boot/compressed/misc.c +19 -16
@@ -142,31 +142,34 @@ static void check_ipl_parmblock(void *stunsigned long decompress_kernel (void ) { -unsigned long output_addr; -unsigned char *output; +void *output, *kernel_end; - output_addr = ((unsigned long ) &_end +HEAP_SIZE +4095UL ) &-4096UL ; -check_ipl_parmblock ((void *)0 , output_addr + SZ__bss_start); -memset (&_bss,0 , &_ebss - &_bss); - free_mem_ptr = (unsigned long )&_end; - free_mem_end_ptr = free_mem_ptr +HEAP_SIZE ; - output = (unsigned char *) output_addr; + output = (void *)ALIGN ((unsigned long ) &_end +HEAP_SIZE ,PAGE_SIZE ); + kernel_end = output + SZ__bss_start; +check_ipl_parmblock ((void *)0 , (unsigned long ) kernel_end);#ifdef CONFIG_BLK_DEV_INITRD /* * Move the initrd right behind the end of the decompressed -* kernel image. +* kernel image. This also prevents initrd corruption caused by +* bss clearing since kernel_end will always be located behind the +* current bss section.. */ -if (INITRD_START &&INITRD_SIZE && -INITRD_START < (unsigned long ) output + SZ__bss_start) { -check_ipl_parmblock (output + SZ__bss_start, -INITRD_START +INITRD_SIZE ); -memmove (output + SZ__bss_start, - (void *)INITRD_START ,INITRD_SIZE ); -INITRD_START = (unsigned long ) output + SZ__bss_start; +if (INITRD_START &&INITRD_SIZE && kernel_end > (void *)INITRD_START ) { +check_ipl_parmblock (kernel_end,INITRD_SIZE ); +memmove (kernel_end, (void *)INITRD_START ,INITRD_SIZE ); +INITRD_START = (unsigned long ) kernel_end; }#endif +/* +* Clear bss section. free_mem_ptr and free_mem_end_ptr need to be +* initialized afterwards since they reside in bss. +*/ +memset (&_bss,0 , &_ebss - &_bss); + free_mem_ptr = (unsigned long ) &_end; + free_mem_end_ptr = free_mem_ptr +HEAP_SIZE ; +puts ("Uncompressing Linux... " );decompress (input_data, input_len,NULL ,NULL , output,NULL , error);puts ("Ok, booting the kernel.\n" );
PATCH 78/178 usb: gadget: uvc: Fix endianness mismatches
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Laurent Pinchart <[email protected]>
commit e102609f107269fbc04af21548e78e99c02b6204 upstream.
The struct usb_endpoint_descriptor wMaxPacketSize field the struct usb_ss_ep_comp_descriptor wBytesPerInterval field are stored in little-endian format. Convert the values from CPU order to little endian before storing the values.
--- drivers/usb/gadget/f_uvc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/usb/gadget/f_uvc.c +7 -5
@@ -611,19 +611,21 @@ uvc_function_bind(struct usb_configurati max_packet_size = streaming_maxpacket /3 ; } - uvc_fs_streaming_ep.wMaxPacketSize =min (streaming_maxpacket,1023U ); + uvc_fs_streaming_ep.wMaxPacketSize = +cpu_to_le16 (min (streaming_maxpacket,1023U )); uvc_fs_streaming_ep.bInterval = streaming_interval; - uvc_hs_streaming_ep.wMaxPacketSize = max_packet_size; - uvc_hs_streaming_ep.wMaxPacketSize |= ((max_packet_mult -1 ) <<11 ); + uvc_hs_streaming_ep.wMaxPacketSize = +cpu_to_le16 (max_packet_size | ((max_packet_mult -1 ) <<11 )); uvc_hs_streaming_ep.bInterval = streaming_interval; - uvc_ss_streaming_ep.wMaxPacketSize = max_packet_size; + uvc_ss_streaming_ep.wMaxPacketSize =cpu_to_le16 (max_packet_size); uvc_ss_streaming_ep.bInterval = streaming_interval; uvc_ss_streaming_comp.bmAttributes = max_packet_mult -1 ; uvc_ss_streaming_comp.bMaxBurst = streaming_maxburst; uvc_ss_streaming_comp.wBytesPerInterval = - max_packet_size * max_packet_mult * streaming_maxburst; +cpu_to_le16 (max_packet_size * max_packet_mult * + streaming_maxburst);/* Allocate endpoints. */ ep =usb_ep_autoconfig (cdev->gadget, &uvc_control_ep);
PATCH 79/178 usb: gadget: f_uvc: Fix SuperSpeed companion descriptor's wBytesPerInterval
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Roger Quadros <[email protected]>
commit 09424c50b7dff40cb30011c09114404a4656e023 upstream.
The streaming_maxburst module parameter is 0 offset (0..15) so we must add 1 while using it for wBytesPerInterval calculation for the SuperSpeed companion descriptor.
Without this host uvcvideo driver will always see the wrong wBytesPerInterval for SuperSpeed uvc gadget and may not find a suitable video interface endpoint.
e.g. for streaming_maxburst = 0 case it will always fail as wBytePerInterval was evaluating to 0.
--- drivers/usb/gadget/f_uvc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/f_uvc.c +1 -1
@@ -625,7 +625,7 @@ uvc_function_bind(struct usb_configurati uvc_ss_streaming_comp.bMaxBurst = streaming_maxburst; uvc_ss_streaming_comp.wBytesPerInterval =cpu_to_le16 (max_packet_size * max_packet_mult * - streaming_maxburst); + (streaming_maxburst +1 ));/* Allocate endpoints. */ ep =usb_ep_autoconfig (cdev->gadget, &uvc_control_ep);
PATCH 80/178 net/mlx5: Increase number of max QPs in default profile
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Maor Gottlieb <[email protected]>
commit 5f40b4ed975c26016cf41953b7510fe90718e21c upstream.
With ConnectX-4 sharing SRQs from the same space as QPs, we hit a limit preventing some applications to allocate needed QPs amount. Double the size to 256K.
--- drivers/infiniband/hw/mlx5/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/main.c +1 -1
@@ -73,7 +73,7 @@ static struct mlx5_profile profile[] = { [2] = { .mask =MLX5_PROF_MASK_QP_SIZE | MLX5_PROF_MASK_MR_CACHE, - .log_max_qp = 17, + .log_max_qp = 18, .mr_cache[0] = { .size = 500, .limit =250
PATCH 81/178 mmc: sdhci: Do not disable interrupts while waiting for clock
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
commit e2ebfb2142acefecc2496e71360f50d25726040b upstream.
Disabling interrupts for even a millisecond can cause problems for some devices. That can happen when sdhci changes clock frequency because it waits for the clock to become stable under a spin lock.
The spin lock is not necessary here. Anything that is racing with changes to the I/O state is already broken. The mmc core already provides synchronization via "claiming" the host.
Although the spin lock probably should be removed from the code paths that lead to this point, such a patch would touch too much code to be suitable for stable trees. Consequently, for this patch, just drop the spin lock while waiting.
--- drivers/mmc/host/sdhci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +3 -1
@@ -1224,7 +1224,9 @@ clock_set:return ; } timeout--; -mdelay (1 ); +spin_unlock_irq (&host->lock); +usleep_range (900 ,1100 ); +spin_lock_irq (&host->lock); } clk |=SDHCI_CLOCK_CARD_EN ;
PATCH 82/178 libceph: force GFP_NOIO for socket allocations
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Dryomov <[email protected]>
commit 633ee407b9d15a75ac9740ba9d3338815e1fcb95 upstream.
sock_alloc_inode() allocates socket+inode and socket_wq with GFP_KERNEL, which is not allowed on the writeback path:
Workqueue: ceph-msgr con_work [libceph]
ffff8810871cb018 0000000000000046 0000000000000000 ffff881085d40000
0000000000012b00 ffff881025cad428 ffff8810871cbfd8 0000000000012b00
ffff880102fc1000 ffff881085d40000 ffff8810871cb038 ffff8810871cb148
Call Trace:
[<ffffffff816dd629>] schedule+0x29/0x70
[<ffffffff816e066d>] schedule_timeout+0x1bd/0x200
[<ffffffff81093ffc>] ? ttwu_do_wakeup+0x2c/0x120
[<ffffffff81094266>] ? ttwu_do_activate.constprop.135+0x66/0x70
[<ffffffff816deb5f>] wait_for_completion+0xbf/0x180
[<ffffffff81097cd0>] ? try_to_wake_up+0x390/0x390
[<ffffffff81086335>] flush_work+0x165/0x250
[<ffffffff81082940>] ? worker_detach_from_pool+0xd0/0xd0
[<ffffffffa03b65b1>] xlog_cil_force_lsn+0x81/0x200 [xfs]
[<ffffffff816d6b42>] ? __slab_free+0xee/0x234
[<ffffffffa03b4b1d>] _xfs_log_force_lsn+0x4d/0x2c0 [xfs]
[<ffffffff811adc1e>] ? lookup_page_cgroup_used+0xe/0x30
[<ffffffffa039a723>] ? xfs_reclaim_inode+0xa3/0x330 [xfs]
[<ffffffffa03b4dcf>] xfs_log_force_lsn+0x3f/0xf0 [xfs]
[<ffffffffa039a723>] ? xfs_reclaim_inode+0xa3/0x330 [xfs]
[<ffffffffa03a62c6>] xfs_iunpin_wait+0xc6/0x1a0 [xfs]
[<ffffffff810aa250>] ? wake_atomic_t_function+0x40/0x40
[<ffffffffa039a723>] xfs_reclaim_inode+0xa3/0x330 [xfs]
[<ffffffffa039ac07>] xfs_reclaim_inodes_ag+0x257/0x3d0 [xfs]
[<ffffffffa039bb13>] xfs_reclaim_inodes_nr+0x33/0x40 [xfs]
[<ffffffffa03ab745>] xfs_fs_free_cached_objects+0x15/0x20 [xfs]
[<ffffffff811c0c18>] super_cache_scan+0x178/0x180
[<ffffffff8115912e>] shrink_slab_node+0x14e/0x340
[<ffffffff811afc3b>] ? mem_cgroup_iter+0x16b/0x450
[<ffffffff8115af70>] shrink_slab+0x100/0x140
[<ffffffff8115e425>] do_try_to_free_pages+0x335/0x490
[<ffffffff8115e7f9>] try_to_free_pages+0xb9/0x1f0
[<ffffffff816d56e4>] ? __alloc_pages_direct_compact+0x69/0x1be
[<ffffffff81150cba>] __alloc_pages_nodemask+0x69a/0xb40
[<ffffffff8119743e>] alloc_pages_current+0x9e/0x110
[<ffffffff811a0ac5>] new_slab+0x2c5/0x390
[<ffffffff816d71c4>] __slab_alloc+0x33b/0x459
[<ffffffff815b906d>] ? sock_alloc_inode+0x2d/0xd0
[<ffffffff8164bda1>] ? inet_sendmsg+0x71/0xc0
[<ffffffff815b906d>] ? sock_alloc_inode+0x2d/0xd0
[<ffffffff811a21f2>] kmem_cache_alloc+0x1a2/0x1b0
[<ffffffff815b906d>] sock_alloc_inode+0x2d/0xd0
[<ffffffff811d8566>] alloc_inode+0x26/0xa0
[<ffffffff811da04a>] new_inode_pseudo+0x1a/0x70
[<ffffffff815b933e>] sock_alloc+0x1e/0x80
[<ffffffff815ba855>] __sock_create+0x95/0x220
[<ffffffff815baa04>] sock_create_kern+0x24/0x30
[<ffffffffa04794d9>] con_work+0xef9/0x2050 [libceph]
[<ffffffffa04aa9ec>] ? rbd_img_request_submit+0x4c/0x60 [rbd]
[<ffffffff81084c19>] process_one_work+0x159/0x4f0
[<ffffffff8108561b>] worker_thread+0x11b/0x530
[<ffffffff81085500>] ? create_worker+0x1d0/0x1d0
[<ffffffff8108b6f9>] kthread+0xc9/0xe0
[<ffffffff8108b630>] ? flush_kthread_worker+0x90/0x90
[<ffffffff816e1b98>] ret_from_fork+0x58/0x90
[<ffffffff8108b630>] ? flush_kthread_worker+0x90/0x90Use memalloc_noio_{save,restore}() to temporarily force GFP_NOIO here.
[bwh: Backported to 3.16:
- memalloc_noio_{save,restore}() are declared in <linux/sched.h>
- Adjust context]
--- net/ceph/messenger.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/ceph/messenger.c +6 -0
@@ -6,6 +6,7 @@#include <linux/inet.h> #include <linux/kthread.h> #include <linux/net.h> +#include <linux/sched.h> #include <linux/slab.h> #include <linux/socket.h> #include <linux/string.h>
@@ -476,11 +477,16 @@ static int ceph_tcp_connect(struct ceph_ {struct sockaddr_storage *paddr = &con->peer_addr.in_addr;struct socket *sock; +unsigned int noio_flag;int ret;BUG_ON (con->sock); + +/* sock_create_kern() allocates with GFP_KERNEL */ + noio_flag =memalloc_noio_save (); ret =sock_create_kern (con->peer_addr.in_addr.ss_family,SOCK_STREAM ,IPPROTO_TCP , &sock); +memalloc_noio_restore (noio_flag);if (ret)return ret; sock->sk->sk_allocation =GFP_NOFS ;
PATCH 83/178 xen/acpi: upload PM state from init-domain to Xen
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ankur Arora <[email protected]>
commit 1914f0cd203c941bba72f9452c8290324f1ef3dc upstream.
This was broken in commit cd979883b9ed ("xen/acpi-processor:
fix enabling interrupts on syscore_resume"). do_suspend (from xen/manage.c) and thus xen_resume_notifier never get called on the initial-domain at resume (it is if running as guest.)
The rationale for the breaking change was that upload_pm_data() potentially does blocking work in syscore_resume(). This patch addresses the original issue by scheduling upload_pm_data() to execute in workqueue context.
--- drivers/xen/xen-acpi-processor.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-)
drivers/xen/xen-acpi-processor.c +26 -8
@@ -27,10 +27,10 @@#include <linux/init.h> #include <linux/module.h> #include <linux/types.h> +#include <linux/syscore_ops.h> #include <linux/acpi.h> #include <acpi/processor.h> #include <xen/xen.h> -#include <xen/xen-ops.h> #include <xen/interface/platform.h> #include <asm/xen/hypercall.h>
@@ -466,15 +466,33 @@ static int xen_upload_processor_pm_data(return rc; } -static int xen_acpi_processor_resume (struct notifier_block *nb, -unsigned long action,void *data) +static void xen_acpi_processor_resume_worker (struct work_struct *dummy) { +int rc; +bitmap_zero (acpi_ids_done, nr_acpi_bits); -return xen_upload_processor_pm_data (); + + rc =xen_upload_processor_pm_data (); +if (rc !=0 ) +pr_info ("ACPI data upload failed, error = %d\n" , rc); +} + +static void xen_acpi_processor_resume (void ) +{ + static DECLARE_WORK(wq, xen_acpi_processor_resume_worker); + +/* +* xen_upload_processor_pm_data() calls non-atomic code. +* However, the context for xen_acpi_processor_resume is syscore +* with only the boot CPU online and in an atomic context. +* +* So defer the upload for some point safer. +*/ +schedule_work (&wq); } -struct notifier_block xen_acpi_processor_resume_nb = { - .notifier_call = xen_acpi_processor_resume, +static struct syscore_ops xap_syscore_ops = { + .resume = xen_acpi_processor_resume, };static int __init xen_acpi_processor_init (void )
@@ -527,7 +545,7 @@ static int __init xen_acpi_processor_iniif (rc) goto err_unregister; -xen_resume_notifier_register (&xen_acpi_processor_resume_nb); +register_syscore_ops (&xap_syscore_ops);return 0 ; err_unregister:
@@ -546,7 +564,7 @@ static void __exit xen_acpi_processor_ex {int i; -xen_resume_notifier_unregister (&xen_acpi_processor_resume_nb); +unregister_syscore_ops (&xap_syscore_ops);kfree (acpi_ids_done);kfree (acpi_id_present);kfree (acpi_id_cst_present);
PATCH 84/178 KVM: x86: clear bus pointer when destroyed
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Peter Xu <[email protected]>
commit df630b8c1e851b5e265dc2ca9c87222e342c093b upstream.
When releasing the bus, let's clear the bus pointers to mark it out. If any further device unregister happens on this bus, we know that we're done if we found the bus being released already.
--- virt/kvm/kvm_main.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
virt/kvm/kvm_main.c +11 -1
@@ -606,8 +606,10 @@ static void kvm_destroy_vm(struct kvm *klist_del (&kvm->vm_list);spin_unlock (&kvm_lock);kvm_free_irq_routing (kvm); -for (i =0 ; i <KVM_NR_BUSES ; i++) +for (i =0 ; i <KVM_NR_BUSES ; i++) {kvm_io_bus_destroy (kvm->buses[i]); + kvm->buses[i] =NULL ; + }kvm_coalesced_mmio_free (kvm);#if defined(CONFIG_MMU_NOTIFIER ) && defined(KVM_ARCH_WANT_MMU_NOTIFIER )mmu_notifier_unregister (&kvm->mmu_notifier, kvm->mm);
@@ -3011,6 +3013,14 @@ int kvm_io_bus_unregister_dev(struct kvmstruct kvm_io_bus *new_bus, *bus; bus = kvm->buses[bus_idx]; + +/* +* It's possible the bus being released before hand. If so, +* we're done here. +*/ +if (!bus) +return 0 ; + r = -ENOENT ;for (i =0 ; i < bus->dev_count; i++)if (bus->range[i].dev == dev) {
PATCH 85/178 KVM: kvm_io_bus_unregister_dev() should never fail
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand <[email protected]>
commit 90db10434b163e46da413d34db8d0e77404cc645 upstream.
No caller currently checks the return value of kvm_io_bus_unregister_dev(). This is evil, as all callers silently go on freeing their device. A stale reference will remain in the io_bus, getting at least used again, when the iobus gets teared down on kvm_destroy_vm() - leading to use after free errors.
There is nothing the callers could do, except retrying over and over again.
So let's simply remove the bus altogether, print an error and make sure no one can access this broken bus again (returning -ENOMEM on any attempt to access it).
[bwh: Backported to 3.16:
- Drop changes to kvm_io_bus_get_dev()
- Adjust context]
---
include/linux/kvm_host.h +2 -2
@@ -177,8 +177,8 @@ int kvm_io_bus_read(struct kvm *kvm, enu void *val);int kvm_io_bus_register_dev (struct kvm *kvm,enum kvm_bus bus_idx,gpa_t addr,int len,struct kvm_io_device *dev); -int kvm_io_bus_unregister_dev (struct kvm *kvm,enum kvm_bus bus_idx, -struct kvm_io_device *dev); +void kvm_io_bus_unregister_dev (struct kvm *kvm,enum kvm_bus bus_idx, +struct kvm_io_device *dev);#ifdef CONFIG_KVM_ASYNC_PF struct kvm_async_pf {
virt/kvm/eventfd.c +2 -1
@@ -794,7 +794,8 @@ kvm_deassign_ioeventfd_idx(struct kvm *kcontinue ;kvm_io_bus_unregister_dev (kvm, bus_idx, &p->dev); - kvm->buses[bus_idx]->ioeventfd_count--; +if (kvm->buses[bus_idx]) + kvm->buses[bus_idx]->ioeventfd_count--;ioeventfd_release (p); ret =0 ;break ;
virt/kvm/kvm_main.c +23 -17
@@ -607,7 +607,8 @@ static void kvm_destroy_vm(struct kvm *kspin_unlock (&kvm_lock);kvm_free_irq_routing (kvm);for (i =0 ; i <KVM_NR_BUSES ; i++) { -kvm_io_bus_destroy (kvm->buses[i]); +if (kvm->buses[i]) +kvm_io_bus_destroy (kvm->buses[i]); kvm->buses[i] =NULL ; }kvm_coalesced_mmio_free (kvm);
@@ -2908,6 +2909,8 @@ int kvm_io_bus_write(struct kvm *kvm, en }; bus =srcu_dereference (kvm->buses[bus_idx], &kvm->srcu); +if (!bus) +return -ENOMEM ; r =__kvm_io_bus_write (bus, &range, val);return r <0 ? r :0 ; }
@@ -2925,6 +2928,8 @@ int kvm_io_bus_write_cookie(struct kvm * }; bus =srcu_dereference (kvm->buses[bus_idx], &kvm->srcu); +if (!bus) +return -ENOMEM ;/* First try the device referenced by cookie. */ if ((cookie >= 0) && (cookie < bus->dev_count) &&
@@ -2975,6 +2980,8 @@ int kvm_io_bus_read(struct kvm *kvm, enu }; bus =srcu_dereference (kvm->buses[bus_idx], &kvm->srcu); +if (!bus) +return -ENOMEM ; r =__kvm_io_bus_read (bus, &range, val);return r <0 ? r :0 ; }
@@ -2987,6 +2994,9 @@ int kvm_io_bus_register_dev(struct kvm *struct kvm_io_bus *new_bus, *bus; bus = kvm->buses[bus_idx]; +if (!bus) +return -ENOMEM ; +/* exclude ioeventfd which is limited by maximum fd */ if (bus->dev_count - bus->ioeventfd_count >NR_IOBUS_DEVS -1 )return -ENOSPC ;
@@ -3006,45 +3016,41 @@ int kvm_io_bus_register_dev(struct kvm * }/* Caller must hold slots_lock. */ -int kvm_io_bus_unregister_dev (struct kvm *kvm,enum kvm_bus bus_idx, -struct kvm_io_device *dev) +void kvm_io_bus_unregister_dev (struct kvm *kvm,enum kvm_bus bus_idx, +struct kvm_io_device *dev) { -int i, r; +int i;struct kvm_io_bus *new_bus, *bus; bus = kvm->buses[bus_idx]; - -/* -* It's possible the bus being released before hand. If so, -* we're done here. -*/ if (!bus) -return 0 ; +return ; - r = -ENOENT ;for (i =0 ; i < bus->dev_count; i++)if (bus->range[i].dev == dev) { - r =0 ;break ; } -if (r) -return r; +if (i == bus->dev_count) +return ; new_bus =kzalloc (sizeof (*bus) + ((bus->dev_count -1 ) *sizeof (struct kvm_io_range )),GFP_KERNEL ); -if (!new_bus) -return -ENOMEM ; +if (!new_bus) { +pr_err ("kvm: failed to shrink bus, removing it completely\n" ); + goto broken; + }memcpy (new_bus, bus,sizeof (*bus) + i *sizeof (struct kvm_io_range )); new_bus->dev_count--;memcpy (new_bus->range + i, bus->range + i +1 , (new_bus->dev_count - i) *sizeof (struct kvm_io_range )); +broken:rcu_assign_pointer (kvm->buses[bus_idx], new_bus);synchronize_srcu_expedited (&kvm->srcu);kfree (bus); -return r; +return ; }static struct notifier_block kvm_cpu_notifier = {
PATCH 86/178 hwmon: (asus_atk0110) fix uninitialized data access
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit a2125d02443e9a4e68bcfd9f8004fa23239e8329 upstream.
The latest gcc-7 snapshot adds a warning to point out that when atk_read_value_old or atk_read_value_new fails, we copy uninitialized data into sensor->cached_value:
drivers/hwmon/asus_atk0110.c: In function 'atk_input_show':drivers/hwmon/asus_atk0110.c:651:26: error: 'value' may be used uninitialized in this function [-Werror=maybe-uninitialized]
Adding an error check avoids this. All versions of the driver are affected.
--- drivers/hwmon/asus_atk0110.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/hwmon/asus_atk0110.c +3 -0
@@ -646,6 +646,9 @@ static int atk_read_value(struct atk_senelse err =atk_read_value_new (sensor, value); +if (err) +return err; + sensor->is_valid = true; sensor->last_updated = jiffies; sensor->cached_value = *value;
PATCH 87/178 ALSA: seq: Fix race during FIFO resize
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 2d7d54002e396c180db0c800c1046f0a3c471597 upstream.
When a new event is queued while processing to resize the FIFO in snd_seq_fifo_clear(), it may lead to a use-after-free, as the old pool that is being queued gets removed. For avoiding this race, we need to close the pool to be deleted and sync its usage before actually deleting it.
The issue was spotted by syzkaller.
--- sound/core/seq/seq_fifo.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/core/seq/seq_fifo.c +4 -0
@@ -265,6 +265,10 @@ int snd_seq_fifo_resize(struct snd_seq_f/* NOTE: overflow flag is not cleared */ spin_unlock_irqrestore (&f->lock, flags); +/* close the old pool and wait until all users are gone */ +snd_seq_pool_mark_closing (oldpool); +snd_use_lock_sync (&f->use_lock); +/* release cells in old pool */ for (cell = oldhead; cell; cell = next) { next = cell->next;
PATCH 88/178 net: phy: handle state correctly in phy_stop_machine
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Sullivan <[email protected]>
commit 49d52e8108a21749dc2114b924c907db43358984 upstream.
If the PHY is halted on stop, then do not set the state to PHY_UP. This ensures the phy will be restarted later in phy_start when the machine is started again.
--- drivers/net/phy/phy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/phy.c +1 -1
@@ -474,7 +474,7 @@ void phy_stop_machine(struct phy_devicecancel_delayed_work_sync (&phydev->state_queue);mutex_lock (&phydev->lock); -if (phydev->state >PHY_UP ) +if (phydev->state >PHY_UP && phydev->state !=PHY_HALTED ) phydev->state =PHY_UP ;mutex_unlock (&phydev->lock); }
PATCH 89/178 IB/qib: fix false-postive maybe-uninitialized warning
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit f6aafac184a3e46e919769dd4faa8bf0dc436534 upstream.
aarch64-linux-gcc-7 complains about code it doesn't fully understand:
drivers/infiniband/hw/qib/qib_iba7322.c: In function 'qib_7322_txchk_change':include/asm-generic/bitops/non-atomic.h:105:35: error: 'shadow' may be used uninitialized in this function [-Werror=maybe-uninitialized]
The code is right, and despite trying hard, I could not come up with a version that I liked better than just adding a fake initialization here to shut up the warning.
--- drivers/infiniband/hw/qib/qib_iba7322.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/qib/qib_iba7322.c +1 -1
@@ -7078,7 +7078,7 @@ static void qib_7322_txchk_change(structunsigned long flags;while (wait) { -unsigned long shadow; +unsigned long shadow =0 ;int cstart, previ =-1 ;/*
PATCH 90/178 ext4: lock the xattr block before checksuming it
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
commit dac7a4b4b1f664934e8b713f529b629f67db313c upstream.
We must lock the xattr block before calculating or verifying the checksum in order to avoid spurious checksum failures.
https://bugzilla.kernel.org/show_bug.cgi?id=193661
--- fs/ext4/xattr.c | 65 +++++++++++++++++++++++++++------------------------------ 1 file changed, 31 insertions(+), 34 deletions(-)
fs/ext4/xattr.c +31 -34
@@ -139,31 +139,26 @@ static __le32 ext4_xattr_block_csum(stru }static int ext4_xattr_block_csum_verify (struct inode *inode, -sector_t block_nr, -struct ext4_xattr_header *hdr) +struct buffer_head *bh) { -if (ext4_has_metadata_csum (inode->i_sb) && - (hdr->h_checksum !=ext4_xattr_block_csum (inode, block_nr, hdr))) -return 0 ; -return 1 ; -} - -static void ext4_xattr_block_csum_set (struct inode *inode, -sector_t block_nr, -struct ext4_xattr_header *hdr) -{ -if (!ext4_has_metadata_csum (inode->i_sb)) -return ; +struct ext4_xattr_header *hdr =BHDR (bh); +int ret =1 ; - hdr->h_checksum =ext4_xattr_block_csum (inode, block_nr, hdr); +if (ext4_has_metadata_csum (inode->i_sb)) { +lock_buffer (bh); + ret = (hdr->h_checksum ==ext4_xattr_block_csum (inode, + bh->b_blocknr, hdr)); +unlock_buffer (bh); + } +return ret; } -static inline int ext4_handle_dirty_xattr_block (handle_t *handle, -struct inode *inode, -struct buffer_head *bh) +static void ext4_xattr_block_csum_set (struct inode *inode, +struct buffer_head *bh) { -ext4_xattr_block_csum_set (inode, bh->b_blocknr,BHDR (bh)); -return ext4_handle_dirty_metadata (handle, inode, bh); +if (ext4_has_metadata_csum (inode->i_sb)) +BHDR (bh)->h_checksum =ext4_xattr_block_csum (inode, + bh->b_blocknr,BHDR (bh)); } static inline const struct xattr_handler *
@@ -224,7 +219,7 @@ ext4_xattr_check_block(struct inode *inoif (BHDR (bh)->h_magic !=cpu_to_le32 (EXT4_XATTR_MAGIC ) ||BHDR (bh)->h_blocks !=cpu_to_le32 (1 ))return -EIO ; -if (!ext4_xattr_block_csum_verify (inode, bh->b_blocknr,BHDR (bh))) +if (!ext4_xattr_block_csum_verify (inode, bh))return -EIO ; error =ext4_xattr_check_names (BFIRST (bh), bh->b_data + bh->b_size, bh->b_data);
@@ -568,23 +563,22 @@ ext4_xattr_release_block(handle_t *handlle32_add_cpu (&BHDR (bh)->h_refcount,-1 );if (ce)mb_cache_entry_release (ce); +ext4_xattr_block_csum_set (inode, bh);/* * Beware of this ugliness: Releasing of xattr block references * from different inodes can race and so we have to protect * from a race where someone else frees the block (and releases * its journal_head) before we are done dirtying the buffer. In * nojournal mode this race is harmless and we actually cannot -* call ext4_handle_dirty_xattr_block() with locked buffer as +* call ext4_handle_dirty_metadata() with locked buffer as * that function can call sync_dirty_buffer() so for that case * we handle the dirtying after unlocking the buffer. */ if (ext4_handle_valid (handle)) - error =ext4_handle_dirty_xattr_block (handle, inode, - bh); + error =ext4_handle_dirty_metadata (handle, inode, bh);unlock_buffer (bh);if (!ext4_handle_valid (handle)) - error =ext4_handle_dirty_xattr_block (handle, inode, - bh); + error =ext4_handle_dirty_metadata (handle, inode, bh);if (IS_SYNC (inode))ext4_handle_sync (handle);dquot_free_block (inode,EXT4_C2B (EXT4_SB (inode->i_sb),1 ));
@@ -812,13 +806,14 @@ ext4_xattr_block_set(handle_t *handle, sext4_xattr_cache_insert (ext4_mb_cache, bs->bh); } +ext4_xattr_block_csum_set (inode, bs->bh);unlock_buffer (bs->bh);if (error == -EIO ) goto bad_block;if (!error) - error =ext4_handle_dirty_xattr_block (handle, - inode, - bs->bh); + error =ext4_handle_dirty_metadata (handle, + inode, + bs->bh);if (error) goto cleanup; goto inserted;
@@ -887,10 +882,11 @@ inserted:le32_add_cpu (&BHDR (new_bh)->h_refcount,1 );ea_bdebug (new_bh,"reusing; refcount now=%d" ,le32_to_cpu (BHDR (new_bh)->h_refcount)); +ext4_xattr_block_csum_set (inode, new_bh);unlock_buffer (new_bh); - error =ext4_handle_dirty_xattr_block (handle, - inode, - new_bh); + error =ext4_handle_dirty_metadata (handle, + inode, + new_bh);if (error) goto cleanup_dquot; }
@@ -945,11 +941,12 @@ getblk_failed: goto getblk_failed; }memcpy (new_bh->b_data, s->base, new_bh->b_size); +ext4_xattr_block_csum_set (inode, new_bh);set_buffer_uptodate (new_bh);unlock_buffer (new_bh);ext4_xattr_cache_insert (ext4_mb_cache, new_bh); - error =ext4_handle_dirty_xattr_block (handle, - inode, new_bh); + error =ext4_handle_dirty_metadata (handle, inode, + new_bh);if (error) goto cleanup; }
PATCH 91/178 USB: fix linked-list corruption in rh_call_control()
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 1633682053a7ee8058e10c76722b9b28e97fb73f upstream.
Using KASAN, Dmitry found a bug in the rh_call_control() routine: If buffer allocation fails, the routine returns immediately without unlinking its URB from the control endpoint, eventually leading to linked-list corruption.
This patch fixes the problem by jumping to the end of the routine (where the URB is unlinked) when an allocation failure occurs.
--- drivers/usb/core/hcd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/usb/core/hcd.c +5 -2
@@ -497,8 +497,10 @@ static int rh_call_control (struct usb_h*/ tbuf_size =max_t (u16,sizeof (struct usb_hub_descriptor ), wLength); tbuf =kzalloc (tbuf_size,GFP_KERNEL ); -if (!tbuf) -return -ENOMEM ; +if (!tbuf) { + status = -ENOMEM ; + goto err_alloc; + } bufp = tbuf;
@@ -701,6 +703,7 @@ error: }kfree (tbuf); + err_alloc:/* any errors get returned through the urb completion */ spin_lock_irq (&hcd_root_hub_lock);
PATCH 92/178 netfilter: nf_nat_snmp: Fix panic when snmp_trap_helper fails to register
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Gao Feng <[email protected]>
commit 75c689dca98851d65ef5a27e5ce26b625b68751c upstream.
In the commit 93557f53e1fb ("netfilter: nf_conntrack: nf_conntrack snmp helper"), the snmp_helper is replaced by nf_nat_snmp_hook. So the snmp_helper is never registered. But it still tries to unregister the snmp_helper, it could cause the panic.
Now remove the useless snmp_helper and the unregister call in the error handler.
--- net/ipv4/netfilter/nf_nat_snmp_basic.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-)
net/ipv4/netfilter/nf_nat_snmp_basic.c +1 -18
@@ -1260,16 +1260,6 @@ static const struct nf_conntrack_expect_ .timeout = 180, }; -static struct nf_conntrack_helper snmp_helper__read_mostly = { - .me =THIS_MODULE , - .help = help, - .expect_policy = &snmp_exp_policy, - .name ="snmp" , - .tuple.src.l3num =AF_INET , - .tuple.src.u.udp.port =cpu_to_be16 (SNMP_PORT ), - .tuple.dst.protonum =IPPROTO_UDP , -}; -static struct nf_conntrack_helper snmp_trap_helper__read_mostly = { .me =THIS_MODULE , .help = help,
@@ -1288,17 +1278,10 @@ static struct nf_conntrack_helper snmp_tstatic int __init nf_nat_snmp_basic_init (void ) { -int ret =0 ; -BUG_ON (nf_nat_snmp_hook !=NULL );RCU_INIT_POINTER (nf_nat_snmp_hook, help); - ret =nf_conntrack_helper_register (&snmp_trap_helper); -if (ret <0 ) { -nf_conntrack_helper_unregister (&snmp_helper); -return ret; - } -return ret; +return nf_conntrack_helper_register (&snmp_trap_helper); } static void __exit nf_nat_snmp_basic_fini(void)
PATCH 93/178 powerpc: Disable HFSCR[TM] if TM is not supported
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Herrenschmidt <[email protected]>
commit 7ed23e1bae8bf7e37fd555066550a00b95a3a98b upstream.
On Power8 & Power9 the early CPU inititialisation in __init_HFSCR() turns on HFSCR[TM] (Hypervisor Facility Status and Control Register [Transactional Memory]), but that doesn't take into account that TM might be disabled by CPU features, or disabled by the kernel being built with CONFIG_PPC_TRANSACTIONAL_MEM=n.
So later in boot, when we have setup the CPU features, clear HSCR[TM] if the TM CPU feature has been disabled. We use CPU_FTR_TM_COMP to account for the CONFIG_PPC_TRANSACTIONAL_MEM=n case.
Without this a KVM guest might try use TM, even if told not to, and cause an oops in the host kernel. Typically the oops is seen in __kvmppc_vcore_entry() and may or may not be fatal to the host, but is always bad news.
In practice all shipping CPU revisions do support TM, and all host kernels we are aware of build with TM support enabled, so no one should actually be able to hit this in the wild.
--- arch/powerpc/kernel/setup_64.c | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/powerpc/kernel/setup_64.c +9 -0
@@ -198,6 +198,15 @@ static void fixup_boot_paca(void)static void cpu_ready_for_interrupts (void ) { +/* +* Fixup HFSCR:TM based on CPU features. The bit is set by our +* early asm init because at that point we haven't updated our +* CPU features from firmware and device-tree. Here we have, +* so let's do it. +*/ +if (cpu_has_feature (CPU_FTR_HVMODE ) && !cpu_has_feature (CPU_FTR_TM_COMP )) +mtspr (SPRN_HFSCR ,mfspr (SPRN_HFSCR ) & ~HFSCR_TM ); +/* Set IR and DR in PACA MSR */ get_paca ()->kernel_msr =MSR_KERNEL ;
PATCH 94/178 virtio_balloon: init 1st buffer in stats vq
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ladi Prosek <[email protected]>
commit fc8653228c8588a120f6b5dad6983b7b61ff669e upstream.
When init_vqs runs, virtio_balloon.stats is either uninitialized or contains stale values. The host updates its state with garbage data because it has no way of knowing that this is just a marker buffer used for signaling.
This patch updates the stats before pushing the initial buffer.
Alternative fixes:
* Push an empty buffer in init_vqs. Not easily done with the current virtio implementation and violates the spec "Driver MUST supply the same subset of statistics in all buffers submitted to the statsq".
* Push a buffer with invalid tags in init_vqs. Violates the same spec clause, plus "invalid tag" is not really defined.
Note: the spec says:
When using the legacy interface, the device SHOULD ignore all values in the first buffer in the statsq supplied by the driver after device initialization. Note: Historically, drivers supplied an uninitialized buffer in the first buffer.
Unfortunately QEMU does not seem to implement the recommendation even for the legacy interface.
--- drivers/virtio/virtio_balloon.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/virtio/virtio_balloon.c +2 -0
@@ -346,6 +346,8 @@ static int init_vqs(struct virtio_balloo* Prime this virtqueue with one buffer so the hypervisor can * use it to signal us later (it can't be broken yet!). */ +update_balloon_stats (vb); +sg_init_one (&sg, vb->stats,sizeof vb->stats);if (virtqueue_add_outbuf (vb->stats_vq, &sg,1 , vb,GFP_KERNEL ) <0 )
PATCH 95/178 virtio_balloon: prevent uninitialized variable use
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit f0bb2d50dfcc519f06f901aac88502be6ff1df2c upstream.
The latest gcc-7.0.1 snapshot reports a new warning:
virtio/virtio_balloon.c: In function 'update_balloon_stats':virtio/virtio_balloon.c:258:26: error: 'events[2]' is used uninitialized in this function [-Werror=uninitialized] virtio/virtio_balloon.c:260:26: error: 'events[3]' is used uninitialized in this function [-Werror=uninitialized] virtio/virtio_balloon.c:261:56: error: 'events[18]' is used uninitialized in this function [-Werror=uninitialized] virtio/virtio_balloon.c:262:56: error: 'events[17]' is used uninitialized in this function [-Werror=uninitialized]
This seems absolutely right, so we should add an extra check to prevent copying uninitialized stack data into the statistics.
Quoted 1 line
Quoted 1 line
From all I can tell, this has been broken since the statistics code
was originally added in 2.6.34.
--- drivers/virtio/virtio_balloon.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/virtio/virtio_balloon.c +2 -0
@@ -218,12 +218,14 @@ static void update_balloon_stats(structall_vm_events (events);si_meminfo (&i); +#ifdef CONFIG_VM_EVENT_COUNTERS update_stat (vb, idx++,VIRTIO_BALLOON_S_SWAP_IN ,pages_to_bytes (events[PSWPIN ]));update_stat (vb, idx++,VIRTIO_BALLOON_S_SWAP_OUT ,pages_to_bytes (events[PSWPOUT ]));update_stat (vb, idx++,VIRTIO_BALLOON_S_MAJFLT , events[PGMAJFAULT ]);update_stat (vb, idx++,VIRTIO_BALLOON_S_MINFLT , events[PGFAULT ]); +#endif update_stat (vb, idx++,VIRTIO_BALLOON_S_MEMFREE ,pages_to_bytes (i.freeram)); update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMTOT,
PATCH 96/178 ACPI: Do not create a platform_device for IOAPIC/IOxAPIC
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Joerg Roedel <[email protected]>
commit 08f63d97749185fab942a3a47ed80f5bd89b8b7d upstream.
No platform-device is required for IO(x)APICs, so don't even create them.
[ rjw: This fixes a problem with leaking platform device objects
after IOAPIC/IOxAPIC hot-removal events.]
--- drivers/acpi/acpi_platform.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/acpi/acpi_platform.c +5 -3
@@ -23,9 +23,11 @@ACPI_MODULE_NAME ("platform" );static const struct acpi_device_id forbidden_id_list[] = { - {"PNP0000" ,0 },/* PIC */ - {"PNP0100" ,0 },/* Timer */ - {"PNP0200" ,0 },/* AT DMA Controller */ + {"PNP0000" ,0 },/* PIC */ + {"PNP0100" ,0 },/* Timer */ + {"PNP0200" ,0 },/* AT DMA Controller */ + {"ACPI0009" ,0 },/* IOxAPIC */ + {"ACPI000A" ,0 },/* IOAPIC */ {"" ,0 }, };
PATCH 97/178 ACPI / APEI: Add missing synchronize_rcu() on NOTIFY_SCI removal
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Morse <[email protected]>
commit 7d64f82cceb21e6d95db312d284f5f195e120154 upstream.
When removing a GHES device notified by SCI, list_del_rcu() is used, ghes_remove() should call synchronize_rcu() before it goes on to call kfree(ghes), otherwise concurrent RCU readers may still hold this list entry after it has been freed.
--- drivers/acpi/apei/ghes.c | 1 + 1 file changed, 1 insertion(+)
drivers/acpi/apei/ghes.c +1 -0
@@ -1020,6 +1020,7 @@ static int ghes_remove(struct platform_dif (list_empty (&ghes_sci))unregister_acpi_hed_notifier (&ghes_notifier_sci);mutex_unlock (&ghes_list_mutex); +synchronize_rcu ();break ;case ACPI_HEST_NOTIFY_NMI :mutex_lock (&ghes_list_mutex);
PATCH 98/178 ACPI: Fix incompatibility with mcount-based function graph tracing
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
commit 61b79e16c68d703dde58c25d3935d67210b7d71b upstream.
Paul Menzel reported a warning:
WARNING: CPU: 0 PID: 774 at /build/linux-ROBWaj/linux-4.9.13/kernel/trace/trace_functions_graph.c:233 ftrace_return_to_handler+0x1aa/0x1e0
Bad frame pointer: expected f6919d98, received f6919db0
from func acpi_pm_device_sleep_wake return to c43b6f9dThe warning means that function graph tracing is broken for the acpi_pm_device_sleep_wake() function. That's because the ACPI Makefile unconditionally sets the '-Os' gcc flag to optimize for size. That's an issue because mcount-based function graph tracing is incompatible with '-Os' on x86, thanks to the following gcc bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42109
I have another patch pending which will ensure that mcount-based function graph tracing is never used with CONFIG_CC_OPTIMIZE_FOR_SIZE on x86.
But this patch is needed in addition to that one because the ACPI Makefile overrides that config option for no apparent reason. It has had this flag since the beginning of git history, and there's no related comment, so I don't know why it's there. As far as I can tell, there's no reason for it to be there. The appropriate behavior is for it to honor CONFIG_CC_OPTIMIZE_FOR_{SIZE,PERFORMANCE} like the rest of the kernel.
--- drivers/acpi/Makefile | 1 - 1 file changed, 1 deletion(-)
drivers/acpi/Makefile +0 -1
@@ -2,7 +2,6 @@ # Makefile for the Linux ACPI interpreter # -ccflags-y := -Os ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT #
PATCH 99/178 xhci: Manually give back cancelled URB if we can't queue it for cancel
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit d3519b9d9606991a1305596348b6d690bfa3eb27 upstream.
xhci needs to take care of four scenarios when asked to cancel a URB.
1 URB is not queued or already given back.
usb_hcd_check_unlink_urb() will return an error, we pass the error on
2 We fail to find xhci internal structures from urb private data such as
virtual device and endpoint ring.
Give back URB immediately, can't do anything about internal structures.
3 URB private data has valid pointers to xhci internal data, but host is
not responding.
give back URB immedately and remove the URB from the endpoint lists.
4 Everyting is working
add URB to cancel list, queue a command to stop the endpoint, after which the URB can be turned to no-op or skipped, removed from lists, and given back.
We failed to give back the urb in case 2 where the correct device and endpoint pointers could not be retrieved from URB private data.
This caused a hang on Dell Inspiron 5558/0VNM2T at resume from suspend as urb was never returned.
[ 245.270505] INFO: task rtsx_usb_ms_1:254 blocked for more than 120 seconds. [ 245.272244] Tainted: G W 4.11.0-rc3-ARCH #2 [ 245.273983] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [ 245.275737] rtsx_usb_ms_1 D 0 254 2 0x00000000 [ 245.277524] Call Trace: [ 245.279278] __schedule+0x2d3/0x8a0 [ 245.281077] schedule+0x3d/0x90 [ 245.281961] usb_kill_urb.part.3+0x6c/0xa0 [usbcore] [ 245.282861] ? wake_atomic_t_function+0x60/0x60 [ 245.283760] usb_kill_urb+0x21/0x30 [usbcore] [ 245.284649] usb_start_wait_urb+0xe5/0x170 [usbcore] [ 245.285541] ? try_to_del_timer_sync+0x53/0x80 [ 245.286434] usb_bulk_msg+0xbd/0x160 [usbcore] [ 245.287326] rtsx_usb_send_cmd+0x63/0x90 [rtsx_usb]
--- drivers/usb/host/xhci.c | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-)
drivers/usb/host/xhci.c +25 -18
@@ -1533,20 +1533,33 @@ int xhci_urb_dequeue(struct usb_hcd *hcdstruct xhci_ring *ep_ring;struct xhci_virt_ep *ep;struct xhci_command *command; +struct xhci_virt_device *vdev; xhci =hcd_to_xhci (hcd);spin_lock_irqsave (&xhci->lock, flags);/* Make sure the URB hasn't completed or been unlinked already */ ret =usb_hcd_check_unlink_urb (hcd, urb, status); -if (ret || !urb->hcpriv) +if (ret) goto done; + +/* give back URB now if we can't queue it for cancel */ + vdev = xhci->devs[urb->dev->slot_id]; + urb_priv = urb->hcpriv; +if (!vdev || !urb_priv) + goto err_giveback; + + ep_index =xhci_get_endpoint_index (&urb->ep->desc); + ep = &vdev->eps[ep_index]; + ep_ring =xhci_urb_to_transfer_ring (xhci, urb); +if (!ep || !ep_ring) + goto err_giveback; + temp =readl (&xhci->op_regs->status);if (temp ==0xffffffff || (xhci->xhc_state &XHCI_STATE_HALTED )) {xhci_dbg_trace (xhci, trace_xhci_dbg_cancel_urb,"HW died, freeing TD." ); - urb_priv = urb->hcpriv;for (i = urb_priv->td_cnt; - i < urb_priv->length && xhci->devs[urb->dev->slot_id]; + i < urb_priv->length; i++) { td = urb_priv->td[i];if (!list_empty (&td->td_list))
@@ -1554,23 +1567,9 @@ int xhci_urb_dequeue(struct usb_hcd *hcdif (!list_empty (&td->cancelled_td_list))list_del_init (&td->cancelled_td_list); } - -usb_hcd_unlink_urb_from_ep (hcd, urb); -spin_unlock_irqrestore (&xhci->lock, flags); -usb_hcd_giveback_urb (hcd, urb, -ESHUTDOWN ); -xhci_urb_free_priv (xhci, urb_priv); -return ret; - } - - ep_index =xhci_get_endpoint_index (&urb->ep->desc); - ep = &xhci->devs[urb->dev->slot_id]->eps[ep_index]; - ep_ring =xhci_urb_to_transfer_ring (xhci, urb); -if (!ep_ring) { - ret = -EINVAL ; - goto done; + goto err_giveback; } - urb_priv = urb->hcpriv; i = urb_priv->td_cnt;if (i < urb_priv->length) xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
@@ -1604,6 +1603,14 @@ int xhci_urb_dequeue(struct usb_hcd *hcd done:spin_unlock_irqrestore (&xhci->lock, flags);return ret; + +err_giveback: +if (urb_priv) +xhci_urb_free_priv (xhci, urb_priv); +usb_hcd_unlink_urb_from_ep (hcd, urb); +spin_unlock_irqrestore (&xhci->lock, flags); +usb_hcd_giveback_urb (hcd, urb, -ESHUTDOWN ); +return ret; }/* Drop an endpoint from a new bandwidth configuration for this device.
PATCH 100/178 l2tp: purge socket queues in the .destruct() callback
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Nault <[email protected]>
commit e91793bb615cf6cdd59c0b6749fe173687bb0947 upstream.
The Rx path may grab the socket right before pppol2tp_release(), but nothing guarantees that it will enqueue packets before skb_queue_purge(). Therefore, the socket can be destroyed without its queues fully purged.
Fix this by purging queues in pppol2tp_session_destruct() where we're guaranteed nothing is still referencing the socket.
--- net/l2tp/l2tp_ppp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/l2tp/l2tp_ppp.c +4 -3
@@ -469,6 +469,10 @@ static void pppol2tp_session_close(strucstatic void pppol2tp_session_destruct (struct sock *sk) {struct l2tp_session *session = sk->sk_user_data; + +skb_queue_purge (&sk->sk_receive_queue); +skb_queue_purge (&sk->sk_write_queue); +if (session) { sk->sk_user_data =NULL ;BUG_ON (session->magic !=L2TP_SESSION_MAGIC );
@@ -507,9 +511,6 @@ static int pppol2tp_release(struct sockel2tp_session_queue_purge (session);sock_put (sk); } -skb_queue_purge (&sk->sk_receive_queue); -skb_queue_purge (&sk->sk_write_queue); -release_sock (sk);/* This will delete the session context via
PATCH 101/178 s390/uaccess: get_user() should zero on failure (again)
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
commit d09c5373e8e4eaaa09233552cbf75dc4c4f21203 upstream.
Commit fd2d2b191fe7 ("s390: get_user() should zero on failure") intended to fix s390's get_user() implementation which did not zero the target operand if the read from user space faulted. Unfortunately the patch has no effect: the corresponding inline assembly specifies that the operand is only written to ("=") and the previous value is discarded.
Therefore the compiler is free to and actually does omit the zero initialization.
To fix this simply change the contraint modifier to "+", so the compiler cannot omit the initialization anymore.
--- arch/s390/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/include/asm/uaccess.h +1 -1
@@ -148,7 +148,7 @@ unsigned long __must_check __copy_to_use" jg 2b\n" \".popsection\n" \ EX_TABLE(0b,3b) EX_TABLE(1b,3b) \ - : "=d" (__rc), "=Q" (*(to)) \ + : "=d" (__rc), "+Q" (*(to)) \: " d" (size), " Q " (*(from)), \ " d" (__reg0), " K " (-EFAULT) \ : " cc"); \
PATCH 102/178 ubi/upd: Always flush after prepared for an update
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Siewior <[email protected]>
commit 9cd9a21ce070be8a918ffd3381468315a7a76ba6 upstream.
In commit 6afaf8a484cb ("UBI: flush wl before clearing update marker") I managed to trigger and fix a similar bug. Now here is another version of which I assumed it wouldn't matter back then but it turns out UBI has a check for it and will error out like this:
|ubi0 warning: validate_vid_hdr: inconsistent used_ebs |ubi0 error: validate_vid_hdr: inconsistent VID header at PEB 592
All you need to trigger this is? "ubiupdatevol /dev/ubi0_0 file" + a powercut in the middle of the operation.ubi_start_update() sets the update-marker and puts all EBs on the erase list. After that userland can proceed to write new data while the old EB aren't erased completely. A powercut at this point is usually not that much of a tragedy. UBI won't give read access to the static volume because it has the update marker. It will most likely set the corrupted flag because it misses some EBs.
So we are all good. Unless the size of the image that has been written differs from the old image in the magnitude of at least one EB. In that case UBI will find two different values for `used_ebs' and refuse to attach the image with the error message mentioned above.
So in order not to get in the situation, the patch will ensure that we wait until everything is removed before it tries to write any data. The alternative would be to detect such a case and remove all EBs at the attached time after we processed the volume-table and see the update-marker set. The patch looks bigger and I doubt it is worth it since usually the write() will wait from time to time for a new EB since usually there not that many spare EB that can be used.
--- drivers/mtd/ubi/upd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mtd/ubi/upd.c +4 -4
@@ -148,11 +148,11 @@ int ubi_start_update(struct ubi_device *return err; } -if (bytes ==0 ) { - err =ubi_wl_flush (ubi,UBI_ALL ,UBI_ALL ); -if (err) -return err; + err =ubi_wl_flush (ubi,UBI_ALL ,UBI_ALL ); +if (err) +return err; +if (bytes ==0 ) { err =clear_update_marker (ubi, vol,0 );if (err)return err;
PATCH 103/178 iscsi-target: Fix TMR reference leak during session shutdown
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Bellinger <[email protected]>
commit efb2ea770bb3b0f40007530bc8b0c22f36e1c5eb upstream.
This patch fixes a iscsi-target specific TMR reference leak during session shutdown, that could occur when a TMR was quiesced before the hand-off back to iscsi-target code via transport_cmd_check_stop_to_fabric().
The reference leak happens because iscsit_free_cmd() was incorrectly skipping the final target_put_sess_cmd() for TMRs when transport_generic_free_cmd() returned zero because the se_cmd->cmd_kref did not reach zero, due to the missing se_cmd assignment in original code.
The result was iscsi_cmd and it's associated se_cmd memory would be freed once se_sess->sess_cmd_map where released, but the associated se_tmr_req was leaked and remained part of se_device->dev_tmr_list.
This bug would manfiest itself as kernel paging request OOPsen in core_tmr_lun_reset(), when a left-over se_tmr_req attempted to dereference it's se_cmd pointer that had already been released during normal session shutdown.
To address this bug, go ahead and treat ISCSI_OP_SCSI_CMD and ISCSI_OP_SCSI_TMFUNC the same when there is an extra se_cmd->cmd_kref to drop in iscsit_free_cmd(), and use op_scsi to signal __iscsit_free_cmd() when the former needs to clear any further iscsi related I/O state.
--- drivers/target/iscsi/iscsi_target_util.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/target/iscsi/iscsi_target_util.c +7 -5
@@ -729,21 +729,23 @@ void iscsit_free_cmd(struct iscsi_cmd *c {struct se_cmd *se_cmd =NULL ;int rc; +bool op_scsi = false;/* * Determine if a struct se_cmd is associated with * this struct iscsi_cmd. */ switch (cmd->iscsi_opcode) {case ISCSI_OP_SCSI_CMD : - se_cmd = &cmd->se_cmd; -__iscsit_free_cmd (cmd, true, shutdown); + op_scsi = true;/* * Fallthrough */ case ISCSI_OP_SCSI_TMFUNC : - rc =transport_generic_free_cmd (&cmd->se_cmd, shutdown); -if (!rc && shutdown && se_cmd && se_cmd->se_sess) { -__iscsit_free_cmd (cmd, true, shutdown); + se_cmd = &cmd->se_cmd; +__iscsit_free_cmd (cmd, op_scsi, shutdown); + rc =transport_generic_free_cmd (se_cmd, shutdown); +if (!rc && shutdown && se_cmd->se_sess) { +__iscsit_free_cmd (cmd, op_scsi, shutdown);target_put_sess_cmd (se_cmd->se_sess, se_cmd); }break ;
PATCH 104/178 drm/vmwgfx: Type-check lookups of fence objects
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Hellstrom <[email protected]>
commit f7652afa8eadb416b23eb57dec6f158529942041 upstream.
A malicious caller could otherwise hand over handles to other objects causing all sorts of interesting problems.
Testing done: Ran a Fedora 25 desktop using both Xorg and gnome-shell/Wayland.
--- drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 77 +++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 27 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_fence.c +49 -26
@@ -494,7 +494,7 @@ int vmw_fence_create(struct vmw_fence_ma struct vmw_fence_obj **p_fence) {struct vmw_fence_obj *fence; -int ret; +int ret; fence =kzalloc (sizeof (*fence),GFP_KERNEL );if (unlikely (fence ==NULL ))
@@ -662,6 +662,41 @@ void vmw_fence_fifo_up(struct vmw_fence_ } +/** +* vmw_fence_obj_lookup - Look up a user-space fence object +* +* @tfile: A struct ttm_object_file identifying the caller. +* @handle: A handle identifying the fence object. +* @return: A struct vmw_user_fence base ttm object on success or +* an error pointer on failure. +* +* The fence object is looked up and type-checked. The caller needs +* to have opened the fence object first, but since that happens on +* creation and fence objects aren't shareable, that's not an +* issue currently. +*/ +static struct ttm_base_object * +vmw_fence_obj_lookup (struct ttm_object_file *tfile,u32 handle) +{ +struct ttm_base_object *base =ttm_base_object_lookup (tfile, handle); + +if (!base) { +pr_err ("Invalid fence object handle 0x%08lx.\n" , + (unsigned long )handle); +return ERR_PTR (-EINVAL ); + } + +if (base->refcount_release != vmw_user_fence_base_release) { +pr_err ("Invalid fence object handle 0x%08lx.\n" , + (unsigned long )handle); +ttm_base_object_unref (&base); +return ERR_PTR (-EINVAL ); + } + +return base; +} + +int vmw_fence_obj_wait_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv) {
@@ -687,13 +722,9 @@ int vmw_fence_obj_wait_ioctl(struct drm_ arg->kernel_cookie = jiffies + wait_timeout; } - base =ttm_base_object_lookup (tfile, arg->handle); -if (unlikely (base ==NULL )) { -printk (KERN_ERR "Wait invalid fence object handle " -"0x%08lx.\n" , - (unsigned long )arg->handle); -return -EINVAL ; - } + base =vmw_fence_obj_lookup (tfile, arg->handle); +if (IS_ERR (base)) +return PTR_ERR (base); fence = &(container_of(base, struct vmw_user_fence, base)->fence);
@@ -732,13 +763,9 @@ int vmw_fence_obj_signaled_ioctl(structstruct ttm_object_file *tfile =vmw_fpriv (file_priv)->tfile;struct vmw_private *dev_priv =vmw_priv (dev); - base =ttm_base_object_lookup (tfile, arg->handle); -if (unlikely (base ==NULL )) { -printk (KERN_ERR "Fence signaled invalid fence object handle " -"0x%08lx.\n" , - (unsigned long )arg->handle); -return -EINVAL ; - } + base =vmw_fence_obj_lookup (tfile, arg->handle); +if (IS_ERR (base)) +return PTR_ERR (base); fence = &(container_of(base, struct vmw_user_fence, base)->fence); fman = fence->fman;
@@ -1052,6 +1079,7 @@ int vmw_fence_event_ioctl(struct drm_dev (struct drm_vmw_fence_event_arg *) data;struct vmw_fence_obj *fence =NULL ;struct vmw_fpriv *vmw_fp =vmw_fpriv (file_priv); +struct ttm_object_file *tfile = vmw_fp->tfile;struct drm_vmw_fence_rep __user *user_fence_rep = (struct drm_vmw_fence_rep __user *)(unsigned long ) arg->fence_rep;
@@ -1065,15 +1093,11 @@ int vmw_fence_event_ioctl(struct drm_dev*/ if (arg->handle) {struct ttm_base_object *base = -ttm_base_object_lookup_for_ref (dev_priv->tdev, - arg->handle); +vmw_fence_obj_lookup (tfile, arg->handle); + +if (IS_ERR (base)) +return PTR_ERR (base); -if (unlikely (base ==NULL )) { -DRM_ERROR ("Fence event invalid fence object handle " -"0x%08lx.\n" , - (unsigned long )arg->handle); -return -EINVAL ; - } fence = &(container_of(base, struct vmw_user_fence, base)->fence); (void )vmw_fence_obj_reference (fence);
@@ -1081,7 +1105,7 @@ int vmw_fence_event_ioctl(struct drm_devif (user_fence_rep !=NULL ) {bool existed; - ret =ttm_ref_object_add (vmw_fp->tfile, base, + ret =ttm_ref_object_add (tfile, base,TTM_REF_USAGE , &existed);if (unlikely (ret !=0 )) { DRM_ERROR("Failed to reference a fence "
@@ -1125,8 +1149,7 @@ int vmw_fence_event_ioctl(struct drm_devreturn 0 ; out_no_create:if (user_fence_rep !=NULL ) -ttm_ref_object_base_unref (vmw_fpriv (file_priv)->tfile, - handle,TTM_REF_USAGE ); +ttm_ref_object_base_unref (tfile, handle,TTM_REF_USAGE ); out_no_ref_obj:vmw_fence_obj_unreference (&fence);return ret;
PATCH 105/178 drm/vmwgfx: avoid calling vzalloc with a 0 size in vmw_get_cap_3d_ioctl()
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Murray McAllister <[email protected]>
commit 63774069d9527a1aeaa4aa20e929ef5e8e9ecc38 upstream.
In vmw_get_cap_3d_ioctl(), a user can supply 0 for a size that is used in vzalloc(). This eventually calls dump_stack() (in warn_alloc()), which can leak useful addresses to dmesg.
Add check to avoid a size of 0.
--- drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c +1 -1
@@ -161,7 +161,7 @@ int vmw_get_cap_3d_ioctl(struct drm_devibool gb_objects = !!(dev_priv->capabilities &SVGA_CAP_GBOBJECTS );struct vmw_fpriv *vmw_fp =vmw_fpriv (file_priv); -if (unlikely (arg->pad64 !=0 )) { +if (unlikely (arg->pad64 !=0 || arg->max_size ==0 )) {DRM_ERROR ("Illegal GET_3D_CAP argument.\n" );return -EINVAL ; }
PATCH 106/178 drm/ttm, drm/vmwgfx: Relax permission checking when opening surfaces
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Hellstrom <[email protected]>
commit fe25deb7737ce6c0879ccf79c99fa1221d428bf2 upstream.
Previously, when a surface was opened using a legacy (non prime) handle, it was verified to have been created by a client in the same master realm. Relax this so that opening is also allowed recursively if the client already has the surface open.
This works around a regression in svga mesa where opening of a shared surface is used recursively to obtain surface information.
--- drivers/gpu/drm/ttm/ttm_object.c | 10 +++++++--- drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 6 ++---- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 22 +++++++++------------- include/drm/ttm/ttm_object.h | 5 ++++- 5 files changed, 24 insertions(+), 23 deletions(-)
drivers/gpu/drm/ttm/ttm_object.c +7 -3
@@ -179,7 +179,7 @@ int ttm_base_object_init(struct ttm_objeif (unlikely (ret !=0 )) goto out_err0; - ret =ttm_ref_object_add (tfile, base,TTM_REF_USAGE ,NULL ); + ret =ttm_ref_object_add (tfile, base,TTM_REF_USAGE ,NULL , false);if (unlikely (ret !=0 )) goto out_err1;
@@ -318,7 +318,8 @@ EXPORT_SYMBOL(ttm_ref_object_exists);int ttm_ref_object_add (struct ttm_object_file *tfile,struct ttm_base_object *base, -enum ttm_ref_type ref_type,bool *existed) +enum ttm_ref_type ref_type,bool *existed, +bool require_existed) {struct drm_open_hash *ht = &tfile->ref_hash[ref_type];struct ttm_ref_object *ref;
@@ -345,6 +346,9 @@ int ttm_ref_object_add(struct ttm_object }rcu_read_unlock (); +if (require_existed) +return -EPERM ; + ret =ttm_mem_global_alloc (mem_glob,sizeof (*ref), false, false);if (unlikely (ret !=0 ))
@@ -635,7 +639,7 @@ int ttm_prime_fd_to_handle(struct ttm_ob prime = (struct ttm_prime_object *) dma_buf->priv; base = &prime->base; *handle = base->hash.key; - ret =ttm_ref_object_add (tfile, base,TTM_REF_USAGE ,NULL ); + ret =ttm_ref_object_add (tfile, base,TTM_REF_USAGE ,NULL , false);dma_buf_put (dma_buf);
drivers/gpu/drm/vmwgfx/vmwgfx_fence.c +2 -4
@@ -1103,10 +1103,8 @@ int vmw_fence_event_ioctl(struct drm_dev (void )vmw_fence_obj_reference (fence);if (user_fence_rep !=NULL ) { -bool existed; - - ret =ttm_ref_object_add (tfile, base, -TTM_REF_USAGE , &existed); + ret =ttm_ref_object_add (vmw_fp->tfile, base, +TTM_REF_USAGE ,NULL , false);if (unlikely (ret !=0 )) {DRM_ERROR ("Failed to reference a fence " "object.\n" );
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +2 -2
@@ -587,7 +587,7 @@ static int vmw_user_dmabuf_synccpu_grab(return ret; ret =ttm_ref_object_add (tfile, &user_bo->prime.base, -TTM_REF_SYNCCPU_WRITE , &existed); +TTM_REF_SYNCCPU_WRITE , &existed, false);if (ret !=0 || existed)ttm_bo_synccpu_write_release (&user_bo->dma.base);
@@ -771,7 +771,7 @@ int vmw_user_dmabuf_reference(struct ttm *handle = user_bo->prime.base.hash.key;return ttm_ref_object_add (tfile, &user_bo->prime.base, -TTM_REF_USAGE ,NULL ); +TTM_REF_USAGE ,NULL , false); }/*
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +9 -13
@@ -902,17 +902,16 @@ vmw_surface_handle_reference(struct vmw_uint32_t handle;struct ttm_base_object *base;int ret; +bool require_exist = false;if (handle_type ==DRM_VMW_HANDLE_PRIME ) { ret =ttm_prime_fd_to_handle (tfile, u_handle, &handle);if (unlikely (ret !=0 ))return ret; }else { -if (unlikely (drm_is_render_client (file_priv))) { -DRM_ERROR ("Render client refused legacy " -"surface reference.\n" ); -return -EACCES ; - } +if (unlikely (drm_is_render_client (file_priv))) + require_exist = true; + handle = u_handle; }
@@ -934,17 +933,14 @@ vmw_surface_handle_reference(struct vmw_/* * Make sure the surface creator has the same -* authenticating master. +* authenticating master, or is already registered with us. */ if (drm_is_primary_client (file_priv) && - user_srf->master != file_priv->master) { -DRM_ERROR ("Trying to reference surface outside of" -" master domain.\n" ); - ret = -EACCES ; - goto out_bad_resource; - } + user_srf->master != file_priv->master) + require_exist = true; - ret =ttm_ref_object_add (tfile, base,TTM_REF_USAGE ,NULL ); + ret =ttm_ref_object_add (tfile, base,TTM_REF_USAGE ,NULL , + require_exist);if (unlikely (ret !=0 )) {DRM_ERROR ("Could not add a reference to a surface.\n" ); goto out_bad_resource;
include/drm/ttm/ttm_object.h +4 -1
@@ -229,6 +229,8 @@ extern void ttm_base_object_unref(struct* @ref_type: The type of reference. * @existed: Upon completion, indicates that an identical reference object * already existed, and the refcount was upped on that object instead. +* @require_existed: Fail with -EPERM if an identical ref object didn't +* already exist. * * Checks that the base object is shareable and adds a ref object to it. *
@@ -243,7 +245,8 @@ extern void ttm_base_object_unref(struct*/ extern int ttm_ref_object_add (struct ttm_object_file *tfile,struct ttm_base_object *base, -enum ttm_ref_type ref_type,bool *existed); +enum ttm_ref_type ref_type,bool *existed, +bool require_existed);extern bool ttm_ref_object_exists (struct ttm_object_file *tfile,struct ttm_base_object *base);
PATCH 107/178 drm/vmwgfx: Remove getparam error message
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Hellstrom <[email protected]>
commit 53e16798b0864464c5444a204e1bb93ae246c429 upstream.
The mesa winsys sometimes uses unimplemented parameter requests to check for features. Remove the error message to avoid bloating the kernel log.
--- drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c +0 -2
@@ -106,8 +106,6 @@ int vmw_getparam_ioctl(struct drm_device param->value = dev_priv->max_mob_size;break ;default : -DRM_ERROR ("Illegal vmwgfx get param request: %d\n" , - param->param);return -EINVAL ; }
PATCH 108/178 mmc: sdhci: Disable runtime pm when the sdio_irq is enabled
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit 923713b357455cfb9aca2cd3429cb0806a724ed2 upstream.
SDIO cards may need clock to send the card interrupt to the host.
On a cherrytrail tablet with a RTL8723BS wifi chip, without this patch pinging the tablet results in:
PING 192.168.1.14 (192.168.1.14) 56(84) bytes of data. 64 bytes from 192.168.1.14: icmp_seq=1 ttl=64 time=78.6 ms 64 bytes from 192.168.1.14: icmp_seq=2 ttl=64 time=1760 ms 64 bytes from 192.168.1.14: icmp_seq=3 ttl=64 time=753 ms 64 bytes from 192.168.1.14: icmp_seq=4 ttl=64 time=3.88 ms 64 bytes from 192.168.1.14: icmp_seq=5 ttl=64 time=795 ms 64 bytes from 192.168.1.14: icmp_seq=6 ttl=64 time=1841 ms 64 bytes from 192.168.1.14: icmp_seq=7 ttl=64 time=810 ms 64 bytes from 192.168.1.14: icmp_seq=8 ttl=64 time=1860 ms 64 bytes from 192.168.1.14: icmp_seq=9 ttl=64 time=812 ms 64 bytes from 192.168.1.14: icmp_seq=10 ttl=64 time=48.6 ms
Where as with this patch I get:
PING 192.168.1.14 (192.168.1.14) 56(84) bytes of data. 64 bytes from 192.168.1.14: icmp_seq=1 ttl=64 time=3.96 ms 64 bytes from 192.168.1.14: icmp_seq=2 ttl=64 time=1.97 ms 64 bytes from 192.168.1.14: icmp_seq=3 ttl=64 time=17.2 ms 64 bytes from 192.168.1.14: icmp_seq=4 ttl=64 time=2.46 ms 64 bytes from 192.168.1.14: icmp_seq=5 ttl=64 time=2.83 ms 64 bytes from 192.168.1.14: icmp_seq=6 ttl=64 time=1.40 ms 64 bytes from 192.168.1.14: icmp_seq=7 ttl=64 time=2.10 ms 64 bytes from 192.168.1.14: icmp_seq=8 ttl=64 time=1.40 ms 64 bytes from 192.168.1.14: icmp_seq=9 ttl=64 time=2.04 ms 64 bytes from 192.168.1.14: icmp_seq=10 ttl=64 time=1.40 ms
--- drivers/mmc/host/sdhci.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/mmc/host/sdhci.c +6 -0
@@ -1708,6 +1708,9 @@ static void sdhci_enable_sdio_irq(structsdhci_runtime_pm_get (host); +if (enable) +pm_runtime_get_noresume (host->mmc->parent); +spin_lock_irqsave (&host->lock, flags);if (enable) host->flags |=SDHCI_SDIO_IRQ_ENABLED ;
@@ -1717,6 +1720,9 @@ static void sdhci_enable_sdio_irq(structsdhci_enable_sdio_irq_nolock (host, enable);spin_unlock_irqrestore (&host->lock, flags); +if (!enable) +pm_runtime_put_noidle (host->mmc->parent); +sdhci_runtime_pm_put (host); }
PATCH 109/178 serial: mxs-auart: fix baud rate range
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Wahren <[email protected]>
commit df57cf6a879502cd6e5559c1f2d6db12128e074f upstream.
Currently mxs-auart doesn't care correctly about the baud rate divisor. According to reference manual the baud rate divisor must be between 0x000000EC and 0x003FFFC0. So calculate the possible baud rate range and use it for uart_get_baud_rate().
--- drivers/tty/serial/mxs-auart.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/tty/serial/mxs-auart.c +6 -2
@@ -90,6 +90,8 @@#define AUART_CTRL2_TXE (1 << 8)#define AUART_CTRL2_UARTEN (1 << 0) +#define AUART_LINECTRL_BAUD_DIV_MAX 0x003fffc0 +#define AUART_LINECTRL_BAUD_DIV_MIN 0x000000ec#define AUART_LINECTRL_BAUD_DIVINT_SHIFT 16#define AUART_LINECTRL_BAUD_DIVINT_MASK 0xffff0000#define AUART_LINECTRL_BAUD_DIVINT (v) (((v) & 0xffff) << 16)
@@ -566,7 +568,7 @@ static void mxs_auart_settermios(struct {struct mxs_auart_port *s =to_auart_port (u);u32 bm, ctrl, ctrl2, div; -unsigned int cflag, baud; +unsigned int cflag, baud, baud_min, baud_max; cflag = termios->c_cflag;
@@ -656,7 +658,9 @@ static void mxs_auart_settermios(struct }/* set baud rate */ - baud =uart_get_baud_rate (u, termios, old,0 , u->uartclk); + baud_min =DIV_ROUND_UP (u->uartclk *32 ,AUART_LINECTRL_BAUD_DIV_MAX ); + baud_max = u->uartclk *32 /AUART_LINECTRL_BAUD_DIV_MIN ; + baud =uart_get_baud_rate (u, termios, old, baud_min, baud_max); div = u->uartclk *32 / baud; ctrl |=AUART_LINECTRL_BAUD_DIVFRAC (div &0x3F ); ctrl |=AUART_LINECTRL_BAUD_DIVINT (div >>6 );
PATCH 110/178 serial: mxs-auart: Fix baudrate calculation
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
commit a6040bc610554c66088fda3608ae5d6307c548e4 upstream.
The reference manual for the i.MX28 recommends to calculate the divisor as
divisor = (UARTCLK * 32) / baud rate, rounded to the nearest integer
, so let's do this. For a typical setup of UARTCLK = 24 MHz and baud rate = 115200 this changes the divisor from 6666 to 6667 and so the actual baud rate improves from 115211.521 Bd (error ≅ 0.01 %) to 115194.240 Bd (error ≅ 0.005 %).
--- drivers/tty/serial/mxs-auart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/mxs-auart.c +1 -1
@@ -661,7 +661,7 @@ static void mxs_auart_settermios(struct baud_min =DIV_ROUND_UP (u->uartclk *32 ,AUART_LINECTRL_BAUD_DIV_MAX ); baud_max = u->uartclk *32 /AUART_LINECTRL_BAUD_DIV_MIN ; baud =uart_get_baud_rate (u, termios, old, baud_min, baud_max); - div = u->uartclk *32 / baud; + div =DIV_ROUND_CLOSEST (u->uartclk *32 , baud); ctrl |=AUART_LINECTRL_BAUD_DIVFRAC (div &0x3F ); ctrl |=AUART_LINECTRL_BAUD_DIVINT (div >>6 );
PATCH 111/178 l2tp: fix race in l2tp_recv_common()
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Nault <[email protected]>
commit 61b9a047729bb230978178bca6729689d0c50ca2 upstream.
Taking a reference on sessions in l2tp_recv_common() is racy; this has to be done by the callers.
To this end, a new function is required (l2tp_session_get()) to atomically lookup a session and take a reference on it. Callers then have to manually drop this reference.
--- net/l2tp/l2tp_core.c | 73 ++++++++++++++++++++++++++++++++++++++++++---------- net/l2tp/l2tp_core.h | 3 +++ net/l2tp/l2tp_ip.c | 17 ++++++++---- net/l2tp/l2tp_ip6.c | 18 +++++++++---- 4 files changed, 88 insertions(+), 23 deletions(-)
net/l2tp/l2tp_core.c +60 -13
@@ -277,6 +277,55 @@ struct l2tp_session *l2tp_session_find(s }EXPORT_SYMBOL_GPL (l2tp_session_find); +/* Like l2tp_session_find() but takes a reference on the returned session. +* Optionally calls session->ref() too if do_ref is true. +*/ +struct l2tp_session *l2tp_session_get (struct net *net, +struct l2tp_tunnel *tunnel, +u32 session_id,bool do_ref) +{ +struct hlist_head *session_list; +struct l2tp_session *session; + +if (!tunnel) { +struct l2tp_net *pn =l2tp_pernet (net); + + session_list =l2tp_session_id_hash_2 (pn, session_id); + +rcu_read_lock_bh (); +hlist_for_each_entry_rcu (session, session_list, global_hlist) { +if (session->session_id == session_id) { +l2tp_session_inc_refcount (session); +if (do_ref && session->ref) + session->ref (session); +rcu_read_unlock_bh (); + +return session; + } + } +rcu_read_unlock_bh (); + +return NULL ; + } + + session_list =l2tp_session_id_hash (tunnel, session_id); +read_lock_bh (&tunnel->hlist_lock); +hlist_for_each_entry (session, session_list, hlist) { +if (session->session_id == session_id) { +l2tp_session_inc_refcount (session); +if (do_ref && session->ref) + session->ref (session); +read_unlock_bh (&tunnel->hlist_lock); + +return session; + } + } +read_unlock_bh (&tunnel->hlist_lock); + +return NULL ; +} +EXPORT_SYMBOL_GPL (l2tp_session_get); +struct l2tp_session *l2tp_session_find_nth (struct l2tp_tunnel *tunnel,int nth) {int hash;
@@ -632,6 +681,9 @@ discard:* a data (not control) frame before coming here. Fields up to the * session-id have already been parsed and ptr points to the data * after the session-id. +* +* session->ref() must have been called prior to l2tp_recv_common(). +* session->deref() will be called automatically after skb is processed. */ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb, unsigned char *ptr, unsigned char *optr, u16 hdrflags,
@@ -641,14 +693,6 @@ void l2tp_recv_common(struct l2tp_sessioint offset;u32 ns, nr; -/* The ref count is increased since we now hold a pointer to -* the session. Take care to decrement the refcnt when exiting -* this function from now on... -*/ -l2tp_session_inc_refcount (session); -if (session->ref) - (*session->ref)(session); -/* Parse and check optional cookie */ if (session->peer_cookie_len >0 ) {if (memcmp (ptr, &session->peer_cookie[0 ], session->peer_cookie_len)) {
@@ -801,8 +845,6 @@ void l2tp_recv_common(struct l2tp_sessio/* Try to dequeue as many skbs from reorder_q as we can. */ l2tp_recv_dequeue (session); -l2tp_session_dec_refcount (session); -return ; discard:
@@ -811,8 +853,6 @@ discard:if (session->deref) (*session->deref)(session); - -l2tp_session_dec_refcount (session); }EXPORT_SYMBOL (l2tp_recv_common);
@@ -919,8 +959,14 @@ static int l2tp_udp_recv_core(struct l2t }/* Find the session context */ - session =l2tp_session_find (tunnel->l2tp_net, tunnel, session_id); + session =l2tp_session_get (tunnel->l2tp_net, tunnel, session_id, true);if (!session || !session->recv_skb) { +if (session) { +if (session->deref) + session->deref (session); +l2tp_session_dec_refcount (session); + } +/* Not found? Pass to userspace to deal with */ l2tp_info(tunnel, L2TP_MSG_DATA, "%s: no session found (%u/%u). Passing up.\n",
@@ -929,6 +975,7 @@ static int l2tp_udp_recv_core(struct l2t }l2tp_recv_common (session, skb, ptr, optr, hdrflags, length, payload_hook); +l2tp_session_dec_refcount (session);return 0 ;
net/l2tp/l2tp_core.h +3 -0
@@ -240,6 +240,9 @@ out:return tunnel; } +struct l2tp_session *l2tp_session_get (struct net *net, +struct l2tp_tunnel *tunnel, +u32 session_id,bool do_ref);struct l2tp_session *l2tp_session_find (struct net *net,struct l2tp_tunnel *tunnel,u32 session_id);
net/l2tp/l2tp_ip.c +12 -5
@@ -142,19 +142,19 @@ static int l2tp_ip_recv(struct sk_buff * }/* Ok, this is a data packet. Lookup the session. */ - session =l2tp_session_find (net,NULL , session_id); -if (session ==NULL ) + session =l2tp_session_get (net,NULL , session_id, true); +if (!session) goto discard; tunnel = session->tunnel; -if (tunnel ==NULL ) - goto discard; +if (!tunnel) + goto discard_sess;/* Trace packet contents, if enabled */ if (tunnel->debug &L2TP_MSG_DATA ) { length =min (32u , skb->len);if (!pskb_may_pull (skb, length)) - goto discard; + goto discard_sess;/* Point to L2TP header */ optr = ptr = skb->data;
@@ -164,6 +164,7 @@ static int l2tp_ip_recv(struct sk_buff * }l2tp_recv_common (session, skb, ptr, optr,0 , skb->len, tunnel->recv_payload_hook); +l2tp_session_dec_refcount (session);return 0 ;
@@ -199,6 +200,12 @@ pass_up:return sk_receive_skb (sk, skb,1 ); +discard_sess: +if (session->deref) + session->deref (session); +l2tp_session_dec_refcount (session); + goto discard; + discard_put:sock_put (sk);
net/l2tp/l2tp_ip6.c +13 -5
@@ -153,19 +153,19 @@ static int l2tp_ip6_recv(struct sk_buff }/* Ok, this is a data packet. Lookup the session. */ - session =l2tp_session_find (&init_net,NULL , session_id); -if (session ==NULL ) + session =l2tp_session_get (&init_net,NULL , session_id, true); +if (!session) goto discard; tunnel = session->tunnel; -if (tunnel ==NULL ) - goto discard; +if (!tunnel) + goto discard_sess;/* Trace packet contents, if enabled */ if (tunnel->debug &L2TP_MSG_DATA ) { length =min (32u , skb->len);if (!pskb_may_pull (skb, length)) - goto discard; + goto discard_sess;/* Point to L2TP header */ optr = ptr = skb->data;
@@ -176,6 +176,8 @@ static int l2tp_ip6_recv(struct sk_buffl2tp_recv_common (session, skb, ptr, optr,0 , skb->len, tunnel->recv_payload_hook); +l2tp_session_dec_refcount (session); +return 0 ; pass_up:
@@ -211,6 +213,12 @@ pass_up:return sk_receive_skb (sk, skb,1 ); +discard_sess: +if (session->deref) + session->deref (session); +l2tp_session_dec_refcount (session); + goto discard; + discard_put:sock_put (sk);
PATCH 112/178 l2tp: ensure session can't get removed during pppol2tp_session_ioctl()
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Nault <[email protected]>
commit 57377d63547861919ee634b845c7caa38de4a452 upstream.
Holding a reference on session is required before calling pppol2tp_session_ioctl(). The session could get freed while processing the ioctl otherwise. Since pppol2tp_session_ioctl() uses the session's socket, we also need to take a reference on it in l2tp_session_get().
--- net/l2tp/l2tp_ppp.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
net/l2tp/l2tp_ppp.c +11 -4
@@ -1160,11 +1160,18 @@ static int pppol2tp_tunnel_ioctl(structif (stats.session_id !=0 ) {/* resend to session ioctl handler */ struct l2tp_session *session = -l2tp_session_find (sock_net (sk), tunnel, stats.session_id); -if (session !=NULL ) - err =pppol2tp_session_ioctl (session, cmd, arg); -else +l2tp_session_get (sock_net (sk), tunnel, + stats.session_id, true); + +if (session) { + err =pppol2tp_session_ioctl (session, cmd, + arg); +if (session->deref) + session->deref (session); +l2tp_session_dec_refcount (session); + }else { err = -EBADR ; + }break ; }#ifdef CONFIG_XFRM
PATCH 113/178 l2tp: fix duplicate session creation
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Nault <[email protected]>
commit dbdbc73b44782e22b3b4b6e8b51e7a3d245f3086 upstream.
l2tp_session_create() relies on its caller for checking for duplicate sessions. This is racy since a session can be concurrently inserted after the caller's verification.
Fix this by letting l2tp_session_create() verify sessions uniqueness upon insertion. Callers need to be adapted to check for l2tp_session_create()'s return code instead of calling l2tp_session_find().
pppol2tp_connect() is a bit special because it has to work on existing sessions (if they're not connected) or to create a new session if none is found. When acting on a preexisting session, a reference must be held or it could go away on us. So we have to use l2tp_session_get() instead of l2tp_session_find() and drop the reference before exiting.
--- net/l2tp/l2tp_core.c | 70 +++++++++++++++++++++++++++++++++++++++------------- net/l2tp/l2tp_eth.c | 10 ++------ net/l2tp/l2tp_ppp.c | 60 ++++++++++++++++++++++---------------------- 3 files changed, 84 insertions(+), 56 deletions(-)
net/l2tp/l2tp_core.c +53 -17
@@ -373,6 +373,48 @@ struct l2tp_session *l2tp_session_find_b }EXPORT_SYMBOL_GPL (l2tp_session_find_by_ifname); +static int l2tp_session_add_to_tunnel (struct l2tp_tunnel *tunnel, +struct l2tp_session *session) +{ +struct l2tp_session *session_walk; +struct hlist_head *g_head; +struct hlist_head *head; +struct l2tp_net *pn; + + head =l2tp_session_id_hash (tunnel, session->session_id); + +write_lock_bh (&tunnel->hlist_lock); +hlist_for_each_entry (session_walk, head, hlist) +if (session_walk->session_id == session->session_id) + goto exist; + +if (tunnel->version ==L2TP_HDR_VER_3 ) { + pn =l2tp_pernet (tunnel->l2tp_net); + g_head =l2tp_session_id_hash_2 (l2tp_pernet (tunnel->l2tp_net), + session->session_id); + +spin_lock_bh (&pn->l2tp_session_hlist_lock); +hlist_for_each_entry (session_walk, g_head, global_hlist) +if (session_walk->session_id == session->session_id) + goto exist_glob; + +hlist_add_head_rcu (&session->global_hlist, g_head); +spin_unlock_bh (&pn->l2tp_session_hlist_lock); + } + +hlist_add_head (&session->hlist, head); +write_unlock_bh (&tunnel->hlist_lock); + +return 0 ; + +exist_glob: +spin_unlock_bh (&pn->l2tp_session_hlist_lock); +exist: +write_unlock_bh (&tunnel->hlist_lock); + +return -EEXIST ; +} +/* Lookup a tunnel by id */ struct l2tp_tunnel *l2tp_tunnel_find (struct net *net,u32 tunnel_id)
@@ -1822,6 +1864,7 @@ EXPORT_SYMBOL_GPL(l2tp_session_set_headestruct l2tp_session *l2tp_session_create (int priv_size,struct l2tp_tunnel *tunnel,u32 session_id,u32 peer_session_id,struct l2tp_session_cfg *cfg) {struct l2tp_session *session; +int err; session =kzalloc (sizeof (struct l2tp_session ) + priv_size,GFP_KERNEL );if (session !=NULL ) {
@@ -1877,6 +1920,13 @@ struct l2tp_session *l2tp_session_createl2tp_session_set_header_len (session, tunnel->version); + err =l2tp_session_add_to_tunnel (tunnel, session); +if (err) { +kfree (session); + +return ERR_PTR (err); + } +/* Bump the reference count. The session context is deleted * only when this drops to zero. */
@@ -1886,28 +1936,14 @@ struct l2tp_session *l2tp_session_create/* Ensure tunnel socket isn't deleted */ sock_hold (tunnel->sock); -/* Add session to the tunnel's hash list */ -write_lock_bh (&tunnel->hlist_lock); -hlist_add_head (&session->hlist, -l2tp_session_id_hash (tunnel, session_id)); -write_unlock_bh (&tunnel->hlist_lock); - -/* And to the global session list if L2TPv3 */ -if (tunnel->version !=L2TP_HDR_VER_2 ) { -struct l2tp_net *pn =l2tp_pernet (tunnel->l2tp_net); - -spin_lock_bh (&pn->l2tp_session_hlist_lock); -hlist_add_head_rcu (&session->global_hlist, -l2tp_session_id_hash_2 (pn, session_id)); -spin_unlock_bh (&pn->l2tp_session_hlist_lock); - } -/* Ignore management session in session count value */ if (session->session_id !=0 )atomic_inc (&l2tp_session_count); + +return session; } -return session; +return ERR_PTR (-ENOMEM ); }EXPORT_SYMBOL_GPL (l2tp_session_create);
net/l2tp/l2tp_eth.c +2 -8
@@ -222,12 +222,6 @@ static int l2tp_eth_create(struct net *n goto out; } - session =l2tp_session_find (net, tunnel, session_id); -if (session) { - rc = -EEXIST ; - goto out; - } -if (cfg->ifname) { dev =dev_get_by_name (net, cfg->ifname);if (dev) {
@@ -241,8 +235,8 @@ static int l2tp_eth_create(struct net *n session =l2tp_session_create (sizeof (*spriv), tunnel, session_id, peer_session_id, cfg); -if (!session) { - rc = -ENOMEM ; +if (IS_ERR (session)) { + rc =PTR_ERR (session); goto out; }
net/l2tp/l2tp_ppp.c +29 -31
101 lines not on this page · raw message
PATCH 114/178 l2tp: take a reference on sessions used in genetlink handlers
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Nault <[email protected]>
commit 2777e2ab5a9cf2b4524486c6db1517a6ded25261 upstream.
Callers of l2tp_nl_session_find() need to hold a reference on the returned session since there's no guarantee that it isn't going to disappear from under them.
Relying on the fact that no l2tp netlink message may be processed concurrently isn't enough: sessions can be deleted by other means (e.g. by closing the PPPOL2TP socket of a ppp pseudowire).
l2tp_nl_cmd_session_delete() is a bit special: it runs a callback function that may require a previous call to session->ref(). In particular, for ppp pseudowires, the callback is l2tp_session_delete(), which then calls pppol2tp_session_close() and dereferences the PPPOL2TP socket. The socket might already be gone at the moment l2tp_session_delete() calls session->ref(), so we need to take a reference during the session lookup. So we need to pass the do_ref variable down to l2tp_session_get() and l2tp_session_get_by_ifname().
Since all callers have to be updated, l2tp_session_find_by_ifname() and l2tp_nl_session_find() are renamed to reflect their new behaviour.
--- net/l2tp/l2tp_core.c | 9 +++++++-- net/l2tp/l2tp_core.h | 3 ++- net/l2tp/l2tp_netlink.c | 39 ++++++++++++++++++++++++++------------- 3 files changed, 35 insertions(+), 16 deletions(-)
net/l2tp/l2tp_core.c +7 -2
@@ -351,7 +351,8 @@ EXPORT_SYMBOL_GPL(l2tp_session_find_nth)/* Lookup a session by interface name. * This is very inefficient but is only used by management interfaces. */ -struct l2tp_session *l2tp_session_find_by_ifname (struct net *net,char *ifname) +struct l2tp_session *l2tp_session_get_by_ifname (struct net *net,char *ifname, +bool do_ref) {struct l2tp_net *pn =l2tp_pernet (net);int hash;
@@ -361,7 +362,11 @@ struct l2tp_session *l2tp_session_find_bfor (hash =0 ; hash <L2TP_HASH_SIZE_2 ; hash++) {hlist_for_each_entry_rcu (session, &pn->l2tp_session_hlist[hash], global_hlist) {if (!strcmp (session->ifname, ifname)) { +l2tp_session_inc_refcount (session); +if (do_ref && session->ref) + session->ref (session);rcu_read_unlock_bh (); +return session; } }
@@ -371,7 +376,7 @@ struct l2tp_session *l2tp_session_find_breturn NULL ; } -EXPORT_SYMBOL_GPL (l2tp_session_find_by_ifname); +EXPORT_SYMBOL_GPL (l2tp_session_get_by_ifname);static int l2tp_session_add_to_tunnel (struct l2tp_tunnel *tunnel,struct l2tp_session *session)
net/l2tp/l2tp_core.h +2 -1
@@ -247,7 +247,8 @@ struct l2tp_session *l2tp_session_find(sstruct l2tp_tunnel *tunnel, u32 session_id);struct l2tp_session *l2tp_session_find_nth (struct l2tp_tunnel *tunnel,int nth); -struct l2tp_session *l2tp_session_find_by_ifname (struct net *net,char *ifname); +struct l2tp_session *l2tp_session_get_by_ifname (struct net *net,char *ifname, +bool do_ref);struct l2tp_tunnel *l2tp_tunnel_find (struct net *net,u32 tunnel_id);struct l2tp_tunnel *l2tp_tunnel_find_nth (struct net *net,int nth);
net/l2tp/l2tp_netlink.c +26 -13
@@ -43,7 +43,8 @@ static struct genl_family l2tp_nl_family/* Accessed under genl lock */ static const struct l2tp_nl_cmd_ops *l2tp_nl_cmd_ops[__L2TP_PWTYPE_MAX]; -static struct l2tp_session *l2tp_nl_session_find (struct genl_info *info) +static struct l2tp_session *l2tp_nl_session_get (struct genl_info *info, +bool do_ref) {u32 tunnel_id;u32 session_id;
@@ -54,14 +55,15 @@ static struct l2tp_session *l2tp_nl_sessif (info->attrs[L2TP_ATTR_IFNAME ]) { ifname =nla_data (info->attrs[L2TP_ATTR_IFNAME ]); - session =l2tp_session_find_by_ifname (net, ifname); + session =l2tp_session_get_by_ifname (net, ifname, do_ref); }else if ((info->attrs[L2TP_ATTR_SESSION_ID ]) && (info->attrs[L2TP_ATTR_CONN_ID ])) { tunnel_id =nla_get_u32 (info->attrs[L2TP_ATTR_CONN_ID ]); session_id =nla_get_u32 (info->attrs[L2TP_ATTR_SESSION_ID ]); tunnel =l2tp_tunnel_find (net, tunnel_id);if (tunnel) - session =l2tp_session_find (net, tunnel, session_id); + session =l2tp_session_get (net, tunnel, session_id, + do_ref); }return session;
@@ -549,7 +551,7 @@ static int l2tp_nl_cmd_session_delete(ststruct l2tp_session *session;u16 pw_type; - session =l2tp_nl_session_find (info); + session =l2tp_nl_session_get (info, true);if (session ==NULL ) { ret = -ENODEV ; goto out;
@@ -560,6 +562,10 @@ static int l2tp_nl_cmd_session_delete(stif (l2tp_nl_cmd_ops[pw_type] && l2tp_nl_cmd_ops[pw_type]->session_delete) ret = (*l2tp_nl_cmd_ops[pw_type]->session_delete)(session); +if (session->deref) + session->deref (session); +l2tp_session_dec_refcount (session); + out:return ret; }
@@ -569,7 +575,7 @@ static int l2tp_nl_cmd_session_modify(stint ret =0 ;struct l2tp_session *session; - session =l2tp_nl_session_find (info); + session =l2tp_nl_session_get (info, false);if (session ==NULL ) { ret = -ENODEV ; goto out;
@@ -601,6 +607,8 @@ static int l2tp_nl_cmd_session_modify(stif (info->attrs[L2TP_ATTR_MRU ]) session->mru =nla_get_u16 (info->attrs[L2TP_ATTR_MRU ]); +l2tp_session_dec_refcount (session); + out:return ret; }
@@ -686,29 +694,34 @@ static int l2tp_nl_cmd_session_get(strucstruct sk_buff *msg;int ret; - session =l2tp_nl_session_find (info); + session =l2tp_nl_session_get (info, false);if (session ==NULL ) { ret = -ENODEV ; - goto out; + goto err; } msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL );if (!msg) { ret = -ENOMEM ; - goto out; + goto err_ref; } ret =l2tp_nl_session_send (msg, info->snd_portid, info->snd_seq,0 , session);if (ret <0 ) - goto err_out; + goto err_ref_msg; -return genlmsg_unicast (genl_info_net (info), msg, info->snd_portid); + ret =genlmsg_unicast (genl_info_net (info), msg, info->snd_portid); -err_out: -nlmsg_free (msg); +l2tp_session_dec_refcount (session); -out: +return ret; + +err_ref_msg: +nlmsg_free (msg); +err_ref: +l2tp_session_dec_refcount (session); +err:return ret; }
PATCH 115/178 kernel.h: make abs() work with 64-bit types
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Michal Nazarewicz <[email protected]>
commit c8299cb605b27dd5a49f7a69e48fd23e5a206298 upstream.
For 64-bit arguments, the abs macro casts it to an int which leads to lost precision and may cause incorrect results. To deal with 64-bit types abs64 macro has been introduced but still there are places where abs macro is used incorrectly.
To deal with the problem, expand abs macro such that it operates on s64 type when dealing with 64-bit types while still returning long when dealing with smaller types.
This fixes one known bug (per John):
The internal clocksteering done for fine-grained error correction uses a : logarithmic approximation, so any time adjtimex() adjusts the clock : steering, timekeeping_freqadjust() quickly approximates the correct clock : frequency over a series of ticks.
:
: Unfortunately, the logic in timekeeping_freqadjust(), introduced in commit : dc491596f639438 (Rework frequency adjustments to work better w/ nohz), : used the abs() function with a s64 error value to calculate the size of : the approximated adjustment to be made.
:
: Per include/linux/kernel.h: "abs() should not be used for 64-bit types : (s64, u64, long long) - use abs64()".
:
: Thus on 32-bit platforms, this resulted in the clocksteering to take a : quite dampended random walk trying to converge on the proper frequency, : which caused the adjustments to be made much slower then intended (most : easily observed when large adjustments are made).
--- include/linux/kernel.h | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-)
include/linux/kernel.h +23 -20
@@ -183,28 +183,31 @@ extern int _cond_resched(void);#define might_sleep_if (cond) do { if (cond) might_sleep(); } while (0) -/* -* abs() handles unsigned and signed longs, ints, shorts and chars. For all -* input types abs() returns a signed long. -* abs() should not be used for 64-bit types (s64, u64, long long) - use abs64() -* for those. +/** +* abs - return absolute value of an argument +* @x: the value. If it is unsigned type, it is converted to signed type first +* (s64, long or int depending on its size). +* +* Return: an absolute value of x. If x is 64-bit, macro's return type is s64, +* otherwise it is signed long. */ -#define abs (x) ({ \ - long ret; \ - if (sizeof(x) == sizeof(long)) { \ - long __x = (x); \ - ret = (__x < 0) ? -__x : __x; \ - } else { \ - int __x = (x); \ - ret = (__x < 0) ? -__x : __x; \ - } \ - ret; \ - }) +#define abs (x) __builtin_choose_expr(sizeof(x) == sizeof(s64), ({ \ + s64 __x = (x); \ + (__x < 0) ? -__x : __x; \ + }), ({ \ + long ret; \ + if (sizeof(x) == sizeof(long)) { \ + long __x = (x); \ + ret = (__x < 0) ? -__x : __x; \ + } else { \ + int __x = (x); \ + ret = (__x < 0) ? -__x : __x; \ + } \ + ret; \ + })) -#define abs64 (x) ({ \ - s64 __x = (x); \ - (__x < 0) ? -__x : __x; \ - }) +/* Deprecated, use abs instead. */ +#define abs64 (x) abs((s64)(x))/** * reciprocal_scale - "scale" a value into range [0, ep_ro)
PATCH 116/178 include/linux/kernel.h: change abs() macro so it uses consistent return type
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Michal Nazarewicz <[email protected]>
commit 8f57e4d930d48217268315898212518d4d3e0773 upstream.
Rewrite abs() so that its return type does not depend on the architecture and no unexpected type conversion happen inside of it. The only conversion is from unsigned to signed type. char is left as a return type but treated as a signed type regradless of it's actual signedness.
With the old version, int arguments were promoted to long and depending on architecture a long argument might result in s64 or long return type (which may or may not be the same).
This came after some back and forth with Nicolas. The current macro has different return type (for the same input type) depending on architecture which might be midly iritating.
An alternative version would promote to int like so:
#define abs(x) __abs_choose_expr(x, long long, \
__abs_choose_expr(x, long, \
__builtin_choose_expr( \
sizeof(x) <= sizeof(int), \
({ int __x = (x); __x<0?-__x:__x; }), \
((void)0))))I have no preference but imagine Linus might. :] Nicolas argument against is that promoting to int causes iconsistent behaviour:
int main(void) {
unsigned short a = 0, b = 1, c = a - b;
unsigned short d = abs(a - b);
unsigned short e = abs(c);
printf("%u %u\n", d, e); // prints: 1 65535
}Then again, no sane person expects consistent behaviour from C integer arithmetic. ;)
Note:
__builtin_types_compatible_p(unsigned char, char) is always false, and __builtin_types_compatible_p(signed char, char) is also always false.
--- drivers/iio/industrialio-core.c | 9 +++---- drivers/net/wireless/iwlwifi/dvm/calib.c | 2 +- include/linux/kernel.h | 36 +++++++++++++------------- 3 files changed, 23 insertions(+), 24 deletions(-)
drivers/iio/industrialio-core.c +4 -5
@@ -390,16 +390,15 @@ ssize_t iio_format_value(char *buf, unsi scale_db = true;case IIO_VAL_INT_PLUS_MICRO :if (vals[1 ] <0 ) -return sprintf (buf,"-%ld.%06u%s\n" ,abs (vals[0 ]), - -vals[1 ], - scale_db ?" dB" :"" ); +return sprintf (buf,"-%d.%06u%s\n" ,abs (vals[0 ]), + -vals[1 ], scale_db ?" dB" :"" );else return sprintf (buf,"%d.%06u%s\n" , vals[0 ], vals[1 ], scale_db ?" dB" :"" );case IIO_VAL_INT_PLUS_NANO :if (vals[1 ] <0 ) -return sprintf (buf,"-%ld.%09u\n" ,abs (vals[0 ]), - -vals[1 ]); +return sprintf (buf,"-%d.%09u\n" ,abs (vals[0 ]), + -vals[1 ]);else return sprintf (buf,"%d.%09u\n" , vals[0 ], vals[1 ]);case IIO_VAL_FRACTIONAL :
drivers/net/wireless/iwlwifi/dvm/calib.c +1 -1
@@ -901,7 +901,7 @@ static void iwlagn_gain_computation(stru/* bound gain by 2 bits value max, 3rd bit is sign */ data->delta_gain_code[i] =min (abs (delta_g), - (long )CHAIN_NOISE_MAX_DELTA_GAIN_CODE ); + (s32 )CHAIN_NOISE_MAX_DELTA_GAIN_CODE );if (delta_g <0 )/*
include/linux/kernel.h +18 -18
@@ -185,26 +185,26 @@ extern int _cond_resched(void);/** * abs - return absolute value of an argument -* @x: the value. If it is unsigned type, it is converted to signed type first -* (s64, long or int depending on its size). +* @x: the value. If it is unsigned type, it is converted to signed type first. +* char is treated as if it was signed (regardless of whether it really is) +* but the macro's return type is preserved as char. * -* Return: an absolute value of x. If x is 64-bit, macro's return type is s64, -* otherwise it is signed long. +* Return: an absolute value of x. */ -#define abs (x) __builtin_choose_expr(sizeof(x) == sizeof(s64), ({ \ - s64 __x = (x); \ - (__x < 0) ? -__x : __x; \ - }), ({ \ - long ret; \ - if (sizeof(x) == sizeof(long)) { \ - long __x = (x); \ - ret = (__x < 0) ? -__x : __x; \ - } else { \ - int __x = (x); \ - ret = (__x < 0) ? -__x : __x; \ - } \ - ret; \ - })) +#define abs (x) __abs_choose_expr(x, long long, \ + __abs_choose_expr(x, long, \ + __abs_choose_expr(x, int, \ + __abs_choose_expr(x, short, \ + __abs_choose_expr(x, char, \ + __builtin_choose_expr( \ + __builtin_types_compatible_p(typeof(x), char), \ + (char)({ signed char __x = (x); __x<0?-__x:__x; }), \ + ((void)0))))))) + +#define __abs_choose_expr (x, type, other) __builtin_choose_expr( \ + __builtin_types_compatible_p(typeof(x), signed type) || \ + __builtin_types_compatible_p(typeof(x), unsigned type), \ + ({ signed type __x = (x); __x < 0 ? -__x : __x; }), other)/* Deprecated, use abs instead. */ #define abs64 (x) abs((s64)(x))
PATCH 117/178 iio: core: Fix IIO_VAL_FRACTIONAL_LOG2 for negative values
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Nikolaus Schulz <[email protected]>
commit 7fd6592d1287046f61bfd3cda3c03cd35be490f7 upstream.
Fix formatting of negative values of type IIO_VAL_FRACTIONAL_LOG2 by switching from do_div(), which can't handle negative numbers, to div_s64_rem(). Also use shift_right for shifting, which is safe with negative values.
[bwh: Backported to 3.16:
- Use vals[] instead of tmp{0,1}
- Keep using sprintf()]
--- drivers/iio/industrialio-core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/iio/industrialio-core.c +3 -4
@@ -406,10 +406,9 @@ ssize_t iio_format_value(char *buf, unsi vals[0 ] = (int )div_s64_rem (tmp,1000000000 , &vals[1 ]);return sprintf (buf,"%d.%09u\n" , vals[0 ],abs (vals[1 ]));case IIO_VAL_FRACTIONAL_LOG2 : - tmp = (s64 )vals[0 ] *1000000000LL >> vals[1 ]; - vals[1 ] =do_div (tmp,1000000000LL ); - vals[0 ] = tmp; -return sprintf (buf,"%d.%09u\n" , vals[0 ], vals[1 ]); + tmp =shift_right ((s64 )vals[0 ] *1000000000LL , vals[1 ]); + vals[0 ] = (int )div_s64_rem (tmp,1000000000LL , &vals[1 ]); +return sprintf (buf,"%d.%09u\n" , vals[0 ],abs (vals[1 ]));case IIO_VAL_INT_MULTIPLE : {int i;
PATCH 118/178 iio: hid-sensor-attributes: Fix sensor property setting failure.
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Song Hongyan <[email protected]>
commit bba6d9e47f3ea894e501f94b086a59ffe28241ac upstream.
When system bootup without get sensor property, set sensor property will be fail.
If no get_feature operation done before set_feature, the sensor properties will all be the initialized value, which is not the same with sensor real properties. When set sensor property it will write back to sensor the changed perperty data combines with other sensor properties data, it is not right and may be dangerous.
In order to get all sensor properties, choose to read one of the sensor properties(no matter read any sensor peroperty, driver will get all the peroperties and return the requested one).
[bwh: Backported to 3.16:
- sensor_hub_get_feature() doesn't take a 'buffer_size' parameter
- Adjust context]
--- drivers/iio/common/hid-sensors/hid-sensor-attributes.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/iio/common/hid-sensors/hid-sensor-attributes.c +10 -0
@@ -363,6 +363,8 @@ int hid_sensor_parse_common_attributes(s struct hid_sensor_common *st) { +s32 value; +int ret;hid_sensor_get_reporting_interval (hsdev, usage_id, st);
@@ -387,6 +389,14 @@ int hid_sensor_parse_common_attributes(s st->power_state.index, st->power_state.report_id, st->sensitivity.index, st->sensitivity.report_id); + ret =sensor_hub_get_feature (hsdev, + st->power_state.report_id, + st->power_state.index, &value); +if (ret <0 ) +return ret; +if (value <0 ) +return -EINVAL ; +return 0 ; }EXPORT_SYMBOL (hid_sensor_parse_common_attributes);
PATCH 119/178 iscsi-target: Drop work-around for legacy GlobalSAN initiator
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Bellinger <[email protected]>
commit 1c99de981f30b3e7868b8d20ce5479fa1c0fea46 upstream.
Once upon a time back in 2009, a work-around was added to support the GlobalSAN iSCSI initiator v3.3 for MacOSX, which during login did not propose nor respond to MaxBurstLength, FirstBurstLength, DefaultTime2Wait and DefaultTime2Retain keys.
The work-around in iscsi_check_proposer_for_optional_reply() allowed the missing keys to be proposed, but did not require waiting for a response before moving to full feature phase operation. This allowed GlobalSAN v3.3 to work out-of-the box, and for many years we didn't run into login interopt issues with any other initiators..
Until recently, when Martin tried a QLogic 57840S iSCSI Offload HBA on Windows 2016 which completed login, but subsequently failed with:
Got unknown iSCSI OpCode: 0x43
The issue was QLogic MSFT side did not propose DefaultTime2Wait + DefaultTime2Retain, so LIO proposes them itself, and immediately transitions to full feature phase because of the GlobalSAN hack. However, the QLogic MSFT side still attempts to respond to DefaultTime2Retain + DefaultTime2Wait, even though LIO has set ISCSI_FLAG_LOGIN_NEXT_STAGE3 + ISCSI_FLAG_LOGIN_TRANSIT in last login response.
So while the QLogic MSFT side should have been proposing these two keys to start, it was doing the correct thing per RFC-3720 attempting to respond to proposed keys before transitioning to full feature phase.
All that said, recent versions of GlobalSAN iSCSI (v5.3.0.541) does correctly propose the four keys during login, making the original work-around moot.
So in order to allow QLogic MSFT to run unmodified as-is, go ahead and drop this long standing work-around.
--- drivers/target/iscsi/iscsi_target_parameters.c | 16 ---------------- 1 file changed, 16 deletions(-)
drivers/target/iscsi/iscsi_target_parameters.c +0 -16
@@ -804,22 +804,6 @@ static void iscsi_check_proposer_for_optif (!strcmp (param->name,MAXRECVDATASEGMENTLENGTH ))SET_PSTATE_REPLY_OPTIONAL (param);/* -* The GlobalSAN iSCSI Initiator for MacOSX does -* not respond to MaxBurstLength, FirstBurstLength, -* DefaultTime2Wait or DefaultTime2Retain parameter keys. -* So, we set them to 'reply optional' here, and assume the -* the defaults from iscsi_parameters.h if the initiator -* is not RFC compliant and the keys are not negotiated. -*/ -if (!strcmp (param->name,MAXBURSTLENGTH )) -SET_PSTATE_REPLY_OPTIONAL (param); -if (!strcmp (param->name,FIRSTBURSTLENGTH )) -SET_PSTATE_REPLY_OPTIONAL (param); -if (!strcmp (param->name,DEFAULTTIME2WAIT )) -SET_PSTATE_REPLY_OPTIONAL (param); -if (!strcmp (param->name,DEFAULTTIME2RETAIN )) -SET_PSTATE_REPLY_OPTIONAL (param); -/* * Required for gPXE iSCSI boot client */ if (!strcmp (param->name,MAXCONNECTIONS ))
PATCH 120/178 af_key: Add lock to key dump
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Yuejie Shi <[email protected]>
commit 89e357d83c06b6fac581c3ca7f0ee3ae7e67109e upstream.
A dump may come in the middle of another dump, modifying its dump structure members. This race condition will result in NULL pointer dereference in kernel. So add a lock to prevent that race.
--- net/key/af_key.c | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-)
net/key/af_key.c +38 -8
@@ -63,6 +63,7 @@ struct pfkey_sock { } u;struct sk_buff *skb; } dump; +struct mutex dump_lock; };static inline struct pfkey_sock *pfkey_sk (struct sock *sk)
@@ -139,6 +140,7 @@ static int pfkey_create(struct net *net, {struct netns_pfkey *net_pfkey =net_generic (net, pfkey_net_id);struct sock *sk; +struct pfkey_sock *pfk;int err;if (!ns_capable (net->user_ns,CAP_NET_ADMIN ))
@@ -153,6 +155,9 @@ static int pfkey_create(struct net *net,if (sk ==NULL ) goto out; + pfk =pfkey_sk (sk); +mutex_init (&pfk->dump_lock); + sock->ops = &pfkey_ops;sock_init_data (sock, sk);
@@ -281,13 +286,23 @@ static int pfkey_do_dump(struct pfkey_sostruct sadb_msg *hdr;int rc; +mutex_lock (&pfk->dump_lock); +if (!pfk->dump.dump) { + rc =0 ; + goto out; + } + rc = pfk->dump.dump (pfk); -if (rc == -ENOBUFS ) -return 0 ; +if (rc == -ENOBUFS ) { + rc =0 ; + goto out; + }if (pfk->dump.skb) { -if (!pfkey_can_dump (&pfk->sk)) -return 0 ; +if (!pfkey_can_dump (&pfk->sk)) { + rc =0 ; + goto out; + } hdr = (struct sadb_msg *) pfk->dump.skb->data; hdr->sadb_msg_seq =0 ;
@@ -298,6 +313,9 @@ static int pfkey_do_dump(struct pfkey_so }pfkey_terminate_dump (pfk); + +out: +mutex_unlock (&pfk->dump_lock);return rc; }
@@ -1795,19 +1813,26 @@ static int pfkey_dump(struct sock *sk, sstruct xfrm_address_filter *filter =NULL ;struct pfkey_sock *pfk =pfkey_sk (sk); -if (pfk->dump.dump !=NULL ) +mutex_lock (&pfk->dump_lock); +if (pfk->dump.dump !=NULL ) { +mutex_unlock (&pfk->dump_lock);return -EBUSY ; + } proto =pfkey_satype2proto (hdr->sadb_msg_satype); -if (proto ==0 ) +if (proto ==0 ) { +mutex_unlock (&pfk->dump_lock);return -EINVAL ; + }if (ext_hdrs[SADB_X_EXT_FILTER -1 ]) {struct sadb_x_filter *xfilter = ext_hdrs[SADB_X_EXT_FILTER -1 ]; filter =kmalloc (sizeof (*filter),GFP_KERNEL ); -if (filter ==NULL ) +if (filter ==NULL ) { +mutex_unlock (&pfk->dump_lock);return -ENOMEM ; + }memcpy (&filter->saddr, &xfilter->sadb_x_filter_saddr,sizeof (xfrm_address_t));
@@ -1823,6 +1848,7 @@ static int pfkey_dump(struct sock *sk, s pfk->dump.dump = pfkey_dump_sa; pfk->dump.done = pfkey_dump_sa_done;xfrm_state_walk_init (&pfk->dump.u.state, proto, filter); +mutex_unlock (&pfk->dump_lock);return pfkey_do_dump (pfk); }
@@ -2681,14 +2707,18 @@ static int pfkey_spddump(struct sock *sk {struct pfkey_sock *pfk =pfkey_sk (sk); -if (pfk->dump.dump !=NULL ) +mutex_lock (&pfk->dump_lock); +if (pfk->dump.dump !=NULL ) { +mutex_unlock (&pfk->dump_lock);return -EBUSY ; + } pfk->dump.msg_version = hdr->sadb_msg_version; pfk->dump.msg_portid = hdr->sadb_msg_pid; pfk->dump.dump = pfkey_dump_sp; pfk->dump.done = pfkey_dump_sp_done;xfrm_policy_walk_init (&pfk->dump.u.policy,XFRM_POLICY_TYPE_MAIN ); +mutex_unlock (&pfk->dump_lock);return pfkey_do_dump (pfk); }
PATCH 121/178 kvm: arm/arm64: Fix locking for kvm_free_stage2_pgd
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Suzuki K Poulose <[email protected]>
commit 8b3405e345b5a098101b0c31b264c812bba045d9 upstream.
In kvm_free_stage2_pgd() we don't hold the kvm->mmu_lock while calling unmap_stage2_range() on the entire memory range for the guest. This could cause problems with other callers (e.g, munmap on a memslot) trying to unmap a range. And since we have to unmap the entire Guest memory range holding a spinlock, make sure we yield the lock if necessary, after we unmap each PUD range.
[bwh: Backported to 3.16:
- unmap_stage2_range() is a wrapper around unmap_range(), which is also used for HYP page table setup. So unmap_range() should do the cond_resched_lock(), but only if kvm != NULL.
- Adjust context]
--- arch/arm/kvm/mmu.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/arm/kvm/mmu.c +10 -0
@@ -199,6 +199,12 @@ static void unmap_range(struct kvm *kvm, next =kvm_pgd_addr_end (addr, end);if (!pgd_none (*pgd))unmap_puds (kvm, pgd, addr, next); +/* +* If the range is too large, release the kvm->mmu_lock +* to prevent starvation and lockup detector warnings. +*/ +if (kvm && next != end) +cond_resched_lock (&kvm->mmu_lock); }while (pgd++, addr = next, addr != end); }
@@ -553,6 +559,7 @@ int kvm_alloc_stage2_pgd(struct kvm *kvm*/ static void unmap_stage2_range (struct kvm *kvm,phys_addr_t start,u64 size) { +assert_spin_locked (&kvm->mmu_lock);unmap_range (kvm, kvm->arch.pgd, start, size); }
@@ -637,7 +644,10 @@ void kvm_free_stage2_pgd(struct kvm *kvmif (kvm->arch.pgd ==NULL )return ; +spin_lock (&kvm->mmu_lock);unmap_stage2_range (kvm,0 ,KVM_PHYS_SIZE ); +spin_unlock (&kvm->mmu_lock); +free_pages ((unsigned long )kvm->arch.pgd,S2_PGD_ORDER ); kvm->arch.pgd =NULL ; }
Re: [PATCH 3.16 121/178] kvm: arm/arm64: Fix locking for kvm_free_stage2_pgd
Quoted 59 lines · Ben Hutchings
3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Suzuki K Poulose <[email protected]>
commit
8b3405e345b5a098101b0c31b264c812bba045d9upstream.In
kvm_free_stage2_pgd()we don't hold thekvm->mmu_lockwhile callingunmap_stage2_range()on the entire memory range for the guest. This could cause problems with other callers (e.g, munmap on a memslot) trying to unmap a range. And since we have to unmap the entire Guest memory range holding a spinlock, make sure we yield the lock if necessary, after we unmap each PUD range.Fixes commit d5d8184d35c9 ("KVM: ARM: Memory virtualization setup")Cc Paolo Bonzini <[email protected]>Cc Marc Zyngier <[email protected]>Cc Christoffer Dall <[email protected]>Cc Mark Rutland <[email protected]>Signed-off-by Suzuki K Poulose <[email protected]>[ Avoid vCPU starvation and lockup detector warnings ]Signed-off-by Marc Zyngier <[email protected]>Signed-off-by Suzuki K Poulose <[email protected]>Signed-off-by Christoffer Dall <[email protected]>[bwh: Backported to 3.16:
-unmap_stage2_range()is a wrapper aroundunmap_range(), which is also used for HYP page table setup. Sounmap_range()should do thecond_resched_lock(), but only if kvm != NULL.
- Adjust context]Signed-off-by Ben Hutchings <[email protected]>--- arch/arm/kvm/mmu.c | 10 ++++++++++ 1 file changed, 10 insertions(+)arch/arm/kvm/mmu.c +7
-0@@ -199,6 +199,12 @@ static void unmap_range(struct kvm *kvm, next =kvm_pgd_addr_end (addr, end);if (!pgd_none (*pgd))unmap_puds (kvm, pgd, addr, next); +/* +* If the range is too large, release the kvm->mmu_lock +* to prevent starvation and lockup detector warnings. +*/ +if (kvm && next != end) +cond_resched_lock (&kvm->mmu_lock); }while (pgd++, addr = next, addr != end); }@@ -553,6 +559,7 @@ int kvm_alloc_stage2_pgd(struct kvm *kvm*/ static void unmap_stage2_range (struct kvm *kvm,phys_addr_t start,u64 size) { +assert_spin_locked (&kvm->mmu_lock);unmap_range (kvm, kvm->arch.pgd, start, size); }
arch/arm/kvm/mmu.c void kvm_free_stage2_pgd(struct kvm *kvm · line 653
Quoted 10 lines
arch/arm/kvm/mmu.c +3
-0@@ -637,7 +644,10 @@ void kvm_free_stage2_pgd(struct kvm *kvmif (kvm->arch.pgd ==NULL )return ; +spin_lock (&kvm->mmu_lock);unmap_stage2_range (kvm,0 ,KVM_PHYS_SIZE ); +spin_unlock (&kvm->mmu_lock); +free_pages ((unsigned long )kvm->arch.pgd,S2_PGD_ORDER ); kvm->arch.pgd =NULL ; }
Hi Ben,
There is a follow up patch for this one to make sure we check/free the PGD under the mmu_lock.
commit 6c0d706b563af73 ("kvm: arm/arm64: Fix race in resetting stage2 PGD")
So unless you want to fold that in, this looks alright. Looks like we missed a Cc:
stable for that. I will send it to stable soon.
Cheers
Suzuki
Quoted 1 line
Re: [PATCH 3.16 121/178] kvm: arm/arm64: Fix locking for kvm_free_stage2_pgd
Quoted 7 lines · Suzuki K Poulose
Quoted 6 lines · Ben Hutchings
3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Suzuki K Poulose <[email protected]>
[...]
Quoted 7 lines
There is a follow up patch for this one to make sure we check/free the PGD under the
mmu_lock.commit
6c0d706b563af73("kvm: arm/arm64: Fix race in resetting stage2 PGD")So unless you want to fold that in, this looks alright. Looks like we missed a Cc:
stable for that. I will send it to stable soon.
That does look like a fix suitable for stable. So far as I can see, though, "kvm: arm/arm64: Fix locking for kvm_free_stage2_pgd" does not introduce a regression - right? So I don't have to apply the two at the same time.
Ben.
Signature · 2 lines
Ben Hutchings Quantity is no substitute for quality, but it's the only one we've got.
PATCH 122/178 powerpc: Don't try to fix up misaligned load-with-reservation instructions
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paul Mackerras <[email protected]>
commit 48fe9e9488743eec9b7c1addd3c93f12f2123d54 upstream.
In the past, there was only one load-with-reservation instruction, lwarx, and if a program attempted a lwarx on a misaligned address, it would take an alignment interrupt and the kernel handler would emulate it as though it was lwzx, which was not really correct, but benign since it is loading the right amount of data, and the lwarx should be paired with a stwcx. to the same address, which would also cause an alignment interrupt which would result in a SIGBUS being delivered to the process.
We now have 5 different sizes of load-with-reservation instruction. Of those, lharx and ldarx cause an immediate SIGBUS by luck since their entries in aligninfo[] overlap instructions which were not fixed up, but lqarx overlaps with lhz and will be emulated as such. lbarx can never generate an alignment interrupt since it only operates on 1 byte.
To straighten this out and fix the lqarx case, this adds code to detect the l[hwdq]arx instructions and return without fixing them up, resulting in a SIGBUS being delivered to the process.
--- arch/powerpc/kernel/align.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)
arch/powerpc/kernel/align.c +19 -8
@@ -808,14 +808,25 @@ int fix_alignment(struct pt_regs *regs) nb = aligninfo[instr].len; flags = aligninfo[instr].flags; -/* ldbrx/stdbrx overlap lfs/stfs in the DSISR unfortunately */ -if (IS_XFORM (instruction) && ((instruction >>1 ) &0x3ff ) ==532 ) { - nb =8 ; - flags =LD +SW ; - }else if (IS_XFORM (instruction) && - ((instruction >>1 ) &0x3ff ) ==660 ) { - nb =8 ; - flags =ST +SW ; +/* +* Handle some cases which give overlaps in the DSISR values. +*/ +if (IS_XFORM (instruction)) { +switch (get_xop (instruction)) { +case 532 :/* ldbrx */ + nb =8 ; + flags =LD +SW ; +break ; +case 660 :/* stdbrx */ + nb =8 ; + flags =ST +SW ; +break ; +case 20 :/* lwarx */ +case 84 :/* ldarx */ +case 116 :/* lharx */ +case 276 :/* lqarx */ +return 0 ;/* not emulated ever */ + } }/* Byteswap little endian loads and stores */
PATCH 123/178 l2tp: take reference on sessions being dumped
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Nault <[email protected]>
commit e08293a4ccbcc993ded0fdc46f1e57926b833d63 upstream.
Take a reference on the sessions returned by l2tp_session_find_nth() (and rename it l2tp_session_get_nth() to reflect this change), so that caller is assured that the session isn't going to disappear while processing it.
For procfs and debugfs handlers, the session is held in the .start() callback and dropped in .show(). Given that pppol2tp_seq_session_show() dereferences the associated PPPoL2TP socket and that l2tp_dfs_seq_session_show() might call pppol2tp_show(), we also need to call the session's .ref() callback to prevent the socket from going away from under us.
--- net/l2tp/l2tp_core.c | 8 ++++++-- net/l2tp/l2tp_core.h | 3 ++- net/l2tp/l2tp_debugfs.c | 10 +++++++--- net/l2tp/l2tp_netlink.c | 7 +++++-- net/l2tp/l2tp_ppp.c | 10 +++++++--- 5 files changed, 27 insertions(+), 11 deletions(-)
net/l2tp/l2tp_core.c +6 -2
@@ -326,7 +326,8 @@ struct l2tp_session *l2tp_session_get(st }EXPORT_SYMBOL_GPL (l2tp_session_get); -struct l2tp_session *l2tp_session_find_nth (struct l2tp_tunnel *tunnel,int nth) +struct l2tp_session *l2tp_session_get_nth (struct l2tp_tunnel *tunnel,int nth, +bool do_ref) {int hash;struct l2tp_session *session;
@@ -336,6 +337,9 @@ struct l2tp_session *l2tp_session_find_nfor (hash =0 ; hash <L2TP_HASH_SIZE ; hash++) {hlist_for_each_entry (session, &tunnel->session_hlist[hash], hlist) {if (++count > nth) { +l2tp_session_inc_refcount (session); +if (do_ref && session->ref) + session->ref (session);read_unlock_bh (&tunnel->hlist_lock);return session; }
@@ -346,7 +350,7 @@ struct l2tp_session *l2tp_session_find_nreturn NULL ; } -EXPORT_SYMBOL_GPL (l2tp_session_find_nth); +EXPORT_SYMBOL_GPL (l2tp_session_get_nth);/* Lookup a session by interface name. * This is very inefficient but is only used by management interfaces.
net/l2tp/l2tp_core.h +2 -1
@@ -246,7 +246,8 @@ struct l2tp_session *l2tp_session_get(ststruct l2tp_session *l2tp_session_find (struct net *net,struct l2tp_tunnel *tunnel,u32 session_id); -struct l2tp_session *l2tp_session_find_nth (struct l2tp_tunnel *tunnel,int nth); +struct l2tp_session *l2tp_session_get_nth (struct l2tp_tunnel *tunnel,int nth, +bool do_ref);struct l2tp_session *l2tp_session_get_by_ifname (struct net *net,char *ifname,bool do_ref);struct l2tp_tunnel *l2tp_tunnel_find (struct net *net,u32 tunnel_id);
net/l2tp/l2tp_debugfs.c +7 -3
@@ -53,7 +53,7 @@ static void l2tp_dfs_next_tunnel(structstatic void l2tp_dfs_next_session (struct l2tp_dfs_seq_data *pd) { - pd->session =l2tp_session_find_nth (pd->tunnel, pd->session_idx); + pd->session =l2tp_session_get_nth (pd->tunnel, pd->session_idx, true); pd->session_idx++;if (pd->session ==NULL ) {
@@ -238,10 +238,14 @@ static int l2tp_dfs_seq_show(struct seq_ }/* Show the tunnel or session context */ -if (pd->session ==NULL ) +if (!pd->session) {l2tp_dfs_seq_tunnel_show (m, pd->tunnel); -else + }else {l2tp_dfs_seq_session_show (m, pd->session); +if (pd->session->deref) + pd->session->deref (pd->session); +l2tp_session_dec_refcount (pd->session); + } out:return 0 ;
net/l2tp/l2tp_netlink.c +5 -2
@@ -740,7 +740,7 @@ static int l2tp_nl_cmd_session_dump(stru goto out; } - session =l2tp_session_find_nth (tunnel, si); + session =l2tp_session_get_nth (tunnel, si, false);if (session ==NULL ) { ti++; tunnel =NULL ;
@@ -750,8 +750,11 @@ static int l2tp_nl_cmd_session_dump(struif (l2tp_nl_session_send (skb,NETLINK_CB (cb->skb).portid, cb->nlh->nlmsg_seq,NLM_F_MULTI , - session) <=0 ) + session) <=0 ) { +l2tp_session_dec_refcount (session);break ; + } +l2tp_session_dec_refcount (session); si++; }
net/l2tp/l2tp_ppp.c +7 -3
@@ -1579,7 +1579,7 @@ static void pppol2tp_next_tunnel(structstatic void pppol2tp_next_session (struct net *net,struct pppol2tp_seq_data *pd) { - pd->session =l2tp_session_find_nth (pd->tunnel, pd->session_idx); + pd->session =l2tp_session_get_nth (pd->tunnel, pd->session_idx, true); pd->session_idx++;if (pd->session ==NULL ) {
@@ -1706,10 +1706,14 @@ static int pppol2tp_seq_show(struct seq_/* Show the tunnel or session context. */ -if (pd->session ==NULL ) +if (!pd->session) {pppol2tp_seq_tunnel_show (m, pd->tunnel); -else + }else {pppol2tp_seq_session_show (m, pd->session); +if (pd->session->deref) + pd->session->deref (pd->session); +l2tp_session_dec_refcount (pd->session); + } out:return 0 ;
PATCH 124/178 powerpc/kernel: Use kprobe blacklist for asm functions
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Piggin <[email protected]>
commit 6f698df10cb24d466b9a790b9daedb9e7bcd5d2a upstream.
Rather than forcing the whole function into the ".kprobes.text" section, just add the symbol's address to the kprobe blacklist.
This also lets us drop the three versions of the_KPROBE macro, in exchange for just one version of _ASM_NOKPROBE_SYMBOL - which is a good cleanup.
--- arch/powerpc/include/asm/ppc_asm.h | 40 +++++++++++++------------------------- arch/powerpc/kernel/misc_32.S | 4 +++- arch/powerpc/kernel/misc_64.S | 5 +++-- 3 files changed, 20 insertions(+), 29 deletions(-)
arch/powerpc/include/asm/ppc_asm.h +14 -26
@@ -217,13 +217,6 @@ name: \ addi r2,r2,(.TOC.-0b)@l; \ .localentry name,.-name -#define _KPROBE (name) \ - .section ".kprobes.text","a"; \ - .align 2 ; \ - .type name,@function; \ - .globl name; \ -name: -#define DOTSYM (a) a#else
@@ -247,20 +240,6 @@ GLUE(.,name):#define _GLOBAL_TOC (name) _GLOBAL(name) -#define _KPROBE (name) \ - .section ".kprobes.text","a"; \ - .align 2 ; \ - .globl name; \ - .globl GLUE(.,name); \ - .section ".opd","aw"; \ -name: \ - .quad GLUE(.,name); \ - .quad .TOC.@tocbase; \ - .quad 0; \ - .previous; \ - .type GLUE(.,name),@function; \ -GLUE(.,name): -#define DOTSYM (a) GLUE(.,a)#endif
@@ -279,13 +258,22 @@ n:#define _GLOBAL_TOC (name) _GLOBAL(name) -#define _KPROBE (n) \ - .section ".kprobes.text","a"; \ - .globl n; \ -n: -#endif +/* +* __kprobes (the C annotation) puts the symbol into the .kprobes.text +* section, which gets emitted at the end of regular text. +* +* _ASM_NOKPROBE_SYMBOL and NOKPROBE_SYMBOL just adds the symbol to +* a blacklist. The former is for core kprobe functions/data, the +* latter is for those that incdentially must be excluded from probing +* and allows them to be linked at more optimal location within text. +*/ +#define _ASM_NOKPROBE_SYMBOL (entry) \ + .pushsection "_kprobe_blacklist","aw"; \ + PPC_LONG (entry) ; \ + .popsection +/* * LOAD_REG_IMMEDIATE(rn, expr) * Loads the value of the constant expression 'expr' into register 'rn'
arch/powerpc/kernel/misc_32.S +3 -1
@@ -345,7 +345,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_UNIFIED_ID * * flush_icache_range(unsigned long start, unsigned long stop) */ -_KPROBE(flush_icache_range) +_GLOBAL(flush_icache_range) BEGIN_FTR_SECTION PURGE_PREFETCHED_INS blr /* for 601, do nothing */
@@ -376,6 +376,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_I sync /* additional sync needed on g4 */ isync blr +_ASM_NOKPROBE_SYMBOL(flush_icache_range) + /* * Write any modified data cache blocks out to memory. * Does not invalidate the corresponding cache lines (especially for
arch/powerpc/kernel/misc_64.S +3 -2
@@ -65,7 +65,7 @@ PPC64_CACHES: * flush all bytes from start through stop-1 inclusive */ -_KPROBE(flush_icache_range) +_GLOBAL(flush_icache_range) BEGIN_FTR_SECTION PURGE_PREFETCHED_INS blr
@@ -108,7 +108,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_I bdnz 2b isync blr - .previous .text +_ASM_NOKPROBE_SYMBOL(flush_icache_range) + /* * Like above, but only do the D-cache. *
PATCH 125/178 powerpc/64: Fix flush_(d|i)cache_range() called from modules
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Oliver O'Halloran <[email protected]>
commit 8f5f525d5b83f7d76a6baf9c4e94d4bf312ea7f6 upstream.
When the kernel is compiled to use 64bit ABIv2 the _GLOBAL() macro does not include a global entry point. A function's global entry point is used when the function is called from a different TOC context and in the kernel this typically means a call from a module into the vmlinux (or vice-versa).
There are a few exported asm functions declared with _GLOBAL() and calling them from a module will likely crash the kernel since any TOC relative load will yield garbage.
flush_icache_range() and flush_dcache_range() are both exported to modules, and use the TOC, so must use _GLOBAL_TOC().
--- arch/powerpc/kernel/misc_64.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kernel/misc_64.S +2 -2
@@ -65,7 +65,7 @@ PPC64_CACHES: * flush all bytes from start through stop-1 inclusive */ -_GLOBAL(flush_icache_range) +_GLOBAL_TOC(flush_icache_range) BEGIN_FTR_SECTION PURGE_PREFETCHED_INS blr
@@ -117,7 +117,7 @@ _ASM_NOKPROBE_SYMBOL(flush_icache_range) * * flush all bytes from start to stop-1 inclusive */ -_GLOBAL(flush_dcache_range) +_GLOBAL_TOC(flush_dcache_range) /* * Flush the data cache to memory
PATCH 126/178 crypto: caam - fix RNG deinstantiation error checking
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Horia Geantă <[email protected]>
commit 40c98cb57cdbc377456116ad4582c89e329721b0 upstream.
RNG instantiation was previously fixed by
commit 62743a4145bb9 ("crypto: caam - fix RNG init descriptor ret. code checking") while deinstantiation was not addressed.
Since the descriptors used are similar, in the sense that they both end with a JUMP HALT command, checking for errors should be similar too, i.e. status code 7000_0000h should be considered successful.
--- drivers/crypto/caam/ctrl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/caam/ctrl.c +2 -1
@@ -251,7 +251,8 @@ static int deinstantiate_rng(struct devi/* Try to run it through DECO0 */ ret =run_descriptor_deco0 (ctrldev, desc, &status); -if (ret || status) { +if (ret || + (status && status !=JRSTA_SSRC_JUMP_HALT_CC )) {dev_err (ctrldev,"Failed to deinstantiate RNG4 SH%d\n" , sh_idx);
PATCH 127/178 ring-buffer: Fix return value check in test_ringbuffer()
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Wei Yongjun <[email protected]>
commit 62277de758b155dc04b78f195a1cb5208c37b2df upstream.
In case of error, the function kthread_run() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().
--- kernel/trace/ring_buffer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/trace/ring_buffer.c +4 -4
@@ -4899,9 +4899,9 @@ static __init int test_ringbuffer(void) rb_data[cpu].cnt = cpu; rb_threads[cpu] =kthread_create (rb_test, &rb_data[cpu],"rbtester/%d" , cpu); -if (WARN_ON (!rb_threads[cpu])) { +if (WARN_ON (IS_ERR (rb_threads[cpu]))) {pr_cont ("FAILED\n" ); - ret =-1 ; + ret =PTR_ERR (rb_threads[cpu]); goto out_free; }
@@ -4911,9 +4911,9 @@ static __init int test_ringbuffer(void)/* Now create the rb hammer! */ rb_hammer =kthread_run (rb_hammer_test,NULL ,"rbhammer" ); -if (WARN_ON (!rb_hammer)) { +if (WARN_ON (IS_ERR (rb_hammer))) {pr_cont ("FAILED\n" ); - ret =-1 ; + ret =PTR_ERR (rb_hammer); goto out_free; }
PATCH 128/178 metag/usercopy: Drop unused macros
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit ef62a2d81f73d9cddef14bc3d9097a57010d551c upstream.
Metag's lib/usercopy.c has a bunch of copy_from_user macros for larger copies between 5 and 16 bytes which are completely unused. Before fixing zeroing lets drop these macros so there is less to fix.
--- arch/metag/lib/usercopy.c | 113 ---------------------------------------------- 1 file changed, 113 deletions(-)
arch/metag/lib/usercopy.c +0 -113
@@ -651,119 +651,6 @@ EXPORT_SYMBOL(__copy_user);#define __asm_copy_from_user_4 (to, from, ret) \ __asm_copy_from_user_4x_cont(to, from, ret, "", "", "") -#define __asm_copy_from_user_5 (to, from, ret) \ - __asm_copy_from_user_4x_cont(to, from, ret, \ - " GETB D1Ar1,[%1++]\n" \ - "4: SETB [%0++],D1Ar1\n", \ - "5: ADD %2,%2,#1\n" \ - " SETB [%0++],D1Ar1\n", \ - " .long 4b,5b\n") - -#define __asm_copy_from_user_6x_cont (to, from, ret,COPY ,FIXUP ,TENTRY ) \ - __asm_copy_from_user_4x_cont(to, from, ret, \ - " GETW D1Ar1,[%1++]\n" \ - "4: SETW [%0++],D1Ar1\n" COPY, \ - "5: ADD %2,%2,#2\n" \ - " SETW [%0++],D1Ar1\n" FIXUP, \ - " .long 4b,5b\n" TENTRY) - -#define __asm_copy_from_user_6 (to, from, ret) \ - __asm_copy_from_user_6x_cont(to, from, ret, "", "", "") - -#define __asm_copy_from_user_7 (to, from, ret) \ - __asm_copy_from_user_6x_cont(to, from, ret, \ - " GETB D1Ar1,[%1++]\n" \ - "6: SETB [%0++],D1Ar1\n", \ - "7: ADD %2,%2,#1\n" \ - " SETB [%0++],D1Ar1\n", \ - " .long 6b,7b\n") - -#define __asm_copy_from_user_8x_cont (to, from, ret,COPY ,FIXUP ,TENTRY ) \ - __asm_copy_from_user_4x_cont(to, from, ret, \ - " GETD D1Ar1,[%1++]\n" \ - "4: SETD [%0++],D1Ar1\n" COPY, \ - "5: ADD %2,%2,#4\n" \ - " SETD [%0++],D1Ar1\n" FIXUP, \ - " .long 4b,5b\n" TENTRY) - -#define __asm_copy_from_user_8 (to, from, ret) \ - __asm_copy_from_user_8x_cont(to, from, ret, "", "", "") - -#define __asm_copy_from_user_9 (to, from, ret) \ - __asm_copy_from_user_8x_cont(to, from, ret, \ - " GETB D1Ar1,[%1++]\n" \ - "6: SETB [%0++],D1Ar1\n", \ - "7: ADD %2,%2,#1\n" \ - " SETB [%0++],D1Ar1\n", \ - " .long 6b,7b\n") - -#define __asm_copy_from_user_10x_cont (to, from, ret,COPY ,FIXUP ,TENTRY ) \ - __asm_copy_from_user_8x_cont(to, from, ret, \ - " GETW D1Ar1,[%1++]\n" \ - "6: SETW [%0++],D1Ar1\n" COPY, \ - "7: ADD %2,%2,#2\n" \ - " SETW [%0++],D1Ar1\n" FIXUP, \ - " .long 6b,7b\n" TENTRY) - -#define __asm_copy_from_user_10 (to, from, ret) \ - __asm_copy_from_user_10x_cont(to, from, ret, "", "", "") - -#define __asm_copy_from_user_11 (to, from, ret) \ - __asm_copy_from_user_10x_cont(to, from, ret, \ - " GETB D1Ar1,[%1++]\n" \ - "8: SETB [%0++],D1Ar1\n", \ - "9: ADD %2,%2,#1\n" \ - " SETB [%0++],D1Ar1\n", \ - " .long 8b,9b\n") - -#define __asm_copy_from_user_12x_cont (to, from, ret,COPY ,FIXUP ,TENTRY ) \ - __asm_copy_from_user_8x_cont(to, from, ret, \ - " GETD D1Ar1,[%1++]\n" \ - "6: SETD [%0++],D1Ar1\n" COPY, \ - "7: ADD %2,%2,#4\n" \ - " SETD [%0++],D1Ar1\n" FIXUP, \ - " .long 6b,7b\n" TENTRY) - -#define __asm_copy_from_user_12 (to, from, ret) \ - __asm_copy_from_user_12x_cont(to, from, ret, "", "", "") - -#define __asm_copy_from_user_13 (to, from, ret) \ - __asm_copy_from_user_12x_cont(to, from, ret, \ - " GETB D1Ar1,[%1++]\n" \ - "8: SETB [%0++],D1Ar1\n", \ - "9: ADD %2,%2,#1\n" \ - " SETB [%0++],D1Ar1\n", \ - " .long 8b,9b\n") - -#define __asm_copy_from_user_14x_cont (to, from, ret,COPY ,FIXUP ,TENTRY ) \ - __asm_copy_from_user_12x_cont(to, from, ret, \ - " GETW D1Ar1,[%1++]\n" \ - "8: SETW [%0++],D1Ar1\n" COPY, \ - "9: ADD %2,%2,#2\n" \ - " SETW [%0++],D1Ar1\n" FIXUP, \ - " .long 8b,9b\n" TENTRY) - -#define __asm_copy_from_user_14 (to, from, ret) \ - __asm_copy_from_user_14x_cont(to, from, ret, "", "", "") - -#define __asm_copy_from_user_15 (to, from, ret) \ - __asm_copy_from_user_14x_cont(to, from, ret, \ - " GETB D1Ar1,[%1++]\n" \ - "10: SETB [%0++],D1Ar1\n", \ - "11: ADD %2,%2,#1\n" \ - " SETB [%0++],D1Ar1\n", \ - " .long 10b,11b\n") - -#define __asm_copy_from_user_16x_cont (to, from, ret,COPY ,FIXUP ,TENTRY ) \ - __asm_copy_from_user_12x_cont(to, from, ret, \ - " GETD D1Ar1,[%1++]\n" \ - "8: SETD [%0++],D1Ar1\n" COPY, \ - "9: ADD %2,%2,#4\n" \ - " SETD [%0++],D1Ar1\n" FIXUP, \ - " .long 8b,9b\n" TENTRY) - -#define __asm_copy_from_user_16 (to, from, ret) \ - __asm_copy_from_user_16x_cont(to, from, ret, "", "", "")#define __asm_copy_from_user_8x64 (to, from, ret) \ asm volatile ( \
PATCH 129/178 metag/usercopy: Fix alignment error checking
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit 2257211942bbbf6c798ab70b487d7e62f7835a1a upstream.
Fix the error checking of the alignment adjustment code in raw_copy_from_user(), which mistakenly considers it safe to skip the error check when aligning the source buffer on a 2 or 4 byte boundary.
If the destination buffer was unaligned it may have started to copy using byte or word accesses, which could well be at the start of a new (valid) source page. This would result in it appearing to have copied 1 or 2 bytes at the end of the first (invalid) page rather than none at all.
--- arch/metag/lib/usercopy.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
arch/metag/lib/usercopy.c +4 -6
@@ -717,6 +717,8 @@ unsigned long __copy_user_zeroing(void *if ((unsigned long ) src &1 ) {__asm_copy_from_user_1 (dst, src, retn); n--; +if (retn) + goto copy_exception_bytes; }if ((unsigned long ) dst &1 ) {/* Worst case - byte copy */
@@ -730,6 +732,8 @@ unsigned long __copy_user_zeroing(void *if (((unsigned long ) src &2 ) && n >=2 ) {__asm_copy_from_user_2 (dst, src, retn); n -=2 ; +if (retn) + goto copy_exception_bytes; }if ((unsigned long ) dst &2 ) {/* Second worst case - word copy */
@@ -741,12 +745,6 @@ unsigned long __copy_user_zeroing(void * } } -/* We only need one check after the unalignment-adjustments, -because if both adjustments were done, either both or -neither reference had an exception. */ -if (retn !=0 ) - goto copy_exception_bytes; -#ifdef USE_RAPF /* 64 bit copy loop */ if (!(((unsigned long ) src | (unsigned long ) dst) &7 )) {
PATCH 130/178 metag/usercopy: Add early abort to copy_to_user
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit fb8ea062a8f2e85256e13f55696c5c5f0dfdcc8b upstream.
When copying to userland on Meta, if any faults are encountered immediately abort the copy instead of continuing on and repeatedly faulting, and worse potentially copying further bytes successfully to subsequent valid pages.
--- arch/metag/lib/usercopy.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
arch/metag/lib/usercopy.c +20 -0
@@ -538,23 +538,31 @@ unsigned long __copy_user(void __user *pif ((unsigned long ) src &1 ) {__asm_copy_to_user_1 (dst, src, retn); n--; +if (retn) +return retn + n; }if ((unsigned long ) dst &1 ) {/* Worst case - byte copy */ while (n >0 ) {__asm_copy_to_user_1 (dst, src, retn); n--; +if (retn) +return retn + n; } }if (((unsigned long ) src &2 ) && n >=2 ) {__asm_copy_to_user_2 (dst, src, retn); n -=2 ; +if (retn) +return retn + n; }if ((unsigned long ) dst &2 ) {/* Second worst case - word copy */ while (n >=2 ) {__asm_copy_to_user_2 (dst, src, retn); n -=2 ; +if (retn) +return retn + n; } }
@@ -569,6 +577,8 @@ unsigned long __copy_user(void __user *pwhile (n >=8 ) {__asm_copy_to_user_8x64 (dst, src, retn); n -=8 ; +if (retn) +return retn + n; } }if (n >=RAPF_MIN_BUF_SIZE ) {
@@ -581,6 +591,8 @@ unsigned long __copy_user(void __user *pwhile (n >=8 ) {__asm_copy_to_user_8x64 (dst, src, retn); n -=8 ; +if (retn) +return retn + n; } }#endif
@@ -588,11 +600,15 @@ unsigned long __copy_user(void __user *pwhile (n >=16 ) {__asm_copy_to_user_16 (dst, src, retn); n -=16 ; +if (retn) +return retn + n; }while (n >=4 ) {__asm_copy_to_user_4 (dst, src, retn); n -=4 ; +if (retn) +return retn + n; }switch (n) {
@@ -609,6 +625,10 @@ unsigned long __copy_user(void __user *pbreak ; } +/* +* If we get here, retn correctly reflects the number of failing +* bytes. +*/ return retn; }EXPORT_SYMBOL (__copy_user);
PATCH 131/178 metag/usercopy: Zero rest of buffer from copy_from_user
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit 563ddc1076109f2b3f88e6d355eab7b6fd4662cb upstream.
Currently we try to zero the destination for a failed read from userland in fixup code in the usercopy.c macros. The rest of the destination buffer is then zeroed from __copy_user_zeroing(), which is used for both copy_from_user() and __copy_from_user().
Unfortunately we fail to zero in the fixup code as D1Ar1 is set to 0 before the fixup code entry labels, and __copy_from_user() shouldn't even be zeroing the rest of the buffer.
Move the zeroing out into copy_from_user() and rename __copy_user_zeroing() to raw_copy_from_user() since it no longer does any zeroing. This also conveniently matches the name needed for RAW_COPY_USER support in a later patch.
--- arch/metag/include/asm/uaccess.h | 15 ++++++----- arch/metag/lib/usercopy.c | 57 +++++++++++++--------------------------- 2 files changed, 26 insertions(+), 46 deletions(-)
arch/metag/include/asm/uaccess.h +8 -7
@@ -192,20 +192,21 @@ extern long __must_check strnlen_user(co#define strlen_user (str) strnlen_user(str, 32767) -extern unsigned long __must_check __copy_user_zeroing (void *to, -const void __user *from, -unsigned long n); +extern unsigned long raw_copy_from_user (void *to,const void __user *from, +unsigned long n);static inline unsigned long copy_from_user (void *to,const void __user *from,unsigned long n) { +unsigned long res = n;if (likely (access_ok (VERIFY_READ , from, n))) -return __copy_user_zeroing (to, from, n); -memset (to,0 , n); -return n; + res =raw_copy_from_user (to, from, n); +if (unlikely (res)) +memset (to + (n - res),0 , res); +return res; } -#define __copy_from_user (to, from, n) __copy_user_zeroing(to, from, n) +#define __copy_from_user (to, from, n) raw_copy_from_user(to, from, n)#define __copy_from_user_inatomic __copy_from_user extern unsigned long __must_check __copy_user(void __user *to,
arch/metag/lib/usercopy.c +18 -39
154 lines not on this page · raw message
PATCH 132/178 metag/usercopy: Set flags before ADDZ
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit fd40eee1290ad7add7aa665e3ce6b0f9fe9734b4 upstream.
The fixup code for the copy_to_user rapf loops reads TXStatus.LSM_STEP to decide how far to rewind the source pointer. There is a special case for the last execution of an MGETL/MGETD, since it leaves LSM_STEP=0 even though the number of MGETLs/MGETDs attempted was 4. This uses ADDZ which is conditional upon the Z condition flag, but the AND instruction which masked the TXStatus.LSM_STEP field didn't set the condition flags based on the result.
Fix that now by using ANDS which does set the flags, and also marking the condition codes as clobbered by the inline assembly.
--- arch/metag/lib/usercopy.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/metag/lib/usercopy.c +4 -4
@@ -315,7 +315,7 @@ " .previous\n" \ : "=r" (to), "=r" (from), "=r" (ret), "=d" (n) \ : "0" (to), "1" (from), "2" (ret), "3" (n) \ -: " D1Ar1", " D0Ar2", " memory") +: " D1Ar1", " D0Ar2", " cc", " memory") /* rewind 'to' and 'from' pointers when a fault occurs *
@@ -341,7 +341,7 @@#define __asm_copy_to_user_64bit_rapf_loop (to, from, ret, n, id)\ __asm_copy_user_64bit_rapf_loop(to, from, ret, n, id, \ "LSR D0Ar2, D0Ar2, #8\n" \ - "AND D0Ar2, D0Ar2, #0x7\n" \ + "ANDS D0Ar2, D0Ar2, #0x7\n" \ "ADDZ D0Ar2, D0Ar2, #4\n" \ "SUB D0Ar2, D0Ar2, #1\n" \ "MOV D1Ar1, #4\n" \
@@ -486,7 +486,7 @@ " .previous\n" \ : "=r" (to), "=r" (from), "=r" (ret), "=d" (n) \ : "0" (to), "1" (from), "2" (ret), "3" (n) \ -: " D1Ar1", " D0Ar2", " memory") +: " D1Ar1", " D0Ar2", " cc", " memory") /* rewind 'to' and 'from' pointers when a fault occurs *
@@ -512,7 +512,7 @@#define __asm_copy_to_user_32bit_rapf_loop (to, from, ret, n, id)\ __asm_copy_user_32bit_rapf_loop(to, from, ret, n, id, \ "LSR D0Ar2, D0Ar2, #8\n" \ - "AND D0Ar2, D0Ar2, #0x7\n" \ + "ANDS D0Ar2, D0Ar2, #0x7\n" \ "ADDZ D0Ar2, D0Ar2, #4\n" \ "SUB D0Ar2, D0Ar2, #1\n" \ "MOV D1Ar1, #4\n" \
PATCH 133/178 metag/usercopy: Fix src fixup in from user rapf loops
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit 2c0b1df88b987a12d95ea1d6beaf01894f3cc725 upstream.
The fixup code to rewind the source pointer in __asm_copy_from_user_{32,64}bit_rapf_loop() always rewound the source by a single unit (4 or 8 bytes), however this is insufficient if the fault didn't occur on the first load in the loop, as the source pointer will have been incremented but nothing will have been stored until all 4 register [pairs] are loaded.
Read the LSM_STEP field of TXSTATUS (which is already loaded into a register), a bit like the copy_to_user versions, to determine how many iterations of MGET[DL] have taken place, all of which need rewinding.
--- arch/metag/lib/usercopy.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-)
arch/metag/lib/usercopy.c +28 -8
@@ -687,29 +687,49 @@ EXPORT_SYMBOL(__copy_user);* * Rationale: * A fault occurs while reading from user buffer, which is the -* source. Since the fault is at a single address, we only -* need to rewind by 8 bytes. +* source. * Since we don't write to kernel buffer until we read first, * the kernel buffer is at the right state and needn't be -* corrected. +* corrected, but the source must be rewound to the beginning of +* the block, which is LSM_STEP*8 bytes. +* LSM_STEP is bits 10:8 in TXSTATUS which is already read +* and stored in D0Ar2 +* +* NOTE: If a fault occurs at the last operation in M{G,S}ETL +* LSM_STEP will be 0. ie: we do 4 writes in our case, if +* a fault happens at the 4th write, LSM_STEP will be 0 +* instead of 4. The code copes with that. */ #define __asm_copy_from_user_64bit_rapf_loop (to, from, ret, n, id) \ __asm_copy_user_64bit_rapf_loop(to, from, ret, n, id, \ - "SUB %1, %1, #8\n") + "LSR D0Ar2, D0Ar2, #5\n" \ + "ANDS D0Ar2, D0Ar2, #0x38\n" \ + "ADDZ D0Ar2, D0Ar2, #32\n" \ + "SUB %1, %1, D0Ar2\n")/* rewind 'from' pointer when a fault occurs * * Rationale: * A fault occurs while reading from user buffer, which is the -* source. Since the fault is at a single address, we only -* need to rewind by 4 bytes. +* source. * Since we don't write to kernel buffer until we read first, * the kernel buffer is at the right state and needn't be -* corrected. +* corrected, but the source must be rewound to the beginning of +* the block, which is LSM_STEP*4 bytes. +* LSM_STEP is bits 10:8 in TXSTATUS which is already read +* and stored in D0Ar2 +* +* NOTE: If a fault occurs at the last operation in M{G,S}ETL +* LSM_STEP will be 0. ie: we do 4 writes in our case, if +* a fault happens at the 4th write, LSM_STEP will be 0 +* instead of 4. The code copes with that. */ #define __asm_copy_from_user_32bit_rapf_loop (to, from, ret, n, id) \ __asm_copy_user_32bit_rapf_loop(to, from, ret, n, id, \ - "SUB %1, %1, #4\n") + "LSR D0Ar2, D0Ar2, #6\n" \ + "ANDS D0Ar2, D0Ar2, #0x1c\n" \ + "ADDZ D0Ar2, D0Ar2, #16\n" \ + "SUB %1, %1, D0Ar2\n")/*
PATCH 134/178 metag/usercopy: Add missing fixups
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit b884a190afcecdbef34ca508ea5ee88bb7c77861 upstream.
The rapf copy loops in the Meta usercopy code is missing some extable entries for HTP cores with unaligned access checking enabled, where faults occur on the instruction immediately after the faulting access.
Add the fixup labels and extable entries for these cases so that corner case user copy failures don't cause kernel crashes.
--- arch/metag/lib/usercopy.c | 72 +++++++++++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 24 deletions(-)
arch/metag/lib/usercopy.c +48 -24
@@ -259,27 +259,31 @@"MGETL D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \"22:\n" \"MSETL [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ -"SUB %3, %3, #32\n" \"23:\n" \ -"MGETL D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ +"SUB %3, %3, #32\n" \"24:\n" \ +"MGETL D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ +"25:\n" \"MSETL [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ +"26:\n" \"SUB %3, %3, #32\n" \"DCACHE [%1+#-64], D0Ar6\n" \"BR $Lloop" id"\n" \ \"MOV RAPF, %1\n" \ -"25:\n" \ +"27:\n" \"MGETL D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ -"26:\n" \ +"28:\n" \"MSETL [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ +"29:\n" \"SUB %3, %3, #32\n" \ -"27:\n" \ +"30:\n" \"MGETL D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ -"28:\n" \ +"31:\n" \"MSETL [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ +"32:\n" \"SUB %0, %0, #8\n" \ -"29:\n" \ +"33:\n" \"SETL [%0++], D0.7, D1.7\n" \"SUB %3, %3, #32\n" \"1:" \
@@ -311,7 +315,11 @@ " .long 26b,3b\n" \ " .long 27b,3b\n" \ " .long 28b,3b\n" \ - " .long 29b,4b\n" \ + " .long 29b,3b\n" \ + " .long 30b,3b\n" \ + " .long 31b,3b\n" \ + " .long 32b,3b\n" \ + " .long 33b,4b\n" \ " .previous\n" \ : "=r" (to), "=r" (from), "=r" (ret), "=d" (n) \ : "0" (to), "1" (from), "2" (ret), "3" (n) \
@@ -402,47 +410,55 @@"MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \"22:\n" \"MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ -"SUB %3, %3, #16\n" \"23:\n" \ -"MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ -"24:\n" \ -"MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \"SUB %3, %3, #16\n" \ -"25:\n" \ +"24:\n" \"MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ -"26:\n" \ +"25:\n" \"MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ +"26:\n" \"SUB %3, %3, #16\n" \"27:\n" \"MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \"28:\n" \"MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ +"29:\n" \ +"SUB %3, %3, #16\n" \ +"30:\n" \ +"MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ +"31:\n" \ +"MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ +"32:\n" \"SUB %3, %3, #16\n" \"DCACHE [%1+#-64], D0Ar6\n" \"BR $Lloop" id"\n" \ \"MOV RAPF, %1\n" \ -"29:\n" \ +"33:\n" \"MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ -"30:\n" \ +"34:\n" \"MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ +"35:\n" \"SUB %3, %3, #16\n" \ -"31:\n" \ +"36:\n" \"MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ -"32:\n" \ +"37:\n" \"MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ +"38:\n" \"SUB %3, %3, #16\n" \ -"33:\n" \ +"39:\n" \"MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ -"34:\n" \ +"40:\n" \"MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ +"41:\n" \"SUB %3, %3, #16\n" \ -"35:\n" \ +"42:\n" \"MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ -"36:\n" \ +"43:\n" \"MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ +"44:\n" \"SUB %0, %0, #4\n" \ -"37:\n" \ +"45:\n" \"SETD [%0++], D0.7\n" \"SUB %3, %3, #16\n" \"1:" \
@@ -482,7 +498,15 @@ " .long 34b,3b\n" \ " .long 35b,3b\n" \ " .long 36b,3b\n" \ - " .long 37b,4b\n" \ + " .long 37b,3b\n" \ + " .long 38b,3b\n" \ + " .long 39b,3b\n" \ + " .long 40b,3b\n" \ + " .long 41b,3b\n" \ + " .long 42b,3b\n" \ + " .long 43b,3b\n" \ + " .long 44b,3b\n" \ + " .long 45b,4b\n" \ " .previous\n" \ : "=r" (to), "=r" (from), "=r" (ret), "=d" (n) \ : "0" (to), "1" (from), "2" (ret), "3" (n) \
PATCH 135/178 CIFS: Handle mismatched open calls
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Shilovsky <[email protected]>
commit 38bd49064a1ecb67baad33598e3d824448ab11ec upstream.
A signal can interrupt a SendReceive call which result in incoming responses to the call being ignored. This is a problem for calls such as open which results in the successful response being ignored. This results in an open file resource on the server.
The patch looks into responses which were cancelled after being sent and in case of successful open closes the open fids.
For this patch, the check is only done in SendReceive2()
RH-bz: 1403319
---
fs/cifs/cifsglob.h +11 -0
@@ -223,6 +223,7 @@ struct smb_version_operations {/* verify the message */ int (*check_message)(char *,unsigned int );bool (*is_oplock_break)(char *,struct TCP_Server_Info *); +int (*handle_cancelled_mid)(char *,struct TCP_Server_Info *);void (*downgrade_oplock)(struct TCP_Server_Info *,struct cifsInodeInfo *,bool );/* process transaction2 response */
@@ -1246,12 +1247,19 @@ struct mid_q_entry {void *callback_data;/* general purpose pointer for callback */ void *resp_buf;/* pointer to received SMB header */ int mid_state;/* wish this were enum but can not pass to wait_event */ +unsigned int mid_flags;__le16 command;/* smb command code */ bool large_buf:1; /* if valid response, is pointer to large buf */ bool multiRsp:1; /* multiple trans2 responses for one request */ bool multiEnd:1; /* both received */ }; +struct close_cancelled_open { +struct cifs_fid fid; +struct cifs_tcon *tcon; +struct work_struct work; +}; +/* Make code in transport.c a little cleaner by moving update of optional stats into function below */ #ifdef CONFIG_CIFS_STATS2
@@ -1383,6 +1391,9 @@ static inline void free_dfs_info_array(s#define MID_RESPONSE_MALFORMED 0x10#define MID_SHUTDOWN 0x20 +/* Flags */ +#define MID_WAIT_CANCELLED 1/* Cancelled while waiting for response */ +/* Types of response buffer returned from SendReceive2 */ #define CIFS_NO_BUFFER 0/* Response buffer not returned */ #define CIFS_SMALL_BUFFER 1
fs/cifs/cifssmb.c +4 -0
@@ -1427,6 +1427,8 @@ cifs_readv_discard(struct TCP_Server_Inf length =discard_remaining_data (server);dequeue_mid (mid, rdata->result); + mid->resp_buf = server->smallbuf; + server->smallbuf =NULL ;return length; }
@@ -1542,6 +1544,8 @@ cifs_readv_receive(struct TCP_Server_Infreturn cifs_readv_discard (server, mid);dequeue_mid (mid, false); + mid->resp_buf = server->smallbuf; + server->smallbuf =NULL ;return length; }
fs/cifs/connect.c +11 -2
@@ -911,10 +911,19 @@ cifs_demultiplex_thread(void *p) server->lstrp = jiffies;if (mid_entry !=NULL ) { +if ((mid_entry->mid_flags &MID_WAIT_CANCELLED ) && + mid_entry->mid_state ==MID_RESPONSE_RECEIVED && + server->ops->handle_cancelled_mid) + server->ops->handle_cancelled_mid ( + mid_entry->resp_buf, + server); +if (!mid_entry->multiRsp || mid_entry->multiEnd) mid_entry->callback (mid_entry); - }else if (!server->ops->is_oplock_break || - !server->ops->is_oplock_break (buf, server)) { + }else if (server->ops->is_oplock_break && + server->ops->is_oplock_break (buf, server)) { +cifs_dbg (FYI ,"Received oplock break\n" ); + }else {cifs_dbg (VFS ,"No task to wake, unknown frame received! NumMids %d\n" ,atomic_read (&midCount)); cifs_dump_mem("Received Data is: ", buf,
fs/cifs/smb2misc.c +44 -0
47 lines not on this page · raw message
fs/cifs/smb2ops.c +3 -0
@@ -1163,6 +1163,7 @@ struct smb_version_operations smb20_oper .clear_stats = smb2_clear_stats, .print_stats = smb2_print_stats, .is_oplock_break = smb2_is_valid_oplock_break, + .handle_cancelled_mid = smb2_handle_cancelled_mid, .downgrade_oplock = smb2_downgrade_oplock, .need_neg = smb2_need_neg, .negotiate = smb2_negotiate,
@@ -1239,6 +1240,7 @@ struct smb_version_operations smb21_oper .clear_stats = smb2_clear_stats, .print_stats = smb2_print_stats, .is_oplock_break = smb2_is_valid_oplock_break, + .handle_cancelled_mid = smb2_handle_cancelled_mid, .downgrade_oplock = smb2_downgrade_oplock, .need_neg = smb2_need_neg, .negotiate = smb2_negotiate,
@@ -1316,6 +1318,7 @@ struct smb_version_operations smb30_oper .print_stats = smb2_print_stats, .dump_share_caps = smb2_dump_share_caps, .is_oplock_break = smb2_is_valid_oplock_break, + .handle_cancelled_mid = smb2_handle_cancelled_mid, .downgrade_oplock = smb2_downgrade_oplock, .need_neg = smb2_need_neg, .negotiate = smb2_negotiate,
fs/cifs/smb2proto.h +7 -0
@@ -47,6 +47,10 @@ extern struct mid_q_entry *smb2_setup_re struct smb_rqst *rqst);extern struct mid_q_entry *smb2_setup_async_request (struct TCP_Server_Info *server,struct smb_rqst *rqst); +extern struct cifs_ses *smb2_find_smb_ses (struct TCP_Server_Info *server, +__u64 ses_id); +extern struct cifs_tcon *smb2_find_smb_tcon (struct TCP_Server_Info *server, +__u64 ses_id,__u32 tid);extern int smb2_calc_signature (struct smb_rqst *rqst,struct TCP_Server_Info *server); extern int smb3_calc_signature(struct smb_rqst *rqst,
@@ -151,6 +155,9 @@ extern int SMB2_set_compression(const unextern int SMB2_oplock_break (const unsigned int xid,struct cifs_tcon *tcon,const u64 persistent_fid,const u64 volatile_fid,const __u8 oplock_level); +extern int smb2_handle_cancelled_mid (char *buffer, +struct TCP_Server_Info *server); +void smb2_cancelled_close_fid (struct work_struct *work);extern int SMB2_QFS_info (const unsigned int xid,struct cifs_tcon *tcon,u64 persistent_file_id,u64 volatile_file_id,struct kstatfs *FSData);
fs/cifs/smb2transport.c +52 -6
88 lines not on this page · raw message
fs/cifs/transport.c +2 -0
@@ -773,9 +773,11 @@ SendReceive2(const unsigned int xid, str rc =wait_for_response (ses->server, midQ);if (rc !=0 ) { +cifs_dbg (FYI ,"Cancelling wait for mid %llu\n" , midQ->mid);send_cancel (ses->server, buf, midQ);spin_lock (&GlobalMid_Lock);if (midQ->mid_state ==MID_REQUEST_SUBMITTED ) { + midQ->mid_flags |=MID_WAIT_CANCELLED ; midQ->callback = DeleteMidQEntry;spin_unlock (&GlobalMid_Lock);cifs_small_buf_release (buf);
PATCH 136/178 Reset TreeId to zero on SMB2 TREE_CONNECT
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jan-Marek Glogowski <[email protected]>
commit 806a28efe9b78ffae5e2757e1ee924b8e50c08ab upstream.
Currently the cifs module breaks the CIFS specs on reconnect as described in http://msdn.microsoft.com/en-us/library/cc246529.aspx:
"TreeId (4 bytes): Uniquely identifies the tree connect for the command. This MUST be 0 for the SMB2 TREE_CONNECT Request."
--- fs/cifs/smb2pdu.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/cifs/smb2pdu.c +4 -0
@@ -857,6 +857,10 @@ SMB2_tcon(const unsigned int xid, structreturn -EINVAL ; } +/* SMB2 TREE_CONNECT request must be called with TreeId == 0 */ +if (tcon) + tcon->tid =0 ; + rc =small_smb2_init (SMB2_TREE_CONNECT , tcon, (void **) &req);if (rc) {kfree (unc_path);
PATCH 137/178 virtio_console: fix uninitialized variable use
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Michael S. Tsirkin" <[email protected]>
commit 2055997f983c6db7b5c3940ce5f8f822657d5bc3 upstream.
We try to disable callbacks on c_ivq even without multiport even though that vq is not initialized in this configuration.
--- drivers/char/virtio_console.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/char/virtio_console.c +4 -2
@@ -2180,14 +2180,16 @@ static int virtcons_freeze(struct virtio vdev->config->reset (vdev); -virtqueue_disable_cb (portdev->c_ivq); +if (use_multiport (portdev)) +virtqueue_disable_cb (portdev->c_ivq);cancel_work_sync (&portdev->control_work);cancel_work_sync (&portdev->config_work);/* * Once more: if control_work_handler() was running, it would * enable the cb as the last step. */ -virtqueue_disable_cb (portdev->c_ivq); +if (use_multiport (portdev)) +virtqueue_disable_cb (portdev->c_ivq);remove_controlq_data (portdev);list_for_each_entry (port, &portdev->ports, list) {
PATCH 138/178 xen, fbfront: fix connecting to backend
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
commit 9121b15b5628b38b4695282dc18c553440e0f79b upstream.
Connecting to the backend isn't working reliably in xen-fbfront: in case XenbusStateInitWait of the backend has been missed the backend transition to XenbusStateConnected will trigger the connected state only without doing the actions required when the backend has connected.
--- drivers/video/fbdev/xen-fbfront.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/fbdev/xen-fbfront.c +2 -2
@@ -644,7 +644,6 @@ static void xenfb_backend_changed(structbreak ;case XenbusStateInitWait: -InitWait:xenbus_switch_state (dev, XenbusStateConnected);break ;
@@ -655,7 +654,8 @@ InitWait:* get Connected twice here. */ if (dev->state != XenbusStateConnected) - goto InitWait;/* no InitWait seen yet, fudge it */ +/* no InitWait seen yet, fudge it */ +xenbus_switch_state (dev, XenbusStateConnected);if (xenbus_scanf (XBT_NIL , info->xbdev->otherend,"request-update" ,"%d" , &val) <0 )
PATCH 139/178 scsi: sr: Sanity check returned mode data
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Martin K. Petersen" <[email protected]>
commit a00a7862513089f17209b732f230922f1942e0b9 upstream.
Kefeng Wang discovered that old versions of the QEMU CD driver would return mangled mode data causing us to walk off the end of the buffer in an attempt to parse it. Sanity check the returned mode sense data.
--- drivers/scsi/sr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/scsi/sr.c +4 -2
@@ -838,6 +838,7 @@ static void get_capabilities(struct scsiunsigned char *buffer;struct scsi_mode_data data;struct scsi_sense_hdr sshdr; +unsigned int ms_len =128 ;int rc, n; static const char *loadmech[] =
@@ -864,10 +865,11 @@ static void get_capabilities(struct scsiscsi_test_unit_ready (cd->device,SR_TIMEOUT ,MAX_RETRIES , &sshdr);/* ask for mode page 0x2a */ - rc =scsi_mode_sense (cd->device,0 ,0x2a , buffer,128 , + rc =scsi_mode_sense (cd->device,0 ,0x2a , buffer, ms_len,SR_TIMEOUT ,3 , &data,NULL ); -if (!scsi_status_is_good (rc)) { +if (!scsi_status_is_good (rc) || data.length > ms_len || + data.header_length + data.block_descriptor_length > data.length) {/* failed, drive doesn't have capabilities mode page */ cd->cdi.speed =1 ; cd->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R |
PATCH 140/178 scsi: sd: Fix capacity calculation with 32-bit sector_t
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Martin K. Petersen" <[email protected]>
commit 7c856152cb92f8eee2df29ef325a1b1f43161aff upstream.
We previously made sure that the reported disk capacity was less than 0xffffffff blocks when the kernel was not compiled with large sector_t support (CONFIG_LBDAF). However, this check assumed that the capacity was reported in units of 512 bytes.
Add a sanity check function to ensure that we only enable disks if the entire reported capacity can be expressed in terms of sector_t.
--- drivers/scsi/sd.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
drivers/scsi/sd.c +18 -2
@@ -1930,6 +1930,22 @@ static void read_capacity_error(struct s#define READ_CAPACITY_RETRIES_ON_RESET 10 +/* +* Ensure that we don't overflow sector_t when CONFIG_LBDAF is not set +* and the reported logical block size is bigger than 512 bytes. Note +* that last_sector is a u64 and therefore logical_to_sectors() is not +* applicable. +*/ +static bool sd_addressable_capacity (u64 lba,unsigned int sector_size) +{ +u64 last_sector = (lba +1ULL ) << (ilog2 (sector_size) -9 ); + +if (sizeof (sector_t) ==4 && last_sector >U32_MAX ) +return false; + +return true; +} +static int read_capacity_16 (struct scsi_disk *sdkp,struct scsi_device *sdp,unsigned char *buffer) {
@@ -1995,7 +2011,7 @@ static int read_capacity_16(struct scsi_return -ENODEV ; } -if ((sizeof (sdkp->capacity) ==4 ) && (lba >=0xffffffffULL )) { +if (!sd_addressable_capacity (lba, sector_size)) {sd_printk (KERN_ERR , sdkp,"Too big for this kernel. Use a " "kernel compiled with support for large block " "devices.\n" );
@@ -2081,7 +2097,7 @@ static int read_capacity_10(struct scsi_return sector_size; } -if ((sizeof (sdkp->capacity) ==4 ) && (lba ==0xffffffff )) { +if (!sd_addressable_capacity (lba, sector_size)) {sd_printk (KERN_ERR , sdkp,"Too big for this kernel. Use a " "kernel compiled with support for large block " "devices.\n" );
PATCH 141/178 ptrace: fix PTRACE_LISTEN race corrupting task->state
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "[email protected]" <[email protected]>
commit 5402e97af667e35e54177af8f6575518bf251d51 upstream.
In PT_SEIZED + LISTEN mode STOP/CONT signals cause a wakeup against __TASK_TRACED. If this races with the ptrace_unfreeze_traced at the end of a PTRACE_LISTEN, this can wake the task /after/ the check against __TASK_TRACED, but before the reset of state to TASK_TRACED. This causes it to instead clobber TASK_WAKING, allowing a subsequent wakeup against TRACED while the task is still on the rq wake_list, corrupting it.
Oleg said:
"The kernel can crash or this can lead to other hard-to-debug problems.
In short, "task->state = TASK_TRACED" in ptrace_unfreeze_traced() assumes that nobody else can wake it up, but PTRACE_LISTEN breaks the contract. Obviusly it is very wrong to manipulate task->state if this task is already running, or WAKING, or it sleeps again"
--- kernel/ptrace.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
kernel/ptrace.c +10 -4
@@ -150,11 +150,17 @@ static void ptrace_unfreeze_traced(strucWARN_ON (!task->ptrace || task->parent != current); +/* +* PTRACE_LISTEN can allow ptrace_trap_notify to wake us up remotely. +* Recheck state under the lock to close this race. +*/ spin_lock_irq (&task->sighand->siglock); -if (__fatal_signal_pending (task)) -wake_up_state (task, __TASK_TRACED); -else - task->state =TASK_TRACED ; +if (task->state == __TASK_TRACED) { +if (__fatal_signal_pending (task)) +wake_up_state (task, __TASK_TRACED); +else + task->state =TASK_TRACED ; + }spin_unlock_irq (&task->sighand->siglock); }
PATCH 142/178 l2tp: don't mask errors in pppol2tp_setsockopt()
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Nault <[email protected]>
commit 364700cf8fd54f54ad08313464105a414e3bccb7 upstream.
pppol2tp_setsockopt() unconditionally overwrites the error value returned by pppol2tp_tunnel_setsockopt() or pppol2tp_session_setsockopt(), thus hiding errors from userspace.
--- net/l2tp/l2tp_ppp.c | 2 -- 1 file changed, 2 deletions(-)
net/l2tp/l2tp_ppp.c +0 -2
@@ -1402,8 +1402,6 @@ static int pppol2tp_setsockopt(struct so }else err =pppol2tp_session_setsockopt (sk, session, optname, val); - err =0 ; - end_put_sess:sock_put (sk); end:
PATCH 143/178 l2tp: don't mask errors in pppol2tp_getsockopt()
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Nault <[email protected]>
commit 321a52a39189d5e4af542f7dcdc07bba4545cf5d upstream.
pppol2tp_getsockopt() doesn't take into account the error code returned by pppol2tp_tunnel_getsockopt() or pppol2tp_session_getsockopt(). If error occurs there, pppol2tp_getsockopt() continues unconditionally and reports erroneous values.
--- net/l2tp/l2tp_ppp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/l2tp/l2tp_ppp.c +6 -1
@@ -1524,8 +1524,13 @@ static int pppol2tp_getsockopt(struct so err =pppol2tp_tunnel_getsockopt (sk, tunnel, optname, &val);sock_put (ps->tunnel_sock); - }else +if (err) + goto end_put_sess; + }else { err =pppol2tp_session_getsockopt (sk, session, optname, &val); +if (err) + goto end_put_sess; + } err = -EFAULT ;if (put_user (len, optlen))
PATCH 144/178 x86/vdso: Ensure vdso32_enabled gets set to valid values only
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Krause <[email protected]>
commit c06989da39cdb10604d572c8c7ea8c8c97f3c483 upstream.
vdso_enabled can be set to arbitrary integer values via the kernel command line 'vdso32=' parameter or via 'sysctl abi.vsyscall32'.
load_vdso32() only maps VDSO if vdso_enabled == 1, but ARCH_DLINFO_IA32 merily checks for vdso_enabled != 0. As a consequence the AT_SYSINFO_EHDR auxiliary vector for the VDSO_ENTRY is emitted with a NULL pointer which causes a segfault when the application tries to use the VDSO.
Restrict the valid arguments on the command line and the sysctl to 0 and 1.
--- arch/x86/vdso/vdso32-setup.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
arch/x86/vdso/vdso32-setup.c +9 -2
@@ -31,8 +31,10 @@ static int __init vdso32_setup(char *s) { vdso32_enabled =simple_strtoul (s,NULL ,0 ); -if (vdso32_enabled >1 ) +if (vdso32_enabled >1 ) {pr_warn ("vdso32 values other than 0 and 1 are no longer allowed; vdso disabled\n" ); + vdso32_enabled =0 ; + }return 1 ; }
@@ -89,13 +91,18 @@ subsys_initcall(sysenter_setup);/* Register vsyscall32 into the ABI table */ #include <linux/sysctl.h> +static const int zero; +static const int one =1 ; +static struct ctl_table abi_table2[] = { { .procname ="vsyscall32" , .data = &vdso32_enabled, .maxlen =sizeof (int ), .mode =0644 , - .proc_handler = proc_dointvec + .proc_handler = proc_dointvec_minmax, + .extra1 = (int *)&zero, + .extra2 = (int *)&one, }, {} };
PATCH 145/178 x86/vdso: Plug race between mapping and ELF header setup
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 6fdc6dd90272ce7e75d744f71535cfbd8d77da81 upstream.
The vsyscall32 sysctl can racy against a concurrent fork when it switches from disabled to enabled:
arch_setup_additional_pages()
if (vdso32_enabled)
--> No mapping
sysctl.vsysscall32()
--> vdso32_enabled = true
create_elf_tables()
ARCH_DLINFO_IA32
if (vdso32_enabled) {
--> Add VDSO entry with NULL pointerMake ARCH_DLINFO_IA32 check whether the VDSO mapping has been set up for the newly forked process or not.
--- arch/x86/include/asm/elf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/elf.h +1 -1
@@ -277,7 +277,7 @@ struct task_struct;#define ARCH_DLINFO_IA32 \ do { \ - if (vdso32_enabled) { \ + if (VDSO_CURRENT_BASE) { \ NEW_AUX_ENT(AT_SYSINFO, VDSO_ENTRY); \ NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_CURRENT_BASE); \ } \
PATCH 146/178 CIFS: remove bad_network_name flag
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Germano Percossi <[email protected]>
commit a0918f1ce6a43ac980b42b300ec443c154970979 upstream.
STATUS_BAD_NETWORK_NAME can be received during node failover, causing the flag to be set and making the reconnect thread always unsuccessful, thereafter.
Once the only place where it is set is removed, the remaining bits are rendered moot.
Removing it does not prevent "mount" from failing when a non existent share is passed.
What happens when the share really ceases to exist while the share is mounted is undefined now as much as it was before.
--- fs/cifs/cifsglob.h | 1 - fs/cifs/smb2pdu.c | 5 ----- 2 files changed, 6 deletions(-)
fs/cifs/cifsglob.h +0 -1
@@ -873,7 +873,6 @@ struct cifs_tcon { bool need_reconnect:1; /* connection reset, tid now invalid */#ifdef CONFIG_CIFS_SMB2 bool print:1; /* set if connection to printer share */ - bool bad_network_name:1; /* set if ret status STATUS_BAD_NETWORK_NAME */__le32 capabilities;__u32 share_flags;__u32 maximal_access;
fs/cifs/smb2pdu.c +0 -5
@@ -843,9 +843,6 @@ SMB2_tcon(const unsigned int xid, structelse return -EIO ; -if (tcon && tcon->bad_network_name) -return -ENOENT ; - unc_path =kmalloc (MAX_SHARENAME_LENGTH *2 ,GFP_KERNEL );if (unc_path ==NULL )return -ENOMEM ;
@@ -939,8 +936,6 @@ tcon_exit: tcon_error_exit:if (rsp->hdr.Status ==STATUS_BAD_NETWORK_NAME ) {cifs_dbg (VFS ,"BAD_NETWORK_NAME: %s\n" , tree); -if (tcon) - tcon->bad_network_name = true; } goto tcon_exit; }
PATCH 147/178 s390/mm: fix CMMA vs KSM vs others
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Christian Borntraeger <[email protected]>
commit a8f60d1fadf7b8b54449fcc9d6b15248917478ba upstream.
On heavy paging with KSM I see guest data corruption. Turns out that KSM will add pages to its tree, where the mapping return true for pte_unused (or might become as such later). KSM will unmap such pages and reinstantiate with different attributes (e.g. write protected or special, e.g. in replace_page or write_protect_page)). This uncovered a bug in our pagetable handling: We must remove the unused flag as soon as an entry becomes present again.
--- arch/s390/include/asm/pgtable.h | 2 ++ 1 file changed, 2 insertions(+)
arch/s390/include/asm/pgtable.h +2 -0
@@ -868,6 +868,8 @@ static inline void set_pte_at(struct mm_ {pgste_t pgste; +if (pte_present (entry)) +pte_val (entry) &= ~_PAGE_UNUSED;if (mm_has_pgste (mm)) { pgste =pgste_get_lock (ptep);pgste_val (pgste) &= ~_PGSTE_GPS_ZERO;
PATCH 148/178 MIPS: KGDB: Use kernel context for sleeping threads
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit 162b270c664dca2e0944308e92f9fcc887151a72 upstream.
KGDB is a kernel debug stub and it can't be used to debug userland as it can only safely access kernel memory.
On MIPS however KGDB has always got the register state of sleeping processes from the userland register context at the beginning of the kernel stack. This is meaningless for kernel threads (which never enter userland), and for user threads it prevents the user seeing what it is doing while in the kernel:
(gdb) info threads
Id Target Id Frame
...
3 Thread 2 (kthreadd) 0x0000000000000000 in ?? () 2 Thread 1 (init) 0x000000007705c4b4 in ?? () 1 Thread -2 (shadowCPU0) 0xffffffff8012524c in arch_kgdb_breakpoint () at arch/mips/kernel/kgdb.c:201
Get the register state instead from the (partial) kernel register context stored in the task's thread_struct for resume() to restore. All threads now correctly appear to be in context_switch():
(gdb) info threads
Id Target Id Frame
...
3 Thread 2 (kthreadd) context_switch (rq=<optimized out>, cookie=..., next=<optimized out>, prev=0x0) at kernel/sched/core.c:2903 2 Thread 1 (init) context_switch (rq=<optimized out>, cookie=..., next=<optimized out>, prev=0x0) at kernel/sched/core.c:2903 1 Thread -2 (shadowCPU0) 0xffffffff8012524c in arch_kgdb_breakpoint () at arch/mips/kernel/kgdb.c:201
Call clobbered registers which aren't saved and exception registers (BadVAddr & Cause) which can't be easily determined without stack unwinding are reported as 0. The PC is taken from the return address, such that the state presented matches that found immediately after returning from resume().
Patchwork: https://patchwork.linux-mips.org/patch/15829/
--- arch/mips/kernel/kgdb.c | 48 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 15 deletions(-)
arch/mips/kernel/kgdb.c +33 -15
@@ -244,9 +244,6 @@ static int compute_signal(int tt)void sleeping_thread_to_gdb_regs (unsigned long *gdb_regs,struct task_struct *p) {int reg; -struct thread_info *ti =task_thread_info (p); -unsigned long ksp = (unsigned long )ti +THREAD_SIZE -32 ; -struct pt_regs *regs = (struct pt_regs *)ksp -1 ;#if (KGDB_GDB_REG_SIZE ==32 )u32 *ptr = (u32 *)gdb_regs;#else
@@ -254,25 +251,46 @@ void sleeping_thread_to_gdb_regs(unsigne#endif for (reg =0 ; reg <16 ; reg++) - *(ptr++) = regs->regs[reg]; + *(ptr++) =0 ;/* S0 - S7 */ -for (reg =16 ; reg <24 ; reg++) - *(ptr++) = regs->regs[reg]; + *(ptr++) = p->thread.reg16; + *(ptr++) = p->thread.reg17; + *(ptr++) = p->thread.reg18; + *(ptr++) = p->thread.reg19; + *(ptr++) = p->thread.reg20; + *(ptr++) = p->thread.reg21; + *(ptr++) = p->thread.reg22; + *(ptr++) = p->thread.reg23;for (reg =24 ; reg <28 ; reg++) *(ptr++) =0 ;/* GP, SP, FP, RA */ -for (reg =28 ; reg <32 ; reg++) - *(ptr++) = regs->regs[reg]; - - *(ptr++) = regs->cp0_status; - *(ptr++) = regs->lo; - *(ptr++) = regs->hi; - *(ptr++) = regs->cp0_badvaddr; - *(ptr++) = regs->cp0_cause; - *(ptr++) = regs->cp0_epc; + *(ptr++) = (long )p; + *(ptr++) = p->thread.reg29; + *(ptr++) = p->thread.reg30; + *(ptr++) = p->thread.reg31; + + *(ptr++) = p->thread.cp0_status; + +/* lo, hi */ + *(ptr++) =0 ; + *(ptr++) =0 ; + +/* +* BadVAddr, Cause +* Ideally these would come from the last exception frame up the stack +* but that requires unwinding, otherwise we can't know much for sure. +*/ + *(ptr++) =0 ; + *(ptr++) =0 ; + +/* +* PC +* use return address (RA), i.e. the moment after return from resume() +*/ + *(ptr++) = p->thread.reg31; }void kgdb_arch_set_pc (struct pt_regs *regs,unsigned long pc)
PATCH 149/178 ALSA: seq: Don't break snd_use_lock_sync() loop by timeout
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 4e7655fd4f47c23e5249ea260dc802f909a64611 upstream.
The snd_use_lock_sync() (thus its implementation snd_use_lock_sync_helper()) has the 5 seconds timeout to break out of the sync loop. It was introduced from the beginning, just to be "safer", in terms of avoiding the stupid bugs.
However, as Ben Hutchings suggested, this timeout rather introduces a potential leak or use-after-free that was apparently fixed by the commit 2d7d54002e39 ("ALSA: seq: Fix race during FIFO resize"):
for example, snd_seq_fifo_event_in() -> snd_seq_event_dup() -> copy_from_user() could block for a long time, and snd_use_lock_sync() goes timeout and still leaves the cell at releasing the pool.
For fixing such a problem, we remove the break by the timeout while still keeping the warning.
--- sound/core/seq/seq_lock.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
sound/core/seq/seq_lock.c +3 -6
@@ -28,19 +28,16 @@/* wait until all locks are released */ void snd_use_lock_sync_helper (snd_use_lock_t *lockp,const char *file,int line) { -int max_count =5 *HZ ; +int warn_count =5 *HZ ;if (atomic_read (lockp) <0 ) {pr_warn ("ALSA: seq_lock: lock trouble [counter = %d] in %s:%d\n" ,atomic_read (lockp), file, line);return ; }while (atomic_read (lockp) >0 ) { -if (max_count ==0 ) { -pr_warn ("ALSA: seq_lock: timeout [%d left] in %s:%d\n" ,atomic_read (lockp), file, line); -break ; - } +if (warn_count-- ==0 ) +pr_warn ("ALSA: seq_lock: waiting [%d left] in %s:%d\n" ,atomic_read (lockp), file, line);schedule_timeout_uninterruptible (1 ); - max_count--; } }
PATCH 150/178 cpupower: Fix turbo frequency reporting for pre-Sandy Bridge cores
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ben Hutchings <[email protected]>
commit 4cca0457686e4ee1677d69469e4ddfd94d389a80 upstream.
The switch that conditionally sets CPUPOWER_CAP_HAS_TURBO_RATIO and CPUPOWER_CAP_IS_SNB flags is missing a break, so all cores get both flags set and an assumed base clock of 100 MHz for turbo values.
References: https://bugs.debian.org/859978
--- tools/power/cpupower/utils/helpers/cpuid.c | 1 + 1 file changed, 1 insertion(+)
tools/power/cpupower/utils/helpers/cpuid.c +1 -0
@@ -156,6 +156,7 @@ out:*/ case 0x2C :/* Westmere EP - Gulftown */ cpu_info->caps |=CPUPOWER_CAP_HAS_TURBO_RATIO ; +break ;case 0x2A :/* SNB */ case 0x2D :/* SNB Xeon */ case 0x3A :/* IVB */
PATCH 151/178 zram: do not use copy_page with non-page aligned address
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Minchan Kim <[email protected]>
commit d72e9a7a93e4f8e9e52491921d99e0c8aa89eb4e upstream.
The copy_page is optimized memcpy for page-alinged address. If it is used with non-page aligned address, it can corrupt memory which means system corruption. With zram, it can happen with
1. 64K architecture
2. partial IO
3. slub debug
Partial IO need to allocate a page and zram allocates it via kmalloc. With slub debug, kmalloc(PAGE_SIZE) doesn't return page-size aligned address. And finally, copy_page(mem, cmem) corrupts memory.
So, this patch changes it to memcpy.
Actuaully, we don't need to change zram_bvec_write part because zsmalloc returns page-aligned address in case of PAGE_SIZE class but it's not good to rely on the internal of zsmalloc.
Note:
When this patch is merged to stable, clear_page should be fixed, too. Unfortunately, recent zram removes it by "same page merge" feature so it's hard to backport this patch to -stable tree.
I will handle it when I receive the mail from stable tree maintainer to merge this patch to backport.
--- drivers/block/zram/zram_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/zram/zram_drv.c +3 -3
@@ -345,13 +345,13 @@ static int zram_decompress_page(struct zif (!handle ||zram_test_flag (meta, index,ZRAM_ZERO )) {read_unlock (&meta->tb_lock); -clear_page (mem); +memset (mem,0 ,PAGE_SIZE );return 0 ; } cmem =zs_map_object (meta->mem_pool, handle,ZS_MM_RO );if (size ==PAGE_SIZE ) -copy_page (mem, cmem); +memcpy (mem, cmem,PAGE_SIZE );else ret =zcomp_decompress (zram->comp, cmem, size, mem);zs_unmap_object (meta->mem_pool, handle);
@@ -501,7 +501,7 @@ static int zram_bvec_write(struct zram *if ((clen ==PAGE_SIZE ) && !is_partial_io (bvec)) { src =kmap_atomic (page); -copy_page (cmem, src); +memcpy (cmem, src,PAGE_SIZE );kunmap_atomic (src); }else {memcpy (cmem, src, clen);
PATCH 152/178 perf/x86: Avoid exposing wrong/stale data in intel_pmu_lbr_read_32()
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <[email protected]>
commit f2200ac311302fcdca6556fd0c5127eab6c65a3e upstream.
When the perf_branch_entry::{in_tx,abort,cycles} fields were added, intel_pmu_lbr_read_32() wasn't updated to initialize them.
[bwh: Backported to 3.16:
- There's no perf_branch_entry::cycles field
- Adjust filename]
---
arch/x86/kernel/cpu/perf_event_intel_lbr.c +2 -0
@@ -268,6 +268,8 @@ static void intel_pmu_lbr_read_32(struct cpuc->lbr_entries[i].to = msr_lastbranch.to; cpuc->lbr_entries[i].mispred =0 ; cpuc->lbr_entries[i].predicted =0 ; + cpuc->lbr_entries[i].in_tx =0 ; + cpuc->lbr_entries[i].abort =0 ; cpuc->lbr_entries[i].reserved =0 ; } cpuc->lbr_stack.nr = i;
PATCH 153/178 ftrace/x86: Fix triple fault with graph tracing and suspend-to-ram
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
commit 34a477e5297cbaa6ecc6e17c042a866e1cbe80d6 upstream.
On x86-32, with CONFIG_FIRMWARE and multiple CPUs, if you enable function graph tracing and then suspend to RAM, it will triple fault and reboot when it resumes.
The first fault happens when booting a secondary CPU:
startup_32_smp()
load_ucode_ap()
prepare_ftrace_return()
ftrace_graph_is_dead()
(accesses 'kill_ftrace_graph')
The early head_32.S code calls into load_ucode_ap(), which has an an ftrace hook, so it calls prepare_ftrace_return(), which calls ftrace_graph_is_dead(), which tries to access the global 'kill_ftrace_graph' variable with a virtual address, causing a fault because the CPU is still in real mode.
The fix is to add a check in prepare_ftrace_return() to make sure it's running in protected mode before continuing. The check makes sure the stack pointer is a virtual kernel address. It's a bit of a hack, but it's not very intrusive and it works well enough.
For reference, here are a few other (more difficult) ways this could have potentially been fixed:
- Move startup_32_smp()'s call to load_ucode_ap() down to *after* paging is enabled. (No idea what that would break.)
- Track down load_ucode_ap()'s entire callee tree and mark all the functions 'notrace'. (Probably not realistic.)
- Pause graph tracing in ftrace_suspend_notifier_call() or bringup_cpu() or __cpu_up(), and ensure that the pause facility can be queried from real mode.
--- arch/x86/kernel/ftrace.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/x86/kernel/ftrace.c +12 -0
@@ -703,6 +703,18 @@ void prepare_ftrace_return(unsigned longunsigned long return_hooker = (unsigned long ) &return_to_handler; +/* +* When resuming from suspend-to-ram, this function can be indirectly +* called from early CPU startup code while the CPU is in real mode, +* which would fail miserably. Make sure the stack pointer is a +* virtual address. +* +* This check isn't as accurate as virt_addr_valid(), but it should be +* good enough for this purpose, and it's fast. +*/ +if (unlikely ((long )__builtin_frame_address (0 ) >=0 )) +return ; +if (unlikely (atomic_read (¤t->tracing_graph_pause)))return ;
PATCH 154/178 p9_client_readdir() fix
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit 71d6ad08379304128e4bdfaf0b4185d54375423e upstream.
Don't assume that server is sane and won't return more data than asked for.
--- net/9p/client.c | 4 ++++ 1 file changed, 4 insertions(+)
net/9p/client.c +4 -0
@@ -2107,6 +2107,10 @@ int p9_client_readdir(struct p9_fid *fidtrace_9p_protocol_dump (clnt, req->rc); goto free_and_error; } +if (rsize < count) { +pr_err ("bogus RREADDIR count (%d > %d)\n" , count, rsize); + count = rsize; + }p9_debug (P9_DEBUG_9P ,"<<< RREADDIR count %d\n" , count);
PATCH 155/178 cifs: Do not send echoes before Negotiate is complete
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sachin Prabhu <[email protected]>
commit 62a6cfddcc0a5313e7da3e8311ba16226fe0ac10 upstream.
commit 4fcd1813e640 ("Fix reconnect to not defer smb3 session reconnect long after socket reconnect") added support for Negotiate requests to be initiated by echo calls.
To avoid delays in calling echo after a reconnect, I added the patch introduced by the commit b8c600120fc8 ("Call echo service immediately after socket reconnect").
This has however caused a regression with cifs shares which do not have support for echo calls to trigger Negotiate requests. On connections which need to call Negotiation, the echo calls trigger an error which triggers a reconnect which in turn triggers another echo call. This results in a loop which is only broken when an operation is performed on the cifs share. For an idle share, it can DOS a server.
The patch uses the smb_operation can_echo() for cifs so that it is called only if connection has been already been setup.
kernel bz: 194531
--- fs/cifs/smb1ops.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/cifs/smb1ops.c +10 -0
@@ -1015,6 +1015,15 @@ cifs_dir_needs_close(struct cifsFileInforeturn !cfile->srch_inf.endOfSearch && !cfile->invalidHandle; } +static bool +cifs_can_echo (struct TCP_Server_Info *server) +{ +if (server->tcpStatus == CifsGood) +return true; + +return false; +} +struct smb_version_operations smb1_operations = { .send_cancel = send_nt_cancel, .compare_fids = cifs_compare_fids,
@@ -1048,6 +1057,7 @@ struct smb_version_operations smb1_opera .get_dfs_refer = CIFSGetDFSRefer, .qfs_tcon = cifs_qfs_tcon, .is_path_accessible = cifs_is_path_accessible, + .can_echo = cifs_can_echo, .query_path_info = cifs_query_path_info, .query_file_info = cifs_query_file_info, .get_srv_inum = cifs_get_srv_inum,
RE: [PATCH 3.16 155/178] cifs: Do not send echoes before Negotiate is complete
2017-07-16 6:57 Ben Hutchings <[email protected]>:
Quoted 19 lines
3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sachin Prabhu <[email protected]>
commit
62a6cfddcc0a5313e7da3e8311ba16226fe0ac10upstream.commit
4fcd1813e640("Fix reconnect to not defer smb3 session reconnect long after socket reconnect") added support for Negotiate requests to be initiated by echo calls.To avoid delays in calling echo after a reconnect, I added the patch introduced by the commit
b8c600120fc8("Call echo service immediately after socket reconnect").This has however caused a regression with cifs shares which do not have support for echo calls to trigger Negotiate requests. On connections which need to call Negotiation, the echo calls trigger an error which triggers a reconnect which in turn triggers another echo call. This results in a loop which is only broken when an operation is performed on the cifs share. For an idle share, it can DOS a server.
The patch uses the
smb_operationcan_echo()for cifs so that it is called only if connection has been already been setup.kernel bz: 194531
Quoted 8 lines
Signed-off-by Sachin Prabhu <[email protected]>Tested-by Jonathan Liu <[email protected]>Acked-by Pavel Shilovsky <[email protected]>Signed-off-by Steve French <[email protected]>Signed-off-by Ben Hutchings <[email protected]>---
fs/cifs/smb1ops.c| 10 ++++++++++1 file changed, 10 insertions(+)
I have just posted a backport of commit b8c600120fc8 ("Call echo service immediately after socket reconnect") for v3.16.x kernel to the stable mailing list. Please consider merging it too.
Best regards,
Pavel Shilovsky
PATCH 156/178 KEYS: Change the name of the dead type to ".dead" to prevent user access
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
commit c1644fe041ebaf6519f6809146a77c3ead9193af upstream.
This fixes CVE-2017-6951.
Userspace should not be able to do things with the "dead" key type as it doesn't have some of the helper functions set upon it that the kernel needs. Attempting to use it may cause the kernel to crash.
Fix this by changing the name of the type to ".dead" so that it's rejected up front on userspace syscalls by key_get_type_from_user().
Though this doesn't seem to affect recent kernels, it does affect older ones, certainly those prior to:
commit c06cfb08b88dfbe13be44a69ae2fdc3a7c902d81 Author: David Howells <[email protected]> Date: Tue Sep 16 17:36:06 2014 +0100 KEYS: Remove key_type::match in favour of overriding default by match_preparse
which went in before 3.18-rc1.
--- security/keys/gc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/keys/gc.c +1 -1
@@ -46,7 +46,7 @@ static unsigned long key_gc_flags;* immediately unlinked. */ struct key_type key_type_dead = { - .name ="dead" , + .name =".dead" , };/*
PATCH 157/178 Input: elantech - add Fujitsu Lifebook E547 to force crc_enabled
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Leemhuis <[email protected]>
commit 704de489e0e3640a2ee2d0daf173e9f7375582ba upstream.
Temporary got a Lifebook E547 into my hands and noticed the touchpad only works after running:
echo "1" > /sys/devices/platform/i8042/serio2/crc_enabled
Add it to the list of machines that need this workaround.
--- drivers/input/mouse/elantech.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/input/mouse/elantech.c +8 -0
@@ -1036,6 +1036,7 @@ static int elantech_get_resolution_v4(st* Asus UX32VD 0x361f02 00, 15, 0e clickpad * Avatar AVIU-145A2 0x361f00 ? clickpad * Fujitsu LIFEBOOK E544 0x470f00 d0, 12, 09 2 hw buttons +* Fujitsu LIFEBOOK E547 0x470f00 50, 12, 09 2 hw buttons * Fujitsu LIFEBOOK E554 0x570f01 40, 14, 0c 2 hw buttons * Gigabyte U2442 0x450f01 58, 17, 0c 2 hw buttons * Lenovo L430 0x350f02 b9, 15, 0c 2 hw buttons (*)
@@ -1396,6 +1397,13 @@ static const struct dmi_system_id elante }, }, { +/* Fujitsu LIFEBOOK E547 does not work with crc_enabled == 0 */ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"FUJITSU" ), + DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E547"), + }, + }, + {/* Fujitsu LIFEBOOK E554 does not work with crc_enabled == 0 */ .matches = { DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
PATCH 158/178 tracing: Allocate the snapshot buffer before enabling probe
In reply to Ben Hutchings3.16.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Steven Rostedt (VMware)" <[email protected]>
commit df62db5be2e5f070ecd1a5ece5945b590ee112e0 upstream.
Currently the snapshot trigger enables the probe and then allocates the snapshot. If the probe triggers before the allocation, it could cause the snapshot to fail and turn tracing off. It's best to allocate the snapshot buffer first, and then enable the trigger. If something goes wrong in the enabling of the trigger, the snapshot buffer is still allocated, but it can also be freed by the user by writting zero into the snapshot buffer file.
Also add a check of the return status of alloc_snapshot().
--- kernel/trace/trace.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
kernel/trace/trace.c +5 -3
@@ -5775,11 +5775,13 @@ ftrace_trace_snapshot_callback(struct ftreturn ret; out_reg: - ret =register_ftrace_function_probe (glob, ops, count); + ret =alloc_snapshot (&global_trace); +if (ret <0 ) + goto out; -if (ret >=0 ) -alloc_snapshot (&global_trace); + ret =register_ftrace_function_probe (glob, ops, count); + out:return ret <0 ? ret :0 ; }