3.16.55-rc1 review
Subsystems (5)
cover 3.16.55-rc1 review
This is the start of the stable review cycle for the 3.16.55 release. There are 254 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 Fri Mar 02 18:00:00 UTC 2018. Anything received after that time might be too late.
All the patches have also been committed to the linux-3.16.y-rc branch of
https://git.kernel.org/pub/scm/linux/kernel/git/bwh/linux-stable-rc.git . A shortlog and diffstat can be found below.
Ben.
-------------
Aaron Ma (2):
Input: elantech - add new icbody type 15
[10d900303f1c3a821eb0bef4e7b7ece16768fba4]
Input: trackpoint - force 3 buttons if 0 button is reported
[f5d07b9e98022d50720e38aa936fc11c67868ece]
Adam Wallis (2):
dmaengine: dmatest: move callback wait queue to thread context
[6f6a23a213be51728502b88741ba6a10cda2441d]
dmaengine: dmatest: warn user when dma test times out
[a9df21e34b422f79d9a9fa5c3eff8c2a53491be6]
Alan Stern (3):
USB: Gadget core: fix inconsistency in the interface tousb_add_gadget_udc_release()
[afd7fd81f22bf90474216515dbd6088f9bd70343]
USB: UDC core: fix double-free in usb_add_gadget_udc_release
[7ae2c3c280db183ca9ada2675c34ec2f7378abfa]
usb: udc: core: add device_del() call to error pathway
[c93e64e91248becd0edb8f01723dff9da890e2ab]
Alexey Kodanev (1):
dccp: don't restart ccid2_hc_tx_rto_expire() if sk in closed state
[dd5684ecae3bd8e44b644f50e2c12c7e57fdfef5]
Andrew Bresticker (1):
mac80211_hwsim: fix compiler warning on MIPS
[5d26b50813ea6206a7bbab2e645e68044f101ac5]
Andrew Honig (1):
KVM: x86: Add memory barrier on vmcs field lookup
[75f139aaf896d6fdeec2e468ddfa4b2fe469bf40]
Anshuman Khandual (1):
mm/mprotect: add a cond_resched() inside change_pmd_range()
[4991c09c7c812dba13ea9be79a68b4565bb1fa4e]
Arnd Bergmann (1):
mmc: s3mci: mark debug_regs[] as static
[2bd7b4aacdb6efa5ccd4749c365c171b884791d2]Bart Van Assche (1):
IB/srpt: Disable RDMA access by the initiator
[bec40c26041de61162f7be9d2ce548c756ce0f65]
Ben Hutchings (3):
ASoC: wm_adsp: Fix validation of firmware and coeff lengths
[50dd2ea8ef67a1617e0c0658bcbec4b9fb03b936]
nfsd: auth: Fix gid sorting when rootsquash enabled
[1995266727fa8143897e89b55f5d3c79aa828420]
of: fdt: Fix return with value in void function
[not upstream; fixes incorrect backport]
Benjamin Herrenschmidt (1):
powerpc: Don't preempt_disable() in show_cpuinfo()
[349524bc0da698ec77f2057cf4a4948eb6349265]
Benjamin Poirier (2):
e1000e: Fix e1000_check_for_copper_link_ich8lan return value.
[4110e02eb45ea447ec6f5459c9934de0a273fb91]
e1000e: Separate signaling for link check/link up
[19110cfbb34d4af0cdfe14cd243f3b09dc95b013]Bin Liu (1):
usb: musb: da8xx: fix babble condition handling
[bd3486ded7a0c313a6575343e6c2b21d14476645]
Chandan Rajendra (1):
ext4: fix crash when a directory's i_size is too small
[9d5afec6b8bd46d6ed821aa1579634437f58ef1f]
Christian Holl (1):
USB: serial: cp210x: add new device ID ELV ALC 8xxx
[d14ac576d10f865970bb1324d337e5e24d79aaf4]Christoph Hellwig (1):
scsi: dma-mapping: always provide dma_get_cache_alignment
[860dd4424f344400b491b212ee4acb3a358ba9d9]
Christoph Paasch (1):
tcp md5sig: Use skb's saddr when replying to an incoming segment
[30791ac41927ebd3e75486f9504b6d2280463bf0]
Christophe JAILLET (1):
mdio-sun4i: Fix a memory leak
[56c0290202ab94a2f2780c449395d4ae8495fab4]
Christophe Leroy (1):
net: fs_enet: do not call phy_stop() in interrupts
[f8b39039cbf2a15f2b8c9f081e1cbd5dee00aaf5]
Colin Ian King (2):
usb: gadget: don't dereference g until after it has been null checked
[b2fc059fa549fe6881d4c1f8d698b0f50bcd16ec]
usb: host: fix incorrect updating of offset
[1d5a31582ef046d3b233f0da1a68ae26519b2f0a]
Cong Wang (1):
8021q: fix a memory leak for VLAN 0 device
[78bbb15f2239bc8e663aa20bbe1987c91a0b75f6]
Daniel Mentz (2):
media: v4l2-compat-ioctl32.c: refactor compat ioctl32 logic
[a1dfb4c48cc1e64eeb7800a27c66a6f7e88d075a]
media: v4l2-compat-ioctl32: Copy v4l2_window->global_alpha
[025a26fa14f8fd55d50ab284a30c016a5be953d0]Daniel Thompson (2):
kdb: Fix handling of kallsyms_symbol_next() return value
[c07d35338081d107e57cf37572d8cc931a8e32e2]
usb: xhci: Add XHCI_TRUST_TX_LENGTH for Renesas uPD720201
[da99706689481717998d1d48edd389f339eea979]
Daniele Palmas (1):
USB: serial: option: add support for Telit ME910 PID 0x1101
[08933099e6404f588f81c2050bfec7313e06eeaf]Dave Martin (2):
arm64: fpsimd: Prevent registers leaking from dead tasks
[071b6d4a5d343046f253a5a8835d477d93992002]
mips/ptrace: Preserve previous registers for short regset write
[d614fd58a2834cfe4efa472c33c8f3ce2338b09b]
David Howells (1):
fscache: Fix the default for fscache_maybe_release_page()
[98801506552593c9b8ac11021b0cdad12cab4f6b]
David Kozub (1):
USB: uas and storage: Add US_FL_BROKEN_FUA for another JMicron JMS567 ID
[62354454625741f0569c2cbe45b2d192f8fd258e]
David Woodhouse (1):
x86/alternatives: Add missing '\n' at end of ALTERNATIVE inline asm
[b9e705ef7cfaf22db0daab91ad3cd33b0fa32eb9]
Dennis Yang (1):
dm thin metadata: THIN_MAX_CONCURRENT_LOCKS should be 6
[490ae017f54e55bde382d45ea24bddfb6d1a0aaf]
Denys Vlasenko (1):
include/stddef.h: Move offsetofend() from vfio.h to a generic kernel header
[3876488444e71238e287459c39d7692b6f718c3e]
Diego Elio Pettenò (1):
USB: serial: cp210x: add IDs for LifeScan OneTouch Verio IQ
[4307413256ac1e09b8f53e8715af3df9e49beec3]Dmitry Fleytman Dmitry Fleytman (1):
usb: Add device quirk for Logitech HD Pro Webcam C925e
[7f038d256c723dd390d2fca942919573995f4cfd]
Dominik Brodowski (1):
nl80211: take RCU read lock when calling ieee80211_bss_get_ie()
[7a94b8c2eee7083ddccd0515830f8c81a8e44b1a]Erez Shitrit (1):
IB/ipoib: Fix race condition in neigh creation
[16ba3defb8bd01a9464ba4820a487f5b196b455b]
Eric Biggers (8):
509: fix printing uninitialized stack memory when OID is empty
[8dfd2f22d3bf3ab7714f7495ad5d897b8845e8c1]
ASN.1: check for error from ASN1_OP_END__ACT actions
[81a7be2cd69b412ab6aeacfe5ebf1bb6e5bce955]
ASN.1: fix out-of-bounds read when parsing indefinite length item
[e0058f3a874ebb48b25be7ff79bc3b4e59929f90]
X.509: fix buffer overflow detection in sprint_oid()
[47e0a208fb9d91e3f3c86309e752b13a36470ae8]
X.509: reject invalid BIT STRING for subjectPublicKey
[0f30cbea005bd3077bd98cd29277d7fc2699c1da]
af_key: fix buffer overread in parse_exthdrs()
[4e765b4972af7b07adcb1feb16e7a525ce1f6b28]
af_key: fix buffer overread in verify_address_len()
[06b335cb51af018d5feeff5dd4fd53847ddb675a]
crypto: algapi - fix NULL dereference in crypto_remove_spawns()
[9a00674213a3f00394f4e3221b88f2d21fc05789]
Eric Dumazet (1):
net/packet: fix a race in packet_bind() and packet_notifier()
[15fe076edea787807a7cdc168df832544b58eba6]
Eryu Guan (1):
ext4: fix fdatasync(2) after fallocate(2) operation
[c894aa97577e47d3066b27b32499ecf899bfa8b0]
Eugenia Emantayev (1):
net/mlx5: Fix misspelling in the error message and comment
[777ec2b2a3f2760505db395de1a9fa4115d74548]
Felix Fietkau (1):
net: igmp: fix source address check for IGMPv3 reports
[ad23b750933ea7bf962678972a286c78a8fa36aa]
Florian Fainelli (1):
net: phy: Add phy_interface_is_rgmii helper
[e463d88c36d42211aa72ed76d32fb8bf37820ef1]
Greg Kroah-Hartman (2):
ACPI: sbshc: remove raw pointer from printk() message
[43cdd1b716b26f6af16da4e145b6578f98798bf6]
efi: Move some sysfs files to be read-only by root
[af97a77bc01ce49a466f9d4c0125479e2e2230b6]
Guennadi Liakhovetski (1):
[media] V4L2: fix VIDIOC_CREATE_BUFS 32-bit compatibility mode data copy-back
[6ed9b28504326f8cf542e6b68245b2f7ce009216]
Guillaume Nault (1):
pppoe: take ->needed_headroom of lower device into account on xmit
[02612bb05e51df8489db5e94d0cf8d1c81f87b0c]H. Nikolaus Schaller (1):
Input: twl6040-vibra - fix DT node memory management
[c52c545ead97fcc2f4f8ea38f1ae3c23211e09a8]
Hans Verkuil (13):
[media] v4l2-compat-ioctl32: fix sparse warnings
[8ae632b11775254c5e555ee8c42b7d19baeb1473]
adv7604: use correct drive strength defines
[not upstream; fixes incorrect backport]
media: v4l2-compat-ioctl32.c: add capabilities field to, v4l2_input32
[037e0865c2ecbaa4558feba239ece08d7e457ec0]
media: v4l2-compat-ioctl32.c: add missing VIDIOC_PREPARE_BUF
[3ee6d040719ae09110e5cdf24d5386abe5d1b776]
media: v4l2-compat-ioctl32.c: avoid sizeof(type)
[333b1e9f96ce05f7498b581509bb30cde03018bf]
media: v4l2-compat-ioctl32.c: copy m.userptr in put_v4l2_plane32
[8ed5a59dcb47a6f76034ee760b36e089f3e82529]
media: v4l2-compat-ioctl32.c: copy clip list in put_v4l2_window32
[a751be5b142ef6bcbbb96d9899516f4d9c8d0ef4]
media: v4l2-compat-ioctl32.c: don't copy back the result for certain errors
[d83a8243aaefe62ace433e4384a4f077bed86acb]
media: v4l2-compat-ioctl32.c: drop pr_info for unknown buffer type
[169f24ca68bf0f247d111aef07af00dd3a02ae88]
media: v4l2-compat-ioctl32.c: fix ctrl_is_pointer
[b8c601e8af2d08f733d74defa8465303391bb930]
media: v4l2-compat-ioctl32.c: fix the indentation
[b7b957d429f601d6d1942122b339474f31191d75]
media: v4l2-compat-ioctl32.c: move 'helper' functions to __get/put_v4l2_format32
[486c521510c44a04cd756a9267e7d1e271c8a4ba]
media: v4l2-ioctl.c: don't copy back the result for -ENOTTY
[181a4a2d5a0a7b43cab08a70710d727e7764ccdd]
Hans de Goede (1):
uas: Always apply US_FL_NO_ATA_1X quirk to Seagate devices
[7fee72d5e8f1e7b8d8212e28291b1a0243ecf2f1]
Heiko Carstens (1):
s390: always save and restore all registers on context switch
[fbbd7f1a51965b50dd12924841da0d478f3da71b]
Heiner Kallweit (1):
eeprom: at24: check at24_read/write arguments
[d9bcd462daf34aebb8de9ad7f76de0198bb5a0f0]
Helge Deller (1):
parisc: Hide Diva-built-in serial aux and graphics card
[bcf3f1752a622f1372d3252d0fea8855d89812e7]
Herbert Xu (5):
ipv4: Avoid reading user iov twice after raw_probe_proto_opt
[c008ba5bdc9fa830e1a349b20b0be5a137bdef7a]
ipv4: Use standard iovec primitive in raw_probe_proto_opt
[32b5913a931fd753faf3d4e1124b2bc2edb364da]
xfrm: Reinject transport-mode packets through tasklet
[acf568ee859f098279eadf551612f103afdacb4e]
xfrm: Return error on unknown encap_type in init_state
[bcfd09f7837f5240c30fd2f52ee7293516641faa]
xfrm: Use __skb_queue_tail in xfrm_trans_queue
[d16b46e4fd8bc6063624605f25b8c0835bb1fbe3]
Huacai Chen (2):
scsi: libsas: align sata_device's rps_resp on a cacheline
[c2e8fbf908afd81ad502b567a6639598f92c9b9d]
scsi: use dma_get_cache_alignment() as minimum DMA alignment
[90addc6b3c9cda0146fbd62a08e234c2b224a80c]
Hui Wang (1):
ALSA: hda - Add MIC_NO_PRESENCE fixup for 2 HP machines
[322f74ede933b3e2cb78768b6a6fdbfbf478a0c1]
Håkon Bugge (1):
rds: Fix NULL pointer dereference in __rds_rdma_map
[f3069c6d33f6ae63a1668737bc78aaaa51bff7ca]
Icenowy Zheng (1):
uas: ignore UAS for Norelsys NS1068(X) chips
[928afc85270753657b5543e052cc270c279a3fe9]
Iyappan Subramanian (1):
phy: Add helper function to check phy interface mode
[32d0f7830d9be5b1652a718e050d808b4908155f]
Jaejoong Kim (2):
ALSA: usb-audio: Add check return value for usb_string()
[89b89d121ffcf8d9546633b98ded9d18b8f75891]
ALSA: usb-audio: Fix out-of-bound error
[251552a2b0d454badc8f486e6d79100970c744b0]
James Hogan (3):
MIPS: CPS: Fix r1 .set mt assembler warning
[17278a91e04f858155d54bee5528ba4fbcec6f87]
MIPS: Clear [MSA]FPE CSR.Cause after notify_die()
[64bedffe496820dbb6b53302d80dd0f04db33d8e]
MIPS: lose_fpu(): Disable FPU when MSA enabled
[acaf6a97d623af123314c2f8ce4cf7254f6b2fc1]
Jan Engelhardt (1):
crypto: n2 - cure use after free
[203f45003a3d03eea8fa28d74cfc74c354416fdb]
Jann Horn (1):
netfilter: xt_bpf: add overflow checks
[6ab405114b0b229151ef06f4e31c7834dd09d0c0]
Jeff Mahoney (1):
btrfs: fix missing error return in btrfs_drop_snapshot
[e19182c0fff451e3744c1107d98f072e7ca377a0]
Jens Axboe (1):
blktrace: fix trace mutex deadlock
[2967acbb257a6a9bf912f4778b727e00972eac9b]
Jeremy Compostella (1):
i2c: core-smbus: prevent stack corruption on read I2C_BLOCK_DATA
[89c6efa61f5709327ecfa24bff18e57a4e80c7fa]
Jerome Brunet (1):
net: stmmac: enable EEE in MII, GMII or RGMII only
[879626e3a52630316d817cbda7cec9a5446d1d82]
Jia Zhang (2):
x86/microcode/intel: Extend BDW late-loading further with LLC size check
[7e702d17ed138cf4ae7c00e8c00681ed464587c7]
x86/microcode/intel: Extend BDW late-loading with a revision check
[b94b7373317164402ff7728d10f7023127a02b60]
Jimmy Assarsson (3):
can: kvaser_usb: Fix comparison bug in kvaser_usb_read_bulk_callback()
[e84f44eb5523401faeb9cc1c97895b68e3cfb78d]
can: kvaser_usb: free buf in error paths
[435019b48033138581a6171093b181fc6b4d3d30]
can: kvaser_usb: ratelimit errors if incomplete messages are received
[8bd13bd522ff7dfa0eb371921aeb417155f7a3be]
Jing Xia (1):
tracing: Fix crash when it fails to alloc ring buffer
[24f2aaf952ee0b59f31c3a18b8b36c9e3d3c2cf5]
Joe Perches (1):
stddef.h: move offsetofend inside #ifndef/#endif guard, neaten
[8c7fbe5795a016259445a61e072eb0118aaf6a61]
Joe Thornber (1):
dm btree: fix serious bug in btree_split_beneath()
[bc68d0a43560e950850fc69b58f0f8254b28f6d6]
Johan Hovold (6):
ASoC: twl4030: fix child-node lookup
[15f8c5f2415bfac73f33a14bcd83422bcbfb5298]
Input: 88pm860x-ts - fix child-node lookup
[906bf7daa0618d0ef39f4872ca42218c29a3631f]
Input: twl4030-vibra - fix sibling-node lookup
[5b189201993ab03001a398de731045bfea90c689]
Input: twl6040-vibra - fix child-node lookup
[dcaf12a8b0bbdbfcfa2be8dff2c4948d9844b4ad]
mfd: twl4030-audio: Fix sibling-node lookup
[0a423772de2f3d7b00899987884f62f63ae00dcb]
mfd: twl6040: Fix child-node lookup
[85e9b13cbb130a3209f21bd7933933399c389ffe]Johannes Berg (4):
cfg80211: check dev_set_name() return value
[59b179b48ce2a6076448a44531242ac2b3f6cef2]
cfg80211: fix station info handling bugs
[5762d7d3eda25c03cc2d9d45227be3f5ab6bec9e]
mac80211_hwsim: validate number of different channels
[51a1aaa631c90223888d8beac4d649dc11d2ca55]
nl80211: fix nl80211_send_iface() error paths
[4564b187c16327045d87596e8980c65ba7b84c50]Johannes Thumshirn (1):
dm mpath: simplify failure path of dm_multipath_init()
[ff658e9c1aae9a84dd06d46f847dc0cd2bf0dd11]
Jon Hunter (1):
mfd: cros ec: spi: Don't send first message too soon
[15d8374874ded0bec37ef27f8301a6d54032c0e5]
Josef Bacik (1):
btrfs: clear space cache inode generation always
[8e138e0d92c6c9d3d481674fb14e3439b495be37]
Juan Zea (1):
usbip: fix usbip bind writing random string after command in match_busid
[544c4605acc5ae4afe7dd5914147947db182f2fb]
Kai-Heng Feng (1):
usb: quirks: Add no-lpm quirk for KY-688 USB 3.1 Type-C Hub
[e43a12f1793ae1fe006e26fe9327a8840a92233c]
Kevin Cernekee (1):
net: igmp: Use correct source address on IGMPv3 reports
[a46182b00290839fa3fa159d54fd3237bd8669f0]
Kristina Martsenko (1):
arm64: KVM: fix VTTBR_BADDR_MASK BUG_ON off-by-one
[26aa7b3b1c0fb3f1a6176a0c1847204ef4355693]
Lan Tianyu (1):
KVM/x86: Check input paging mode when cs.l is set
[f29810335965ac1f7bcb501ee2af5f039f792416]
Laurent Caumont (1):
media: dvb: i2c transfers over usb cannot be done from stack
[6d33377f2abbf9f0e561b116dd468d1c3ff36a6a]
Li Jinyue (1):
futex: Prevent overflow by strengthen input validation
[fbe0e839d1e22d88810f3ee3e2f1479be4c0aa4a]
Linus Torvalds (2):
kbuild: add '-fno-stack-check' to kernel build options
[3ce120b16cc548472f80cf8644f90eda958cf1b6]
n_tty: fix EXTPROC vs ICANON interaction with TIOCINQ (aka FIONREAD)
[966031f340185eddd05affcf72b740549f056348]
Liran Alon (3):
KVM: x86: Don't re-execute instruction when not passing CR2 value
[9b8ae63798cb97e785a667ff27e43fa6220cb734]
KVM: x86: Exit to user-mode on #UD intercept when emulator requires
[61cb57c9ed631c95b54f8e9090c89d18b3695b3c]
KVM: x86: emulator: Return to user-mode on L1 CPL=0 emulation failure
[1f4dcb3b213235e642088709a1c54964d23365e9]
Lixin Wang (1):
i2c: core: decrease reference count of device node in i2c_unregister_device
[e0638fa400eaccf9fa8060f67140264c4e276552]
Maciej S. Szmigiero (2):
ASoC: fsl_ssi: AC'97 ops need regmap, clock and cleaning up on failure
[695b78b548d8a26288f041e907ff17758df9e1d5]
ASoC: fsl_ssi: add AC'97 ops setting check and cleanup
[04143d614f3af84a3f39e79a24a7ca740bd39efd]
Maciej W. Rozycki (13):
MIPS: Always clear FCSR cause bits after emulation
[443c44032a54f9acf027a8e688380fddc809bc19]
MIPS: Disallow outsized PTRACE_SETREGSET NT_PRFPREG regset accesses
[c8c5a3a24d395b14447a9a89d61586a913840a3b]
MIPS: Factor out NT_PRFPREG regset access helpers
[a03fe72572c12e98f4173f8a535f32468e48b6ec]
MIPS: Fix FCSR Cause bit handling for correct SIGFPE issue
[5a1aca4469fdccd5b74ba0b4e490173b2b447895]
MIPS: Fix a preemption issue with thread's FPU defaults
[03dce595270f22d59a6f37e9170287c1afd94bc2]
MIPS: Fix an FCSR access API regression with NT_PRFPREG and MSA
[be07a6a1188372b6d19a3307ec33211fc9c9439d]
MIPS: Guard against any partial write attempt with PTRACE_SETREGSET
[dc24d0edf33c3e15099688b6bbdf7bdc24bf6e91]
MIPS: Respect the FCSR exception mask for `si_code'
[ed2d72c1eb3643b7c109bdf387563d9b9a30c279]
MIPS: Respect the ISA level in FCSR handling
[9b26616c8d9dae53fbac7f7cb2c6dd1308102976]
MIPS: Set `si_code' for SIGFPE signals sent from emulation too
[304acb717e5b67cf56f05bc5b21123758e1f7ea0]
MIPS: math-emu: Define IEEE 754-2008 feature control bits
[f1f3b7ebac08161761c352fd070cfa07b7b94c54]
MIPS: ptrace: Fix FP context restoration FCSR regression
[4249548454f7ba4581aeee26bd83f42b48a14d15]
MIPS: ptrace: Prevent writes to read-only FCSR bits
[abf378be49f38c4d3e23581d3df3fa9f1b1b11d2]
Marc Kleine-Budde (2):
can: af_can: can_rcv(): replace WARN_ONCE by pr_warn_once
[8cb68751c115d176ec851ca56ecfbb411568c9e8]
can: af_can: canfd_rcv(): replace WARN_ONCE by pr_warn_once
[d4689846881d160a4d12a514e991a740bcb5d65a]
Marc Zyngier (3):
KVM: arm/arm64: Fix HYP unmapping going off limits
[7839c672e58bf62da8f2f0197fefb442c02ba1dd]
arm64: KVM: Fix SMCCC handling of unimplemented SMC/HVC calls
[acfb3b883f6d6a4b5d27ad7fdded11f6a09ae6dd]
arm: KVM: Fix VTTBR_BADDR_MASK BUG_ON off-by-one
[5553b142be11e794ebc0805950b2e8313f93d718]
Marek Belisko (1):
Input: twl4030-vibra - fix ERROR: Bad of_node_put() warning
[e661d0a04462dd98667f8947141bd8defab5b34a]
Martin Kelly (4):
can: ems_usb: cancel urb on -EPIPE and -EPROTO
[bd352e1adfe0d02d3ea7c8e3fb19183dc317e679]
can: esd_usb2: cancel urb on -EPIPE and -EPROTO
[7a31ced3de06e9878e4f9c3abe8f87d9344d8144]
can: kvaser_usb: cancel urb on -EPIPE and -EPROTO
[6aa8d5945502baf4687d80de59b7ac865e9e666b]
can: usb_8dev: cancel urb on -EPIPE and -EPROTO
[12147edc434c9e4c7c2f5fee2e5519b2e5ac34ce]
Masakazu Mokuno (1):
USB: core: Add type-specific length check of BOS descriptors
[81cf4a45360f70528f1f64ba018d61cb5767249a]
Mathias Nyman (2):
xhci: Don't add a virt_dev to the devs array before it's fully allocated
[5d9b70f7d52eb14bb37861c663bae44de9521c35]
xhci: Don't show incorrect WARN message about events for empty rings
[e4ec40ec4b260efcca15089de4285a0a3411259b]
Matt Wilson (1):
serial: 8250_pci: Add Amazon PCI serial device ID
[3bfd1300abfe3adb18e84a89d97a0e82a22124bb]
Max Schulze (1):
USB: serial: ftdi_sio: add id for Airbus DS P8GR
[c6a36ad383559a60a249aa6016cebf3cb8b6c485]
Mike Looijmans (1):
usb: hub: Cycle HUB power when initialization fails
[973593a960ddac0f14f0d8877d2d0abe0afda795]
Ming Lei (1):
blk-mq: fix race between timeout and freeing request
[0048b4837affd153897ed1222283492070027aa9]
Mohamed Ghannam (1):
net: ipv4: fix for a race condition in raw_sendmsg
[8f659a03a0ba9289b9aeb9b4470e6fb263d6f483]
[email protected] (1):
dm: fix various targets to dm_register_target after module __init resources created
[7e6358d244e4706fe612a77b9c36519a33600ac0]
Moshe Shemesh (2):
net/mlx5: Cleanup IRQs in case of unload failure
[d6b2785cd55ee72e9608762650b3ef299f801b1b]
net/mlx5: Stay in polling mode when command EQ destroy fails
[a2fba188fd5eadd6061bef4f2f2577a43231ebf3]
Nicolai Stange (1):
net: ipv4: emulate READ_ONCE() on ->hdrincl bit-field in raw_sendmsg()
[20b50d79974ea3192e8c3ab7faf4e536e5f14d8f]Nikolay Aleksandrov (1):
net: bridge: fix early call to br_stp_change_bridge_id and plug newlink leaks
[84aeb437ab98a2bce3d4b2111c79723aedfceb33]
Nikolay Borisov (1):
btrfs: Fix possible off-by-one in btrfs_search_path_in_tree
[c8bcbfbd239ed60a6562964b58034ac8a25f4c31]
Nogah Frankel (2):
net_sched: red: Avoid devision by zero
[5c472203421ab4f928aa1ae9e1dbcfdd80324148]
net_sched: red: Avoid illegal values
[8afa10cbe281b10371fee5a87ab266e48d71a7f9]
Oleg Nesterov (1):
kernel/acct.c: fix the acct->needcheck check in check_free_space()
[4d9570158b6260f449e317a5f9ed030c2504a615]Oliver Neukum (2):
USB: usbfs: Filter flags passed in from user space
[446f666da9f019ce2ffd03800995487e79a91462]
usb: add RESET_RESUME for ELSA MicroLink 56K
[b9096d9f15c142574ebebe8fbb137012bb9d99c2]
Oliver Stäbler (1):
can: ti_hecc: Fix napi poll return value for repoll
[f6c23b174c3c96616514827407769cbcfc8005cf]
Omar Sandoval (1):
Btrfs: disable FUA if mounted with nobarrier
[1b9e619c5bc8235cfba3dc4ced2fb0e3554a05d4]
Oscar Campos (1):
Input: trackpoint - assume 3 buttons when buttons detection fails
[293b915fd9bebf33cdc906516fb28d54649a25ac]
Paul Burton (2):
MIPS: clear MSACSR cause bits when handling MSA FP exception
[091be550a70a086c3b4420c6155e733dc410f190]
MIPS: prevent FP context set via ptrace being discarded
[ac9ad83bc318635ed7496e9dff30beaa522eaec7]
Paul Meyer (1):
hv: kvp: Avoid reading past allocated blocks from KVP file
[297d6b6e56c2977fc504c61bbeeaa21296923f89]
Pete Zaitcev (1):
USB: fix usbmon BUG trigger
[46eb14a6e1585d99c1b9f58d0e7389082a5f466b]
Petri Gynther (1):
net: bcmgenet: fix bcmgenet_open()
[fac25940c5e0d6f31d56bb2a704fadad6d5e382a]
Rafael J. Wysocki (2):
PCI / PM: Force devices to D0 in pci_pm_thaw_noirq()
[5839ee7389e893a31e4e3c9cf17b50d14103c902]
x86/PCI: Make broadcom_postcore_init() check acpi_disabled
[ddec3bdee05b06f1dda20ded003c3e10e4184cab]
Ralf Baechle (1):
MIPS: MSA: bugfix - disable MSA correctly for new threads/processes.
[9cc719ab3f4f639d629ac8ff09e9b998bc006f68]
Ravi Bangoria (1):
powerpc/perf: Dereference BHRB entries safely
[f41d84dddc66b164ac16acf3f584c276146f1c48]
Ricardo Ribalda (1):
vb2: V4L2_BUF_FLAG_DONE is set after DQBUF
[3171cc2b4eb9831ab4df1d80d0410a945b8bc84e]
Richard Fitzgerald (1):
ASoC: wm_adsp: Don't overrun firmware file buffer when reading region data
[1cab2a84f470e15ecc8e5143bfe9398c6e888032]
Robb Glasser (1):
ALSA: pcm: prevent UAF in snd_pcm_info
[362bca57f5d78220f8b5907b875961af9436e229]
Robert Lippert (1):
hwmon: (pmbus) Use 64bit math for DIRECT format values
[bd467e4eababe4c04272c1e646f066db02734c79]
Robin Murphy (1):
iommu/vt-d: Fix scatterlist offset handling
[29a90b70893817e2f2bb3cea40a29f5308e21b21]
Rui Hua (1):
bcache: recover data from backing when data is clean
[e393aa2446150536929140739f09c6ecbcbea7f0]
SZ Lin (1):
USB: serial: option: adding support for YUGA CLM920-NC5
[3920bb713038810f25770e7545b79f204685c8f2]
Sebastian Sjoholm (1):
USB: serial: option: add Quectel BG96 id
[c654b21ede93845863597de9ad774fd30db5f2ab]
Sergei Shtylyov (5):
SolutionEngine771x: add Ether TSU resource
[f9a531d6731d74f1e24298d9641c2dc1fef2631b]
SolutionEngine771x: fix Ether platform data
[195e2addbce09e5afbc766efc1e6567c9ce840d3]
sh_eth: fix SH7757 GEther initialization
[5133550296d43236439494aa955bfb765a89f615]
sh_eth: fix TSU resource handling
[dfe8266b8dd10e12a731c985b725fcf7f0e537f0]
sh_eth: fix TXALCR1 offsets
[50f3d740d376f664f6accc7e86c9afd8f1c7e1e4]
Shuah Khan (4):
usbip: prevent leaking socket pointer address in messages
[90120d15f4c397272aaf41077960a157fc4212bf]
usbip: remove kernel addresses from usb device and urb debug msgs
[e1346fd87c71a1f61de1fe476ec8df1425ac931c]
usbip: stub: stop printing kernel pointer addresses in messages
[248a22044366f588d46754c54dfe29ffe4f8b4df]
usbip: vhci: stop printing kernel pointer addresses in messages
[8272d099d05f7ab2776cf56a2ab9f9443be18907]
Stefan Agner (1):
usb: misc: usb3503: make sure reset is low for at least 100us
[b8626f1dc29d3eee444bfaa92146ec7b291ef41c]
Steve Wise (1):
iw_cxgb4: Only validate the MSN for successful completions
[f55688c45442bc863f40ad678c638785b26cdce6]
Steven Rostedt (2):
ring-buffer: Mask out the info bits when returning buffer page length
[45d8b80c2ac5d21cd1e2954431fb676bc2b1e099]
tracing: Fix possible double free on failure of allocating trace buffer
[4397f04575c44e1440ec2e49b6302785c95fd2f8]
Sven Eckelmann (1):
batman-adv: Fix lock for ogm cnt access in batadv_iv_ogm_calc_tq
[5ba7dcfe77037b67016263ea597a8b431692ecab]
Takashi Iwai (15):
ACPI: APEI / ERST: Fix missing error handling in erst_reader()
[bb82e0b4a7e96494f0c1004ce50cec3d7b5fb3d1]
ALSA: aloop: Fix inconsistent format due to incomplete rule
[b088b53e20c7d09b5ab84c5688e609f478e5c417]
ALSA: aloop: Fix racy hw constraints adjustment
[898dfe4687f460ba337a01c11549f87269a13fa2]
ALSA: aloop: Release cable upon open error path
[9685347aa0a5c2869058ca6ab79fd8e93084a67f]
ALSA: hda - Apply the existing quirk to iMac 14,1
[031f335cda879450095873003abb03ae8ed3b74a]
ALSA: pcm: Abort properly at pending signal in OSS read/write loops
[29159a4ed7044c52e3e2cf1a9fb55cec4745c60b]
ALSA: pcm: Add missing error checks in OSS emulation plugin builder
[6708913750344a900f2e73bfe4a4d6dbbce4fe8d]
ALSA: pcm: Allow aborting mutex lock at OSS read/write loops
[900498a34a3ac9c611e9b425094c8106bdd7dc1c]
ALSA: pcm: Remove incorrect snd_BUG_ON() usages
[fe08f34d066f4404934a509b6806db1a4f700c86]
ALSA: pcm: Remove yet superfluous WARN_ON()
[23b19b7b50fe1867da8d431eea9cd3e4b6328c2c]
ALSA: rawmidi: Avoid racy info ioctl via ctl device
[c1cfd9025cc394fd137a01159d74335c5ac978ce]
ALSA: seq: Fix regression by incorrect ioctl_mutex usages
[not upstream; fixes incorrect backport]
ALSA: seq: Remove spurious WARN_ON() at timer check
[43a3542870328601be02fcc9d27b09db467336ef]
ALSA: usb-audio: Fix the missing ctl name suffix at parsing SU
[5a15f289ee87eaf33f13f08a4909ec99d837ec5f]
lib/oid_registry.c: X.509: fix the buffer overflow in the utility function for OID string
[afdb05e9d61905220f09268535235288e6ba3a16]
Tetsuo Handa (1):
quota: Check for register_shrinker() failure.
[88bc0ede8d35edc969350852894dc864a2dc1859]
Thiago Rafael Becker (1):
kernel: make groups_sort calling a responsibility group_info allocators
[bdcf0a423ea1c40bbb40e7ee483b50fc8aa3d758]
Thomas Gleixner (4):
hrtimer: Reset hrtimer cpu base proper on CPU hotplug
[d5421ea43d30701e03cadc56a38854c36a8b4433]
nohz: Prevent a timer interrupt storm in tick_nohz_stop_sched_tick()
[5d62c183f9e9df1deeea0906d099a94e8a43047a]
posix-timer: Properly check sigevent->sigev_notify
[cef31d9af908243421258f1df35a4a644604efbe]
x86/mce: Make machine check speculation protected
[6f41c34d69eb005e7848716bbcafc979b35037d5]Thomas Petazzoni (1):
ARM: dts: kirkwood: fix pin-muxing of MPP7 on OpenBlocks A7
[56aeb07c914a616ab84357d34f8414a69b140cdf]
Tianyu Lan (1):
KVM/x86: Fix wrong macro references of X86_CR0_PG_BIT and X86_CR4_PAE_BIT in kvm_valid_sregs()
[37b95951c58fdf08dc10afa9d02066ed9f176fb5]
Tiffany Lin (1):
[media] media: v4l2-compat-ioctl32: fix missing reserved field copy in put_v4l2_create32
[baf43c6eace43868e490f18560287fa3481b2159]
Tobias Jordan (2):
dmaengine: jz4740: disable/unprepare clk if probe fails
[eb9436966fdc84cebdf222952a99898ab46d9bb0]
net: mvmdio: disable/unprepare clocks in EPROBE_DEFER case
[589bf32f09852041fbd3b7ce1a9e703f95c230ba]
Tonghao Zhang (1):
sctp: Replace use of sockets_allocated with specified macro.
[8cb38a602478e9f806571f6920b0a3298aabf042]
Ville Syrjälä (2):
drm/i915: Don't try indexed reads to alternate slave addresses
[c4deb62d7821672265b87952bcd1c808f3bf3e8f]
drm/i915: Prevent zero length "index" write
[bb9e0d4bca50f429152e74a459160b41f3d60fb2]
Wanpeng Li (1):
KVM: X86: Fix load RFLAGS w/o the fixed bit
[d73235d17ba63b53dc0e1051dbc10a1f1be91b71]
Weiping Zhang (1):
virtio: release virtio index when fail to device_register
[e60ea67bb60459b95a50a156296041a13e0e380e]
William Breathitt Gray (1):
isa: Prevent NULL dereference in isa_bus driver callbacks
[5a244727f428a06634f22bb890e78024ab0c89f3]
Wolfgang Grandegger (1):
can: gs_usb: fix return value of the "set_bittiming" callback
[d5b42e6607661b198d8b26a0c30969605b1bf5c7]
Xin Long (4):
sctp: do not allow the v4 socket to bind a v4mapped v6 address
[c5006b8aa74599ce19104b31d322d2ea9ff887cc]
sctp: force the params with right types for sctp csum apis
[af2697a0273f7665429c47d71ab26f2412af924e]
sctp: return error if the asoc has been peeled off in sctp_wait_for_sndbuf
[a0ff660058b88d12625a783ce9e5c1371c87951f]
sctp: use the right sk after waking up from wait_buf sleep
[cea0cc80a6777beb6eb643d4ad53690e1ad1d4ff]
Yelena Krivosheev (1):
net: mvneta: clear interface link status on port disable
[4423c18e466afdfb02a36ee8b9f901d144b3c607]
Yu Chen (1):
usb: xhci: fix panic in xhci_free_virt_devices_depth_first
[80e457699a8dbdd70f2d26911e46f538645c55fc]
Zhao Qiang (1):
net: phy: marvell: Limit 88m1101 autoneg errata to 88E1145 as well.
[c505873eaece2b4aefd07d339dc7e1400e0235ac]
Makefile | 7 +- arch/arm/boot/dts/kirkwood-openblocks_a7.dts | 10 +- arch/arm/include/asm/kvm_arm.h | 3 +- arch/arm/kvm/mmu.c | 10 +- arch/arm64/include/asm/kvm_arm.h | 3 +- arch/arm64/kernel/process.c | 9 + arch/arm64/kvm/handle_exit.c | 4 +- arch/mips/include/asm/cpu-info.h | 2 + arch/mips/include/asm/elf.h | 7 + arch/mips/include/asm/fpu.h | 6 +- arch/mips/include/asm/fpu_emulator.h | 18 +- arch/mips/include/asm/kdebug.h | 3 +- arch/mips/include/asm/mipsregs.h | 14 +- arch/mips/include/asm/switch_to.h | 21 +- arch/mips/kernel/cps-vec.S | 2 + arch/mips/kernel/cpu-probe.c | 55 +- arch/mips/kernel/genex.S | 15 +- arch/mips/kernel/ptrace.c | 197 +++- arch/mips/kernel/r2300_switch.S | 7 +- arch/mips/kernel/r4k_switch.S | 7 +- arch/mips/kernel/traps.c | 153 ++- arch/mips/kernel/unaligned.c | 4 +- arch/mips/math-emu/cp1emu.c | 8 +- arch/mips/math-emu/ieee754.h | 12 +- arch/powerpc/kernel/setup-common.c | 11 - arch/powerpc/perf/core-book3s.c | 8 +- arch/s390/include/asm/switch_to.h | 24 +- arch/s390/kernel/compat_linux.c | 1 + arch/sh/boards/mach-se/770x/setup.c | 24 +- arch/sh/include/mach-se/mach/se.h | 1 + arch/x86/include/asm/alternative.h | 4 +- arch/x86/include/asm/kvm_host.h | 3 +- arch/x86/include/asm/traps.h | 1 + arch/x86/kernel/cpu/mcheck/mce.c | 6 + arch/x86/kernel/cpu/microcode/intel.c | 29 +- arch/x86/kernel/entry_64.S | 2 +- arch/x86/kvm/svm.c | 2 + arch/x86/kvm/vmx.c | 16 +- arch/x86/kvm/x86.c | 30 +- arch/x86/pci/broadcom_bus.c | 2 +- block/blk-flush.c | 6 + block/blk-mq-tag.h | 12 + block/blk-mq.c | 16 +- crypto/algapi.c | 12 + crypto/asymmetric_keys/x509_cert_parser.c | 2 + drivers/acpi/apei/erst.c | 2 +- drivers/acpi/sbshc.c | 4 +- drivers/base/isa.c | 10 +- drivers/crypto/n2_core.c | 3 + drivers/dma/dma-jz4740.c | 4 +- drivers/dma/dmatest.c | 54 +- drivers/firmware/efi/efi.c | 3 +- drivers/firmware/efi/runtime-map.c | 10 +- drivers/gpu/drm/i915/intel_i2c.c | 4 +- drivers/hwmon/pmbus/pmbus_core.c | 21 +- drivers/i2c/i2c-core.c | 17 +- drivers/infiniband/hw/cxgb4/cq.c | 6 +- drivers/infiniband/ulp/ipoib/ipoib_main.c | 25 +- drivers/infiniband/ulp/ipoib/ipoib_multicast.c | 5 +- drivers/infiniband/ulp/srpt/ib_srpt.c | 3 +- drivers/input/misc/twl4030-vibra.c | 7 +- drivers/input/misc/twl6040-vibra.c | 2 +- drivers/input/mouse/elantech.c | 2 +- drivers/input/mouse/trackpoint.c | 7 +- drivers/input/touchscreen/88pm860x-ts.c | 16 +- drivers/iommu/intel-iommu.c | 8 +- drivers/md/bcache/request.c | 13 +- drivers/md/dm-cache-target.c | 12 +- drivers/md/dm-mpath.c | 34 +- drivers/md/dm-snap.c | 48 +- drivers/md/dm-thin-metadata.c | 6 +- drivers/md/dm-thin.c | 22 +- drivers/md/persistent-data/dm-btree.c | 19 +- drivers/media/i2c/adv7604.c | 6 +- drivers/media/usb/dvb-usb/dibusb-common.c | 16 +- drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 1025 ++++++++++++-------- drivers/media/v4l2-core/v4l2-ioctl.c | 5 +- drivers/media/v4l2-core/videobuf2-core.c | 5 + drivers/mfd/cros_ec_spi.c | 4 + drivers/mfd/twl4030-audio.c | 9 +- drivers/mfd/twl6040.c | 12 +- drivers/misc/eeprom/at24.c | 6 + drivers/mmc/host/s3cmci.c | 6 +- drivers/net/can/ti_hecc.c | 3 + drivers/net/can/usb/ems_usb.c | 2 + drivers/net/can/usb/esd_usb2.c | 2 + drivers/net/can/usb/gs_usb.c | 2 +- drivers/net/can/usb/kvaser_usb.c | 13 +- drivers/net/can/usb/usb_8dev.c | 2 + drivers/net/ethernet/broadcom/genet/bcmgenet.c | 2 +- .../net/ethernet/freescale/fs_enet/fs_enet-main.c | 16 +- drivers/net/ethernet/freescale/fs_enet/fs_enet.h | 1 + drivers/net/ethernet/intel/e1000e/ich8lan.c | 11 +- drivers/net/ethernet/intel/e1000e/mac.c | 11 +- drivers/net/ethernet/intel/e1000e/netdev.c | 2 +- drivers/net/ethernet/marvell/mvmdio.c | 3 +- drivers/net/ethernet/marvell/mvneta.c | 4 + drivers/net/ethernet/mellanox/mlx5/core/eq.c | 17 +- drivers/net/ethernet/renesas/sh_eth.c | 33 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 + drivers/net/phy/marvell.c | 2 +- drivers/net/phy/mdio-sun4i.c | 6 +- drivers/net/ppp/pppoe.c | 11 +- drivers/net/wireless/mac80211_hwsim.c | 14 +- drivers/of/fdt.c | 2 +- drivers/parisc/lba_pci.c | 33 + drivers/pci/pci-driver.c | 7 +- drivers/scsi/scsi_lib.c | 10 +- drivers/staging/usbip/stub_dev.c | 3 +- drivers/staging/usbip/stub_main.c | 5 +- drivers/staging/usbip/stub_rx.c | 7 +- drivers/staging/usbip/stub_tx.c | 4 +- drivers/staging/usbip/usbip_common.c | 31 +- drivers/staging/usbip/userspace/src/utils.c | 9 +- drivers/staging/usbip/vhci_hcd.c | 12 +- drivers/staging/usbip/vhci_rx.c | 23 +- drivers/staging/usbip/vhci_tx.c | 3 +- drivers/tty/n_tty.c | 4 +- drivers/tty/serial/8250/8250_pci.c | 3 + drivers/usb/core/config.c | 16 +- drivers/usb/core/devio.c | 14 +- drivers/usb/core/hub.c | 9 + drivers/usb/core/quirks.c | 9 +- drivers/usb/gadget/composite.c | 7 +- drivers/usb/gadget/udc-core.c | 32 +- drivers/usb/host/ehci-dbg.c | 2 +- drivers/usb/host/xhci-mem.c | 24 +- drivers/usb/host/xhci-pci.c | 3 + drivers/usb/host/xhci-ring.c | 12 +- drivers/usb/misc/usb3503.c | 2 + drivers/usb/mon/mon_bin.c | 8 +- drivers/usb/musb/da8xx.c | 10 +- drivers/usb/serial/cp210x.c | 2 + drivers/usb/serial/ftdi_sio.c | 1 + drivers/usb/serial/ftdi_sio_ids.h | 6 + drivers/usb/serial/option.c | 20 + drivers/usb/storage/uas-detect.h | 4 + drivers/usb/storage/unusual_devs.h | 7 + drivers/usb/storage/unusual_uas.h | 14 + drivers/virtio/virtio.c | 2 + fs/btrfs/disk-io.c | 9 +- fs/btrfs/extent-tree.c | 15 +- fs/btrfs/ioctl.c | 2 +- fs/ext4/extents.c | 1 + fs/ext4/namei.c | 4 + fs/nfsd/auth.c | 3 + fs/quota/dquot.c | 3 +- include/asm-generic/dma-mapping-broken.h | 3 - include/linux/blkdev.h | 6 + include/linux/cred.h | 1 + include/linux/dma-mapping.h | 2 - include/linux/fscache.h | 2 +- include/linux/mlx5/driver.h | 2 +- include/linux/phy.h | 21 + include/linux/sh_eth.h | 1 - include/linux/stddef.h | 15 +- include/linux/sysfs.h | 6 + include/linux/vfio.h | 13 - include/net/cfg80211.h | 2 + include/net/red.h | 13 +- include/net/sctp/checksum.h | 13 +- include/net/xfrm.h | 1 + include/scsi/libsas.h | 2 +- include/uapi/linux/usb/ch9.h | 2 + kernel/acct.c | 2 +- kernel/debug/kdb/kdb_io.c | 2 +- kernel/futex.c | 3 + kernel/groups.c | 5 +- kernel/hrtimer.c | 2 + kernel/posix-timers.c | 37 +- kernel/time/tick-sched.c | 19 +- kernel/trace/blktrace.c | 4 +- kernel/trace/ring_buffer.c | 6 +- kernel/trace/trace.c | 3 + kernel/uid16.c | 1 + lib/asn1_decoder.c | 45 +- lib/oid_registry.c | 16 +- mm/mprotect.c | 6 +- net/8021q/vlan.c | 7 +- net/batman-adv/bat_iv_ogm.c | 4 +- net/bridge/br_netlink.c | 7 +- net/can/af_can.c | 22 +- net/dccp/ccids/ccid2.c | 3 + net/ipv4/esp4.c | 1 + net/ipv4/igmp.c | 20 +- net/ipv4/raw.c | 121 ++- net/ipv4/tcp_ipv4.c | 2 +- net/ipv4/xfrm4_input.c | 11 +- net/ipv6/esp6.c | 3 +- net/ipv6/tcp_ipv6.c | 2 +- net/ipv6/xfrm6_input.c | 9 +- net/key/af_key.c | 8 + net/netfilter/xt_bpf.c | 6 +- net/packet/af_packet.c | 5 + net/rds/rdma.c | 2 +- net/sched/sch_choke.c | 3 + net/sched/sch_gred.c | 3 + net/sched/sch_red.c | 2 + net/sched/sch_sfq.c | 3 + net/sctp/socket.c | 31 +- net/sunrpc/auth_gss/gss_rpc_xdr.c | 1 + net/sunrpc/auth_gss/svcauth_gss.c | 1 + net/sunrpc/svcauth_unix.c | 2 + net/wireless/core.c | 7 +- net/wireless/core.h | 2 - net/wireless/nl80211.c | 15 +- net/wireless/wext-compat.c | 3 +- net/xfrm/xfrm_input.c | 56 ++ sound/core/oss/pcm_oss.c | 41 +- sound/core/oss/pcm_plugin.c | 14 +- sound/core/pcm.c | 2 + sound/core/pcm_lib.c | 5 +- sound/core/rawmidi.c | 15 +- sound/core/seq/seq_clientmgr.c | 15 +- sound/core/seq/seq_timer.c | 2 +- sound/drivers/aloop.c | 98 +- sound/pci/hda/patch_cirrus.c | 1 + sound/pci/hda/patch_conexant.c | 29 + sound/soc/codecs/twl4030.c | 4 +- sound/soc/codecs/wm_adsp.c | 29 +- sound/soc/fsl/fsl_ssi.c | 17 +- sound/usb/mixer.c | 26 +- tools/hv/hv_kvp_daemon.c | 70 +- 223 files changed, 2532 insertions(+), 1264 deletions(-)
Signature · 2 lines
Ben Hutchings If the facts do not conform to your theory, they must be disposed of.
PATCH 1/254 ALSA: seq: Fix regression by incorrect ioctl_mutex usages
3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
This is the revised backport of the upstream commit b3defb791b26ea0683a93a4f49c77ec45ec96f10
We had another backport (e.g. 623e5c8ae32b in 4.4.115), but it applies the new mutex also to the code paths that are invoked via faked kernel-to-kernel ioctls. As reported recently, this leads to a deadlock at suspend (or other scenarios triggering the kernel sequencer client).
This patch addresses the issue by taking the mutex only in the code paths invoked by user-space, just like the original fix patch does.
--- sound/core/seq/seq_clientmgr.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
sound/core/seq/seq_clientmgr.c +7 -8
@@ -2201,7 +2201,6 @@ static int snd_seq_do_ioctl(struct snd_s void __user *arg) {struct seq_ioctl_table *p; -int ret;switch (cmd) {case SNDRV_SEQ_IOCTL_PVERSION :
@@ -2215,12 +2214,8 @@ static int snd_seq_do_ioctl(struct snd_sif (! arg)return -EFAULT ;for (p = ioctl_tables; p->cmd; p++) { -if (p->cmd == cmd) { -mutex_lock (&client->ioctl_mutex); - ret = p->func (client, arg); -mutex_unlock (&client->ioctl_mutex); -return ret; - } +if (p->cmd == cmd) +return p->func (client, arg); }pr_debug ("ALSA: seq unknown ioctl() 0x%x (type='%c', number=0x%02x)\n" , cmd,_IOC_TYPE (cmd),_IOC_NR (cmd));
@@ -2231,11 +2226,15 @@ static int snd_seq_do_ioctl(struct snd_sstatic long snd_seq_ioctl (struct file *file,unsigned int cmd,unsigned long arg) {struct snd_seq_client *client = file->private_data; +long ret;if (snd_BUG_ON (!client))return -ENXIO ; -return snd_seq_do_ioctl (client, cmd, (void __user *) arg); +mutex_lock (&client->ioctl_mutex); + ret =snd_seq_do_ioctl (client, cmd, (void __user *) arg); +mutex_unlock (&client->ioctl_mutex); +return ret; }#ifdef CONFIG_COMPAT
PATCH 2/254 ASoC: twl4030: fix child-node lookup
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 15f8c5f2415bfac73f33a14bcd83422bcbfb5298 upstream.
Fix child-node lookup during probe, which ended up searching the whole device tree depth-first starting at the parent rather than just matching on its children.
To make things worse, the parent codec node was also prematurely freed, while the child node was leaked.
--- sound/soc/codecs/twl4030.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/codecs/twl4030.c +3 -1
@@ -232,7 +232,7 @@ static struct twl4030_codec_data *twl403struct twl4030_codec_data *pdata =dev_get_platdata (codec->dev);struct device_node *twl4030_codec_node =NULL ; - twl4030_codec_node =of_find_node_by_name (codec->dev->parent->of_node, + twl4030_codec_node =of_get_child_by_name (codec->dev->parent->of_node,"codec" );if (!pdata && twl4030_codec_node) {
@@ -241,9 +241,11 @@ static struct twl4030_codec_data *twl403 GFP_KERNEL);if (!pdata) {dev_err (codec->dev,"Can not allocate memory\n" ); +of_node_put (twl4030_codec_node);return NULL ; }twl4030_setup_pdata_of (pdata, twl4030_codec_node); +of_node_put (twl4030_codec_node); }return pdata;
PATCH 3/254 KVM: x86: Exit to user-mode on #UD intercept when emulator requires
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Liran Alon <[email protected]>
commit 61cb57c9ed631c95b54f8e9090c89d18b3695b3c upstream.
Instruction emulation after trapping a #UD exception can result in an MMIO access, for example when emulating a MOVBE on a processor that doesn't support the instruction. In this case, the #UD vmexit handler must exit to user mode, but there wasn't any code to do so. Add it for both VMX and SVM.
--- arch/x86/kvm/svm.c | 2 ++ arch/x86/kvm/vmx.c | 2 ++ 2 files changed, 4 insertions(+)
arch/x86/kvm/svm.c +2 -0
@@ -1776,6 +1776,8 @@ static int ud_interception(struct vcpu_sint er; er =emulate_instruction (&svm->vcpu,EMULTYPE_TRAP_UD ); +if (er ==EMULATE_USER_EXIT ) +return 0 ;if (er !=EMULATE_DONE )kvm_queue_exception (&svm->vcpu,UD_VECTOR );return 1 ;
arch/x86/kvm/vmx.c +2 -0
@@ -4853,6 +4853,8 @@ static int handle_exception(struct kvm_vif (is_invalid_opcode (intr_info)) { er =emulate_instruction (vcpu,EMULTYPE_TRAP_UD ); +if (er ==EMULATE_USER_EXIT ) +return 0 ;if (er !=EMULATE_DONE )kvm_queue_exception (vcpu,UD_VECTOR );return 1 ;
PATCH 4/254 KVM: x86: emulator: Return to user-mode on L1 CPL=0 emulation failure
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Liran Alon <[email protected]>
commit 1f4dcb3b213235e642088709a1c54964d23365e9 upstream.
On this case, handle_emulation_failure() fills kvm_run with internal-error information which it expects to be delivered to user-mode for further processing.
However, the code reports a wrong return-value which makes KVM to never return to user-mode on this scenario.
userspace")
--- arch/x86/kvm/x86.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/x86.c +1 -1
@@ -5009,7 +5009,7 @@ static int handle_emulation_failure(stru vcpu->run->exit_reason =KVM_EXIT_INTERNAL_ERROR ; vcpu->run->internal.suberror =KVM_INTERNAL_ERROR_EMULATION ; vcpu->run->internal.ndata =0 ; - r =EMULATE_FAIL ; + r =EMULATE_USER_EXIT ; }kvm_queue_exception (vcpu,UD_VECTOR );
PATCH 5/254 KVM: x86: Don't re-execute instruction when not passing CR2 value
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Liran Alon <[email protected]>
commit 9b8ae63798cb97e785a667ff27e43fa6220cb734 upstream.
In case of instruction-decode failure or emulation failure, x86_emulate_instruction() will call reexecute_instruction() which will attempt to use the cr2 value passed to x86_emulate_instruction(). However, when x86_emulate_instruction() is called from emulate_instruction(), cr2 is not passed (passed as 0) and therefore it doesn't make sense to execute reexecute_instruction() logic at all.
--- arch/x86/include/asm/kvm_host.h | 3 ++- arch/x86/kvm/vmx.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
arch/x86/include/asm/kvm_host.h +2 -1
@@ -847,7 +847,8 @@ int x86_emulate_instruction(struct kvm_vstatic inline int emulate_instruction (struct kvm_vcpu *vcpu,int emulation_type) { -return x86_emulate_instruction (vcpu,0 , emulation_type,NULL ,0 ); +return x86_emulate_instruction (vcpu,0 , + emulation_type |EMULTYPE_NO_REEXECUTE ,NULL ,0 ); }void kvm_enable_efer_bits (u64 );
arch/x86/kvm/vmx.c +1 -1
@@ -5659,7 +5659,7 @@ static int handle_invalid_guest_state(stif (test_bit (KVM_REQ_EVENT , &vcpu->requests))return 1 ; - err =emulate_instruction (vcpu,EMULTYPE_NO_REEXECUTE ); + err =emulate_instruction (vcpu,0 );if (err ==EMULATE_USER_EXIT ) { ++vcpu->stat.mmio_exits;
PATCH 6/254 iommu/vt-d: Fix scatterlist offset handling
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Robin Murphy <[email protected]>
commit 29a90b70893817e2f2bb3cea40a29f5308e21b21 upstream.
The intel-iommu DMA ops fail to correctly handle scatterlists where sg->offset is greater than PAGE_SIZE - the IOVA allocation is computed appropriately based on the page-aligned portion of the offset, but the mapping is set up relative to sg->page, which means it fails to actually cover the whole buffer (and in the worst case doesn't cover it at all):
(sg->dma_address + sg->dma_len) ----+
sg->dma_address ---------+ |
iov_pfn------+ | |
| | |
v v v
iova: a b c d e f
|--------|--------|--------|--------|--------|
<...calculated....>
[_____mapped______]
pfn: 0 1 2 3 4 5
|--------|--------|--------|--------|--------|
^ ^ ^
| | |
sg->page ----+ | |
sg->offset --------------+ |
(sg->offset + sg->length) ----------+As a result, the caller ends up overrunning the mapping into whatever lies beyond, which usually goes badly:
[ 429.645492] DMAR: DRHD: handling fault status reg 2 [ 429.650847] DMAR: [DMA Write] Request device [02:00.4] fault addr f2682000 ...
Whilst this is a fairly rare occurrence, it can happen from the result of intermediate scatterlist processing such as scatterwalk_ffwd() in the crypto layer. Whilst that particular site could be fixed up, it still seems worthwhile to bring intel-iommu in line with other DMA API implementations in handling this robustly.
To that end, fix the intel_map_sg() path to line up the mapping correctly (in units of MM pages rather than VT-d pages to match the aligned_nrpages() calculation) regardless of the offset, and use sg_phys() consistently for clarity.
Reviewed by: Ashok Raj <[email protected]>
Tested by: Jacob Pan <[email protected]>
--- drivers/iommu/intel-iommu.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/iommu/intel-iommu.c +5 -3
@@ -2008,10 +2008,12 @@ static int __domain_mapping(struct dmar_uint64_t tmp;if (!sg_res) { +unsigned int pgoff = sg->offset & ~PAGE_MASK ; + sg_res =aligned_nrpages (sg->offset, sg->length); - sg->dma_address = ((dma_addr_t )iov_pfn <<VTD_PAGE_SHIFT ) + sg->offset; + sg->dma_address = ((dma_addr_t )iov_pfn <<VTD_PAGE_SHIFT ) + pgoff; sg->dma_length = sg->length; - pteval =page_to_phys (sg_page (sg)) | prot; + pteval = (sg_phys (sg) - pgoff) | prot; phys_pfn = pteval >>VTD_PAGE_SHIFT ; }
@@ -3345,7 +3347,7 @@ static int intel_nontranslate_map_sg(strfor_each_sg (sglist, sg, nelems, i) {BUG_ON (!sg_page (sg)); - sg->dma_address =page_to_phys (sg_page (sg)) + sg->offset; + sg->dma_address =sg_phys (sg); sg->dma_length = sg->length; }return nelems;
PATCH 7/254 btrfs: clear space cache inode generation always
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit 8e138e0d92c6c9d3d481674fb14e3439b495be37 upstream.
We discovered a box that had double allocations, and suspected the space cache may be to blame. While auditing the write out path I noticed that if we've already setup the space cache we will just carry on. This means that any error we hit after cache_save_setup before we go to actually write the cache out we won't reset the inode generation, so whatever was already written will be considered correct, except it'll be stale. Fix this by _always_ resetting the generation on the block group inode, this way we only ever have valid or invalid cache.
With this patch I was no longer able to reproduce cache corruption with dm-log-writes and my bpf error injection tool.
--- fs/btrfs/extent-tree.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
fs/btrfs/extent-tree.c +7 -7
@@ -3236,13 +3236,6 @@ again: goto again; } -/* We've already setup this transaction, go ahead and exit */ -if (block_group->cache_generation == trans->transid && -i_size_read (inode)) { - dcs =BTRFS_DC_SETUP ; - goto out_put; - } -/* * We want to set the generation to 0, that way if anything goes wrong * from here on out we know not to trust this cache when we load up next
@@ -3252,6 +3245,13 @@ again: ret =btrfs_update_inode (trans, root, inode);WARN_ON (ret); +/* We've already setup this transaction, go ahead and exit */ +if (block_group->cache_generation == trans->transid && +i_size_read (inode)) { + dcs =BTRFS_DC_SETUP ; + goto out_put; + } +if (i_size_read (inode) >0 ) { ret =btrfs_check_trunc_cache_free_space (root, &root->fs_info->global_block_rsv);
PATCH 8/254 scsi: dma-mapping: always provide dma_get_cache_alignment
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Hellwig <[email protected]>
commit 860dd4424f344400b491b212ee4acb3a358ba9d9 upstream.
Provide the dummy version of dma_get_cache_alignment that always returns 1 even if CONFIG_HAS_DMA is not set, so that drivers and subsystems can use it without ifdefs.
[bwh: Backported to 3.16: Also delete the conflicting declaration in
<asm-generic/dma-mapping-broken.h>]
---
include/linux/dma-mapping.h +0 -2
@@ -181,7 +181,6 @@ static inline void *dma_zalloc_coherent(return ret; } -#ifdef CONFIG_HAS_DMA static inline int dma_get_cache_alignment (void ) {#ifdef ARCH_DMA_MINALIGN
@@ -189,7 +188,6 @@ static inline int dma_get_cache_alignmen#endif return 1 ; } -#endif /* flags for the coherent memory api */ #define DMA_MEMORY_MAP 0x01
include/asm-generic/dma-mapping-broken.h +0 -3
@@ -85,9 +85,6 @@ dma_supported(struct device *dev, u64 maextern int dma_set_mask (struct device *dev,u64 mask); -extern int -dma_get_cache_alignment (void ); -extern void dma_cache_sync (struct device *dev,void *vaddr,size_t size,enum dma_data_direction direction);
PATCH 9/254 scsi: use dma_get_cache_alignment() as minimum DMA alignment
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Huacai Chen <[email protected]>
commit 90addc6b3c9cda0146fbd62a08e234c2b224a80c upstream.
In non-coherent DMA mode, kernel uses cache flushing operations to maintain I/O coherency, so scsi's block queue should be aligned to the value returned by dma_get_cache_alignment(). Otherwise, If a DMA buffer and a kernel structure share a same cache line, and if the kernel structure has dirty data, cache_invalidate (no writeback) will cause data corruption.
--- drivers/scsi/scsi_lib.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/scsi/scsi_lib.c +6 -4
@@ -1671,11 +1671,13 @@ struct request_queue *__scsi_alloc_queue q->limits.cluster =0 ;/* -* set a reasonable default alignment on word boundaries: the -* host and device may alter it using -* blk_queue_update_dma_alignment() later. +* Set a reasonable default alignment: The larger of 32-byte (dword), +* which is a common minimum for HBAs, and the minimum DMA alignment, +* which is set by the platform. +* +* Devices that require a bigger alignment can increase it later. */ -blk_queue_dma_alignment (q,0x03 ); +blk_queue_dma_alignment (q,max (4 ,dma_get_cache_alignment ()) -1 );return q; }
PATCH 10/254 scsi: libsas: align sata_device's rps_resp on a cacheline
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Huacai Chen <[email protected]>
commit c2e8fbf908afd81ad502b567a6639598f92c9b9d upstream.
The rps_resp buffer in ata_device is a DMA target, but it isn't explicitly cacheline aligned. Due to this, adjacent fields can be overwritten with stale data from memory on non-coherent architectures. As a result, the kernel is sometimes unable to communicate with an SATA device behind a SAS expander.
Fix this by ensuring that the rps_resp buffer is cacheline aligned.
This issue is similar to that fixed by Commit 84bda12af31f93 ("libata:
align ap->sector_buf") and Commit 4ee34ea3a12396f35b26 ("libata: Align ata_device's id on a cacheline").
--- include/scsi/libsas.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/scsi/libsas.h +1 -1
@@ -170,11 +170,11 @@ enum ata_command_set {struct sata_device {enum ata_command_set command_set; -struct smp_resp rps_resp;/* report_phy_sata_resp */ u8 port_no;/* port number, if this is a PM (Port) */ struct ata_port *ap;struct ata_host ata_host; +struct smp_resp rps_resp____cacheline_aligned ;/* report_phy_sata_resp */ u8 fis[ATA_RESP_FIS_SIZE ]; };
PATCH 11/254 bcache: recover data from backing when data is clean
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Rui Hua <[email protected]>
commit e393aa2446150536929140739f09c6ecbcbea7f0 upstream.
When we send a read request and hit the clean data in cache device, there is a situation called cache read race in bcache(see the commit in the tail of cache_look_up(), the following explaination just copy from there):
The bucket we're reading from might be reused while our bio is in flight, and we could then end up reading the wrong data. We guard against this by checking (in bch_cache_read_endio()) if the pointer is stale again; if so, we treat it as an error (s->iop.error = -EINTR) and reread from the backing device (but we don't pass that error up anywhere)
It should be noted that cache read race happened under normal circumstances, not the circumstance when SSD failed, it was counted and shown in /sys/fs/bcache/XXX/internal/cache_read_races.
Without this patch, when we use writeback mode, we will never reread from the backing device when cache read race happened, until the whole cache device is clean, because the condition
(s->recoverable && (dc && !atomic_read(&dc->has_dirty))) is false in cached_dev_read_error(). In this situation, the s->iop.error(= -EINTR) will be passed up, at last, user will receive -EINTR when it's bio end, this is not suitable, and wield to up-application.
In this patch, we use s->read_dirty_data to judge whether the read request hit dirty data in cache device, it is safe to reread data from the backing device when the read request hit clean data. This can not only handle cache read race, but also recover data when failed read request from cache device.
[edited by mlyle to fix up whitespace, commit log title, comment spelling]
--- drivers/md/bcache/request.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/md/bcache/request.c +6 -7
@@ -698,16 +698,15 @@ static void cached_dev_read_error(struct { struct search *s = container_of(cl, struct search, cl);struct bio *bio = &s->bio.bio; - struct cached_dev *dc = container_of(s->d, struct cached_dev, disk);/* -* If cache device is dirty (dc->has_dirty is non-zero), then -* recovery a failed read request from cached device may get a -* stale data back. So read failure recovery is only permitted -* when cache device is clean. +* If read request hit dirty data (s->read_dirty_data is true), +* then recovery a failed read request from cached device may +* get a stale data back. So read failure recovery is only +* permitted when read request hit clean data in cache device, +* or when cache read race happened. */ -if (s->recoverable && - (dc && !atomic_read (&dc->has_dirty))) { +if (s->recoverable && !s->read_dirty_data) {/* Retry from the backing device: */ trace_bcache_read_retry (s->orig_bio);
PATCH 12/254 Input: elantech - add new icbody type 15
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Aaron Ma <[email protected]>
commit 10d900303f1c3a821eb0bef4e7b7ece16768fba4 upstream.
The touchpad of Lenovo Thinkpad L480 reports it's version as 15.
--- drivers/input/mouse/elantech.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/mouse/elantech.c +1 -1
@@ -1481,7 +1481,7 @@ static int elantech_set_properties(struccase 5 : etd->hw_version =3 ;break ; - case 6 ... 14: + case 6 ... 15: etd->hw_version =4 ;break ;default :
PATCH 13/254 USB: serial: option: add Quectel BG96 id
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Sjoholm <[email protected]>
commit c654b21ede93845863597de9ad774fd30db5f2ab upstream.
Quectel BG96 is an Qualcomm MDM9206 based IoT modem, supporting both CAT-M and NB-IoT. Tested hardware is BG96 mounted on Quectel development board (EVB). The USB id is added to option.c to allow DIAG,GPS,AT and modem communication with the BG96.
--- drivers/usb/serial/option.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/serial/option.c +3 -0
@@ -242,6 +242,7 @@ static void option_instat_callback(struc/* These Quectel products use Quectel's vendor ID */ #define QUECTEL_PRODUCT_EC21 0x0121#define QUECTEL_PRODUCT_EC25 0x0125 +#define QUECTEL_PRODUCT_BG96 0x0296#define SIERRA_VENDOR_ID 0x1199
@@ -1204,6 +1205,8 @@ static const struct usb_device_id option .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(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96), + .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) }, { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003),
PATCH 14/254 ASoC: fsl_ssi: add AC'97 ops setting check and cleanup
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Maciej S. Szmigiero" <[email protected]>
commit 04143d614f3af84a3f39e79a24a7ca740bd39efd upstream.
Check whether setting AC'97 ops succeeded and clean them on removal so the fsl_ssi driver can be reloaded.
--- sound/soc/fsl/fsl_ssi.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
sound/soc/fsl/fsl_ssi.c +8 -1
@@ -1274,7 +1274,11 @@ static int fsl_ssi_probe(struct platform fsl_ac97_data = ssi_private; -snd_soc_set_ac97_ops_of_reset (&fsl_ssi_ac97_ops, pdev); + ret =snd_soc_set_ac97_ops_of_reset (&fsl_ssi_ac97_ops, pdev); +if (ret) { +dev_err (&pdev->dev,"could not set AC'97 ops\n" ); +return ret; + } }else {/* Initialize this copy of the CPU DAI driver structure */ memcpy(&ssi_private->cpu_dai_drv, &fsl_ssi_dai_template,
@@ -1422,6 +1426,9 @@ static int fsl_ssi_remove(struct platforif (ssi_private->use_dma)irq_dispose_mapping (ssi_private->irq); +if (fsl_ssi_is_ac97 (ssi_private)) +snd_soc_set_ac97_ops (NULL ); +return 0 ; }
PATCH 15/254 ASoC: fsl_ssi: AC'97 ops need regmap, clock and cleaning up on failure
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Maciej S. Szmigiero" <[email protected]>
commit 695b78b548d8a26288f041e907ff17758df9e1d5 upstream.
AC'97 ops (register read / write) need SSI regmap and clock, so they have to be set after them.
We also need to set these ops back to NULL if we fail the probe.
--- sound/soc/fsl/fsl_ssi.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
sound/soc/fsl/fsl_ssi.c +12 -6
@@ -1273,12 +1273,6 @@ static int fsl_ssi_probe(struct platform sizeof(fsl_ssi_ac97_dai)); fsl_ac97_data = ssi_private; - - ret =snd_soc_set_ac97_ops_of_reset (&fsl_ssi_ac97_ops, pdev); -if (ret) { -dev_err (&pdev->dev,"could not set AC'97 ops\n" ); -return ret; - } }else {/* Initialize this copy of the CPU DAI driver structure */ memcpy(&ssi_private->cpu_dai_drv, &fsl_ssi_dai_template,
@@ -1336,6 +1330,14 @@ static int fsl_ssi_probe(struct platform goto error_irqmap; } +if (fsl_ssi_is_ac97 (ssi_private)) { + ret =snd_soc_set_ac97_ops_of_reset (&fsl_ssi_ac97_ops, pdev); +if (ret) { +dev_err (&pdev->dev,"could not set AC'97 ops\n" ); + goto error_ac97_ops; + } + } + ret =snd_soc_register_component (&pdev->dev, &fsl_ssi_component, &ssi_private->cpu_dai_drv,1 );if (ret) {
@@ -1400,6 +1402,10 @@ error_irq:snd_soc_unregister_component (&pdev->dev); error_asoc_register: +if (fsl_ssi_is_ac97 (ssi_private)) +snd_soc_set_ac97_ops (NULL ); + +error_ac97_ops:if (ssi_private->soc->imx)fsl_ssi_imx_clean (pdev, ssi_private);
PATCH 16/254 blktrace: fix trace mutex deadlock
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
commit 2967acbb257a6a9bf912f4778b727e00972eac9b upstream.
A previous commit changed the locking around registration/cleanup, but direct callers of blk_trace_remove() were missed. This means that if we hit the error path in setup, we will deadlock on attempting to re-acquire the queue trace mutex.
--- kernel/trace/blktrace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/blktrace.c +2 -2
@@ -562,7 +562,7 @@ static int __blk_trace_setup(struct requreturn ret;if (copy_to_user (arg, &buts,sizeof (buts))) { -blk_trace_remove (q); +__blk_trace_remove (q);return -EFAULT ; }return 0 ;
@@ -608,7 +608,7 @@ static int compat_blk_trace_setup(structreturn ret;if (copy_to_user (arg, &buts.name,ARRAY_SIZE (buts.name))) { -blk_trace_remove (q); +__blk_trace_remove (q);return -EFAULT ; }
PATCH 17/254 hwmon: (pmbus) Use 64bit math for DIRECT format values
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Robert Lippert <[email protected]>
commit bd467e4eababe4c04272c1e646f066db02734c79 upstream.
Power values in the 100s of watt range can easily blow past 32bit math limits when processing everything in microwatts.
Use 64bit math instead to avoid these issues on common 32bit ARM BMC platforms.
--- drivers/hwmon/pmbus/pmbus_core.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
drivers/hwmon/pmbus/pmbus_core.c +12 -9
@@ -20,6 +20,7 @@*/ #include <linux/kernel.h> +#include <linux/math64.h> #include <linux/module.h> #include <linux/init.h> #include <linux/err.h>
@@ -443,8 +444,8 @@ static long pmbus_reg2data_linear(structstatic long pmbus_reg2data_direct (struct pmbus_data *data,struct pmbus_sensor *sensor) { -long val = (s16 ) sensor->data; -long m, b,R ; +s64 b, val = (s16 )sensor->data; +s32 m,R ; m = data->info->m[sensor->class]; b = data->info->b[sensor->class];
@@ -472,11 +473,12 @@ static long pmbus_reg2data_direct(structR --; }while (R <0 ) { - val =DIV_ROUND_CLOSEST (val,10 ); + val =div_s64 (val +5LL ,10L );/* round closest */ R ++; } -return (val - b) / m; + val =div_s64 (val - b, m); +return clamp_val (val,LONG_MIN ,LONG_MAX ); }/*
@@ -588,7 +590,8 @@ static u16 pmbus_data2reg_linear(structstatic u16 pmbus_data2reg_direct (struct pmbus_data *data,struct pmbus_sensor *sensor,long val) { -long m, b,R ; +s64 b, val64 = val; +s32 m,R ; m = data->info->m[sensor->class]; b = data->info->b[sensor->class];
@@ -605,18 +608,18 @@ static u16 pmbus_data2reg_direct(structR -=3 ;/* Adjust R and b for data in milli-units */ b *=1000 ; } - val = val * m + b; + val64 = val64 * m + b;while (R >0 ) { - val *=10 ; + val64 *=10 ;R --; }while (R <0 ) { - val =DIV_ROUND_CLOSEST (val,10 ); + val64 =div_s64 (val64 +5LL ,10L );/* round closest */ R ++; } -return val; +return (u16 )clamp_val (val64,S16_MIN ,S16_MAX ); } static u16 pmbus_data2reg_vid(struct pmbus_data *data,
PATCH 18/254 drm/i915: Don't try indexed reads to alternate slave addresses
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit ae5c631e605a452a5a0e73205a92810c01ed954b upstream.
We can only specify the one slave address to indexed reads/writes. Make sure the messages we check are destined to the same slave address before deciding to do an indexed transfer.
--- drivers/gpu/drm/i915/intel_i2c.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/i915/intel_i2c.c +1 -0
@@ -448,6 +448,7 @@ static bool gmbus_is_index_read(struct i2c_msg *msgs, int i, int num) { return (i + 1 < num && + msgs[i].addr == msgs[i + 1].addr && !(msgs[i].flags & I2C_M_RD) && msgs[i].len <= 2 && (msgs[i + 1].flags & I2C_M_RD)); }
PATCH 19/254 drm/i915: Prevent zero length "index" write
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit 56350fb8978bbf4aafe08f21234e161dd128b417 upstream.
The hardware always writes one or two bytes in the index portion of an indexed transfer. Make sure the message we send as the index doesn't have a zero length.
--- drivers/gpu/drm/i915/intel_i2c.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_i2c.c +2 -1
@@ -449,7 +449,8 @@ gmbus_is_index_read(struct i2c_msg *msgs {return (i +1 < num && msgs[i].addr == msgs[i +1 ].addr && - !(msgs[i].flags &I2C_M_RD ) && msgs[i].len <=2 && + !(msgs[i].flags &I2C_M_RD ) && + (msgs[i].len ==1 || msgs[i].len ==2 ) && (msgs[i +1 ].flags &I2C_M_RD )); }
PATCH 20/254 usb: gadget: don't dereference g until after it has been null checked
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Colin Ian King <[email protected]>
commit b2fc059fa549fe6881d4c1f8d698b0f50bcd16ec upstream.
Avoid dereferencing pointer g until after g has been sanity null checked; move the assignment of cdev much later when it is required into a more local scope.
Detected by CoverityScan, CID#1222135 ("Dereference before null check")
--- drivers/usb/gadget/composite.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/usb/gadget/composite.c +5 -2
@@ -103,7 +103,6 @@ int config_ep_by_speed(struct usb_gadgetstruct usb_function *f, struct usb_ep *_ep) { - struct usb_composite_dev *cdev = get_gadget_data(g); struct usb_endpoint_descriptor *chosen_desc = NULL;struct usb_descriptor_header **speed_desc =NULL ;
@@ -175,8 +174,12 @@ ep_found: _ep->maxburst = comp_desc->bMaxBurst +1 ;break ;default : -if (comp_desc->bMaxBurst !=0 ) +if (comp_desc->bMaxBurst !=0 ) { +struct usb_composite_dev *cdev; + + cdev =get_gadget_data (g);ERROR (cdev,"ep0 bMaxBurst must be 0\n" ); + } _ep->maxburst =1 ;break ; }
PATCH 21/254 USB: usbfs: Filter flags passed in from user space
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit 446f666da9f019ce2ffd03800995487e79a91462 upstream.
USBDEVFS_URB_ISO_ASAP must be accepted only for ISO endpoints. Improve sanity checking.
--- drivers/usb/core/devio.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/usb/core/devio.c +9 -5
@@ -1295,14 +1295,18 @@ static int proc_do_submiturb(struct usb_int number_of_packets =0 ;unsigned int stream_id =0 ;void *buf; - -if (uurb->flags & ~(USBDEVFS_URB_ISO_ASAP | -USBDEVFS_URB_SHORT_NOT_OK | +unsigned long mask =USBDEVFS_URB_SHORT_NOT_OK |USBDEVFS_URB_BULK_CONTINUATION |USBDEVFS_URB_NO_FSBR |USBDEVFS_URB_ZERO_PACKET | -USBDEVFS_URB_NO_INTERRUPT )) -return -EINVAL ; +USBDEVFS_URB_NO_INTERRUPT ; +/* USBDEVFS_URB_ISO_ASAP is a special case */ +if (uurb->type ==USBDEVFS_URB_TYPE_ISO ) + mask |=USBDEVFS_URB_ISO_ASAP ; + +if (uurb->flags & ~mask) +return -EINVAL ; +if (uurb->buffer_length >0 && !uurb->buffer)return -EINVAL ; if (!(uurb->type == USBDEVFS_URB_TYPE_CONTROL &&
PATCH 22/254 usb: host: fix incorrect updating of offset
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Colin Ian King <[email protected]>
commit 1d5a31582ef046d3b233f0da1a68ae26519b2f0a upstream.
The variable temp is incorrectly being updated, instead it should be offset otherwise the loop just reads the same capability value and loops forever. Thanks to Alan Stern for pointing out the correct fix to my original fix. Fix also cleans up clang warning:
drivers/usb/host/ehci-dbg.c:840:4: warning: Value stored to 'temp' is never read
--- drivers/usb/host/ehci-dbg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/ehci-dbg.c +1 -1
@@ -850,7 +850,7 @@ static ssize_t fill_registers_buffer(strdefault :/* unknown */ break; } - temp = (cap >>8 ) &0xff ; + offset = (cap >>8 ) &0xff ; } }#endif
PATCH 23/254 USB: core: Add type-specific length check of BOS descriptors
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Masakazu Mokuno <[email protected]>
commit 81cf4a45360f70528f1f64ba018d61cb5767249a upstream.
As most of BOS descriptors are longer in length than their header 'struct usb_dev_cap_header', comparing solely with it is not sufficient to avoid out-of-bounds access to BOS descriptors.
This patch adds descriptor type specific length check in usb_get_bos_descriptor() to fix the issue.
---
drivers/usb/core/config.c +15 -1
@@ -871,6 +871,13 @@ void usb_release_bos_descriptor(struct u } } +static const __u8 bos_desc_len[256 ] = { + [USB_CAP_TYPE_WIRELESS_USB ] =USB_DT_USB_WIRELESS_CAP_SIZE , + [USB_CAP_TYPE_EXT ] =USB_DT_USB_EXT_CAP_SIZE , + [USB_SS_CAP_TYPE ] =USB_DT_USB_SS_CAP_SIZE , + [CONTAINER_ID_TYPE ] =USB_DT_USB_SS_CONTN_ID_SIZE , +}; +/* Get BOS descriptor set */ int usb_get_bos_descriptor (struct usb_device *dev) {
@@ -879,6 +886,7 @@ int usb_get_bos_descriptor(struct usb_destruct usb_dev_cap_header *cap;unsigned char *buffer;int length, total_len, num, i; +__u8 cap_type;int ret; bos =kzalloc (sizeof (struct usb_bos_descriptor ),GFP_KERNEL );
@@ -931,7 +939,13 @@ int usb_get_bos_descriptor(struct usb_de dev->bos->desc->bNumDeviceCaps = i;break ; } + cap_type = cap->bDevCapabilityType; length = cap->bLength; +if (bos_desc_len[cap_type] && length < bos_desc_len[cap_type]) { + dev->bos->desc->bNumDeviceCaps = i; +break ; + } + total_len -= length;if (cap->bDescriptorType !=USB_DT_DEVICE_CAPABILITY ) {
@@ -939,7 +953,7 @@ int usb_get_bos_descriptor(struct usb_decontinue ; } -switch (cap->bDevCapabilityType) { +switch (cap_type) {case USB_CAP_TYPE_WIRELESS_USB :/* Wireless USB cap descriptor is handled by wusb */ break ;
include/uapi/linux/usb/ch9.h +2 -0
@@ -819,6 +819,8 @@ struct usb_wireless_cap_descriptor { /*__u8 bReserved; } __attribute__((packed)); +#define USB_DT_USB_WIRELESS_CAP_SIZE 11 +/* USB 2.0 Extension descriptor */ #define USB_CAP_TYPE_EXT 2
PATCH 24/254 usb: hub: Cycle HUB power when initialization fails
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mike Looijmans <[email protected]>
commit 973593a960ddac0f14f0d8877d2d0abe0afda795 upstream.
Sometimes the USB device gets confused about the state of the initialization and the connection fails. In particular, the device thinks that it's already set up and running while the host thinks the device still needs to be configured. To work around this issue, power-cycle the hub's output to issue a sort of "reset" to the device. This makes the device restart its state machine and then the initialization succeeds.
This fixes problems where the kernel reports a list of errors like this:
usb 1-1.3: device not accepting address 19, error -71
The end result is a non-functioning device. After this patch, the sequence becomes like this:
usb 1-1.3: new high-speed USB device number 18 using ci_hdrc usb 1-1.3: device not accepting address 18, error -71 usb 1-1.3: new high-speed USB device number 19 using ci_hdrc usb 1-1.3: device not accepting address 19, error -71 usb 1-1-port3: attempt power cycle
usb 1-1.3: new high-speed USB device number 21 using ci_hdrc usb-storage 1-1.3:1.2: USB Mass Storage device detected
--- drivers/usb/core/hub.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/usb/core/hub.c +9 -0
@@ -4792,6 +4792,15 @@ loop:usb_put_dev (udev);if ((status == -ENOTCONN ) || (status == -ENOTSUPP ))break ; + +/* When halfway through our retry count, power-cycle the port */ +if (i == (SET_CONFIG_TRIES /2 ) -1 ) { +dev_info (&port_dev->dev,"attempt power cycle\n" ); +usb_hub_set_port_power (hdev, hub, port1, false); +msleep (2 *hub_power_on_good_delay (hub)); +usb_hub_set_port_power (hdev, hub, port1, true); +msleep (hub_power_on_good_delay (hub)); + } } if (hub->hdev->parent || !hcd->driver->port_handed_over ||
PATCH 25/254 usb: quirks: Add no-lpm quirk for KY-688 USB 3.1 Type-C Hub
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Kai-Heng Feng <[email protected]>
commit e43a12f1793ae1fe006e26fe9327a8840a92233c upstream.
KY-688 USB 3.1 Type-C Hub internally uses a Genesys Logic hub to connect to Realtek r8153.
Similar to commit ("7496cfe5431f2 usb: quirks: Add no-lpm quirk for Moshi USB to Ethernet Adapter"), no-lpm can make r8153 ethernet work.
--- drivers/usb/core/quirks.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/core/quirks.c +3 -0
@@ -148,6 +148,9 @@ static const struct usb_device_id usb_qu/* appletouch */ { USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME }, + /* Genesys Logic hub, internally used by KY-688 USB 3.1 Type-C Hub */ + { USB_DEVICE(0x05e3, 0x0612), .driver_info = USB_QUIRK_NO_LPM }, + /* Genesys Logic hub, internally used by Moshi USB to Ethernet Adapter */ { USB_DEVICE(0x05e3, 0x0616), .driver_info = USB_QUIRK_NO_LPM },
PATCH 26/254 uas: Always apply US_FL_NO_ATA_1X quirk to Seagate devices
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit 7fee72d5e8f1e7b8d8212e28291b1a0243ecf2f1 upstream.
We've been adding this as a quirk on a per device basis hoping that newer disk enclosures would do better, but that has not happened, so simply apply this quirk to all Seagate devices.
--- drivers/usb/storage/uas-detect.h | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/storage/uas-detect.h +4 -0
@@ -111,6 +111,10 @@ static int uas_use_uas_driver(struct usb } } +/* All Seagate disk enclosures have broken ATA pass-through support */ +if (le16_to_cpu (udev->descriptor.idVendor) ==0x0bc2 ) + flags |=US_FL_NO_ATA_1X ; +usb_stor_adjust_quirks (udev, &flags);if (flags &US_FL_IGNORE_UAS ) {
PATCH 27/254 serial: 8250_pci: Add Amazon PCI serial device ID
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Matt Wilson <[email protected]>
commit 3bfd1300abfe3adb18e84a89d97a0e82a22124bb upstream.
This device will be used in future Amazon EC2 instances as the primary serial port (i.e., data sent to this port will be available via the GetConsoleOuput [1] EC2 API).
[1] http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_GetConsoleOutput.html
--- drivers/tty/serial/8250/8250_pci.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/tty/serial/8250/8250_pci.c +3 -0
@@ -5542,6 +5542,9 @@ static struct pci_device_id serial_pci_t { PCI_DEVICE(0x1601, 0x0800), .driver_data = pbn_b0_4_1250000 }, { PCI_DEVICE(0x1601, 0xa801), .driver_data = pbn_b0_4_1250000 }, + /* Amazon PCI serial device */ + { PCI_DEVICE(0x1d0f, 0x8250), .driver_data = pbn_b0_1_115200 }, +/* * These entries match devices with class COMMUNICATION_SERIAL, * COMMUNICATION_MODEM or COMMUNICATION_MULTISERIAL
PATCH 28/254 isa: Prevent NULL dereference in isa_bus driver callbacks
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: William Breathitt Gray <[email protected]>
commit 5a244727f428a06634f22bb890e78024ab0c89f3 upstream.
The isa_driver structure for an isa_bus device is stored in the device platform_data member of the respective device structure. This platform_data member may be reset to NULL if isa_driver match callback for the device fails, indicating a device unsupported by the ISA driver.
This patch fixes a possible NULL pointer dereference if one of the isa_driver callbacks to attempted for an unsupported device. This error should not occur in practice since ISA devices are typically manually configured and loaded by the users, but we may as well prevent this error from popping up for the 0day testers.
--- drivers/base/isa.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/base/isa.c +5 -5
@@ -39,7 +39,7 @@ static int isa_bus_probe(struct device * {struct isa_driver *isa_driver = dev->platform_data; -if (isa_driver->probe) +if (isa_driver && isa_driver->probe)return isa_driver->probe (dev,to_isa_dev (dev)->id);return 0 ;
@@ -49,7 +49,7 @@ static int isa_bus_remove(struct device {struct isa_driver *isa_driver = dev->platform_data; -if (isa_driver->remove) +if (isa_driver && isa_driver->remove)return isa_driver->remove (dev,to_isa_dev (dev)->id);return 0 ;
@@ -59,7 +59,7 @@ static void isa_bus_shutdown(struct devi {struct isa_driver *isa_driver = dev->platform_data; -if (isa_driver->shutdown) +if (isa_driver && isa_driver->shutdown) isa_driver->shutdown (dev,to_isa_dev (dev)->id); }
@@ -67,7 +67,7 @@ static int isa_bus_suspend(struct device {struct isa_driver *isa_driver = dev->platform_data; -if (isa_driver->suspend) +if (isa_driver && isa_driver->suspend)return isa_driver->suspend (dev,to_isa_dev (dev)->id, state);return 0 ;
@@ -77,7 +77,7 @@ static int isa_bus_resume(struct device {struct isa_driver *isa_driver = dev->platform_data; -if (isa_driver->resume) +if (isa_driver && isa_driver->resume)return isa_driver->resume (dev,to_isa_dev (dev)->id);return 0 ;
PATCH 29/254 hv: kvp: Avoid reading past allocated blocks from KVP file
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paul Meyer <[email protected]>
commit 297d6b6e56c2977fc504c61bbeeaa21296923f89 upstream.
While reading in more than one block (50) of KVP records, the allocation goes per block, but the reads used the total number of allocated records (without resetting the pointer/stream). This causes the records buffer to overrun when the refresh reads more than one block over the previous capacity (e.g. reading more than 100 KVP records whereas the in-memory database was empty before).
Fix this by reading the correct number of KVP records from file each time.
--- tools/hv/hv_kvp_daemon.c | 70 ++++++++++-------------------------------------- 1 file changed, 14 insertions(+), 56 deletions(-)
tools/hv/hv_kvp_daemon.c +14 -56
@@ -196,11 +196,14 @@ static void kvp_update_mem_state(int poofor (;;) { readp = &record[records_read]; records_read +=fread (readp,sizeof (struct kvp_record ), -ENTRIES_PER_BLOCK * num_blocks, - filep); +ENTRIES_PER_BLOCK * num_blocks - records_read, + filep);if (ferror (filep)) { -syslog (LOG_ERR ,"Failed to read file, pool: %d" , pool); +syslog (LOG_ERR , +"Failed to read file, pool: %d; error: %d %s" , + pool, errno,strerror (errno)); +kvp_release_lock (pool);exit (EXIT_FAILURE ); }
@@ -213,6 +216,7 @@ static void kvp_update_mem_state(int pooif (record ==NULL ) {syslog (LOG_ERR ,"malloc failed" ); +kvp_release_lock (pool);exit (EXIT_FAILURE ); }continue ;
@@ -227,15 +231,11 @@ static void kvp_update_mem_state(int poofclose (filep);kvp_release_lock (pool); } +static int kvp_file_init (void ) {int fd; -FILE *filep; -size_t records_read;char *fname; -struct kvp_record *record; -struct kvp_record *readp; -int num_blocks;int i;int alloc_unit =sizeof (struct kvp_record ) *ENTRIES_PER_BLOCK ;
@@ -249,61 +249,19 @@ static int kvp_file_init(void)for (i =0 ; i <KVP_POOL_COUNT ; i++) { fname = kvp_file_info[i].fname; - records_read =0 ; - num_blocks =1 ;sprintf (fname,"%s/.kvp_pool_%d" ,KVP_CONFIG_LOC , i); fd =open (fname,O_RDWR |O_CREAT |O_CLOEXEC ,0644 /* rw-r--r-- */ );if (fd ==-1 )return 1 ; - - filep =fopen (fname,"re" ); -if (!filep) { -close (fd); -return 1 ; - } - - record =malloc (alloc_unit * num_blocks); -if (record ==NULL ) { -fclose (filep); -close (fd); -return 1 ; - } -for (;;) { - readp = &record[records_read]; - records_read +=fread (readp,sizeof (struct kvp_record ), -ENTRIES_PER_BLOCK , - filep); - -if (ferror (filep)) { -syslog (LOG_ERR ,"Failed to read file, pool: %d" , - i); -exit (EXIT_FAILURE ); - } - -if (!feof (filep)) { -/* -* We have more data to read. -*/ - num_blocks++; - record =realloc (record, alloc_unit * - num_blocks); -if (record ==NULL ) { -fclose (filep); -close (fd); -return 1 ; - } -continue ; - } -break ; - } kvp_file_info[i].fd = fd; - kvp_file_info[i].num_blocks = num_blocks; - kvp_file_info[i].records = record; - kvp_file_info[i].num_records = records_read; -fclose (filep); - + kvp_file_info[i].num_blocks =1 ; + kvp_file_info[i].records =malloc (alloc_unit); +if (kvp_file_info[i].records ==NULL ) +return 1 ; + kvp_file_info[i].num_records =0 ; +kvp_update_mem_state (i); }return 0 ;
PATCH 30/254 sctp: force the params with right types for sctp csum apis
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
commit af2697a0273f7665429c47d71ab26f2412af924e upstream.
Now sctp_csum_xxx doesn't really match the param types of these common csum apis. As sctp_csum_xxx is defined in sctp/checksum.h, many sparse errors occur when make C=2 not only with M=net/sctp but also with other modules that include this header file.
This patch is to force them fit in csum apis with the right types.
--- include/net/sctp/checksum.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
include/net/sctp/checksum.h +7 -6
@@ -48,31 +48,32 @@ static inline __wsum sctp_csum_update(co/* This uses the crypto implementation of crc32c, which is either * implemented w/ hardware support or resolves to __crc32c_le(). */ - return crc32c(sum, buff, len); +return (__force __wsum )crc32c ((__force __u32 )sum, buff, len); }static inline __wsum sctp_csum_combine (__wsum csum,__wsum csum2,int offset,int len) { -return __crc32c_le_combine (csum, csum2, len); +return (__force __wsum )__crc32c_le_combine ((__force __u32 )csum, + (__force __u32 )csum2, len); }static inline __le32 sctp_compute_cksum (const struct sk_buff *skb,unsigned int offset) {struct sctphdr *sh =sctp_hdr (skb); -__le32 ret, old = sh->checksum;const struct skb_checksum_ops ops = { .update = sctp_csum_update, .combine = sctp_csum_combine, }; +__le32 old = sh->checksum; +__wsum new; sh->checksum =0 ; - ret =cpu_to_le32 (~__skb_checksum (skb, offset, skb->len - offset, - ~(__u32 )0 , &ops)); + new = ~__skb_checksum (skb, offset, skb->len - offset, ~(__wsum )0 , &ops); sh->checksum = old; -return ret; +return cpu_to_le32 ((__force __u32 )new); }#endif /* __sctp_checksum_h__ */
PATCH 31/254 net/packet: fix a race in packet_bind() and packet_notifier()
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit 15fe076edea787807a7cdc168df832544b58eba6 upstream.
syzbot reported crashes [1] and provided a C repro easing bug hunting.
When/if packet_do_bind() calls __unregister_prot_hook() and releases po->bind_lock, another thread can run packet_notifier() and process an NETDEV_UP event.
This calls register_prot_hook() and hooks again the socket right before first thread is able to grab again po->bind_lock.
Fixes this issue by temporarily setting po->num to 0, as suggested by David Miller.
[1]dev_remove_pack: ffff8801bf16fa80 not found
------------[ cut here ]------------ kernel BUG at net/core/dev.c:7945! ( BUG_ON(!list_empty(&dev->ptype_all)); ) invalid opcode: 0000 [#1] SMP KASAN Dumping ftrace buffer: (ftrace buffer empty) Modules linked in: device syz0 entered promiscuous mode CPU: 0 PID: 3161 Comm: syzkaller404108 Not tainted 4.14.0+ #190 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 task: ffff8801cc57a500 task.stack: ffff8801cc588000 RIP: 0010:netdev_run_todo+0x772/0xae0 net/core/dev.c:7945 RSP: 0018:ffff8801cc58f598 EFLAGS: 00010293 RAX: ffff8801cc57a500 RBX: dffffc0000000000 RCX: ffffffff841f75b2 RDX: 0000000000000000 RSI: 1ffff100398b1ede RDI: ffff8801bf1f8810 device syz0 entered promiscuous mode RBP: ffff8801cc58f898 R08: 0000000000000001 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: ffff8801bf1f8cd8 R13: ffff8801cc58f870 R14: ffff8801bf1f8780 R15: ffff8801cc58f7f0 FS: 0000000001716880(0000) GS:ffff8801db400000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000020b13000 CR3: 0000000005e25000 CR4: 00000000001406f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: rtnl_unlock+0xe/0x10 net/core/rtnetlink.c:106 tun_detach drivers/net/tun.c:670 [inline] tun_chr_close+0x49/0x60 drivers/net/tun.c:2845 __fput+0x333/0x7f0 fs/file_table.c:210 ____fput+0x15/0x20 fs/file_table.c:244 task_work_run+0x199/0x270 kernel/task_work.c:113 exit_task_work include/linux/task_work.h:22 [inline] do_exit+0x9bb/0x1ae0 kernel/exit.c:865 do_group_exit+0x149/0x400 kernel/exit.c:968 SYSC_exit_group kernel/exit.c:979 [inline] SyS_exit_group+0x1d/0x20 kernel/exit.c:977 entry_SYSCALL_64_fastpath+0x1f/0x96 RIP: 0033:0x44ad19
--- net/packet/af_packet.c | 5 +++++ 1 file changed, 5 insertions(+)
net/packet/af_packet.c +5 -0
@@ -2732,6 +2732,10 @@ static int packet_do_bind(struct sock *sif (need_rehook) {if (po->running) {rcu_read_unlock (); +/* prevents packet_notifier() from calling +* register_prot_hook() +*/ + po->num =0 ;__unregister_prot_hook (sk, true);rcu_read_lock (); dev_curr = po->prot_hook.dev;
@@ -2740,6 +2744,7 @@ static int packet_do_bind(struct sock *s dev->ifindex); } +BUG_ON (po->running); po->num = proto; po->prot_hook.type = proto;
PATCH 32/254 eeprom: at24: check at24_read/write arguments
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Heiner Kallweit <[email protected]>
commit d9bcd462daf34aebb8de9ad7f76de0198bb5a0f0 upstream.
So far we completely rely on the caller to provide valid arguments. To be on the safe side perform an own sanity check.
--- drivers/misc/eeprom/at24.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/misc/eeprom/at24.c +6 -0
@@ -274,6 +274,9 @@ static ssize_t at24_read(struct at24_datif (unlikely (!count))return count; +if (off + count > at24->chip.byte_len) +return -EINVAL ; +/* * Read data from chip, protecting against concurrent updates * from this host, but not from other I2C masters.
@@ -396,6 +399,9 @@ static ssize_t at24_write(struct at24_daif (unlikely (!count))return count; +if (off + count > at24->chip.byte_len) +return -EINVAL ; +/* * Write data to chip, protecting against concurrent updates * from this host, but not from other I2C masters.
PATCH 33/254 arm64: KVM: fix VTTBR_BADDR_MASK BUG_ON off-by-one
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Kristina Martsenko <[email protected]>
commit 26aa7b3b1c0fb3f1a6176a0c1847204ef4355693 upstream.
VTTBR_BADDR_MASK is used to sanity check the size and alignment of the VTTBR address. It seems to currently be off by one, thereby only allowing up to 47-bit addresses (instead of 48-bit) and also insufficiently checking the alignment. This patch fixes it.
As an example, with 4k pages, before this patch we have:
PHYS_MASK_SHIFT = 48
VTTBR_X = 37 - 24 = 13
VTTBR_BADDR_SHIFT = 13 - 1 = 12
VTTBR_BADDR_MASK = ((1 << 35) - 1) << 12 = 0x00007ffffffff000
Which is wrong, because the mask doesn't allow bit 47 of the VTTBR address to be set, and only requires the address to be 12-bit (4k) aligned, while it actually needs to be 13-bit (8k) aligned because we concatenate two 4k tables.
With this patch, the mask becomes 0x0000ffffffffe000, which is what we want.
--- arch/arm64/include/asm/kvm_arm.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/include/asm/kvm_arm.h +1 -2
@@ -164,8 +164,7 @@#define VTTBR_X (37 - VTCR_EL2_T0SZ_40B)#endif -#define VTTBR_BADDR_SHIFT (VTTBR_X - 1) -#define VTTBR_BADDR_MASK (((UL(1) << (PHYS_MASK_SHIFT - VTTBR_X)) - 1) << VTTBR_BADDR_SHIFT) +#define VTTBR_BADDR_MASK (((UL(1) << (PHYS_MASK_SHIFT - VTTBR_X)) - 1) << VTTBR_X)#define VTTBR_VMID_SHIFT (UL(48))#define VTTBR_VMID_MASK (UL(0xFF) << VTTBR_VMID_SHIFT)
PATCH 34/254 arm: KVM: Fix VTTBR_BADDR_MASK BUG_ON off-by-one
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
commit 5553b142be11e794ebc0805950b2e8313f93d718 upstream.
VTTBR_BADDR_MASK is used to sanity check the size and alignment of the VTTBR address. It seems to currently be off by one, thereby only allowing up to 39-bit addresses (instead of 40-bit) and also insufficiently checking the alignment. This patch fixes it.
This patch is the 32bit pendent of Kristina's arm64 fix, and she deserves the actual kudos for pinpointing that one.
--- arch/arm/include/asm/kvm_arm.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/include/asm/kvm_arm.h +1 -2
@@ -161,8 +161,7 @@#else #define VTTBR_X (5 - KVM_T0SZ)#endif -#define VTTBR_BADDR_SHIFT (VTTBR_X - 1) -#define VTTBR_BADDR_MASK (((1LLU << (40 - VTTBR_X)) - 1) << VTTBR_BADDR_SHIFT) +#define VTTBR_BADDR_MASK (((1LLU << (40 - VTTBR_X)) - 1) << VTTBR_X)#define VTTBR_VMID_SHIFT (48LLU)#define VTTBR_VMID_MASK (0xffLLU << VTTBR_VMID_SHIFT)
PATCH 35/254 quota: Check for register_shrinker() failure.
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Tetsuo Handa <[email protected]>
commit 88bc0ede8d35edc969350852894dc864a2dc1859 upstream.
register_shrinker() might return -ENOMEM error since Linux 3.12. Call panic() as with other failure checks in this function if register_shrinker() failed.
--- fs/quota/dquot.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/quota/dquot.c +2 -1
@@ -2747,7 +2747,8 @@ static int __init dquot_init(void)printk ("Dquot-cache hash table entries: %ld (order %ld, %ld bytes)\n" , nr_hash, order, (PAGE_SIZE << order)); -register_shrinker (&dqcache_shrinker); +if (register_shrinker (&dqcache_shrinker)) +panic ("Cannot register dquot shrinker" );return 0 ; }
PATCH 36/254 mfd: cros ec: spi: Don't send first message too soon
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jon Hunter <[email protected]>
commit 15d8374874ded0bec37ef27f8301a6d54032c0e5 upstream.
On the Tegra124 Nyan-Big chromebook the very first SPI message sent to the EC is failing.
The Tegra SPI driver configures the SPI chip-selects to be active-high by default (and always has for many years). The EC SPI requires an active-low chip-select and so the Tegra chip-select is reconfigured to be active-low when the EC SPI driver calls spi_setup(). The problem is that if the first SPI message to the EC is sent too soon after reconfiguring the SPI chip-select, it fails.
The EC SPI driver prevents back-to-back SPI messages being sent too soon by keeping track of the time the last transfer was sent via the variable 'last_transfer_ns'. To prevent the very first transfer being sent too soon, initialise the 'last_transfer_ns' variable after calling spi_setup() and before sending the first SPI message.
---
drivers/mfd/cros_ec_spi.c +4 -0
@@ -347,6 +347,7 @@ static int cros_ec_spi_probe(struct spi_struct device *dev = &spi->dev;struct cros_ec_device *ec_dev;struct cros_ec_spi *ec_spi; +struct timespec ts;int err; spi->bits_per_word =8 ;
@@ -379,6 +380,9 @@ static int cros_ec_spi_probe(struct spi_ ec_dev->din_size =EC_MSG_BYTES +EC_MSG_PREAMBLE_COUNT ; ec_dev->dout_size =EC_MSG_BYTES ; +ktime_get_ts (&ts); + ec_spi->last_transfer_ns =timespec_to_ns (&ts); + err =cros_ec_register (ec_dev);if (err) {dev_err (dev,"cannot register EC\n" );
PATCH 37/254 mfd: twl4030-audio: Fix sibling-node lookup
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 0a423772de2f3d7b00899987884f62f63ae00dcb upstream.
A helper purported to look up a child node based on its name was using the wrong of-helper and ended up prematurely freeing the parent of-node while leaking any matching node.
To make things worse, any matching node would not even necessarily be a child node as the whole device tree was searched depth-first starting at the parent.
--- drivers/mfd/twl4030-audio.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/mfd/twl4030-audio.c +7 -2
@@ -159,13 +159,18 @@ unsigned int twl4030_audio_get_mclk(voidEXPORT_SYMBOL_GPL (twl4030_audio_get_mclk);static bool twl4030_audio_has_codec (struct twl4030_audio_data *pdata, -struct device_node *node) +struct device_node *parent) { +struct device_node *node; +if (pdata && pdata->codec)return true; -if (of_find_node_by_name (node,"codec" )) + node =of_get_child_by_name (parent,"codec" ); +if (node) { +of_node_put (node);return true; + }return false; }
PATCH 38/254 mfd: twl6040: Fix child-node lookup
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 85e9b13cbb130a3209f21bd7933933399c389ffe upstream.
Fix child-node lookup during probe, which ended up searching the whole device tree depth-first starting at the parent rather than just matching on its children.
To make things worse, the parent node was prematurely freed, while the child node was leaked.
Note that the CONFIG_OF compile guard can be removed as of_get_child_by_name() provides a !CONFIG_OF implementation which always fails.
--- drivers/mfd/twl6040.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/mfd/twl6040.c +8 -4
@@ -97,12 +97,16 @@ static struct reg_default twl6040_patch[ }; -static bool twl6040_has_vibra (struct device_node *node) +static bool twl6040_has_vibra (struct device_node *parent) { -#ifdef CONFIG_OF -if (of_find_node_by_name (node,"vibra" )) +struct device_node *node; + + node =of_get_child_by_name (parent,"vibra" ); +if (node) { +of_node_put (node);return true; -#endif + } +return false; }
PATCH 39/254 ALSA: seq: Remove spurious WARN_ON() at timer check
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 43a3542870328601be02fcc9d27b09db467336ef upstream.
The use of snd_BUG_ON() in ALSA sequencer timer may lead to a spurious WARN_ON() when a slave timer is deployed as its backend and a corresponding master timer stops meanwhile. The symptom was triggered by syzkaller spontaneously.
Since the NULL timer is valid there, rip off snd_BUG_ON().
--- sound/core/seq/seq_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/seq/seq_timer.c +1 -1
@@ -355,7 +355,7 @@ static int initialize_timer(struct snd_sunsigned long freq; t = tmr->timeri->timer; -if (snd_BUG_ON (!t)) +if (!t)return -EINVAL ; freq = tmr->preferred_resolution;
PATCH 40/254 media: dvb: i2c transfers over usb cannot be done from stack
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Laurent Caumont <[email protected]>
commit 6d33377f2abbf9f0e561b116dd468d1c3ff36a6a upstream.
--- drivers/media/usb/dvb-usb/dibusb-common.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/media/usb/dvb-usb/dibusb-common.c +14 -2
@@ -179,8 +179,20 @@ EXPORT_SYMBOL(dibusb_i2c_algo);int dibusb_read_eeprom_byte (struct dvb_usb_device *d,u8 offs,u8 *val) { -u8 wbuf[1 ] = { offs }; -return dibusb_i2c_msg (d,0x50 , wbuf,1 , val,1 ); +u8 *buf; +int rc; + + buf =kmalloc (2 ,GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + + buf[0 ] = offs; + + rc =dibusb_i2c_msg (d,0x50 , &buf[0 ],1 , &buf[1 ],1 ); + *val = buf[1 ]; +kfree (buf); + +return rc; }EXPORT_SYMBOL (dibusb_read_eeprom_byte);
PATCH 41/254 can: kvaser_usb: free buf in error paths
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jimmy Assarsson <[email protected]>
commit 435019b48033138581a6171093b181fc6b4d3d30 upstream.
The allocated buffer was not freed if usb_submit_urb() failed.
--- drivers/net/can/usb/kvaser_usb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/can/usb/kvaser_usb.c +2 -0
@@ -608,6 +608,7 @@ static int kvaser_usb_simple_msg_async(sif (err) {netdev_err (netdev,"Error transmitting URB\n" );usb_unanchor_urb (urb); +kfree (buf);usb_free_urb (urb);return err; }
@@ -1406,6 +1407,7 @@ static netdev_tx_t kvaser_usb_start_xmitspin_unlock_irqrestore (&priv->tx_contexts_lock, flags);usb_unanchor_urb (urb); +kfree (buf); stats->tx_dropped++;
PATCH 42/254 can: kvaser_usb: Fix comparison bug in kvaser_usb_read_bulk_callback()
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jimmy Assarsson <[email protected]>
commit e84f44eb5523401faeb9cc1c97895b68e3cfb78d upstream.
The conditon in the while-loop becomes true when actual_length is less than 2 (MSG_HEADER_LEN). In best case we end up with a former, already dispatched msg, that got msg->len greater than actual_length. This will result in a "Format error" error printout.
Problem seen when unplugging a Kvaser USB device connected to a vbox guest.
warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
--- drivers/net/can/usb/kvaser_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/usb/kvaser_usb.c +1 -1
@@ -983,7 +983,7 @@ static void kvaser_usb_read_bulk_callbac goto resubmit_urb; } -while (pos <= urb->actual_length -MSG_HEADER_LEN ) { +while (pos <= (int )(urb->actual_length -MSG_HEADER_LEN )) { msg = urb->transfer_buffer + pos;/* The Kvaser firmware can only read and write messages that
PATCH 43/254 can: kvaser_usb: ratelimit errors if incomplete messages are received
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jimmy Assarsson <[email protected]>
commit 8bd13bd522ff7dfa0eb371921aeb417155f7a3be upstream.
Avoid flooding the kernel log with "Formate error", if incomplete message are received.
--- drivers/net/can/usb/kvaser_usb.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/can/usb/kvaser_usb.c +4 -3
@@ -417,8 +417,8 @@ static int kvaser_usb_wait_msg(const str }if (pos + tmp->len > actual_len) { -dev_err (dev->udev->dev.parent, -"Format error\n" ); +dev_err_ratelimited (dev->udev->dev.parent, +"Format error\n" );break ; }
@@ -1001,7 +1001,8 @@ static void kvaser_usb_read_bulk_callbac }if (pos + msg->len > urb->actual_length) { -dev_err (dev->udev->dev.parent,"Format error\n" ); +dev_err_ratelimited (dev->udev->dev.parent, +"Format error\n" );break ; }
PATCH 44/254 can: ti_hecc: Fix napi poll return value for repoll
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Stäbler <[email protected]>
commit f6c23b174c3c96616514827407769cbcfc8005cf upstream.
After commit d75b1ade567f ("net: less interrupt masking in NAPI") napi repoll is done only when work_done == budget.
So we need to return budget if there are still packets to receive.
--- drivers/net/can/ti_hecc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/can/ti_hecc.c +3 -0
@@ -652,6 +652,9 @@ static int ti_hecc_rx_poll(struct napi_s mbx_mask =hecc_read (priv,HECC_CANMIM ); mbx_mask |=HECC_TX_MBOX_MASK ;hecc_write (priv,HECC_CANMIM , mbx_mask); + }else { +/* repoll is done only if whole budget is used */ + num_pkts = quota; }return num_pkts;
PATCH 45/254 virtio: release virtio index when fail to device_register
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: weiping zhang <[email protected]>
commit e60ea67bb60459b95a50a156296041a13e0e380e upstream.
index can be reused by other virtio device.
--- drivers/virtio/virtio.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/virtio/virtio.c +2 -0
@@ -223,6 +223,8 @@ int register_virtio_device(struct virtio/* device_register() causes the bus infrastructure to look for a * matching driver. */ err =device_register (&dev->dev); +if (err) +ida_simple_remove (&virtio_index_ida, dev->index); out:if (err)add_status (dev,VIRTIO_CONFIG_S_FAILED );
PATCH 46/254 xhci: Don't show incorrect WARN message about events for empty rings
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit e4ec40ec4b260efcca15089de4285a0a3411259b upstream.
xHC can generate two events for a short transfer if the short TRB and last TRB in the TD are not the same TRB.
The driver will handle the TD after the first short event, and remove it from its internal list. Driver then incorrectly prints a warning for the second event:
"WARN Event TRB for slot x ep y with no TDs queued"
Fix this by not printing a warning if we get a event on a empty list if the previous event was a short event.
--- drivers/usb/host/xhci-ring.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/usb/host/xhci-ring.c +8 -4
@@ -2442,12 +2442,16 @@ static int handle_tx_event(struct xhci_h*/ if (list_empty (&ep_ring->td_list)) {/* -* A stopped endpoint may generate an extra completion -* event if the device was suspended. Don't print -* warnings. +* Don't print wanings if it's due to a stopped endpoint +* generating an extra completion event if the device +* was suspended. Or, a event for the last TRB of a +* short TD we already got a short event for. +* The short TD is already removed from the TD list. */ +if (!(trb_comp_code ==COMP_STOP || - trb_comp_code ==COMP_STOP_INVAL )) { + trb_comp_code ==COMP_STOP_INVAL || + ep_ring->last_td_was_short)) {xhci_warn (xhci,"WARN Event TRB for slot %d ep %d with no TDs queued?\n" ,TRB_TO_SLOT_ID (le32_to_cpu (event->flags)), ep_index);
PATCH 47/254 usb: xhci: fix panic in xhci_free_virt_devices_depth_first
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Yu Chen <[email protected]>
commit 80e457699a8dbdd70f2d26911e46f538645c55fc upstream.
Check vdev->real_port 0 to avoid panic
[ 9.261347] [<ffffff800884a390>] xhci_free_virt_devices_depth_first+0x58/0x108 [ 9.261352] [<ffffff800884a814>] xhci_mem_cleanup+0x1bc/0x570 [ 9.261355] [<ffffff8008842de8>] xhci_stop+0x140/0x1c8 [ 9.261365] [<ffffff80087ed304>] usb_remove_hcd+0xfc/0x1d0 [ 9.261369] [<ffffff80088551c4>] xhci_plat_remove+0x6c/0xa8 [ 9.261377] [<ffffff80086e928c>] platform_drv_remove+0x2c/0x70 [ 9.261384] [<ffffff80086e6ea0>] __device_release_driver+0x80/0x108 [ 9.261387] [<ffffff80086e7a1c>] device_release_driver+0x2c/0x40 [ 9.261392] [<ffffff80086e5f28>] bus_remove_device+0xe0/0x120 [ 9.261396] [<ffffff80086e2e34>] device_del+0x114/0x210 [ 9.261399] [<ffffff80086e9e00>] platform_device_del+0x30/0xa0 [ 9.261403] [<ffffff8008810bdc>] dwc3_otg_work+0x204/0x488 [ 9.261407] [<ffffff80088133fc>] event_work+0x304/0x5b8 [ 9.261414] [<ffffff80080e31b0>] process_one_work+0x148/0x490 [ 9.261417] [<ffffff80080e3548>] worker_thread+0x50/0x4a0 [ 9.261421] [<ffffff80080e9ea0>] kthread+0xe8/0x100 [ 9.261427] [<ffffff8008083680>] ret_from_fork+0x10/0x50
The problem can occur if xhci_plat_remove() is called shortly after xhci_plat_probe(). While xhci_free_virt_devices_depth_first been called before the device has been setup and get real_port initialized. The problem occurred on Hikey960 and was reproduced by Guenter Roeck on Kevin with chromeos-4.4.
--- drivers/usb/host/xhci-mem.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/host/xhci-mem.c +7 -0
@@ -982,6 +982,12 @@ void xhci_free_virt_devices_depth_first(if (!vdev)return ; +if (vdev->real_port ==0 || + vdev->real_port >HCS_MAX_PORTS (xhci->hcs_params1)) { +xhci_dbg (xhci,"Bad vdev->real_port.\n" ); + goto out; + } + tt_list_head = &(xhci->rh_bw[vdev->real_port -1 ].tts);list_for_each_entry_safe (tt_info, next, tt_list_head, tt_list) {/* is this a hub device that added a tt_info to the tts list */
@@ -995,6 +1001,7 @@ void xhci_free_virt_devices_depth_first( } } } +out:/* we are now at a leaf device */ xhci_free_virt_device (xhci, slot_id); }
PATCH 48/254 ext4: fix fdatasync(2) after fallocate(2) operation
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eryu Guan <[email protected]>
commit c894aa97577e47d3066b27b32499ecf899bfa8b0 upstream.
Currently, fallocate(2) with KEEP_SIZE followed by a fdatasync(2) then crash, we'll see wrong allocated block number (stat -c %b), the blocks allocated beyond EOF are all lost. fstests generic/468 exposes this bug.
Commit 67a7d5f561f4 ("ext4: fix fdatasync(2) after extent manipulation operations") fixed all the other extent manipulation operation paths such as hole punch, zero range, collapse range etc., but forgot the fallocate case.
So similarly, fix it by recording the correct journal tid in ext4 inode in fallocate(2) path, so that ext4_sync_file() will wait for the right tid to be committed on fdatasync(2).
This addresses the test failure in xfstests test generic/468.
--- fs/ext4/extents.c | 1 + 1 file changed, 1 insertion(+)
fs/ext4/extents.c +1 -0
@@ -4726,6 +4726,7 @@ retry: EXT4_INODE_EOFBLOCKS); }ext4_mark_inode_dirty (handle, inode); +ext4_update_inode_fsync_trans (handle, inode,1 ); ret2 =ext4_journal_stop (handle);if (ret2)break ;
PATCH 49/254 ALSA: usb-audio: Fix out-of-bound error
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jaejoong Kim <[email protected]>
commit 251552a2b0d454badc8f486e6d79100970c744b0 upstream.
The snd_usb_copy_string_desc() retrieves the usb string corresponding to the index number through the usb_string(). The problem is that the usb_string() returns the length of the string (>= 0) when successful, but it can also return a negative value about the error case or status of usb_control_msg().
If iClockSource is '0' as shown below, usb_string() will returns -EINVAL. This will result in '0' being inserted into buf[-22], and the following KASAN out-of-bound error message will be output.
AudioControl Interface Descriptor:
bLength 8
bDescriptorType 36
bDescriptorSubtype 10 (CLOCK_SOURCE)
bClockID 1
bmAttributes 0x07 Internal programmable Clock (synced to SOF)
bmControls 0x07
Clock Frequency Control (read/write)
Clock Validity Control (read-only)
bAssocTerminal 0
iClockSource 0
To fix it, check usb_string()'return value and bail out.
==================================================================
BUG: KASAN: stack-out-of-bounds in parse_audio_unit+0x1327/0x1960 [snd_usb_audio] Write of size 1 at addr ffff88007e66735a by task systemd-udevd/18376 CPU: 0 PID: 18376 Comm: systemd-udevd Not tainted 4.13.0+ #3 Hardware name: LG Electronics 15N540-RFLGL/White Tip Mountain, BIOS 15N5 Call Trace: dump_stack+0x63/0x8d print_address_description+0x70/0x290 ? parse_audio_unit+0x1327/0x1960 [snd_usb_audio] kasan_report+0x265/0x350 __asan_store1+0x4a/0x50 parse_audio_unit+0x1327/0x1960 [snd_usb_audio] ? save_stack+0xb5/0xd0 ? save_stack_trace+0x1b/0x20 ? save_stack+0x46/0xd0 ? kasan_kmalloc+0xad/0xe0 ? kmem_cache_alloc_trace+0xff/0x230 ? snd_usb_create_mixer+0xb0/0x4b0 [snd_usb_audio] ? usb_audio_probe+0x4de/0xf40 [snd_usb_audio] ? usb_probe_interface+0x1f5/0x440 ? driver_probe_device+0x3ed/0x660 ? build_feature_ctl+0xb10/0xb10 [snd_usb_audio] ? save_stack_trace+0x1b/0x20 ? init_object+0x69/0xa0 ? snd_usb_find_csint_desc+0xa8/0xf0 [snd_usb_audio] snd_usb_mixer_controls+0x1dc/0x370 [snd_usb_audio] ? build_audio_procunit+0x890/0x890 [snd_usb_audio] ? snd_usb_create_mixer+0xb0/0x4b0 [snd_usb_audio] ? kmem_cache_alloc_trace+0xff/0x230 ? usb_ifnum_to_if+0xbd/0xf0 snd_usb_create_mixer+0x25b/0x4b0 [snd_usb_audio] ? snd_usb_create_stream+0x255/0x2c0 [snd_usb_audio] usb_audio_probe+0x4de/0xf40 [snd_usb_audio] ? snd_usb_autosuspend.part.7+0x30/0x30 [snd_usb_audio] ? __pm_runtime_idle+0x90/0x90 ? kernfs_activate+0xa6/0xc0 ? usb_match_one_id_intf+0xdc/0x130 ? __pm_runtime_set_status+0x2d4/0x450 usb_probe_interface+0x1f5/0x440
--- sound/usb/mixer.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/usb/mixer.c +4 -0
@@ -199,6 +199,10 @@ static int snd_usb_copy_string_desc(stru int index, char *buf, int maxlen) { int len = usb_string(state->chip->dev, index, buf, maxlen - 1); + +if (len <0 ) +return 0 ; + buf[len] =0 ;return len; }
PATCH 50/254 ALSA: usb-audio: Add check return value for usb_string()
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jaejoong Kim <[email protected]>
commit 89b89d121ffcf8d9546633b98ded9d18b8f75891 upstream.
snd_usb_copy_string_desc() returns zero if usb_string() fails. In case of failure, we need to check the snd_usb_copy_string_desc()'s return value and add an exception case
--- sound/usb/mixer.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
sound/usb/mixer.c +5 -4
@@ -2100,13 +2100,14 @@ static int parse_audio_selector_unit(strif (len) ;else if (nameid) -snd_usb_copy_string_desc (state, nameid, kctl->id.name, + len =snd_usb_copy_string_desc (state, nameid, kctl->id.name,sizeof (kctl->id.name)); -else { +else len =get_term_name (state, &state->oterm, kctl->id.name,sizeof (kctl->id.name),0 ); -if (!len) -strlcpy (kctl->id.name,"USB" ,sizeof (kctl->id.name)); + +if (!len) { +strlcpy (kctl->id.name,"USB" ,sizeof (kctl->id.name));if (desc->bDescriptorSubtype ==UAC2_CLOCK_SELECTOR )append_ctl_name (kctl," Clock Source" );
PATCH 51/254 netfilter: xt_bpf: add overflow checks
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit 6ab405114b0b229151ef06f4e31c7834dd09d0c0 upstream.
Check whether inputs from userspace are too long (explicit length field too big or string not null-terminated) to avoid out-of-bounds reads.
As far as I can tell, this can at worst lead to very limited kernel heap memory disclosure or oopses.
This bug can be triggered by an unprivileged user even if the xt_bpf module is not loaded: iptables is available in network namespaces, and the xt_bpf module can be autoloaded.
Triggering the bug with a classic BPF filter with fake length 0x1000 causes the following KASAN report:
==================================================================
BUG: KASAN: slab-out-of-bounds in bpf_prog_create+0x84/0xf0
Read of size 32768 at addr ffff8801eff2c494 by task test/4627
CPU: 0 PID: 4627 Comm: test Not tainted 4.15.0-rc1+ #1
[...]
Call Trace:
dump_stack+0x5c/0x85
print_address_description+0x6a/0x260
kasan_report+0x254/0x370
? bpf_prog_create+0x84/0xf0
memcpy+0x1f/0x50
bpf_prog_create+0x84/0xf0
bpf_mt_check+0x90/0xd6 [xt_bpf]
[...]
Allocated by task 4627:
kasan_kmalloc+0xa0/0xd0
__kmalloc_node+0x47/0x60
xt_alloc_table_info+0x41/0x70 [x_tables]
[...]
The buggy address belongs to the object at ffff8801eff2c3c0
which belongs to the cache kmalloc-2048 of size 2048
The buggy address is located 212 bytes inside of
2048-byte region [ffff8801eff2c3c0, ffff8801eff2cbc0)[...]
==================================================================
[bwh: Backported to 3.16:
- Add len variable in bpf_mt_check()
- Drop change in __bpf_mt_check_path()]
---
net/netfilter/xt_bpf.c +5 -1
@@ -24,8 +24,12 @@ static int bpf_mt_check(const struct xt_ {struct xt_bpf_info *info = par->matchinfo;struct sock_fprog_kern program; +u16 len = info->bpf_program_num_elem; - program.len = info->bpf_program_num_elem; +if (len >XT_BPF_MAX_NUM_INSTR ) +return -EINVAL ; + + program.len = len; program.filter = info->bpf_program;if (sk_unattached_filter_create (&info->filter, &program)) {
PATCH 52/254 batman-adv: Fix lock for ogm cnt access in batadv_iv_ogm_calc_tq
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit 5ba7dcfe77037b67016263ea597a8b431692ecab upstream.
The originator node object orig_neigh_node is used to when accessing the bcast_own(_sum) and real_packet_count information. The access to them has to be protected with the spinlock in orig_neigh_node.
But the function uses the lock in orig_node instead. This is incorrect because they could be two different originator node objects.
--- net/batman-adv/bat_iv_ogm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/batman-adv/bat_iv_ogm.c +2 -2
@@ -1174,7 +1174,7 @@ static int batadv_iv_ogm_calc_tq(struct orig_node->last_seen = jiffies;/* find packet count of corresponding one hop neighbor */ -spin_lock_bh (&orig_node->bat_iv.ogm_cnt_lock); +spin_lock_bh (&orig_neigh_node->bat_iv.ogm_cnt_lock); if_num = if_incoming->if_num; orig_eq_count = orig_neigh_node->bat_iv.bcast_own_sum[if_num]; neigh_ifinfo =batadv_neigh_ifinfo_new (neigh_node, if_outgoing);
@@ -1184,7 +1184,7 @@ static int batadv_iv_ogm_calc_tq(struct }else { neigh_rq_count =0 ; } -spin_unlock_bh (&orig_node->bat_iv.ogm_cnt_lock); +spin_unlock_bh (&orig_neigh_node->bat_iv.ogm_cnt_lock);/* pay attention to not get a value bigger than 100 % */ if (orig_eq_count > neigh_rq_count)
PATCH 53/254 dm mpath: simplify failure path of dm_multipath_init()
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
commit ff658e9c1aae9a84dd06d46f847dc0cd2bf0dd11 upstream.
Currently the cleanup of all error cases are open-coded. Introduce a common exit path and labels.
--- drivers/md/dm-mpath.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
drivers/md/dm-mpath.c +15 -9
@@ -1691,16 +1691,15 @@ static int __init dm_multipath_init(void r =dm_register_target (&multipath_target);if (r <0 ) {DMERR ("register failed %d" , r); -kmem_cache_destroy (_mpio_cache); -return -EINVAL ; + r = -EINVAL ; + goto bad_register_target; } kmultipathd =alloc_workqueue ("kmpathd" ,WQ_MEM_RECLAIM ,0 );if (!kmultipathd) {DMERR ("failed to create workqueue kmpathd" ); -dm_unregister_target (&multipath_target); -kmem_cache_destroy (_mpio_cache); -return -ENOMEM ; + r = -ENOMEM ; + goto bad_alloc_kmultipathd; }/*
@@ -1713,16 +1712,23 @@ static int __init dm_multipath_init(void WQ_MEM_RECLAIM);if (!kmpath_handlerd) {DMERR ("failed to create workqueue kmpath_handlerd" ); -destroy_workqueue (kmultipathd); -dm_unregister_target (&multipath_target); -kmem_cache_destroy (_mpio_cache); -return -ENOMEM ; + r = -ENOMEM ; + goto bad_alloc_kmpath_handlerd; }DMINFO ("version %u.%u.%u loaded" , multipath_target.version[0 ], multipath_target.version[1 ], multipath_target.version[2 ]); +return 0 ; + +bad_alloc_kmpath_handlerd: +destroy_workqueue (kmultipathd); +bad_alloc_kmultipathd: +dm_unregister_target (&multipath_target); +bad_register_target: +kmem_cache_destroy (_mpio_cache); +return r; }
PATCH 54/254 dm: fix various targets to dm_register_target after module __init resources created
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "[email protected]" <[email protected]>
commit 7e6358d244e4706fe612a77b9c36519a33600ac0 upstream.
A NULL pointer is seen if two concurrent "vgchange -ay -K <vg name>" processes race to load the dm-thin-pool module:
PID: 25992 TASK: ffff883cd7d23500 CPU: 4 COMMAND: "vgchange"
#0 [ffff883cd743d600] machine_kexec at ffffffff81038fa9 0000001 [ffff883cd743d660] crash_kexec at ffffffff810c5992 0000002 [ffff883cd743d730] oops_end at ffffffff81515c90 0000003 [ffff883cd743d760] no_context at ffffffff81049f1b 0000004 [ffff883cd743d7b0] __bad_area_nosemaphore at ffffffff8104a1a5 0000005 [ffff883cd743d800] bad_area at ffffffff8104a2ce 0000006 [ffff883cd743d830] __do_page_fault at ffffffff8104aa6f 0000007 [ffff883cd743d950] do_page_fault at ffffffff81517bae 0000008 [ffff883cd743d980] page_fault at ffffffff81514f95
[exception RIP: kmem_cache_alloc+108]
RIP: ffffffff8116ef3c RSP: ffff883cd743da38 RFLAGS: 00010046
RAX: 0000000000000004 RBX: ffffffff81121b90 RCX: ffff881bf1e78cc0
RDX: 0000000000000000 RSI: 00000000000000d0 RDI: 0000000000000000
RBP: ffff883cd743da68 R8: ffff881bf1a4eb00 R9: 0000000080042000
R10: 0000000000002000 R11: 0000000000000000 R12: 00000000000000d0
R13: 0000000000000000 R14: 00000000000000d0 R15: 0000000000000246
ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018 0000009 [ffff883cd743da70] mempool_alloc_slab at ffffffff81121ba5
0000010 [ffff883cd743da80] mempool_create_node at ffffffff81122083 0000011 [ffff883cd743dad0] mempool_create at ffffffff811220f4 0000012 [ffff883cd743dae0] pool_ctr at ffffffffa08de049 [dm_thin_pool] 0000013 [ffff883cd743dbd0] dm_table_add_target at ffffffffa0005f2f [dm_mod] 0000014 [ffff883cd743dc30] table_load at ffffffffa0008ba9 [dm_mod] 0000015 [ffff883cd743dc90] ctl_ioctl at ffffffffa0009dc4 [dm_mod]
The race results in a NULL pointer because:
Process A (vgchange -ay -K):
a. send DM_LIST_VERSIONS_CMD ioctl; b. pool_target not registered;
c. modprobe dm_thin_pool and wait until end.
Process B (vgchange -ay -K):
a. send DM_LIST_VERSIONS_CMD ioctl;
b. pool_target registered;
c. table_load->dm_table_add_target->pool_ctr; d. _new_mapping_cache is NULL and panic.
Note:
1. process A and process B are two concurrent processes.
2. pool_target can be detected by process B but _new_mapping_cache initialization has not ended.
To fix dm-thin-pool, and other targets (cache, multipath, and snapshot) with the same problem, simply dm_register_target() after all resources created during module init (as labelled with __init) are finished.
--- drivers/md/dm-cache-target.c | 12 +++++------ drivers/md/dm-mpath.c | 18 ++++++++--------- drivers/md/dm-snap.c | 48 ++++++++++++++++++++++---------------------- drivers/md/dm-thin.c | 22 +++++++++----------- 4 files changed, 49 insertions(+), 51 deletions(-)
drivers/md/dm-cache-target.c +6 -6
@@ -3108,18 +3108,18 @@ static int __init dm_cache_init(void) {int r; - r =dm_register_target (&cache_target); -if (r) { -DMERR ("cache target registration failed: %d" , r); -return r; - } - migration_cache =KMEM_CACHE (dm_cache_migration,0 );if (!migration_cache) {dm_unregister_target (&cache_target);return -ENOMEM ; } + r =dm_register_target (&cache_target); +if (r) { +DMERR ("cache target registration failed: %d" , r); +return r; + } +return 0 ; }
drivers/md/dm-mpath.c +9 -9
@@ -1688,13 +1688,6 @@ static int __init dm_multipath_init(voidif (!_mpio_cache)return -ENOMEM ; - r =dm_register_target (&multipath_target); -if (r <0 ) { -DMERR ("register failed %d" , r); - r = -EINVAL ; - goto bad_register_target; - } - kmultipathd =alloc_workqueue ("kmpathd" ,WQ_MEM_RECLAIM ,0 );if (!kmultipathd) {DMERR ("failed to create workqueue kmpathd" );
@@ -1716,17 +1709,24 @@ static int __init dm_multipath_init(void goto bad_alloc_kmpath_handlerd; } + r =dm_register_target (&multipath_target); +if (r <0 ) { +DMERR ("register failed %d" , r); + r = -EINVAL ; + goto bad_register_target; + } +DMINFO ("version %u.%u.%u loaded" , multipath_target.version[0 ], multipath_target.version[1 ], multipath_target.version[2 ]);return 0 ; +bad_register_target: +destroy_workqueue (kmpath_handlerd); bad_alloc_kmpath_handlerd:destroy_workqueue (kmultipathd); bad_alloc_kmultipathd: -dm_unregister_target (&multipath_target); -bad_register_target:kmem_cache_destroy (_mpio_cache);return r;
drivers/md/dm-snap.c +24 -24
67 lines not on this page · raw message
drivers/md/dm-thin.c +10 -12
@@ -3521,30 +3521,28 @@ static struct target_type thin_target =static int __init dm_thin_init (void ) { -int r; +int r = -ENOMEM ;pool_table_init (); + _new_mapping_cache =KMEM_CACHE (dm_thin_new_mapping,0 ); +if (!_new_mapping_cache) +return r; + r =dm_register_target (&thin_target);if (r) -return r; + goto bad_new_mapping_cache; r =dm_register_target (&pool_target);if (r) - goto bad_pool_target; - - r = -ENOMEM ; - - _new_mapping_cache =KMEM_CACHE (dm_thin_new_mapping,0 ); -if (!_new_mapping_cache) - goto bad_new_mapping_cache; + goto bad_thin_target;return 0 ; -bad_new_mapping_cache: -dm_unregister_target (&pool_target); -bad_pool_target: +bad_thin_target:dm_unregister_target (&thin_target); +bad_new_mapping_cache: +kmem_cache_destroy (_new_mapping_cache);return r; }
PATCH 55/254 s390: always save and restore all registers on context switch
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
commit fbbd7f1a51965b50dd12924841da0d478f3da71b upstream.
The switch_to() macro has an optimization to avoid saving and restoring register contents that aren't needed for kernel threads.
There is however the possibility that a kernel thread execve's a user space program. In such a case the execve'd process can partially see the contents of the previous process, which shouldn't be allowed.
To avoid this, simply always save and restore register contents on context switch.
[bwh: Backported to 3.16:
- The save/restore functions are different here
- FP restore is non-lazy, so drop the comment about it being lazy]
---
arch/s390/include/asm/switch_to.h +10 -14
@@ -117,21 +117,17 @@ static inline void restore_access_regs(u asm volatile("lam 0,15,%0" : : "Q" (*(acrstype *)acrs)); } -#define switch_to (prev,next,last) do { \ - if (prev->mm) { \ - save_fp_ctl(&prev->thread.fp_regs.fpc); \ - save_fp_regs(prev->thread.fp_regs.fprs); \ - save_access_regs(&prev->thread.acrs[0]); \ - save_ri_cb(prev->thread.ri_cb); \ - } \ +#define switch_to (prev, next, last) do { \ + save_fp_ctl(&prev->thread.fp_regs.fpc); \ + save_fp_regs(prev->thread.fp_regs.fprs); \ + save_access_regs(&prev->thread.acrs[0]); \ + save_ri_cb(prev->thread.ri_cb); \ update_cr_regs(next); \ - if (next->mm) { \ - restore_fp_ctl(&next->thread.fp_regs.fpc); \ - restore_fp_regs(next->thread.fp_regs.fprs); \ - restore_access_regs(&next->thread.acrs[0]); \ - restore_ri_cb(next->thread.ri_cb, prev->thread.ri_cb); \ - } \ - prev = __switch_to(prev,next); \ + restore_fp_ctl(&next->thread.fp_regs.fpc); \ + restore_fp_regs(next->thread.fp_regs.fprs); \ + restore_access_regs(&next->thread.acrs[0]); \ + restore_ri_cb(next->thread.ri_cb, prev->thread.ri_cb); \ + prev = __switch_to(prev, next); \ } while (0)#endif /* __ASM_SWITCH_TO_H */
PATCH 56/254 net_sched: red: Avoid devision by zero
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Nogah Frankel <[email protected]>
commit 5c472203421ab4f928aa1ae9e1dbcfdd80324148 upstream.
Do not allow delta value to be zero since it is used as a divisor.
--- include/net/red.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/net/red.h +1 -1
@@ -178,7 +178,7 @@ static inline void red_set_parms(struct p->qth_max = qth_max << Wlog; p->Wlog = Wlog; p->Plog = Plog; -if (delta <0 ) +if (delta <=0 ) delta =1 ; p->qth_delta = delta;if (!max_P) {
PATCH 57/254 net_sched: red: Avoid illegal values
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Nogah Frankel <[email protected]>
commit 8afa10cbe281b10371fee5a87ab266e48d71a7f9 upstream.
Check the qmin & qmax values doesn't overflow for the given Wlog value. Check that qmin <= qmax.
--- include/net/red.h | 11 +++++++++++ net/sched/sch_choke.c | 3 +++ net/sched/sch_gred.c | 3 +++ net/sched/sch_red.c | 2 ++ net/sched/sch_sfq.c | 3 +++ 5 files changed, 22 insertions(+)
include/net/red.h +11 -0
@@ -167,6 +167,17 @@ static inline void red_set_vars(struct r v->qcount =-1 ; } +static inline bool red_check_params (u32 qth_min,u32 qth_max,u8 Wlog) +{ +if (fls (qth_min) + Wlog >32 ) +return false; +if (fls (qth_max) + Wlog >32 ) +return false; +if (qth_max < qth_min) +return false; +return true; +} +static inline void red_set_parms (struct red_parms *p,u32 qth_min,u32 qth_max,u8 Wlog,u8 Plog,u8 Scell_log,u8 *stab,u32 max_P)
net/sched/sch_choke.c +3 -0
@@ -419,6 +419,9 @@ static int choke_change(struct Qdisc *sc ctl =nla_data (tb[TCA_CHOKE_PARMS ]); +if (!red_check_params (ctl->qth_min, ctl->qth_max, ctl->Wlog)) +return -EINVAL ; +if (ctl->limit >CHOKE_MAX_QUEUE )return -EINVAL ;
net/sched/sch_gred.c +3 -0
@@ -388,6 +388,9 @@ static inline int gred_change_vq(structstruct gred_sched *table =qdisc_priv (sch);struct gred_sched_data *q = table->tab[dp]; +if (!red_check_params (ctl->qth_min, ctl->qth_max, ctl->Wlog)) +return -EINVAL ; +if (!q) { table->tab[dp] = q = *prealloc; *prealloc =NULL ;
net/sched/sch_red.c +2 -0
@@ -199,6 +199,8 @@ static int red_change(struct Qdisc *sch, max_P = tb[TCA_RED_MAX_P ] ?nla_get_u32 (tb[TCA_RED_MAX_P ]) :0 ; ctl =nla_data (tb[TCA_RED_PARMS ]); +if (!red_check_params (ctl->qth_min, ctl->qth_max, ctl->Wlog)) +return -EINVAL ;if (ctl->limit >0 ) { child =fifo_create_dflt (sch, &bfifo_qdisc_ops, ctl->limit);
net/sched/sch_sfq.c +3 -0
@@ -658,6 +658,9 @@ static int sfq_change(struct Qdisc *sch,if (ctl->divisor && (!is_power_of_2 (ctl->divisor) || ctl->divisor >65536 ))return -EINVAL ; +if (ctl_v1 && !red_check_params (ctl_v1->qth_min, ctl_v1->qth_max, + ctl_v1->Wlog)) +return -EINVAL ;if (ctl_v1 && ctl_v1->qth_min) { p =kmalloc (sizeof (*p),GFP_KERNEL );if (!p)
PATCH 58/254 ALSA: pcm: prevent UAF in snd_pcm_info
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Robb Glasser <[email protected]>
commit 362bca57f5d78220f8b5907b875961af9436e229 upstream.
When the device descriptor is closed, the substream->runtime pointer is freed. But another thread may be in the ioctl handler, case SNDRV_CTL_IOCTL_PCM_INFO. This case calls snd_pcm_info_user() which calls snd_pcm_info() which accesses the now freed substream->runtime.
Note: this fixes CVE-2017-0861
--- sound/core/pcm.c | 2 ++ 1 file changed, 2 insertions(+)
sound/core/pcm.c +2 -0
@@ -150,7 +150,9 @@ static int snd_pcm_control_ioctl(struct err = -ENXIO ; goto _error; } +mutex_lock (&pcm->open_mutex); err =snd_pcm_info_user (substream, info); +mutex_unlock (&pcm->open_mutex); _error:mutex_unlock (®ister_mutex);return err;
PATCH 59/254 x86/PCI: Make broadcom_postcore_init() check acpi_disabled
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Rafael J. Wysocki" <[email protected]>
commit ddec3bdee05b06f1dda20ded003c3e10e4184cab upstream.
acpi_os_get_root_pointer() may return a valid address even if acpi_disabled is set, but the host bridge information from the ACPI tables is not going to be used in that case and the Broadcom host bridge initialization should not be skipped then, So make broadcom_postcore_init() check acpi_disabled too to avoid this issue.
--- arch/x86/pci/broadcom_bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/pci/broadcom_bus.c +1 -1
@@ -97,7 +97,7 @@ static int __init broadcom_postcore_init* We should get host bridge information from ACPI unless the BIOS * doesn't support it. */ -if (acpi_os_get_root_pointer ()) +if (!acpi_disabled &&acpi_os_get_root_pointer ())return 0 ;#endif
PATCH 60/254 arm64: fpsimd: Prevent registers leaking from dead tasks
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dave Martin <[email protected]>
commit 071b6d4a5d343046f253a5a8835d477d93992002 upstream.
Currently, loading of a task's fpsimd state into the CPU registers is skipped if that task's state is already present in the registers of that CPU.
However, the code relies on the struct fpsimd_state * (and by extension struct task_struct *) to unambiguously identify a task.
There is a particular case in which this doesn't work reliably:
when a task exits, its task_struct may be recycled to describe a new task.
Consider the following scenario:
1) Task P loads its fpsimd state onto cpu C.
per_cpu(fpsimd_last_state, C) := P;
P->thread.fpsimd_state.cpu := C;2) Task X is scheduled onto C and loads its fpsimd state on C.
per_cpu(fpsimd_last_state, C) := X;
X->thread.fpsimd_state.cpu := C; 3) X exits, causing X's task_struct to be freed.
4) P forks a new child T, which obtains X's recycled task_struct.
T == X. T->thread.fpsimd_state.cpu == C (inherited from P).
5) T is scheduled on C.
T's fpsimd state is not loaded, because
per_cpu(fpsimd_last_state, C) == T (== X) &&
T->thread.fpsimd_state.cpu == C.
(This is the check performed by fpsimd_thread_switch().)So, T gets X's registers because the last registers loaded onto C were those of X, in (2).
This patch fixes the problem by ensuring that the sched-in check fails in (5): fpsimd_flush_task_state(T) is called when T is forked, so that T->thread.fpsimd_state.cpu == C cannot be true. This relies on the fact that T is not schedulable until after copy_thread() completes.
Once T's fpsimd state has been loaded on some CPU C there may still be other cpus D for which per_cpu(fpsimd_last_state, D) == &X->thread.fpsimd_state. But D is necessarily != C in this case, and the check in (5) must fail.
An alternative fix would be to do refcounting on task_struct. This would result in each CPU holding a reference to the last task whose fpsimd state was loaded there. It's not clear whether this is preferable, and it involves higher overhead than the fix proposed in this patch. It would also move all the task_struct freeing work into the context switch critical section, or otherwise some deferred cleanup mechanism would need to be introduced, neither of which seems obviously justified.
--- arch/arm64/kernel/process.c | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/arm64/kernel/process.c +9 -0
@@ -269,6 +269,15 @@ int copy_thread(unsigned long clone_flagmemset (&p->thread.cpu_context,0 ,sizeof (struct cpu_context )); +/* +* In case p was allocated the same task_struct pointer as some +* other recently-exited task, make sure p is disassociated from +* any cpu that may have run that now-exited task recently. +* Otherwise we could erroneously skip reloading the FPSIMD +* registers for p. +*/ +fpsimd_flush_task_state (p); +if (likely (!(p->flags &PF_KTHREAD ))) { *childregs = *current_pt_regs (); childregs->regs[0 ] =0 ;
PATCH 61/254 efi: Move some sysfs files to be read-only by root
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit af97a77bc01ce49a466f9d4c0125479e2e2230b6 upstream.
Thanks to the scripts/leaking_addresses.pl script, it was found that some EFI values should not be readable by non-root users.
So make them root-only, and to do that, add a __ATTR_RO_MODE() macro to make this easier, and use it in other places at the same time.
---
drivers/firmware/efi/efi.c +1 -2
@@ -72,8 +72,7 @@ static ssize_t systab_show(struct kobjecreturn str - buf; } -static struct kobj_attribute efi_attr_systab = -__ATTR (systab,0400 , systab_show,NULL ); +static struct kobj_attribute efi_attr_systab =__ATTR_RO_MODE (systab,0400 );#define EFI_FIELD (var) efi.var
drivers/firmware/efi/runtime-map.c +5 -5
@@ -67,11 +67,11 @@ static ssize_t map_attr_show(struct kobjreturn map_attr->show (entry, buf); } -static struct map_attribute map_type_attr =__ATTR_RO (type); -static struct map_attribute map_phys_addr_attr =__ATTR_RO (phys_addr); -static struct map_attribute map_virt_addr_attr =__ATTR_RO (virt_addr); -static struct map_attribute map_num_pages_attr =__ATTR_RO (num_pages); -static struct map_attribute map_attribute_attr =__ATTR_RO (attribute); +static struct map_attribute map_type_attr =__ATTR_RO_MODE (type,0400 ); +static struct map_attribute map_phys_addr_attr =__ATTR_RO_MODE (phys_addr,0400 ); +static struct map_attribute map_virt_addr_attr =__ATTR_RO_MODE (virt_addr,0400 ); +static struct map_attribute map_num_pages_attr =__ATTR_RO_MODE (num_pages,0400 ); +static struct map_attribute map_attribute_attr =__ATTR_RO_MODE (attribute,0400 );/* * These are default attributes that are added for every memmap entry.
include/linux/sysfs.h +6 -0
@@ -82,6 +82,12 @@ struct attribute_group { .show = _name##_show, \ } +#define __ATTR_RO_MODE (_name, _mode) { \ + .attr = { .name = __stringify(_name), \ + .mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \ + .show = _name##_show, \ +} +#define __ATTR_WO (_name) { \ .attr = { .name = __stringify(_name), .mode = S_IWUSR }, \ .store = _name##_store, \
PATCH 62/254 kdb: Fix handling of kallsyms_symbol_next() return value
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Thompson <[email protected]>
commit c07d35338081d107e57cf37572d8cc931a8e32e2 upstream.
kallsyms_symbol_next() returns a boolean (true on success). Currently kdb_read() tests the return value with an inequality that unconditionally evaluates to true.
This is fixed in the obvious way and, since the conditional branch is supposed to be unreachable, we also add a WARN_ON().
--- kernel/debug/kdb/kdb_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/debug/kdb/kdb_io.c +1 -1
@@ -349,7 +349,7 @@ poll_again: }kdb_printf ("\n" );for (i =0 ; i < count; i++) { -if (kallsyms_symbol_next (p_tmp, i) <0 ) +if (WARN_ON (!kallsyms_symbol_next (p_tmp, i)))break ;kdb_printf ("%s " , p_tmp); *(p_tmp + len) ='\0' ;
PATCH 63/254 btrfs: fix missing error return in btrfs_drop_snapshot
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Mahoney <[email protected]>
commit e19182c0fff451e3744c1107d98f072e7ca377a0 upstream.
If btrfs_del_root fails in btrfs_drop_snapshot, we'll pick up the error but then return 0 anyway due to mixing err and ret.
--- fs/btrfs/extent-tree.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/extent-tree.c +1 -0
@@ -8071,6 +8071,7 @@ int btrfs_drop_snapshot(struct btrfs_roo ret =btrfs_del_root (trans, tree_root, &root->root_key);if (ret) {btrfs_abort_transaction (trans, tree_root, ret); + err = ret; goto out_end_trans; }
PATCH 64/254 Btrfs: disable FUA if mounted with nobarrier
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Omar Sandoval <[email protected]>
commit 1b9e619c5bc8235cfba3dc4ced2fb0e3554a05d4 upstream.
I was seeing disk flushes still happening when I mounted a Btrfs filesystem with nobarrier for testing. This is because we use FUA to write out the first super block, and on devices without FUA support, the block layer translates FUA to a flush. Even on devices supporting true FUA, using FUA when we asked for no barriers is surprising.
[bwh: Backported to 3.16:
- I/O flag names are different, and are combined with the operation type
- Use the do_barrier parameter instead of checking the NOBARRIER option again]
---
fs/btrfs/disk-io.c +5 -4
@@ -3140,6 +3140,7 @@ static int write_dev_supers(struct btrfsint errors =0 ;u32 crc;u64 bytenr; +int op_flags;if (max_mirrors ==0 ) max_mirrors =BTRFS_SUPER_MIRROR_MAX ;
@@ -3204,10 +3205,10 @@ static int write_dev_supers(struct btrfs* we fua the first super. The others we allow * to go down lazy. */ -if (i ==0 ) - ret =btrfsic_submit_bh (WRITE_FUA , bh); -else - ret =btrfsic_submit_bh (WRITE_SYNC , bh); + op_flags =REQ_SYNC |REQ_NOIDLE ; +if (i ==0 && do_barriers) + op_flags |=REQ_FUA ; + ret =btrfsic_submit_bh (WRITE | op_flags, bh);if (ret) errors++; }
PATCH 65/254 btrfs: Fix possible off-by-one in btrfs_search_path_in_tree
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Nikolay Borisov <[email protected]>
commit c8bcbfbd239ed60a6562964b58034ac8a25f4c31 upstream.
The name char array passed to btrfs_search_path_in_tree is of size BTRFS_INO_LOOKUP_PATH_MAX (4080). So the actual accessible char indexes are in the range of [0, 4079]. Currently the code uses the define but this represents an off-by-one.
Implications:
Size of btrfs_ioctl_ino_lookup_args is 4096, so the new byte will be written to extra space, not some padding that could be provided by the allocator.
btrfs-progs store the arguments on stack, but kernel does own copy of the ioctl buffer and the off-by-one overwrite does not affect userspace, but the ending 0 might be lost.
Kernel ioctl buffer is allocated dynamically so we're overwriting somebody else's memory, and the ioctl is privileged if args.objectid is not 256. Which is in most cases, but resolving a subvolume stored in another directory will trigger that path.
Before this patch the buffer was one byte larger, but then the -1 was not added.
--- fs/btrfs/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/ioctl.c +1 -1
@@ -2253,7 +2253,7 @@ static noinline int btrfs_search_path_inif (!path)return -ENOMEM ; - ptr = &name[BTRFS_INO_LOOKUP_PATH_MAX ]; + ptr = &name[BTRFS_INO_LOOKUP_PATH_MAX -1 ]; key.objectid = tree_id; key.type =BTRFS_ROOT_ITEM_KEY ;
PATCH 66/254 net: mvmdio: disable/unprepare clocks in EPROBE_DEFER case
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Tobias Jordan <[email protected]>
commit 589bf32f09852041fbd3b7ce1a9e703f95c230ba upstream.
add appropriate calls to clk_disable_unprepare() by jumping to out_mdio in case orion_mdio_probe() returns -EPROBE_DEFER.
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/net/ethernet/marvell/mvmdio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/mvmdio.c +2 -1
@@ -241,7 +241,8 @@ static int orion_mdio_probe(struct platf dev->regs + MVMDIO_ERR_INT_MASK); }else if (dev->err_interrupt == -EPROBE_DEFER ) { -return -EPROBE_DEFER ; + ret = -EPROBE_DEFER ; + goto out_mdio; }mutex_init (&dev->lock);
PATCH 67/254 can: ems_usb: cancel urb on -EPIPE and -EPROTO
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Martin Kelly <[email protected]>
commit bd352e1adfe0d02d3ea7c8e3fb19183dc317e679 upstream.
In mcba_usb, we have observed that when you unplug the device, the driver will endlessly resubmit failing URBs, which can cause CPU stalls. This issue is fixed in mcba_usb by catching the codes seen on device disconnect (-EPIPE and -EPROTO).
This driver also resubmits in the case of -EPIPE and -EPROTO, so fix it in the same way.
--- drivers/net/can/usb/ems_usb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/can/usb/ems_usb.c +2 -0
@@ -290,6 +290,8 @@ static void ems_usb_read_interrupt_callbcase -ECONNRESET :/* unlink */ case -ENOENT : +case -EPIPE : +case -EPROTO :case -ESHUTDOWN :return ;
PATCH 68/254 can: esd_usb2: cancel urb on -EPIPE and -EPROTO
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Martin Kelly <[email protected]>
commit 7a31ced3de06e9878e4f9c3abe8f87d9344d8144 upstream.
In mcba_usb, we have observed that when you unplug the device, the driver will endlessly resubmit failing URBs, which can cause CPU stalls. This issue is fixed in mcba_usb by catching the codes seen on device disconnect (-EPIPE and -EPROTO).
This driver also resubmits in the case of -EPIPE and -EPROTO, so fix it in the same way.
--- drivers/net/can/usb/esd_usb2.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/can/usb/esd_usb2.c +2 -0
@@ -395,6 +395,8 @@ static void esd_usb2_read_bulk_callback(break ;case -ENOENT : +case -EPIPE : +case -EPROTO :case -ESHUTDOWN :return ;
PATCH 69/254 can: kvaser_usb: cancel urb on -EPIPE and -EPROTO
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Martin Kelly <[email protected]>
commit 6aa8d5945502baf4687d80de59b7ac865e9e666b upstream.
In mcba_usb, we have observed that when you unplug the device, the driver will endlessly resubmit failing URBs, which can cause CPU stalls. This issue is fixed in mcba_usb by catching the codes seen on device disconnect (-EPIPE and -EPROTO).
This driver also resubmits in the case of -EPIPE and -EPROTO, so fix it in the same way.
--- drivers/net/can/usb/kvaser_usb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/can/usb/kvaser_usb.c +2 -0
@@ -975,6 +975,8 @@ static void kvaser_usb_read_bulk_callbaccase 0 :break ;case -ENOENT : +case -EPIPE : +case -EPROTO :case -ESHUTDOWN :return ;default :
PATCH 70/254 can: usb_8dev: cancel urb on -EPIPE and -EPROTO
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Martin Kelly <[email protected]>
commit 12147edc434c9e4c7c2f5fee2e5519b2e5ac34ce upstream.
In mcba_usb, we have observed that when you unplug the device, the driver will endlessly resubmit failing URBs, which can cause CPU stalls. This issue is fixed in mcba_usb by catching the codes seen on device disconnect (-EPIPE and -EPROTO).
This driver also resubmits in the case of -EPIPE and -EPROTO, so fix it in the same way.
--- drivers/net/can/usb/usb_8dev.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/can/usb/usb_8dev.c +2 -0
@@ -527,6 +527,8 @@ static void usb_8dev_read_bulk_callback(break ;case -ENOENT : +case -EPIPE : +case -EPROTO :case -ESHUTDOWN :return ;
PATCH 71/254 ASN.1: fix out-of-bounds read when parsing indefinite length item
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit e0058f3a874ebb48b25be7ff79bc3b4e59929f90 upstream.
In asn1_ber_decoder(), indefinitely-sized ASN.1 items were being passed to the action functions before their lengths had been computed, using the bogus length of 0x80 (ASN1_INDEFINITE_LENGTH). This resulted in reading data past the end of the input buffer, when given a specially crafted message.
Fix it by rearranging the code so that the indefinite length is resolved before the action is called.
This bug was originally found by fuzzing the X.509 parser in userspace using libFuzzer from the LLVM project.
KASAN report (cleaned up slightly):
BUG: KASAN: slab-out-of-bounds in memcpy ./include/linux/string.h:341 [inline]
BUG: KASAN: slab-out-of-bounds in x509_fabricate_name.constprop.1+0x1a4/0x940 crypto/asymmetric_keys/x509_cert_parser.c:366
Read of size 128 at addr ffff880035dd9eaf by task keyctl/195
CPU: 1 PID: 195 Comm: keyctl Not tainted 4.14.0-09238-g1d3b78bbc6e9 #26
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-20171110_100015-anatol 04/01/2014
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0xd1/0x175 lib/dump_stack.c:53
print_address_description+0x78/0x260 mm/kasan/report.c:252
kasan_report_error mm/kasan/report.c:351 [inline]
kasan_report+0x23f/0x350 mm/kasan/report.c:409
memcpy+0x1f/0x50 mm/kasan/kasan.c:302
memcpy ./include/linux/string.h:341 [inline]
x509_fabricate_name.constprop.1+0x1a4/0x940 crypto/asymmetric_keys/x509_cert_parser.c:366
asn1_ber_decoder+0xb4a/0x1fd0 lib/asn1_decoder.c:447
x509_cert_parse+0x1c7/0x620 crypto/asymmetric_keys/x509_cert_parser.c:89
x509_key_preparse+0x61/0x750 crypto/asymmetric_keys/x509_public_key.c:174
asymmetric_key_preparse+0xa4/0x150 crypto/asymmetric_keys/asymmetric_type.c:388
key_create_or_update+0x4d4/0x10a0 security/keys/key.c:850
SYSC_add_key security/keys/keyctl.c:122 [inline]
SyS_add_key+0xe8/0x290 security/keys/keyctl.c:62
entry_SYSCALL_64_fastpath+0x1f/0x96
Allocated by task 195:
__do_kmalloc_node mm/slab.c:3675 [inline]
__kmalloc_node+0x47/0x60 mm/slab.c:3682
kvmalloc ./include/linux/mm.h:540 [inline]
SYSC_add_key security/keys/keyctl.c:104 [inline]
SyS_add_key+0x19e/0x290 security/keys/keyctl.c:62
entry_SYSCALL_64_fastpath+0x1f/0x96--- lib/asn1_decoder.c | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-)
lib/asn1_decoder.c +24 -19
@@ -305,38 +305,43 @@ next_op:/* Decide how to handle the operation */ switch (op) { -case ASN1_OP_MATCH_ANY_ACT : -case ASN1_OP_COND_MATCH_ANY_ACT : - ret = actions[machine[pc +1 ]](context, hdr, tag, data + dp, len); -if (ret <0 ) -return ret; - goto skip_data; - -case ASN1_OP_MATCH_ACT : -case ASN1_OP_MATCH_ACT_OR_SKIP : -case ASN1_OP_COND_MATCH_ACT_OR_SKIP : - ret = actions[machine[pc +2 ]](context, hdr, tag, data + dp, len); -if (ret <0 ) -return ret; - goto skip_data; -case ASN1_OP_MATCH :case ASN1_OP_MATCH_OR_SKIP : +case ASN1_OP_MATCH_ACT : +case ASN1_OP_MATCH_ACT_OR_SKIP :case ASN1_OP_MATCH_ANY : +case ASN1_OP_MATCH_ANY_ACT :case ASN1_OP_COND_MATCH_OR_SKIP : +case ASN1_OP_COND_MATCH_ACT_OR_SKIP :case ASN1_OP_COND_MATCH_ANY : - skip_data: +case ASN1_OP_COND_MATCH_ANY_ACT : +if (!(flags &FLAG_CONS )) {if (flags &FLAG_INDEFINITE_LENGTH ) { +size_t tmp = dp; + ret =asn1_find_indefinite_length ( - data, datalen, &dp, &len, &errmsg); + data, datalen, &tmp, &len, &errmsg);if (ret <0 ) goto error; - }else { - dp += len; }pr_debug ("- LEAF: %zu\n" , len); } + +if (op &ASN1_OP_MATCH__ACT ) { +unsigned char act; + +if (op &ASN1_OP_MATCH__ANY ) + act = machine[pc +1 ]; +else + act = machine[pc +2 ]; + ret = actions[act](context, hdr, tag, data + dp, len); +if (ret <0 ) +return ret; + } + +if (!(flags &FLAG_CONS )) + dp += len; pc += asn1_op_lengths[op]; goto next_op;
PATCH 72/254 ASN.1: check for error from ASN1_OP_END__ACT actions
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 81a7be2cd69b412ab6aeacfe5ebf1bb6e5bce955 upstream.
asn1_ber_decoder() was ignoring errors from actions associated with the opcodes ASN1_OP_END_SEQ_ACT, ASN1_OP_END_SET_ACT, ASN1_OP_END_SEQ_OF_ACT, and ASN1_OP_END_SET_OF_ACT. In practice, this meant the pkcs7_note_signed_info() action (since that was the only user of those opcodes). Fix it by checking for the error, just like the decoder does for actions associated with the other opcodes.
This bug allowed users to leak slab memory by repeatedly trying to add a specially crafted "pkcs7_test" key (requires CONFIG_PKCS7_TEST_KEY).
In theory, this bug could also be used to bypass module signature verification, by providing a PKCS#7 message that is misparsed such that a signature's ->authattrs do not contain its ->msgdigest. But it doesn't seem practical in normal cases, due to restrictions on the format of the ->authattrs.
--- lib/asn1_decoder.c | 2 ++ 1 file changed, 2 insertions(+)
lib/asn1_decoder.c +2 -0
@@ -427,6 +427,8 @@ next_op:else act = machine[pc +1 ]; ret = actions[act](context, hdr,0 , data + tdp, len); +if (ret <0 ) +return ret; } pc += asn1_op_lengths[op]; goto next_op;
PATCH 73/254 lib/oid_registry.c: X.509: fix the buffer overflow in the utility function for OID string
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit afdb05e9d61905220f09268535235288e6ba3a16 upstream.
The sprint_oid() utility function doesn't properly check the buffer size that it causes that the warning in vsnprintf() be triggered. For example on v4.1 kernel:
------------[ cut here ]------------ WARNING: CPU: 0 PID: 2357 at lib/vsprintf.c:1867 vsnprintf+0x5a7/0x5c0() ...
We can trigger this issue by injecting maliciously crafted x509 cert in DER format. Just using hex editor to change the length of OID to over the length of the SEQUENCE container. For example:
0:d=0 hl=4 l= 980 cons: SEQUENCE
4:d=1 hl=4 l= 700 cons: SEQUENCE
8:d=2 hl=2 l= 3 cons: cont [ 0 ]
10:d=3 hl=2 l= 1 prim: INTEGER :02
13:d=2 hl=2 l= 9 prim: INTEGER :9B47FAF791E7D1E3
24:d=2 hl=2 l= 13 cons: SEQUENCE
26:d=3 hl=2 l= 9 prim: OBJECT :sha256WithRSAEncryption
37:d=3 hl=2 l= 0 prim: NULL
39:d=2 hl=2 l= 121 cons: SEQUENCE
41:d=3 hl=2 l= 22 cons: SET
43:d=4 hl=2 l= 20 cons: SEQUENCE <=== the SEQ length is 20
45:d=5 hl=2 l= 3 prim: OBJECT :organizationName
<=== the original length is 3, change the length of OID to over the length of SEQUENCEPawel Wieczorkiewicz reported this problem and Takashi Iwai provided patch to fix it by checking the bufsize in sprint_oid().
--- lib/oid_registry.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/oid_registry.c +2 -2
@@ -142,9 +142,9 @@ int sprint_oid(const void *data, size_t } ret += count =snprintf (buffer, bufsize,".%lu" , num); buffer += count; - bufsize -= count; -if (bufsize ==0 ) +if (bufsize <= count)return -ENOBUFS ; + bufsize -= count; }return ret;
PATCH 74/254 X.509: reject invalid BIT STRING for subjectPublicKey
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 0f30cbea005bd3077bd98cd29277d7fc2699c1da upstream.
Adding a specially crafted X.509 certificate whose subjectPublicKey ASN.1 value is zero-length caused x509_extract_key_data() to set the public key size to SIZE_MAX, as it subtracted the nonexistent BIT STRING metadata byte. Then, x509_cert_parse() called kmemdup() with that bogus size, triggering the WARN_ON_ONCE() in kmalloc_slab().
This appears to be harmless, but it still must be fixed since WARNs are never supposed to be user-triggerable.
Fix it by updating x509_cert_parse() to validate that the value has a BIT STRING metadata byte, and that the byte is 0 which indicates that the number of bits in the bitstring is a multiple of 8.
It would be nice to handle the metadata byte in asn1_ber_decoder() instead. But that would be tricky because in the general case a BIT STRING could be implicitly tagged, and/or could legitimately have a length that is not a whole number of bytes.
Here was the WARN (cleaned up slightly):
WARNING: CPU: 1 PID: 202 at mm/slab_common.c:971 kmalloc_slab+0x5d/0x70 mm/slab_common.c:971
Modules linked in:
CPU: 1 PID: 202 Comm: keyctl Tainted: G B 4.14.0-09238-g1d3b78bbc6e9 #26
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-20171110_100015-anatol 04/01/2014
task: ffff880033014180 task.stack: ffff8800305c8000
Call Trace:
__do_kmalloc mm/slab.c:3706 [inline]
__kmalloc_track_caller+0x22/0x2e0 mm/slab.c:3726
kmemdup+0x17/0x40 mm/util.c:118
kmemdup include/linux/string.h:414 [inline]
x509_cert_parse+0x2cb/0x620 crypto/asymmetric_keys/x509_cert_parser.c:106
x509_key_preparse+0x61/0x750 crypto/asymmetric_keys/x509_public_key.c:174
asymmetric_key_preparse+0xa4/0x150 crypto/asymmetric_keys/asymmetric_type.c:388
key_create_or_update+0x4d4/0x10a0 security/keys/key.c:850
SYSC_add_key security/keys/keyctl.c:122 [inline]
SyS_add_key+0xe8/0x290 security/keys/keyctl.c:62
entry_SYSCALL_64_fastpath+0x1f/0x96--- crypto/asymmetric_keys/x509_cert_parser.c | 2 ++ 1 file changed, 2 insertions(+)
crypto/asymmetric_keys/x509_cert_parser.c +2 -0
@@ -348,6 +348,8 @@ int x509_extract_key_data(void *context, ctx->cert->pub->pkey_algo =PKEY_ALGO_RSA ;/* Discard the BIT STRING metadata */ +if (vlen <1 || *(const u8 *)value !=0 ) +return -EBADMSG ; ctx->key = value +1 ; ctx->key_size = vlen -1 ;return 0 ;
PATCH 75/254 X.509: fix buffer overflow detection in sprint_oid()
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 47e0a208fb9d91e3f3c86309e752b13a36470ae8 upstream.
In sprint_oid(), if the input buffer were to be more than 1 byte too small for the first snprintf(), 'bufsize' would underflow, causing a buffer overflow when printing the remainder of the OID.
Fortunately this cannot actually happen currently, because no users pass in a buffer that can be too small for the first snprintf().
Regardless, fix it by checking the snprintf() return value correctly.
For consistency also tweak the second snprintf() check to look the same.
--- lib/oid_registry.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
lib/oid_registry.c +4 -4
@@ -120,10 +120,10 @@ int sprint_oid(const void *data, size_t n = *v++; ret = count =snprintf (buffer, bufsize,"%u.%u" , n /40 , n %40 ); +if (count >= bufsize) +return -ENOBUFS ; buffer += count; bufsize -= count; -if (bufsize ==0 ) -return -ENOBUFS ;while (v < end) { num =0 ;
@@ -141,9 +141,9 @@ int sprint_oid(const void *data, size_t }while (n &0x80 ); } ret += count =snprintf (buffer, bufsize,".%lu" , num); - buffer += count; -if (bufsize <= count) +if (count >= bufsize)return -ENOBUFS ; + buffer += count; bufsize -= count; }
PATCH 76/254 509: fix printing uninitialized stack memory when OID is empty
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 8dfd2f22d3bf3ab7714f7495ad5d897b8845e8c1 upstream.
Callers of sprint_oid() do not check its return value before printing the result. In the case where the OID is zero-length, -EBADMSG was being returned without anything being written to the buffer, resulting in uninitialized stack memory being printed. Fix this by writing "(bad)" to the buffer in the cases where -EBADMSG is returned.
--- lib/oid_registry.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
lib/oid_registry.c +6 -2
@@ -116,7 +116,7 @@ int sprint_oid(const void *data, size_tint count;if (v >= end) -return -EBADMSG ; + goto bad; n = *v++; ret = count =snprintf (buffer, bufsize,"%u.%u" , n /40 , n %40 );
@@ -134,7 +134,7 @@ int sprint_oid(const void *data, size_t num = n &0x7f ; do { if (v >= end) - return -EBADMSG; + goto bad; n = *v++; num <<= 7; num |= n & 0x7f;
@@ -148,6 +148,10 @@ int sprint_oid(const void *data, size_t }return ret; + +bad: +snprintf (buffer, bufsize,"(bad)" ); +return -EBADMSG ; }EXPORT_SYMBOL_GPL (sprint_oid);
PATCH 77/254 usb: musb: da8xx: fix babble condition handling
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Bin Liu <[email protected]>
commit bd3486ded7a0c313a6575343e6c2b21d14476645 upstream.
When babble condition happens, the musb controller might automatically turns off VBUS. On DA8xx platform, the controller generates drvvbus interrupt for turning off VBUS along with the babble interrupt.
In this case, we should handle the babble interrupt first and recover from the babble condition.
This change ignores the drvvbus interrupt if babble interrupt is also generated at the same time, so the babble recovery routine works properly.
--- drivers/usb/musb/da8xx.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/usb/musb/da8xx.c +9 -1
@@ -350,7 +350,15 @@ static irqreturn_t da8xx_musb_interrupt( musb->xceiv->state =OTG_STATE_A_WAIT_VRISE ;portstate (musb->port1_status |=USB_PORT_STAT_POWER );del_timer (&otg_workaround); - }else { + }else if (!(musb->int_usb &MUSB_INTR_BABBLE )) { +/* +* When babble condition happens, drvvbus interrupt +* is also generated. Ignore this drvvbus interrupt +* and let babble interrupt handler recovers the +* controller; otherwise, the host-mode flag is lost +* due to the MUSB_DEV_MODE() call below and babble +* recovery logic will not be called. +*/ musb->is_active =0 ;MUSB_DEV_MODE (musb); otg->default_a =0 ;
PATCH 78/254 USB: uas and storage: Add US_FL_BROKEN_FUA for another JMicron JMS567 ID
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: David Kozub <[email protected]>
commit 62354454625741f0569c2cbe45b2d192f8fd258e upstream.
There is another JMS567-based USB3 UAS enclosure (152d:0578) that fails with the following error:
[sda] tag#0 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE [sda] tag#0 Sense Key : Illegal Request [current]
[sda] tag#0 Add. Sense: Invalid field in cdb
The issue occurs both with UAS (occasionally) and mass storage (immediately after mounting a FS on a disk in the enclosure).
Enabling US_FL_BROKEN_FUA quirk solves this issue.
This patch adds an UNUSUAL_DEV with US_FL_BROKEN_FUA for the enclosure for both UAS and mass storage.
--- drivers/usb/storage/unusual_devs.h | 7 +++++++ drivers/usb/storage/unusual_uas.h | 7 +++++++ 2 files changed, 14 insertions(+)
drivers/usb/storage/unusual_devs.h +7 -0
@@ -1981,6 +1981,13 @@ UNUSUAL_DEV( 0x152d, 0x0567, 0x0114, 0x USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_BROKEN_FUA ), +/* Reported by David Kozub <[email protected]> */ +UNUSUAL_DEV (0x152d ,0x0578 ,0x0000 ,0x9999 , +"JMicron" , +"JMS567" , +USB_SC_DEVICE ,USB_PR_DEVICE ,NULL , + US_FL_BROKEN_FUA), +/* Reported by Alexandre Oliva <[email protected]> * JMicron responds to USN and several other SCSI ioctls with a * residue that causes subsequent I/O requests to fail. */
drivers/usb/storage/unusual_uas.h +7 -0
@@ -131,6 +131,13 @@ UNUSUAL_DEV(0x152d, 0x0567, 0x0000, 0x99 USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_BROKEN_FUA | US_FL_NO_REPORT_OPCODES), +/* Reported-by: David Kozub <[email protected]> */ +UNUSUAL_DEV (0x152d ,0x0578 ,0x0000 ,0x9999 , +"JMicron" , +"JMS567" , +USB_SC_DEVICE ,USB_PR_DEVICE ,NULL , +US_FL_BROKEN_FUA ), +/* Reported-by: Hans de Goede <[email protected]> */ UNUSUAL_DEV(0x2109, 0x0711, 0x0000, 0x9999, "VIA",
PATCH 79/254 ASoC: wm_adsp: Don't overrun firmware file buffer when reading region data
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Fitzgerald <[email protected]>
commit 1cab2a84f470e15ecc8e5143bfe9398c6e888032 upstream.
Protect against corrupt firmware files by ensuring that the length we get for the data in a region actually lies within the available firmware file data buffer.
--- sound/soc/codecs/wm_adsp.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
sound/soc/codecs/wm_adsp.c +24 -1
@@ -532,7 +532,7 @@ static int wm_adsp_load(struct wm_adsp *const struct wmfw_region *region;const struct wm_adsp_region *mem;const char *region_name; -char *file, *text; +char *file, *text =NULL ;struct wm_adsp_buf *buf;unsigned int reg;int regions =0 ;
@@ -677,10 +677,21 @@ static int wm_adsp_load(struct wm_adsp * regions,le32_to_cpu (region->len), offset, region_name); +if ((pos +le32_to_cpu (region->len) +sizeof (*region)) > + firmware->size) { +adsp_err (dsp, +"%s.%d: %s region len %d bytes exceeds file length %zu\n" , + file, regions, region_name, +le32_to_cpu (region->len), firmware->size); + ret = -EINVAL ; + goto out_fw; + } +if (text) {memcpy (text, region->data,le32_to_cpu (region->len));adsp_info (dsp,"%s: %s\n" , file, text);kfree (text); + text =NULL ; }if (reg) {
@@ -737,6 +748,7 @@ out_fw:regmap_async_complete (regmap);wm_adsp_buf_free (&buf_list);release_firmware (firmware); +kfree (text); out:kfree (file);
@@ -1316,6 +1328,17 @@ static int wm_adsp_load_coeff(struct wm_ }if (reg) { +if ((pos +le32_to_cpu (blk->len) +sizeof (*blk)) > + firmware->size) { +adsp_err (dsp, +"%s.%d: %s region len %d bytes exceeds file length %zu\n" , + file, blocks, region_name, +le32_to_cpu (blk->len), + firmware->size); + ret = -EINVAL ; + goto out_fw; + } + buf =wm_adsp_buf_alloc (blk->data,le32_to_cpu (blk->len), &buf_list);
PATCH 80/254 ASoC: wm_adsp: Fix validation of firmware and coeff lengths
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ben Hutchings <[email protected]>
commit 50dd2ea8ef67a1617e0c0658bcbec4b9fb03b936 upstream.
The checks for whether another region/block header could be present are subtracting the size from the current offset. Obviously we should instead subtract the offset from the size.
The checks for whether the region/block data fit in the file are adding the data size to the current offset and header size, without checking for integer overflow. Rearrange these so that overflow is impossible.
--- sound/soc/codecs/wm_adsp.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
sound/soc/codecs/wm_adsp.c +6 -6
@@ -622,7 +622,7 @@ static int wm_adsp_load(struct wm_adsp * le64_to_cpu(footer->timestamp));while (pos < firmware->size && - pos - firmware->size >sizeof (*region)) { +sizeof (*region) < firmware->size - pos) { region = (void *)&(firmware->data[pos]); region_name ="Unknown" ; reg =0 ;
@@ -677,8 +677,8 @@ static int wm_adsp_load(struct wm_adsp * regions,le32_to_cpu (region->len), offset, region_name); -if ((pos +le32_to_cpu (region->len) +sizeof (*region)) > - firmware->size) { +if (le32_to_cpu (region->len) > + firmware->size - pos -sizeof (*region)) { adsp_err(dsp, "%s.%d: %s region len %d bytes exceeds file length %zu\n", file, regions, region_name,
@@ -1248,7 +1248,7 @@ static int wm_adsp_load_coeff(struct wm_ blocks =0 ;while (pos < firmware->size && - pos - firmware->size >sizeof (*blk)) { +sizeof (*blk) < firmware->size - pos) { blk = (void *)(&firmware->data[pos]); type =le16_to_cpu (blk->type);
@@ -1328,8 +1328,8 @@ static int wm_adsp_load_coeff(struct wm_ }if (reg) { -if ((pos +le32_to_cpu (blk->len) +sizeof (*blk)) > - firmware->size) { +if (le32_to_cpu (blk->len) > + firmware->size - pos -sizeof (*blk)) { adsp_err(dsp, "%s.%d: %s region len %d bytes exceeds file length %zu\n", file, blocks, region_name,
PATCH 81/254 xhci: Don't add a virt_dev to the devs array before it's fully allocated
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit 5d9b70f7d52eb14bb37861c663bae44de9521c35 upstream.
Avoid null pointer dereference if some function is walking through the devs array accessing members of a new virt_dev that is mid allocation.
Add the virt_dev to xhci->devs[i] _after_ the virt_device and all its members are properly allocated.
issue found by KASAN: null-ptr-deref in xhci_find_slot_id_by_port
"Quick analysis suggests that xhci_alloc_virt_device() is not mutex protected. If so, there is a time frame where xhci->devs[slot_id] is set but not fully initialized. Specifically, xhci->devs[i]->udev can be NULL."
[bwh: Backported to 3.16: There is an extra failure path, so we may need to
free dev->eps[0].ring]
---
drivers/usb/host/xhci-mem.c +13 -4
@@ -1018,10 +1018,9 @@ int xhci_alloc_virt_device(struct xhci_hreturn 0 ; } - xhci->devs[slot_id] =kzalloc (sizeof (*xhci->devs[slot_id]), flags); -if (!xhci->devs[slot_id]) + dev =kzalloc (sizeof (*dev), flags); +if (!dev)return 0 ; - dev = xhci->devs[slot_id];/* Allocate the (output) device context that will be used in the HC. */ dev->out_ctx =xhci_alloc_container_ctx (xhci,XHCI_CTX_TYPE_DEVICE , flags);
@@ -1069,9 +1068,19 @@ int xhci_alloc_virt_device(struct xhci_h &xhci->dcbaa->dev_context_ptrs[slot_id], le64_to_cpu(xhci->dcbaa->dev_context_ptrs[slot_id])); + xhci->devs[slot_id] = dev; +return 1 ; fail: -xhci_free_virt_device (xhci, slot_id); + +if (dev->eps[0 ].ring) +xhci_ring_free (xhci, dev->eps[0 ].ring); +if (dev->in_ctx) +xhci_free_container_ctx (xhci, dev->in_ctx); +if (dev->out_ctx) +xhci_free_container_ctx (xhci, dev->out_ctx); +kfree (dev); +return 0 ; }
PATCH 82/254 dmaengine: dmatest: warn user when dma test times out
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Adam Wallis <[email protected]>
commit a9df21e34b422f79d9a9fa5c3eff8c2a53491be6 upstream.
Commit adfa543e7314 ("dmatest: don't use set_freezable_with_signal()") introduced a bug (that is in fact documented by the patch commit text) that leaves behind a dangling pointer. Since the done_wait structure is allocated on the stack, future invocations to the DMATEST can produce undesirable results (e.g., corrupted spinlocks). Ideally, this would be cleaned up in the thread handler, but at the very least, the kernel is left in a very precarious scenario that can lead to some long debug sessions when the crash comes later.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=197605
--- drivers/dma/dmatest.c | 1 + 1 file changed, 1 insertion(+)
drivers/dma/dmatest.c +1 -0
@@ -633,6 +633,7 @@ static int dmatest_func(void *data)* free it this time?" dancing. For now, just * leave it dangling. */ +WARN (1 ,"dmatest: Kernel stack may be corrupted!!\n" );dmaengine_unmap_put (um);result ("test timed out" , total_tests, src_off, dst_off, len,0 );
PATCH 83/254 dmaengine: dmatest: move callback wait queue to thread context
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Adam Wallis <[email protected]>
commit 6f6a23a213be51728502b88741ba6a10cda2441d upstream.
Commit adfa543e7314 ("dmatest: don't use set_freezable_with_signal()") introduced a bug (that is in fact documented by the patch commit text) that leaves behind a dangling pointer. Since the done_wait structure is allocated on the stack, future invocations to the DMATEST can produce undesirable results (e.g., corrupted spinlocks).
Commit a9df21e34b42 ("dmaengine: dmatest: warn user when dma test times out") attempted to WARN the user that the stack was likely corrupted but did not fix the actual issue.
This patch fixes the issue by pushing the wait queue and callback structs into the the thread structure. If a failure occurs due to time, dmaengine_terminate_all will force the callback to safely call wake_up_all() without possibility of using a freed pointer.
--- drivers/dma/dmatest.c | 55 +++++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 24 deletions(-)
drivers/dma/dmatest.c +31 -24
@@ -148,6 +148,12 @@ MODULE_PARM_DESC(run, "Run the test (def#define PATTERN_OVERWRITE 0x20#define PATTERN_COUNT_MASK 0x1f +/* poor man's completion - we want to use wait_event_freezable() on it */ +struct dmatest_done { +bool done; +wait_queue_head_t *wait; +}; +struct dmatest_thread {struct list_head node;struct dmatest_info *info;
@@ -156,6 +162,8 @@ struct dmatest_thread {u8 **srcs;u8 **dsts;enum dma_transaction_type type; +wait_queue_head_t done_wait; +struct dmatest_done test_done;bool done; };
@@ -316,18 +324,25 @@ static unsigned int dmatest_verify(u8 **return error_count; } -/* poor man's completion - we want to use wait_event_freezable() on it */ -struct dmatest_done { -bool done; -wait_queue_head_t *wait; -};static void dmatest_callback (void *arg) {struct dmatest_done *done = arg; - - done->done = true; -wake_up_all (done->wait); +struct dmatest_thread *thread = + container_of(arg, struct dmatest_thread, done_wait); +if (!thread->done) { + done->done = true; +wake_up_all (done->wait); + }else { +/* +* If thread->done, it means that this callback occurred +* after the parent thread has cleaned up. This can +* happen in the case that driver doesn't implement +* the terminate_all() functionality and a dma operation +* did not occur within the timeout period +*/ +WARN (1 ,"dmatest: Kernel memory may be corrupted!!\n" ); + } }static unsigned int min_odd (unsigned int x,unsigned int y)
@@ -398,9 +413,8 @@ static unsigned long long dmatest_KBs(s6*/ static int dmatest_func (void *data) { -DECLARE_WAIT_QUEUE_HEAD_ONSTACK (done_wait);struct dmatest_thread *thread = data; -struct dmatest_done done = { .wait = &done_wait }; +struct dmatest_done *done = &thread->test_done;struct dmatest_info *info;struct dmatest_params *params;struct dma_chan *chan;
@@ -604,9 +618,9 @@ static int dmatest_func(void *data)continue ; } - done.done = false; + done->done = false; tx->callback = dmatest_callback; - tx->callback_param = &done; + tx->callback_param = done; cookie = tx->tx_submit (tx);if (dma_submit_error (cookie)) {
@@ -619,21 +633,12 @@ static int dmatest_func(void *data) }dma_async_issue_pending (chan); -wait_event_freezable_timeout (done_wait, done.done, +wait_event_freezable_timeout (thread->done_wait, done->done,msecs_to_jiffies (params->timeout)); status =dma_async_is_tx_complete (chan, cookie,NULL ,NULL ); -if (!done.done) { -/* -* We're leaving the timed out dma operation with -* dangling pointer to done_wait. To make this -* correct, we'll need to allocate wait_done for -* each test iteration and perform "who's gonna -* free it this time?" dancing. For now, just -* leave it dangling. -*/ -WARN (1 ,"dmatest: Kernel stack may be corrupted!!\n" ); +if (!done->done) {dmaengine_unmap_put (um);result ("test timed out" , total_tests, src_off, dst_off, len,0 );
@@ -707,7 +712,7 @@ err_thread_type: dmatest_KBs(runtime, total_len), ret);/* terminate all transfers on specified channels */ -if (ret) +if (ret || failed_tests)dmaengine_terminate_all (chan); thread->done = true;
@@ -765,6 +770,8 @@ static int dmatest_add_threads(struct dm thread->info = info; thread->chan = dtc->chan; thread->type = type; + thread->test_done.wait = &thread->done_wait; +init_waitqueue_head (&thread->done_wait);smp_wmb (); thread->task =kthread_create (dmatest_func, thread,"%s-%s%u" ,dma_chan_name (chan), op, i);
Re: [PATCH 3.16 083/254] dmaengine: dmatest: move callback wait queue to thread context
Ben
Quoted 23 lines · Ben Hutchings
3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Adam Wallis <[email protected]>
commit
6f6a23a213be51728502b88741ba6a10cda2441dupstream.Commit
adfa543e7314("dmatest: don't useset_freezable_with_signal()") introduced a bug (that is in fact documented by the patch commit text) that leaves behind a dangling pointer. Since thedone_waitstructure is allocated on the stack, future invocations to the DMATEST can produce undesirable results (e.g., corrupted spinlocks).Commit
a9df21e34b42("dmaengine: dmatest: warn user when dma test times out") attempted to WARN the user that the stack was likely corrupted but did not fix the actual issue.This patch fixes the issue by pushing the wait queue and callback structs into the the thread structure. If a failure occurs due to time,
dmaengine_terminate_allwill force the callback to safely callwake_up_all()without possibility of using a freed pointer.
Quoted 7 lines
Fixes adfa543e7314 ("dmatest: don't use set_freezable_with_signal()")Reviewed-by Sinan Kaya <[email protected]>Suggested-by Shunyong Yang <[email protected]>Signed-off-by Adam Wallis <[email protected]>Signed-off-by Vinod Koul <[email protected]>Signed-off-by Ben Hutchings <[email protected]>
[..]
Make sure you pick up the following bug fix on whatever branch you apply the above patch to
Quoted 1 line
From
66b3bd2356e0a1531c71a3dcf96944621e25c17cMon Sep 17 00:00:00 2001
From: Yang Shunyong <[email protected]>
Date: Mon, 29 Jan 2018 14:40:11 +0800
Subject: dmaengine: dmatest: fix container_of member in dmatest_callback
From: Yang Shunyong <[email protected]>
commit 66b3bd2356e0a1531c71a3dcf96944621e25c17c upstream.
The type of arg passed to dmatest_callback is struct dmatest_done. It refers to test_done in struct dmatest_thread, not done_wait.
Signature · 4 lines
Adam Wallis Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [PATCH 3.16 083/254] dmaengine: dmatest: move callback wait queue to thread context
Quoted 40 lines · Adam Wallis
Ben
Quoted 23 lines · Ben Hutchings
3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Adam Wallis <[email protected]>
commit
6f6a23a213be51728502b88741ba6a10cda2441dupstream.Commit
adfa543e7314("dmatest: don't useset_freezable_with_signal()") introduced a bug (that is in fact documented by the patch commit text) that leaves behind a dangling pointer. Since thedone_waitstructure is allocated on the stack, future invocations to the DMATEST can produce undesirable results (e.g., corrupted spinlocks).Commit
a9df21e34b42("dmaengine: dmatest: warn user when dma test times out") attempted to WARN the user that the stack was likely corrupted but did not fix the actual issue.This patch fixes the issue by pushing the wait queue and callback structs into the the thread structure. If a failure occurs due to time,
dmaengine_terminate_allwill force the callback to safely callwake_up_all()without possibility of using a freed pointer.Quoted 7 lines
Fixes adfa543e7314 ("dmatest: don't use set_freezable_with_signal()")Reviewed-by Sinan Kaya <[email protected]>Suggested-by Shunyong Yang <[email protected]>Signed-off-by Adam Wallis <[email protected]>Signed-off-by Vinod Koul <[email protected]>Signed-off-by Ben Hutchings <[email protected]>[..]
Make sure you pick up the following bug fix on whatever branch you apply the above patch to
Quoted 8 lines
From
66b3bd2356e0a1531c71a3dcf96944621e25c17cMon Sep 17 00:00:00 2001
From: Yang Shunyong <[email protected]>
Date: Mon, 29 Jan 2018 14:40:11 +0800
Subject: dmaengine: dmatest: fixcontainer_ofmember indmatest_callbackFrom: Yang Shunyong <[email protected]>
commit
66b3bd2356e0a1531c71a3dcf96944621e25c17cupstream.
Thanks, I've added this.
Ben.
Quoted 11 lines
The type of arg passed to
dmatest_callbackis structdmatest_done. It refers totest_donein structdmatest_thread, notdone_wait.Fixes 6f6a23a213be ("dmaengine: dmatest: move callback wait ...")Signed-off-by Yang Shunyong <[email protected]>Acked-by Adam Wallis <[email protected]>Signed-off-by Vinod Koul <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Signature · 6 lines
Ben Hutchings [W]e found...that it wasn't as easy to get programs right as we had thought. ... I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs. - Maurice Wilkes, 1949
PATCH 84/254 dmaengine: jz4740: disable/unprepare clk if probe fails
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Tobias Jordan <[email protected]>
commit eb9436966fdc84cebdf222952a99898ab46d9bb0 upstream.
in error path of jz4740_dma_probe(), call clk_disable_unprepare() to clean up.
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/dma/dma-jz4740.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/dma/dma-jz4740.c +3 -1
@@ -574,7 +574,7 @@ static int jz4740_dma_probe(struct platf ret =dma_async_device_register (dd);if (ret) -return ret; + goto err_clk; irq =platform_get_irq (pdev,0 ); ret =request_irq (irq, jz4740_dma_irq,0 ,dev_name (&pdev->dev), dmadev);
@@ -587,6 +587,8 @@ static int jz4740_dma_probe(struct platf err_unregister:dma_async_device_unregister (dd); +err_clk: +clk_disable_unprepare (dmadev->clk);return ret; }
PATCH 85/254 nl80211: fix nl80211_send_iface() error paths
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit 4564b187c16327045d87596e8980c65ba7b84c50 upstream.
Evidently I introduced a locking bug in my change here, the nla_put_failure sometimes needs to unlock. Fix it.
--- net/wireless/nl80211.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/wireless/nl80211.c +4 -2
@@ -2346,7 +2346,7 @@ static int nl80211_send_iface(struct sk_case NL80211_IFTYPE_AP :if (wdev->ssid_len &&nla_put (msg,NL80211_ATTR_SSID , wdev->ssid_len, wdev->ssid)) - goto nla_put_failure; + goto nla_put_failure_locked;break ;case NL80211_IFTYPE_STATION :case NL80211_IFTYPE_P2P_CLIENT :
@@ -2359,7 +2359,7 @@ static int nl80211_send_iface(struct sk_if (!ssid_ie)break ;if (nla_put (msg,NL80211_ATTR_SSID , ssid_ie[1 ], ssid_ie +2 )) - goto nla_put_failure; + goto nla_put_failure_locked;break ; }default :
@@ -2370,6 +2370,8 @@ static int nl80211_send_iface(struct sk_return genlmsg_end (msg, hdr); + nla_put_failure_locked: +wdev_unlock (wdev); nla_put_failure:genlmsg_cancel (msg, hdr);return -EMSGSIZE ;
PATCH 86/254 ipv4: Use standard iovec primitive in raw_probe_proto_opt
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
commit 32b5913a931fd753faf3d4e1124b2bc2edb364da upstream.
The function raw_probe_proto_opt tries to extract the first two bytes from the user input in order to seed the IPsec lookup for ICMP packets. In doing so it's processing iovec by hand and overcomplicating things.
This patch replaces the manual iovec processing with a call to memcpy_fromiovecend.
--- net/ipv4/raw.c | 50 +++++++++++--------------------------------------- 1 file changed, 11 insertions(+), 39 deletions(-)
net/ipv4/raw.c +11 -39
@@ -417,48 +417,20 @@ error:static int raw_probe_proto_opt (struct flowi4 *fl4,struct msghdr *msg) { -struct iovec *iov; -u8 __user *type =NULL ; -u8 __user *code =NULL ; -int probed =0 ; -unsigned int i; +struct icmphdr icmph; +int err; -if (!msg->msg_iov) +if (fl4->flowi4_proto !=IPPROTO_ICMP )return 0 ; -for (i =0 ; i < msg->msg_iovlen; i++) { - iov = &msg->msg_iov[i]; -if (!iov) -continue ; - -switch (fl4->flowi4_proto) { -case IPPROTO_ICMP : -/* check if one-byte field is readable or not. */ -if (iov->iov_base && iov->iov_len <1 ) -break ; - -if (!type) { - type = iov->iov_base; -/* check if code field is readable or not. */ -if (iov->iov_len >1 ) - code = type +1 ; - }else if (!code) - code = iov->iov_base; - -if (type && code) { -if (get_user (fl4->fl4_icmp_type, type) || -get_user (fl4->fl4_icmp_code, code)) -return -EFAULT ; - probed =1 ; - } -break ; -default : - probed =1 ; -break ; - } -if (probed) -break ; - } +/* We only need the first two bytes. */ + err =memcpy_fromiovecend ((void *)&icmph, msg->msg_iov,0 ,2 ); +if (err) +return err; + + fl4->fl4_icmp_type = icmph.type; + fl4->fl4_icmp_code = icmph.code; +return 0 ; }
PATCH 87/254 ipv4: Avoid reading user iov twice after raw_probe_proto_opt
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
commit c008ba5bdc9fa830e1a349b20b0be5a137bdef7a upstream.
Ever since raw_probe_proto_opt was added it had the problem of causing the user iov to be read twice, once during the probe for the protocol header and once again in ip_append_data.
This is a potential security problem since it means that whatever we're probing may be invalid. This patch plugs the hole by firstly advancing the iov so we don't read the same spot again, and secondly saving what we read the first time around for use by ip_append_data.
--- net/ipv4/raw.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 8 deletions(-)
net/ipv4/raw.c +54 -8
@@ -78,6 +78,16 @@#include <linux/netfilter.h> #include <linux/netfilter_ipv4.h> #include <linux/compat.h> +#include <linux/uio.h> + +struct raw_frag_vec { +struct iovec *iov; +union { +struct icmphdr icmph; +char c[1 ]; + } hdr; +int hlen; +};static struct raw_hashinfo raw_v4_hashinfo = { .lock =__RW_LOCK_UNLOCKED (raw_v4_hashinfo.lock),
@@ -415,25 +425,57 @@ error:return err; } -static int raw_probe_proto_opt (struct flowi4 *fl4,struct msghdr *msg) +static int raw_probe_proto_opt (struct raw_frag_vec *rfv,struct flowi4 *fl4) { -struct icmphdr icmph;int err;if (fl4->flowi4_proto !=IPPROTO_ICMP )return 0 ;/* We only need the first two bytes. */ - err =memcpy_fromiovecend ((void *)&icmph, msg->msg_iov,0 ,2 ); + rfv->hlen =2 ; + + err =memcpy_fromiovec (rfv->hdr.c, rfv->iov, rfv->hlen);if (err)return err; - fl4->fl4_icmp_type = icmph.type; - fl4->fl4_icmp_code = icmph.code; + fl4->fl4_icmp_type = rfv->hdr.icmph.type; + fl4->fl4_icmp_code = rfv->hdr.icmph.code;return 0 ; } +static int raw_getfrag (void *from,char *to,int offset,int len,int odd, +struct sk_buff *skb) +{ +struct raw_frag_vec *rfv = from; + +if (offset < rfv->hlen) { +int copy =min (rfv->hlen - offset, len); + +if (skb->ip_summed ==CHECKSUM_PARTIAL ) +memcpy (to, rfv->hdr.c + offset, copy); +else + skb->csum =csum_block_add ( + skb->csum, +csum_partial_copy_nocheck (rfv->hdr.c + offset, + to, copy,0 ), + odd); + + odd =0 ; + offset += copy; + to += copy; + len -= copy; + +if (!len) +return 0 ; + } + + offset -= rfv->hlen; + +return ip_generic_getfrag (rfv->iov, to, offset, len, odd, skb); +} +static int raw_sendmsg (struct kiocb *iocb,struct sock *sk,struct msghdr *msg,size_t len) {
@@ -447,6 +489,7 @@ static int raw_sendmsg(struct kiocb *iocu8 tos;int err;struct ip_options_data opt_copy; +struct raw_frag_vec rfv; err = -EMSGSIZE ;if (len >0xFFFF )
@@ -554,7 +597,10 @@ static int raw_sendmsg(struct kiocb *ioc daddr, saddr, 0, 0);if (!inet->hdrincl) { - err =raw_probe_proto_opt (&fl4, msg); + rfv.iov = msg->msg_iov; + rfv.hlen =0 ; + + err =raw_probe_proto_opt (&rfv, &fl4);if (err) goto done; }
@@ -583,8 +629,8 @@ back_from_confirm:if (!ipc.addr) ipc.addr = fl4.daddr;lock_sock (sk); - err =ip_append_data (sk, &fl4, ip_generic_getfrag, - msg->msg_iov, len,0 , + err =ip_append_data (sk, &fl4, raw_getfrag, + &rfv, len,0 , &ipc, &rt, msg->msg_flags);if (err)ip_flush_pending_frames (sk);
PATCH 88/254 net: ipv4: fix for a race condition in raw_sendmsg
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mohamed Ghannam <[email protected]>
commit 8f659a03a0ba9289b9aeb9b4470e6fb263d6f483 upstream.
inet->hdrincl is racy, and could lead to uninitialized stack pointer usage, so its value should be read only once.
--- net/ipv4/raw.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
net/ipv4/raw.c +10 -5
@@ -490,11 +490,16 @@ static int raw_sendmsg(struct kiocb *iocint err;struct ip_options_data opt_copy;struct raw_frag_vec rfv; +int hdrincl; err = -EMSGSIZE ;if (len >0xFFFF ) goto out; +/* hdrincl should be READ_ONCE(inet->hdrincl) +* but READ_ONCE() doesn't work with bit fields +*/ + hdrincl = inet->hdrincl;/* * Check the flags. */
@@ -569,7 +574,7 @@ static int raw_sendmsg(struct kiocb *ioc/* Linux does not mangle headers on raw sockets, * so that IP options + IP_HDRINCL is non-sense. */ -if (inet->hdrincl) +if (hdrincl) goto done;if (ipc.opt->opt.srr) {if (!daddr)
@@ -591,12 +596,12 @@ static int raw_sendmsg(struct kiocb *iocflowi4_init_output (&fl4, ipc.oif, sk->sk_mark, tos,RT_SCOPE_UNIVERSE , - inet->hdrincl ?IPPROTO_RAW : sk->sk_protocol, + hdrincl ?IPPROTO_RAW : sk->sk_protocol,inet_sk_flowi_flags (sk) | - (inet->hdrincl ?FLOWI_FLAG_KNOWN_NH :0 ), + (hdrincl ?FLOWI_FLAG_KNOWN_NH :0 ), daddr, saddr,0 ,0 ); -if (!inet->hdrincl) { +if (!hdrincl) { rfv.iov = msg->msg_iov; rfv.hlen =0 ;
@@ -621,7 +626,7 @@ static int raw_sendmsg(struct kiocb *ioc goto do_confirm; back_from_confirm: -if (inet->hdrincl) +if (hdrincl) err =raw_send_hdrinc (sk, &fl4, msg->msg_iov, len, &rt, msg->msg_flags);
PATCH 89/254 ext4: fix crash when a directory's i_size is too small
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Chandan Rajendra <[email protected]>
commit 9d5afec6b8bd46d6ed821aa1579634437f58ef1f upstream.
On a ppc64 machine, when mounting a fuzzed ext2 image (generated by fsfuzzer) the following call trace is seen,
VFS: brelse: Trying to free free buffer
WARNING: CPU: 1 PID: 6913 at /root/repos/linux/fs/buffer.c:1165 .__brelse.part.6+0x24/0x40 .__brelse.part.6+0x20/0x40 (unreliable) .ext4_find_entry+0x384/0x4f0 .ext4_lookup+0x84/0x250 .lookup_slow+0xdc/0x230 .walk_component+0x268/0x400 .path_lookupat+0xec/0x2d0 .filename_lookup+0x9c/0x1d0 .vfs_statx+0x98/0x140 .SyS_newfstatat+0x48/0x80 system_call+0x58/0x6c
This happens because the directory that ext4_find_entry() looks up has inode->i_size that is less than the block size of the filesystem. This causes 'nblocks' to have a value of zero. ext4_bread_batch() ends up not reading any of the directory file's blocks. This renders the entries in bh_use[] array to continue to have garbage data. buffer_uptodate() on bh_use[0] can then return a zero value upon which brelse() function is invoked.
This commit fixes the bug by returning -ENOENT when the directory file has no associated blocks.
--- fs/ext4/namei.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/ext4/namei.c +4 -0
@@ -1267,6 +1267,10 @@ static struct buffer_head * ext4_find_en "falling back\n")); } nblocks = dir->i_size >>EXT4_BLOCK_SIZE_BITS (sb); +if (!nblocks) { + ret =NULL ; + goto cleanup_and_exit; + } start =EXT4_I (dir)->i_dir_start_lookup;if (start >= nblocks) start =0 ;
PATCH 90/254 tcp md5sig: Use skb's saddr when replying to an incoming segment
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Paasch <[email protected]>
commit 30791ac41927ebd3e75486f9504b6d2280463bf0 upstream.
The MD5-key that belongs to a connection is identified by the peer's IP-address. When we are in tcp_v4(6)_reqsk_send_ack(), we are replying to an incoming segment from tcp_check_req() that failed the seq-number checks.
Thus, to find the correct key, we need to use the skb's saddr and not the daddr.
This bug seems to have been there since quite a while, but probably got unnoticed because the consequences are not catastrophic. We will call tcp_v4_reqsk_send_ack only to send a challenge-ACK back to the peer, thus the connection doesn't really fail.
--- net/ipv4/tcp_ipv4.c | 2 +- net/ipv6/tcp_ipv6.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/ipv4/tcp_ipv4.c +1 -1
@@ -809,7 +809,7 @@ static void tcp_v4_reqsk_send_ack(struct tcp_time_stamp, req->ts_recent,0 , -tcp_md5_do_lookup (sk, (union tcp_md5_addr *)&ip_hdr (skb)->daddr, +tcp_md5_do_lookup (sk, (union tcp_md5_addr *)&ip_hdr (skb)->saddr,AF_INET ),inet_rsk (req)->no_srccheck ?IP_REPLY_ARG_NOSRCCHECK :0 , ip_hdr(skb)->tos);
net/ipv6/tcp_ipv6.c +1 -1
@@ -941,7 +941,7 @@ static void tcp_v6_reqsk_send_ack(struct tcp_rsk(req)->snt_isn + 1 : tcp_sk(sk)->snd_nxt,tcp_rsk (req)->rcv_nxt, req->rcv_wnd, tcp_time_stamp, req->ts_recent, sk->sk_bound_dev_if, -tcp_v6_md5_do_lookup (sk, &ipv6_hdr (skb)->daddr), +tcp_v6_md5_do_lookup (sk, &ipv6_hdr (skb)->saddr), 0, 0); }
PATCH 91/254 MIPS: CPS: Fix r1 .set mt assembler warning
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit 17278a91e04f858155d54bee5528ba4fbcec6f87 upstream.
MIPS CPS has a build warning on kernels configured for MIPS32R1 or MIPS64R1, due to the use of .set mt without a prior .set mips{32,64}r2:
arch/mips/kernel/cps-vec.S Assembler messages:arch/mips/kernel/cps-vec.S:238: Warning: the `mt' extension requires MIPS32 revision 2 or greater
Add .set MIPS_ISA_LEVEL_RAW before .set mt to silence the warning.
Patchwork: https://patchwork.linux-mips.org/patch/17699/
--- arch/mips/kernel/cps-vec.S | 2 ++ 1 file changed, 2 insertions(+)
arch/mips/kernel/cps-vec.S +2 -0
@@ -229,6 +229,7 @@ LEAF(mips_cps_core_init) has_mt t0, 3f .set push + .set MIPS_ISA_LEVEL_RAW .set mt /* Only allow 1 TC per VPE to execute... */
@@ -347,6 +348,7 @@ LEAF(mips_cps_boot_vpes) nop .set push + .set MIPS_ISA_LEVEL_RAW .set mt 1: /* Enter VPE configuration state */
Re: [PATCH 3.16 091/254] MIPS: CPS: Fix r1 .set mt assembler warning
Quoted 7 lines · Ben Hutchings
3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit
17278a91e04f858155d54bee5528ba4fbcec6f87upstream.
You'll want this too:
8dbc1864b74f5dea5a3f7c30ca8fd358a675132f
MIPS: CPS: Fix MIPS_ISA_LEVEL_RAW fallout
Its only tagged for stable 4.15 since the one it fixes wasn't tagged for stable.
If you're going to select patches for backporting based on Fixes tags, maybe its worth looking for patches which are marked as fixing ones you've backported too.
Cheers
James
Ben Hutchings
Tested-by Greg UngererRe: [PATCH 3.16 091/254] MIPS: CPS: Fix r1 .set mt assembler warning
Quoted 14 lines · James Hogan
Quoted 7 lines · Ben Hutchings
3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit
17278a91e04f858155d54bee5528ba4fbcec6f87upstream.You'll want this too:
8dbc1864b74f5dea5a3f7c30ca8fd358a675132f
MIPS: CPS: FixMIPS_ISA_LEVEL_RAWfallout
Quoted 6 lines
Its only tagged for stable 4.15 since the one it fixes wasn't tagged for stable.
If you're going to select patches for backporting based on Fixes tags, maybe its worth looking for patches which are marked as fixing ones you've backported too.
I do that, but didn't look beyond v4.15 yet. Here's the version of that fix I've ended up with for 3.16.
Ben.
Signature · 5 lines
Ben Hutchings [W]e found...that it wasn't as easy to get programs right as we had thought. ... I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs. - Maurice Wilkes, 1949
From: James Hogan <[email protected]>
Date: Fri, 2 Feb 2018 14:36:40 +0000
Subject: MIPS: CPS: Fix MIPS_ISA_LEVEL_RAW fallout
commit 8dbc1864b74f5dea5a3f7c30ca8fd358a675132f upstream.
Commit 17278a91e04f ("MIPS: CPS: Fix r1 .set mt assembler warning") added .set MIPS_ISA_LEVEL_RAW to silence warnings about .set mt on r1, however this can result in a MOVE being encoded as a 64-bit DADDU instruction on certain version of binutils (e.g. 2.22), and reserved instruction exceptions at runtime on 32-bit hardware.
Reduce the sizes of the push/pop sections to include only instructions that are part of the MT ASE or which won't convert to 64-bit instructions after .set mips64r2/mips64r6.
Patchwork: https://patchwork.linux-mips.org/patch/18578/
---
arch/mips/kernel/cps-vec.S +10 -3
@@ -347,12 +347,13 @@ LEAF(mips_cps_boot_vpes) jr ra nop +1: /* Enter VPE configuration state */ .set push .set MIPS_ISA_LEVEL_RAW .set mt - -1: /* Enter VPE configuration state */ dvpe + .set pop + la t1, 1f jr.hb t1 nop
@@ -379,6 +380,10 @@ LEAF(mips_cps_boot_vpes) mtc0 t0, CP0_VPECONTROL ehb + .set push + .set MIPS_ISA_LEVEL_RAW + .set mt + /* Skip the VPE if its TC is not halted */ mftc0 t0, CP0_TCHALT beqz t0, 2f
@@ -437,6 +442,8 @@ LEAF(mips_cps_boot_vpes) ehb evpe + .set pop + /* Check whether this VPE is meant to be running */ li t0, 1 sll t0, t0, t9
@@ -451,7 +458,7 @@ LEAF(mips_cps_boot_vpes) 1: jr.hb t0 nop -2: .set pop +2: #endif /* CONFIG_MIPS_MT_SMP */
PATCH 92/254 MIPS: clear MSACSR cause bits when handling MSA FP exception
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paul Burton <[email protected]>
commit 091be550a70a086c3b4420c6155e733dc410f190 upstream.
Much like for traditional scalar FP exceptions, the cause bits in the MSACSR register need to be cleared following an MSA FP exception. Without doing so the exception will simply be raised again whenever the kernel restores MSACSR from a tasks saved context, leading to undesirable spurious exceptions. Clear the cause bits from the handle_msa_fpe function, mirroring the way handle_fpe clears the cause bits in FCSR.
Patchwork: https://patchwork.linux-mips.org/patch/9164/
--- arch/mips/kernel/genex.S | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
arch/mips/kernel/genex.S +10 -1
@@ -368,6 +368,15 @@ NESTED(nmi_handler, PT_SIZE, sp) STI .endm + .macro __build_clear_msa_fpe + _cfcmsa a1, MSA_CSR + li a2, ~(0x3f << 12) + and a1, a1, a2 + _ctcmsa MSA_CSR, a1 + TRACE_IRQS_ON + STI + .endm + .macro __build_clear_ade MFC0 t0, CP0_BADVADDR PTR_S t0, PT_BVADDR(sp)
@@ -426,7 +435,7 @@ NESTED(nmi_handler, PT_SIZE, sp) BUILD_HANDLER cpu cpu sti silent /* #11 */ BUILD_HANDLER ov ov sti silent /* #12 */ BUILD_HANDLER tr tr sti silent /* #13 */ - BUILD_HANDLER msa_fpe msa_fpe sti silent /* #14 */ + BUILD_HANDLER msa_fpe msa_fpe msa_fpe silent /* #14 */ BUILD_HANDLER fpe fpe fpe silent /* #15 */ BUILD_HANDLER ftlb ftlb none silent /* #16 */ BUILD_HANDLER msa msa sti silent /* #21 */
PATCH 93/254 MIPS: Clear [MSA]FPE CSR.Cause after notify_die()
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit 64bedffe496820dbb6b53302d80dd0f04db33d8e upstream.
When handling floating point exceptions (FPEs) and MSA FPEs the Cause bits of the appropriate control and status register (FCSR for FPEs and MSACSR for MSA FPEs) are read and cleared before enabling interrupts, presumably so that it doesn't have to go through the pain of restoring those bits if the process is pre-empted, since writing those bits would cause another immediate exception while still in the kernel.
The bits aren't normally ever restored again, since userland never expects to see them set.
However for virtualisation it is necessary for the kernel to be able to restore these Cause bits, as the guest may have been interrupted in an FP exception handler but before it could read the Cause bits. This can be done by registering a die notifier, to get notified of the exception when such a value is restored, and if the PC was at the instruction which is used to restore the guest state, the handler can step over it and continue execution. The Cause bits can then remain set without causing further exceptions.
For this to work safely a few changes are made:
- __build_clear_fpe and __build_clear_msa_fpe no longer clear the Cause bits, and now return from exception level with interrupts disabled instead of enabled.
- do_fpe() now clears the Cause bits and enables interrupts after notify_die() is called, so that the notifier can chose to return from exception without this happening.
- do_msa_fpe() acts similarly, but now actually makes use of the second argument (msacsr) and calls notify_die() with the new DIE_MSAFP, allowing die notifiers to be informed of MSA FPEs too.
--- arch/mips/include/asm/kdebug.h | 3 ++- arch/mips/kernel/genex.S | 14 ++++---------- arch/mips/kernel/traps.c | 16 +++++++++++++++- 3 files changed, 21 insertions(+), 12 deletions(-)
arch/mips/include/asm/kdebug.h +2 -1
@@ -10,7 +10,8 @@ enum die_val {DIE_RI ,DIE_PAGE_FAULT ,DIE_BREAK , -DIE_SSTEPBP +DIE_SSTEPBP , +DIE_MSAFP };#endif /* _ASM_MIPS_KDEBUG_H */
arch/mips/kernel/genex.S +4 -10
@@ -360,21 +360,15 @@ NESTED(nmi_handler, PT_SIZE, sp) .set mips1 SET_HARDFLOAT cfc1 a1, fcr31 - li a2, ~(0x3f << 12) - and a2, a1 - ctc1 a2, fcr31 .set pop - TRACE_IRQS_ON - STI + CLI + TRACE_IRQS_OFF .endm .macro __build_clear_msa_fpe _cfcmsa a1, MSA_CSR - li a2, ~(0x3f << 12) - and a1, a1, a2 - _ctcmsa MSA_CSR, a1 - TRACE_IRQS_ON - STI + CLI + TRACE_IRQS_OFF .endm .macro __build_clear_ade
arch/mips/kernel/traps.c +15 -1
@@ -744,6 +744,11 @@ asmlinkage void do_fpe(struct pt_regs *rif (notify_die (DIE_FP ,"FP exception" , regs,0 ,regs_to_trapnr (regs),SIGFPE ) ==NOTIFY_STOP ) goto out; + +/* Clear FCSR.Cause before enabling interrupts */ +write_32bit_cp1_register (CP1_STATUS , fcr31 & ~FPU_CSR_ALL_X ); +local_irq_enable (); +die_if_kernel ("FP exception in kernel code" , regs);if (fcr31 &FPU_CSR_UNI_X ) {
@@ -1295,13 +1300,22 @@ out:exception_exit (prev_state); } -asmlinkage void do_msa_fpe(struct pt_regs *regs) +asmlinkage void do_msa_fpe(struct pt_regs *regs, unsigned int msacsr) {enum ctx_state prev_state; prev_state =exception_enter (); +if (notify_die (DIE_MSAFP ,"MSA FP exception" , regs,0 , +regs_to_trapnr (regs),SIGFPE ) ==NOTIFY_STOP ) + goto out; + +/* Clear MSACSR.Cause before enabling interrupts */ +write_msa_csr (msacsr & ~MSA_CSR_CAUSEF ); +local_irq_enable (); +die_if_kernel ("do_msa_fpe invoked from kernel context!" , regs);force_sig (SIGFPE , current); +out:exception_exit (prev_state); }
PATCH 94/254 MIPS: prevent FP context set via ptrace being discarded
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paul Burton <[email protected]>
commit ac9ad83bc318635ed7496e9dff30beaa522eaec7 upstream.
If a ptracee has not used the FPU and the ptracer sets its FP context using PTRACE_POKEUSR, PTRACE_SETFPREGS or PTRACE_SETREGSET then that context will be discarded upon either the ptracee using the FPU or a further write to the context via ptrace. Prevent this loss by recording that the task has "used" math once its FP context has been written to. The context initialisation code that was present for the PTRACE_POKEUSR case is reused for the other 2 cases to provide consistent behaviour for the different ptrace requests.
Patchwork: https://patchwork.linux-mips.org/patch/9166/
--- arch/mips/kernel/ptrace.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-)
arch/mips/kernel/ptrace.c +24 -6
@@ -47,6 +47,26 @@#define CREATE_TRACE_POINTS #include <trace/events/syscalls.h> +static void init_fp_ctx (struct task_struct *target) +{ +/* If FP has been used then the target already has context */ +if (tsk_used_math (target)) +return ; + +/* Begin with data registers set to all 1s... */ +memset (&target->thread.fpu.fpr, ~0 ,sizeof (target->thread.fpu.fpr)); + +/* ...and FCSR zeroed */ + target->thread.fpu.fcr31 =0 ; + +/* +* Record that the target has "used" math, such that the context +* just initialised, and any modifications made by the caller, +* aren't discarded. +*/ +set_stopped_child_used_math (target); +} +/* * Called by kernel/ptrace.c when detaching.. *
@@ -143,6 +163,7 @@ int ptrace_setfpregs(struct task_structif (!access_ok (VERIFY_READ , data,33 *8 ))return -EIO ; +init_fp_ctx (child); fregs =get_fpu_regs (child);for (i =0 ; i <32 ; i++) {
@@ -440,6 +461,8 @@ static int fpr_set(struct task_struct *t/* XXX fcr31 */ +init_fp_ctx (target); +if (sizeof (target->thread.fpu.fpr[i]) ==sizeof (elf_fpreg_t)) return user_regset_copyin(&pos, &count, &kbuf, &ubuf, &target->thread.fpu,
@@ -678,12 +701,7 @@ long arch_ptrace(struct task_struct *chi case FPR_BASE ... FPR_BASE + 31: {union fpureg *fregs =get_fpu_regs (child); -if (!tsk_used_math (child)) { -/* FP not yet used */ -memset (&child->thread.fpu, ~0 , -sizeof (child->thread.fpu)); - child->thread.fpu.fcr31 =0 ; - } +init_fp_ctx (child);#ifdef CONFIG_32BIT if (test_thread_flag (TIF_32BIT_FPREGS )) {/*
PATCH 95/254 MIPS: lose_fpu(): Disable FPU when MSA enabled
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit acaf6a97d623af123314c2f8ce4cf7254f6b2fc1 upstream.
The lose_fpu() function only disables the FPU in CP0_Status.CU1 if the FPU is in use and MSA isn't enabled.
This isn't necessarily a problem because KSTK_STATUS(current), the version of CP0_Status stored on the kernel stack on entry from user mode, does always get updated and gets restored when returning to user mode, but I don't think it was intended, and it is inconsistent with the case of only the FPU being in use. Sometimes leaving the FPU enabled may also mask kernel bugs where FPU operations are executed when the FPU might not be enabled.
So lets disable the FPU in the MSA case too.
Patchwork: https://patchwork.linux-mips.org/patch/9323/
--- arch/mips/include/asm/fpu.h | 1 + 1 file changed, 1 insertion(+)
arch/mips/include/asm/fpu.h +1 -0
@@ -150,6 +150,7 @@ static inline void lose_fpu(int save) }disable_msa ();clear_thread_flag (TIF_USEDMSA ); +__disable_fpu (); }else if (is_fpu_owner ()) {if (save)_save_fp (current);
PATCH 96/254 MIPS: Respect the FCSR exception mask for `si_code'
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Maciej W. Rozycki" <[email protected]>
commit ed2d72c1eb3643b7c109bdf387563d9b9a30c279 upstream.
Respect the FCSR exception mask when interpreting the IEEE 754 exception condition to report with SIGFPE in `si_code', so as not to use one that has been masked where a different one set in parallel caused the FPE hardware exception to trigger. As per the IEEE Std 754 the Inexact exception can happen together with Overflow or Underflow.
Patchwork: https://patchwork.linux-mips.org/patch/9703/
--- arch/mips/kernel/traps.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
arch/mips/kernel/traps.c +10 -1
@@ -12,6 +12,7 @@* Copyright (C) 2000, 2001, 2012 MIPS Technologies, Inc. All rights reserved. * Copyright (C) 2014, Imagination Technologies Ltd. */ +#include <linux/bitops.h> #include <linux/bug.h> #include <linux/compiler.h> #include <linux/context_tracking.h>
@@ -785,7 +786,15 @@ asmlinkage void do_fpe(struct pt_regs *rprocess_fpemu_return (sig, fault_addr); goto out; - }else if (fcr31 &FPU_CSR_INV_X ) + } + +/* +* Inexact can happen together with Overflow or Underflow. +* Respect the mask to deliver the correct exception. +*/ + fcr31 &= (fcr31 &FPU_CSR_ALL_E ) << + (ffs (FPU_CSR_ALL_X ) -ffs (FPU_CSR_ALL_E )); +if (fcr31 &FPU_CSR_INV_X ) info.si_code =FPE_FLTINV ;else if (fcr31 &FPU_CSR_DIV_X ) info.si_code =FPE_FLTDIV ;
PATCH 97/254 MIPS: Always clear FCSR cause bits after emulation
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Maciej W. Rozycki" <[email protected]>
commit 443c44032a54f9acf027a8e688380fddc809bc19 upstream.
Clear any FCSR cause bits recorded in the saved FPU context after emulation in all cases rather than in `do_fpe' only, so that any unmasked IEEE 754 exception left from emulation does not cause a fatal kernel-mode FPE hardware exception with the CTC1 instruction used by the kernel to subsequently restore FCSR hardware from the saved FPU context.
Patchwork: https://patchwork.linux-mips.org/patch/9704/
---
arch/mips/kernel/traps.c +8 -1
@@ -775,7 +775,7 @@ asmlinkage void do_fpe(struct pt_regs *r/* * We can't allow the emulated instruction to leave any of -* the cause bit set in $fcr31. +* the cause bits set in $fcr31. */ current->thread.fpu.fcr31 &= ~FPU_CSR_ALL_X ;
@@ -1292,6 +1292,13 @@ asmlinkage void do_cpu(struct pt_regs *r sig =fpu_emulator_cop1Handler (regs, ¤t->thread.fpu,0 , &fault_addr); + +/* +* We can't allow the emulated instruction to leave +* any of the cause bits set in $fcr31. +*/ + current->thread.fpu.fcr31 &= ~FPU_CSR_ALL_X ; +if (!process_fpemu_return (sig, fault_addr) && !err)mt_ase_fp_affinity (); }
PATCH 98/254 MIPS: Set `si_code' for SIGFPE signals sent from emulation too
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Maciej W. Rozycki" <[email protected]>
commit 304acb717e5b67cf56f05bc5b21123758e1f7ea0 upstream.
Rework process_fpemu_return' and move IEEE 754 exception interpretation there, from do_fpe'. Record the cause bits set in FCSR before they are cleared and pass them through to process_fpemu_return' so as to set si_code' correctly too for SIGFPE signals sent from emulation rather than those issued by hardware with the FPE processor exception only.
For simplicity mipsr2_decoder' assumes *fcr31' has been preinitialised and only sets it to anything if an FPU instruction has been emulated, which in turn is the only case SIGFPE can be issued for here.
Patchwork: https://patchwork.linux-mips.org/patch/9705/
[bwh: Backported to 3.16:
- Drop changes in mips-r2-to-r6-emul and simulate_fp()
- Adjust context]
---
arch/mips/include/asm/fpu_emulator.h +2 -1
@@ -65,7 +65,8 @@ extern int do_dsemulret(struct pt_regs *extern int fpu_emulator_cop1Handler (struct pt_regs *xcp,struct mips_fpu_struct *ctx,int has_fpu,void *__user *fault_addr); -int process_fpemu_return (int sig,void __user *fault_addr); +int process_fpemu_return (int sig,void __user *fault_addr, +unsigned long fcr31);int mm_isBranchInstr (struct pt_regs *regs,struct mm_decoded_insn dec_insn,unsigned long *contpc);
arch/mips/kernel/traps.c +73 -62
191 lines not on this page · raw message
arch/mips/kernel/unaligned.c +2 -2
@@ -697,7 +697,7 @@ static void emulate_load_store_insn(struown_fpu (1 );/* Restore FPU state. */ /* Signal if something went wrong. */ -process_fpemu_return (res, fault_addr); +process_fpemu_return (res, fault_addr,0 );if (res ==0 )break ;
@@ -1129,7 +1129,7 @@ fpu_emul:own_fpu (1 );/* restore FPU state */ /* If something went wrong, signal */ -process_fpemu_return (res, fault_addr); +process_fpemu_return (res, fault_addr,0 );if (res ==0 ) goto success;
PATCH 99/254 MIPS: math-emu: Define IEEE 754-2008 feature control bits
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Maciej W. Rozycki" <[email protected]>
commit f1f3b7ebac08161761c352fd070cfa07b7b94c54 upstream.
Define IEEE 754-2008 feature control bits: FIR.HAS2008, FCSR.ABS2008 and FCSR.NAN2008, and update the `_ieee754_csr' structure accordingly.
For completeness define FIR.UFRP too.
Patchwork: https://patchwork.linux-mips.org/patch/9709/
---
arch/mips/include/asm/mipsregs.h +7 -2
@@ -136,10 +136,13 @@#define FPU_CSR_COND7 0x80000000/* $fcc7 */ /* -* Bits 18 - 20 of the FPU Status Register will be read as 0, +* Bits 22:20 of the FPU Status Register will be read as 0, * and should be written as zero. */ -#define FPU_CSR_RSVD 0x001c0000 +#define FPU_CSR_RSVD (_ULCAST_(7) << 20) + +#define FPU_CSR_ABS2008 (_ULCAST_(1) << 19) +#define FPU_CSR_NAN2008 (_ULCAST_(1) << 18)/* * X the exception cause indicator
@@ -687,6 +690,8 @@#define MIPS_FPIR_W (_ULCAST_(1) << 20)#define MIPS_FPIR_L (_ULCAST_(1) << 21)#define MIPS_FPIR_F64 (_ULCAST_(1) << 22) +#define MIPS_FPIR_HAS2008 (_ULCAST_(1) << 23) +#define MIPS_FPIR_UFRP (_ULCAST_(1) << 28)/* * Bits in the MIPS32 Memory Segmentation registers.
arch/mips/math-emu/cp1emu.c +4 -2
@@ -929,10 +929,12 @@ emul: MIPSInst_RT(ir), value);/* -* Don't write reserved bits, +* Don't write unsupported bits, * and convert to ieee library modes */ - ctx->fcr31 = (value & ~(FPU_CSR_RSVD |FPU_CSR_RM )) | + ctx->fcr31 = (value & + ~(FPU_CSR_RSVD |FPU_CSR_ABS2008 | +FPU_CSR_NAN2008 |FPU_CSR_RM )) |modeindex (value); }if ((ctx->fcr31 >>5 ) & ctx->fcr31 &FPU_CSR_ALL_E ) {
arch/mips/math-emu/ieee754.h +7 -5
@@ -195,15 +195,17 @@ static inline int ieee754dp_ge(union iee* The control status register */ struct _ieee754_csr { - __BITFIELD_FIELD(unsigned pad0:7, - __BITFIELD_FIELD(unsigned nod:1, /* set 1 for no denormalised numbers */ - __BITFIELD_FIELD(unsigned c:1, /* condition */ - __BITFIELD_FIELD(unsigned pad1:5, + __BITFIELD_FIELD(unsigned fcc:7, /* condition[7:1] */ + __BITFIELD_FIELD(unsigned nod:1, /* set 1 for no denormals */ + __BITFIELD_FIELD(unsigned c:1, /* condition[0] */ + __BITFIELD_FIELD(unsigned pad0:3, + __BITFIELD_FIELD(unsigned abs2008:1, /* IEEE 754-2008 ABS/NEG.fmt */ + __BITFIELD_FIELD(unsigned nan2008:1, /* IEEE 754-2008 NaN mode */ __BITFIELD_FIELD(unsigned cx:6, /* exceptions this operation */ __BITFIELD_FIELD(unsigned mx:5, /* exception enable mask */ __BITFIELD_FIELD(unsigned sx:5, /* exceptions total */ __BITFIELD_FIELD(unsigned rm:2, /* current rounding mode */ - ;)))))))) + ;)))))))))) };#define ieee754_csr (*(struct _ieee754_csr *)(¤t->thread.fpu.fcr31))
PATCH 100/254 MIPS: Respect the ISA level in FCSR handling
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Maciej W. Rozycki" <[email protected]>
commit 9b26616c8d9dae53fbac7f7cb2c6dd1308102976 upstream.
Define the central place the default FCSR value is set from, initialised in `cpu_probe'. Determine the FCSR mask applied to values written to the register with CTC1 in the full emulation mode and via ptrace(2), according to the ISA level of processor hardware or the writability of bits 31:18 if actual FPU hardware is used.
Software may rely on FCSR bits whose functions our emulator does not implement, so it should not allow them to be set or software may get confused. For ptrace(2) it's just sanity.
[[email protected]: Fixed double inclusion of <asm/current.h>.]
Patchwork: https://patchwork.linux-mips.org/patch/9711/
[bwh: Backported to 3.16:
- In cop1Emulate(), keep converting the rounding mode
- Drop change in loongson_cu2_call()
- Add definitions of FPU_CSR_{FS,CONDX} in <asm/mipsregs.h>
- Adjust context]
---
arch/mips/include/asm/cpu-info.h +2 -0
@@ -49,6 +49,8 @@ struct cpuinfo_mips {unsigned int udelay_val;unsigned int processor_id;unsigned int fpu_id; +unsigned int fpu_csr31; +unsigned int fpu_msk31;unsigned int msa_id;unsigned int cputype;int isa_level;
arch/mips/include/asm/elf.h +7 -0
@@ -9,6 +9,9 @@#define _ASM_ELF_H +#include <asm/cpu-info.h> +#include <asm/current.h> +/* ELF header e_flags defines. */ /* MIPS architecture level. */ #define EF_MIPS_ARCH_1 0x00000000/* -mips1 code. */
@@ -273,6 +276,8 @@ do { \set_personality (PER_LINUX ); \ \ current->thread.abi = &mips_abi; \ + \ + current->thread.fpu.fcr31 = current_cpu_data.fpu_csr31; \ } while (0)#endif /* CONFIG_32BIT */
@@ -332,6 +337,8 @@ do { \ else \ current->thread.abi = &mips_abi; \ \ + current->thread.fpu.fcr31 = current_cpu_data.fpu_csr31; \ + \ p =personality (current->personality); \if (p !=PER_LINUX32 && p !=PER_LINUX ) \set_personality (PER_LINUX ); \
arch/mips/include/asm/fpu.h +3 -2
@@ -30,7 +30,7 @@struct sigcontext ;struct sigcontext32 ; -extern void _init_fpu (void ); +extern void _init_fpu (unsigned int );extern void _save_fp (struct task_struct *);extern void _restore_fp (struct task_struct *);
@@ -163,6 +163,7 @@ static inline void lose_fpu(int save)static inline int init_fpu (void ) { +unsigned int fcr31 = current->thread.fpu.fcr31;int ret =0 ;preempt_disable ();
@@ -170,7 +171,7 @@ static inline int init_fpu(void)if (cpu_has_fpu) { ret =__own_fpu ();if (!ret) -_init_fpu (); +_init_fpu (fcr31); }else fpu_emulator_init_fpu ();
arch/mips/include/asm/fpu_emulator.h +0 -2
@@ -87,8 +87,6 @@ static inline void fpu_emulator_init_fpustruct task_struct *t = current;int i; - t->thread.fpu.fcr31 =0 ; -for (i =0 ; i <32 ; i++)set_fpr64 (&t->thread.fpu.fpr[i],0 ,SIGNALLING_NAN ); }
arch/mips/kernel/cpu-probe.c +54 -1
165 lines not on this page · raw message
arch/mips/kernel/ptrace.c +8 -2
@@ -33,6 +33,7 @@#include <asm/byteorder.h> #include <asm/cpu.h> +#include <asm/cpu-info.h> #include <asm/dsp.h> #include <asm/fpu.h> #include <asm/mipsregs.h>
@@ -158,6 +159,9 @@ int ptrace_setfpregs(struct task_struct {union fpureg *fregs;u64 fpr_val; +u32 fcr31; +u32 value; +u32 mask;int i;if (!access_ok (VERIFY_READ , data,33 *8 ))
@@ -171,8 +175,10 @@ int ptrace_setfpregs(struct task_structset_fpr64 (&fregs[i],0 , fpr_val); } -__get_user (child->thread.fpu.fcr31, data +64 ); - child->thread.fpu.fcr31 &= ~FPU_CSR_ALL_X ; +__get_user (value, data +64 ); + fcr31 = child->thread.fpu.fcr31; + mask = current_cpu_data.fpu_msk31; + child->thread.fpu.fcr31 = (value & ~mask) | (fcr31 & mask);/* FIR may not be written. */
arch/mips/kernel/r2300_switch.S +2 -5
@@ -115,11 +115,9 @@ LEAF(_restore_fp) * the property that no matter whether considered as single or as double * precision represents signaling NANS. * - * We initialize fcr31 to rounding to nearest, no exceptions. + * The value to initialize fcr31 to comes in $a0. */ -#define FPU_DEFAULT 0x00000000 - .set push SET_HARDFLOAT
@@ -129,8 +127,7 @@ LEAF(_init_fpu) or t0, t1 mtc0 t0, CP0_STATUS - li t1, FPU_DEFAULT - ctc1 t1, fcr31 + ctc1 a0, fcr31 li t0, -1
arch/mips/kernel/r4k_switch.S +2 -5
@@ -163,11 +163,9 @@ LEAF(_init_msa_upper) * the property that no matter whether considered as single or as double * precision represents signaling NANS. * - * We initialize fcr31 to rounding to nearest, no exceptions. + * The value to initialize fcr31 to comes in $a0. */ -#define FPU_DEFAULT 0x00000000 - .set push SET_HARDFLOAT
@@ -178,8 +176,7 @@ LEAF(_init_fpu) mtc0 t0, CP0_STATUS enable_fpu_hazard - li t1, FPU_DEFAULT - ctc1 t1, fcr31 + ctc1 a0, fcr31 li t1, -1 # SNaN
arch/mips/math-emu/cp1emu.c +6 -4
@@ -924,17 +924,19 @@ emul:/* we only have one writable control reg */ if (MIPSInst_RD (ir) ==FPCREG_CSR ) { +u32 mask; +pr_debug ("%p gpr[%d]->csr=%08x\n" , (void *) (xcp->cp0_epc),MIPSInst_RT (ir), value);/* -* Don't write unsupported bits, +* Preserve read-only bits, * and convert to ieee library modes */ - ctx->fcr31 = (value & - ~(FPU_CSR_RSVD |FPU_CSR_ABS2008 | -FPU_CSR_NAN2008 |FPU_CSR_RM )) | + mask = current_cpu_data.fpu_msk31; + ctx->fcr31 = (value & ~(mask |FPU_CSR_RM )) | + (ctx->fcr31 & mask) |modeindex (value); }if ((ctx->fcr31 >>5 ) & ctx->fcr31 &FPU_CSR_ALL_E ) {
arch/mips/include/asm/mipsregs.h +5 -0
@@ -123,6 +123,11 @@/* * Status Register Values */ +#define FPU_CSR_FS_S 24/* flush denormalised results to 0 */ +#define FPU_CSR_FS (_ULCAST_(1) << FPU_CSR_FS_S) + +#define FPU_CSR_CONDX_S 25/* $fcc[7:1] */ +#define FPU_CSR_CONDX (_ULCAST_(127) << FPU_CSR_CONDX_S)#define FPU_CSR_FLUSH 0x01000000/* flush denormalised results to 0 */ #define FPU_CSR_COND 0x00800000/* $fcc0 */
PATCH 101/254 MIPS: Fix a preemption issue with thread's FPU defaults
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Maciej W. Rozycki" <[email protected]>
commit 03dce595270f22d59a6f37e9170287c1afd94bc2 upstream.
Fix "BUG: using smp_processor_id() in preemptible" reported in accesses to thread's FPU defaults: the value to initialise FSCR to at program startup, the FCSR r/w mask and the contents of FIR in full FPU emulation, removing a regression introduced with 9b26616c [MIPS: Respect the ISA level in FCSR handling] and f6843626 [MIPS: math-emu: Set FIR feature flags for full emulation].
Use boot_cpu_data' to obtain the data from, following the approach that cpu_has_*' macros take and avoiding the call to smp_processor_id' made in the reference to current_cpu_data'. The contents of FSCR have to be consistent across processors in an SMP system, the settings there must not change as a thread is migrated across processors. And the contents of FIR are guaranteed to be consistent in FPU emulation, by definition.
Patchwork: https://patchwork.linux-mips.org/patch/10030/
[bwh: Backported to 3.16:
- Drop change in cop1_cfc()
- Adjust context]
---
arch/mips/include/asm/elf.h +2 -2
@@ -277,7 +277,7 @@ do { \ \ current->thread.abi = &mips_abi; \ \ - current->thread.fpu.fcr31 = current_cpu_data.fpu_csr31; \ + current->thread.fpu.fcr31 = boot_cpu_data.fpu_csr31; \ } while (0)#endif /* CONFIG_32BIT */
@@ -337,7 +337,7 @@ do { \ else \ current->thread.abi = &mips_abi; \ \ - current->thread.fpu.fcr31 = current_cpu_data.fpu_csr31; \ + current->thread.fpu.fcr31 = boot_cpu_data.fpu_csr31; \ \ p =personality (current->personality); \if (p !=PER_LINUX32 && p !=PER_LINUX ) \
arch/mips/kernel/ptrace.c +1 -1
@@ -177,7 +177,7 @@ int ptrace_setfpregs(struct task_struct__get_user (value, data +64 ); fcr31 = child->thread.fpu.fcr31; - mask = current_cpu_data.fpu_msk31; + mask = boot_cpu_data.fpu_msk31; child->thread.fpu.fcr31 = (value & ~mask) | (fcr31 & mask);/* FIR may not be written. */
arch/mips/math-emu/cp1emu.c +1 -1
@@ -934,7 +934,7 @@ emul:* Preserve read-only bits, * and convert to ieee library modes */ - mask = current_cpu_data.fpu_msk31; + mask = boot_cpu_data.fpu_msk31; ctx->fcr31 = (value & ~(mask |FPU_CSR_RM )) | (ctx->fcr31 & mask) |modeindex (value);
PATCH 102/254 MIPS: ptrace: Fix FP context restoration FCSR regression
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Maciej W. Rozycki" <[email protected]>
commit 4249548454f7ba4581aeee26bd83f42b48a14d15 upstream.
Fix a floating-point context restoration regression introduced with commit 9b26616c8d9d ("MIPS: Respect the ISA level in FCSR handling") that causes a Floating Point exception and consequently a kernel oops with hard float configurations when one or more FCSR Enable and their corresponding Cause bits are set both at a time via a ptrace(2) call.
To do so reinstate Cause bit masking originally introduced with commit b1442d39fac2 ("MIPS: Prevent user from setting FCSR cause bits") to address this exact problem and then inadvertently removed from the PTRACE_SETFPREGS request with the commit referred above.
Patchwork: https://patchwork.linux-mips.org/patch/13238/
--- arch/mips/kernel/ptrace.c | 1 + 1 file changed, 1 insertion(+)
arch/mips/kernel/ptrace.c +1 -0
@@ -176,6 +176,7 @@ int ptrace_setfpregs(struct task_struct }__get_user (value, data +64 ); + value &= ~FPU_CSR_ALL_X ; fcr31 = child->thread.fpu.fcr31; mask = boot_cpu_data.fpu_msk31; child->thread.fpu.fcr31 = (value & ~mask) | (fcr31 & mask);
PATCH 103/254 MIPS: ptrace: Prevent writes to read-only FCSR bits
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Maciej W. Rozycki" <[email protected]>
commit abf378be49f38c4d3e23581d3df3fa9f1b1b11d2 upstream.
Correct the cases missed with commit 9b26616c8d9d ("MIPS: Respect the ISA level in FCSR handling") and prevent writes to read-only FCSR bits there.
This in particular applies to FP context initialisation where any IEEE 754-2008 bits preset by `mips_set_personality_nan' are cleared before the relevant ptrace(2) call takes effect and the PTRACE_POKEUSR request addressing FPC_CSR where no masking of read-only FCSR bits is done.
Remove the FCSR clearing from FP context initialisation then and unify PTRACE_POKEUSR/FPC_CSR and PTRACE_SETFPREGS handling, by factoring out code from `ptrace_setfpregs' and calling it from both places.
This mostly matters to soft float configurations where the emulator can be switched this way to a mode which should not be accessible and cannot be set with the CTC1 instruction. With hard float configurations any effect is transient anyway as read-only bits will retain their values at the time the FP context is restored.
Patchwork: https://patchwork.linux-mips.org/patch/13239/
[bwh: Backported to 3.16: There is no mips_set_personality_nan(), so make
init_fp_ctx() copy the initial value of FCSR31]
---
arch/mips/kernel/ptrace.c +19 -9
@@ -57,8 +57,7 @@ static void init_fp_ctx(struct task_stru/* Begin with data registers set to all 1s... */ memset (&target->thread.fpu.fpr, ~0 ,sizeof (target->thread.fpu.fpr)); -/* ...and FCSR zeroed */ - target->thread.fpu.fcr31 =0 ; + target->thread.fpu.fcr31 = boot_cpu_data.fpu_csr31;/* * Record that the target has "used" math, such that the context
@@ -80,6 +79,22 @@ void ptrace_disable(struct task_struct * }/* +* Poke at FCSR according to its mask. Don't set the cause bits as +* this is currently not handled correctly in FP context restoration +* and will cause an oops if a corresponding enable bit is set. +*/ +static void ptrace_setfcr31 (struct task_struct *child,u32 value) +{ +u32 fcr31; +u32 mask; + + value &= ~FPU_CSR_ALL_X ; + fcr31 = child->thread.fpu.fcr31; + mask = boot_cpu_data.fpu_msk31; + child->thread.fpu.fcr31 = (value & ~mask) | (fcr31 & mask); +} + +/* * Read a general register set. We always use the 64-bit format, even * for 32-bit kernels and for 32-bit processes on a 64-bit kernel. * Registers are sign extended to fill the available space.
@@ -159,9 +174,7 @@ int ptrace_setfpregs(struct task_struct {union fpureg *fregs;u64 fpr_val; -u32 fcr31;u32 value; -u32 mask;int i;if (!access_ok (VERIFY_READ , data,33 *8 ))
@@ -176,10 +189,7 @@ int ptrace_setfpregs(struct task_struct }__get_user (value, data +64 ); - value &= ~FPU_CSR_ALL_X ; - fcr31 = child->thread.fpu.fcr31; - mask = boot_cpu_data.fpu_msk31; - child->thread.fpu.fcr31 = (value & ~mask) | (fcr31 & mask); +ptrace_setfcr31 (child, value);/* FIR may not be written. */
@@ -739,7 +749,7 @@ long arch_ptrace(struct task_struct *chibreak ;#endif case FPC_CSR : - child->thread.fpu.fcr31 = data & ~FPU_CSR_ALL_X ; +ptrace_setfcr31 (child, data);break ; case DSP_BASE ... DSP_BASE + 5: {dspreg_t *dregs;
PATCH 104/254 MIPS: MSA: bugfix - disable MSA correctly for new threads/processes.
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ralf Baechle <[email protected]>
commit 9cc719ab3f4f639d629ac8ff09e9b998bc006f68 upstream.
Due to the slightly odd way that new threads and processes start execution when scheduled for the very first time they were bypassing the required disable_msa call.
--- arch/mips/include/asm/switch_to.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/include/asm/switch_to.h +1 -1
@@ -101,7 +101,6 @@ do { \if (test_and_clear_tsk_thread_flag (prev,TIF_USEDMSA )) \ __fpsave =FP_SAVE_VECTOR ; \ (last) =resume (prev, next,task_thread_info (next), __fpsave); \ -disable_msa (); \ }while (0 ) #define finish_arch_switch(prev) \
@@ -119,6 +118,7 @@ do { \if (cpu_has_userlocal) \write_c0_userlocal (current_thread_info ()->tp_value); \__restore_watch (); \ +disable_msa (); \ } while (0)#endif /* _ASM_SWITCH_TO_H */
PATCH 105/254 MIPS: Fix FCSR Cause bit handling for correct SIGFPE issue
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Maciej W. Rozycki" <[email protected]>
commit 5a1aca4469fdccd5b74ba0b4e490173b2b447895 upstream.
Sanitize FCSR Cause bit handling, following a trail of past attempts:
* commit 4249548454f7 ("MIPS: ptrace: Fix FP context restoration FCSR regression"),
* commit 443c44032a54 ("MIPS: Always clear FCSR cause bits after emulation"),
* commit 64bedffe4968 ("MIPS: Clear [MSA]FPE CSR.Cause after notify_die()"),
* commit b1442d39fac2 ("MIPS: Prevent user from setting FCSR cause bits"),
* commit b54d2901517d ("Properly handle branch delay slots in connection with signals.").
Specifically do not mask these bits out in ptrace(2) processing and send a SIGFPE signal instead whenever a matching pair of an FCSR Cause and Enable bit is seen as execution of an affected context is about to resume. Only then clear Cause bits, and even then do not clear any bits that are set but masked with the respective Enable bits. Adjust Cause bit clearing throughout code likewise, except within the FPU emulator proper where they are set according to IEEE 754 exceptions raised as the operation emulated executed. Do so so that any IEEE 754 exceptions subject to their default handling are recorded like with operations executed by FPU hardware.
Patchwork: https://patchwork.linux-mips.org/patch/14460/
[bwh: Backported to 3.16:
- Drop changes in mips-r2-to-r6-emul and simulate_fp()
- Add #include <asm/fpu.h> in <asm/switch_to.h>
- Adjust context]
---
arch/mips/include/asm/fpu_emulator.h +13 -0
@@ -65,6 +65,8 @@ extern int do_dsemulret(struct pt_regs *extern int fpu_emulator_cop1Handler (struct pt_regs *xcp,struct mips_fpu_struct *ctx,int has_fpu,void *__user *fault_addr); +void force_fcr31_sig (unsigned long fcr31,void __user *fault_addr, +struct task_struct *tsk);int process_fpemu_return (int sig,void __user *fault_addr,unsigned long fcr31); int mm_isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
@@ -91,4 +93,15 @@ static inline void fpu_emulator_init_fpu set_fpr64(&t->thread.fpu.fpr[i], 0, SIGNALLING_NAN); } +/* +* Mask the FCSR Cause bits according to the Enable bits, observing +* that Unimplemented is always enabled. +*/ +static inline unsigned long mask_fcr31_x (unsigned long fcr31) +{ +return fcr31 & (FPU_CSR_UNI_X | + ((fcr31 &FPU_CSR_ALL_E ) << + (ffs (FPU_CSR_ALL_X ) -ffs (FPU_CSR_ALL_E )))); +} +#endif /* _ASM_FPU_EMULATOR_H */
arch/mips/include/asm/switch_to.h +19 -0
@@ -17,6 +17,7 @@#include <asm/dsp.h> #include <asm/cop2.h> #include <asm/msa.h> +#include <asm/fpu.h> struct task_struct ;
@@ -80,11 +81,29 @@ do { \ ll_bit =0 ; \ }while (0 ) +/* +* Check FCSR for any unmasked exceptions pending set with `ptrace', +* clear them and send a signal. + */ +#define __sanitize_fcr31 (next) \ +do { \ + unsigned long fcr31 = mask_fcr31_x(next->thread.fpu.fcr31); \ + void __user *pc; \ + \ + if (unlikely(fcr31)) { \ + pc = (void __user *)task_pt_regs(next)->cp0_epc; \ + next->thread.fpu.fcr31 &= ~fcr31; \ + force_fcr31_sig(fcr31, pc, next); \ + } \ +} while (0) +#define switch_to (prev, next, last) \ do { \ u32 __c0_stat; \ s32 __fpsave = FP_SAVE_NONE; \ __mips_mt_fpaff_switch_to(prev); \ + if (tsk_used_math(next)) \ + __sanitize_fcr31(next); \ if (cpu_has_dsp) \ __save_dsp(prev); \ if (cop2_present && (KSTK_STATUS(prev) & ST0_CU2)) { \
arch/mips/kernel/ptrace.c +3 -4
@@ -79,16 +79,15 @@ void ptrace_disable(struct task_struct * }/* -* Poke at FCSR according to its mask. Don't set the cause bits as -* this is currently not handled correctly in FP context restoration -* and will cause an oops if a corresponding enable bit is set. +* Poke at FCSR according to its mask. Set the Cause bits even +* if a corresponding Enable bit is set. This will be noticed at +* the time the thread is switched to and SIGFPE thrown accordingly. */ static void ptrace_setfcr31 (struct task_struct *child,u32 value) {u32 fcr31;u32 mask; - value &= ~FPU_CSR_ALL_X ; fcr31 = child->thread.fpu.fcr31; mask = boot_cpu_data.fpu_msk31; child->thread.fpu.fcr31 = (value & ~mask) | (fcr31 & mask);
arch/mips/kernel/traps.c +35 -29
101 lines not on this page · raw message
PATCH 106/254 mips/ptrace: Preserve previous registers for short regset write
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dave Martin <[email protected]>
commit d614fd58a2834cfe4efa472c33c8f3ce2338b09b upstream.
Ensure that if userspace supplies insufficient data to PTRACE_SETREGSET to fill all the registers, the thread's old registers are preserved.
--- arch/mips/kernel/ptrace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/kernel/ptrace.c +2 -1
@@ -484,7 +484,8 @@ static int fpr_set(struct task_struct *t &target->thread.fpu, 0, sizeof(elf_fpregset_t)); -for (i =0 ; i <NUM_FPU_REGS ; i++) { +BUILD_BUG_ON (sizeof (fpr_val) !=sizeof (elf_fpreg_t)); +for (i =0 ; i <NUM_FPU_REGS && count >=sizeof (elf_fpreg_t); i++) { err =user_regset_copyin (&pos, &count, &kbuf, &ubuf, &fpr_val, i *sizeof (elf_fpreg_t), (i +1 ) *sizeof (elf_fpreg_t));
PATCH 107/254 MIPS: Factor out NT_PRFPREG regset access helpers
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Maciej W. Rozycki" <[email protected]>
commit a03fe72572c12e98f4173f8a535f32468e48b6ec upstream.
In preparation to fix a commit 72b22bbad1e7 ("MIPS: Don't assume 64-bit FP registers for FP regset") FCSR access regression factor out NT_PRFPREG regset access helpers for the non-MSA and the MSA variants respectively, to avoid having to deal with excessive indentation in the actual fix.
No functional change, however use target->thread.fpu.fpr[0]' rather than target->thread.fpu.fpr[i]' for FGR holding type size determination as there's no i' variable to refer to anymore, and for the factored out i' variable declaration use unsigned int' rather than unsigned' as its type, following the common style.
Patchwork: https://patchwork.linux-mips.org/patch/17925/
--- arch/mips/kernel/ptrace.c | 108 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 83 insertions(+), 25 deletions(-)
arch/mips/kernel/ptrace.c +83 -25
@@ -438,25 +438,36 @@ static int gpr64_set(struct task_struct#endif /* CONFIG_64BIT */ -static int fpr_get (struct task_struct *target, -const struct user_regset *regset, -unsigned int pos,unsigned int count, -void *kbuf,void __user *ubuf) +/* +* Copy the floating-point context to the supplied NT_PRFPREG buffer, +* !CONFIG_CPU_HAS_MSA variant. FP context's general register slots +* correspond 1:1 to buffer slots. +*/ +static int fpr_get_fpa (struct task_struct *target, +unsigned int *pos,unsigned int *count, +void **kbuf,void __user **ubuf) { -unsigned i; -int err; -u64 fpr_val; - -/* XXX fcr31 */ +return user_regset_copyout (pos, count, kbuf, ubuf, + &target->thread.fpu, +0 ,sizeof (elf_fpregset_t)); +} -if (sizeof (target->thread.fpu.fpr[i]) ==sizeof (elf_fpreg_t)) -return user_regset_copyout (&pos, &count, &kbuf, &ubuf, - &target->thread.fpu, -0 ,sizeof (elf_fpregset_t)); +/* +* Copy the floating-point context to the supplied NT_PRFPREG buffer, +* CONFIG_CPU_HAS_MSA variant. Only lower 64 bits of FP context's +* general register slots are copied to buffer slots. +*/ +static int fpr_get_msa (struct task_struct *target, +unsigned int *pos,unsigned int *count, +void **kbuf,void __user **ubuf) +{ +unsigned int i; +u64 fpr_val; +int err;for (i =0 ; i <NUM_FPU_REGS ; i++) { fpr_val =get_fpr64 (&target->thread.fpu.fpr[i],0 ); - err =user_regset_copyout (&pos, &count, &kbuf, &ubuf, + err =user_regset_copyout (pos, count, kbuf, ubuf, &fpr_val, i *sizeof (elf_fpreg_t), (i +1 ) *sizeof (elf_fpreg_t));if (err)
@@ -466,27 +477,54 @@ static int fpr_get(struct task_struct *treturn 0 ; } -static int fpr_set (struct task_struct *target, +/* Copy the floating-point context to the supplied NT_PRFPREG buffer. */ +static int fpr_get (struct task_struct *target,const struct user_regset *regset,unsigned int pos,unsigned int count, -const void *kbuf,const void __user *ubuf) +void *kbuf,void __user *ubuf) { -unsigned i;int err; -u64 fpr_val;/* XXX fcr31 */ -init_fp_ctx (target); +if (sizeof (target->thread.fpu.fpr[0 ]) ==sizeof (elf_fpreg_t)) + err =fpr_get_fpa (target, &pos, &count, &kbuf, &ubuf); +else + err =fpr_get_msa (target, &pos, &count, &kbuf, &ubuf); + +return err; +} -if (sizeof (target->thread.fpu.fpr[i]) ==sizeof (elf_fpreg_t)) -return user_regset_copyin (&pos, &count, &kbuf, &ubuf, - &target->thread.fpu, -0 ,sizeof (elf_fpregset_t)); +/* +* Copy the supplied NT_PRFPREG buffer to the floating-point context, +* !CONFIG_CPU_HAS_MSA variant. Buffer slots correspond 1:1 to FP +* context's general register slots. +*/ +static int fpr_set_fpa (struct task_struct *target, +unsigned int *pos,unsigned int *count, +const void **kbuf,const void __user **ubuf) +{ +return user_regset_copyin (pos, count, kbuf, ubuf, + &target->thread.fpu, +0 ,sizeof (elf_fpregset_t)); +} + +/* +* Copy the supplied NT_PRFPREG buffer to the floating-point context, +* CONFIG_CPU_HAS_MSA variant. Buffer slots are copied to lower 64 +* bits only of FP context's general register slots. +*/ +static int fpr_set_msa (struct task_struct *target, +unsigned int *pos,unsigned int *count, +const void **kbuf,const void __user **ubuf) +{ +unsigned int i; +u64 fpr_val; +int err;BUILD_BUG_ON (sizeof (fpr_val) !=sizeof (elf_fpreg_t)); -for (i =0 ; i <NUM_FPU_REGS && count >=sizeof (elf_fpreg_t); i++) { - err =user_regset_copyin (&pos, &count, &kbuf, &ubuf, +for (i =0 ; i <NUM_FPU_REGS && *count >=sizeof (elf_fpreg_t); i++) { + err =user_regset_copyin (pos, count, kbuf, ubuf, &fpr_val, i *sizeof (elf_fpreg_t), (i +1 ) *sizeof (elf_fpreg_t));if (err)
@@ -497,6 +535,26 @@ static int fpr_set(struct task_struct *treturn 0 ; } +/* Copy the supplied NT_PRFPREG buffer to the floating-point context. */ +static int fpr_set (struct task_struct *target, +const struct user_regset *regset, +unsigned int pos,unsigned int count, +const void *kbuf,const void __user *ubuf) +{ +int err; + +/* XXX fcr31 */ + +init_fp_ctx (target); + +if (sizeof (target->thread.fpu.fpr[0 ]) ==sizeof (elf_fpreg_t)) + err =fpr_set_fpa (target, &pos, &count, &kbuf, &ubuf); +else + err =fpr_set_msa (target, &pos, &count, &kbuf, &ubuf); + +return err; +} +enum mips_regset {REGSET_GPR ,REGSET_FPR ,
PATCH 108/254 MIPS: Guard against any partial write attempt with PTRACE_SETREGSET
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Maciej W. Rozycki" <[email protected]>
commit dc24d0edf33c3e15099688b6bbdf7bdc24bf6e91 upstream.
Complement commit d614fd58a283 ("mips/ptrace: Preserve previous registers for short regset write") and ensure that no partial register write attempt is made with PTRACE_SETREGSET, as we do not preinitialize any temporaries used to hold incoming register data and consequently random data could be written.
It is the responsibility of the caller, such as `ptrace_regset', to arrange for writes to span whole registers only, so here we only assert that it has indeed happened.
Patchwork: https://patchwork.linux-mips.org/patch/17926/
--- arch/mips/kernel/ptrace.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
arch/mips/kernel/ptrace.c +11 -1
@@ -535,7 +535,15 @@ static int fpr_set_msa(struct task_strucreturn 0 ; } -/* Copy the supplied NT_PRFPREG buffer to the floating-point context. */ +/* +* Copy the supplied NT_PRFPREG buffer to the floating-point context. +* +* We optimize for the case where `count % sizeof(elf_fpreg_t) == 0', +* which is supposed to have been guaranteed by the kernel before +* calling us, e.g. in `ptrace_regset'. We enforce that requirement, +* so that we can safely avoid preinitializing temporaries for +* partial register writes. +*/ static int fpr_set(struct task_struct *target, const struct user_regset *regset, unsigned int pos, unsigned int count,
@@ -543,6 +551,8 @@ static int fpr_set(struct task_struct *t {int err; +BUG_ON (count %sizeof (elf_fpreg_t)); +/* XXX fcr31 */ init_fp_ctx (target);
PATCH 109/254 MIPS: Fix an FCSR access API regression with NT_PRFPREG and MSA
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Maciej W. Rozycki" <[email protected]>
commit be07a6a1188372b6d19a3307ec33211fc9c9439d upstream.
Fix a commit 72b22bbad1e7 ("MIPS: Don't assume 64-bit FP registers for FP regset") public API regression, then activated by commit 1db1af84d6df ("MIPS: Basic MSA context switching support"), that caused the FCSR register not to be read or written for CONFIG_CPU_HAS_MSA kernel configurations (regardless of actual presence or absence of the MSA feature in a given processor) with ptrace(2) PTRACE_GETREGSET and PTRACE_SETREGSET requests nor recorded in core dumps.
This is because with !CONFIG_CPU_HAS_MSA configurations the whole of `elf_fpregset_t' array is bulk-copied as it is, which includes the FCSR in one half of the last, 33rd slot, whereas with CONFIG_CPU_HAS_MSA configurations array elements are copied individually, and then only the leading 32 FGR slots while the remaining slot is ignored.
Correct the code then such that only FGR slots are copied in the respective !MSA and MSA helpers an then the FCSR slot is handled separately in common code. Use `ptrace_setfcr31' to update the FCSR too, so that the read-only mask is respected.
Retrieving a correct value of FCSR is important in debugging not only for the human to be able to get the right interpretation of the situation, but for correct operation of GDB as well. This is because the condition code bits in FSCR are used by GDB to determine the location to place a breakpoint at when single-stepping through an FPU branch instruction. If such a breakpoint is placed incorrectly (i.e. with the condition reversed), then it will be missed, likely causing the debuggee to run away from the control of GDB and consequently breaking the process of investigation.
Fortunately GDB continues using the older PTRACE_GETFPREGS ptrace(2) request which is unaffected, so the regression only really hits with post-mortem debug sessions using a core dump file, in which case execution, and consequently single-stepping through branches is not possible. Of course core files created by buggy kernels out there will have the value of FCSR recorded clobbered, but such core files cannot be corrected and the person using them simply will have to be aware that the value of FCSR retrieved is not reliable.
Which also means we can likely get away without defining a replacement API which would ensure a correct value of FSCR to be retrieved, or none at all.
This is based on previous work by Alex Smith, extensively rewritten.
Patchwork: https://patchwork.linux-mips.org/patch/17928/
--- arch/mips/kernel/ptrace.c | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-)
arch/mips/kernel/ptrace.c +36 -11
@@ -441,7 +441,7 @@ static int gpr64_set(struct task_struct/* * Copy the floating-point context to the supplied NT_PRFPREG buffer, * !CONFIG_CPU_HAS_MSA variant. FP context's general register slots -* correspond 1:1 to buffer slots. +* correspond 1:1 to buffer slots. Only general registers are copied. */ static int fpr_get_fpa(struct task_struct *target, unsigned int *pos, unsigned int *count,
@@ -449,13 +449,14 @@ static int fpr_get_fpa(struct task_struc {return user_regset_copyout (pos, count, kbuf, ubuf, &target->thread.fpu, -0 ,sizeof (elf_fpregset_t)); +0 ,NUM_FPU_REGS *sizeof (elf_fpreg_t)); }/* * Copy the floating-point context to the supplied NT_PRFPREG buffer, * CONFIG_CPU_HAS_MSA variant. Only lower 64 bits of FP context's -* general register slots are copied to buffer slots. +* general register slots are copied to buffer slots. Only general +* registers are copied. */ static int fpr_get_msa(struct task_struct *target, unsigned int *pos, unsigned int *count,
@@ -477,20 +478,29 @@ static int fpr_get_msa(struct task_strucreturn 0 ; } -/* Copy the floating-point context to the supplied NT_PRFPREG buffer. */ +/* +* Copy the floating-point context to the supplied NT_PRFPREG buffer. +* Choose the appropriate helper for general registers, and then copy +* the FCSR register separately. +*/ static int fpr_get (struct task_struct *target,const struct user_regset *regset,unsigned int pos,unsigned int count,void *kbuf,void __user *ubuf) { +const int fcr31_pos =NUM_FPU_REGS *sizeof (elf_fpreg_t);int err; -/* XXX fcr31 */ -if (sizeof (target->thread.fpu.fpr[0 ]) ==sizeof (elf_fpreg_t)) err =fpr_get_fpa (target, &pos, &count, &kbuf, &ubuf);else err =fpr_get_msa (target, &pos, &count, &kbuf, &ubuf); +if (err) +return err; + + err =user_regset_copyout (&pos, &count, &kbuf, &ubuf, + &target->thread.fpu.fcr31, + fcr31_pos, fcr31_pos +sizeof (u32));return err; }
@@ -498,7 +508,7 @@ static int fpr_get(struct task_struct *t/* * Copy the supplied NT_PRFPREG buffer to the floating-point context, * !CONFIG_CPU_HAS_MSA variant. Buffer slots correspond 1:1 to FP -* context's general register slots. +* context's general register slots. Only general registers are copied. */ static int fpr_set_fpa(struct task_struct *target, unsigned int *pos, unsigned int *count,
@@ -506,13 +516,14 @@ static int fpr_set_fpa(struct task_struc {return user_regset_copyin (pos, count, kbuf, ubuf, &target->thread.fpu, -0 ,sizeof (elf_fpregset_t)); +0 ,NUM_FPU_REGS *sizeof (elf_fpreg_t)); }/* * Copy the supplied NT_PRFPREG buffer to the floating-point context, * CONFIG_CPU_HAS_MSA variant. Buffer slots are copied to lower 64 -* bits only of FP context's general register slots. +* bits only of FP context's general register slots. Only general +* registers are copied. */ static int fpr_set_msa(struct task_struct *target, unsigned int *pos, unsigned int *count,
@@ -537,6 +548,8 @@ static int fpr_set_msa(struct task_struc/* * Copy the supplied NT_PRFPREG buffer to the floating-point context. +* Choose the appropriate helper for general registers, and then copy +* the FCSR register separately. * * We optimize for the case where `count % sizeof(elf_fpreg_t) == 0', * which is supposed to have been guaranteed by the kernel before
@@ -549,18 +562,30 @@ static int fpr_set(struct task_struct *t unsigned int pos, unsigned int count, const void *kbuf, const void __user *ubuf) { + const int fcr31_pos = NUM_FPU_REGS * sizeof(elf_fpreg_t); +u32 fcr31;int err;BUG_ON (count %sizeof (elf_fpreg_t)); -/* XXX fcr31 */ -init_fp_ctx (target);if (sizeof (target->thread.fpu.fpr[0 ]) ==sizeof (elf_fpreg_t)) err =fpr_set_fpa (target, &pos, &count, &kbuf, &ubuf);else err =fpr_set_msa (target, &pos, &count, &kbuf, &ubuf); +if (err) +return err; + +if (count >0 ) { + err =user_regset_copyin (&pos, &count, &kbuf, &ubuf, + &fcr31, + fcr31_pos, fcr31_pos +sizeof (u32)); +if (err) +return err; + +ptrace_setfcr31 (target, fcr31); + }return err; }
PATCH 110/254 MIPS: Disallow outsized PTRACE_SETREGSET NT_PRFPREG regset accesses
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Maciej W. Rozycki" <[email protected]>
commit c8c5a3a24d395b14447a9a89d61586a913840a3b upstream.
Complement commit c23b3d1a5311 ("MIPS: ptrace: Change GP regset to use correct core dump register layout") and also reject outsized PTRACE_SETREGSET requests to the NT_PRFPREG regset, like with the NT_PRSTATUS regset.
Patchwork: https://patchwork.linux-mips.org/patch/17930/
--- arch/mips/kernel/ptrace.c | 3 +++ 1 file changed, 3 insertions(+)
arch/mips/kernel/ptrace.c +3 -0
@@ -568,6 +568,9 @@ static int fpr_set(struct task_struct *tBUG_ON (count %sizeof (elf_fpreg_t)); +if (pos + count >sizeof (elf_fpregset_t)) +return -EIO ; +init_fp_ctx (target);if (sizeof (target->thread.fpu.fpr[0 ]) ==sizeof (elf_fpreg_t))
PATCH 111/254 powerpc/perf: Dereference BHRB entries safely
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ravi Bangoria <[email protected]>
commit f41d84dddc66b164ac16acf3f584c276146f1c48 upstream.
It's theoretically possible that branch instructions recorded in BHRB (Branch History Rolling Buffer) entries have already been unmapped before they are processed by the kernel. Hence, trying to dereference such memory location will result in a crash. eg:
Unable to handle kernel paging request for data at address 0xd000000019c41764
Faulting instruction address: 0xc000000000084a14
NIP [c000000000084a14] branch_target+0x4/0x70
LR [c0000000000eb828] record_and_restart+0x568/0x5c0
Call Trace:
[c0000000000eb3b4] record_and_restart+0xf4/0x5c0 (unreliable)
[c0000000000ec378] perf_event_interrupt+0x298/0x460
[c000000000027964] performance_monitor_exception+0x54/0x70
[c000000000009ba4] performance_monitor_common+0x114/0x120Fix it by deferefencing the addresses safely.
--- arch/powerpc/perf/core-book3s.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/powerpc/perf/core-book3s.c +6 -2
@@ -391,8 +391,12 @@ static __u64 power_pmu_bhrb_to(u64 addr)int ret;__u64 target; -if (is_kernel_addr (addr)) -return branch_target ((unsigned int *)addr); +if (is_kernel_addr (addr)) { +if (probe_kernel_read (&instr, (void *)addr,sizeof (instr))) +return 0 ; + +return branch_target (&instr); + }/* Userspace: need copy instruction here then translate it */ pagefault_disable ();
PATCH 112/254 KVM: X86: Fix load RFLAGS w/o the fixed bit
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Wanpeng Li <[email protected]>
commit d73235d17ba63b53dc0e1051dbc10a1f1be91b71 upstream.
*** Guest State ***
CR0: actual=0x0000000000000030, shadow=0x0000000060000010, gh_mask=fffffffffffffff7
CR4: actual=0x0000000000002050, shadow=0x0000000000000000, gh_mask=ffffffffffffe871 CR3 = 0x00000000fffbc000
RSP = 0x0000000000000000 RIP = 0x0000000000000000
RFLAGS=0x00000000 DR7 = 0x0000000000000400
^^^^^^^^^^
The failed vmentry is triggered by the following testcase when ept=Y:
#include <unistd.h>
#include <sys/syscall.h>
#include <string.h>
#include <stdint.h>
#include <linux/kvm.h>
#include <fcntl.h>
#include <sys/ioctl.h>
long r[5];
int main()
{
r[2] = open("/dev/kvm", O_RDONLY);
r[3] = ioctl(r[2], KVM_CREATE_VM, 0);
r[4] = ioctl(r[3], KVM_CREATE_VCPU, 7);
struct kvm_regs regs = {
.rflags = 0,
};
ioctl(r[4], KVM_SET_REGS, ®s);
ioctl(r[4], KVM_RUN, 0);
}X86 RFLAGS bit 1 is fixed set, userspace can simply clearing bit 1 of RFLAGS with KVM_SET_REGS ioctl which results in vmentry fails. This patch fixes it by oring X86_EFLAGS_FIXED during ioctl.
--- arch/x86/kvm/x86.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/x86.c +1 -1
@@ -6471,7 +6471,7 @@ int kvm_arch_vcpu_ioctl_set_regs(struct#endif kvm_rip_write (vcpu, regs->rip); -kvm_set_rflags (vcpu, regs->rflags); +kvm_set_rflags (vcpu, regs->rflags |X86_EFLAGS_FIXED ); vcpu->arch.exception.pending = false;
PATCH 113/254 ALSA: rawmidi: Avoid racy info ioctl via ctl device
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit c1cfd9025cc394fd137a01159d74335c5ac978ce upstream.
The rawmidi also allows to obtaining the information via ioctl of ctl API. It means that user can issue an ioctl to the rawmidi device even when it's being removed as long as the control device is present. Although the code has some protection via the global register_mutex, its range is limited to the search of the corresponding rawmidi object, and the mutex is already unlocked at accessing the rawmidi object. This may lead to a use-after-free.
For avoiding it, this patch widens the application of register_mutex to the whole snd_rawmidi_info_select() function. We have another mutex per rawmidi object, but this operation isn't very hot path, so it shouldn't matter from the performance POV.
--- sound/core/rawmidi.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
sound/core/rawmidi.c +12 -3
@@ -589,15 +589,14 @@ static int snd_rawmidi_info_user(structreturn 0 ; } -int snd_rawmidi_info_select (struct snd_card *card,struct snd_rawmidi_info *info) +static int __snd_rawmidi_info_select (struct snd_card *card, +struct snd_rawmidi_info *info) {struct snd_rawmidi *rmidi;struct snd_rawmidi_str *pstr;struct snd_rawmidi_substream *substream; -mutex_lock (®ister_mutex); rmidi =snd_rawmidi_search (card, info->device); -mutex_unlock (®ister_mutex);if (!rmidi)return -ENXIO ;if (info->stream <0 || info->stream >1 )
@@ -613,6 +612,16 @@ int snd_rawmidi_info_select(struct snd_c }return -ENXIO ; } + +int snd_rawmidi_info_select (struct snd_card *card,struct snd_rawmidi_info *info) +{ +int ret; + +mutex_lock (®ister_mutex); + ret =__snd_rawmidi_info_select (card, info); +mutex_unlock (®ister_mutex); +return ret; +}EXPORT_SYMBOL (snd_rawmidi_info_select); static int snd_rawmidi_info_select_user(struct snd_card *card,
PATCH 114/254 kernel: make groups_sort calling a responsibility group_info allocators
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thiago Rafael Becker <[email protected]>
commit bdcf0a423ea1c40bbb40e7ee483b50fc8aa3d758 upstream.
In testing, we found that nfsd threads may call set_groups in parallel for the same entry cached in auth.unix.gid, racing in the call of groups_sort, corrupting the groups for that entry and leading to permission denials for the client.
This patch:
- Make groups_sort globally visible.
- Move the call to groups_sort to the modifiers of group_info
- Remove the call to groups_sort from set_groups
--- arch/s390/kernel/compat_linux.c | 1 + fs/nfsd/auth.c | 3 +++ include/linux/cred.h | 1 + kernel/groups.c | 5 +++-- kernel/uid16.c | 1 + net/sunrpc/auth_gss/gss_rpc_xdr.c | 1 + net/sunrpc/auth_gss/svcauth_gss.c | 1 + net/sunrpc/svcauth_unix.c | 2 ++ 8 files changed, 13 insertions(+), 2 deletions(-)
arch/s390/kernel/compat_linux.c +1 -0
@@ -263,6 +263,7 @@ COMPAT_SYSCALL_DEFINE2(s390_setgroups16,return retval; } +groups_sort (group_info); retval =set_current_groups (group_info);put_group_info (group_info);
fs/nfsd/auth.c +3 -0
@@ -59,6 +59,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,GROUP_AT (gi, i) = exp->ex_anon_gid; elseGROUP_AT (gi ,i ) =GROUP_AT (rqgi, i); + +/* Each thread allocates its own gi, no race */ +groups_sort (gi); } }else { gi =get_group_info (rqgi);
include/linux/cred.h +1 -0
@@ -69,6 +69,7 @@ extern int set_current_groups(struct groextern void set_groups (struct cred *,struct group_info *);extern int groups_search (const struct group_info *,kgid_t );extern bool may_setgroups (void ); +extern void groups_sort (struct group_info *);/* access the groups "array" with this macro */ #define GROUP_AT (gi, i) \
kernel/groups.c +3 -2
@@ -104,7 +104,7 @@ static int groups_from_user(struct group }/* a simple Shell sort */ -static void groups_sort (struct group_info *group_info) +void groups_sort (struct group_info *group_info) {int base, max, stride;int gidsetsize = group_info->ngroups;
@@ -131,6 +131,7 @@ static void groups_sort(struct group_inf stride /=3 ; } } +EXPORT_SYMBOL (groups_sort);/* a simple bsearch */ int groups_search (const struct group_info *group_info,kgid_t grp)
@@ -162,7 +163,6 @@ int groups_search(const struct group_infvoid set_groups (struct cred *new,struct group_info *group_info) {put_group_info (new->group_info); -groups_sort (group_info);get_group_info (group_info); new->group_info = group_info; }
@@ -246,6 +246,7 @@ SYSCALL_DEFINE2(setgroups, int, gidsetsireturn retval; } +groups_sort (group_info); retval =set_current_groups (group_info);put_group_info (group_info);
kernel/uid16.c +1 -0
@@ -190,6 +190,7 @@ SYSCALL_DEFINE2(setgroups16, int, gidsetreturn retval; } +groups_sort (group_info); retval =set_current_groups (group_info);put_group_info (group_info);
net/sunrpc/auth_gss/gss_rpc_xdr.c +1 -0
@@ -231,6 +231,7 @@ static int gssx_dec_linux_creds(struct x goto out_free_groups;GROUP_AT (creds->cr_group_info, i) = kgid; } +groups_sort (creds->cr_group_info);return 0 ; out_free_groups:
net/sunrpc/auth_gss/svcauth_gss.c +1 -0
@@ -479,6 +479,7 @@ static int rsc_parse(struct cache_detail goto out;GROUP_AT (rsci.cred.cr_group_info, i) = kgid; } +groups_sort (rsci.cred.cr_group_info);/* mech name */ len =qword_get (&mesg, buf, mlen);
net/sunrpc/svcauth_unix.c +2 -0
@@ -520,6 +520,7 @@ static int unix_gid_parse(struct cache_dGROUP_AT (ug.gi, i) = kgid; } +groups_sort (ug.gi); ugp =unix_gid_lookup (cd, uid);if (ugp) {struct cache_head *ch;
@@ -827,6 +828,7 @@ svcauth_unix_accept(struct svc_rqst *rqskgid_t kgid =make_kgid (&init_user_ns,svc_getnl (argv));GROUP_AT (cred->cr_group_info, i) = kgid; } +groups_sort (cred->cr_group_info);if (svc_getu32 (argv) !=htonl (RPC_AUTH_NULL ) ||svc_getu32 (argv) !=0 ) { *authp = rpc_autherr_badverf;return SVC_DENIED ;
PATCH 115/254 nfsd: auth: Fix gid sorting when rootsquash enabled
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ben Hutchings <[email protected]>
commit 1995266727fa8143897e89b55f5d3c79aa828420 upstream.
Commit bdcf0a423ea1 ("kernel: make groups_sort calling a responsibility group_info allocators") appears to break nfsd rootsquash in a pretty major way.
It adds a call to groups_sort() inside the loop that copies/squashes gids, which means the valid gids are sorted along with the following garbage. The net result is that the highest numbered valid gids are replaced with any lower-valued garbage gids, possibly including 0.
We should sort only once, after filling in all the gids.
--- fs/nfsd/auth.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/nfsd/auth.c +3 -3
@@ -59,10 +59,10 @@ int nfsd_setuser(struct svc_rqst *rqstp,GROUP_AT (gi, i) = exp->ex_anon_gid; elseGROUP_AT (gi ,i ) =GROUP_AT (rqgi, i); - -/* Each thread allocates its own gi, no race */ -groups_sort (gi); } + +/* Each thread allocates its own gi, no race */ +groups_sort (gi); }else { gi =get_group_info (rqgi); }
PATCH 116/254 USB: serial: option: add support for Telit ME910 PID 0x1101
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Daniele Palmas <[email protected]>
commit 08933099e6404f588f81c2050bfec7313e06eeaf upstream.
This patch adds support for PID 0x1101 of Telit ME910.
--- drivers/usb/serial/option.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/usb/serial/option.c +8 -0
@@ -286,6 +286,7 @@ static void option_instat_callback(struc#define TELIT_PRODUCT_LE922_USBCFG3 0x1043#define TELIT_PRODUCT_LE922_USBCFG5 0x1045#define TELIT_PRODUCT_ME910 0x1100 +#define TELIT_PRODUCT_ME910_DUAL_MODEM 0x1101#define TELIT_PRODUCT_LE920 0x1200#define TELIT_PRODUCT_LE910 0x1201#define TELIT_PRODUCT_LE910_USBCFG4 0x1206
@@ -658,6 +659,11 @@ static const struct option_blacklist_inf .reserved = BIT(1) | BIT(3), }; +static const struct option_blacklist_info telit_me910_dual_modem_blacklist = { + .sendsetup =BIT (0 ), + .reserved =BIT (3 ), +}; +static const struct option_blacklist_info telit_le910_blacklist = { .sendsetup =BIT (0 ), .reserved =BIT (1 ) |BIT (2 ),
@@ -1266,6 +1272,8 @@ static const struct usb_device_id option .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg0 }, { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910), .driver_info = (kernel_ulong_t)&telit_me910_blacklist }, + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM), + .driver_info = (kernel_ulong_t)&telit_me910_dual_modem_blacklist }, { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910), .driver_info = (kernel_ulong_t)&telit_le910_blacklist }, { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910_USBCFG4),
PATCH 117/254 posix-timer: Properly check sigevent->sigev_notify
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit cef31d9af908243421258f1df35a4a644604efbe upstream.
timer_create() specifies via sigevent->sigev_notify the signal delivery for the new timer. The valid modes are SIGEV_NONE, SIGEV_SIGNAL, SIGEV_THREAD and (SIGEV_SIGNAL | SIGEV_THREAD_ID).
The sanity check in good_sigevent() is only checking the valid combination for the SIGEV_THREAD_ID bit, i.e. SIGEV_SIGNAL, but if SIGEV_THREAD_ID is not set it accepts any random value.
This has no real effects on the posix timer and signal delivery code, but it affects show_timer() which handles the output of /proc/$PID/timers. That function uses a string array to pretty print sigev_notify. The access to that array has no bound checks, so random sigev_notify cause access beyond the array bounds.
Add proper checks for the valid notify modes and remove the SIGEV_THREAD_ID masking from various code pathes as SIGEV_NONE can never be set in combination with SIGEV_THREAD_ID.
[bwh: Backported to 3.16:
- Add sig_none variable in common_timer_get(), added earlier upstream
- Adjust filename, context]
--- kernel/posix-timers.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)
kernel/posix-timers.c +21 -16
@@ -498,17 +498,22 @@ static struct pid *good_sigevent(sigeven {struct task_struct *rtn = current->group_leader; -if ((event->sigev_notify &SIGEV_THREAD_ID ) && - (!(rtn =find_task_by_vpid (event->sigev_notify_thread_id)) || - !same_thread_group (rtn, current) || - (event->sigev_notify & ~SIGEV_THREAD_ID ) !=SIGEV_SIGNAL )) +switch (event->sigev_notify) { +case SIGEV_SIGNAL |SIGEV_THREAD_ID : + rtn =find_task_by_vpid (event->sigev_notify_thread_id); +if (!rtn || !same_thread_group (rtn, current)) +return NULL ; +/* FALLTHRU */ +case SIGEV_SIGNAL : +case SIGEV_THREAD : +if (event->sigev_signo <=0 || event->sigev_signo >SIGRTMAX ) +return NULL ; +/* FALLTHRU */ +case SIGEV_NONE : +return task_pid (rtn); +default :return NULL ; - -if (((event->sigev_notify & ~SIGEV_THREAD_ID ) !=SIGEV_NONE ) && - ((event->sigev_signo <=0 ) || (event->sigev_signo >SIGRTMAX ))) -return NULL ; - -return task_pid (rtn); + } } void posix_timers_register_clock(const clockid_t clock_id,
@@ -728,16 +733,17 @@ common_timer_get(struct k_itimer *timr, {ktime_t now, remaining, iv;struct hrtimer *timer = &timr->it.real.timer; +bool sig_none;memset (cur_setting,0 ,sizeof (struct itimerspec )); + sig_none = timr->it_sigev_notify ==SIGEV_NONE ; iv = timr->it.real.interval;/* interval timer ? */ if (iv.tv64) cur_setting->it_interval =ktime_to_timespec (iv); -else if (!hrtimer_active (timer) && - (timr->it_sigev_notify & ~SIGEV_THREAD_ID ) !=SIGEV_NONE ) +else if (!hrtimer_active (timer) && !sig_none)return ; now = timer->base->get_time ();
@@ -747,8 +753,7 @@ common_timer_get(struct k_itimer *timr,* timer move the expiry time forward by intervals, so * expiry is > now. */ -if (iv.tv64 && (timr->it_requeue_pending &REQUEUE_PENDING || - (timr->it_sigev_notify & ~SIGEV_THREAD_ID ) ==SIGEV_NONE )) +if (iv.tv64 && (timr->it_requeue_pending &REQUEUE_PENDING || sig_none)) timr->it_overrun += (unsigned int )hrtimer_forward (timer, now, iv); remaining =ktime_sub (hrtimer_get_expires (timer), now);
@@ -758,7 +763,7 @@ common_timer_get(struct k_itimer *timr,* A single shot SIGEV_NONE timer must return 0, when * it is expired ! */ -if ((timr->it_sigev_notify & ~SIGEV_THREAD_ID ) !=SIGEV_NONE ) +if (!sig_none) cur_setting->it_value.tv_nsec =1 ; }else cur_setting->it_value =ktime_to_timespec (remaining);
@@ -856,7 +861,7 @@ common_timer_set(struct k_itimer *timr, timr->it.real.interval =timespec_to_ktime (new_setting->it_interval);/* SIGEV_NONE timers are not queued ! See common_timer_get */ -if (((timr->it_sigev_notify & ~SIGEV_THREAD_ID ) ==SIGEV_NONE )) { +if (timr->it_sigev_notify ==SIGEV_NONE ) {/* Setup correct expiry time for relative timers */ if (mode ==HRTIMER_MODE_REL ) {hrtimer_add_expires (timer, timer->base->get_time ());
PATCH 118/254 parisc: Hide Diva-built-in serial aux and graphics card
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit bcf3f1752a622f1372d3252d0fea8855d89812e7 upstream.
Diva GSP card has built-in serial AUX port and ATI graphic card which simply don't work and which both don't have external connectors. User Guides even mention that those devices shouldn't be used.
So, prevent that Linux drivers try to enable those devices.
--- drivers/parisc/lba_pci.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
drivers/parisc/lba_pci.c +33 -0
@@ -1652,3 +1652,36 @@ void lba_set_iregs(struct parisc_deviceiounmap (base_addr); } + +/* +* The design of the Diva management card in rp34x0 machines (rp3410, rp3440) +* seems rushed, so that many built-in components simply don't work. +* The following quirks disable the serial AUX port and the built-in ATI RV100 +* Radeon 7000 graphics card which both don't have any external connectors and +* thus are useless, and even worse, e.g. the AUX port occupies ttyS0 and as +* such makes those machines the only PARISC machines on which we can't use +* ttyS0 as boot console. +*/ +static void quirk_diva_ati_card (struct pci_dev *dev) +{ +if (dev->subsystem_vendor !=PCI_VENDOR_ID_HP || + dev->subsystem_device !=0x1292 ) +return ; + +dev_info (&dev->dev,"Hiding Diva built-in ATI card" ); + dev->device =0 ; +} +DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_ATI ,PCI_DEVICE_ID_ATI_RADEON_QY , + quirk_diva_ati_card); + +static void quirk_diva_aux_disable (struct pci_dev *dev) +{ +if (dev->subsystem_vendor !=PCI_VENDOR_ID_HP || + dev->subsystem_device !=0x1291 ) +return ; + +dev_info (&dev->dev,"Hiding Diva built-in AUX serial device" ); + dev->device =0 ; +} +DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_HP ,PCI_DEVICE_ID_HP_DIVA_AUX , + quirk_diva_aux_disable);
PATCH 119/254 KVM: arm/arm64: Fix HYP unmapping going off limits
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
commit 7839c672e58bf62da8f2f0197fefb442c02ba1dd upstream.
When we unmap the HYP memory, we try to be clever and unmap one PGD at a time. If we start with a non-PGD aligned address and try to unmap a whole PGD, things go horribly wrong in unmap_hyp_range (addr and end can never match, and it all goes really badly as we keep incrementing pgd and parse random memory as page tables...).
The obvious fix is to let unmap_hyp_range do what it does best, which is to iterate over a range.
The size of the linear mapping, which begins at PAGE_OFFSET, can be easily calculated by subtracting PAGE_OFFSET form high_memory, because high_memory is defined as the linear map address of the last byte of DRAM, plus one.
The size of the vmalloc region is given trivially by VMALLOC_END - VMALLOC_START.
--- arch/arm/kvm/mmu.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
arch/arm/kvm/mmu.c +4 -6
@@ -345,17 +345,15 @@ void free_boot_hyp_pgd(void)*/ void free_hyp_pgds (void ) { -unsigned long addr; -free_boot_hyp_pgd ();mutex_lock (&kvm_hyp_pgd_mutex);if (hyp_pgd) { -for (addr =PAGE_OFFSET ;virt_addr_valid (addr); addr +=PGDIR_SIZE ) -unmap_range (NULL , hyp_pgd,KERN_TO_HYP (addr),PGDIR_SIZE ); -for (addr =VMALLOC_START ;is_vmalloc_addr ((void *)addr); addr +=PGDIR_SIZE ) -unmap_range (NULL , hyp_pgd,KERN_TO_HYP (addr),PGDIR_SIZE ); +unmap_range (NULL , hyp_pgd,KERN_TO_HYP (PAGE_OFFSET ), + (uintptr_t )high_memory -PAGE_OFFSET ); +unmap_range (NULL , hyp_pgd,KERN_TO_HYP (VMALLOC_START ), +VMALLOC_END -VMALLOC_START );free_pages ((unsigned long )hyp_pgd, pgd_order); hyp_pgd =NULL ;
PATCH 120/254 PCI / PM: Force devices to D0 in pci_pm_thaw_noirq()
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Rafael J. Wysocki" <[email protected]>
commit 5839ee7389e893a31e4e3c9cf17b50d14103c902 upstream.
It is incorrect to call pci_restore_state() for devices in low-power states (D1-D3), as that involves the restoration of MSI setup which requires MMIO to be operational and that is only the case in D0.
However, pci_pm_thaw_noirq() may do that if the driver's "freeze" callbacks put the device into a low-power state, so fix it by making it force devices into D0 via pci_set_power_state() instead of trying to "update" their power state which is pointless.
--- drivers/pci/pci-driver.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/pci/pci-driver.c +6 -1
@@ -921,7 +921,12 @@ static int pci_pm_thaw_noirq(struct deviif (pci_has_legacy_pm_support (pci_dev))return pci_legacy_resume_early (dev); -pci_update_current_state (pci_dev,PCI_D0 ); +/* +* pci_restore_state() requires the device to be in D0 (because of MSI +* restoration among other things), so force it into D0 in case the +* driver's "freeze" callbacks put it into a low-power state directly. +*/ +pci_set_power_state (pci_dev,PCI_D0 );pci_restore_state (pci_dev);if (drv && drv->pm && drv->pm->thaw_noirq)
PATCH 121/254 ACPI: APEI / ERST: Fix missing error handling in erst_reader()
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit bb82e0b4a7e96494f0c1004ce50cec3d7b5fb3d1 upstream.
The commit f6f828513290 ("pstore: pass allocated memory region back to caller") changed the check of the return value from erst_read() in erst_reader() in the following way:
if (len == -ENOENT)
goto skip;
- else if (len < 0) {
- rc = -1;
+ else if (len < sizeof(*rcd)) {
+ rc = -EIO;
goto out;This introduced another bug: since the comparison with sizeof() is cast to unsigned, a negative len value doesn't hit any longer. As a result, when an error is returned from erst_read(), the code falls through, and it may eventually lead to some weird thing like memory corruption.
This patch adds the negative error value check more explicitly for addressing the issue.
--- drivers/acpi/apei/erst.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/apei/erst.c +1 -1
@@ -1023,7 +1023,7 @@ skip:/* The record may be cleared by others, try read next record */ if (len == -ENOENT ) goto skip; -else if (len <sizeof (*rcd)) { +else if (len <0 || len <sizeof (*rcd)) { rc = -EIO ; goto out; }
PATCH 122/254 net: phy: marvell: Limit 88m1101 autoneg errata to 88E1145 as well.
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Qiang <[email protected]>
commit c505873eaece2b4aefd07d339dc7e1400e0235ac upstream.
88E1145 also need this autoneg errata.
--- drivers/net/phy/marvell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/marvell.c +1 -1
@@ -988,7 +988,7 @@ static struct phy_driver marvell_drivers .features = PHY_GBIT_FEATURES, .flags = PHY_HAS_INTERRUPT, .config_init = &m88e1145_config_init, - .config_aneg = &marvell_config_aneg, + .config_aneg = &m88e1101_config_aneg, .read_status = &genphy_read_status, .ack_interrupt = &marvell_ack_interrupt, .config_intr = &marvell_config_intr,
PATCH 123/254 net: bridge: fix early call to br_stp_change_bridge_id and plug newlink leaks
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Nikolay Aleksandrov <[email protected]>
commit 84aeb437ab98a2bce3d4b2111c79723aedfceb33 upstream.
The early call to br_stp_change_bridge_id in bridge's newlink can cause a memory leak if an error occurs during the newlink because the fdb entries are not cleaned up if a different lladdr was specified, also another minor issue is that it generates fdb notifications with ifindex = 0. Another unrelated memory leak is the bridge sysfs entries which get added on NETDEV_REGISTER event, but are not cleaned up in the newlink error path. To remove this special case the call to br_stp_change_bridge_id is done after netdev register and we cleanup the bridge on changelink error via br_dev_delete to plug all leaks.
This patch makes netlink bridge destruction on newlink error the same as dellink and ioctl del which is necessary since at that point we have a fully initialized bridge device.
To reproduce the issue:
$ ip l add br0 address 00:11:22:33:44:55 type bridge group_fwd_mask 1 RTNETLINK answers: Invalid argument
$ rmmod bridge [ 1822.142525] ============================================================================= [ 1822.143640] BUG bridge_fdb_cache (Tainted: G O ): Objects remaining in bridge_fdb_cache on __kmem_cache_shutdown() [ 1822.144821] -----------------------------------------------------------------------------
[ 1822.145990] Disabling lock debugging due to kernel taint [ 1822.146732] INFO: Slab 0x0000000092a844b2 objects=32 used=2 fp=0x00000000fef011b0 flags=0x1ffff8000000100 [ 1822.147700] CPU: 2 PID: 13584 Comm: rmmod Tainted: G B O 4.15.0-rc2+ #87 [ 1822.148578] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.7.5-20140531_083030-gandalf 04/01/2014 [ 1822.150008] Call Trace: [ 1822.150510] dump_stack+0x78/0xa9 [ 1822.151156] slab_err+0xb1/0xd3 [ 1822.151834] ? __kmalloc+0x1bb/0x1ce [ 1822.152546] __kmem_cache_shutdown+0x151/0x28b [ 1822.153395] shutdown_cache+0x13/0x144 [ 1822.154126] kmem_cache_destroy+0x1c0/0x1fb [ 1822.154669] SyS_delete_module+0x194/0x244 [ 1822.155199] ? trace_hardirqs_on_thunk+0x1a/0x1c [ 1822.155773] entry_SYSCALL_64_fastpath+0x23/0x9a [ 1822.156343] RIP: 0033:0x7f929bd38b17 [ 1822.156859] RSP: 002b:00007ffd160e9a98 EFLAGS: 00000202 ORIG_RAX: 00000000000000b0 [ 1822.157728] RAX: ffffffffffffffda RBX: 00005578316ba090 RCX: 00007f929bd38b17 [ 1822.158422] RDX: 00007f929bd9ec60 RSI: 0000000000000800 RDI: 00005578316ba0f0 [ 1822.159114] RBP: 0000000000000003 R08: 00007f929bff5f20 R09: 00007ffd160e8a11 [ 1822.159808] R10: 00007ffd160e9860 R11: 0000000000000202 R12: 00007ffd160e8a80 [ 1822.160513] R13: 0000000000000000 R14: 0000000000000000 R15: 00005578316ba090 [ 1822.161278] INFO: Object 0x000000007645de29 @offset=0 [ 1822.161666] INFO: Object 0x00000000d5df2ab5 @offset=128
[bwh: Backported to 3.16: register_netdevice() was the last thing done in
br_dev_newlink(), so no extra cleanup is needed]
---
net/bridge/br_netlink.c +6 -1
@@ -452,6 +452,11 @@ static int br_dev_newlink(struct net *sr struct nlattr *tb[], struct nlattr *data[]) { struct net_bridge *br = netdev_priv(dev); +int err; + + err =register_netdevice (dev); +if (err) +return err;if (tb[IFLA_ADDRESS ]) {spin_lock_bh (&br->lock);
@@ -459,7 +464,7 @@ static int br_dev_newlink(struct net *srspin_unlock_bh (&br->lock); } -return register_netdevice (dev); +return 0 ; }static size_t br_get_link_af_size (const struct net_device *dev)
PATCH 124/254 ALSA: usb-audio: Fix the missing ctl name suffix at parsing SU
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 5a15f289ee87eaf33f13f08a4909ec99d837ec5f upstream.
The commit 89b89d121ffc ("ALSA: usb-audio: Add check return value for usb_string()") added the check of the return value from snd_usb_copy_string_desc(), which is correct per se, but it introduced a regression. In the original code, either the "Clock Source", "Playback Source" or "Capture Source" suffix is added after the terminal string, while the commit changed it to add the suffix only when get_term_name() is failing. It ended up with an incorrect ctl name like "PCM" instead of "PCM Capture Source".
Also, even the original code has a similar bug: when the ctl name is generated from snd_usb_copy_string_desc() for the given iSelector, it also doesn't put the suffix.
This patch addresses these issues: the suffix is added always when no static mapping is found. Also the patch tries to put more comments and cleans up the if/else block for better readability in order to avoid the same pitfall again.
--- sound/usb/mixer.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-)
sound/usb/mixer.c +16 -11
@@ -2095,20 +2095,25 @@ static int parse_audio_selector_unit(str kctl->private_value = (unsigned long )namelist; kctl->private_free = usb_mixer_selector_elem_free; - nameid =uac_selector_unit_iSelector (desc); +/* check the static mapping table at first */ len =check_mapped_name (map, kctl->id.name,sizeof (kctl->id.name)); -if (len) - ; -else if (nameid) - len =snd_usb_copy_string_desc (state, nameid, kctl->id.name, -sizeof (kctl->id.name)); -else - len =get_term_name (state, &state->oterm, - kctl->id.name,sizeof (kctl->id.name),0 ); -if (!len) { -strlcpy (kctl->id.name,"USB" ,sizeof (kctl->id.name)); +/* no mapping ? */ +/* if iSelector is given, use it */ + nameid =uac_selector_unit_iSelector (desc); +if (nameid) + len =snd_usb_copy_string_desc (state, nameid, + kctl->id.name, +sizeof (kctl->id.name)); +/* ... or pick up the terminal name at next */ +if (!len) + len =get_term_name (state, &state->oterm, + kctl->id.name,sizeof (kctl->id.name),0 ); +/* ... or use the fixed string "USB" as the last resort */ +if (!len) +strlcpy (kctl->id.name,"USB" ,sizeof (kctl->id.name)); +/* and add the proper suffix */ if (desc->bDescriptorSubtype ==UAC2_CLOCK_SELECTOR )append_ctl_name (kctl," Clock Source" );else if ((state->oterm.type &0xff00 ) ==0x0100 )
PATCH 125/254 xfrm: Reinject transport-mode packets through tasklet
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
commit acf568ee859f098279eadf551612f103afdacb4e upstream.
This is an old bugbear of mine:
https://www.mail-archive.com/[email protected]/msg03894.html
By crafting special packets, it is possible to cause recursion in our kernel when processing transport-mode packets at levels that are only limited by packet size.
The easiest one is with DNAT, but an even worse one is where UDP encapsulation is used in which case you just have to insert an UDP encapsulation header in between each level of recursion.
This patch avoids this problem by reinjecting tranport-mode packets through a tasklet.
[bwh: Backported to 3.16:
- netfilter finish callbacks only receive an sk_buff pointer
- Adjust context]
---
include/net/xfrm.h +1 -0
@@ -1496,6 +1496,7 @@ int xfrm_init_state(struct xfrm_state *xint xfrm_prepare_input (struct xfrm_state *x,struct sk_buff *skb);int xfrm_input (struct sk_buff *skb,int nexthdr,__be32 spi,int encap_type);int xfrm_input_resume (struct sk_buff *skb,int nexthdr); +int xfrm_trans_queue (struct sk_buff *skb,int (*finish)(struct sk_buff *));int xfrm_output_resume (struct sk_buff *skb,int err);int xfrm_output (struct sk_buff *skb);int xfrm_inner_extract_output (struct xfrm_state *x,struct sk_buff *skb);
net/ipv4/xfrm4_input.c +10 -1
@@ -22,6 +22,11 @@ int xfrm4_extract_input(struct xfrm_statreturn xfrm4_extract_header (skb); } +static int xfrm4_rcv_encap_finish2 (struct sk_buff *skb) +{ +return dst_input (skb); +} +static inline int xfrm4_rcv_encap_finish (struct sk_buff *skb) {if (skb_dst (skb) ==NULL ) {
@@ -31,7 +36,11 @@ static inline int xfrm4_rcv_encap_finish iph->tos, skb->dev)) goto drop; } -return dst_input (skb); + +if (xfrm_trans_queue (skb, xfrm4_rcv_encap_finish2)) + goto drop; + +return 0 ; drop:kfree_skb (skb);return NET_RX_DROP ;
net/ipv6/xfrm6_input.c +8 -1
@@ -29,6 +29,13 @@ int xfrm6_rcv_spi(struct sk_buff *skb, i }EXPORT_SYMBOL (xfrm6_rcv_spi); +static int xfrm6_transport_finish2 (struct sk_buff *skb) +{ +if (xfrm_trans_queue (skb, ip6_rcv_finish)) +__kfree_skb (skb); +return -1 ; +} +int xfrm6_transport_finish (struct sk_buff *skb,int async) { skb_network_header(skb)[IP6CB(skb)->nhoff] =
@@ -43,7 +50,7 @@ int xfrm6_transport_finish(struct sk_buf__skb_push (skb, skb->data -skb_network_header (skb));NF_HOOK (NFPROTO_IPV6 ,NF_INET_PRE_ROUTING , skb, skb->dev,NULL , - ip6_rcv_finish); + xfrm6_transport_finish2);return -1 ; }
net/xfrm/xfrm_input.c +56 -0
84 lines not on this page · raw message
PATCH 126/254 USB: serial: option: adding support for YUGA CLM920-NC5
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: SZ Lin (林上智)
<[email protected]>
commit 3920bb713038810f25770e7545b79f204685c8f2 upstream.
This patch adds support for YUGA CLM920-NC5 PID 0x9625 USB modem to option driver.
Interface layout:
0: QCDM/DIAG
1: ADB
2: MODEM
3: AT
4: RMNET
--- drivers/usb/serial/option.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/usb/serial/option.c +9 -0
@@ -237,6 +237,8 @@ static void option_instat_callback(struc/* These Quectel products use Qualcomm's vendor ID */ #define QUECTEL_PRODUCT_UC20 0x9003#define QUECTEL_PRODUCT_UC15 0x9090 +/* These Yuga products use Qualcomm's vendor ID */ +#define YUGA_PRODUCT_CLM920_NC5 0x9625#define QUECTEL_VENDOR_ID 0x2c7c/* These Quectel products use Quectel's vendor ID */
@@ -698,6 +700,10 @@ static const struct option_blacklist_inf .reserved = BIT(4) | BIT(5), }; +static const struct option_blacklist_info yuga_clm920_nc5_blacklist = { + .reserved =BIT (1 ) |BIT (4 ), +}; +static const struct usb_device_id option_ids[] = { {USB_DEVICE (OPTION_VENDOR_ID ,OPTION_PRODUCT_COLT ) }, {USB_DEVICE (OPTION_VENDOR_ID ,OPTION_PRODUCT_RICOLA ) },
@@ -1206,6 +1212,9 @@ static const struct usb_device_id option { USB_DEVICE(QUALCOMM_VENDOR_ID, QUECTEL_PRODUCT_UC15)}, { USB_DEVICE(QUALCOMM_VENDOR_ID, QUECTEL_PRODUCT_UC20), .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, + /* Yuga products use Qualcomm vendor ID */ + { USB_DEVICE(QUALCOMM_VENDOR_ID, YUGA_PRODUCT_CLM920_NC5), + .driver_info = (kernel_ulong_t)&yuga_clm920_nc5_blacklist },/* Quectel products using Quectel vendor ID */ { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC21), .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
PATCH 127/254 usbip: vhci: stop printing kernel pointer addresses in messages
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Shuah Khan <[email protected]>
commit 8272d099d05f7ab2776cf56a2ab9f9443be18907 upstream.
Remove and/or change debug, info. and error messages to not print kernel pointer addresses.
--- drivers/staging/usbip/vhci_hcd.c | 10 ---------- drivers/staging/usbip/vhci_rx.c | 23 +++++++++++------------ drivers/staging/usbip/vhci_tx.c | 3 ++- 3 files changed, 13 insertions(+), 23 deletions(-)
drivers/staging/usbip/vhci_hcd.c +0 -10
@@ -466,9 +466,6 @@ static int vhci_urb_enqueue(struct usb_hint ret =0 ;struct vhci_device *vdev; -usbip_dbg_vhci_hc ("enter, usb_hcd %p urb %p mem_flags %d\n" , - hcd, urb, mem_flags); -/* patch to usb_sg_init() is in 2.5.60 */ BUG_ON (!urb->transfer_buffer && urb->transfer_buffer_length);
@@ -626,8 +623,6 @@ static int vhci_urb_dequeue(struct usb_hstruct vhci_priv *priv;struct vhci_device *vdev; -pr_info ("dequeue a urb %p\n" , urb); -spin_lock (&the_controller->lock); priv = urb->hcpriv;
@@ -655,7 +650,6 @@ static int vhci_urb_dequeue(struct usb_h/* tcp connection is closed */ spin_lock (&vdev->priv_lock); -pr_info ("device %p seems to be disconnected\n" , vdev);list_del (&priv->list);kfree (priv); urb->hcpriv =NULL ;
@@ -667,8 +661,6 @@ static int vhci_urb_dequeue(struct usb_h* vhci_rx will receive RET_UNLINK and give back the URB. * Otherwise, we give back it here. */ -pr_info ("gives back urb %p\n" , urb); -usb_hcd_unlink_urb_from_ep (hcd, urb);spin_unlock (&the_controller->lock);
@@ -697,8 +689,6 @@ static int vhci_urb_dequeue(struct usb_h unlink->unlink_seqnum = priv->seqnum; -pr_info ("device %p seems to be still connected\n" , vdev); -/* send cmd_unlink and try to cancel the pending URB in the * peer */ list_add_tail (&unlink->list, &vdev->unlink_tx);
drivers/staging/usbip/vhci_rx.c +11 -12
@@ -37,24 +37,23 @@ struct urb *pickup_urb_and_free_priv(str urb = priv->urb; status = urb->status; -usbip_dbg_vhci_rx ("find urb %p vurb %p seqnum %u\n" , - urb, priv, seqnum); +usbip_dbg_vhci_rx ("find urb seqnum %u\n" , seqnum);switch (status) {case -ENOENT :/* fall through */ case -ECONNRESET : -dev_info (&urb->dev->dev, -"urb %p was unlinked %ssynchronuously.\n" , urb, - status == -ENOENT ?"" :"a" ); +dev_dbg (&urb->dev->dev, +"urb seq# %u was unlinked %ssynchronuously\n" , + seqnum, status == -ENOENT ?"" :"a" );break ;case -EINPROGRESS :/* no info output */ break ;default : -dev_info (&urb->dev->dev, -"urb %p may be in a error, status %d\n" , urb, - status); +dev_dbg (&urb->dev->dev, +"urb seq# %u may be in a error, status %d\n" , + seqnum, status); }list_del (&priv->list);
@@ -78,8 +77,8 @@ static void vhci_recv_ret_submit(structspin_unlock (&vdev->priv_lock);if (!urb) { -pr_err ("cannot find a urb of seqnum %u\n" , pdu->base.seqnum); -pr_info ("max seqnum %d\n" , +pr_err ("cannot find a urb of seqnum %u max seqnum %d\n" , + pdu->base.seqnum,atomic_read (&the_controller->seqnum));usbip_event_add (ud,VDEV_EVENT_ERROR_TCP );return ;
@@ -102,7 +101,7 @@ static void vhci_recv_ret_submit(structif (usbip_dbg_flag_vhci_rx)usbip_dump_urb (urb); -usbip_dbg_vhci_rx ("now giveback urb %p\n" , urb); +usbip_dbg_vhci_rx ("now giveback urb %u\n" , pdu->base.seqnum);spin_lock (&the_controller->lock);usb_hcd_unlink_urb_from_ep (vhci_to_hcd (the_controller), urb);
@@ -167,7 +166,7 @@ static void vhci_recv_ret_unlink(structpr_info ("the urb (seqnum %d) was already given back\n" , pdu->base.seqnum); }else { -usbip_dbg_vhci_rx ("now giveback urb %p\n" , urb); +usbip_dbg_vhci_rx ("now giveback urb %d\n" , pdu->base.seqnum);/* If unlink is successful, status is -ECONNRESET */ urb->status = pdu->u.ret_unlink.status;
drivers/staging/usbip/vhci_tx.c +2 -1
@@ -82,7 +82,8 @@ static int vhci_send_cmd_submit(struct vmemset (&msg,0 ,sizeof (msg));memset (&iov,0 ,sizeof (iov)); -usbip_dbg_vhci_tx ("setup txdata urb %p\n" , urb); +usbip_dbg_vhci_tx ("setup txdata urb seqnum %lu\n" , + priv->seqnum);/* 1. setup usbip_header */ setup_cmd_submit_pdu (&pdu_header, urb);
PATCH 128/254 usbip: stub: stop printing kernel pointer addresses in messages
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Shuah Khan <[email protected]>
commit 248a22044366f588d46754c54dfe29ffe4f8b4df upstream.
Remove and/or change debug, info. and error messages to not print kernel pointer addresses.
[bwh: Backported to 3.16:
- Drop change in stub_complete()
- Adjust filenames]
--- drivers/staging/usbip/stub_main.c | 5 +++-- drivers/staging/usbip/stub_rx.c | 7 ++----- drivers/staging/usbip/stub_tx.c | 6 +++--- 3 files changed, 8 insertions(+), 10 deletions(-)
drivers/staging/usbip/stub_main.c +3 -2
@@ -256,11 +256,12 @@ void stub_device_cleanup_urbs(struct stustruct stub_priv *priv;struct urb *urb; -dev_dbg (&sdev->udev->dev,"free sdev %p\n" , sdev); +dev_dbg (&sdev->udev->dev,"Stub device cleaning up urbs\n" );while ((priv =stub_priv_pop (sdev))) { urb = priv->urb; -dev_dbg (&sdev->udev->dev,"free urb %p\n" , urb); +dev_dbg (&sdev->udev->dev,"free urb seqnum %lu\n" , + priv->seqnum);usb_kill_urb (urb);kmem_cache_free (stub_priv_cache, priv);
drivers/staging/usbip/stub_rx.c +2 -5
@@ -225,9 +225,6 @@ static int stub_recv_cmd_unlink(struct sif (priv->seqnum != pdu->u.cmd_unlink.seqnum)continue ; -dev_info (&priv->urb->dev->dev,"unlink urb %p\n" , - priv->urb); -/* * This matched urb is not completed yet (i.e., be in * flight in usb hcd hardware/driver). Now we are
@@ -266,8 +263,8 @@ static int stub_recv_cmd_unlink(struct s ret =usb_unlink_urb (priv->urb);if (ret != -EINPROGRESS )dev_err (&priv->urb->dev->dev, -"failed to unlink a urb %p, ret %d\n" , - priv->urb, ret); +"failed to unlink a urb # %lu, ret %d\n" , + priv->seqnum, ret);return 0 ; }
drivers/staging/usbip/stub_tx.c +2 -2
@@ -201,8 +201,8 @@ static int stub_send_ret_submit(struct s/* 1. setup usbip_header */ setup_ret_submit_pdu (&pdu_header, urb); -usbip_dbg_stub_tx ("setup txdata seqnum: %d urb: %p\n" , - pdu_header.base.seqnum, urb); +usbip_dbg_stub_tx ("setup txdata seqnum: %d\n" , + pdu_header.base.seqnum);usbip_header_correct_endian (&pdu_header,1 ); iov[iovnum].iov_base = &pdu_header;
PATCH 129/254 usbip: prevent leaking socket pointer address in messages
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Shuah Khan <[email protected]>
commit 90120d15f4c397272aaf41077960a157fc4212bf upstream.
usbip driver is leaking socket pointer address in messages. Remove the messages that aren't useful and print sockfd in the ones that are useful for debugging.
---
drivers/staging/usbip/stub_dev.c +1 -2
@@ -190,8 +190,7 @@ static void stub_shutdown_connection(str* step 1? */ if (ud->tcp_socket) { -dev_dbg (&sdev->udev->dev,"shutdown tcp_socket %p\n" , - ud->tcp_socket); +dev_dbg (&sdev->udev->dev,"shutdown sockfd %d\n" , ud->sockfd);kernel_sock_shutdown (ud->tcp_socket,SHUT_RDWR ); }
drivers/staging/usbip/usbip_common.c +4 -10
@@ -333,13 +333,10 @@ int usbip_recv(struct socket *sock, voidchar *bp = buf;int osize = size; -usbip_dbg_xmit ("enter\n" ); - -if (!sock || !buf || !size) { -pr_err ("invalid arg, sock %p buff %p size %d\n" , sock, buf, - size); +if (!sock || !buf || !size)return -EINVAL ; - } + +usbip_dbg_xmit ("enter\n" ); do { sock->sk->sk_allocation = GFP_NOIO;
@@ -352,11 +349,8 @@ int usbip_recv(struct socket *sock, void msg.msg_flags =MSG_NOSIGNAL ; result =kernel_recvmsg (sock, &msg, &iov,1 , size,MSG_WAITALL ); -if (result <=0 ) { -pr_debug ("receive sock %p buf %p size %u ret %d total %d\n" , - sock, buf, size, result, total); +if (result <=0 ) goto err; - } size -= result; buf += result;
drivers/staging/usbip/vhci_hcd.c +1 -1
@@ -767,7 +767,7 @@ static void vhci_shutdown_connection(str/* need this? see stub_dev.c */ if (ud->tcp_socket) { -pr_debug ("shutdown tcp_socket %p\n" , ud->tcp_socket); +pr_debug ("shutdown tcp_socket %d\n" , ud->sockfd);kernel_sock_shutdown (ud->tcp_socket,SHUT_RDWR ); }
PATCH 130/254 usbip: fix usbip bind writing random string after command in match_busid
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Juan Zea <[email protected]>
commit 544c4605acc5ae4afe7dd5914147947db182f2fb upstream.
usbip bind writes commands followed by random string when writing to match_busid attribute in sysfs, caused by using full variable size instead of string length.
--- drivers/staging/usbip/userspace/src/utils.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/staging/usbip/userspace/src/utils.c +6 -3
@@ -30,6 +30,7 @@ int modify_match_busid(char *busid, intchar command[SYSFS_BUS_ID_SIZE +4 ];char match_busid_attr_path[SYSFS_PATH_MAX ];int rc; +int cmd_size; snprintf(match_busid_attr_path, sizeof(match_busid_attr_path), "%s/%s/%s/%s/%s/%s", SYSFS_MNT_PATH, SYSFS_BUS_NAME,
@@ -37,12 +38,14 @@ int modify_match_busid(char *busid, int attr_name);if (add) -snprintf (command,SYSFS_BUS_ID_SIZE +4 ,"add %s" , busid); + cmd_size =snprintf (command,SYSFS_BUS_ID_SIZE +4 ,"add %s" , + busid);else -snprintf (command,SYSFS_BUS_ID_SIZE +4 ,"del %s" , busid); + cmd_size =snprintf (command,SYSFS_BUS_ID_SIZE +4 ,"del %s" , + busid); rc =write_sysfs_attribute (match_busid_attr_path, command, -sizeof (command)); + cmd_size);if (rc <0 ) {dbg ("failed to write match_busid: %s" ,strerror (errno));return -1 ;
PATCH 131/254 usb: add RESET_RESUME for ELSA MicroLink 56K
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit b9096d9f15c142574ebebe8fbb137012bb9d99c2 upstream.
This modem needs this quirk to operate. It produces timeouts when resumed without reset.
--- drivers/usb/core/quirks.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/core/quirks.c +3 -0
@@ -151,6 +151,9 @@ static const struct usb_device_id usb_qu/* Genesys Logic hub, internally used by KY-688 USB 3.1 Type-C Hub */ { USB_DEVICE(0x05e3, 0x0612), .driver_info = USB_QUIRK_NO_LPM }, + /* ELSA MicroLink 56K */ + { USB_DEVICE(0x05cc, 0x2267), .driver_info = USB_QUIRK_RESET_RESUME }, + /* Genesys Logic hub, internally used by Moshi USB to Ethernet Adapter */ { USB_DEVICE(0x05e3, 0x0616), .driver_info = USB_QUIRK_NO_LPM },
PATCH 132/254 usb: Add device quirk for Logitech HD Pro Webcam C925e
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Fleytman Dmitry Fleytman <[email protected]>
commit 7f038d256c723dd390d2fca942919573995f4cfd upstream.
Commit e0429362ab15
("usb: Add device quirk for Logitech HD Pro Webcams C920 and C930e") introduced quirk to workaround an issue with some Logitech webcams.
There is one more model that has the same issue - C925e, so applying the same quirk as well.
See aforementioned commit message for detailed explanation of the problem.
--- drivers/usb/core/quirks.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/core/quirks.c +2 -1
@@ -57,10 +57,11 @@ static const struct usb_device_id usb_qu/* Microsoft LifeCam-VX700 v2.0 */ { USB_DEVICE(0x045e, 0x0770), .driver_info = USB_QUIRK_RESET_RESUME }, - /* Logitech HD Pro Webcams C920, C920-C and C930e */ + /* Logitech HD Pro Webcams C920, C920-C, C925e and C930e */ { USB_DEVICE(0x046d, 0x082d), .driver_info = USB_QUIRK_DELAY_INIT }, { USB_DEVICE(0x046d, 0x0841), .driver_info = USB_QUIRK_DELAY_INIT }, { USB_DEVICE(0x046d, 0x0843), .driver_info = USB_QUIRK_DELAY_INIT }, + { USB_DEVICE(0x046d, 0x085b), .driver_info = USB_QUIRK_DELAY_INIT }, /* Logitech ConferenceCam CC3000e */ { USB_DEVICE(0x046d, 0x0847), .driver_info = USB_QUIRK_DELAY_INIT },
PATCH 133/254 net/mlx5: Fix misspelling in the error message and comment
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eugenia Emantayev <[email protected]>
commit 777ec2b2a3f2760505db395de1a9fa4115d74548 upstream.
Fix misspelling in word syndrome.
---
drivers/net/ethernet/mellanox/mlx5/core/eq.c +1 -1
@@ -261,7 +261,7 @@ static int mlx5_eq_int(struct mlx5_core_break ;case MLX5_EVENT_TYPE_CQ_ERROR : cqn =be32_to_cpu (eqe->data.cq_err.cqn) &0xffffff ; -mlx5_core_warn (dev,"CQ error on CQN 0x%x, syndrom 0x%x\n" , +mlx5_core_warn (dev,"CQ error on CQN 0x%x, syndrome 0x%x\n" , cqn, eqe->data.cq_err.syndrome);mlx5_cq_event (dev, cqn, eqe->type);break ;
PATCH 134/254 net/mlx5: Cleanup IRQs in case of unload failure
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Moshe Shemesh <[email protected]>
commit d6b2785cd55ee72e9608762650b3ef299f801b1b upstream.
When mlx5_stop_eqs fails to destroy any of the eqs it returns with an error. In such failure flow the function will return without
releasing all EQs irqs and then pci_free_irq_vectors will fail. Fix by only warn on destroy EQ failure and continue to release other EQs and their irqs.
It fixes the following kernel trace:
kernel: kernel BUG at drivers/pci/msi.c:352!
...
...
kernel: Call Trace:
kernel: pci_disable_msix+0xd3/0x100
kernel: pci_free_irq_vectors+0xe/0x20
kernel: mlx5_load_one.isra.17+0x9f5/0xec0 [mlx5_core]
---
drivers/net/ethernet/mellanox/mlx5/core/eq.c +11 -6
@@ -485,23 +485,28 @@ err1:return err; } -int mlx5_stop_eqs (struct mlx5_core_dev *dev) +void mlx5_stop_eqs (struct mlx5_core_dev *dev) {struct mlx5_eq_table *table = &dev->priv.eq_table;int err; err =mlx5_destroy_unmap_eq (dev, &table->pages_eq);if (err) -return err; +mlx5_core_err (dev,"failed to destroy pages eq, err(%d)\n" , + err); -mlx5_destroy_unmap_eq (dev, &table->async_eq); + err =mlx5_destroy_unmap_eq (dev, &table->async_eq); +if (err) +mlx5_core_err (dev,"failed to destroy async eq, err(%d)\n" , + err);mlx5_cmd_use_polling (dev); err =mlx5_destroy_unmap_eq (dev, &table->cmd_eq); -if (err) +if (err) { +mlx5_core_err (dev,"failed to destroy command eq, err(%d)\n" , + err);mlx5_cmd_use_events (dev); - -return err; + } } int mlx5_core_eq_query(struct mlx5_core_dev *dev, struct mlx5_eq *eq,
include/linux/mlx5/driver.h +1 -1
@@ -759,7 +759,7 @@ int mlx5_create_map_eq(struct mlx5_core_ int nent, u64 mask, const char *name, struct mlx5_uar *uar);int mlx5_destroy_unmap_eq (struct mlx5_core_dev *dev,struct mlx5_eq *eq);int mlx5_start_eqs (struct mlx5_core_dev *dev); -int mlx5_stop_eqs (struct mlx5_core_dev *dev); +void mlx5_stop_eqs (struct mlx5_core_dev *dev);int mlx5_core_attach_mcg (struct mlx5_core_dev *dev,union ib_gid *mgid,u32 qpn);int mlx5_core_detach_mcg (struct mlx5_core_dev *dev,union ib_gid *mgid,u32 qpn);
PATCH 135/254 net/mlx5: Stay in polling mode when command EQ destroy fails
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Moshe Shemesh <[email protected]>
commit a2fba188fd5eadd6061bef4f2f2577a43231ebf3 upstream.
During unload, on mlx5_stop_eqs we move command interface from events mode to polling mode, but if command interface EQ destroy fail we move back to events mode.
That's wrong since even if we fail to destroy command interface EQ, we do release its irq, so no interrupts will be received.
--- drivers/net/ethernet/mellanox/mlx5/core/eq.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eq.c +1 -3
@@ -502,11 +502,9 @@ void mlx5_stop_eqs(struct mlx5_core_devmlx5_cmd_use_polling (dev); err =mlx5_destroy_unmap_eq (dev, &table->cmd_eq); -if (err) { +if (err)mlx5_core_err (dev,"failed to destroy command eq, err(%d)\n" , err); -mlx5_cmd_use_events (dev); - } } int mlx5_core_eq_query(struct mlx5_core_dev *dev, struct mlx5_eq *eq,
PATCH 136/254 net: mvneta: clear interface link status on port disable
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Yelena Krivosheev <[email protected]>
commit 4423c18e466afdfb02a36ee8b9f901d144b3c607 upstream.
When port connect to PHY in polling mode (with poll interval 1 sec), port and phy link status must be synchronize in order don't loss link change event.
--- drivers/net/ethernet/marvell/mvneta.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/marvell/mvneta.c +4 -0
@@ -851,6 +851,10 @@ static void mvneta_port_disable(struct m val &= ~MVNETA_GMAC0_PORT_ENABLE ;mvreg_write (pp,MVNETA_GMAC_CTRL_0 , val); + pp->link =0 ; + pp->duplex =-1 ; + pp->speed =0 ; +udelay (200 ); }
PATCH 137/254 n_tty: fix EXTPROC vs ICANON interaction with TIOCINQ (aka FIONREAD)
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <[email protected]>
commit 966031f340185eddd05affcf72b740549f056348 upstream.
We added support for EXTPROC back in 2010 in commit 26df6d13406d ("tty:
Add EXTPROC support for LINEMODE") and the intent was to allow it to override some (all?) ICANON behavior. Quoting from that original commit message:
There is a new bit in the termios local flag word, EXTPROC. When this bit is set, several aspects of the terminal driver are disabled. Input line editing, character echo, and mapping of signals are all disabled. This allows the telnetd to turn off these functions when in linemode, but still keep track of what state the user wants the terminal to be in.
but the problem turns out that "several aspects of the terminal driver are disabled" is a bit ambiguous, and you can really confuse the n_tty layer by setting EXTPROC and then causing some of the ICANON invariants to no longer be maintained.
This fixes at least one such case (TIOCINQ) becoming unhappy because of the confusion over whether ICANON really means ICANON when EXTPROC is set.
This basically makes TIOCINQ match the case of read: if EXTPROC is set, we ignore ICANON. Also, make sure to reset the ICANON state ie EXTPROC changes, not just if ICANON changes.
--- drivers/tty/n_tty.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/n_tty.c +2 -2
@@ -1809,7 +1809,7 @@ static void n_tty_set_termios(struct tty {struct n_tty_data *ldata = tty->disc_data; -if (!old || (old->c_lflag ^ tty->termios.c_lflag) &ICANON ) { +if (!old || (old->c_lflag ^ tty->termios.c_lflag) & (ICANON |EXTPROC )) {bitmap_zero (ldata->read_flags,N_TTY_BUF_SIZE ); ldata->line_start = ldata->read_tail;if (!L_ICANON (tty) || !read_cnt (ldata)) {
@@ -2520,7 +2520,7 @@ static int n_tty_ioctl(struct tty_structreturn put_user (tty_chars_in_buffer (tty), (int __user *) arg);case TIOCINQ :down_write (&tty->termios_rwsem); -if (L_ICANON (tty)) +if (L_ICANON (tty) && !L_EXTPROC (tty)) retval =inq_canon (ldata);else retval =read_cnt (ldata);
PATCH 138/254 iw_cxgb4: Only validate the MSN for successful completions
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Steve Wise <[email protected]>
commit f55688c45442bc863f40ad678c638785b26cdce6 upstream.
If the RECV CQE is in error, ignore the MSN check. This was causing recvs that were flushed into the sw cq to be completed with the wrong status (BAD_MSN instead of FLUSHED).
--- drivers/infiniband/hw/cxgb4/cq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/infiniband/hw/cxgb4/cq.c +3 -3
@@ -574,10 +574,10 @@ static int poll_cq(struct t4_wq *wq, str ret = -EAGAIN ; goto skip_cqe; } -if (unlikely ((CQE_WRID_MSN (hw_cqe) != (wq->rq.msn)))) { +if (unlikely (!CQE_STATUS (hw_cqe) && +CQE_WRID_MSN (hw_cqe) != wq->rq.msn)) {t4_set_wq_in_error (wq); - hw_cqe->header |=htonl (V_CQE_STATUS (T4_ERR_MSN )); - goto proc_cqe; + hw_cqe->header |=cpu_to_be32 (V_CQE_STATUS (T4_ERR_MSN )); } goto proc_cqe; }
PATCH 139/254 crypto: n2 - cure use after free
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jan Engelhardt <[email protected]>
commit 203f45003a3d03eea8fa28d74cfc74c354416fdb upstream.
queue_cache_init is first called for the Control Word Queue (n2_crypto_probe). At that time, queue_cache[0] is NULL and a new kmem_cache will be allocated. If the subsequent n2_register_algs call fails, the kmem_cache will be released in queue_cache_destroy, but queue_cache_init[0] is not set back to NULL.
So when the Module Arithmetic Unit gets probed next (n2_mau_probe), queue_cache_init will not allocate a kmem_cache again, but leave it as its bogus value, causing a BUG() to trigger when queue_cache[0] is eventually passed to kmem_cache_zalloc:
n2_crypto: Found N2CP at /virtual-devices@100/n2cp@7
n2_crypto: Registered NCS HVAPI version 2.0
called queue_cache_init
n2_crypto: md5 alg registration failed
n2cp f028687c: /virtual-devices@100/n2cp@7: Unable to register algorithms.
called queue_cache_destroy
n2cp: probe of f028687c failed with error -22
n2_crypto: Found NCP at /virtual-devices@100/ncp@6
n2_crypto: Registered NCS HVAPI version 2.0
called queue_cache_init
kernel BUG at mm/slab.c:2993!
Call Trace:
[0000000000604488] kmem_cache_alloc+0x1a8/0x1e0
(inlined) kmem_cache_zalloc
(inlined) new_queue
(inlined) spu_queue_setup
(inlined) handle_exec_unit
[0000000010c61eb4] spu_mdesc_scan+0x1f4/0x460 [n2_crypto]
[0000000010c62b80] n2_mau_probe+0x100/0x220 [n2_crypto]
[000000000084b174] platform_drv_probe+0x34/0xc0--- drivers/crypto/n2_core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/crypto/n2_core.c +3 -0
@@ -1644,6 +1644,7 @@ static int queue_cache_init(void) CWQ_ENTRY_SIZE, 0, NULL);if (!queue_cache[HV_NCS_QTYPE_CWQ -1 ]) {kmem_cache_destroy (queue_cache[HV_NCS_QTYPE_MAU -1 ]); + queue_cache[HV_NCS_QTYPE_MAU -1 ] =NULL ;return -ENOMEM ; }return 0 ;
@@ -1653,6 +1654,8 @@ static void queue_cache_destroy(void) {kmem_cache_destroy (queue_cache[HV_NCS_QTYPE_MAU -1 ]);kmem_cache_destroy (queue_cache[HV_NCS_QTYPE_CWQ -1 ]); + queue_cache[HV_NCS_QTYPE_MAU -1 ] =NULL ; + queue_cache[HV_NCS_QTYPE_CWQ -1 ] =NULL ; }static int spu_queue_register (struct spu_queue *p,unsigned long q_type)
PATCH 140/254 ALSA: hda - Add MIC_NO_PRESENCE fixup for 2 HP machines
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hui Wang <[email protected]>
commit 322f74ede933b3e2cb78768b6a6fdbfbf478a0c1 upstream.
There is a headset jack on the front panel, when we plug a headset into it, the headset mic can't trigger unsol events, and read_pin_sense() can't detect its presence too. So add this fixup to fix this issue.
--- sound/pci/hda/patch_conexant.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
sound/pci/hda/patch_conexant.c +29 -0
@@ -2845,6 +2845,8 @@ enum {CXT_FIXUP_MUTE_LED_EAPD ,CXT_FIXUP_HP_SPECTRE ,CXT_FIXUP_HP_GATE_MIC , +CXT_FIXUP_HEADSET_MIC , + CXT_FIXUP_HP_MIC_NO_PRESENCE, };/* for hda_fixup_thinkpad_acpi() */
@@ -2923,6 +2925,18 @@ static void cxt_fixup_headphone_mic(stru } } +static void cxt_fixup_headset_mic (struct hda_codec *codec, +const struct hda_fixup *fix,int action) +{ +struct conexant_spec *spec = codec->spec; + +switch (action) { +case HDA_FIXUP_ACT_PRE_PROBE : + spec->parse_flags |=HDA_PINCFG_HEADSET_MIC ; +break ; + } +} +/* OPLC XO 1.5 fixup */ /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors)
@@ -3374,6 +3388,19 @@ static const struct hda_fixup cxt_fixups .type = HDA_FIXUP_FUNC, .v.func = cxt_fixup_hp_gate_mic_jack, }, + [CXT_FIXUP_HEADSET_MIC] = { + .type = HDA_FIXUP_FUNC, + .v.func = cxt_fixup_headset_mic, + }, + [CXT_FIXUP_HP_MIC_NO_PRESENCE] = { + .type = HDA_FIXUP_PINS, + .v.pins = (const struct hda_pintbl []) { + {0x1a ,0x02a1113c }, + { } + }, + .chained = true, + .chain_id = CXT_FIXUP_HEADSET_MIC, + }, };static const struct snd_pci_quirk cxt5045_fixups[] = {
@@ -3425,6 +3452,8 @@ static const struct snd_pci_quirk cxt506SND_PCI_QUIRK (0x1025 ,0x054f ,"Acer Aspire 4830T" ,CXT_FIXUP_ASPIRE_DMIC ),SND_PCI_QUIRK (0x103c ,0x8174 ,"HP Spectre x360" ,CXT_FIXUP_HP_SPECTRE ),SND_PCI_QUIRK (0x103c ,0x8115 ,"HP Z1 Gen3" ,CXT_FIXUP_HP_GATE_MIC ), +SND_PCI_QUIRK (0x103c ,0x8299 ,"HP 800 G3 SFF" ,CXT_FIXUP_HP_MIC_NO_PRESENCE ), +SND_PCI_QUIRK (0x103c ,0x829a ,"HP 800 G3 DM" ,CXT_FIXUP_HP_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1043 ,0x138d ,"Asus" ,CXT_FIXUP_HEADPHONE_MIC_PIN ),SND_PCI_QUIRK (0x152d ,0x0833 ,"OLPC XO-1.5" ,CXT_FIXUP_OLPC_XO ), SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410),
PATCH 141/254 USB: serial: ftdi_sio: add id for Airbus DS P8GR
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Max Schulze <[email protected]>
commit c6a36ad383559a60a249aa6016cebf3cb8b6c485 upstream.
Add AIRBUS_DS_P8GR device IDs to ftdi_sio driver.
--- drivers/usb/serial/ftdi_sio.c | 1 + drivers/usb/serial/ftdi_sio_ids.h | 6 ++++++ 2 files changed, 7 insertions(+)
drivers/usb/serial/ftdi_sio.c +1 -0
@@ -1030,6 +1030,7 @@ static const struct usb_device_id id_tab .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, { USB_DEVICE(CYPRESS_VID, CYPRESS_WICED_BT_USB_PID) }, { USB_DEVICE(CYPRESS_VID, CYPRESS_WICED_WL_USB_PID) }, + { USB_DEVICE(AIRBUS_DS_VID, AIRBUS_DS_P8GR) }, { } /* Terminating entry */ };
drivers/usb/serial/ftdi_sio_ids.h +6 -0
@@ -914,6 +914,12 @@#define ICPDAS_I7563U_PID 0x0105/* +* Airbus Defence and Space +*/ +#define AIRBUS_DS_VID 0x1e8e/* Vendor ID */ +#define AIRBUS_DS_P8GR 0x6001/* Tetra P8GR */ + +/* * RT Systems programming cables for various ham radios */ #define RTSYSTEMS_VID 0x2100/* Vendor ID */
PATCH 142/254 usb: xhci: Add XHCI_TRUST_TX_LENGTH for Renesas uPD720201
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Thompson <[email protected]>
commit da99706689481717998d1d48edd389f339eea979 upstream.
When plugging in a USB webcam I see the following message:xhci_hcd 0000:04:00.0: WARN Successful completion on short TX: needs XHCI_TRUST_TX_LENGTH quirk?handle_tx_event: 913 callbacks suppressed
All is quiet again with this patch (and I've done a fair but of soak testing with the camera since).
--- drivers/usb/host/xhci-pci.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/host/xhci-pci.c +3 -0
@@ -183,6 +183,9 @@ static void xhci_pci_quirks(struct devic xhci->quirks |=XHCI_BROKEN_STREAMS ; }if (pdev->vendor ==PCI_VENDOR_ID_RENESAS && + pdev->device ==0x0014 ) + xhci->quirks |=XHCI_TRUST_TX_LENGTH ; +if (pdev->vendor ==PCI_VENDOR_ID_RENESAS && pdev->device ==0x0015 ) xhci->quirks |=XHCI_RESET_ON_RESUME ;if (pdev->vendor ==PCI_VENDOR_ID_VIA )
PATCH 143/254 sctp: Replace use of sockets_allocated with specified macro.
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Tonghao Zhang <[email protected]>
commit 8cb38a602478e9f806571f6920b0a3298aabf042 upstream.
The patch(180d8cd942ce) replaces all uses of struct sock fields' memory_pressure, memory_allocated, sockets_allocated, and sysctl_mem to accessor macros. But the sockets_allocated field of sctp sock is not replaced at all. Then replace it now for unifying the code.
--- net/sctp/socket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/sctp/socket.c +2 -2
@@ -4021,7 +4021,7 @@ static int sctp_init_sock(struct sock *sSCTP_DBG_OBJCNT_INC (sock);local_bh_disable (); -percpu_counter_inc (&sctp_sockets_allocated); +sk_sockets_allocated_inc (sk);sock_prot_inuse_add (net, sk->sk_prot,1 );/* Nothing can fail after this block, otherwise
@@ -4065,7 +4065,7 @@ static void sctp_destroy_sock(struct soc }sctp_endpoint_free (sp->ep);local_bh_disable (); -percpu_counter_dec (&sctp_sockets_allocated); +sk_sockets_allocated_dec (sk);sock_prot_inuse_add (sock_net (sk), sk->sk_prot,-1 );local_bh_enable (); }
PATCH 144/254 ring-buffer: Mask out the info bits when returning buffer page length
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Steven Rostedt (VMware)" <[email protected]>
commit 45d8b80c2ac5d21cd1e2954431fb676bc2b1e099 upstream.
Two info bits were added to the "commit" part of the ring buffer data page when returned to be consumed. This was to inform the user space readers that events have been missed, and that the count may be stored at the end of the page.
What wasn't handled, was the splice code that actually called a function to return the length of the data in order to zero out the rest of the page before sending it up to user space. These data bits were returned with the length making the value negative, and that negative value was not checked. It was compared to PAGE_SIZE, and only used if the size was less than PAGE_SIZE. Luckily PAGE_SIZE is unsigned long which made the compare an unsigned compare, meaning the negative size value did not end up causing a large portion of memory to be randomly zeroed out.
--- kernel/trace/ring_buffer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
kernel/trace/ring_buffer.c +5 -1
@@ -336,6 +336,8 @@ EXPORT_SYMBOL_GPL(ring_buffer_event_data/* Missed count stored at end */ #define RB_MISSED_STORED (1 << 30) +#define RB_MISSED_FLAGS (RB_MISSED_EVENTS|RB_MISSED_STORED) +struct buffer_data_page {u64 time_stamp;/* page time stamp */ local_t commit;/* write committed index */
@@ -387,7 +389,9 @@ static void rb_init_page(struct buffer_d*/ size_t ring_buffer_page_len (void *page) { -return local_read (&((struct buffer_data_page *)page)->commit) +struct buffer_data_page *bpage = page; + +return (local_read (&bpage->commit) & ~RB_MISSED_FLAGS ) +BUF_PAGE_HDR_SIZE ; }
PATCH 145/254 tracing: Fix crash when it fails to alloc ring buffer
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jing Xia <[email protected]>
commit 24f2aaf952ee0b59f31c3a18b8b36c9e3d3c2cf5 upstream.
Double free of the ring buffer happens when it fails to alloc new ring buffer instance for max_buffer if TRACER_MAX_TRACE is configured. The root cause is that the pointer is not set to NULL after the buffer is freed in allocate_trace_buffers(), and the freeing of the ring buffer is invoked again later if the pointer is not equal to Null, as:
instance_mkdir()
|-allocate_trace_buffers()
|-allocate_trace_buffer(tr, &tr->trace_buffer...)
|-allocate_trace_buffer(tr, &tr->max_buffer...)
// allocate fail(-ENOMEM),first free
// and the buffer pointer is not set to null
|-ring_buffer_free(tr->trace_buffer.buffer)
// out_free_tr
|-free_trace_buffers()
|-free_trace_buffer(&tr->trace_buffer);
//if trace_buffer is not null, free again
|-ring_buffer_free(buf->buffer)
|-rb_free_cpu_buffer(buffer->buffers[cpu])
// ring_buffer_per_cpu is null, and
// crash in ring_buffer_per_cpu->pages--- kernel/trace/trace.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/trace/trace.c +2 -0
@@ -6243,7 +6243,9 @@ static int allocate_trace_buffers(struct allocate_snapshot ? size : 1);if (WARN_ON (ret)) {ring_buffer_free (tr->trace_buffer.buffer); + tr->trace_buffer.buffer =NULL ;free_percpu (tr->trace_buffer.data); + tr->trace_buffer.data =NULL ;return -ENOMEM ; } tr->allocated_snapshot = allocate_snapshot;
PATCH 146/254 tracing: Fix possible double free on failure of allocating trace buffer
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Steven Rostedt (VMware)" <[email protected]>
commit 4397f04575c44e1440ec2e49b6302785c95fd2f8 upstream.
Jing Xia and Chunyan Zhang reported that on failing to allocate part of the tracing buffer, memory is freed, but the pointers that point to them are not initialized back to NULL, and later paths may try to free the freed memory again. Jing and Chunyan fixed one of the locations that does this, but missed a spot.
--- kernel/trace/trace.c | 1 + 1 file changed, 1 insertion(+)
kernel/trace/trace.c +1 -0
@@ -6220,6 +6220,7 @@ allocate_trace_buffer(struct trace_array buf->data = alloc_percpu(struct trace_array_cpu);if (!buf->data) {ring_buffer_free (buf->buffer); + buf->buffer =NULL ;return -ENOMEM ; }
PATCH 147/254 nohz: Prevent a timer interrupt storm in tick_nohz_stop_sched_tick()
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 5d62c183f9e9df1deeea0906d099a94e8a43047a upstream.
The conditions in irq_exit() to invoke tick_nohz_irq_exit() which subsequently invokes tick_nohz_stop_sched_tick() are:
if ((idle_cpu(cpu) && !need_resched()) || tick_nohz_full_cpu(cpu))
If need_resched() is not set, but a timer softirq is pending then this is an indication that the softirq code punted and delegated the execution to softirqd. need_resched() is not true because the current interrupted task takes precedence over softirqd.
Invoking tick_nohz_irq_exit() in this case can cause an endless loop of timer interrupts because the timer wheel contains an expired timer, but softirqs are not yet executed. So it returns an immediate expiry request, which causes the timer to fire immediately again. Lather, rinse and repeat....
Prevent that by adding a check for a pending timer soft interrupt to the conditions in tick_nohz_stop_sched_tick() which avoid calling get_next_timer_interrupt(). That keeps the tick sched timer on the tick and prevents a repetitive programming of an already expired timer.
--- kernel/time/tick-sched.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
kernel/time/tick-sched.c +17 -2
@@ -527,6 +527,11 @@ u64 get_cpu_iowait_time_us(int cpu, u64 }EXPORT_SYMBOL_GPL (get_cpu_iowait_time_us); +static inline bool local_timer_softirq_pending (void ) +{ +return local_softirq_pending () &TIMER_SOFTIRQ ; +} +static ktime_t tick_nohz_stop_sched_tick (struct tick_sched *ts,ktime_t now,int cpu) {
@@ -545,8 +550,18 @@ static ktime_t tick_nohz_stop_sched_tick last_jiffies = jiffies; }while (read_seqretry (&jiffies_lock, seq)); -if (rcu_needs_cpu (cpu, &rcu_delta_jiffies) || -arch_needs_cpu (cpu) ||irq_work_needs_cpu ()) { +/* +* Keep the periodic tick, when RCU, architecture or irq_work +* requests it. +* Aside of that check whether the local timer softirq is +* pending. If so its a bad idea to call get_next_timer_interrupt() +* because there is an already expired timer, so it will request +* immeditate expiry, which rearms the hardware timer with a +* minimal delta which brings us back to this place +* immediately. Lather, rinse and repeat... +*/ +if (rcu_needs_cpu (cpu, &rcu_delta_jiffies) ||arch_needs_cpu (cpu) || +irq_work_needs_cpu () ||local_timer_softirq_pending ()) { next_jiffies = last_jiffies +1 ; delta_jiffies =1 ; }else {
PATCH 148/254 include/stddef.h: Move offsetofend() from vfio.h to a generic kernel header
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Denys Vlasenko <[email protected]>
commit 3876488444e71238e287459c39d7692b6f718c3e upstream.
Suggested by Andy.
--- include/linux/stddef.h | 9 +++++++++ include/linux/vfio.h | 13 ------------- 2 files changed, 9 insertions(+), 13 deletions(-)
include/linux/stddef.h +9 -0
@@ -19,3 +19,12 @@ enum {#define offsetof (TYPE ,MEMBER ) ((size_t) &((TYPE *)0)->MEMBER)#endif #endif + +/** +* offsetofend(TYPE, MEMBER) +* +* @TYPE: The type of the structure +* @MEMBER: The member within the structure to get the end offset of +*/ +#define offsetofend (TYPE ,MEMBER ) \ + (offsetof(TYPE, MEMBER) + sizeof(((TYPE *)0)->MEMBER))
include/linux/vfio.h +0 -13
@@ -76,19 +76,6 @@ extern int vfio_register_iommu_driver(coextern void vfio_unregister_iommu_driver (const struct vfio_iommu_driver_ops *ops); -/** -* offsetofend(TYPE, MEMBER) -* -* @TYPE: The type of the structure -* @MEMBER: The member within the structure to get the end offset of -* -* Simple helper macro for dealing with variable sized structures passed -* from user space. This allows us to easily determine if the provided -* structure is sized to include various fields. -*/ -#define offsetofend (TYPE ,MEMBER ) \ - (offsetof(TYPE, MEMBER) + sizeof(((TYPE *)0)->MEMBER)) -/* * External user API */
PATCH 149/254 stddef.h: move offsetofend inside #ifndef/#endif guard, neaten
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Joe Perches <[email protected]>
commit 8c7fbe5795a016259445a61e072eb0118aaf6a61 upstream.
Commit 3876488444e7 ("include/stddef.h: Move offsetofend() from vfio.h to a generic kernel header") added offsetofend outside the normal include #ifndef/#endif guard. Move it inside.
Miscellanea:
o remove unnecessary blank line
o standardize offsetof macros whitespace style
--- include/linux/stddef.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
include/linux/stddef.h +4 -4
@@ -3,7 +3,6 @@#include <uapi/linux/stddef.h> -#undef NULL#define NULL ((void *)0)
@@ -14,10 +13,9 @@ enum {#undef offsetof#ifdef __compiler_offsetof -#define offsetof (TYPE ,MEMBER ) __compiler_offsetof(TYPE,MEMBER) +#define offsetof (TYPE ,MEMBER ) __compiler_offsetof(TYPE, MEMBER)#else -#define offsetof (TYPE ,MEMBER ) ((size_t) &((TYPE *)0)->MEMBER) -#endif +#define offsetof (TYPE ,MEMBER ) ((size_t)&((TYPE *)0)->MEMBER)#endif /**
@@ -28,3 +26,5 @@ enum {*/ #define offsetofend (TYPE ,MEMBER ) \ (offsetof(TYPE, MEMBER) + sizeof(((TYPE *)0)->MEMBER)) + +#endif
PATCH 150/254 af_key: fix buffer overread in verify_address_len()
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 06b335cb51af018d5feeff5dd4fd53847ddb675a upstream.
If a message sent to a PF_KEY socket ended with one of the extensions that takes a 'struct sadb_address' but there were not enough bytes remaining in the message for the ->sa_family member of the 'struct sockaddr' which is supposed to follow, then verify_address_len() read past the end of the message, into uninitialized memory. Fix it by returning -EINVAL in this case.
This bug was found using syzkaller with KMSAN.
Reproducer:
#include <linux/pfkeyv2.h>
#include <sys/socket.h>
#include <unistd.h>
int main()
{
int sock = socket(PF_KEY, SOCK_RAW, PF_KEY_V2);
char buf[24] = { 0 };
struct sadb_msg *msg = (void *)buf;
struct sadb_address *addr = (void *)(msg + 1);
msg->sadb_msg_version = PF_KEY_V2;
msg->sadb_msg_type = SADB_DELETE;
msg->sadb_msg_len = 3;
addr->sadb_address_len = 1;
addr->sadb_address_exttype = SADB_EXT_ADDRESS_SRC;
write(sock, buf, 24);
}--- net/key/af_key.c | 5 +++++ 1 file changed, 5 insertions(+)
net/key/af_key.c +5 -0
@@ -397,6 +397,11 @@ static int verify_address_len(const void#endif int len; +if (sp->sadb_address_len < +DIV_ROUND_UP (sizeof (*sp) +offsetofend (typeof (*addr), sa_family), +sizeof (uint64_t ))) +return -EINVAL ; +switch (addr->sa_family) {case AF_INET : len =DIV_ROUND_UP (sizeof (*sp) +sizeof (*sin),sizeof (uint64_t ));
PATCH 151/254 af_key: fix buffer overread in parse_exthdrs()
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 4e765b4972af7b07adcb1feb16e7a525ce1f6b28 upstream.
If a message sent to a PF_KEY socket ended with an incomplete extension header (fewer than 4 bytes remaining), then parse_exthdrs() read past the end of the message, into uninitialized memory. Fix it by returning -EINVAL in this case.
Reproducer:
#include <linux/pfkeyv2.h>
#include <sys/socket.h>
#include <unistd.h>
int main()
{
int sock = socket(PF_KEY, SOCK_RAW, PF_KEY_V2);
char buf[17] = { 0 };
struct sadb_msg *msg = (void *)buf;
msg->sadb_msg_version = PF_KEY_V2;
msg->sadb_msg_type = SADB_DELETE;
msg->sadb_msg_len = 2;
write(sock, buf, 17);
}--- net/key/af_key.c | 3 +++ 1 file changed, 3 insertions(+)
net/key/af_key.c +3 -0
@@ -513,6 +513,9 @@ static int parse_exthdrs(struct sk_buffuint16_t ext_type;int ext_len; +if (len <sizeof (*ehdr)) +return -EINVAL ; + ext_len = ehdr->sadb_ext_len; ext_len *=sizeof (uint64_t ); ext_type = ehdr->sadb_ext_type;
PATCH 152/254 kbuild: add '-fno-stack-check' to kernel build options
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <[email protected]>
commit 3ce120b16cc548472f80cf8644f90eda958cf1b6 upstream.
It appears that hardened gentoo enables "-fstack-check" by default for gcc.
That doesn't work _at_all_ for the kernel, because the kernel stack doesn't act like a user stack at all: it's much smaller, and it doesn't auto-expand on use. So the extra "probe one page below the stack" code generated by -fstack-check just breaks the kernel in horrible ways, causing infinite double faults etc.
[ I have to say, that the particular code gcc generates looks very
stupid even for user space where it works, but that's a separate issue. ]
--- Makefile | 3 +++ 1 file changed, 3 insertions(+)
Makefile +3 -0
@@ -736,6 +736,9 @@ KBUILD_CFLAGS += $(call cc-disable-warni # disable invalid "can't wrap" optimizations for signed / pointers KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow) +# Make sure -fstack-check isn't enabled (like gentoo apparently did) +KBUILD_CFLAGS += $(call cc-option,-fno-stack-check,) + # conserve stack if available KBUILD_CFLAGS += $(call cc-option,-fconserve-stack)
PATCH 153/254 USB: serial: cp210x: add IDs for LifeScan OneTouch Verio IQ
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Diego Elio Pettenò <[email protected]>
commit 4307413256ac1e09b8f53e8715af3df9e49beec3 upstream.
Add IDs for the OneTouch Verio IQ that comes with an embedded USB-to-serial converter.
--- drivers/usb/serial/cp210x.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/serial/cp210x.c +1 -0
@@ -120,6 +120,7 @@ static const struct usb_device_id id_tab { USB_DEVICE(0x10C4, 0x8470) }, /* Juniper Networks BX Series System Console */ { USB_DEVICE(0x10C4, 0x8477) }, /* Balluff RFID */ { USB_DEVICE(0x10C4, 0x84B6) }, /* Starizona Hyperion */ + { USB_DEVICE(0x10C4, 0x85A7) }, /* LifeScan OneTouch Verio IQ */ { USB_DEVICE(0x10C4, 0x85EA) }, /* AC-Services IBUS-IF */ { USB_DEVICE(0x10C4, 0x85EB) }, /* AC-Services CIS-IBUS */ { USB_DEVICE(0x10C4, 0x85F8) }, /* Virtenio Preon32 */
PATCH 154/254 fscache: Fix the default for fscache_maybe_release_page()
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
commit 98801506552593c9b8ac11021b0cdad12cab4f6b upstream.
Fix the default for fscache_maybe_release_page() for when the cookie isn't valid or the page isn't cached. It mustn't return false as that indicates the page cannot yet be freed.
The problem with the default is that if, say, there's no cache, but a network filesystem's pages are using up almost all the available memory, a system can OOM because the filesystem ->releasepage() op will not allow them to be released as fscache_maybe_release_page() incorrectly prevents it.
This can be tested by writing a sequence of 512MiB files to an AFS mount. It does not affect NFS or CIFS because both of those wrap the call in a check of PG_fscache and it shouldn't bother Ceph as that only has PG_private set whilst writeback is in progress. This might be an issue for 9P, however.
Note that the pages aren't entirely stuck. Removing a file or unmounting will clear things because that uses ->invalidatepage() instead.
--- include/linux/fscache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/fscache.h +1 -1
@@ -764,7 +764,7 @@ bool fscache_maybe_release_page(struct f {if (fscache_cookie_valid (cookie) &&PageFsCache (page))return __fscache_maybe_release_page (cookie, page, gfp); -return false; +return true; }/**
PATCH 155/254 ALSA: pcm: Remove incorrect snd_BUG_ON() usages
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit fe08f34d066f4404934a509b6806db1a4f700c86 upstream.
syzkaller triggered kernel warnings through PCM OSS emulation at closing a stream:
WARNING: CPU: 0 PID: 3502 at sound/core/pcm_lib.c:1635 snd_pcm_hw_param_first+0x289/0x690 sound/core/pcm_lib.c:1635 Call Trace: .... snd_pcm_hw_param_near.constprop.27+0x78d/0x9a0 sound/core/oss/pcm_oss.c:457 snd_pcm_oss_change_params+0x17d3/0x3720 sound/core/oss/pcm_oss.c:969 snd_pcm_oss_make_ready+0xaa/0x130 sound/core/oss/pcm_oss.c:1128 snd_pcm_oss_sync+0x257/0x830 sound/core/oss/pcm_oss.c:1638 snd_pcm_oss_release+0x20b/0x280 sound/core/oss/pcm_oss.c:2431 __fput+0x327/0x7e0 fs/file_table.c:210 ....
This happens while it tries to open and set up the aloop device concurrently. The warning above (invoked from snd_BUG_ON() macro) is to detect the unexpected logical error where snd_pcm_hw_refine() call shouldn't fail. The theory is true for the case where the hw_params config rules are static. But for an aloop device, the hw_params rule condition does vary dynamically depending on the connected target; when another device is opened and changes the parameters, the device connected in another side is also affected, and it caused the error from snd_pcm_hw_refine().
That is, the simplest "solution" for this is to remove the incorrect assumption of static rules, and treat such an error as a normal error path. As there are a couple of other places using snd_BUG_ON() incorrectly, this patch removes these spurious snd_BUG_ON() calls.
--- sound/core/oss/pcm_oss.c | 1 - sound/core/pcm_lib.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-)
sound/core/oss/pcm_oss.c +0 -1
@@ -465,7 +465,6 @@ static int snd_pcm_hw_param_near(struct v =snd_pcm_hw_param_last (pcm, params, var, dir); else v =snd_pcm_hw_param_first (pcm, params, var, dir); -snd_BUG_ON (v <0 );return v; }
sound/core/pcm_lib.c +2 -2
@@ -1631,7 +1631,7 @@ int snd_pcm_hw_param_first(struct snd_pcreturn changed;if (params->rmask) {int err =snd_pcm_hw_refine (pcm, params); -if (snd_BUG_ON (err <0 )) +if (err <0 )return err; }return snd_pcm_hw_param_value (params, var, dir);
@@ -1678,7 +1678,7 @@ int snd_pcm_hw_param_last(struct snd_pcmreturn changed;if (params->rmask) {int err =snd_pcm_hw_refine (pcm, params); -if (snd_BUG_ON (err <0 )) +if (err <0 )return err; }return snd_pcm_hw_param_value (params, var, dir);
PATCH 156/254 IB/ipoib: Fix race condition in neigh creation
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Erez Shitrit <[email protected]>
commit 16ba3defb8bd01a9464ba4820a487f5b196b455b upstream.
When using enhanced mode for IPoIB, two threads may execute xmit in parallel to two different TX queues while the target is the same. In this case, both of them will add the same neighbor to the path's neigh link list and we might see the following message:
list_add double add: new=ffff88024767a348, prev=ffff88024767a348...
WARNING: lib/list_debug.c:31__list_add_valid+0x4e/0x70 ipoib_start_xmit+0x477/0x680 [ib_ipoib] dev_hard_start_xmit+0xb9/0x3e0 sch_direct_xmit+0xf9/0x250 __qdisc_run+0x176/0x5d0 __dev_queue_xmit+0x1f5/0xb10 __dev_queue_xmit+0x55/0xb10
Analysis:
Two SKB are scheduled to be transmitted from two cores.
In ipoib_start_xmit, both gets NULL when calling ipoib_neigh_get. Two calls to neigh_add_path are made. One thread takes the spin-lock and calls ipoib_neigh_alloc which creates the neigh structure, then (after the __path_find) the neigh is added to the path's neigh link list. When the second thread enters the critical section it also calls ipoib_neigh_alloc but in this case it gets the already allocated ipoib_neigh structure, which is already linked to the path's neigh link list and adds it again to the list. Which beside of triggering the list, it creates a loop in the linked list. This loop leads to endless loop inside path_rec_completion.
Solution:
Check list_empty(&neigh->list) before adding to the list. Add a similar fix in "ipoib_multicast.c::ipoib_mcast_send"
--- drivers/infiniband/ulp/ipoib/ipoib_main.c | 25 ++++++++++++++++++------- drivers/infiniband/ulp/ipoib/ipoib_multicast.c | 5 ++++- 2 files changed, 22 insertions(+), 8 deletions(-)
drivers/infiniband/ulp/ipoib/ipoib_main.c +18 -7
@@ -615,8 +615,8 @@ static int path_rec_start(struct net_devreturn 0 ; } -static void neigh_add_path (struct sk_buff *skb,u8 *daddr, -struct net_device *dev) +static struct ipoib_neigh *neigh_add_path (struct sk_buff *skb,u8 *daddr, +struct net_device *dev) {struct ipoib_dev_priv *priv =netdev_priv (dev);struct ipoib_path *path;
@@ -629,7 +629,15 @@ static void neigh_add_path(struct sk_bufspin_unlock_irqrestore (&priv->lock, flags); ++dev->stats.tx_dropped;dev_kfree_skb_any (skb); -return ; +return NULL ; + } + +/* To avoid race condition, make sure that the +* neigh will be added only once. +*/ +if (unlikely (!list_empty (&neigh->list))) { +spin_unlock_irqrestore (&priv->lock, flags); +return neigh; } path =__path_find (dev, daddr +4 );
@@ -665,7 +673,7 @@ static void neigh_add_path(struct sk_bufspin_unlock_irqrestore (&priv->lock, flags);ipoib_send (dev, skb, path->ah,IPOIB_QPN (daddr));ipoib_neigh_put (neigh); -return ; +return NULL ; } }else { neigh->ah =NULL ;
@@ -678,7 +686,7 @@ static void neigh_add_path(struct sk_bufspin_unlock_irqrestore (&priv->lock, flags);ipoib_neigh_put (neigh); -return ; +return NULL ; err_path:ipoib_neigh_free (neigh);
@@ -688,6 +696,8 @@ err_drop:spin_unlock_irqrestore (&priv->lock, flags);ipoib_neigh_put (neigh); + +return NULL ; } static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev,
@@ -784,8 +794,9 @@ static int ipoib_start_xmit(struct sk_bucase htons (ETH_P_TIPC ): neigh =ipoib_neigh_get (dev, cb->hwaddr);if (unlikely (!neigh)) { -neigh_add_path (skb, cb->hwaddr, dev); -return NETDEV_TX_OK ; + neigh =neigh_add_path (skb, cb->hwaddr, dev); +if (likely (!neigh)) +return NETDEV_TX_OK ; }break ;case htons (ETH_P_ARP ):
drivers/infiniband/ulp/ipoib/ipoib_multicast.c +4 -1
@@ -728,7 +728,10 @@ out:spin_lock_irqsave (&priv->lock, flags);if (!neigh) { neigh =ipoib_neigh_alloc (daddr, dev); -if (neigh) { +/* Make sure that the neigh will be added only +* once to mcast list. +*/ +if (neigh &&list_empty (&neigh->list)) {kref_get (&mcast->ah->ref); neigh->ah = mcast->ah;list_add_tail (&neigh->list, &mcast->neigh_list);
PATCH 157/254 e1000e: Separate signaling for link check/link up
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Poirier <[email protected]>
commit 19110cfbb34d4af0cdfe14cd243f3b09dc95b013 upstream.
Lennart reported the following race condition:
\ e1000_watchdog_task
\ e1000e_has_link
\ hw->mac.ops.check_for_link() === e1000e_check_for_copper_link
/* link is up */
mac->get_link_status = false;
/* interrupt */
\ e1000_msix_other
hw->mac.get_link_status = true;
link_active = !hw->mac.get_link_status
/* link_active is false, wrongly */This problem arises because the single flag get_link_status is used to signal two different states: link status needs checking and link status is down.
Avoid the problem by using the return value of .check_for_link to signal the link status to e1000e_has_link().
--- drivers/net/ethernet/intel/e1000e/mac.c | 11 ++++++++--- drivers/net/ethernet/intel/e1000e/netdev.c | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/e1000e/mac.c +8 -3
@@ -410,6 +410,9 @@ void e1000e_clear_hw_cntrs_base(struct e* Checks to see of the link status of the hardware has changed. If a * change in link status has been detected, then we read the PHY registers * to get the current speed/duplex if link exists. +* +* Returns a negative error code (-E1000_ERR_*) or 0 (link down) or 1 (link +* up). **/ s32 e1000e_check_for_copper_link (struct e1000_hw *hw) {
@@ -423,7 +426,7 @@ s32 e1000e_check_for_copper_link(struct* Change or Rx Sequence Error interrupt. */ if (!mac->get_link_status) -return 0 ; +return 1 ;/* First we want to see if the MII Status Register reports * link. If so, then we want to get the current speed/duplex
@@ -461,10 +464,12 @@ s32 e1000e_check_for_copper_link(struct* different link partner. */ ret_val =e1000e_config_fc_after_link_up (hw); -if (ret_val) +if (ret_val) {e_dbg ("Error configuring flow control\n" ); +return ret_val; + } -return ret_val; +return 1 ; }/**
drivers/net/ethernet/intel/e1000e/netdev.c +1 -1
@@ -4844,7 +4844,7 @@ static bool e1000e_has_link(struct e1000case e1000_media_type_copper:if (hw->mac.get_link_status) { ret_val = hw->mac.ops.check_for_link (hw); - link_active = !hw->mac.get_link_status; + link_active = ret_val >0 ; }else { link_active = true; }
PATCH 158/254 e1000e: Fix e1000_check_for_copper_link_ich8lan return value.
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Poirier <[email protected]>
commit 4110e02eb45ea447ec6f5459c9934de0a273fb91 upstream.
e1000e_check_for_copper_link() and e1000_check_for_copper_link_ich8lan() are the two functions that may be assigned to mac.ops.check_for_link when phy.media_type == e1000_media_type_copper. Commit 19110cfbb34d ("e1000e:
Separate signaling for link check/link up") changed the meaning of the return value of check_for_link for copper media but only adjusted the first function. This patch adjusts the second function likewise.
--- drivers/net/ethernet/intel/e1000e/ich8lan.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/e1000e/ich8lan.c +8 -3
@@ -1300,6 +1300,9 @@ out:* Checks to see of the link status of the hardware has changed. If a * change in link status has been detected, then we read the PHY registers * to get the current speed/duplex if link exists. +* +* Returns a negative error code (-E1000_ERR_*) or 0 (link down) or 1 (link +* up). **/ static s32 e1000_check_for_copper_link_ich8lan (struct e1000_hw *hw) {
@@ -1314,7 +1317,7 @@ static s32 e1000_check_for_copper_link_i* Change or Rx Sequence Error interrupt. */ if (!mac->get_link_status) -return 0 ; +return 1 ;/* First we want to see if the MII Status Register reports * link. If so, then we want to get the current speed/duplex
@@ -1453,10 +1456,12 @@ static s32 e1000_check_for_copper_link_i* different link partner. */ ret_val =e1000e_config_fc_after_link_up (hw); -if (ret_val) +if (ret_val) {e_dbg ("Error configuring flow control\n" ); +return ret_val; + } -return ret_val; +return 1 ; }static s32 e1000_get_variants_ich8lan (struct e1000_adapter *adapter)
PATCH 159/254 IB/srpt: Disable RDMA access by the initiator
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
commit bec40c26041de61162f7be9d2ce548c756ce0f65 upstream.
With the SRP protocol all RDMA operations are initiated by the target. Since no RDMA operations are initiated by the initiator, do not grant the initiator permission to submit RDMA reads or writes to the target.
--- drivers/infiniband/ulp/srpt/ib_srpt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/ulp/srpt/ib_srpt.c +1 -2
@@ -958,8 +958,7 @@ static int srpt_init_ch_qp(struct srpt_rreturn -ENOMEM ; attr->qp_state =IB_QPS_INIT ; - attr->qp_access_flags =IB_ACCESS_LOCAL_WRITE |IB_ACCESS_REMOTE_READ | -IB_ACCESS_REMOTE_WRITE ; + attr->qp_access_flags =IB_ACCESS_LOCAL_WRITE ; attr->port_num = ch->sport->port; attr->pkey_index =0 ;
PATCH 160/254 mmc: s3mci: mark debug_regs[] as static
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit 2bd7b4aacdb6efa5ccd4749c365c171b884791d2 upstream.
The global array clashes with a newly added symbol of the same name:
drivers/staging/ccree/cc_debugfs.o:(.data+0x0): multiple definition of `debug_regs' drivers/mmc/host/s3cmci.o:(.data+0x70): first defined here
We should fix both, this one addresses the s3cmci driver by removing the symbol from the global namespace. While at it, this separates the declaration from the type definition and makes the variable const.
--- drivers/mmc/host/s3cmci.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mmc/host/s3cmci.c +4 -2
@@ -1537,7 +1537,9 @@ static const struct file_operations s3cmstruct s3cmci_reg {unsigned short addr;unsigned char *name; -} debug_regs[] = { +}; + +static const struct s3cmci_reg debug_regs[] = {DBG_REG (CON ),DBG_REG (PRE ),DBG_REG (CMDARG ),
@@ -1559,7 +1561,7 @@ struct s3cmci_reg {static int s3cmci_regs_show (struct seq_file *seq,void *v) {struct s3cmci_host *host = seq->private; -struct s3cmci_reg *rptr = debug_regs; +const struct s3cmci_reg *rptr = debug_regs;for (; rptr->name; rptr++) seq_printf(seq, "SDI%s\t=0x%08x\n", rptr->name,
PATCH 161/254 USB: serial: cp210x: add new device ID ELV ALC 8xxx
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Christian Holl <[email protected]>
commit d14ac576d10f865970bb1324d337e5e24d79aaf4 upstream.
This adds the ELV ALC 8xxx Battery Charging device to the list of USB IDs of drivers/usb/serial/cp210x.c
--- drivers/usb/serial/cp210x.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/serial/cp210x.c +1 -0
@@ -171,6 +171,7 @@ static const struct usb_device_id id_tab { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */ { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */ { USB_DEVICE(0x18EF, 0xE025) }, /* ELV Marble Sound Board 1 */ + { USB_DEVICE(0x18EF, 0xE030) }, /* ELV ALC 8xxx Battery Charger */ { USB_DEVICE(0x18EF, 0xE032) }, /* ELV TFD500 Data Logger */ { USB_DEVICE(0x1901, 0x0190) }, /* GE B850 CP2105 Recorder interface */ { USB_DEVICE(0x1901, 0x0193) }, /* GE B650 CP2104 PMC interface */
PATCH 162/254 can: gs_usb: fix return value of the "set_bittiming" callback
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Wolfgang Grandegger <[email protected]>
commit d5b42e6607661b198d8b26a0c30969605b1bf5c7 upstream.
The "set_bittiming" callback treats a positive return value as error! For that reason "can_changelink()" will quit silently after setting the bittiming values without processing ctrlmode, restart-ms, etc.
--- drivers/net/can/usb/gs_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/usb/gs_usb.c +1 -1
@@ -430,7 +430,7 @@ static int gs_usb_set_bittiming(struct ndev_err (netdev->dev.parent,"Couldn't set bittimings (err=%d)" , rc); -return rc; +return (rc >0 ) ?0 : rc; }static void gs_usb_xmit_callback (struct urb *urb)
PATCH 163/254 ALSA: pcm: Add missing error checks in OSS emulation plugin builder
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 6708913750344a900f2e73bfe4a4d6dbbce4fe8d upstream.
In the OSS emulation plugin builder where the frame size is parsed in the plugin chain, some places miss the possible errors returned from the plugin src_ or dst_frames callback.
This patch papers over such places.
--- sound/core/oss/pcm_plugin.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
sound/core/oss/pcm_plugin.c +11 -3
@@ -591,18 +591,26 @@ snd_pcm_sframes_t snd_pcm_plug_write_trasnd_pcm_sframes_t frames = size; plugin =snd_pcm_plug_first (plug); -while (plugin && frames >0 ) { +while (plugin) { +if (frames <=0 ) +return frames;if ((next = plugin->next) !=NULL ) {snd_pcm_sframes_t frames1 = frames; -if (plugin->dst_frames) +if (plugin->dst_frames) { frames1 = plugin->dst_frames (plugin, frames); +if (frames1 <=0 ) +return frames1; + }if ((err = next->client_channels (next, frames1, &dst_channels)) <0 ) {return err; }if (err != frames1) { frames = err; -if (plugin->src_frames) +if (plugin->src_frames) { frames = plugin->src_frames (plugin, frames1); +if (frames <=0 ) +return frames; + } } }else dst_channels =NULL ;
PATCH 164/254 usbip: remove kernel addresses from usb device and urb debug msgs
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Shuah Khan <[email protected]>
commit e1346fd87c71a1f61de1fe476ec8df1425ac931c upstream.
usbip_dump_usb_device() and usbip_dump_urb() print kernel addresses. Remove kernel addresses from usb device and urb debug msgs and improve the message content.
Instead of printing parent device and bus addresses, print parent device and bus names.
--- drivers/staging/usbip/usbip_common.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)
drivers/staging/usbip/usbip_common.c +3 -14
@@ -103,7 +103,7 @@ static void usbip_dump_usb_device(structdev_dbg (dev," devnum(%d) devpath(%s) usb speed(%s)" , udev->devnum, udev->devpath,usb_speed_string (udev->speed)); -pr_debug ("tt %p, ttport %d\n" , udev->tt, udev->ttport); +pr_debug ("tt hub ttport %d\n" , udev->ttport);dev_dbg (dev," " );for (i =0 ; i <16 ; i++)
@@ -136,12 +136,8 @@ static void usbip_dump_usb_device(struct }pr_debug ("\n" ); -dev_dbg (dev,"parent %p, bus %p\n" , udev->parent, udev->bus); - -dev_dbg (dev, -"descriptor %p, config %p, actconfig %p, rawdescriptors %p\n" , - &udev->descriptor, udev->config, - udev->actconfig, udev->rawdescriptors); +dev_dbg (dev,"parent %s, bus %s\n" ,dev_name (&udev->parent->dev), + udev->bus->bus_name);dev_dbg (dev,"have_langid %d, string_langid %d\n" , udev->have_langid, udev->string_langid);
@@ -249,9 +245,6 @@ void usbip_dump_urb(struct urb *urb) dev = &urb->dev->dev; -dev_dbg (dev," urb :%p\n" , urb); -dev_dbg (dev," dev :%p\n" , urb->dev); -usbip_dump_usb_device (urb->dev);dev_dbg (dev," pipe :%08x " , urb->pipe);
@@ -260,11 +253,9 @@ void usbip_dump_urb(struct urb *urb)dev_dbg (dev," status :%d\n" , urb->status);dev_dbg (dev," transfer_flags :%08X\n" , urb->transfer_flags); -dev_dbg (dev," transfer_buffer :%p\n" , urb->transfer_buffer);dev_dbg (dev," transfer_buffer_length:%d\n" , urb->transfer_buffer_length);dev_dbg (dev," actual_length :%d\n" , urb->actual_length); -dev_dbg (dev," setup_packet :%p\n" , urb->setup_packet);if (urb->setup_packet &&usb_pipetype (urb->pipe) ==PIPE_CONTROL ) usbip_dump_usb_ctrlrequest(
@@ -274,8 +265,6 @@ void usbip_dump_urb(struct urb *urb)dev_dbg (dev," number_of_packets :%d\n" , urb->number_of_packets);dev_dbg (dev," interval :%d\n" , urb->interval);dev_dbg (dev," error_count :%d\n" , urb->error_count); -dev_dbg (dev," context :%p\n" , urb->context); -dev_dbg (dev," complete :%p\n" , urb->complete); }EXPORT_SYMBOL_GPL (usbip_dump_urb);
PATCH 165/254 net: phy: Add phy_interface_is_rgmii helper
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
commit e463d88c36d42211aa72ed76d32fb8bf37820ef1 upstream.
RGMII interfaces come in 4 different flavors that the PHY library needs to care about: regular RGMII (no delays), RGMII with either RX or TX delay, and both. In order to avoid errors of checking only for one type of RGMII interface and miss the 3 others, introduce a convenience function which tests for all values.
--- include/linux/phy.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
include/linux/phy.h +11 -0
@@ -630,6 +630,17 @@ static inline bool phy_is_internal(struc }/** +* phy_interface_is_rgmii - Convenience function for testing if a PHY interface +* is RGMII (all variants) +* @phydev: the phy_device struct +*/ +static inline bool phy_interface_is_rgmii (struct phy_device *phydev) +{ +return phydev->interface >=PHY_INTERFACE_MODE_RGMII && + phydev->interface <=PHY_INTERFACE_MODE_RGMII_TXID ; +} + +/** * phy_write_mmd - Convenience function for writing a register * on an MMD on a given PHY. * @phydev: The phy_device struct
PATCH 166/254 phy: Add helper function to check phy interface mode
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Iyappan Subramanian <[email protected]>
commit 32d0f7830d9be5b1652a718e050d808b4908155f upstream.
Added helper function that checks phy_mode is RGMII (all variants) 'bool phy_interface_mode_is_rgmii(phy_interface_t mode)'
Changed the following function, to use the above. 'bool phy_interface_is_rgmii(struct phy_device *phydev)'
--- include/linux/phy.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
include/linux/phy.h +12 -2
@@ -630,14 +630,24 @@ static inline bool phy_is_internal(struc }/** +* phy_interface_mode_is_rgmii - Convenience function for testing if a +* PHY interface mode is RGMII (all variants) +* @mode: the phy_interface_t enum +*/ +static inline bool phy_interface_mode_is_rgmii (phy_interface_t mode) +{ +return mode >=PHY_INTERFACE_MODE_RGMII && + mode <=PHY_INTERFACE_MODE_RGMII_TXID ; +}; + +/** * phy_interface_is_rgmii - Convenience function for testing if a PHY interface * is RGMII (all variants) * @phydev: the phy_device struct */ static inline bool phy_interface_is_rgmii (struct phy_device *phydev) { -return phydev->interface >=PHY_INTERFACE_MODE_RGMII && - phydev->interface <=PHY_INTERFACE_MODE_RGMII_TXID ; +return phy_interface_mode_is_rgmii (phydev->interface); }/**
PATCH 167/254 net: stmmac: enable EEE in MII, GMII or RGMII only
In reply to Ben Hutchings3.16.55-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jerome Brunet <[email protected]>
commit 879626e3a52630316d817cbda7cec9a5446d1d82 upstream.
Note in the databook - Section 4.4 - EEE :
" The EEE feature is not supported when the MAC is configured to use the TBI, RTBI, SMII, RMII or SGMII single PHY interface. Even if the MAC supports multiple PHY interfaces, you should activate the EEE mode only when the MAC is operating with GMII, MII, or RGMII interface."
Applying this restriction solves a stability issue observed on Amlogic gxl platforms operating with RMII interface and the internal PHY.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +6 -0
@@ -275,8 +275,14 @@ static void stmmac_eee_ctrl_timer(unsign*/ bool stmmac_eee_init (struct stmmac_priv *priv) { +int interface = priv->plat->interface;bool ret = false; +if ((interface !=PHY_INTERFACE_MODE_MII ) && + (interface !=PHY_INTERFACE_MODE_GMII ) && + !phy_interface_mode_is_rgmii (interface)) + goto out; +/* Using PCS we cannot dial with the phy registers at this stage * so we do not support extra feature like EEE. */