3.16.52-rc1 review
Subsystems (5)
cover 3.16.52-rc1 review
This is the start of the stable review cycle for the 3.16.52 release. There are 204 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 Mon Jan 1 17: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.
-------------
Adrian Salido (1):
HID: i2c-hid: allocate hid buffers for real worst case
[8320caeeffdefec3b58b9d4a7ed8e1079492fe7b]
Al Viro (3):
Bluetooth: bnep: bnep_add_connection() should verify that it's dealing with l2cap socket
[71bb99a02b32b4cc4265118e85f6035ca72923f0]
Bluetooth: cmtp: cmtp_add_connection() should verify that it's dealing with l2cap socket
[96c26653ce65bf84f3212f8b00d4316c1efcbf4c]
more bio_map_user_iov() leak fixes
[2b04e8f6bbb196cab4b232af0f8d48ff2c7a8058]
Alan Stern (11):
USB: core: prevent malicious bNumInterfaces overflow
[48a4ff1c7bb5a32d2e396b03132d20d552c0eca7]
USB: dummy-hcd: Fix deadlock caused by disconnect detection
[ab219221a5064abfff9f78c323c4a257b16cdb81]
USB: dummy-hcd: Fix erroneous synchronization change
[7dbd8f4cabd96db5a50513de9d83a8105a5ffc81]
USB: dummy-hcd: fix connection failures (wrong speed)
[fe659bcc9b173bcfdd958ce2aec75e47651e74e1]
USB: dummy-hcd: fix infinite-loop resubmission bug
[0173a68bfb0ad1c72a6ee39cc485aa2c97540b98]
USB: g_mass_storage: Fix deadlock when driver is unbound
[1fbbb78f25d1291274f320462bf6908906f538db]
USB: gadgetfs, dummy-hcd, net2280: fix locking for callbacks
[f16443a034c7aa359ddf6f0f9bc40d01ca31faea]
USB: gadgetfs: Fix crash caused by inadequate synchronization
[520b72fc64debf8a86c3853b8e486aa5982188f0]
USB: gadgetfs: fix copy_to_user while holding spinlock
[6e76c01e71551cb221c1f3deacb9dcd9a7346784]
usb-storage: fix bogus hardware error messages for ATA pass-thru devices
[a4fd4a724d6c30ad671046d83be2e9be2f11d275]
usb-storage: unusual_devs entry to fix write-access regression for Seagate external drives
[113f6eb6d50cfa5e2a1cdcf1678b12661fa272ab]
Alex Estrin (1):
Revert "IB/ipoib: Update broadcast object if PKey value was changed in index 0"
[612601d0013f03de9dc134809f242ba6da9ca252]
Alexey Kodanev (1):
vti: fix use after free in vti_tunnel_xmit/vti6_tnl_xmit
[36f6ee22d2d66046e369757ec6bbe1c482957ba6]
Andreas Engel (1):
USB: serial: cp210x: add support for ELV TFD500
[c496ad835c31ad639b6865714270b3003df031f6]Andreas Gruenbacher (2):
direct-io: Prevent NULL pointer access in submit_page_section
[899f0429c7d3eed886406cd72182bee3b96aa1f9]
vfs: Return -ENXIO for negative SEEK_HOLE / SEEK_DATA offsets
[fc46820b27a2d9a46f7e90c9ceb4a64a1bc5fab8]
Andrei Vagin (1):
net/unix: don't show information about sockets from other namespaces
[0f5da659d8f1810f44de14acf2c80cd6499623a0]
Andrew Gabbasov (1):
usb: gadget: composite: Fix use-after-free in usb_composite_overwrite_options
[aec17e1e249567e82b26dafbb86de7d07fde8729]
Andrew Honig (1):
KVM: VMX: remove I/O port 0x80 bypass on Intel hosts
[d59d51f088014f25c2562de59b9abff4f42a7468]Andrey Konovalov (2):
uwb: ensure that endpoint is interrupt
[70e743e4cec3733dc13559f6184b35d358b9ef3f]
uwb: properly check kthread_run return value
[bbf26183b7a6236ba602f4d6a2f7cade35bba043]
Aravind Gopalakrishnan (2):
pci_ids: Add PCI device IDs for F15h M60h
[4cbbdb51cc921f95978360fd7a0652d493dadc3e]
x86, amd_nb: Add device IDs to NB tables for F15h M60h
[15895a729e02ea55433b912cc31d5c6de16359ec]
Arnd Bergmann (4):
ARM: 8715/1: add a private asm/unaligned.h
[1cce91dfc8f7990ca3aea896bfb148f240b12860]
gpio: acpi: work around false-positive -Wstring-overflow warning
[e40a3ae1f794a35c4af3746291ed6fedc1fa0f6f]
include/linux/of.h: provide of_n_{addr,size}_cells wrappers for !CONFIG_OF
[8a1ac5dc7be09883051b1bf89a5e57d7ad850fa5]
usb: gadget: dummy: fix nonsensical comparisons
[7661ca09b2ff98f48693f431bb01fed62830e433]
Ashish Samant (1):
ocfs2: fstrim: Fix start offset of first cluster group during fstrim
[105ddc93f06ebe3e553f58563d11ed63dbcd59f0]
Baruch Siach (1):
spi: uapi: spidev: add missing ioctl header
[a2b4a79b88b24c49d98d45a06a014ffd22ada1a4]
Ben Hutchings (1):
ipsec: Fix aborted xfrm policy dump crash
[1137b5e2529a8f5ca8ee709288ecba3e68044df2]
Bo Yan (1):
tracing: Erase irqsoff trace with empty write
[8dd33bcb7050dd6f8c1432732f930932c9d3a33e]
Borislav Petkov (3):
x86/cpu/AMD: Apply the Erratum 688 fix when the BIOS doesn't
[bfc1168de949cd3e9ca18c3480b5085deff1ea7c]
x86/microcode/intel: Disable late loading on model 79
[723f2828a98c8ca19842042f418fb30dd8cfc0f7]
x86/oprofile/ppro: Do not use __this_cpu*() in preemptible context
[a743bbeef27b9176987ec0cb7f906ab0ab52d1da]
Casey Schaufler (1):
lsm: fix smack_inode_removexattr and xattr_getsecurity memleak
[57e7ba04d422c3d41c8426380303ec9b7533ded9]
Christophe Jaillet (1):
IB/mlx5: Fix the size parameter to find_first_bit
[fffd68734dc685e208e86d8c5f6522cd695a8d60]
Colin Ian King (2):
IB/ocrdma: fix incorrect fall-through on switch statement
[06564f60859bdf7e73d70ae35d7e285e96ae9c46]
staging: iio: ade7759: fix signed extension bug on shift of a u8
[13ffe9a26df4e156363579b25c904dd0b1e31bfb]
Cong Wang (2):
tun: call dev_get_valid_name() before register_netdevice()
[0ad646c81b2182f7fa67ec0c8c825e0ee165696d]
vlan: fix a use-after-free in vlan_device_event()
[052d41c01b3a2e3371d66de569717353af489d63]
Craig Gallek (1):
tun/tap: sanitize TUNSETSNDBUF input
[93161922c658c714715686cd0cf69b090cb9bf1d]
Dan Carpenter (1):
tile: array underflow in setup_maxnodemem()
[637f23abca87d26e091e0d6647ec878d97d2c6cd]
David Disseldorp (2):
SMB: fix leak of validate negotiate info response buffer
[fe83bebc05228e838ed5cbbc62712ab50dd40e18]
SMB: fix validate negotiate info uninitialised memory use
[a2d9daad1d2dfbd307ab158044d1c323d7babbde]
Dmitry Fleytman (1):
usb: Increase quirk delay for USB devices
[b2a542bbb3081dbd64acc8929c140d196664c406]
Dmitry Torokhov (3):
Input: ims-psu - check if CDC union descriptor is sane
[ea04efee7635c9120d015dcdeeeb6988130cb67a]
Input: uinput - avoid FF flush when destroying device
[e8b95728f724797f958912fd9b765a695595d3a6]
Input: uinput - avoid crash when sending FF request to device going away
[6b4877c7bdc6ae39ce03716df7caeecf204697eb]
Dongjiu Geng (1):
arm/arm64: KVM: set right LR register value for 32 bit guest when inject abort
[fd6c8c206fc5d0717b0433b191de0715122f33bb]
Dragos Bogdan (2):
iio: ad7793: Fix the serial interface reset
[7ee3b7ebcb74714df6d94c8f500f307e1ee5dda5]
iio: ad_sigma_delta: Implement a dedicated reset function
[7fc10de8d49a748c476532c9d8e8fe19e548dd67]
Eric Biggers (18):
FS-Cache: fix dereference of NULL user_key_payload
[d124b2c53c7bee6569d2a2d0b18b4a1afde00134]
KEYS: add missing permission check for request_key() destination
[4dca6ea1d9432052afb06baf2e3ae78188a4410b]
KEYS: don't revoke uninstantiated key in request_key_auth_new()
[f7b48cf08fa63a68b59c2894806ee478216d7f91]
KEYS: encrypted: fix dereference of NULL user_key_payload
[13923d0865ca96312197962522e88bc0aedccd74]
KEYS: fix NULL pointer dereference during ASN.1 parsing [ver #2]
[624f5ab8720b3371367327a822c267699c1823b8]
KEYS: fix cred refcount leak in request_key_auth_new()
[44d8143340a99b167c74365e844516b73523c087]
KEYS: fix key refcount leak in keyctl_assume_authority()
[884bee0215fcc239b30c062c37ca29077005e064]
KEYS: fix key refcount leak in keyctl_read_key()
[7fc0786d956d9e59b68d282be9b156179846ea3d]
KEYS: fix out-of-bounds read during ASN.1 parsing
[2eb9eabf1e868fda15808954fb29b0f105ed65f1]
KEYS: fix writing past end of user-supplied buffer in keyring_read()
[e645016abc803dafc75e4b8f6e4118f088900ffb]
KEYS: prevent creating a different user's keyrings
[237bbd29f7a049d310d907f4b2716a7feef9abf3]
KEYS: return full count in keyring_read() if buffer is too small
[3239b6f29bdfb4b0a2ba59df995fc9e6f4df7f1f]
KEYS: trusted: fix writing past end of buffer in trusted_read()
[a3c812f7cfd80cf51e8f5b7034f7418f6beb56c1]
KEYS: trusted: sanitize all key material
[ee618b4619b72527aaed765f0f0b74072b281159]
crypto: hmac - require that the underlying hash algorithm is unkeyed
[af3ff8045bbf3e32f1a448542e73abb4c8ceb6f1]
crypto: salsa20 - fix blkcipher_walk API usage
[ecaaab5649781c5a0effdaf298a925063020500e]
ecryptfs: fix dereference of NULL user_key_payload
[f66665c09ab489a11ca490d6a82df57cfc1bea3e]
lib/digsig: fix dereference of NULL user_key_payload
[192cabd6a296cbc57b3d8c05c4c89d87fc102506]
Eric Dumazet (3):
netfilter: x_tables: avoid stack-out-of-bounds read in xt_copy_counters_from_user
[e466af75c074e76107ae1cd5a2823e9c61894ffb]
tcp: fastopen: fix on syn-data transmit failure
[b5b7db8d680464b1d631fd016f5e093419f0bfd9]
tcp: fix tcp_mtu_probe() vs highest_sack
[2b7cda9c35d3b940eb9ce74b30bbd5eb30db493d]
Eric W. Biederman (5):
exec: Ensure mm->user_ns contains the execed files
[f84df2a6f268de584a201e8911384a2d244876e3]
mm: Add a user_ns owner to mm_struct and fix ptrace permission checks
[bfedb589252c01fa505ac9f6f2a3d5d68d707ef4]
ptrace: Capture the ptracer's creds not PT_PTRACE_CAP
[64b875f7ac8a5d60a4e191479299e931ee949b67]
ptrace: Don't allow accessing an undumpable mm
[84d77d3f06e7e8dea057d10e8ec77ad71f721be3]
ptrace: Properly initialize ptracer_cred on fork
[c70d9d809fdeecedb96972457ee45c49a232d97f]Ethan Zhao (1):
sched/sysctl: Check user input value of sysctl_sched_time_avg
[5ccba44ba118a5000cccc50076b0344632459779]
Felipe Balbi (1):
usb: quirks: add quirk for WORLDE MINI MIDI keyboard
[2811501e6d8f5747d08f8e25b9ecf472d0dc4c7d]
Florian Westphal (1):
netfilter: ipset: pernet ops must be unregistered last
[e23ed762db7ed1950a6408c3be80bc56909ab3d4]
Geert Uytterhoeven (4):
sh: sh7264: remove nonexistent GPIO_PH[0-7] to fix pinctrl registration
[eae3df7e82318d798f45dedf111e241805ec7a4a]
sh: sh7269: remove nonexistent GPIO_PH[0-7] to fix pinctrl registration
[d9d73e81fe82fdf4ee65a48c26531edc04108349]
sh: sh7722: remove nonexistent GPIO_PTQ7 to fix pinctrl registration
[b78412b8300a8453b78d2c1b0b925b66493bb011]
sh: sh7757: remove nonexistent GPIO_PT[JLNQ]7_RESV to fix pinctrl registration
[d8ce38f69843a56da044e56b6c16aecfbc3c6e39]
Gerald Schaefer (1):
s390/mm: fix write access check in gup_huge_pmd()
[ba385c0594e723d41790ecfb12c610e6f90c7785]
Guillaume Nault (6):
l2tp: check ps->sock before running pppol2tp_session_ioctl()
[5903f594935a3841137c86b9d5b75143a5b7121c]
l2tp: don't use l2tp_tunnel_find() in l2tp_ip and l2tp_ip6
[8f7dc9ae4a7aece9fbc3e6637bdfa38b36bcdf09]
l2tp: fix l2tp_eth module loading
[9f775ead5e570e7e19015b9e4e2f3dd6e71a5935]
l2tp: hold socket before dropping lock in l2tp_ip{, 6}_recv()
[a3c18422a4b4e108bcf6a2328f48867e1003fd95]
l2tp: hold tunnel in pppol2tp_connect()
[f9e56baf03f9d36043a78f16e3e8b2cfd211e09e]
l2tp: hold tunnel socket when handling control frames in l2tp_ip and l2tp_ip6
[94d7ee0baa8b764cf64ad91ed69464c1a6a0066b]Gustavo A. R. Silva (1):
MIPS: microMIPS: Fix incorrect mask in insn_table_MM
[77238e76b9156d28d86c1e31c00ed2960df0e4de]
Hante Meuleman (1):
brcmfmac: Add length checks on firmware events
[0aedbcaf6f182690790d98d90d5fe1e64c846c34]
Haozhong Zhang (1):
KVM: nVMX: fix guest CR4 loading when emulating L2 to L1 exit
[8eb3f87d903168bdbd1222776a6b1e281f50513e]
Henryk Heisig (1):
USB: serial: option: add support for TP-Link LTE module
[837ddc4793a69b256ac5e781a5e729b448a8d983]
Herbert Xu (1):
crypto: shash - Fix zero-length shash ahash digest crash
[b61907bb42409adf9b3120f741af7c57dd7e3db2]
Ilya Dryomov (1):
rbd: use GFP_NOIO for parent stat and data requests
[1e37f2f84680fa7f8394fd444b6928e334495ccc]
Ilya Lesokhin (1):
IB/mlx5: Simplify mlx5_ib_cont_pages
[d67bc5d4e3e100d762c0f57ea67f28bc219698a6]
Jan Luebbe (1):
bus: mbus: fix window size calculation for 4GB windows
[2bbbd96357ce76cc45ec722c00f654aa7b189112]
Jani Nikula (1):
drm/i915/bios: ignore HDMI on port A
[d27ffc1d00327c29b3aa97f941b42f0949f9e99f]
Jann Horn (1):
security: let security modules use PTRACE_MODE_* with bitmasks
[3dfb7d8cdbc7ea0c2970450e60818bb3eefbad69]
Jason A. Donenfeld (1):
security/keys: properly zero out sensitive key material in big_key
[910801809b2e40a4baedd080ef5d80b4a180e70e]
Jean Delvare (1):
kernel/params.c: align add_sysfs_param documentation with code
[630cc2b30a42c70628368a412beb4a5e5dd71abe]
Jeff Lance (1):
Input: ti_am335x_tsc - fix incorrect step config for 5 wire touchscreen
[cf5dd48907bebaefdb43a8ca079be77e8da2cb20]
Jeffrey Chu (1):
USB: serial: ftdi_sio: add id for Cypress WICED dev board
[a6c215e21b0dc5fe9416dce90f9acc2ea53c4502]
Jim Dickerson (1):
usb: pci-quirks.c: Corrected timeout values used in handshake
[114ec3a6f9096d211a4aff4277793ba969a62c73]
Jimmy Assarsson (1):
can: kvaser_usb: Correct return value in printout
[8f65a923e6b628e187d5e791cf49393dd5e8c2f9]
Joerg Roedel (1):
iommu/amd: Finish TLB flush in amd_iommu_unmap()
[ce76353f169a6471542d999baf3d29b121dce9c0]
Johan Hovold (1):
USB: serial: metro-usb: add MS7820 device id
[31dc3f819bac28a0990b36510197560258ab7421]
Johannes Thumshirn (1):
scsi: libiscsi: fix shifting of DID_REQUEUE host byte
[eef9ffdf9cd39b2986367bc8395e2772bc1284ba]
John David Anglin (1):
parisc: Fix double-word compare and exchange in LWS code on 32-bit kernels
[374b3bf8e8b519f61eb9775888074c6e46b3bf0c]
Jonathan Basseri (1):
xfrm: Clear sk_dst_cache when applying per-socket policy.
[2b06cdf3e688b98fcc9945873b5d42792bd4eee0]
Kazuya Mizuguchi (1):
usb: renesas_usbhs: Fix DMAC sequence for receiving zero-length packet
[29c7f3e68eec4ae94d85ad7b5dfdafdb8089f513]
Kevin Cernekee (4):
brcmfmac: Add check for short event packets
[dd2349121bb1b8ff688c3ca6a2a0bea9d8c142ca]
netfilter: nfnetlink_cthelper: Add missing permission checks
[4b380c42f7d00a395feede754f0bc2292eebe6e5]
netfilter: xt_osf: Add missing permission checks
[916a27901de01446bcf57ecca4783f6cff493309]
netlink: Add netns check on taps
[93c647643b48f0131f02e45da3bd367d80443291]
Kirill A. Shutemov (1):
mm, thp: Do not make page table dirty unconditionally in touch_p[mu]d()
[a8f97366452ed491d13cf1e44241bc0b5740b1f0]
Konstantin Khlebnikov (2):
Smack: remove unneeded NULL-termination from securtity label
[da1b63566c469bf3e2b24182114422e16b1aa34c]
net_sched: always reset qdisc backlog in qdisc_reset()
[c8e1812960eeae42e2183154927028511c4bc566]
LEROY Christophe (2):
crypto: talitos - Don't provide setkey for non hmac hashing algs.
[56136631573baa537a15e0012055ffe8cfec1a33]
crypto: talitos - fix sha224
[afd62fa26343be6445479e75de9f07092a061459]
Lauro Ramos Venancio (1):
sched/topology: Optimize build_group_mask()
[f32d782e31bf079f600dcec126ed117b0577e85c]
Li Bin (1):
workqueue: Fix NULL pointer dereference
[cef572ad9bd7f85035ba8272e5352040e8be0152]
Luca Coelho (1):
iwlwifi: mvm: use IWL_HCMD_NOCOPY for MCAST_FILTER_CMD
[97bce57bd7f96e1218751996f549a6e61f18cc8c]
Lukas Wunner (1):
iio: adc: mcp320x: Fix oops on module unload
[0964e40947a630a2a6f724e968246992f97bcf1c]Maksim Salau (1):
usb: cdc_acm: Add quirk for Elatec TWN3
[765fb2f181cad669f2beb87842a05d8071f2be85]
Marc Zyngier (1):
arm64: Make sure SPsel is always set
[5371513fb338fb9989c569dc071326d369d6ade8]
Marek Szyprowski (1):
iommu/exynos: Remove initconst attribute to avoid potential kernel oops
[9d25e3cc83d731ae4eeb017fd07562fde3f80bef]
Mark Rutland (3):
ARM: 8720/1: ensure dump_instr() checks addr_limit
[b9dd05c7002ee0ca8b676428b2268c26399b5e31]
arm64: ensure __dump_instr() checks addr_limit
[7a7003b1da010d2b0d1dc8bf21c10f5c73b389f1]
arm64: fix dump_instr when PAN and UAO are in use
[c5cea06be060f38e5400d796e61cfc8c36e52924]
Martin K. Petersen (1):
scsi: sd: Implement blacklist option for WRITE SAME w/ UNMAP
[28a0bc4120d38a394499382ba21d6965a67a3703]
Mathias Nyman (2):
usb: hub: Allow reset retry for USB2 devices on connect bounce
[1ac7db63333db1eeff901bfd6bbcd502b4634fa4]
xhci: fix finding correct bus_state structure for USB 3.1 hosts
[5a838a13c9b4e5dd188b7a6eaeb894e9358ead0c]
Matt Bennett (1):
ip6_gre: Reduce log level in ip6gre_err() to debug
[a46496ce38eeb401344d5623c1960dbf2f1769be]
Matt Fornero (1):
iio: core: Return error for failed read_reg
[3d62c78a6eb9a7d67bace9622b66ad51e81c5f9b]
Matthew Wilcox (1):
fs/mpage.c: fix mpage_writepage() for pages with buffers
[f892760aa66a2d657deaf59538fb69433036767c]
Mayank Rana (1):
usb: xhci: Handle error condition in xhci_stop_device()
[b3207c65dfafae27e7c492cb9188c0dc0eeaf3fd]
Michael S. Tsirkin (1):
macvtap: fix TUNSETSNDBUF values > 64k
[3ea79249e81e5ed051f2e6480cbde896d99046e8]
Miklos Szeredi (1):
fuse: fix READDIRPLUS skipping an entry
[c6cdd51404b7ac12dd95173ddfc548c59ecf037f]
Mohamed Ghannam (1):
dccp: CVE-2017-8824: use-after-free in DCCP code
[69c64866ce072dea1d1e59a0d61e0f66c0dffb76]Nicolai Stange (1):
PCI: Fix race condition with driver_override
[9561475db680f7144d2223a409dd3d7e322aca03]
Nicolas Dichtel (1):
net: enable interface alias removal via rtnl
[2459b4c635858094df78abb9ca87d99f89fe8ca5]
Oleg Nesterov (1):
ptrace: change __ptrace_unlink() to clear ->ptrace under ->siglock
[1333ab03150478df8d6f5673a91df1e50dc6ab97]Omar Sandoval (1):
Btrfs: fix incorrect {node,sector}size endianness from BTRFS_IOC_FS_INFO
[bea7eafdbda3ba1d4b2ccb9cca829eefb7989bb9]
Oswald Buddenhagen (1):
MIPS: AR7: Ensure that serial ports are properly set up
[b084116f8587b222a2c5ef6dcd846f40f24b9420]
Paolo Abeni (4):
IPv4: early demux can return an error code
[7487449c86c65202b3b725c4524cb48dd65e4e6f]
ipv4: fix broadcast packets reception
[ad0ea1989cc4d5905941d0a9e62c63ad6d859cef]
udp: fix bcast packet reception
[996b44fcef8f216ea0b6b6e74468c5a77b5e341f]
udp: perform source validation for mcast early demux
[bc044e8db7962e727a75b591b9851ff2ac5cf846]
Paul Burton (1):
MIPS: Fix CM region target definitions
[6a6cba1d945a7511cdfaf338526871195e420762]
Peng Xu (1):
nl80211: Define policy for packet pattern attributes
[ad670233c9e1d5feb365d870e30083ef1b889177]
Peter Zijlstra (3):
sched/topology: Remove FORCE_SD_OVERLAP
[af85596c74de2fd9abb87501ae280038ac28a3f4]
sched/topology: Simplify build_overlap_sched_groups()
[91eaed0d61319f58a9f8e43d41a8cbb069b4f73d]
x86/uaccess, sched/preempt: Verify access_ok() context
[7c4788950ba5922fde976d80b72baf46f14dee8d]
Ravi Bangoria (1):
powerpc/sysrq: Fix oops whem ppmu is not registered
[4917fcb58cc73f6b81455e3c5f960144809ddf1a]
Ricard Wanderlof (1):
ASoC: adau17x1: Workaround for noise bug in ADC
[1e6f4fc06f6411adf98bbbe7fcd79442cd2b2a75]
Richard Schütz (1):
can: c_can: don't indicate triple sampling support for D_CAN
[fb5f0b3ef69b95e665e4bbe8a3de7201f09f1071]
Ronnie Sahlberg (1):
cifs: check rsp for NULL before dereferencing in SMB2_open
[bf2afee14e07de16d3cafc67edbfc2a3cc65e4bc]
Sabrina Dubroca (1):
l2tp: fix race condition in l2tp_tunnel_delete
[62b982eeb4589b2e6d7c01a90590e3a4c2b2ca19]
Satoru Takeuchi (1):
btrfs: prevent to set invalid default subvolid
[6d6d282932d1a609e60dc4467677e0e863682f57]
Sekhar Nori (1):
ARM: dts: da850-evm: add serial and ethernet aliases
[ce21574ad1922b403198ee664c4dff276f514f1d]
Shrirang Bagul (1):
USB: serial: qcserial: add Dell DW5818, DW5819
[f5d9644c5fca7d8e8972268598bb516a7eae17f9]Shu Wang (2):
cifs: release auth_key.response for reconnect.
[f5c4ba816315d3b813af16f5571f86c8d4e897bd]
cifs: release cifs root_cred after exit_cifs
[94183331e815617246b1baa97e0916f358c794bb]
Stefan Mätje (1):
can: esd_usb2: Fix can_dlc value for received RTR, frames
[72d92e865d1560723e1957ee3f393688c49ca5bf]
Stefan Popa (1):
staging: iio: ad7192: Fix - use the dedicated reset function avoiding dma from stack.
[f790923f146140a261ad211e5baf75d169f16fb2]
Stefano Brivio (1):
scsi: lpfc: Don't return internal MBXERR_ERROR code from probe function
[5c756065e47dc3e84b00577bd109f0a8e69903d7]
Steffen Maier (1):
scsi: zfcp: fix erp_action use-before-initialize in REC action trace
[ab31fd0ce65ec93828b617123792c1bb7c6dcc42]
Steve French (3):
SMB3: Don't ignore O_SYNC/O_DSYNC and O_DIRECT flags
[1013e760d10e614dc10b5624ce9fc41563ba2e65]
SMB3: Validate negotiate request must always be signed
[4587eee04e2ac7ac3ac9fa2bc164fb6e548f99cd]
SMB: Validate negotiate (to protect against downgrade) even if signing off
[0603c96f3af50e2f9299fa410c224ab1d465e0f9]
Tahsin Erdogan (1):
tracing: Fix trace_pipe behavior for instance traces
[75df6e688ccd517e339a7c422ef7ad73045b18a2]
Takashi Iwai (10):
ALSA: caiaq: Fix stray URB at probe error path
[99fee508245825765ff60155fed43f970ff83a8f]
ALSA: hda: Remove superfluous '-' added by printk conversion
[6bf88a343db2b3c160edf9b82a74966b31cc80bd]
ALSA: seq: Avoid invalid lockdep class warning
[3510c7aa069aa83a2de6dab2b41401a198317bdc]
ALSA: seq: Fix OSS sysex delivery in OSS emulation
[132d358b183ac6ad8b3fea32ad5e0663456d18d1]
ALSA: seq: Fix copy_from_user() call inside lock
[5803b023881857db32ffefa0d269c90280a67ee0]
ALSA: seq: Fix nested rwsem annotation for lockdep splat
[1f20f9ff57ca23b9f5502fca85ce3977e8496cb1]
ALSA: timer: Add missing mutex lock for compat ioctls
[79fb0518fec8c8b4ea7f1729f54f293724b3dbb0]
ALSA: timer: Limit max instances per timer
[9b7d869ee5a77ed4a462372bb89af622e705bfb8]
ALSA: timer: Protect the whole snd_timer_close() with open race
[9984d1b5835ca29fc7025186a891ee7398d21cc7]
ALSA: usx2y: Suppress kernel warning at page allocation failures
[7682e399485fe19622b6fd82510b1f4551e48a25]
Tejun Heo (1):
workqueue: replace pool->manager_arb mutex with a flag
[692b48258dda7c302e777d7d5f4217244478f1f6]Tyrel Datwyler (1):
powerpc/pseries: Fix parent_dn reference leak in add_dt_node()
[b537ca6fede69a281dc524983e5e633d79a10a08]
Wanpeng Li (1):
KVM: Fix stack-out-of-bounds read in write_mmio
[e39d200fa5bf5b94a0948db0dae44c1b73b84a56]
Will Deacon (1):
arm64: fault: Route pte translation faults via do_translation_fault
[760bfb47c36a07741a089bf6a28e854ffbee7dc9]
Willem de Bruijn (1):
packet: only test po->has_vnet_hdr once in packet_snd
[da7c9561015e93d10fe6aab73e9288e0d09d65a6]Wolfgang Grandegger (1):
can: gs_usb: fix busy loop if no more TX context is available
[97819f943063b622eca44d3644067c190dc75039]
Xin Long (4):
ip6_gre: only increase err_count for some certain type icmpv6 in ip6gre_err
[f8d20b46ce55cf40afb30dcef6d9288f7ef46d9b]
ip6_gre: skb_push ipv6hdr before packing the header in ip6gre_header
[76cc0d3282d4b933fa144fa41fbc5318e0fdca24]
sctp: add the missing sock_owned_by_user check in sctp_icmp_redirect
[1cc276cec9ec574d41cf47dfc0f51406b6f26ab4]
sctp: fix a type cast warnings that causes a_rwnd gets the wrong value
[f6fc6bc0b8e0bb13a210bd7386ffdcb1a5f30ef1]
Yasuaki Ishimatsu (2):
mm/memory_hotplug: change pfn_to_section_nr/section_nr_to_pfn macro to inline function
[1dd2bfc86818ddbc95f98e312e7704350223fd7d]
mm/memory_hotplug: define find_{smallest|biggest}_section_pfn as unsigned long
[d09b0137d204bebeaafed672bc5a244e9ac92edb]
Yazen Ghannam (1):
x86/amd_nb: Add Fam17h Data Fabric as "Northbridge"
[b791c6b6a55c402367cc544f54921074253db061]
Ye Yin (1):
netfilter/ipvs: clear ipvs_property flag when SKB net namespace changed
[2b5ec1a5f9738ee7bf8f5ec0526e75e00362c48f]
Yoshihiro Shimoda (2):
usb: renesas_usbhs: fix the BCLR setting condition for non-DCP pipe
[6124607acc88fffeaadf3aacfeb3cc1304c87387]
usb: renesas_usbhs: fix usbhsf_fifo_clear() for RX direction
[0a2ce62b61f2c76d0213edf4e37aaf54a8ddf295]
Makefile | 4 +- arch/alpha/kernel/ptrace.c | 2 +- arch/arm/boot/dts/da850-evm.dts | 7 ++ arch/arm/include/asm/Kbuild | 1 - arch/arm/include/asm/unaligned.h | 27 +++++ arch/arm/kernel/traps.c | 28 ++++-- arch/arm/kvm/emulate.c | 5 +- arch/arm/kvm/mmio.c | 4 +- arch/arm64/kernel/head.S | 1 + arch/arm64/kernel/traps.c | 28 +++--- arch/arm64/kvm/inject_fault.c | 16 ++- arch/arm64/mm/fault.c | 2 +- arch/blackfin/kernel/ptrace.c | 4 +- arch/cris/arch-v32/kernel/ptrace.c | 2 +- arch/ia64/kernel/ptrace.c | 2 +- arch/mips/ar7/platform.c | 1 + arch/mips/include/asm/mips-cm.h | 4 +- arch/mips/kernel/ptrace32.c | 4 +- arch/mips/mm/uasm-micromips.c | 2 +- arch/parisc/kernel/syscall.S | 6 +- arch/powerpc/kernel/ptrace32.c | 4 +- arch/powerpc/perf/core-book3s.c | 5 + arch/powerpc/platforms/pseries/mobility.c | 4 +- arch/s390/mm/gup.c | 7 +- arch/sh/include/cpu-sh2a/cpu/sh7264.h | 4 +- arch/sh/include/cpu-sh2a/cpu/sh7269.h | 4 +- arch/sh/include/cpu-sh4/cpu/sh7722.h | 2 +- arch/sh/include/cpu-sh4/cpu/sh7757.h | 8 +- arch/tile/kernel/setup.c | 2 +- arch/x86/crypto/salsa20_glue.c | 7 -- arch/x86/include/asm/uaccess.h | 14 ++- arch/x86/kernel/amd_nb.c | 48 +++++++++ arch/x86/kernel/cpu/microcode/intel.c | 18 ++++ arch/x86/kvm/vmx.c | 7 +- arch/x86/kvm/x86.c | 8 +- arch/x86/oprofile/op_model_ppro.c | 4 +- block/bio.c | 14 ++- crypto/hmac.c | 6 +- crypto/salsa20_generic.c | 7 -- crypto/shash.c | 13 ++- drivers/block/rbd.c | 4 +- drivers/bus/mvebu-mbus.c | 2 +- drivers/crypto/talitos.c | 7 +- drivers/gpio/gpiolib-acpi.c | 2 +- drivers/gpu/drm/i915/intel_bios.c | 7 ++ drivers/hid/i2c-hid/i2c-hid.c | 3 +- drivers/iio/adc/ad7793.c | 4 +- drivers/iio/adc/ad_sigma_delta.c | 28 ++++++ drivers/iio/adc/mcp320x.c | 1 + drivers/iio/industrialio-core.c | 4 +- drivers/infiniband/hw/mlx5/mem.c | 49 ++++----- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 3 + drivers/infiniband/ulp/ipoib/ipoib_ib.c | 13 --- drivers/input/ff-core.c | 13 ++- drivers/input/misc/ims-pcu.c | 16 ++- drivers/input/misc/uinput.c | 57 +++++++---- drivers/input/touchscreen/ti_am335x_tsc.c | 2 +- drivers/iommu/amd_iommu.c | 1 + drivers/iommu/exynos-iommu.c | 2 +- drivers/net/can/c_can/c_can_pci.c | 1 - drivers/net/can/c_can/c_can_platform.c | 1 - drivers/net/can/usb/esd_usb2.c | 2 +- drivers/net/can/usb/gs_usb.c | 10 +- drivers/net/can/usb/kvaser_usb.c | 3 +- drivers/net/macvtap.c | 6 +- drivers/net/tun.c | 7 ++ drivers/net/wireless/brcm80211/brcmfmac/fweh.c | 58 +++-------- drivers/net/wireless/brcm80211/brcmfmac/fweh.h | 68 ++++++++++--- drivers/net/wireless/brcm80211/brcmfmac/p2p.c | 10 ++ .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c | 5 + drivers/net/wireless/iwlwifi/mvm/mac80211.c | 10 +- drivers/pci/pci-sysfs.c | 11 ++- drivers/s390/scsi/zfcp_aux.c | 5 + drivers/s390/scsi/zfcp_erp.c | 18 ++-- drivers/s390/scsi/zfcp_scsi.c | 5 + drivers/scsi/libiscsi.c | 2 +- drivers/scsi/lpfc/lpfc_init.c | 1 + drivers/scsi/scsi_scan.c | 3 + drivers/scsi/sd.c | 16 ++- drivers/staging/iio/adc/ad7192.c | 4 +- drivers/staging/iio/meter/ade7759.c | 2 +- drivers/usb/class/cdc-acm.c | 3 + drivers/usb/core/config.c | 6 +- drivers/usb/core/hub.c | 13 ++- drivers/usb/core/quirks.c | 4 + drivers/usb/gadget/composite.c | 5 + drivers/usb/gadget/dummy_hcd.c | 81 +++++++++++---- drivers/usb/gadget/f_mass_storage.c | 31 ++---- drivers/usb/gadget/f_mass_storage.h | 14 --- drivers/usb/gadget/inode.c | 55 +++++++++-- drivers/usb/gadget/mass_storage.c | 20 +--- drivers/usb/gadget/net2280.c | 5 +- drivers/usb/host/pci-quirks.c | 8 +- drivers/usb/host/xhci-hub.c | 22 ++++- drivers/usb/host/xhci.h | 2 +- drivers/usb/renesas_usbhs/fifo.c | 23 ++++- drivers/usb/serial/cp210x.c | 1 + drivers/usb/serial/ftdi_sio.c | 2 + drivers/usb/serial/ftdi_sio_ids.h | 7 ++ drivers/usb/serial/metro-usb.c | 1 + drivers/usb/serial/option.c | 2 + drivers/usb/serial/qcserial.c | 4 + drivers/usb/storage/transport.c | 14 ++- drivers/usb/storage/unusual_devs.h | 7 ++ drivers/uwb/hwa-rc.c | 2 + drivers/uwb/uwbd.c | 12 ++- fs/block_dev.c | 6 +- fs/btrfs/ioctl.c | 10 +- fs/cifs/cifsfs.c | 2 +- fs/cifs/connect.c | 8 ++ fs/cifs/file.c | 7 ++ fs/cifs/smb2pdu.c | 34 +++++-- fs/direct-io.c | 3 +- fs/ecryptfs/ecryptfs_kernel.h | 25 +++-- fs/ecryptfs/keystore.c | 9 +- fs/exec.c | 22 ++++- fs/fscache/object-list.c | 7 ++ fs/fuse/dir.c | 3 +- fs/mpage.c | 14 ++- fs/ocfs2/alloc.c | 24 +++-- fs/read_write.c | 4 +- fs/xattr.c | 2 +- include/crypto/internal/hash.h | 8 ++ include/linux/buffer_head.h | 1 + include/linux/capability.h | 2 + include/linux/iio/adc/ad_sigma_delta.h | 3 + include/linux/input.h | 1 + include/linux/key.h | 2 + include/linux/mbus.h | 4 +- include/linux/mm.h | 2 + include/linux/mm_types.h | 1 + include/linux/mmzone.h | 10 +- include/linux/netdevice.h | 3 + include/linux/of.h | 10 ++ include/linux/pci_ids.h | 2 + include/linux/preempt_mask.h | 21 ++-- include/linux/ptrace.h | 11 ++- include/linux/sched.h | 1 + include/linux/skbuff.h | 7 ++ include/net/protocol.h | 2 +- include/net/route.h | 4 +- include/net/tcp.h | 8 +- include/net/udp.h | 2 +- include/scsi/scsi_device.h | 1 + include/scsi/scsi_devinfo.h | 1 + include/sound/seq_kernel.h | 3 +- include/sound/seq_virmidi.h | 1 + include/sound/timer.h | 2 + include/trace/events/kvm.h | 7 +- include/uapi/linux/spi/spidev.h | 1 + kernel/capability.c | 36 ++++++- kernel/fork.c | 9 +- kernel/params.c | 2 +- kernel/ptrace.c | 91 +++++++++++------ kernel/sched/core.c | 21 ++-- kernel/sched/features.h | 1 - kernel/sysctl.c | 3 +- kernel/trace/trace.c | 12 ++- kernel/workqueue.c | 37 +++---- kernel/workqueue_internal.h | 3 +- lib/asn1_decoder.c | 7 +- lib/digsig.c | 6 ++ mm/huge_memory.c | 14 +-- mm/init-mm.c | 2 + mm/memory.c | 2 +- mm/memory_hotplug.c | 6 +- mm/nommu.c | 2 +- net/8021q/vlan.c | 6 +- net/bluetooth/bnep/core.c | 3 + net/bluetooth/cmtp/core.c | 3 + net/core/dev.c | 6 +- net/core/rtnetlink.c | 5 +- net/core/skbuff.c | 1 + net/dccp/proto.c | 5 + net/ipv4/ip_input.c | 22 +++-- net/ipv4/ip_vti.c | 3 +- net/ipv4/route.c | 44 +++++---- net/ipv4/tcp_ipv4.c | 9 +- net/ipv4/tcp_output.c | 12 ++- net/ipv4/udp.c | 30 ++++-- net/ipv6/ip6_gre.c | 41 ++++---- net/ipv6/ip6_vti.c | 3 +- net/l2tp/l2tp_core.c | 10 +- net/l2tp/l2tp_core.h | 5 +- net/l2tp/l2tp_eth.c | 51 +--------- net/l2tp/l2tp_ip.c | 20 ++-- net/l2tp/l2tp_ip6.c | 21 ++-- net/l2tp/l2tp_ppp.c | 10 +- net/netfilter/ipset/ip_set_core.c | 23 +++-- net/netfilter/nfnetlink_cthelper.c | 10 ++ net/netfilter/x_tables.c | 4 +- net/netfilter/xt_osf.c | 7 ++ net/netlink/af_netlink.c | 3 + net/packet/af_packet.c | 4 +- net/sched/sch_generic.c | 1 + net/sctp/input.c | 2 +- net/sctp/sm_sideeffect.c | 4 +- net/unix/diag.c | 2 + net/wireless/nl80211.c | 12 ++- net/xfrm/xfrm_state.c | 1 + net/xfrm/xfrm_user.c | 3 +- security/keys/big_key.c | 2 +- security/keys/encrypted-keys/encrypted.c | 7 ++ security/keys/internal.h | 2 +- security/keys/key.c | 2 + security/keys/keyctl.c | 8 +- security/keys/keyring.c | 72 +++++++------- security/keys/process_keys.c | 8 +- security/keys/request_key.c | 46 +++++++-- security/keys/request_key_auth.c | 69 ++++++------- security/keys/trusted.c | 69 ++++++------- security/smack/smack_lsm.c | 65 ++++++------ security/yama/yama_lsm.c | 4 +- sound/core/hrtimer.c | 1 + sound/core/seq/oss/seq_oss_midi.c | 4 +- sound/core/seq/oss/seq_oss_readq.c | 29 ++++++ sound/core/seq/oss/seq_oss_readq.h | 2 + sound/core/seq/seq_clientmgr.c | 2 +- sound/core/seq/seq_virmidi.c | 27 +++-- sound/core/timer.c | 109 ++++++++++++++------- sound/core/timer_compat.c | 17 +++- sound/pci/hda/hda_codec.c | 2 +- sound/soc/codecs/adau17x1.c | 24 ++++- sound/soc/codecs/adau17x1.h | 2 + sound/usb/caiaq/device.c | 12 ++- sound/usb/usx2y/usb_stream.c | 6 +- 226 files changed, 1733 insertions(+), 945 deletions(-)
Signature · 2 lines
Ben Hutchings The two most common things in the universe are hydrogen and stupidity.
PATCH 1/204 tile: array underflow in setup_maxnodemem()
3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 637f23abca87d26e091e0d6647ec878d97d2c6cd upstream.
My static checker correctly complains that we should have a lower bound on "node" to prevent an array underflow.
--- arch/tile/kernel/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/tile/kernel/setup.c +1 -1
@@ -139,7 +139,7 @@ static int __init setup_maxnodemem(char {char *endp;unsigned long long maxnodemem; -long node; +unsigned long node; node = str ?simple_strtoul (str, &endp,0 ) :INT_MAX ;if (node >=MAX_NUMNODES || *endp !=':' )
PATCH 2/204 ASoC: adau17x1: Workaround for noise bug in ADC
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ricard Wanderlof <[email protected]>
commit 1e6f4fc06f6411adf98bbbe7fcd79442cd2b2a75 upstream.
The ADC in the ADAU1361 (and possibly other Analog Devices codecs) exhibits a cyclic variation in the noise floor (in our test setup between -87 and -93 dB), a new value being attained within this range whenever a new capture stream is started. The cycle repeats after about 10 or 11 restarts.
The workaround recommended by the manufacturer is to toggle the ADOSR bit in the Converter Control 0 register each time a new capture stream is started.
I have verified that the patch fixes this problem on the ADAU1361, and according to the manufacturer toggling the bit in question in this manner will at least have no detrimental effect on other chips served by this driver.
--- sound/soc/codecs/adau17x1.c | 24 +++++++++++++++++++++++- sound/soc/codecs/adau17x1.h | 2 ++ 2 files changed, 25 insertions(+), 1 deletion(-)
sound/soc/codecs/adau17x1.c +23 -1
@@ -88,6 +88,27 @@ static int adau17x1_pll_event(struct sndreturn 0 ; } +static int adau17x1_adc_fixup (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *kcontrol,int event) +{ +struct snd_soc_codec *codec =snd_soc_dapm_to_codec (w->dapm); +struct adau *adau =snd_soc_codec_get_drvdata (codec); + +/* +* If we are capturing, toggle the ADOSR bit in Converter Control 0 to +* avoid losing SNR (workaround from ADI). This must be done after +* the ADC(s) have been enabled. According to the data sheet, it is +* normally illegal to set this bit when the sampling rate is 96 kHz, +* but according to ADI it is acceptable for this workaround. +*/ +regmap_update_bits (adau->regmap,ADAU17X1_CONVERTER0 , +ADAU17X1_CONVERTER0_ADOSR ,ADAU17X1_CONVERTER0_ADOSR ); +regmap_update_bits (adau->regmap,ADAU17X1_CONVERTER0 , +ADAU17X1_CONVERTER0_ADOSR ,0 ); + +return 0 ; +} +static const char *const adau17x1_mono_stereo_text[] = {"Stereo" ,"Mono Left Channel (L+R)" ,
@@ -119,7 +140,8 @@ static const struct snd_soc_dapm_widgetSND_SOC_DAPM_MUX ("Right DAC Mode Mux" ,SND_SOC_NOPM ,0 ,0 , &adau17x1_dac_mode_mux), -SND_SOC_DAPM_ADC ("Left Decimator" ,NULL ,ADAU17X1_ADC_CONTROL ,0 ,0 ), +SND_SOC_DAPM_ADC_E ("Left Decimator" ,NULL ,ADAU17X1_ADC_CONTROL ,0 ,0 , + adau17x1_adc_fixup,SND_SOC_DAPM_POST_PMU ),SND_SOC_DAPM_ADC ("Right Decimator" ,NULL ,ADAU17X1_ADC_CONTROL ,1 ,0 ),SND_SOC_DAPM_DAC ("Left DAC" ,NULL ,ADAU17X1_DAC_CONTROL0 ,0 ,0 ), SND_SOC_DAPM_DAC("Right DAC", NULL, ADAU17X1_DAC_CONTROL0, 1, 0),
sound/soc/codecs/adau17x1.h +2 -0
@@ -120,5 +120,7 @@ bool adau17x1_has_dsp(struct adau *adau)#define ADAU17X1_CONVERTER0_CONVSR_MASK 0x7 +#define ADAU17X1_CONVERTER0_ADOSR BIT(3) +#endif
PATCH 3/204 iwlwifi: mvm: use IWL_HCMD_NOCOPY for MCAST_FILTER_CMD
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Luca Coelho <[email protected]>
commit 97bce57bd7f96e1218751996f549a6e61f18cc8c upstream.
The MCAST_FILTER_CMD can get quite large when we have many mcast addresses to set (we support up to 255). So the command should be send as NOCOPY to prevent a warning caused by too-long commands:
WARNING: CPU: 0 PID: 9700 at /root/iwlwifi/stack-dev/drivers/net/wireless/iwlwifi/pcie/tx.c:1550 iwl_pcie_enqueue_hcmd+0x8c7/0xb40 [iwlwifi]
Command MCAST_FILTER_CMD (0x1d0) is too large (328 bytes)
This fixes: https://bugzilla.kernel.org/show_bug.cgi?id=196743
--- drivers/net/wireless/iwlwifi/mvm/mac80211.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/wireless/iwlwifi/mvm/mac80211.c +9 -1
@@ -1004,6 +1004,11 @@ static void iwl_mvm_mc_iface_iterator(vostruct iwl_mvm_mc_iter_data *data = _data;struct iwl_mvm *mvm = data->mvm;struct iwl_mcast_filter_cmd *cmd = mvm->mcast_filter_cmd; +struct iwl_host_cmd hcmd = { + .id =MCAST_FILTER_CMD , + .flags =CMD_ASYNC , + .dataflags[0 ] =IWL_HCMD_DFL_NOCOPY , + };int ret, len;/* if we don't have free ports, mcast frames will be dropped */
@@ -1018,7 +1023,10 @@ static void iwl_mvm_mc_iface_iterator(vomemcpy (cmd->bssid, vif->bss_conf.bssid,ETH_ALEN ); len =roundup (sizeof (*cmd) + cmd->count *ETH_ALEN ,4 ); - ret =iwl_mvm_send_cmd_pdu (mvm,MCAST_FILTER_CMD ,CMD_ASYNC , len, cmd); + hcmd.len[0 ] = len; + hcmd.data[0 ] = cmd; + + ret =iwl_mvm_send_cmd (mvm, &hcmd);if (ret)IWL_ERR (mvm,"mcast filter cmd error. ret=%d\n" , ret); }
PATCH 4/204 cifs: check rsp for NULL before dereferencing in SMB2_open
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ronnie Sahlberg <[email protected]>
commit bf2afee14e07de16d3cafc67edbfc2a3cc65e4bc upstream.
In SMB2_open there are several paths where the SendReceive2 call will return an error before it sets rsp_iov.iov_base thus leaving iov_base uninitialized.
Thus we need to check rsp before we dereference it in the call to get_rfc1002_length().
A report of this issue was previously reported in
http://www.spinics.net/lists/linux-cifs/msg12846.html
RH-bugzilla : 1476151
Version 2 :
* Lets properly initialize rsp_iov before we use it.
--- fs/cifs/smb2pdu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/cifs/smb2pdu.c +2 -2
@@ -1114,7 +1114,7 @@ SMB2_open(const unsigned int xid, structstruct TCP_Server_Info *server;struct cifs_tcon *tcon = oparms->tcon;struct cifs_ses *ses = tcon->ses; -struct kvec iov[4 ]; +struct kvec iov[4 ] = {{NULL ,0 }};int resp_buftype;int uni_path_len;__le16 *copy_path =NULL ;
@@ -1215,7 +1215,7 @@ SMB2_open(const unsigned int xid, structif (rc !=0 ) {cifs_stats_fail_inc (tcon,SMB2_CREATE_HE ); -if (err_buf) +if (err_buf && rsp) *err_buf =kmemdup (rsp,get_rfc1002_length (rsp) +4 ,GFP_KERNEL ); goto creat_exit;
PATCH 5/204 HID: i2c-hid: allocate hid buffers for real worst case
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Salido <[email protected]>
commit 8320caeeffdefec3b58b9d4a7ed8e1079492fe7b upstream.
The buffer allocation is not currently accounting for an extra byte for the report id. This can cause an out of bounds access in function i2c_hid_set_or_send_report() with reportID > 15.
--- drivers/hid/i2c-hid/i2c-hid.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/hid/i2c-hid/i2c-hid.c +2 -1
@@ -526,7 +526,8 @@ static int i2c_hid_alloc_buffers(struct {/* the worst case is computed from the set_report command with a * reportID > 15 and the maximum report length */ -int args_len =sizeof (__u8) +/* optional ReportID byte */ +int args_len =sizeof (__u8) +/* ReportID */ +sizeof (__u8) +/* optional ReportID byte */ sizeof (__u16) +/* data register */ sizeof (__u16) +/* size of the report */ report_size;/* report */
PATCH 6/204 spi: uapi: spidev: add missing ioctl header
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Baruch Siach <[email protected]>
commit a2b4a79b88b24c49d98d45a06a014ffd22ada1a4 upstream.
The SPI_IOC_MESSAGE() macro references _IOC_SIZEBITS. Add linux/ioctl.h to make sure this macro is defined. This fixes the following build failure of lcdproc with the musl libc:
In file included from .../sysroot/usr/include/sys/ioctl.h:7:0,
from hd44780-spi.c:31:
hd44780-spi.c: In function 'spi_transfer':
hd44780-spi.c:89:24: error: '_IOC_SIZEBITS' undeclared (first use in this function)
status = ioctl(p->fd, SPI_IOC_MESSAGE(1), &xfer);
^--- include/uapi/linux/spi/spidev.h | 1 + 1 file changed, 1 insertion(+)
include/uapi/linux/spi/spidev.h +1 -0
@@ -23,6 +23,7 @@#define SPIDEV_H #include <linux/types.h> +#include <linux/ioctl.h> /* User space versions of kernel symbols for SPI clocking modes, * matching <linux/spi/spi.h>
PATCH 7/204 scsi: lpfc: Don't return internal MBXERR_ERROR code from probe function
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Stefano Brivio <[email protected]>
commit 5c756065e47dc3e84b00577bd109f0a8e69903d7 upstream.
Internal error codes happen to be positive, thus the PCI driver core won't treat them as failure, but we do. This would cause a crash later on as lpfc_pci_remove_one() is called (e.g. as shutdown function).
--- drivers/scsi/lpfc/lpfc_init.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/lpfc/lpfc_init.c +1 -0
@@ -5242,6 +5242,7 @@ lpfc_sli4_driver_resource_setup(struct llpfc_printf_log (phba,KERN_ERR ,LOG_INIT ,"2999 Unsupported SLI4 Parameters " "Extents and RPI headers enabled.\n" ); + rc = -EIO ; goto out_free_bsmbx; } }
PATCH 8/204 USB: serial: ftdi_sio: add id for Cypress WICED dev board
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jeffrey Chu <[email protected]>
commit a6c215e21b0dc5fe9416dce90f9acc2ea53c4502 upstream.
Add CYPRESS_VID vid and CYPRESS_WICED_BT_USB and CYPRESS_WICED_WL_USB device IDs to ftdi_sio driver.
--- drivers/usb/serial/ftdi_sio.c | 2 ++ drivers/usb/serial/ftdi_sio_ids.h | 7 +++++++ 2 files changed, 9 insertions(+)
drivers/usb/serial/ftdi_sio.c +2 -0
@@ -1028,6 +1028,8 @@ static const struct usb_device_id id_tab { USB_DEVICE(WICED_VID, WICED_USB20706V2_PID) }, { USB_DEVICE(TI_VID, TI_CC3200_LAUNCHPAD_PID), .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) }, { } /* Terminating entry */ };
drivers/usb/serial/ftdi_sio_ids.h +7 -0
@@ -610,6 +610,13 @@#define ADI_GNICEPLUS_PID 0xF001/* +* Cypress WICED USB UART +*/ +#define CYPRESS_VID 0x04B4 +#define CYPRESS_WICED_BT_USB_PID 0x009B +#define CYPRESS_WICED_WL_USB_PID 0xF900 + +/* * Microchip Technology, Inc. * * MICROCHIP_VID (0x04D8) and MICROCHIP_USB_BOARD_PID (0x000A) are
PATCH 9/204 USB: serial: option: add support for TP-Link LTE module
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Henryk Heisig <[email protected]>
commit 837ddc4793a69b256ac5e781a5e729b448a8d983 upstream.
This commit adds support for TP-Link LTE mPCIe module is used in in TP-Link MR200v1, MR6400v1 and v2 routers.
--- drivers/usb/serial/option.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/serial/option.c +2 -0
@@ -524,6 +524,7 @@ static void option_instat_callback(struc/* TP-LINK Incorporated products */ #define TPLINK_VENDOR_ID 0x2357 +#define TPLINK_PRODUCT_LTE 0x000D#define TPLINK_PRODUCT_MA180 0x0201/* Changhong products */
@@ -2022,6 +2023,7 @@ static const struct usb_device_id option { USB_DEVICE(CELLIENT_VENDOR_ID, CELLIENT_PRODUCT_MEN200) }, { USB_DEVICE(PETATEL_VENDOR_ID, PETATEL_PRODUCT_NP10T_600A) }, { USB_DEVICE(PETATEL_VENDOR_ID, PETATEL_PRODUCT_NP10T_600E) }, + { USB_DEVICE_AND_INTERFACE_INFO(TPLINK_VENDOR_ID, TPLINK_PRODUCT_LTE, 0xff, 0x00, 0x00) }, /* TP-Link LTE Module */ { USB_DEVICE(TPLINK_VENDOR_ID, TPLINK_PRODUCT_MA180), .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, { USB_DEVICE(TPLINK_VENDOR_ID, 0x9000), /* TP-Link MA260 */
PATCH 10/204 uwb: ensure that endpoint is interrupt
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Konovalov <[email protected]>
commit 70e743e4cec3733dc13559f6184b35d358b9ef3f upstream.
hwarc_neep_init() assumes that endpoint 0 is interrupt, but there's no check for that, which results in a WARNING in USB core code, when a bad USB descriptor is provided from a device:
usb 1-1: BOGUS urb xfer, pipe 1 != type 3
------------[ cut here ]------------ WARNING: CPU: 0 PID: 3 at drivers/usb/core/urb.c:449 usb_submit_urb+0xf8a/0x11d0 Modules linked in: CPU: 0 PID: 3 Comm: kworker/0:0 Not tainted 4.13.0+ #111 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 Workqueue: usb_hub_wq hub_event task: ffff88006bdc1a00 task.stack: ffff88006bde8000 RIP: 0010:usb_submit_urb+0xf8a/0x11d0 drivers/usb/core/urb.c:448 RSP: 0018:ffff88006bdee3c0 EFLAGS: 00010282 RAX: 0000000000000029 RBX: ffff8800672a7200 RCX: 0000000000000000 RDX: 0000000000000029 RSI: ffff88006c815c78 RDI: ffffed000d7bdc6a RBP: ffff88006bdee4c0 R08: fffffbfff0fe00ff R09: fffffbfff0fe00ff R10: 0000000000000018 R11: fffffbfff0fe00fe R12: 1ffff1000d7bdc7f R13: 0000000000000003 R14: 0000000000000001 R15: ffff88006b02cc90 FS: 0000000000000000(0000) GS:ffff88006c800000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fe4daddf000 CR3: 000000006add6000 CR4: 00000000000006f0 Call Trace: hwarc_neep_init+0x4ce/0x9c0 drivers/uwb/hwa-rc.c:710 uwb_rc_add+0x2fb/0x730 drivers/uwb/lc-rc.c:361 hwarc_probe+0x34e/0x9b0 drivers/uwb/hwa-rc.c:858 usb_probe_interface+0x351/0x8d0 drivers/usb/core/driver.c:361 really_probe drivers/base/dd.c:385 driver_probe_device+0x610/0xa00 drivers/base/dd.c:529 __device_attach_driver+0x230/0x290 drivers/base/dd.c:625 bus_for_each_drv+0x15e/0x210 drivers/base/bus.c:463 __device_attach+0x269/0x3c0 drivers/base/dd.c:682 device_initial_probe+0x1f/0x30 drivers/base/dd.c:729 bus_probe_device+0x1da/0x280 drivers/base/bus.c:523 device_add+0xcf9/0x1640 drivers/base/core.c:1703 usb_set_configuration+0x1064/0x1890 drivers/usb/core/message.c:1932 generic_probe+0x73/0xe0 drivers/usb/core/generic.c:174 usb_probe_device+0xaf/0xe0 drivers/usb/core/driver.c:266 really_probe drivers/base/dd.c:385 driver_probe_device+0x610/0xa00 drivers/base/dd.c:529 __device_attach_driver+0x230/0x290 drivers/base/dd.c:625 bus_for_each_drv+0x15e/0x210 drivers/base/bus.c:463 __device_attach+0x269/0x3c0 drivers/base/dd.c:682 device_initial_probe+0x1f/0x30 drivers/base/dd.c:729 bus_probe_device+0x1da/0x280 drivers/base/bus.c:523 device_add+0xcf9/0x1640 drivers/base/core.c:1703 usb_new_device+0x7b8/0x1020 drivers/usb/core/hub.c:2457 hub_port_connect drivers/usb/core/hub.c:4890 hub_port_connect_change drivers/usb/core/hub.c:4996 port_event drivers/usb/core/hub.c:5102 hub_event+0x23c8/0x37c0 drivers/usb/core/hub.c:5182 process_one_work+0x9fb/0x1570 kernel/workqueue.c:2097 worker_thread+0x1e4/0x1350 kernel/workqueue.c:2231 kthread+0x324/0x3f0 kernel/kthread.c:231 ret_from_fork+0x25/0x30 arch/x86/entry/entry_64.S:425 Code: 48 8b 85 30 ff ff ff 48 8d b8 98 00 00 00 e8 8e 93 07 ff 45 89 e8 44 89 f1 4c 89 fa 48 89 c6 48 c7 c7 a0 e5 55 86 e8 20 08 8f fd <0f> ff e9 9b f7 ff ff e8 4a 04 d6 fd e9 80 f7 ff ff e8 60 11 a6 ---[ end trace 55d741234124cfc3 ]---
Check that endpoint is interrupt.
Found by syzkaller.
--- drivers/uwb/hwa-rc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/uwb/hwa-rc.c +2 -0
@@ -827,6 +827,8 @@ static int hwarc_probe(struct usb_interfif (iface->cur_altsetting->desc.bNumEndpoints <1 )return -ENODEV ; +if (!usb_endpoint_xfer_int (&iface->cur_altsetting->endpoint[0 ].desc)) +return -ENODEV ; result = -ENOMEM ; uwb_rc =uwb_rc_alloc ();
PATCH 11/204 uwb: properly check kthread_run return value
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Konovalov <[email protected]>
commit bbf26183b7a6236ba602f4d6a2f7cade35bba043 upstream.
uwbd_start() calls kthread_run() and checks that the return value is not NULL. But the return value is not NULL in case kthread_run() fails, it takes the form of ERR_PTR(-EINTR).
Use IS_ERR() instead.
Also add a check to uwbd_stop().
--- drivers/uwb/uwbd.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/uwb/uwbd.c +8 -4
@@ -303,18 +303,22 @@ static int uwbd(void *param)/** Start the UWB daemon */ void uwbd_start (struct uwb_rc *rc) { - rc->uwbd.task =kthread_run (uwbd, rc,"uwbd" ); -if (rc->uwbd.task ==NULL ) +struct task_struct *task =kthread_run (uwbd, rc,"uwbd" ); +if (IS_ERR (task)) { + rc->uwbd.task =NULL ;printk (KERN_ERR "UWB: Cannot start management daemon; " "UWB won't work\n" ); -else + }else { + rc->uwbd.task = task; rc->uwbd.pid = rc->uwbd.task->pid; + } }/* Stop the UWB daemon and free any unprocessed events */ void uwbd_stop (struct uwb_rc *rc) { -kthread_stop (rc->uwbd.task); +if (rc->uwbd.task) +kthread_stop (rc->uwbd.task);uwbd_flush (rc); }
PATCH 12/204 usb: Increase quirk delay for USB devices
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Fleytman <[email protected]>
commit b2a542bbb3081dbd64acc8929c140d196664c406 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.
The workaround is introducing delay for some USB operations.
According to our testing, delay introduced by original commit is not long enough and in rare cases we still see issues described by the aforementioned commit.
This patch increases delays introduced by original commit. Having this patch applied we do not see those problems anymore.
--- drivers/usb/core/config.c | 2 +- drivers/usb/core/hub.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/usb/core/config.c +1 -1
@@ -824,7 +824,7 @@ int usb_get_configuration(struct usb_dev }if (dev->quirks &USB_QUIRK_DELAY_INIT ) -msleep (100 ); +msleep (200 ); result =usb_get_descriptor (dev,USB_DT_CONFIG , cfgno, bigbuffer, length);
drivers/usb/core/hub.c +1 -1
@@ -4699,7 +4699,7 @@ static void hub_port_connect(struct usb_ goto loop;if (udev->quirks &USB_QUIRK_DELAY_INIT ) -msleep (1000 ); +msleep (2000 );/* consecutive bus-powered hubs aren't reliable; they can * violate the voltage drop budget. if the new child has
PATCH 13/204 xhci: fix finding correct bus_state structure for USB 3.1 hosts
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit 5a838a13c9b4e5dd188b7a6eaeb894e9358ead0c upstream.
xhci driver keeps a bus_state structure for each hcd (usb2 and usb3)
The structure is picked based on hcd speed, but driver only compared for HCD_USB3 speed, returning the wrong bus_state for HCD_USB31 hosts.
This caused null pointer dereference errors in bus_resume function.
--- drivers/usb/host/xhci.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci.h +1 -1
@@ -1437,7 +1437,7 @@ struct xhci_bus_state {static inline unsigned int hcd_index (struct usb_hcd *hcd) { -if (hcd->speed ==HCD_USB3 ) +if (hcd->speed >=HCD_USB3 )return 0 ;else return 1 ;
PATCH 14/204 usb: pci-quirks.c: Corrected timeout values used in handshake
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jim Dickerson <[email protected]>
commit 114ec3a6f9096d211a4aff4277793ba969a62c73 upstream.
Servers were emitting failed handoff messages but were not waiting the full 1 second as designated in section 4.22.1 of the eXtensible Host Controller Interface specifications. The handshake was using wrong units so calls were made with milliseconds not microseconds. Comments referenced 5 seconds not 1 second as in specs.
The wrong units were also corrected in a second handshake call.
--- drivers/usb/host/pci-quirks.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/host/pci-quirks.c +4 -4
@@ -1024,7 +1024,7 @@ EXPORT_SYMBOL_GPL(usb_disable_xhci_ports* * Takes care of the handoff between the Pre-OS (i.e. BIOS) and the OS. * It signals to the BIOS that the OS wants control of the host controller, -* and then waits 5 seconds for the BIOS to hand over control. +* and then waits 1 second for the BIOS to hand over control. * If we timeout, assume the BIOS is broken and take control anyway. */ static void quirk_usb_handoff_xhci (struct pci_dev *pdev)
@@ -1070,9 +1070,9 @@ static void quirk_usb_handoff_xhci(strucif (val &XHCI_HC_BIOS_OWNED ) {writel (val |XHCI_HC_OS_OWNED , base + ext_cap_offset); -/* Wait for 5 seconds with 10 microsecond polling interval */ +/* Wait for 1 second with 10 microsecond polling interval */ timeout =handshake (base + ext_cap_offset,XHCI_HC_BIOS_OWNED , -0 ,5000 ,10 ); +0 ,1000000 ,10 );/* Assume a buggy BIOS and take HC ownership anyway */ if (timeout) {
@@ -1100,7 +1100,7 @@ hc_init:* operational or runtime registers. Wait 5 seconds and no more. */ timeout =handshake (op_reg_base +XHCI_STS_OFFSET ,XHCI_STS_CNR ,0 , -5000 ,10 ); +5000000 ,10 );/* Assume a buggy HC and start HC initialization anyway */ if (timeout) { val =readl (op_reg_base +XHCI_STS_OFFSET );
PATCH 15/204 ip6_gre: skb_push ipv6hdr before packing the header in ip6gre_header
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
commit 76cc0d3282d4b933fa144fa41fbc5318e0fdca24 upstream.
Now in ip6gre_header before packing the ipv6 header, it skb_push t->hlen which only includes encap_hlen + tun_hlen. It means greh and inner header would be over written by ipv6 stuff and ipv6h might have no chance to set up.
Jianlin found this issue when using remote any on ip6_gre, the packets he captured on gre dev are truncated:
22:50:26.210866 Out ethertype IPv6 (0x86dd), length 120: truncated-ip6 -\
8128 bytes missing!(flowlabel 0x92f40, hlim 0, next-header Options (0) \
payload length: 8192) ::1:2000:0 > ::1:0:86dd: HBH [trunc] ip-proto-128 \
8184
It should also skb_push ipv6hdr so that ipv6h points to the right position to set ipv6 stuff up.
This patch is to skb_push hlen + sizeof(*ipv6h) and also fix some indents in ip6gre_header.
---
net/ipv6/ip6_gre.c +8 -6
@@ -1172,21 +1172,23 @@ static int ip6gre_tunnel_change_mtu(stru }static int ip6gre_header (struct sk_buff *skb,struct net_device *dev, -unsigned short type, -const void *daddr,const void *saddr,unsigned int len) +unsigned short type,const void *daddr, +const void *saddr,unsigned int len) {struct ip6_tnl *t =netdev_priv (dev); -struct ipv6hdr *ipv6h = (struct ipv6hdr *)skb_push (skb, t->hlen); -__be16 *p = (__be16 *)(ipv6h+1 ); +struct ipv6hdr *ipv6h; +__be16 *p; + ipv6h = (struct ipv6hdr *)skb_push (skb, t->hlen +sizeof (*ipv6h));ip6_flow_hdr (ipv6h,0 , t->fl.u.ip6.flowlabel); ipv6h->hop_limit = t->parms.hop_limit; ipv6h->nexthdr =NEXTHDR_GRE ; ipv6h->saddr = t->parms.laddr; ipv6h->daddr = t->parms.raddr; - p[0 ] = t->parms.o_flags; - p[1 ] =htons (type); + p = (__be16 *)(ipv6h +1 ); + p[0 ] = t->parms.o_flags; + p[1 ] =htons (type);/* * Set the source hardware address.
PATCH 16/204 s390/mm: fix write access check in gup_huge_pmd()
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Gerald Schaefer <[email protected]>
commit ba385c0594e723d41790ecfb12c610e6f90c7785 upstream.
The check for the _SEGMENT_ENTRY_PROTECT bit in gup_huge_pmd() is the wrong way around. It must not be set for write==1, and not be checked for write==0. Fix this similar to how it was fixed for ptes long time ago in commit 25591b070336 ("[S390] fix get_user_pages_fast").
One impact of this bug would be unnecessarily using the gup slow path for write==0 on r/w mappings. A potentially more severe impact would be that gup_huge_pmd() will succeed for write==1 on r/o mappings.
--- arch/s390/mm/gup.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
arch/s390/mm/gup.c +3 -4
@@ -51,13 +51,12 @@ static inline int gup_pte_range(pmd_t *pstatic inline int gup_huge_pmd (pmd_t *pmdp,pmd_t pmd,unsigned long addr,unsigned long end,int write,struct page **pages,int *nr) { -unsigned long mask, result;struct page *head, *page, *tail; +unsigned long mask;int refs; - result = write ?0 : _SEGMENT_ENTRY_PROTECT; - mask = result | _SEGMENT_ENTRY_INVALID; -if ((pmd_val (pmd) & mask) != result) + mask = (write ? _SEGMENT_ENTRY_PROTECT :0 ) | _SEGMENT_ENTRY_INVALID; +if ((pmd_val (pmd) & mask) !=0 )return 0 ;VM_BUG_ON (!pfn_valid (pmd_val (pmd) >>PAGE_SHIFT ));
PATCH 17/204 gpio: acpi: work around false-positive -Wstring-overflow warning
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit e40a3ae1f794a35c4af3746291ed6fedc1fa0f6f upstream.
gcc-7 notices that the pin_table is an array of 16-bit numbers, but fails to take the following range check into account:
drivers/gpio/gpiolib-acpi.c: In function 'acpi_gpiochip_request_interrupt':drivers/gpio/gpiolib-acpi.c:206:24: warning: '%02X' directive writing between 2 and 4 bytes into a region of size 3 [-Wformat-overflow=]
sprintf(ev_name, "_%c%02X",
^~~~
drivers/gpio/gpiolib-acpi.c:206:20: note: directive argument in the range [0, 65535]
sprintf(ev_name, "_%c%02X",
^~~~~~~~~
drivers/gpio/gpiolib-acpi.c:206:3: note: 'sprintf' output between 5 and 7 bytes into a destination of size 5
sprintf(ev_name, "_%c%02X",
^~~~~~~~~~~~~~~~~~~~~~~~~~~
agpio->triggering == ACPI_EDGE_SENSITIVE ? 'E' : 'L',
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pin);
~~~~As suggested by Andy, this changes the format string to have a fixed length. Since modifying the range check did not help, I also opened a bug against gcc, see link below.
--- drivers/gpio/gpiolib-acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpiolib-acpi.c +1 -1
@@ -130,7 +130,7 @@ static acpi_status acpi_gpiochip_requestif (pin <=255 ) {char ev_name[5 ]; -sprintf (ev_name,"_%c%02X" , +sprintf (ev_name,"_%c%02hhX" , agpio->triggering ==ACPI_EDGE_SENSITIVE ?'E' :'L' , pin);if (ACPI_SUCCESS (acpi_get_handle (handle, ev_name, &evt_handle)))
PATCH 18/204 USB: serial: cp210x: add support for ELV TFD500
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Engel <[email protected]>
commit c496ad835c31ad639b6865714270b3003df031f6 upstream.
Add the USB device id for the ELV TFD500 data logger.
--- drivers/usb/serial/cp210x.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/serial/cp210x.c +1 -0
@@ -170,6 +170,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, 0xE032) }, /* ELV TFD500 Data Logger */ { USB_DEVICE(0x1901, 0x0190) }, /* GE B850 CP2105 Recorder interface */ { USB_DEVICE(0x1901, 0x0193) }, /* GE B650 CP2104 PMC interface */ { USB_DEVICE(0x1901, 0x0194) }, /* GE Healthcare Remote Alarm Box */
PATCH 19/204 tracing: Erase irqsoff trace with empty write
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Bo Yan <[email protected]>
commit 8dd33bcb7050dd6f8c1432732f930932c9d3a33e upstream.
One convenient way to erase trace is "echo > trace". However, this is currently broken if the current tracer is irqsoff tracer. This is because irqsoff tracer use max_buffer as the default trace buffer.
Set the max_buffer as the one to be cleared when it's the trace buffer currently in use.
--- kernel/trace/trace.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
kernel/trace/trace.c +8 -2
@@ -3191,11 +3191,17 @@ static int tracing_open(struct inode *in/* If this file was open for write, then erase contents */ if ((file->f_mode &FMODE_WRITE ) && (file->f_flags &O_TRUNC )) {int cpu =tracing_get_cpu (inode); +struct trace_buffer *trace_buf = &tr->trace_buffer; + +#ifdef CONFIG_TRACER_MAX_TRACE +if (tr->current_trace->print_max) + trace_buf = &tr->max_buffer; +#endif if (cpu ==RING_BUFFER_ALL_CPUS ) -tracing_reset_online_cpus (&tr->trace_buffer); +tracing_reset_online_cpus (trace_buf);else -tracing_reset (&tr->trace_buffer, cpu); +tracing_reset (trace_buf, cpu); }if (file->f_mode &FMODE_READ ) {
PATCH 20/204 tracing: Fix trace_pipe behavior for instance traces
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Tahsin Erdogan <[email protected]>
commit 75df6e688ccd517e339a7c422ef7ad73045b18a2 upstream.
When reading data from trace_pipe, tracing_wait_pipe() performs a check to see if tracing has been turned off after some data was read. Currently, this check always looks at global trace state, but it should be checking the trace instance where trace_pipe is located at.
Because of this bug, cat instances/i1/trace_pipe in the following script will immediately exit instead of waiting for data:
cd /sys/kernel/debug/tracing
echo 0 > tracing_on
mkdir -p instances/i1
echo 1 > instances/i1/tracing_on
echo 1 > instances/i1/events/sched/sched_process_exec/enable cat instances/i1/trace_pipe
--- kernel/trace/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace.c +1 -1
@@ -4414,7 +4414,7 @@ static int tracing_wait_pipe(struct file* * iter->pos will be 0 if we haven't read anything. */ -if (!tracing_is_on () && iter->pos) +if (!tracer_tracing_is_on (iter->tr) && iter->pos)break ;mutex_unlock (&iter->mutex);
PATCH 21/204 tcp: fastopen: fix on syn-data transmit failure
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit b5b7db8d680464b1d631fd016f5e093419f0bfd9 upstream.
Our recent change exposed a bug in TCP Fastopen Client that syzkaller found right away [1]
When we prepare skb with SYN+DATA, we attempt to transmit it, and we update socket state as if the transmit was a success.
In socket RTX queue we have two skbs, one with the SYN alone, and a second one containing the DATA.
When (malicious) ACK comes in, we now complain that second one had no skb_mstamp.
The proper fix is to make sure that if the transmit failed, we do not pretend we sent the DATA skb, and make it our send_head.
When 3WHS completes, we can now send the DATA right away, without having to wait for a timeout.
[1]
WARNING: CPU: 0 PID: 100189 at net/ipv4/tcp_input.c:3117 tcp_clean_rtx_queue+0x2057/0x2ab0 net/ipv4/tcp_input.c:3117()
WARN_ON_ONCE(last_ackt == 0);
Modules linked in: CPU: 0 PID: 100189 Comm: syz-executor1 Not tainted Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 0000000000000000 ffff8800b35cb1d8 ffffffff81cad00d 0000000000000000 ffffffff828a4347 ffff88009f86c080 ffffffff8316eb20 0000000000000d7f ffff8800b35cb220 ffffffff812c33c2 ffff8800baad2440 00000009d46575c0 Call Trace: [<ffffffff81cad00d>] __dump_stack [<ffffffff81cad00d>] dump_stack+0xc1/0x124 [<ffffffff812c33c2>] warn_slowpath_common+0xe2/0x150 [<ffffffff812c361e>] warn_slowpath_null+0x2e/0x40 [<ffffffff828a4347>] tcp_clean_rtx_queue+0x2057/0x2ab0 n [<ffffffff828ae6fd>] tcp_ack+0x151d/0x3930 [<ffffffff828baa09>] tcp_rcv_state_process+0x1c69/0x4fd0 [<ffffffff828efb7f>] tcp_v4_do_rcv+0x54f/0x7c0 [<ffffffff8258aacb>] sk_backlog_rcv [<ffffffff8258aacb>] __release_sock+0x12b/0x3a0 [<ffffffff8258ad9e>] release_sock+0x5e/0x1c0 [<ffffffff8294a785>] inet_wait_for_connect [<ffffffff8294a785>] __inet_stream_connect+0x545/0xc50 [<ffffffff82886f08>] tcp_sendmsg_fastopen [<ffffffff82886f08>] tcp_sendmsg+0x2298/0x35a0 [<ffffffff82952515>] inet_sendmsg+0xe5/0x520 [<ffffffff8257152f>] sock_sendmsg_nosec [<ffffffff8257152f>] sock_sendmsg+0xcf/0x110
--- net/ipv4/tcp_output.c | 9 +++++++++ 1 file changed, 9 insertions(+)
net/ipv4/tcp_output.c +9 -0
@@ -3058,6 +3058,10 @@ static int tcp_send_syn_data(struct sock goto done; } +/* data was not sent, this is our new send_head */ + sk->sk_send_head = syn_data; + tp->packets_out -=tcp_skb_pcount (syn_data); + fallback:/* Send a regular SYN with Fast Open cookie request option */ if (fo->cookie.len >0 )
@@ -3104,6 +3108,11 @@ int tcp_connect(struct sock *sk)*/ tp->snd_nxt = tp->write_seq; tp->pushed_seq = tp->write_seq; + buff =tcp_send_head (sk); +if (unlikely (buff)) { + tp->snd_nxt =TCP_SKB_CB (buff)->seq; + tp->pushed_seq =TCP_SKB_CB (buff)->seq; + }TCP_INC_STATS (sock_net (sk),TCP_MIB_ACTIVEOPENS );/* Timer for repeating the SYN until an answer. */
PATCH 22/204 powerpc/sysrq: Fix oops whem ppmu is not registered
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ravi Bangoria <[email protected]>
commit 4917fcb58cc73f6b81455e3c5f960144809ddf1a upstream.
Kernel crashes if power pmu is not registered and user tries to dump regs with 'echo p > /proc/sysrq-trigger'. Sample log:
Unable to handle kernel paging request for data at address 0x00000008 Faulting instruction address: 0xc0000000000d52f0
NIP [c0000000000d52f0] perf_event_print_debug+0x10/0x230 LR [c00000000058a938] sysrq_handle_showregs+0x38/0x50
Call Trace: printk+0x38/0x4c (unreliable) __handle_sysrq+0xe4/0x270 write_sysrq_trigger+0x64/0x80 proc_reg_write+0x80/0xd0 __vfs_write+0x40/0x200 vfs_write+0xc8/0x240 SyS_write+0x60/0x110 system_call+0x58/0x6c
--- arch/powerpc/perf/core-book3s.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/powerpc/perf/core-book3s.c +5 -0
@@ -755,6 +755,11 @@ void perf_event_print_debug(void)u32 pmcs[MAX_HWEVENTS ];int i; +if (!ppmu) { +pr_info ("Performance monitor hardware not registered.\n" ); +return ; + } +if (!ppmu->n_counter)return ;
PATCH 23/204 ARM: dts: da850-evm: add serial and ethernet aliases
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sekhar Nori <[email protected]>
commit ce21574ad1922b403198ee664c4dff276f514f1d upstream.
Add aliases for serial and ethernet nodes. Serial
aliases help keep order of tty nodes fixed and
ethernet alias is used by bootloader to setup mac
address correctly.
--- arch/arm/boot/dts/da850-evm.dts | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm/boot/dts/da850-evm.dts +7 -0
@@ -14,6 +14,13 @@ compatible = "ti,da850-evm", "ti,da850"; model = "DA850/AM1808/OMAP-L138 EVM"; + aliases { + serial0 = &serial0; + serial1 = &serial1; + serial2 = &serial2; + ethernet0 = ð0; + }; + soc { pmx_core: pinmux@1c14120 { status = "okay";
PATCH 24/204 crypto: talitos - fix sha224
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: LEROY Christophe <[email protected]>
commit afd62fa26343be6445479e75de9f07092a061459 upstream.
Kernel crypto tests report the following error at startup
[ 2.752626] alg: hash: Test 4 failed for sha224-talitos [ 2.757907] 00000000: 30 e2 86 e2 e7 8a dd 0d d7 eb 9f d5 83 fe f1 b0
00000010: 2d 5a 6c a5 f9 55 ea fd 0e 72 05 22
This patch fixes it
--- drivers/crypto/talitos.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/talitos.c +2 -2
@@ -1581,9 +1581,9 @@ static int common_nonsnoop_hash(struct t req_ctx->swinit =0 ; }else { desc->ptr[1 ] = zero_entry; -/* Indicate next op is not the first. */ - req_ctx->first =0 ; } +/* Indicate next op is not the first. */ + req_ctx->first =0 ;/* HMAC key */ if (ctx->keylen)
PATCH 25/204 crypto: talitos - Don't provide setkey for non hmac hashing algs.
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: LEROY Christophe <[email protected]>
commit 56136631573baa537a15e0012055ffe8cfec1a33 upstream.
Today, md5sum fails with error -ENOKEY because a setkey function is set for non hmac hashing algs, see strace output below:
mmap(NULL, 378880, PROT_READ, MAP_SHARED, 6, 0) = 0x77f50000accept(3, 0, NULL) = 7
vmsplice(5, [{"bin/\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 378880}], 1, SPLICE_F_MORE|SPLICE_F_GIFT) = 262144 splice(4, NULL, 7, NULL, 262144, SPLICE_F_MORE) = -1 ENOKEY (Required key not available)write(2, "Generation of hash for file kcap"..., 50) = 50munmap(0x77f50000, 378880) = 0
This patch ensures that setkey() function is set only for hmac hashing.
--- drivers/crypto/talitos.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/talitos.c +2 -1
@@ -2550,7 +2550,8 @@ static struct talitos_crypto_alg *talito t_alg->algt.alg.hash.final = ahash_final; t_alg->algt.alg.hash.finup = ahash_finup; t_alg->algt.alg.hash.digest = ahash_digest; - t_alg->algt.alg.hash.setkey = ahash_setkey; +if (!strncmp (alg->cra_name,"hmac" ,4 )) + t_alg->algt.alg.hash.setkey = ahash_setkey;if (!(priv->features &TALITOS_FTR_HMAC_OK ) && !strncmp (alg->cra_name,"hmac" ,4 )) {
PATCH 26/204 usb: gadget: dummy: fix nonsensical comparisons
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit 7661ca09b2ff98f48693f431bb01fed62830e433 upstream.
gcc-8 points out two comparisons that are clearly bogus and almost certainly not what the author intended to write:
drivers/usb/gadget/udc/dummy_hcd.c: In function 'set_link_state_by_speed':drivers/usb/gadget/udc/dummy_hcd.c:379:31: error: bitwise comparison always evaluates to false [-Werror=tautological-compare]
USB_PORT_STAT_ENABLE) == 1 &&
^~
drivers/usb/gadget/udc/dummy_hcd.c:381:25: error: bitwise comparison always evaluates to false [-Werror=tautological-compare]
USB_SS_PORT_LS_U0) == 1 &&
^~I looked at the code for a bit and came up with a change that makes it look like what the author probably meant here. This makes it look reasonable to me and to gcc, shutting up the warning.
It does of course change behavior as the two conditions are actually evaluated rather than being hardcoded to false, and I have made no attempt at verifying that the changed logic makes sense in the context of a USB HCD, so that part needs to be reviewed carefully.
--- drivers/usb/gadget/dummy_hcd.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/usb/gadget/dummy_hcd.c +4 -5
@@ -311,11 +311,10 @@ static void set_link_state_by_speed(stru USB_PORT_STAT_CONNECTION) == 0) dum_hcd->port_status |= (USB_PORT_STAT_C_CONNECTION <<16 ); -if ((dum_hcd->port_status & -USB_PORT_STAT_ENABLE ) ==1 && - (dum_hcd->port_status & -USB_SS_PORT_LS_U0 ) ==1 && - dum_hcd->rh_state !=DUMMY_RH_SUSPENDED ) +if ((dum_hcd->port_status &USB_PORT_STAT_ENABLE ) && + (dum_hcd->port_status & +USB_PORT_STAT_LINK_STATE ) ==USB_SS_PORT_LS_U0 && + dum_hcd->rh_state !=DUMMY_RH_SUSPENDED ) dum_hcd->active =1 ; } }else {
PATCH 27/204 cifs: release cifs root_cred after exit_cifs
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Shu Wang <[email protected]>
commit 94183331e815617246b1baa97e0916f358c794bb upstream.
memory leak was found by kmemleak. exit_cifs_spnego should be called before cifs module removed, or cifs root_cred will not be released.
kmemleak report:
unreferenced object 0xffff880070a3ce40 (size 192):
backtrace:
kmemleak_alloc+0x4a/0xa0
kmem_cache_alloc+0xc7/0x1d0
prepare_kernel_cred+0x20/0x120
init_cifs_spnego+0x2d/0x170 [cifs]
0xffffffffc07801f3
do_one_initcall+0x51/0x1b0
do_init_module+0x60/0x1fd
load_module+0x161e/0x1b60
SYSC_finit_module+0xa9/0x100
SyS_finit_module+0xe/0x10--- fs/cifs/cifsfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/cifsfs.c +1 -1
@@ -1294,7 +1294,7 @@ exit_cifs(void)exit_cifs_idmap ();#endif #ifdef CONFIG_CIFS_UPCALL -unregister_key_type (&cifs_spnego_key_type); +exit_cifs_spnego ();#endif cifs_destroy_request_bufs ();cifs_destroy_mids ();
PATCH 28/204 cifs: release auth_key.response for reconnect.
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Shu Wang <[email protected]>
commit f5c4ba816315d3b813af16f5571f86c8d4e897bd upstream.
There is a race that cause cifs reconnect in cifs_mount,
- cifs_mount
- cifs_get_tcp_session
- [ start thread cifs_demultiplex_thread
- cifs_read_from_socket: -ECONNABORTED
- DELAY_WORK smb2_reconnect_server ]
- cifs_setup_session
- [ smb2_reconnect_server ]
auth_key.response was allocated in cifs_setup_session, and will release when the session destoried. So when session re- connect, auth_key.response should be check and released.
Tested with my system:
CIFS VFS: Free previous auth_key.response = ffff8800320bbf80
A simple auth_key.response allocation call trace:
- cifs_setup_session
- SMB2_sess_setup
- SMB2_sess_auth_rawntlmssp_authenticate
- build_ntlmssp_auth_blob
- setup_ntlmv2_rsp
--- fs/cifs/connect.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/cifs/connect.c +8 -0
@@ -3956,6 +3956,14 @@ cifs_setup_session(const unsigned int xicifs_dbg (FYI ,"Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d\n" , server->sec_mode, server->capabilities, server->timeAdj); +if (ses->auth_key.response) { +cifs_dbg (VFS ,"Free previous auth_key.response = %p\n" , + ses->auth_key.response); +kfree (ses->auth_key.response); + ses->auth_key.response =NULL ; + ses->auth_key.len =0 ; + } +if (server->ops->sess_setup) rc = server->ops->sess_setup (xid, ses, nls_info);
PATCH 29/204 SMB: Validate negotiate (to protect against downgrade) even if signing off
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit 0603c96f3af50e2f9299fa410c224ab1d465e0f9 upstream.
As long as signing is supported (ie not a guest user connection) and connection is SMB3 or SMB3.02, then validate negotiate (protect against man in the middle downgrade attacks). We had been doing this only when signing was required, not when signing was just enabled, but this more closely matches recommended SMB3 behavior and is better security. Suggested by Metze.
--- fs/cifs/smb2pdu.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
fs/cifs/smb2pdu.c +12 -5
@@ -486,15 +486,22 @@ int smb3_validate_negotiate(const unsign/* * validation ioctl must be signed, so no point sending this if we -* can not sign it. We could eventually change this to selectively +* can not sign it (ie are not known user). Even if signing is not +* required (enabled but not negotiated), in those cases we selectively * sign just this, the first and only signed request on a connection. -* This is good enough for now since a user who wants better security -* would also enable signing on the mount. Having validation of -* negotiate info for signed connections helps reduce attack vectors +* Having validation of negotiate info helps reduce attack vectors. */ -if (tcon->ses->server->sign == false) +if (tcon->ses->session_flags &SMB2_SESSION_FLAG_IS_GUEST )return 0 ;/* validation requires signing */ +if (tcon->ses->user_name ==NULL ) { +cifs_dbg (FYI ,"Can't validate negotiate: null user mount\n" ); +return 0 ;/* validation requires signing */ + } + +if (tcon->ses->session_flags &SMB2_SESSION_FLAG_IS_NULL ) +cifs_dbg (VFS ,"Unexpected null user (anonymous) auth flag sent by server\n" ); + vneg_inbuf.Capabilities =cpu_to_le32 (tcon->ses->server->vals->req_capabilities); memcpy(vneg_inbuf.Guid, tcon->ses->server->client_guid,
PATCH 30/204 powerpc/pseries: Fix parent_dn reference leak in add_dt_node()
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Tyrel Datwyler <[email protected]>
commit b537ca6fede69a281dc524983e5e633d79a10a08 upstream.
A reference to the parent device node is held by add_dt_node() for the node to be added. If the call to dlpar_configure_connector() fails add_dt_node() returns ENOENT and that reference is not freed.
Add a call to of_node_put(parent_dn) prior to bailing out after a failed dlpar_configure_connector() call.
--- arch/powerpc/platforms/pseries/mobility.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/powerpc/platforms/pseries/mobility.c +3 -1
@@ -224,8 +224,10 @@ static int add_dt_node(__be32 parent_phareturn -ENOENT ; dn =dlpar_configure_connector (drc_index, parent_dn); -if (!dn) +if (!dn) { +of_node_put (parent_dn);return -ENOENT ; + } rc =dlpar_attach_node (dn);if (rc)
PATCH 31/204 net_sched: always reset qdisc backlog in qdisc_reset()
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Konstantin Khlebnikov <[email protected]>
commit c8e1812960eeae42e2183154927028511c4bc566 upstream.
SKB stored in qdisc->gso_skb also counted into backlog.
Some qdiscs don't reset backlog to zero in ->reset(), for example sfq just dequeue and free all queued skb.
--- net/sched/sch_generic.c | 1 + 1 file changed, 1 insertion(+)
net/sched/sch_generic.c +1 -0
@@ -621,6 +621,7 @@ void qdisc_reset(struct Qdisc *qdisc) qdisc->gso_skb =NULL ; qdisc->q.qlen =0 ; } + qdisc->qstats.backlog =0 ; }EXPORT_SYMBOL (qdisc_reset);
PATCH 32/204 Input: uinput - avoid FF flush when destroying device
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Torokhov <[email protected]>
commit e8b95728f724797f958912fd9b765a695595d3a6 upstream.
Normally, when input device supporting force feedback effects is being destroyed, we try to "flush" currently playing effects, so that the physical device does not continue vibrating (or executing other effects). Unfortunately this does not work well for uinput as flushing of the effects deadlocks with the destroy action:
- if device is being destroyed because the file descriptor is being closed, then there is noone to even service FF requests;
- if device is being destroyed because userspace sent UI_DEV_DESTROY, while theoretically it could be possible to service FF requests, userspace is unlikely to do so (they'd need to make sure FF handling happens on a separate thread) even if kernel solves the issue with FF ioctls deadlocking with UI_DEV_DESTROY ioctl on udev->mutex.
To avoid lockups like the one below, let's install a custom input device flush handler, and avoid trying to flush force feedback effects when we destroying the device, and instead rely on uinput to shut off the device properly.
NMI watchdog: Watchdog detected hard LOCKUP on cpu 3
...
<<EOE>> [<ffffffff817a0307>] _raw_spin_lock_irqsave+0x37/0x40
[<ffffffff810e633d>] complete+0x1d/0x50 [<ffffffffa00ba08c>] uinput_request_done+0x3c/0x40 [uinput] [<ffffffffa00ba587>] uinput_request_submit.part.7+0x47/0xb0 [uinput] [<ffffffffa00bb62b>] uinput_dev_erase_effect+0x5b/0x76 [uinput] [<ffffffff815d91ad>] erase_effect+0xad/0xf0 [<ffffffff815d929d>] flush_effects+0x4d/0x90 [<ffffffff815d4cc0>] input_flush_device+0x40/0x60 [<ffffffff815daf1c>] evdev_cleanup+0xac/0xc0 [<ffffffff815daf5b>] evdev_disconnect+0x2b/0x60 [<ffffffff815d74ac>] __input_unregister_device+0xac/0x150 [<ffffffff815d75f7>] input_unregister_device+0x47/0x70 [<ffffffffa00bac45>] uinput_destroy_device+0xb5/0xc0 [uinput] [<ffffffffa00bb2de>] uinput_ioctl_handler.isra.9+0x65e/0x740 [uinput] [<ffffffff811231ab>] ? do_futex+0x12b/0xad0 [<ffffffffa00bb3f8>] uinput_ioctl+0x18/0x20 [uinput] [<ffffffff81241248>] do_vfs_ioctl+0x298/0x480 [<ffffffff81337553>] ? security_file_ioctl+0x43/0x60 [<ffffffff812414a9>] SyS_ioctl+0x79/0x90 [<ffffffff817a04ee>] entry_SYSCALL_64_fastpath+0x12/0x71
--- drivers/input/ff-core.c | 13 ++++++++++--- drivers/input/misc/uinput.c | 18 ++++++++++++++++++ include/linux/input.h | 1 + 3 files changed, 29 insertions(+), 3 deletions(-)
drivers/input/ff-core.c +10 -3
@@ -239,9 +239,15 @@ int input_ff_erase(struct input_dev *devEXPORT_SYMBOL_GPL (input_ff_erase);/* -* flush_effects - erase all effects owned by a file handle +* input_ff_flush - erase all effects owned by a file handle +* @dev: input device to erase effect from +* @file: purported owner of the effects +* +* This function erases all force-feedback effects associated with +* the given owner from specified device. Note that @file may be %NULL, +* in which case all effects will be erased. */ -static int flush_effects (struct input_dev *dev,struct file *file) +int input_ff_flush (struct input_dev *dev,struct file *file) {struct ff_device *ff = dev->ff;int i;
@@ -257,6 +263,7 @@ static int flush_effects(struct input_dereturn 0 ; } +EXPORT_SYMBOL_GPL (input_ff_flush);/** * input_ff_event() - generic handler for force-feedback events
@@ -340,7 +347,7 @@ int input_ff_create(struct input_dev *demutex_init (&ff->mutex); dev->ff = ff; - dev->flush = flush_effects; + dev->flush = input_ff_flush; dev->event = input_ff_event;__set_bit (EV_FF , dev->evbit);
drivers/input/misc/uinput.c +18 -0
@@ -230,6 +230,18 @@ static int uinput_dev_erase_effect(strucreturn uinput_request_submit (udev, &request); } +static int uinput_dev_flush (struct input_dev *dev,struct file *file) +{ +/* +* If we are called with file == NULL that means we are tearing +* down the device, and therefore we can not handle FF erase +* requests: either we are handling UI_DEV_DESTROY (and holding +* the udev->mutex), or the file descriptor is closed and there is +* nobody on the other side anymore. +*/ +return file ?input_ff_flush (dev, file) :0 ; +} +static void uinput_destroy_device (struct uinput_device *udev) {const char *name, *phys;
@@ -273,6 +285,12 @@ static int uinput_create_device(struct u dev->ff->playback = uinput_dev_playback; dev->ff->set_gain = uinput_dev_set_gain; dev->ff->set_autocenter = uinput_dev_set_autocenter; +/* +* The standard input_ff_flush() implementation does +* not quite work for uinput as we can't reasonably +* handle FF requests during device teardown. +*/ + dev->flush = uinput_dev_flush; } error =input_register_device (udev->dev);
include/linux/input.h +1 -0
@@ -527,6 +527,7 @@ int input_ff_event(struct input_dev *devint input_ff_upload (struct input_dev *dev,struct ff_effect *effect,struct file *file);int input_ff_erase (struct input_dev *dev,int effect_id,struct file *file); +int input_ff_flush (struct input_dev *dev,struct file *file);int input_ff_create_memless (struct input_dev *dev,void *data,int (*play_effect)(struct input_dev *,void *,struct ff_effect *));
PATCH 33/204 Input: uinput - avoid crash when sending FF request to device going away
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Torokhov <[email protected]>
commit 6b4877c7bdc6ae39ce03716df7caeecf204697eb upstream.
If FF request comes in while uinput device is going away, uinput_request_send() will fail with -ENODEV, and uinput_request_submit() will attempt to mark the slot as unused by calling uinput_request_done(). Unfortunately in this case we haven't initialized request->done completion yet, and we get a crash:
[ 39.402036] BUG: spinlock bad magic on CPU#1, fftest/3108 [ 39.402046] lock: 0xffff88006a93bb00, .magic: 00000000, .owner: /39, .owner_cpu: 1217155072 [ 39.402055] CPU: 1 PID: 3108 Comm: fftest Tainted: G W 4.13.0+ #15 [ 39.402059] Hardware name: LENOVO 20HQS0EG02/20HQS0EG02, BIOS N1MET37W (1.22 ) 07/04/2017 [ 39.402064] 0000000000000086 f0fad82f3ceaa120 ffff88006a93b9a0 ffffffff9de941bb [ 39.402077] ffff88026df8ae00 ffff88006a93bb00 ffff88006a93b9c0 ffffffff9dca62b7 [ 39.402088] ffff88006a93bb00 ffff88006a93baf8 ffff88006a93b9e0 ffffffff9dca62e7 [ 39.402099] Call Trace: [ 39.402112] [<ffffffff9de941bb>] dump_stack+0x4d/0x63 [ 39.402123] [<ffffffff9dca62b7>] spin_dump+0x97/0x9c [ 39.402130] [<ffffffff9dca62e7>] spin_bug+0x2b/0x2d [ 39.402138] [<ffffffff9dca6373>] do_raw_spin_lock+0x28/0xfd [ 39.402147] [<ffffffff9e3055cd>] _raw_spin_lock_irqsave+0x19/0x1f [ 39.402154] [<ffffffff9dca05b7>] complete+0x1d/0x48 [ 39.402162] [<ffffffffc04f30af>] 0xffffffffc04f30af [ 39.402167] [<ffffffffc04f468c>] 0xffffffffc04f468c [ 39.402177] [<ffffffff9dd59c16>] ? __slab_free+0x22f/0x359 [ 39.402184] [<ffffffff9dcc13e9>] ? tk_clock_read+0xc/0xe [ 39.402189] [<ffffffffc04f471f>] 0xffffffffc04f471f [ 39.402195] [<ffffffff9dc9ffe5>] ? __wake_up+0x44/0x4b [ 39.402200] [<ffffffffc04f3240>] ? 0xffffffffc04f3240 [ 39.402207] [<ffffffff9e0f57f3>] erase_effect+0xa1/0xd2 [ 39.402214] [<ffffffff9e0f58c6>] input_ff_flush+0x43/0x5c [ 39.402219] [<ffffffffc04f32ad>] 0xffffffffc04f32ad [ 39.402227] [<ffffffff9e0f174f>] input_flush_device+0x3d/0x51 [ 39.402234] [<ffffffff9e0f69ae>] evdev_flush+0x49/0x5c [ 39.402243] [<ffffffff9dd62d6e>] filp_close+0x3f/0x65 [ 39.402253] [<ffffffff9dd7dcf7>] put_files_struct+0x66/0xc1 [ 39.402261] [<ffffffff9dd7ddeb>] exit_files+0x47/0x4e [ 39.402270] [<ffffffff9dc6b329>] do_exit+0x483/0x969 [ 39.402278] [<ffffffff9dc73211>] ? recalc_sigpending_tsk+0x3d/0x44 [ 39.402285] [<ffffffff9dc6c7a2>] do_group_exit+0x42/0xb0 [ 39.402293] [<ffffffff9dc767e1>] get_signal+0x58d/0x5bf [ 39.402300] [<ffffffff9dc03701>] do_signal+0x37/0x53e [ 39.402307] [<ffffffff9e0f8401>] ? evdev_ioctl_handler+0xac8/0xb04 [ 39.402314] [<ffffffff9e0f8464>] ? evdev_ioctl+0x10/0x12 [ 39.402321] [<ffffffff9dd74cfa>] ? do_vfs_ioctl+0x42e/0x501 [ 39.402328] [<ffffffff9dc0170e>] prepare_exit_to_usermode+0x66/0x90 [ 39.402333] [<ffffffff9dc0181b>] syscall_return_slowpath+0xe3/0xec [ 39.402339] [<ffffffff9e305b7b>] int_ret_from_sys_call+0x25/0x8f
While we could solve this by simply initializing the completion earlier, we are better off rearranging the code a bit so we avoid calling complete() on requests that we did not send out. This patch consolidates marking request slots as free in one place (in uinput_request_submit(), the same place where we acquire them) and having everyone else simply signal completion of the requests.
--- drivers/input/misc/uinput.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-)
drivers/input/misc/uinput.c +21 -18
@@ -98,14 +98,15 @@ static int uinput_request_reserve_slot(s uinput_request_alloc_id(udev, request)); } -static void uinput_request_done (struct uinput_device *udev, -struct uinput_request *request) +static void uinput_request_release_slot (struct uinput_device *udev, +unsigned int id) {/* Mark slot as available */ - udev->requests[request->id] =NULL ; -wake_up (&udev->requests_waitq); +spin_lock (&udev->requests_lock); + udev->requests[id] =NULL ; +spin_unlock (&udev->requests_lock); -complete (&request->done); +wake_up (&udev->requests_waitq); } static int uinput_request_send(struct uinput_device *udev,
@@ -138,20 +139,22 @@ static int uinput_request_send(struct uistatic int uinput_request_submit (struct uinput_device *udev,struct uinput_request *request) { -int error; +int retval; - error =uinput_request_reserve_slot (udev, request); -if (error) -return error; + retval =uinput_request_reserve_slot (udev, request); +if (retval) +return retval; - error =uinput_request_send (udev, request); -if (error) { -uinput_request_done (udev, request); -return error; - } + retval =uinput_request_send (udev, request); +if (retval) + goto out;wait_for_completion (&request->done); -return request->retval; + retval = request->retval; + + out: +uinput_request_release_slot (udev, request->id); +return retval; }/*
@@ -169,7 +172,7 @@ static void uinput_flush_requests(struct request = udev->requests[i];if (request) { request->retval = -ENODEV ; -uinput_request_done (udev, request); +complete (&request->done); } }
@@ -858,7 +861,7 @@ static long uinput_ioctl_handler(struct } req->retval = ff_up.retval; -uinput_request_done (udev, req); +complete (&req->done); goto out;case UI_END_FF_ERASE :
@@ -874,7 +877,7 @@ static long uinput_ioctl_handler(struct } req->retval = ff_erase.retval; -uinput_request_done (udev, req); +complete (&req->done); goto out; }
PATCH 34/204 usb-storage: fix bogus hardware error messages for ATA pass-thru devices
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit a4fd4a724d6c30ad671046d83be2e9be2f11d275 upstream.
Ever since commit a621bac3044e ("scsi_lib: correctly retry failed zero length REQ_TYPE_FS commands"), people have been getting bogus error messages for USB disk drives using ATA pass-thru. For example:
[ 1344.880193] sd 6:0:0:0: [sdb] Attached SCSI disk [ 1345.069152] sd 6:0:0:0: [sdb] tag#0 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_SENSE [ 1345.069159] sd 6:0:0:0: [sdb] tag#0 Sense Key : Hardware Error [current] [descriptor] [ 1345.069162] sd 6:0:0:0: [sdb] tag#0 Add. Sense: No additional sense information [ 1345.069168] sd 6:0:0:0: [sdb] tag#0 CDB: ATA command pass through(16) 85 06 20 00 00 00 00 00 00 00 00 00 00 00 e5 00 [ 1345.172252] sd 6:0:0:0: [sdb] tag#0 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_SENSE [ 1345.172258] sd 6:0:0:0: [sdb] tag#0 Sense Key : Hardware Error [current] [descriptor] [ 1345.172261] sd 6:0:0:0: [sdb] tag#0 Add. Sense: No additional sense information [ 1345.172266] sd 6:0:0:0: [sdb] tag#0 CDB: ATA command pass through(12)/Blank a1 06 20 da 00 00 4f c2 00 b0 00 00
These messages can be quite annoying, because programs like udisks2 provoke them every 10 minutes or so. Other programs can also have this effect, such as those in smartmontools.
I don't fully understand how that commit induced the SCSI core to log these error messages, but the underlying cause for them is code added to usb-storage by commit f1a0743bc0e7 ("USB: storage: When a device returns no sense data, call it a Hardware Error"). At the time it was necessary to do this, in order to prevent an infinite retry loop with some not-so-great mass storage devices.
However, the ATA pass-thru protocol uses SCSI sense data to return command status values, and some devices always report Check Condition status for ATA pass-thru commands to ensure that the host retrieves the sense data, even if the command succeeded. This violates the USB mass-storage protocol (Check Condition status is supposed to mean the command failed), but we can't help that.
This patch attempts to mitigate the problem of these bogus error reports by changing usb-storage. The HARDWARE ERROR sense key will be inserted only for commands that aren't ATA pass-thru.
Thanks to Ewan Milne for pointing out that this mechanism was present in usb-storage. 8 years after writing it, I had completely forgotten its existence.
Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1351305
--- drivers/usb/storage/transport.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/usb/storage/transport.c +13 -1
@@ -808,12 +808,24 @@ Retry_Sense:if (result ==USB_STOR_TRANSPORT_GOOD ) { srb->result =SAM_STAT_GOOD ; srb->sense_buffer[0 ] =0x0 ; + } + +/* +* ATA-passthru commands use sense data to report +* the command completion status, and often devices +* return Check Condition status when nothing is +* wrong. +*/ +else if (srb->cmnd[0 ] ==ATA_16 || + srb->cmnd[0 ] ==ATA_12 ) { +/* leave the data alone */ + }/* If there was a problem, report an unspecified * hardware error to prevent the higher layers from * entering an infinite retry loop. */ - }else { +else { srb->result =DID_ERROR <<16 ;if ((sshdr.response_code &0x72 ) ==0x72 ) srb->sense_buffer[1 ] =HARDWARE_ERROR ;
PATCH 35/204 usb-storage: unusual_devs entry to fix write-access regression for Seagate external drives
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 113f6eb6d50cfa5e2a1cdcf1678b12661fa272ab upstream.
Kris Lindgren reports that without the NO_WP_DETECT flag, his Seagate external disk drive fails all write accesses. This regresssion dates back approximately to the start of the 4.x kernel releases.
--- drivers/usb/storage/unusual_devs.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/storage/unusual_devs.h +7 -0
@@ -1360,6 +1360,13 @@ UNUSUAL_DEV( 0x0bc2, 0x3010, 0x0000, 0x0 USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_SANE_SENSE ), +/* Reported by Kris Lindgren <[email protected]> */ +UNUSUAL_DEV (0x0bc2 ,0x3332 ,0x0000 ,0x9999 , +"Seagate" , +"External" , +USB_SC_DEVICE ,USB_PR_DEVICE ,NULL , +US_FL_NO_WP_DETECT ), + UNUSUAL_DEV( 0x0d49, 0x7310, 0x0000, 0x9999, "Maxtor", "USB to SATA",
PATCH 36/204 USB: gadgetfs: fix copy_to_user while holding spinlock
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 6e76c01e71551cb221c1f3deacb9dcd9a7346784 upstream.
The gadgetfs driver as a long-outstanding FIXME, regarding a call of copy_to_user() made while holding a spinlock. This patch fixes the issue by dropping the spinlock and using the dev->udc_usage mechanism introduced by another recent patch to guard against status changes while the lock isn't held.
--- drivers/usb/gadget/inode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/usb/gadget/inode.c +4 -1
@@ -1055,11 +1055,14 @@ ep0_read (struct file *fd, char __user * retval = -EIO ; else { len =min (len, (size_t )dev->req->actual); -// FIXME don't call this with the spinlock held ... + ++dev->udc_usage; +spin_unlock_irq (&dev->lock);if (copy_to_user (buf, dev->req->buf, len)) retval = -EFAULT ;else retval = len; +spin_lock_irq (&dev->lock); + --dev->udc_usage;clean_req (dev->gadget->ep0, dev->req);/* NOTE userspace can't yet choose to stall */ }
PATCH 37/204 USB: gadgetfs: Fix crash caused by inadequate synchronization
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 520b72fc64debf8a86c3853b8e486aa5982188f0 upstream.
The gadgetfs driver (drivers/usb/gadget/legacy/inode.c) was written before the UDC and composite frameworks were adopted; it is a legacy driver. As such, it expects that once bound to a UDC controller, it will not be unbound until it unregisters itself.
However, the UDC framework does unbind function drivers while they are still registered. When this happens, it can cause the gadgetfs driver to misbehave or crash. For example, userspace can cause a crash by opening the device file and doing an ioctl call before setting up a configuration (found by Andrey Konovalov using the syzkaller fuzzer).
This patch adds checks and synchronization to prevent these bad behaviors. It adds a udc_usage counter that the driver increments at times when it is using a gadget interface without holding the private spinlock. The unbind routine waits for this counter to go to 0 before returning, thereby ensuring that the UDC is no longer in use.
The patch also adds a check in the dev_ioctl() routine to make sure the driver is bound to a UDC before dereferencing the gadget pointer, and it makes destroy_ep_files() synchronize with the endpoint I/O routines, to prevent the user from accessing an endpoint data structure after it has been removed.
[bwh: Backported to 3.16:
- Expand locked section in ep0_write() to match upstream
- Adjust filename, context]
---
drivers/usb/gadget/inode.c +38 -7
@@ -26,7 +26,7 @@#include <linux/poll.h> #include <linux/mmu_context.h> #include <linux/aio.h> - +#include <linux/delay.h> #include <linux/device.h> #include <linux/moduleparam.h>
@@ -113,6 +113,7 @@ enum ep0_state {struct dev_data {spinlock_t lock;atomic_t count; +int udc_usage;enum ep0_state state;/* P: lock */ struct usb_gadgetfs_event event [N_EVENT ];unsigned ev_next;
@@ -620,9 +621,9 @@ static void ep_aio_complete(struct usb_e priv->actual = req->actual;schedule_work (&priv->work); } -spin_unlock (&epdata->dev->lock);usb_ep_free_request (ep, req); +spin_unlock (&epdata->dev->lock);put_ep (epdata); }
@@ -1011,9 +1012,11 @@ ep0_read (struct file *fd, char __user *struct usb_request *req = dev->req;if ((retval =setup_req (ep, req,0 )) ==0 ) { + ++dev->udc_usage;spin_unlock_irq (&dev->lock); retval =usb_ep_queue (ep, req,GFP_KERNEL );spin_lock_irq (&dev->lock); + --dev->udc_usage; } dev->state =STATE_DEV_CONNECTED ;
@@ -1208,6 +1211,7 @@ ep0_write (struct file *fd, const char _ retval =setup_req (dev->gadget->ep0, dev->req, len);if (retval ==0 ) { dev->state =STATE_DEV_CONNECTED ; + ++dev->udc_usage;spin_unlock_irq (&dev->lock);if (copy_from_user (dev->req->buf, buf, len)) retval = -EFAULT ;
@@ -1218,12 +1222,13 @@ ep0_write (struct file *fd, const char _ dev->gadget->ep0, dev->req, GFP_KERNEL); } +spin_lock_irq (&dev->lock); + --dev->udc_usage;if (retval <0 ) { -spin_lock_irq (&dev->lock);clean_req (dev->gadget->ep0, dev->req); -spin_unlock_irq (&dev->lock); }else retval = len; +spin_unlock_irq (&dev->lock);return retval; }
@@ -1316,9 +1321,21 @@ static long dev_ioctl (struct file *fd,struct usb_gadget *gadget = dev->gadget;long ret = -ENOTTY ; -if (gadget->ops->ioctl) +spin_lock_irq (&dev->lock); +if (dev->state ==STATE_DEV_OPENED || + dev->state ==STATE_DEV_UNBOUND ) { +/* Not bound to a UDC */ + }else if (gadget->ops->ioctl) { + ++dev->udc_usage; +spin_unlock_irq (&dev->lock); + ret = gadget->ops->ioctl (gadget, code, value); +spin_lock_irq (&dev->lock); + --dev->udc_usage; + } +spin_unlock_irq (&dev->lock); +return ret; }
@@ -1549,10 +1566,12 @@ delegate:if (value <0 )break ; + ++dev->udc_usage;spin_unlock (&dev->lock); value =usb_ep_queue (gadget->ep0, dev->req,GFP_KERNEL );spin_lock (&dev->lock); + --dev->udc_usage;if (value <0 ) {clean_req (gadget->ep0, dev->req);break ;
@@ -1576,8 +1595,12 @@ delegate: req->length = value; req->zero = value < w_length; + ++dev->udc_usage;spin_unlock (&dev->lock); value =usb_ep_queue (gadget->ep0, req,GFP_KERNEL ); +spin_lock (&dev->lock); + --dev->udc_usage; +spin_unlock (&dev->lock);if (value <0 ) {DBG (dev,"ep_queue --> %d\n" , value); req->status =0 ;
@@ -1604,21 +1627,24 @@ static void destroy_ep_files (struct dev/* break link to FS */ ep = list_first_entry (&dev->epfiles, struct ep_data, epfiles);list_del_init (&ep->epfiles); +spin_unlock_irq (&dev->lock); + dentry = ep->dentry; ep->dentry =NULL ; parent = dentry->d_parent->d_inode;/* break link to controller */ +mutex_lock (&ep->lock);if (ep->state ==STATE_EP_ENABLED ) (void )usb_ep_disable (ep->ep); ep->state =STATE_EP_UNBOUND ;usb_ep_free_request (ep->ep, ep->req); ep->ep =NULL ; +mutex_unlock (&ep->lock); +wake_up (&ep->wait);put_ep (ep); -spin_unlock_irq (&dev->lock); -/* break link to dcache */ mutex_lock (&parent->i_mutex);d_delete (dentry);
@@ -1691,6 +1717,11 @@ gadgetfs_unbind (struct usb_gadget *gadgspin_lock_irq (&dev->lock); dev->state =STATE_DEV_UNBOUND ; +while (dev->udc_usage >0 ) { +spin_unlock_irq (&dev->lock); +usleep_range (1000 ,2000 ); +spin_lock_irq (&dev->lock); + }spin_unlock_irq (&dev->lock);destroy_ep_files (dev);
PATCH 38/204 USB: g_mass_storage: Fix deadlock when driver is unbound
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 1fbbb78f25d1291274f320462bf6908906f538db upstream.
As a holdover from the old g_file_storage gadget, the g_mass_storage legacy gadget driver attempts to unregister itself when its main operating thread terminates (if it hasn't been unregistered already). This is not strictly necessary; it was never more than an attempt to have the gadget fail cleanly if something went wrong and the main thread was killed.
However, now that the UDC core manages gadget drivers independently of UDC drivers, this scheme doesn't work any more. A simple test:
modprobe dummy-hcd
modprobe g-mass-storage file=...
rmmod dummy-hcd
ends up in a deadlock with the following backtrace:
sysrq: SysRq : Show Blocked State
task PC stack pid father
file-storage D 0 1130 2 0x00000000
Call Trace: __schedule+0x53e/0x58c schedule+0x6e/0x77 schedule_preempt_disabled+0xd/0xf __mutex_lock.isra.1+0x129/0x224 ? _raw_spin_unlock_irqrestore+0x12/0x14 __mutex_lock_slowpath+0x12/0x14 mutex_lock+0x28/0x2b usb_gadget_unregister_driver+0x29/0x9b [udc_core] usb_composite_unregister+0x10/0x12 [libcomposite] msg_cleanup+0x1d/0x20 [g_mass_storage] msg_thread_exits+0xd/0xdd7 [g_mass_storage] fsg_main_thread+0x1395/0x13d6 [usb_f_mass_storage] ? __schedule+0x573/0x58c kthread+0xd9/0xdb ? do_set_interface+0x25c/0x25c [usb_f_mass_storage] ? init_completion+0x1e/0x1e ret_from_fork+0x19/0x24 rmmod D 0 1155 683 0x00000000 Call Trace: __schedule+0x53e/0x58c schedule+0x6e/0x77 schedule_timeout+0x26/0xbc ? __schedule+0x573/0x58c do_wait_for_common+0xb3/0x128 ? usleep_range+0x81/0x81 ? wake_up_q+0x3f/0x3f wait_for_common+0x2e/0x45 wait_for_completion+0x17/0x19 fsg_common_put+0x34/0x81 [usb_f_mass_storage] fsg_free_inst+0x13/0x1e [usb_f_mass_storage] usb_put_function_instance+0x1a/0x25 [libcomposite] msg_unbind+0x2a/0x42 [g_mass_storage] __composite_unbind+0x4a/0x6f [libcomposite] composite_unbind+0x12/0x14 [libcomposite] usb_gadget_remove_driver+0x4f/0x77 [udc_core] usb_del_gadget_udc+0x52/0xcc [udc_core] dummy_udc_remove+0x27/0x2c [dummy_hcd] platform_drv_remove+0x1d/0x31 device_release_driver_internal+0xe9/0x16d device_release_driver+0x11/0x13 bus_remove_device+0xd2/0xe2 device_del+0x19f/0x221 ? selinux_capable+0x22/0x27 platform_device_del+0x21/0x63 platform_device_unregister+0x10/0x1a cleanup+0x20/0x817 [dummy_hcd] SyS_delete_module+0x10c/0x197 ? ____fput+0xd/0xf ? task_work_run+0x55/0x62 ? prepare_exit_to_usermode+0x65/0x75 do_fast_syscall_32+0x86/0xc3 entry_SYSENTER_32+0x4e/0x7c
What happens is that removing the dummy-hcd driver causes the UDC core to unbind the gadget driver, which it does while holding the udc_lock mutex. The unbind routine in g_mass_storage tells the main thread to exit and waits for it to terminate.
But as mentioned above, when the main thread exits it tries to unregister the mass-storage function driver. Via the composite framework this ends up calling usb_gadget_unregister_driver(), which tries to acquire the udc_lock mutex. The result is deadlock.
The simplest way to fix the problem is not to be so clever: The main thread doesn't have to unregister the function driver. The side effects won't be so terrible; if the gadget is still attached to a USB host when the main thread is killed, it will appear to the host as though the gadget's firmware has crashed -- a reasonably accurate interpretation, and an all-too-common occurrence for USB mass-storage devices.
In fact, the code to unregister the driver when the main thread exits is specific to g-mass-storage; it is not used when f-mass-storage is included as a function in a larger composite device. Therefore the entire mechanism responsible for this (the fsg_operations structure with its ->thread_exits method, the fsg_common_set_ops() routine, and the msg_thread_exits() callback routine) can all be eliminated. Even the msg_registered bitflag can be removed, because now the driver is unregistered in only one place rather than in two places.
[bwh: Backported to 3.16:
- Preserve the old way of iterating over LUNs in fsg_main_thread() cleanup
- Adjust filename, context]
---
drivers/usb/gadget/f_mass_storage.c +11 -22
@@ -307,8 +307,6 @@ struct fsg_common {struct completion thread_notifier;struct task_struct *thread_task; -/* Callback functions. */ -const struct fsg_operations *ops;/* Gadget's private data. */ void *private_data;
@@ -2498,6 +2496,8 @@ static void handle_exception(struct fsg_static int fsg_main_thread (void *common_) {struct fsg_common *common = common_; +struct fsg_lun **curlun_it; +unsigned i;/* * Allow the thread to be killed by a signal, but set the signal mask
@@ -2559,22 +2559,18 @@ static int fsg_main_thread(void *common_ common->thread_task =NULL ;spin_unlock_irq (&common->lock); -if (!common->ops || !common->ops->thread_exits - || common->ops->thread_exits (common) <0 ) { -struct fsg_lun **curlun_it = common->luns; -unsigned i = common->nluns; - -down_write (&common->filesem); -for (; i--; ++curlun_it) { -struct fsg_lun *curlun = *curlun_it; -if (!curlun || !fsg_lun_is_open (curlun)) -continue ; +/* Eject media from all LUNs */ + curlun_it = common->luns; + i = common->nluns; + +down_write (&common->filesem); +for (; i--; ++curlun_it) { +struct fsg_lun *curlun = *curlun_it; +if (curlun &&fsg_lun_is_open (curlun))fsg_lun_close (curlun); - curlun->unit_attention_data =SS_MEDIUM_NOT_PRESENT ; - } -up_write (&common->filesem); } +up_write (&common->filesem);/* Let fsg_unbind() know the thread has exited */ complete_and_exit (&common->thread_notifier,0 );
@@ -2842,13 +2838,6 @@ int fsg_common_set_nluns(struct fsg_comm }EXPORT_SYMBOL_GPL (fsg_common_set_nluns); -void fsg_common_set_ops (struct fsg_common *common, -const struct fsg_operations *ops) -{ - common->ops = ops; -} -EXPORT_SYMBOL_GPL (fsg_common_set_ops); -void fsg_common_free_buffers (struct fsg_common *common) {_fsg_common_free_buffers (common->buffhds, common->fsg_num_buffers);
drivers/usb/gadget/f_mass_storage.h +0 -14
@@ -60,17 +60,6 @@ struct fsg_module_parameters {struct fsg_common ;/* FSF callback functions */ -struct fsg_operations { -/* -* Callback function to call when thread exits. If no -* callback is set or it returns value lower then zero MSF -* will force eject all LUNs it operates on (including those -* marked as non-removable or with prevent_medium_removal flag -* set). -*/ -int (*thread_exits)(struct fsg_common *common); -}; -struct fsg_lun_opts {struct config_group group;struct fsg_lun *lun;
@@ -145,9 +134,6 @@ void fsg_common_free_luns(struct fsg_comint fsg_common_set_nluns (struct fsg_common *common,int nluns); -void fsg_common_set_ops (struct fsg_common *common, -const struct fsg_operations *ops); -int fsg_common_create_lun (struct fsg_common *common,struct fsg_lun_config *cfg,unsigned int id,const char *name,const char **name_pfx);
drivers/usb/gadget/mass_storage.c +2 -18
@@ -121,15 +121,6 @@ static unsigned int fsg_num_buffers = CO FSG_MODULE_PARAMETERS(/* no prefix */, mod_data); -static unsigned long msg_registered; -static void msg_cleanup (void ); - -static int msg_thread_exits (struct fsg_common *common) -{ -msg_cleanup (); -return 0 ; -} -static int __init msg_do_config (struct usb_configuration *c) {struct fsg_opts *opts;
@@ -172,9 +163,6 @@ static struct usb_configuration msg_confstatic int __init msg_bind (struct usb_composite_dev *cdev) { -static const struct fsg_operations ops = { - .thread_exits = msg_thread_exits, - };struct fsg_opts *opts;struct fsg_config config;int status;
@@ -195,8 +183,6 @@ static int __init msg_bind(struct usb_coif (status) goto fail_set_nluns; -fsg_common_set_ops (opts->common, &ops); - status =fsg_common_set_cdev (opts->common, cdev, config.can_stall);if (status) goto fail_set_cdev;
@@ -221,7 +207,6 @@ static int __init msg_bind(struct usb_cousb_composite_overwrite_options (cdev, &coverwrite);dev_info (&cdev->gadget->dev,DRIVER_DESC ", version: " DRIVER_VERSION "\n" ); -set_bit (0 , &msg_registered);return 0 ; fail_string_ids:
@@ -268,9 +253,8 @@ static int __init msg_init(void) }module_init (msg_init); -static void msg_cleanup (void ) +static void __exit msg_cleanup(void) { -if (test_and_clear_bit (0 , &msg_registered)) -usb_composite_unregister (&msg_driver); +usb_composite_unregister (&msg_driver); }module_exit (msg_cleanup);
PATCH 39/204 IB/ocrdma: fix incorrect fall-through on switch statement
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Colin Ian King <[email protected]>
commit 06564f60859bdf7e73d70ae35d7e285e96ae9c46 upstream.
In the case where mbox_status is OCRDMA_MBX_STATUS_FAILED and add_status is OCRDMA_MBX_STATUS_FAILED err_num is assigned -EAGAIN however the case OCRDMA_MBX_STATUS_FAILED is missing a break and falls through to the default case which then re-assigns err_num
to -EFAULT. Fix this so that err_num is assigned to -EAGAIN
for the add_status OCRDMA_MBX_STATUS_FAILED case and -EFAULT otherwise.
Detected by CoverityScan CID#703125 ("Missing break in switch")
--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +3 -0
@@ -235,7 +235,10 @@ static int ocrdma_get_mbx_errno(u32 statcase OCRDMA_MBX_ADDI_STATUS_INSUFFICIENT_RESOURCES : err_num = -EAGAIN ;break ; +default : + err_num = -EFAULT ; } +break ;default : err_num = -EFAULT ; }
PATCH 40/204 SMB3: Don't ignore O_SYNC/O_DSYNC and O_DIRECT flags
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit 1013e760d10e614dc10b5624ce9fc41563ba2e65 upstream.
--- fs/cifs/file.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/cifs/file.c +7 -0
@@ -225,6 +225,13 @@ cifs_nt_open(char *full_path, struct inoif (backup_cred (cifs_sb)) create_options |=CREATE_OPEN_BACKUP_INTENT ; +/* O_SYNC also has bit for O_DSYNC so following check picks up either */ +if (f_flags &O_SYNC ) + create_options |=CREATE_WRITE_THROUGH ; + +if (f_flags &O_DIRECT ) + create_options |=CREATE_NO_BUFFER ; + oparms.tcon = tcon; oparms.cifs_sb = cifs_sb; oparms.desired_access = desired_access;
PATCH 41/204 iio: adc: mcp320x: Fix oops on module unload
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Wunner <[email protected]>
commit 0964e40947a630a2a6f724e968246992f97bcf1c upstream.
The driver calls spi_get_drvdata() in its ->remove hook even though it has never called spi_set_drvdata(). Stack trace for posterity:
Unable to handle kernel NULL pointer dereference at virtual address 00000220 Internal error: Oops: 5 [#1] SMP ARM [<8072f564>] (mutex_lock) from [<7f1400d0>] (iio_device_unregister+0x24/0x7c [industrialio]) [<7f1400d0>] (iio_device_unregister [industrialio]) from [<7f15e020>] (mcp320x_remove+0x20/0x30 [mcp320x]) [<7f15e020>] (mcp320x_remove [mcp320x]) from [<8055a8cc>] (spi_drv_remove+0x2c/0x44) [<8055a8cc>] (spi_drv_remove) from [<805087bc>] (__device_release_driver+0x98/0x134) [<805087bc>] (__device_release_driver) from [<80509180>] (driver_detach+0xdc/0xe0) [<80509180>] (driver_detach) from [<8050823c>] (bus_remove_driver+0x5c/0xb0) [<8050823c>] (bus_remove_driver) from [<80509ab0>] (driver_unregister+0x38/0x58) [<80509ab0>] (driver_unregister) from [<7f15e69c>] (mcp320x_driver_exit+0x14/0x1c [mcp320x]) [<7f15e69c>] (mcp320x_driver_exit [mcp320x]) from [<801a78d0>] (SyS_delete_module+0x184/0x1d0) [<801a78d0>] (SyS_delete_module) from [<80108100>] (ret_fast_syscall+0x0/0x1c)
--- drivers/iio/adc/mcp320x.c | 1 + 1 file changed, 1 insertion(+)
drivers/iio/adc/mcp320x.c +1 -0
@@ -180,6 +180,7 @@ static int mcp320x_probe(struct spi_devi indio_dev->name =spi_get_device_id (spi)->name; indio_dev->modes =INDIO_DIRECT_MODE ; indio_dev->info = &mcp320x_info; +spi_set_drvdata (spi, indio_dev); chip_info = &mcp3208_chip_infos[spi_get_device_id (spi)->driver_data]; indio_dev->channels = chip_info->channels;
PATCH 42/204 iio: ad_sigma_delta: Implement a dedicated reset function
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dragos Bogdan <[email protected]>
commit 7fc10de8d49a748c476532c9d8e8fe19e548dd67 upstream.
Since most of the SD ADCs have the option of reseting the serial interface by sending a number of SCLKs with CS = 0 and DIN = 1, a dedicated function that can do this is usefull.
Needed for the patch: iio: ad7793: Fix the serial interface reset
--- drivers/iio/adc/ad_sigma_delta.c | 28 ++++++++++++++++++++++++++++ include/linux/iio/adc/ad_sigma_delta.h | 3 +++ 2 files changed, 31 insertions(+)
drivers/iio/adc/ad_sigma_delta.c +28 -0
@@ -177,6 +177,34 @@ out: }EXPORT_SYMBOL_GPL (ad_sd_read_reg); +/** +* ad_sd_reset() - Reset the serial interface +* +* @sigma_delta: The sigma delta device +* @reset_length: Number of SCLKs with DIN = 1 +* +* Returns 0 on success, an error code otherwise. +**/ +int ad_sd_reset (struct ad_sigma_delta *sigma_delta, +unsigned int reset_length) +{ +uint8_t *buf; +unsigned int size; +int ret; + + size =DIV_ROUND_UP (reset_length,8 ); + buf =kcalloc (size,sizeof (*buf),GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + +memset (buf,0xff , size); + ret =spi_write (sigma_delta->spi, buf, size); +kfree (buf); + +return ret; +} +EXPORT_SYMBOL_GPL (ad_sd_reset); +static int ad_sd_calibrate (struct ad_sigma_delta *sigma_delta,unsigned int mode,unsigned int channel) {
include/linux/iio/adc/ad_sigma_delta.h +3 -0
@@ -111,6 +111,9 @@ int ad_sd_write_reg(struct ad_sigma_deltint ad_sd_read_reg (struct ad_sigma_delta *sigma_delta,unsigned int reg,unsigned int size,unsigned int *val); +int ad_sd_reset (struct ad_sigma_delta *sigma_delta, +unsigned int reset_length); +int ad_sigma_delta_single_conversion (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,int *val); int ad_sd_calibrate_all(struct ad_sigma_delta *sigma_delta,
PATCH 43/204 iio: ad7793: Fix the serial interface reset
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dragos Bogdan <[email protected]>
commit 7ee3b7ebcb74714df6d94c8f500f307e1ee5dda5 upstream.
The serial interface can be reset by writing 32 consecutive 1s to the device. 'ret' was initialized correctly but its value was overwritten when ad7793_check_platform_data() was called. Since a dedicated reset function is present now, it should be used instead.
--- drivers/iio/adc/ad7793.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/adc/ad7793.c +2 -2
@@ -257,7 +257,7 @@ static int ad7793_setup(struct iio_dev * unsigned int vref_mv) {struct ad7793_state *st =iio_priv (indio_dev); -int i, ret =-1 ; +int i, ret;unsigned long long scale_uv;u32 id;
@@ -266,7 +266,7 @@ static int ad7793_setup(struct iio_dev *return ret;/* reset the serial interface */ - ret =spi_write (st->sd.spi, (u8 *)&ret,sizeof (ret)); + ret =ad_sd_reset (&st->sd,32 );if (ret <0 ) goto out;usleep_range (500 ,2000 );/* Wait for at least 500us */
PATCH 44/204 iio: core: Return error for failed read_reg
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Matt Fornero <[email protected]>
commit 3d62c78a6eb9a7d67bace9622b66ad51e81c5f9b upstream.
If an IIO device returns an error code for a read access via debugfs, it is currently ignored by the IIO core (other than emitting an error message). Instead, return this error code to user space, so upper layers can detect it correctly.
--- drivers/iio/industrialio-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/industrialio-core.c +3 -1
@@ -184,8 +184,10 @@ static ssize_t iio_debugfs_read_reg(stru ret = indio_dev->info->debugfs_reg_access (indio_dev, indio_dev->cached_reg_addr,0 , &val); -if (ret) +if (ret) {dev_err (indio_dev->dev.parent,"%s: read failed\n" , __func__); +return ret; + } len =snprintf (buf,sizeof (buf),"0x%X\n" , val);
PATCH 45/204 staging: iio: ad7192: Fix - use the dedicated reset function avoiding dma from stack.
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Popa <[email protected]>
commit f790923f146140a261ad211e5baf75d169f16fb2 upstream.
Depends on: 691c4b95d1 ("iio: ad_sigma_delta: Implement a dedicated reset function")
SPI host drivers can use DMA to transfer data, so the buffer should be properly allocated. Keeping it on the stack could cause an undefined behavior.
The dedicated reset function solves this issue.
--- drivers/staging/iio/adc/ad7192.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/iio/adc/ad7192.c +1 -3
@@ -206,11 +206,9 @@ static int ad7192_setup(struct ad7192_ststruct iio_dev *indio_dev =spi_get_drvdata (st->sd.spi);unsigned long long scale_uv;int i, ret, id; -u8 ones[6 ];/* reset the serial interface */ -memset (&ones,0xFF ,6 ); - ret =spi_write (st->sd.spi, &ones,6 ); + ret =ad_sd_reset (&st->sd,48 );if (ret <0 ) goto out;msleep (1 );/* Wait for at least 500us */
PATCH 46/204 KEYS: fix cred refcount leak in request_key_auth_new()
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 44d8143340a99b167c74365e844516b73523c087 upstream.
In request_key_auth_new(), if key_alloc() or key_instantiate_and_link() were to fail, we would leak a reference to the 'struct cred'. Currently this can only happen if key_alloc() fails to allocate memory. But it still should be fixed, as it is a more severe bug waiting to happen.
Fix it by cleaning things up to use a helper function which frees a 'struct request_key_auth' correctly.
--- security/keys/request_key_auth.c | 68 ++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 37 deletions(-)
security/keys/request_key_auth.c +31 -37
@@ -107,6 +107,18 @@ static void request_key_auth_revoke(stru } } +static void free_request_key_auth (struct request_key_auth *rka) +{ +if (!rka) +return ; +key_put (rka->target_key); +key_put (rka->dest_keyring); +if (rka->cred) +put_cred (rka->cred); +kfree (rka->callout_info); +kfree (rka); +} +/* * Destroy an instantiation authorisation token key. */
@@ -116,15 +128,7 @@ static void request_key_auth_destroy(strkenter ("{%d}" , key->serial); -if (rka->cred) { -put_cred (rka->cred); - rka->cred =NULL ; - } - -key_put (rka->target_key); -key_put (rka->dest_keyring); -kfree (rka->callout_info); -kfree (rka); +free_request_key_auth (rka); }/*
@@ -138,22 +142,17 @@ struct key *request_key_auth_new(structconst struct cred *cred = current->cred;struct key *authkey =NULL ;char desc[20 ]; -int ret; +int ret = -ENOMEM ;kenter ("%d," , target->serial);/* allocate a auth record */ - rka =kmalloc (sizeof (*rka),GFP_KERNEL ); -if (!rka) { -kleave (" = -ENOMEM" ); -return ERR_PTR (-ENOMEM ); - } + rka =kzalloc (sizeof (*rka),GFP_KERNEL ); +if (!rka) + goto error; rka->callout_info =kmalloc (callout_len,GFP_KERNEL ); -if (!rka->callout_info) { -kleave (" = -ENOMEM" ); -kfree (rka); -return ERR_PTR (-ENOMEM ); - } +if (!rka->callout_info) + goto error_free_rka;/* see if the calling process is already servicing the key request of * another process */
@@ -163,8 +162,12 @@ struct key *request_key_auth_new(struct/* if the auth key has been revoked, then the key we're * servicing is already instantiated */ -if (test_bit (KEY_FLAG_REVOKED , &cred->request_key_auth->flags)) - goto auth_key_revoked; +if (test_bit (KEY_FLAG_REVOKED , + &cred->request_key_auth->flags)) { +up_read (&cred->request_key_auth->sem); + ret = -EKEYREVOKED ; + goto error_free_rka; + } irka = cred->request_key_auth->payload.data; rka->cred =get_cred (irka->cred);
@@ -192,32 +195,23 @@ struct key *request_key_auth_new(struct KEY_USR_VIEW, KEY_ALLOC_NOT_IN_QUOTA);if (IS_ERR (authkey)) { ret =PTR_ERR (authkey); - goto error_alloc; + goto error_free_rka; }/* construct the auth key */ ret =key_instantiate_and_link (authkey, rka,0 ,NULL ,NULL );if (ret <0 ) - goto error_inst; + goto error_put_authkey;kleave (" = {%d,%d}" , authkey->serial,atomic_read (&authkey->usage));return authkey; -auth_key_revoked: -up_read (&cred->request_key_auth->sem); -kfree (rka->callout_info); -kfree (rka); -kleave ("= -EKEYREVOKED" ); -return ERR_PTR (-EKEYREVOKED ); - -error_inst: +error_put_authkey:key_revoke (authkey);key_put (authkey); -error_alloc: -key_put (rka->target_key); -key_put (rka->dest_keyring); -kfree (rka->callout_info); -kfree (rka); +error_free_rka: +free_request_key_auth (rka); +error:kleave ("= %d" , ret);return ERR_PTR (ret); }
PATCH 47/204 KEYS: don't revoke uninstantiated key in request_key_auth_new()
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit f7b48cf08fa63a68b59c2894806ee478216d7f91 upstream.
If key_instantiate_and_link() were to fail (which fortunately isn't possible currently), the call to key_revoke(authkey) would crash with a NULL pointer dereference in request_key_auth_revoke() because the key has not yet been instantiated.
Fix this by removing the call to key_revoke(). key_put() is sufficient, as it's not possible for an uninstantiated authkey to have been used for anything yet.
--- security/keys/request_key_auth.c | 1 - 1 file changed, 1 deletion(-)
security/keys/request_key_auth.c +0 -1
@@ -207,7 +207,6 @@ struct key *request_key_auth_new(structreturn authkey; error_put_authkey: -key_revoke (authkey);key_put (authkey); error_free_rka:free_request_key_auth (rka);
PATCH 48/204 KEYS: fix key refcount leak in keyctl_assume_authority()
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 884bee0215fcc239b30c062c37ca29077005e064 upstream.
In keyctl_assume_authority(), if keyctl_change_reqkey_auth() were to fail, we would leak the reference to the 'authkey'. Currently this can only happen if prepare_creds() fails to allocate memory. But it still should be fixed, as it is a more severe bug waiting to happen.
This patch also moves the read of 'authkey->serial' to before the reference to the authkey is dropped. Doing the read after dropping the reference is very fragile because it assumes we still hold another reference to the key. (Which we do, in current->cred->request_key_auth, but there's no reason not to write it in the "obviously correct" way.)
--- security/keys/keyctl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
security/keys/keyctl.c +2 -4
@@ -1401,11 +1401,9 @@ long keyctl_assume_authority(key_serial_ } ret =keyctl_change_reqkey_auth (authkey); -if (ret <0 ) - goto error; +if (ret ==0 ) + ret = authkey->serial;key_put (authkey); - - ret = authkey->serial; error:return ret; }
PATCH 49/204 KEYS: fix key refcount leak in keyctl_read_key()
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 7fc0786d956d9e59b68d282be9b156179846ea3d upstream.
In keyctl_read_key(), if key_permission() were to return an error code other than EACCES, we would leak a the reference to the key. This can't actually happen currently because key_permission() can only return an error code other than EACCES if security_key_permission() does, only SELinux and Smack implement that hook, and neither can return an error code other than EACCES. But it should still be fixed, as it is a bug waiting to happen.
--- security/keys/keyctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/keys/keyctl.c +1 -1
@@ -745,7 +745,7 @@ long keyctl_read_key(key_serial_t keyid,if (ret ==0 ) goto can_read_key;if (ret != -EACCES ) - goto error; + goto error2;/* we can't; see if it's searchable from this process's keyrings * - we automatically take account of the fact that it may be
PATCH 50/204 KEYS: fix writing past end of user-supplied buffer in keyring_read()
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit e645016abc803dafc75e4b8f6e4118f088900ffb upstream.
Userspace can call keyctl_read() on a keyring to get the list of IDs of keys in the keyring. But if the user-supplied buffer is too small, the kernel would write the full list anyway --- which will corrupt whatever userspace memory happened to be past the end of the buffer. Fix it by only filling the space that is available.
--- security/keys/keyring.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
security/keys/keyring.c +5 -9
@@ -405,7 +405,7 @@ static void keyring_describe(const struc }struct keyring_read_iterator_context { -size_t qty; +size_t buflen;size_t count;key_serial_t __user *buffer; };
@@ -417,9 +417,9 @@ static int keyring_read_iterator(const vint ret;kenter ("{%s,%d},,{%zu/%zu}" , - key->type->name, key->serial, ctx->count, ctx->qty); + key->type->name, key->serial, ctx->count, ctx->buflen); -if (ctx->count >= ctx->qty) +if (ctx->count >= ctx->buflen)return 1 ; ret =put_user (key->serial, ctx->buffer);
@@ -454,16 +454,12 @@ static long keyring_read(const struct kereturn 0 ;/* Calculate how much data we could return */ - ctx.qty = nr_keys *sizeof (key_serial_t); -if (!buffer || !buflen) -return ctx.qty; - -if (buflen > ctx.qty) - ctx.qty = buflen; +return nr_keys *sizeof (key_serial_t);/* Copy the IDs of the subscribed keys into the buffer */ ctx.buffer = (key_serial_t __user *)buffer; + ctx.buflen = buflen; ctx.count =0 ; ret =assoc_array_iterate (&keyring->keys, keyring_read_iterator, &ctx);if (ret <0 ) {
PATCH 51/204 KEYS: prevent creating a different user's keyrings
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 237bbd29f7a049d310d907f4b2716a7feef9abf3 upstream.
It was possible for an unprivileged user to create the user and user session keyrings for another user. For example:
sudo -u '#3000' sh -c 'keyctl add keyring _uid.4000 "" @u
keyctl add keyring _uid_ses.4000 "" @u
sleep 15' &
sleep 1
sudo -u '#4000' keyctl describe @u
sudo -u '#4000' keyctl describe @usThis is problematic because these "fake" keyrings won't have the right permissions. In particular, the user who created them first will own them and will have full access to them via the possessor permissions, which can be used to compromise the security of a user's keys:
-4: alswrv-----v------------ 3000 0 keyring: _uid.4000
-5: alswrv-----v------------ 3000 0 keyring: _uid_ses.4000Fix it by marking user and user session keyrings with a flag KEY_FLAG_UID_KEYRING. Then, when searching for a user or user session keyring by name, skip all keyrings that don't have the flag set.
---
include/linux/key.h +2 -0
@@ -170,6 +170,7 @@ struct key {#define KEY_FLAG_INVALIDATED 7/* set if key has been invalidated */ #define KEY_FLAG_TRUSTED 8/* set if key is trusted */ #define KEY_FLAG_TRUSTED_ONLY 9/* set if keyring only accepts links to trusted keys */ +#define KEY_FLAG_UID_KEYRING 11/* set if key is a user or user session keyring */ /* the key type and key description string * - the desc is used to match a key against search criteria
@@ -221,6 +222,7 @@ extern struct key *key_alloc(struct key_#define KEY_ALLOC_QUOTA_OVERRUN 0x0001/* add to quota, permit even if overrun */ #define KEY_ALLOC_NOT_IN_QUOTA 0x0002/* not in quota */ #define KEY_ALLOC_TRUSTED 0x0004/* Key should be flagged as trusted */ +#define KEY_ALLOC_UID_KEYRING 0x0010/* allocating a user or user session keyring */ extern void key_revoke (struct key *key);extern void key_invalidate (struct key *key);
security/keys/internal.h +1 -1
@@ -137,7 +137,7 @@ extern key_ref_t keyring_search_aux(key_extern key_ref_t search_my_process_keyrings (struct keyring_search_context *ctx);extern key_ref_t search_process_keyrings (struct keyring_search_context *ctx); -extern struct key *find_keyring_by_name (const char *name,bool skip_perm_check); +extern struct key *find_keyring_by_name (const char *name,bool uid_keyring);extern int install_user_keyrings (void );extern int install_thread_keyring_to_cred (struct cred *);
security/keys/key.c +2 -0
@@ -298,6 +298,8 @@ struct key *key_alloc(struct key_type *t key->flags |=1 <<KEY_FLAG_IN_QUOTA ;if (flags &KEY_ALLOC_TRUSTED ) key->flags |=1 <<KEY_FLAG_TRUSTED ; +if (flags &KEY_ALLOC_UID_KEYRING ) + key->flags |=1 <<KEY_FLAG_UID_KEYRING ;#ifdef KEY_DEBUGGING key->magic =KEY_DEBUG_MAGIC ;
security/keys/keyring.c +14 -9
@@ -931,15 +931,15 @@ found:/* * Find a keyring with the specified name. * -* All named keyrings in the current user namespace are searched, provided they -* grant Search permission directly to the caller (unless this check is -* skipped). Keyrings whose usage points have reached zero or who have been -* revoked are skipped. +* Only keyrings that have nonzero refcount, are not revoked, and are owned by a +* user in the current user namespace are considered. If @uid_keyring is %true, +* the keyring additionally must have been allocated as a user or user session +* keyring; otherwise, it must grant Search permission directly to the caller. * * Returns a pointer to the keyring with the keyring's refcount having being * incremented on success. -ENOKEY is returned if a key could not be found. */ -struct key *find_keyring_by_name (const char *name,bool skip_perm_check) +struct key *find_keyring_by_name (const char *name,bool uid_keyring) {struct key *keyring;int bucket;
@@ -967,10 +967,15 @@ struct key *find_keyring_by_name(const cif (strcmp (keyring->description, name) !=0 )continue ; -if (!skip_perm_check && -key_permission (make_key_ref (keyring,0 ), -KEY_NEED_SEARCH ) <0 ) -continue ; +if (uid_keyring) { +if (!test_bit (KEY_FLAG_UID_KEYRING , + &keyring->flags)) +continue ; + }else { +if (key_permission (make_key_ref (keyring,0 ), +KEY_NEED_SEARCH ) <0 ) +continue ; + }/* we've got a match but we might end up racing with * key_cleanup() if the keyring is currently 'dead'
security/keys/process_keys.c +6 -2
@@ -76,7 +76,9 @@ int install_user_keyrings(void)if (IS_ERR (uid_keyring)) { uid_keyring =keyring_alloc (buf, user->uid,INVALID_GID , cred, user_keyring_perm, -KEY_ALLOC_IN_QUOTA ,NULL ); +KEY_ALLOC_UID_KEYRING | +KEY_ALLOC_IN_QUOTA , +NULL );if (IS_ERR (uid_keyring)) { ret =PTR_ERR (uid_keyring); goto error;
@@ -92,7 +94,9 @@ int install_user_keyrings(void) session_keyring =keyring_alloc (buf, user->uid,INVALID_GID , cred, user_keyring_perm, -KEY_ALLOC_IN_QUOTA ,NULL ); +KEY_ALLOC_UID_KEYRING | +KEY_ALLOC_IN_QUOTA , +NULL );if (IS_ERR (session_keyring)) { ret =PTR_ERR (session_keyring); goto error_release;
PATCH 52/204 IB/mlx5: Fix the size parameter to find_first_bit
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Jaillet <[email protected]>
commit fffd68734dc685e208e86d8c5f6522cd695a8d60 upstream.
The 2nd parameter of 'find_first_bit' is the number of bits to search. In this case, we are passing 'sizeof(tmp)' which is likely to be 4 or 8 because 'tmp' is an 'unsigned long'.
It is likely that the number of bits of 'tmp' was expected here. So use BITS_PER_LONG instead.
It has been spotted by the following coccinelle script:
@@
expression ret, x;
@@
* ret = \(find_first_bit \| find_first_zero_bit\) (x, sizeof(...));
--- drivers/infiniband/hw/mlx5/mem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/infiniband/hw/mlx5/mem.c +3 -3
@@ -58,7 +58,7 @@ void mlx5_ib_cont_pages(struct ib_umem * addr = addr >>PAGE_SHIFT ; tmp = (unsigned long )addr; - m =find_first_bit (&tmp,sizeof (tmp)); + m =find_first_bit (&tmp,BITS_PER_LONG ); skip =1 << m; mask = skip -1 ; i =0 ;
@@ -68,7 +68,7 @@ void mlx5_ib_cont_pages(struct ib_umem *for (k =0 ; k < len; k++) {if (!(i & mask)) { tmp = (unsigned long )pfn; - m = min_t(unsigned long, m, find_first_bit(&tmp, sizeof(tmp))); + m = min_t(unsigned long, m, find_first_bit(&tmp, BITS_PER_LONG)); skip =1 << m; mask = skip -1 ; base = pfn;
@@ -76,7 +76,7 @@ void mlx5_ib_cont_pages(struct ib_umem * }else {if (base + p != pfn) { tmp = (unsigned long )p; - m =find_first_bit (&tmp,sizeof (tmp)); + m =find_first_bit (&tmp,BITS_PER_LONG ); skip =1 << m; mask = skip -1 ; base = pfn;
PATCH 53/204 IB/mlx5: Simplify mlx5_ib_cont_pages
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Lesokhin <[email protected]>
commit d67bc5d4e3e100d762c0f57ea67f28bc219698a6 upstream.
The patch simplifies mlx5_ib_cont_pages and fixes the following issues in the original implementation:
First issues is related to alignment of the PFNs. After the check base + p != PFN, the alignment of the PFN wasn't checked. So the PFN sequence 0, 1, 1, 2 would result in a page_shift of 13 even though the 3rd PFN is not 8KB aligned.
This wasn't actually a bug because it was supported by all the existing mlx5 compatible device, but we don't want to require this support in all future devices.
Another issue is because the inner loop didn't advance PFN so the test "if (base + p != pfn)" always failed for SGE with len > (1<<page_shift).
--- drivers/infiniband/hw/mlx5/mem.c | 47 +++++++++++++++------------------------- 1 file changed, 17 insertions(+), 30 deletions(-)
drivers/infiniband/hw/mlx5/mem.c +17 -30
@@ -46,46 +46,33 @@ void mlx5_ib_cont_pages(struct ib_umem * {unsigned long tmp;unsigned long m; -int i, k; -u64 base =0 ; -int p =0 ; -int skip; -int mask; -u64 len; -u64 pfn; +u64 base = ~0 , p =0 ; +u64 len, pfn; +int i =0 ;struct scatterlist *sg;int entry; addr = addr >>PAGE_SHIFT ; tmp = (unsigned long )addr; m =find_first_bit (&tmp,BITS_PER_LONG ); - skip =1 << m; - mask = skip -1 ; - i =0 ; +for_each_sg (umem->sg_head.sgl, sg, umem->nmap, entry) { len =sg_dma_len (sg) >>PAGE_SHIFT ; pfn =sg_dma_address (sg) >>PAGE_SHIFT ; -for (k =0 ; k < len; k++) { -if (!(i & mask)) { - tmp = (unsigned long )pfn; - m = min_t(unsigned long, m, find_first_bit(&tmp, BITS_PER_LONG)); - skip =1 << m; - mask = skip -1 ; - base = pfn; - p =0 ; - }else { -if (base + p != pfn) { - tmp = (unsigned long )p; - m =find_first_bit (&tmp,BITS_PER_LONG ); - skip =1 << m; - mask = skip -1 ; - base = pfn; - p =0 ; - } - } - p++; - i++; +if (base + p != pfn) { +/* If either the offset or the new +* base are unaligned update m +*/ + tmp = (unsigned long )(pfn | p); +if (!IS_ALIGNED (tmp,1 << m)) + m =find_first_bit (&tmp,BITS_PER_LONG ); + + base = pfn; + p =0 ; } + + p += len; + i += len; }if (i) {
PATCH 54/204 security/keys: properly zero out sensitive key material in big_key
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Jason A. Donenfeld" <[email protected]>
commit 910801809b2e40a4baedd080ef5d80b4a180e70e upstream.
Error paths forgot to zero out sensitive material, so this patch changes some kfrees into a kzfrees.
--- security/keys/big_key.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
security/keys/big_key.c +1 -1
@@ -135,7 +135,7 @@ void big_key_destroy(struct key *key) path->mnt =NULL ; path->dentry =NULL ; }else { -kfree (key->payload.data); +kzfree (key->payload.data); key->payload.data =NULL ; } }
PATCH 55/204 PCI: Fix race condition with driver_override
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Nicolai Stange <[email protected]>
commit 9561475db680f7144d2223a409dd3d7e322aca03 upstream.
The driver_override implementation is susceptible to a race condition when different threads are reading vs. storing a different driver override. Add locking to avoid the race condition.
This is in close analogy to commit 6265539776a0 ("driver core: platform:
fix race condition with driver_override") from Adrian Salido.
--- drivers/pci/pci-sysfs.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/pci/pci-sysfs.c +9 -2
@@ -514,7 +514,7 @@ static ssize_t driver_override_store(str const char *buf, size_t count) {struct pci_dev *pdev =to_pci_dev (dev); -char *driver_override, *old = pdev->driver_override, *cp; +char *driver_override, *old, *cp;/* We need to keep extra room for a newline */ if (count >= (PAGE_SIZE -1 ))
@@ -528,12 +528,15 @@ static ssize_t driver_override_store(strif (cp) *cp ='\0' ; +device_lock (dev); + old = pdev->driver_override;if (strlen (driver_override)) { pdev->driver_override = driver_override; }else {kfree (driver_override); pdev->driver_override =NULL ; } +device_unlock (dev);kfree (old);
@@ -544,8 +547,12 @@ static ssize_t driver_override_show(stru struct device_attribute *attr, char *buf) { struct pci_dev *pdev = to_pci_dev(dev); +ssize_t len; -return snprintf (buf,PAGE_SIZE ,"%s\n" , pdev->driver_override); +device_lock (dev); + len =snprintf (buf,PAGE_SIZE ,"%s\n" , pdev->driver_override); +device_unlock (dev); +return len; }static DEVICE_ATTR_RW (driver_override);
PATCH 56/204 Btrfs: fix incorrect {node,sector}size endianness from BTRFS_IOC_FS_INFO
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Omar Sandoval <[email protected]>
commit bea7eafdbda3ba1d4b2ccb9cca829eefb7989bb9 upstream.
fs_info->super_copy->{node,sector}size are little-endian, but the ioctl should return the values in native endianness. Use the cached values in btrfs_fs_info instead. Found with sparse.
[bwh: Backported to 3.16: native nodesize and sectorsize are members of
struct btrfs_root, not struct btrfs_fs_info]
--- fs/btrfs/ioctl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/btrfs/ioctl.c +3 -3
@@ -2745,9 +2745,9 @@ static long btrfs_ioctl_fs_info(struct b }mutex_unlock (&fs_devices->device_list_mutex); - fi_args->nodesize = root->fs_info->super_copy->nodesize; - fi_args->sectorsize = root->fs_info->super_copy->sectorsize; - fi_args->clone_alignment = root->fs_info->super_copy->sectorsize; + fi_args->nodesize = root->nodesize; + fi_args->sectorsize = root->sectorsize; + fi_args->clone_alignment = root->sectorsize;if (copy_to_user (arg, fi_args,sizeof (*fi_args))) ret = -EFAULT ;
PATCH 57/204 btrfs: prevent to set invalid default subvolid
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: satoru takeuchi <[email protected]>
commit 6d6d282932d1a609e60dc4467677e0e863682f57 upstream.
btrfs sub set-default succeeds to set an ID which isn't corresponding to any fs/file tree. If such the bad ID is set to a filesystem, we can't mount this filesystem without specifying subvol or subvolid mount options.
--- fs/btrfs/ioctl.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/btrfs/ioctl.c +4 -0
@@ -3980,6 +3980,10 @@ static long btrfs_ioctl_default_subvol(s ret =PTR_ERR (new_root); goto out; } +if (!is_fstree (new_root->objectid)) { + ret = -ENOENT ; + goto out; + } path =btrfs_alloc_path ();if (!path) {
PATCH 58/204 drm/i915/bios: ignore HDMI on port A
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jani Nikula <[email protected]>
commit 2ba7d7e0437127314864238f8bfcb8369d81075c upstream.
The hardware state readout oopses after several warnings when trying to use HDMI on port A, if such a combination is configured in VBT. Filter the combo out already at the VBT parsing phase.
v2: also ignore DVI (Ville)
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102889
--- drivers/gpu/drm/i915/intel_bios.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/i915/intel_bios.c +7 -0
@@ -939,6 +939,13 @@ static void parse_ddi_port(struct drm_i9 is_hdmi = is_dvi && (child->common.device_type &DEVICE_TYPE_NOT_HDMI_OUTPUT ) ==0 ; is_edp = is_dp && (child->common.device_type &DEVICE_TYPE_INTERNAL_CONNECTOR ); +if (port ==PORT_A && is_dvi) { +DRM_DEBUG_KMS ("VBT claims port A supports DVI%s, ignoring\n" , + is_hdmi ?"/HDMI" :"" ); + is_dvi = false; + is_hdmi = false; + } + info->supports_dvi = is_dvi; info->supports_hdmi = is_hdmi; info->supports_dp = is_dp;
PATCH 59/204 vti: fix use after free in vti_tunnel_xmit/vti6_tnl_xmit
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Kodanev <[email protected]>
commit 36f6ee22d2d66046e369757ec6bbe1c482957ba6 upstream.
When running LTP IPsec tests, KASan might report:
BUG: KASAN: use-after-free in vti_tunnel_xmit+0xeee/0xff0 [ip_vti] Read of size 4 at addr ffff880dc6ad1980 by task swapper/0/0 ... Call Trace: <IRQ> dump_stack+0x63/0x89 print_address_description+0x7c/0x290 kasan_report+0x28d/0x370 ? vti_tunnel_xmit+0xeee/0xff0 [ip_vti] __asan_report_load4_noabort+0x19/0x20 vti_tunnel_xmit+0xeee/0xff0 [ip_vti] ? vti_init_net+0x190/0x190 [ip_vti] ? save_stack_trace+0x1b/0x20 ? save_stack+0x46/0xd0 dev_hard_start_xmit+0x147/0x510 ? icmp_echo.part.24+0x1f0/0x210 __dev_queue_xmit+0x1394/0x1c60 ... Freed by task 0: save_stack_trace+0x1b/0x20 save_stack+0x46/0xd0 kasan_slab_free+0x70/0xc0 kmem_cache_free+0x81/0x1e0 kfree_skbmem+0xb1/0xe0 kfree_skb+0x75/0x170 kfree_skb_list+0x3e/0x60 __dev_queue_xmit+0x1298/0x1c60 dev_queue_xmit+0x10/0x20 neigh_resolve_output+0x3a8/0x740 ip_finish_output2+0x5c0/0xe70 ip_finish_output+0x4ba/0x680 ip_output+0x1c1/0x3a0 xfrm_output_resume+0xc65/0x13d0 xfrm_output+0x1e4/0x380 xfrm4_output_finish+0x5c/0x70
Can be fixed if we get skb->len before dst_output().
--- net/ipv4/ip_vti.c | 3 ++- net/ipv6/ip6_vti.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
net/ipv4/ip_vti.c +2 -1
@@ -151,6 +151,7 @@ static netdev_tx_t vti_xmit(struct sk_bustruct ip_tunnel_parm *parms = &tunnel->parms;struct dst_entry *dst =skb_dst (skb);struct net_device *tdev;/* Device to other host */ +int pkt_len = skb->len;int err;if (!dst) {
@@ -194,7 +195,7 @@ static netdev_tx_t vti_xmit(struct sk_bu err =dst_output (skb);if (net_xmit_eval (err) ==0 ) - err = skb->len; + err = pkt_len;iptunnel_xmit_stats (err, &dev->stats, dev->tstats);return NETDEV_TX_OK ;
net/ipv6/ip6_vti.c +2 -1
@@ -407,6 +407,7 @@ vti6_xmit(struct sk_buff *skb, struct nestruct net_device_stats *stats = &t->dev->stats;struct dst_entry *dst =skb_dst (skb);struct net_device *tdev; +int pkt_len = skb->len;int err =-1 ;if (!dst)
@@ -441,7 +442,7 @@ vti6_xmit(struct sk_buff *skb, struct nestruct pcpu_sw_netstats *tstats =this_cpu_ptr (dev->tstats);u64_stats_update_begin (&tstats->syncp); - tstats->tx_bytes += skb->len; + tstats->tx_bytes += pkt_len; tstats->tx_packets++;u64_stats_update_end (&tstats->syncp); }else {
PATCH 60/204 l2tp: fix race condition in l2tp_tunnel_delete
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
commit 62b982eeb4589b2e6d7c01a90590e3a4c2b2ca19 upstream.
If we try to delete the same tunnel twice, the first delete operation does a lookup (l2tp_tunnel_get), finds the tunnel, calls l2tp_tunnel_delete, which queues it for deletion by l2tp_tunnel_del_work.
The second delete operation also finds the tunnel and calls l2tp_tunnel_delete. If the workqueue has already fired and started running l2tp_tunnel_del_work, then l2tp_tunnel_delete will queue the same tunnel a second time, and try to free the socket again.
Add a dead flag to prevent firing the workqueue twice. Then we can remove the check of queue_work's result that was meant to prevent that race but doesn't.
Reproducer:
ip l2tp add tunnel tunnel_id 3000 peer_tunnel_id 4000 local 192.168.0.2 remote 192.168.0.1 encap udp udp_sport 5000 udp_dport 6000 ip l2tp add session name l2tp1 tunnel_id 3000 session_id 1000 peer_session_id 2000
ip link set l2tp1 up
ip l2tp del tunnel tunnel_id 3000
ip l2tp del tunnel tunnel_id 3000
--- net/l2tp/l2tp_core.c | 10 ++++------ net/l2tp/l2tp_core.h | 5 ++++- 2 files changed, 8 insertions(+), 7 deletions(-)
net/l2tp/l2tp_core.c +4 -6
@@ -1771,14 +1771,12 @@ EXPORT_SYMBOL_GPL(l2tp_tunnel_create);/* This function is used by the netlink TUNNEL_DELETE command. */ -int l2tp_tunnel_delete (struct l2tp_tunnel *tunnel) +void l2tp_tunnel_delete (struct l2tp_tunnel *tunnel) { -l2tp_tunnel_inc_refcount (tunnel); -if (false ==queue_work (l2tp_wq, &tunnel->del_work)) { -l2tp_tunnel_dec_refcount (tunnel); -return 1 ; +if (!test_and_set_bit (0 , &tunnel->dead)) { +l2tp_tunnel_inc_refcount (tunnel); +queue_work (l2tp_wq, &tunnel->del_work); } -return 0 ; }EXPORT_SYMBOL_GPL (l2tp_tunnel_delete);
net/l2tp/l2tp_core.h +4 -1
@@ -169,6 +169,9 @@ struct l2tp_tunnel_cfg {struct l2tp_tunnel {int magic;/* Should be L2TP_TUNNEL_MAGIC */ + +unsigned long dead; +struct rcu_head rcu;rwlock_t hlist_lock;/* protect session_hlist */ bool acpt_newsess;/* Indicates whether this
@@ -266,7 +269,7 @@ int l2tp_tunnel_create(struct net *net, u32 peer_tunnel_id, struct l2tp_tunnel_cfg *cfg, struct l2tp_tunnel **tunnelp);void l2tp_tunnel_closeall (struct l2tp_tunnel *tunnel); -int l2tp_tunnel_delete (struct l2tp_tunnel *tunnel); +void l2tp_tunnel_delete (struct l2tp_tunnel *tunnel); struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunnel, u32 session_id, u32 peer_session_id,
PATCH 61/204 netfilter: ipset: pernet ops must be unregistered last
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
commit e23ed762db7ed1950a6408c3be80bc56909ab3d4 upstream.
Removing the ipset module leaves a small window where one cpu performs module removal while another runs a command like 'ipset flush'.
ipset uses net_generic(), unregistering the pernet ops frees this storage area.
Fix it by first removing the user-visible api handlers and the pernet ops last.
---
net/netfilter/ipset/ip_set_core.c +14 -9
@@ -1982,24 +1982,28 @@ static struct pernet_operations ip_set_nstatic int __init ip_set_init (void ) { -int ret =nfnetlink_subsys_register (&ip_set_netlink_subsys); +int ret =register_pernet_subsys (&ip_set_net_ops); + +if (ret) { +pr_err ("ip_set: cannot register pernet_subsys.\n" ); +return ret; + } + + ret =nfnetlink_subsys_register (&ip_set_netlink_subsys);if (ret !=0 ) {pr_err ("ip_set: cannot register with nfnetlink.\n" ); +unregister_pernet_subsys (&ip_set_net_ops);return ret; } + ret =nf_register_sockopt (&so_set);if (ret !=0 ) {pr_err ("SO_SET registry failed: %d\n" , ret);nfnetlink_subsys_unregister (&ip_set_netlink_subsys); +unregister_pernet_subsys (&ip_set_net_ops);return ret; } - ret =register_pernet_subsys (&ip_set_net_ops); -if (ret) { -pr_err ("ip_set: cannot register pernet_subsys.\n" ); -nf_unregister_sockopt (&so_set); -nfnetlink_subsys_unregister (&ip_set_netlink_subsys); -return ret; - } +pr_info ("ip_set: protocol %u\n" ,IPSET_PROTOCOL );return 0 ; }
@@ -2007,9 +2011,10 @@ ip_set_init(void) static void __exitip_set_fini (void ) { -unregister_pernet_subsys (&ip_set_net_ops);nf_unregister_sockopt (&so_set);nfnetlink_subsys_unregister (&ip_set_netlink_subsys); + +unregister_pernet_subsys (&ip_set_net_ops);pr_debug ("these are the famous last words\n" ); }
PATCH 62/204 vfs: Return -ENXIO for negative SEEK_HOLE / SEEK_DATA offsets
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Gruenbacher <[email protected]>
commit fc46820b27a2d9a46f7e90c9ceb4a64a1bc5fab8 upstream.
In generic_file_llseek_size, return -ENXIO for negative offsets as well as offsets beyond EOF. This affects filesystems which don't implement SEEK_HOLE / SEEK_DATA internally, possibly because they don't support holes.
Fixes xfstest generic/448.
--- fs/read_write.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/read_write.c +2 -2
@@ -116,7 +116,7 @@ generic_file_llseek_size(struct file *fi* In the generic case the entire file is data, so as long as * offset isn't at the end of the file then the offset is data. */ -if (offset >= eof) +if ((unsigned long long )offset >= eof)return -ENXIO ;break ;case SEEK_HOLE :
@@ -124,7 +124,7 @@ generic_file_llseek_size(struct file *fi* There is a virtual hole at the end of the file, so as long as * offset isn't i_size or larger, return i_size. */ -if (offset >= eof) +if ((unsigned long long )offset >= eof)return -ENXIO ; offset = eof;break ;
PATCH 63/204 arm64: Make sure SPsel is always set
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
commit 5371513fb338fb9989c569dc071326d369d6ade8 upstream.
When the kernel is entered at EL2 on an ARMv8.0 system, we construct the EL1 pstate and make sure this uses the the EL1 stack pointer (we perform an exception return to EL1h).
But if the kernel is either entered at EL1 or stays at EL2 (because we're on a VHE-capable system), we fail to set SPsel, and use whatever stack selection the higher exception level has choosen for us.
Let's not take any chance, and make sure that SPsel is set to one before we decide the mode we're going to run in.
--- arch/arm64/kernel/head.S | 1 + 1 file changed, 1 insertion(+)
arch/arm64/kernel/head.S +1 -0
@@ -269,6 +269,7 @@ ENDPROC(stext) * booted in EL1 or EL2 respectively. */ ENTRY(el2_setup) + msr SPsel, #1 // We want to use SP_EL{1,2} mrs x0, CurrentEL cmp x0, #CurrentEL_EL2 b.ne 1f
PATCH 64/204 Revert "IB/ipoib: Update broadcast object if PKey value was changed in index 0"
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alex Estrin <[email protected]>
commit 612601d0013f03de9dc134809f242ba6da9ca252 upstream.
commit 9a9b8112699d will cause core to fail UD QP from being destroyed on ipoib unload, therefore cause resources leakage.
On pkey change event above patch modifies mgid before calling underlying driver to detach it from QP. Drivers' detach_mcast() will fail to find modified mgid it was never given to attach in a first place. Core qp->usecnt will never go down, so ib_destroy_qp() will fail.
IPoIB driver actually does take care of new broadcast mgid based on new pkey by destroying an old mcast object in ipoib_mcast_dev_flush())
....
if (priv->broadcast) {
rb_erase(&priv->broadcast->rb_node, &priv->multicast_tree);
list_add_tail(&priv->broadcast->list, &remove_list);
priv->broadcast = NULL;
}...
then in restarted ipoib_macst_join_task() creating a new broadcast mcast object, sending join request and on completion tells the driver to attach to reinitialized QP:
...
if (!priv->broadcast) {
...
broadcast = ipoib_mcast_alloc(dev, 0); ... memcpy(broadcast->mcmember.mgid.raw, priv->dev->broadcast + 4, sizeof (union ib_gid)); priv->broadcast = broadcast;
...
--- drivers/infiniband/ulp/ipoib/ipoib_ib.c | 13 ------------- 1 file changed, 13 deletions(-)
drivers/infiniband/ulp/ipoib/ipoib_ib.c +0 -13
@@ -961,19 +961,6 @@ static inline int update_parent_pkey(str*/ priv->dev->broadcast[8 ] = priv->pkey >>8 ; priv->dev->broadcast[9 ] = priv->pkey &0xff ; - -/* -* Update the broadcast address in the priv->broadcast object, -* in case it already exists, otherwise no one will do that. -*/ -if (priv->broadcast) { -spin_lock_irq (&priv->lock); -memcpy (priv->broadcast->mcmember.mgid.raw, - priv->dev->broadcast +4 , -sizeof (union ib_gid )); -spin_unlock_irq (&priv->lock); - } -return 0 ; }
PATCH 65/204 USB: dummy-hcd: fix connection failures (wrong speed)
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit fe659bcc9b173bcfdd958ce2aec75e47651e74e1 upstream.
The dummy-hcd UDC driver is not careful about the way it handles connection speeds. It ignores the module parameter that is supposed to govern the maximum connection speed and it doesn't set the HCD flags properly for the case where it ends up running at full speed.
The result is that in many cases, gadget enumeration over dummy-hcd fails because the bMaxPacketSize byte in the device descriptor is set incorrectly. For example, the default settings call for a high-speed connection, but the maxpacket value for ep0 ends up being set for a Super-Speed connection.
This patch fixes the problem by initializing the gadget's max_speed and the HCD flags correctly.
--- drivers/usb/gadget/dummy_hcd.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/usb/gadget/dummy_hcd.c +11 -4
@@ -973,7 +973,12 @@ static int dummy_udc_probe(struct platfo dum = *((void **)dev_get_platdata (&pdev->dev)); dum->gadget.name = gadget_name; dum->gadget.ops = &dummy_ops; - dum->gadget.max_speed =USB_SPEED_SUPER ; +if (mod_data.is_super_speed) + dum->gadget.max_speed =USB_SPEED_SUPER ; +else if (mod_data.is_high_speed) + dum->gadget.max_speed =USB_SPEED_HIGH ; +else + dum->gadget.max_speed =USB_SPEED_FULL ; dum->gadget.dev.parent = &pdev->dev;init_dummy_udc_hw (dum);
@@ -2489,8 +2494,6 @@ static struct hc_driver dummy_hcd = { .product_desc = "Dummy host controller", .hcd_priv_size = sizeof(struct dummy_hcd), - .flags = HCD_USB3 | HCD_SHARED, - .reset = dummy_setup, .start = dummy_start, .stop = dummy_stop,
@@ -2519,8 +2522,12 @@ static int dummy_hcd_probe(struct platfodev_info (&pdev->dev,"%s, driver " DRIVER_VERSION "\n" , driver_desc); dum = *((void **)dev_get_platdata (&pdev->dev)); -if (!mod_data.is_super_speed) +if (mod_data.is_super_speed) + dummy_hcd.flags =HCD_USB3 |HCD_SHARED ; +else if (mod_data.is_high_speed) dummy_hcd.flags =HCD_USB2 ; +else + dummy_hcd.flags =HCD_USB11 ; hs_hcd =usb_create_hcd (&dummy_hcd, &pdev->dev,dev_name (&pdev->dev));if (!hs_hcd)return -ENOMEM ;
PATCH 66/204 USB: dummy-hcd: fix infinite-loop resubmission bug
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 0173a68bfb0ad1c72a6ee39cc485aa2c97540b98 upstream.
The dummy-hcd HCD/UDC emulator tries not to do too much work during each timer interrupt. But it doesn't try very hard; currently all it does is limit the total amount of bulk data transferred. Other transfer types aren't limited, and URBs that transfer no data (because of an error, perhaps) don't count toward the limit, even though on a real USB bus they would consume at least a minimum overhead.
This means it's possible to get the driver stuck in an infinite loop, for example, if the host class driver resubmits an URB every time it completes (which is common for interrupt URBs). Each time the URB is resubmitted it gets added to the end of the pending-URBs list, and dummy-hcd doesn't stop until that list is empty. Andrey Konovalov was able to trigger this failure mode using the syzkaller fuzzer.
This patch fixes the infinite-loop problem by restricting the URBs handled during each timer interrupt to those that were already on the pending list when the interrupt routine started. Newly added URBs won't be processed until the next timer interrupt. The problem of properly accounting for non-bulk bandwidth (as well as packet and transaction overhead) is not addressed here.
--- drivers/usb/gadget/dummy_hcd.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/usb/gadget/dummy_hcd.c +9 -0
@@ -173,6 +173,8 @@ struct dummy_hcd {struct usb_device *udev;struct list_head urbp_list; +struct urbp *next_frame_urbp; +u32 stream_en_ep;u8 num_stream[30 /2 ];
@@ -1188,6 +1190,8 @@ static int dummy_urb_enqueue(list_add_tail (&urbp->urbp_list, &dum_hcd->urbp_list); urb->hcpriv = urbp; +if (!dum_hcd->next_frame_urbp) + dum_hcd->next_frame_urbp = urbp;if (usb_pipetype (urb->pipe) ==PIPE_CONTROL ) urb->error_count =1 ;/* mark as a new urb */
@@ -1691,6 +1695,7 @@ static void dummy_timer(unsigned long _dspin_unlock_irqrestore (&dum->lock, flags);return ; } + dum_hcd->next_frame_urbp =NULL ;for (i =0 ; i <DUMMY_ENDPOINTS ; i++) {if (!ep_name[i])
@@ -1707,6 +1712,10 @@ restart:int type;int status = -EINPROGRESS ; +/* stop when we reach URBs queued after the timer interrupt */ +if (urbp == dum_hcd->next_frame_urbp) +break ; + urb = urbp->urb;if (urb->unlinked) goto return_urb;
PATCH 67/204 USB: gadgetfs, dummy-hcd, net2280: fix locking for callbacks
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit f16443a034c7aa359ddf6f0f9bc40d01ca31faea upstream.
Using the syzkaller kernel fuzzer, Andrey Konovalov generated the following error in gadgetfs:
Quoted 101 lines
BUG: KASAN: use-after-free in __lock_acquire+0x3069/0x3690 kernel/locking/lockdep.c:3246 Read of size 8 at addr ffff88003a2bdaf8 by task kworker/3:1/903 CPU: 3 PID: 903 Comm: kworker/3:1 Not tainted 4.12.0-rc4+ #35 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 Workqueue: usb_hub_wq hub_event Call Trace: __dump_stack lib/dump_stack.c:16 [inline] dump_stack+0x292/0x395 lib/dump_stack.c:52 print_address_description+0x78/0x280 mm/kasan/report.c:252 kasan_report_error mm/kasan/report.c:351 [inline] kasan_report+0x230/0x340 mm/kasan/report.c:408 __asan_report_load8_noabort+0x19/0x20 mm/kasan/report.c:429 __lock_acquire+0x3069/0x3690 kernel/locking/lockdep.c:3246 lock_acquire+0x22d/0x560 kernel/locking/lockdep.c:3855 __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline] _raw_spin_lock+0x2f/0x40 kernel/locking/spinlock.c:151 spin_lock include/linux/spinlock.h:299 [inline] gadgetfs_suspend+0x89/0x130 drivers/usb/gadget/legacy/inode.c:1682 set_link_state+0x88e/0xae0 drivers/usb/gadget/udc/dummy_hcd.c:455 dummy_hub_control+0xd7e/0x1fb0 drivers/usb/gadget/udc/dummy_hcd.c:2074 rh_call_control drivers/usb/core/hcd.c:689 [inline] rh_urb_enqueue drivers/usb/core/hcd.c:846 [inline] usb_hcd_submit_urb+0x92f/0x20b0 drivers/usb/core/hcd.c:1650 usb_submit_urb+0x8b2/0x12c0 drivers/usb/core/urb.c:542 usb_start_wait_urb+0x148/0x5b0 drivers/usb/core/message.c:56 usb_internal_control_msg drivers/usb/core/message.c:100 [inline] usb_control_msg+0x341/0x4d0 drivers/usb/core/message.c:151 usb_clear_port_feature+0x74/0xa0 drivers/usb/core/hub.c:412 hub_port_disable+0x123/0x510 drivers/usb/core/hub.c:4177 hub_port_init+0x1ed/0x2940 drivers/usb/core/hub.c:4648 hub_port_connect drivers/usb/core/hub.c:4826 [inline] hub_port_connect_change drivers/usb/core/hub.c:4999 [inline] port_event drivers/usb/core/hub.c:5105 [inline] hub_event+0x1ae1/0x3d40 drivers/usb/core/hub.c:5185 process_one_work+0xc08/0x1bd0 kernel/workqueue.c:2097 process_scheduled_works kernel/workqueue.c:2157 [inline] worker_thread+0xb2b/0x1860 kernel/workqueue.c:2233 kthread+0x363/0x440 kernel/kthread.c:231 ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:424 Allocated by task 9958: save_stack_trace+0x1b/0x20 arch/x86/kernel/stacktrace.c:59 save_stack+0x43/0xd0 mm/kasan/kasan.c:513 set_track mm/kasan/kasan.c:525 [inline] kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:617 kmem_cache_alloc_trace+0x87/0x280 mm/slub.c:2745 kmalloc include/linux/slab.h:492 [inline] kzalloc include/linux/slab.h:665 [inline] dev_new drivers/usb/gadget/legacy/inode.c:170 [inline] gadgetfs_fill_super+0x24f/0x540 drivers/usb/gadget/legacy/inode.c:1993 mount_single+0xf6/0x160 fs/super.c:1192 gadgetfs_mount+0x31/0x40 drivers/usb/gadget/legacy/inode.c:2019 mount_fs+0x9c/0x2d0 fs/super.c:1223 vfs_kern_mount.part.25+0xcb/0x490 fs/namespace.c:976 vfs_kern_mount fs/namespace.c:2509 [inline] do_new_mount fs/namespace.c:2512 [inline] do_mount+0x41b/0x2d90 fs/namespace.c:2834 SYSC_mount fs/namespace.c:3050 [inline] SyS_mount+0xb0/0x120 fs/namespace.c:3027 entry_SYSCALL_64_fastpath+0x1f/0xbe Freed by task 9960: save_stack_trace+0x1b/0x20 arch/x86/kernel/stacktrace.c:59 save_stack+0x43/0xd0 mm/kasan/kasan.c:513 set_track mm/kasan/kasan.c:525 [inline] kasan_slab_free+0x72/0xc0 mm/kasan/kasan.c:590 slab_free_hook mm/slub.c:1357 [inline] slab_free_freelist_hook mm/slub.c:1379 [inline] slab_free mm/slub.c:2961 [inline] kfree+0xed/0x2b0 mm/slub.c:3882 put_dev+0x124/0x160 drivers/usb/gadget/legacy/inode.c:163 gadgetfs_kill_sb+0x33/0x60 drivers/usb/gadget/legacy/inode.c:2027 deactivate_locked_super+0x8d/0xd0 fs/super.c:309 deactivate_super+0x21e/0x310 fs/super.c:340 cleanup_mnt+0xb7/0x150 fs/namespace.c:1112 __cleanup_mnt+0x1b/0x20 fs/namespace.c:1119 task_work_run+0x1a0/0x280 kernel/task_work.c:116 exit_task_work include/linux/task_work.h:21 [inline] do_exit+0x18a8/0x2820 kernel/exit.c:878 do_group_exit+0x14e/0x420 kernel/exit.c:982 get_signal+0x784/0x1780 kernel/signal.c:2318 do_signal+0xd7/0x2130 arch/x86/kernel/signal.c:808 exit_to_usermode_loop+0x1ac/0x240 arch/x86/entry/common.c:157 prepare_exit_to_usermode arch/x86/entry/common.c:194 [inline] syscall_return_slowpath+0x3ba/0x410 arch/x86/entry/common.c:263 entry_SYSCALL_64_fastpath+0xbc/0xbe The buggy address belongs to the object at ffff88003a2bdae0 which belongs to the cache kmalloc-1024 of size 1024 The buggy address is located 24 bytes inside of 1024-byte region [ffff88003a2bdae0, ffff88003a2bdee0) The buggy address belongs to the page: page:ffffea0000e8ae00 count:1 mapcount:0 mapping: (null) index:0x0 compound_mapcount: 0 flags: 0x100000000008100(slab|head) raw: 0100000000008100 0000000000000000 0000000000000000 0000000100170017 raw: ffffea0000ed3020 ffffea0000f5f820 ffff88003e80efc0 0000000000000000 page dumped because: kasan: bad access detected
Quoted 8 lines
Memory state around the buggy address:
ffff88003a2bd980: fb fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88003a2bda00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88003a2bda80: fc fc fc fc fc fc fc fc fc fc fc fc fb fb fb fb
^
ffff88003a2bdb00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88003a2bdb80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================What this means is that the gadgetfs_suspend() routine was trying to access dev->lock after it had been deallocated. The root cause is a race in the dummy_hcd driver; the dummy_udc_stop() routine can race with the rest of the driver because it contains no locking. And even when proper locking is added, it can still race with the set_link_state() function because that function incorrectly drops the private spinlock before invoking any gadget driver callbacks.
The result of this race, as seen above, is that set_link_state() can invoke a callback in gadgetfs even after gadgetfs has been unbound from dummy_hcd's UDC and its private data structures have been deallocated.
include/linux/usb/gadget.h documents that the ->reset, ->disconnect, ->suspend, and ->resume callbacks may be invoked in interrupt context. In general this is necessary, to prevent races with gadget driver removal. This patch fixes dummy_hcd to retain the spinlock across these calls, and it adds a spinlock acquisition to dummy_udc_stop() to prevent the race.
The net2280 driver makes the same mistake of dropping the private spinlock for its ->disconnect and ->reset callback invocations. The patch fixes it too.
Lastly, since gadgetfs_suspend() may be invoked in interrupt context, it cannot assume that interrupts are enabled when it runs. It must use spin_lock_irqsave() instead of spin_lock_irq(). The patch fixes that bug as well.
[bwh: Backported to 3.16:
- Drop changes in net2280's handle_stat1_irqs()
- Adjust filenames, context]
---
drivers/usb/gadget/inode.c +3 -2
@@ -1798,9 +1798,10 @@ static void gadgetfs_suspend (struct usb_gadget *gadget) {struct dev_data *dev =get_gadget_data (gadget); +unsigned long flags;INFO (dev,"suspended from state %d\n" , dev->state); -spin_lock (&dev->lock); +spin_lock_irqsave (&dev->lock, flags);switch (dev->state) {case STATE_DEV_SETUP :// VERY odd... host died?? case STATE_DEV_CONNECTED :
@@ -1811,7 +1812,7 @@ gadgetfs_suspend (struct usb_gadget *gaddefault :break ; } -spin_unlock (&dev->lock); +spin_unlock_irqrestore (&dev->lock, flags); }static struct usb_gadget_driver gadgetfs_driver = {
drivers/usb/gadget/dummy_hcd.c +4 -9
@@ -379,20 +379,13 @@ static void set_link_state(struct dummy_ (dum_hcd->old_status & USB_PORT_STAT_RESET) == 0 && dum->driver) {stop_activity (dum); -spin_unlock (&dum->lock); dum->driver->disconnect (&dum->gadget); -spin_lock (&dum->lock); } }else if (dum_hcd->active != dum_hcd->old_active) { -if (dum_hcd->old_active && dum->driver->suspend) { -spin_unlock (&dum->lock); +if (dum_hcd->old_active && dum->driver->suspend) dum->driver->suspend (&dum->gadget); -spin_lock (&dum->lock); - }else if (!dum_hcd->old_active && dum->driver->resume) { -spin_unlock (&dum->lock); +else if (!dum_hcd->old_active && dum->driver->resume) dum->driver->resume (&dum->gadget); -spin_lock (&dum->lock); - } } dum_hcd->old_status = dum_hcd->port_status;
@@ -926,7 +919,9 @@ static int dummy_udc_stop(struct usb_gaddev_dbg (udc_dev (dum),"unregister gadget driver '%s'\n" , driver->driver.name); +spin_lock_irq (&dum->lock); dum->driver =NULL ; +spin_unlock_irq (&dum->lock);return 0 ; }
drivers/usb/gadget/net2280.c +1 -4
@@ -1941,11 +1941,8 @@ stop_activity (struct net2280 *dev, strunuke (&dev->ep [i]);/* report disconnect; the driver is already quiesced */ -if (driver) { -spin_unlock (&dev->lock); +if (driver) driver->disconnect (&dev->gadget); -spin_lock (&dev->lock); - }usb_reinit (dev); }
PATCH 68/204 USB: dummy-hcd: Fix erroneous synchronization change
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 7dbd8f4cabd96db5a50513de9d83a8105a5ffc81 upstream.
A recent change to the synchronization in dummy-hcd was incorrect. The issue was that dummy_udc_stop() contained no locking and therefore could race with various gadget driver callbacks, and the fix was to add locking and issue the callbacks with the private spinlock held.
UDC drivers aren't supposed to do this. Gadget driver callback routines are allowed to invoke functions in the UDC driver, and these functions will generally try to acquire the private spinlock. This would deadlock the driver.
The correct solution is to drop the spinlock before issuing callbacks, and avoid races by emulating the synchronize_irq() call that all real UDC drivers must perform in their ->udc_stop() routines after disabling interrupts. This involves adding a flag to dummy-hcd's private structure to keep track of whether interrupts are supposed to be enabled, and adding a counter to keep track of ongoing callbacks so that dummy_udc_stop() can wait for them all to finish.
A real UDC driver won't receive disconnect, reset, suspend, resume, or setup events once it has disabled interrupts. dummy-hcd will receive them but won't try to issue any gadget driver callbacks, which should be just as good.
--- drivers/usb/gadget/dummy_hcd.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-)
drivers/usb/gadget/dummy_hcd.c +30 -2
@@ -191,11 +191,13 @@ struct dummy {*/ struct dummy_ep ep[DUMMY_ENDPOINTS ];int address; +int callback_usage;struct usb_gadget gadget;struct usb_gadget_driver *driver;struct dummy_request fifo_req;u8 fifo_buf[FIFO_SIZE ];u16 devstatus; + unsigned ints_enabled:1; unsigned udc_suspended:1; unsigned pullup:1;
@@ -377,15 +379,24 @@ static void set_link_state(struct dummy_*/ if ((dum_hcd->old_status &USB_PORT_STAT_CONNECTION ) !=0 && (dum_hcd->old_status &USB_PORT_STAT_RESET ) ==0 && - dum->driver) { + dum->ints_enabled) {stop_activity (dum); + ++dum->callback_usage; +spin_unlock (&dum->lock); dum->driver->disconnect (&dum->gadget); +spin_lock (&dum->lock); + --dum->callback_usage; } - }else if (dum_hcd->active != dum_hcd->old_active) { + }else if (dum_hcd->active != dum_hcd->old_active && + dum->ints_enabled) { + ++dum->callback_usage; +spin_unlock (&dum->lock);if (dum_hcd->old_active && dum->driver->suspend) dum->driver->suspend (&dum->gadget);else if (!dum_hcd->old_active && dum->driver->resume) dum->driver->resume (&dum->gadget); +spin_lock (&dum->lock); + --dum->callback_usage; } dum_hcd->old_status = dum_hcd->port_status;
@@ -901,9 +912,12 @@ static int dummy_udc_start(struct usb_ga* can't enumerate without help from the driver we're binding. */ +spin_lock_irq (&dum->lock); dum->devstatus =0 ; dum->driver = driver; + dum->ints_enabled =1 ; +spin_unlock_irq (&dum->lock);dev_dbg (udc_dev (dum),"binding gadget driver '%s'\n" , driver->driver.name);return 0 ;
@@ -920,6 +934,16 @@ static int dummy_udc_stop(struct usb_gad driver->driver.name);spin_lock_irq (&dum->lock); + dum->ints_enabled =0 ; +stop_activity (dum); + +/* emulate synchronize_irq(): wait for callbacks to finish */ +while (dum->callback_usage >0 ) { +spin_unlock_irq (&dum->lock); +usleep_range (1000 ,2000 ); +spin_lock_irq (&dum->lock); + } + dum->driver =NULL ;spin_unlock_irq (&dum->lock);
@@ -1449,6 +1473,8 @@ static struct dummy_ep *find_endpoint(stif (!is_active ((dum->gadget.speed ==USB_SPEED_SUPER ? dum->ss_hcd : dum->hs_hcd)))return NULL ; +if (!dum->ints_enabled) +return NULL ;if ((address & ~USB_DIR_IN ) ==0 )return &dum->ep[0 ];for (i =1 ; i <DUMMY_ENDPOINTS ; i++) {
@@ -1790,10 +1816,12 @@ restart:* until setup() returns; no reentrancy issues etc. */ if (value >0 ) { + ++dum->callback_usage;spin_unlock (&dum->lock); value = dum->driver->setup (&dum->gadget, &setup);spin_lock (&dum->lock); + --dum->callback_usage;if (value >=0 ) {/* no delays (max 64KB data stage) */
PATCH 69/204 usb: renesas_usbhs: fix the BCLR setting condition for non-DCP pipe
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Yoshihiro Shimoda <[email protected]>
commit 6124607acc88fffeaadf3aacfeb3cc1304c87387 upstream.
This patch fixes an issue that the driver sets the BCLR bit of {C,Dn}FIFOCTR register to 1 even when it's non-DCP pipe and the FRDY bit of {C,Dn}FIFOCTR register is set to 1.
--- drivers/usb/renesas_usbhs/fifo.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/usb/renesas_usbhs/fifo.c +8 -2
@@ -261,11 +261,17 @@ static void usbhsf_fifo_clear(struct usb struct usbhs_fifo *fifo) {struct usbhs_priv *priv =usbhs_pipe_to_priv (pipe); +int ret =0 ;if (!usbhs_pipe_is_dcp (pipe)) -usbhsf_fifo_barrier (priv, fifo); + ret =usbhsf_fifo_barrier (priv, fifo); -usbhs_write (priv, fifo->ctr,BCLR ); +/* +* if non-DCP pipe, this driver should set BCLR when +* usbhsf_fifo_barrier() returns 0. +*/ +if (!ret) +usbhs_write (priv, fifo->ctr,BCLR ); } static int usbhsf_fifo_rcv_len(struct usbhs_priv *priv,
PATCH 70/204 usb: renesas_usbhs: fix usbhsf_fifo_clear() for RX direction
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Yoshihiro Shimoda <[email protected]>
commit 0a2ce62b61f2c76d0213edf4e37aaf54a8ddf295 upstream.
This patch fixes an issue that the usbhsf_fifo_clear() is possible to cause 10 msec delay if the pipe is RX direction and empty because the FRDY bit will never be set to 1 in such case.
--- drivers/usb/renesas_usbhs/fifo.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/usb/renesas_usbhs/fifo.c +11 -2
@@ -263,8 +263,17 @@ static void usbhsf_fifo_clear(struct usbstruct usbhs_priv *priv =usbhs_pipe_to_priv (pipe);int ret =0 ; -if (!usbhs_pipe_is_dcp (pipe)) - ret =usbhsf_fifo_barrier (priv, fifo); +if (!usbhs_pipe_is_dcp (pipe)) { +/* +* This driver checks the pipe condition first to avoid -EBUSY +* from usbhsf_fifo_barrier() with about 10 msec delay in +* the interrupt handler if the pipe is RX direction and empty. +*/ +if (usbhs_pipe_is_dir_in (pipe)) + ret =usbhs_pipe_is_accessible (pipe); +if (!ret) + ret =usbhsf_fifo_barrier (priv, fifo); + }/* * if non-DCP pipe, this driver should set BCLR when
PATCH 71/204 packet: only test po->has_vnet_hdr once in packet_snd
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Willem de Bruijn <[email protected]>
commit da7c9561015e93d10fe6aab73e9288e0d09d65a6 upstream.
Packet socket option po->has_vnet_hdr can be updated concurrently with other operations if no ring is attached.
Do not test the option twice in packet_snd, as the value may change in between calls. A race on setsockopt disable may cause a packet > mtu to be sent without having GSO options set.
--- net/packet/af_packet.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/packet/af_packet.c +3 -1
@@ -2432,6 +2432,7 @@ static int packet_snd(struct socket *socint offset =0 ;int vnet_hdr_len;struct packet_sock *po =pkt_sk (sk); +bool has_vnet_hdr = false;unsigned short gso_type =0 ;int hlen, tlen;int extra_len =0 ;
@@ -2466,6 +2467,7 @@ static int packet_snd(struct socket *soc reserve = dev->hard_header_len;if (po->has_vnet_hdr) { vnet_hdr_len =sizeof (vnet_hdr); + has_vnet_hdr = true; err = -EINVAL ;if (len < vnet_hdr_len)
@@ -2557,7 +2559,7 @@ static int packet_snd(struct socket *soc skb->priority = sk->sk_priority; skb->mark = sk->sk_mark; -if (po->has_vnet_hdr) { +if (has_vnet_hdr) {if (vnet_hdr.flags &VIRTIO_NET_HDR_F_NEEDS_CSUM ) {if (!skb_partial_csum_set (skb, vnet_hdr.csum_start, vnet_hdr.csum_offset)) {
PATCH 72/204 sched/sysctl: Check user input value of sysctl_sched_time_avg
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ethan Zhao <[email protected]>
commit 5ccba44ba118a5000cccc50076b0344632459779 upstream.
System will hang if user set sysctl_sched_time_avg to 0:
[root@XXX ~]# sysctl kernel.sched_time_avg_ms=0
Stack traceback for pid 0
0xffff883f6406c600 0 0 1 3 R 0xffff883f6406cf50 *swapper/3 ffff883f7ccc3ae8 0000000000000018 ffffffff810c4dd0 0000000000000000 0000000000017800 ffff883f7ccc3d78 0000000000000003 ffff883f7ccc3bf8 ffffffff810c4fc9 ffff883f7ccc3c08 00000000810c5043 ffff883f7ccc3c08
Call Trace: <IRQ> [<ffffffff810c4dd0>] ? update_group_capacity+0x110/0x200 [<ffffffff810c4fc9>] ? update_sd_lb_stats+0x109/0x600 [<ffffffff810c5507>] ? find_busiest_group+0x47/0x530 [<ffffffff810c5b84>] ? load_balance+0x194/0x900 [<ffffffff810ad5ca>] ? update_rq_clock.part.83+0x1a/0xe0 [<ffffffff810c6d42>] ? rebalance_domains+0x152/0x290 [<ffffffff810c6f5c>] ? run_rebalance_domains+0xdc/0x1d0 [<ffffffff8108a75b>] ? __do_softirq+0xfb/0x320 [<ffffffff8108ac85>] ? irq_exit+0x125/0x130 [<ffffffff810b3a17>] ? scheduler_ipi+0x97/0x160 [<ffffffff81052709>] ? smp_reschedule_interrupt+0x29/0x30 [<ffffffff8173a1be>] ? reschedule_interrupt+0x6e/0x80 <EOI> [<ffffffff815bc83c>] ? cpuidle_enter_state+0xcc/0x230 [<ffffffff815bc80c>] ? cpuidle_enter_state+0x9c/0x230 [<ffffffff815bc9d7>] ? cpuidle_enter+0x17/0x20 [<ffffffff810cd6dc>] ? cpu_startup_entry+0x38c/0x420 [<ffffffff81053373>] ? start_secondary+0x173/0x1e0
Because divide-by-zero error happens in function:
update_group_capacity()
update_cpu_capacity()
scale_rt_capacity()
{
...
total = sched_avg_period() + delta;
used = div_u64(avg, total);
...
}To fix this issue, check user input value of sysctl_sched_time_avg, keep it unchanged when hitting invalid input, and set the minimum limit of sysctl_sched_time_avg to 1 ms.
--- kernel/sysctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sysctl.c +2 -1
@@ -342,7 +342,8 @@ static struct ctl_table kern_table[] = { .data = &sysctl_sched_time_avg, .maxlen = sizeof(unsigned int), .mode = 0644, - .proc_handler = proc_dointvec, + .proc_handler = proc_dointvec_minmax, + .extra1 = &one, }, { .procname = "sched_shares_window_ns",
PATCH 73/204 arm64: fault: Route pte translation faults via do_translation_fault
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
commit 760bfb47c36a07741a089bf6a28e854ffbee7dc9 upstream.
We currently route pte translation faults via do_page_fault, which elides the address check against TASK_SIZE before invoking the mm fault handling code. However, this can cause issues with the path walking code in conjunction with our word-at-a-time implementation because load_unaligned_zeropad can end up faulting in kernel space if it reads across a page boundary and runs into a page fault (e.g. by attempting to read from a guard region).
In the case of such a fault, load_unaligned_zeropad has registered a fixup to shift the valid data and pad with zeroes, however the abort is reported as a level 3 translation fault and we dispatch it straight to do_page_fault, despite it being a kernel address. This results in calling a sleeping function from atomic context:
BUG: sleeping function called from invalid context at arch/arm64/mm/fault.c:313 in_atomic(): 0, irqs_disabled(): 0, pid: 10290 Internal error: Oops - BUG: 0 [#1] PREEMPT SMP [...] [<ffffff8e016cd0cc>] ___might_sleep+0x134/0x144 [<ffffff8e016cd158>] __might_sleep+0x7c/0x8c [<ffffff8e016977f0>] do_page_fault+0x140/0x330 [<ffffff8e01681328>] do_mem_abort+0x54/0xb0 Exception stack(0xfffffffb20247a70 to 0xfffffffb20247ba0) [...] [<ffffff8e016844fc>] el1_da+0x18/0x78 [<ffffff8e017f399c>] path_parentat+0x44/0x88 [<ffffff8e017f4c9c>] filename_parentat+0x5c/0xd8 [<ffffff8e017f5044>] filename_create+0x4c/0x128 [<ffffff8e017f59e4>] SyS_mkdirat+0x50/0xc8 [<ffffff8e01684e30>] el0_svc_naked+0x24/0x28 Code: 36380080 d5384100 f9400800 9402566d (d4210000) ---[ end trace 2d01889f2bca9b9f ]---
Fix this by dispatching all translation faults to do_translation_faults, which avoids invoking the page fault logic for faults on kernel addresses.
--- arch/arm64/mm/fault.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/mm/fault.c +1 -1
@@ -386,7 +386,7 @@ static struct fault_info { { do_translation_fault, SIGSEGV, SEGV_MAPERR, "input address range fault" }, { do_translation_fault, SIGSEGV, SEGV_MAPERR, "level 1 translation fault" }, { do_translation_fault, SIGSEGV, SEGV_MAPERR, "level 2 translation fault" }, - { do_page_fault, SIGSEGV, SEGV_MAPERR, "level 3 translation fault" }, + { do_translation_fault, SIGSEGV, SEGV_MAPERR, "level 3 translation fault" }, { do_bad, SIGBUS, 0, "reserved access flag fault" }, { do_page_fault, SIGSEGV, SEGV_ACCERR, "level 1 access flag fault" }, { do_page_fault, SIGSEGV, SEGV_ACCERR, "level 2 access flag fault" },
PATCH 74/204 staging: iio: ade7759: fix signed extension bug on shift of a u8
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Colin Ian King <[email protected]>
commit 13ffe9a26df4e156363579b25c904dd0b1e31bfb upstream.
The current shift of st->rx[2] left shifts a u8 24 bits left, promotes the integer to a an int and then to a unsigned u64. If the top bit of st->rx[2] is set then we end up with all the upper bits being set to 1. Fix this by casting st->rx[2] to a u64 before the 24 bit left shift.
Detected by CoverityScan CID#144940 ("Unintended sign extension")
--- drivers/staging/iio/meter/ade7759.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/meter/ade7759.c +1 -1
@@ -124,7 +124,7 @@ static int ade7759_spi_read_reg_40(struc reg_address); goto error_ret; } - *val = ((u64 )st->rx[1 ] <<32 ) | (st->rx[2 ] <<24 ) | + *val = ((u64 )st->rx[1 ] <<32 ) | ((u64 )st->rx[2 ] <<24 ) | (st->rx[3 ] <<16 ) | (st->rx[4 ] <<8 ) | st->rx[5 ]; error_ret:
PATCH 75/204 ipv4: fix broadcast packets reception
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
commit ad0ea1989cc4d5905941d0a9e62c63ad6d859cef upstream.
Currently, ingress ipv4 broadcast datagrams are dropped since, in udp_v4_early_demux(), ip_check_mc_rcu() is invoked even on bcast packets.
This patch addresses the issue, invoking ip_check_mc_rcu() only for mcast packets.
--- net/ipv4/udp.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
net/ipv4/udp.c +8 -4
@@ -1974,10 +1974,14 @@ void udp_v4_early_demux(struct sk_buff *if (!in_dev)return ; - ours =ip_check_mc_rcu (in_dev, iph->daddr, iph->saddr, - iph->protocol); -if (!ours) -return ; +/* we are supposed to accept bcast packets */ +if (skb->pkt_type ==PACKET_MULTICAST ) { + ours =ip_check_mc_rcu (in_dev, iph->daddr, iph->saddr, + iph->protocol); +if (!ours) +return ; + } + sk =__udp4_lib_mcast_demux_lookup (net, uh->dest, iph->daddr, uh->source, iph->saddr, dif); }else if (skb->pkt_type ==PACKET_HOST ) {
PATCH 76/204 IPv4: early demux can return an error code
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
commit 7487449c86c65202b3b725c4524cb48dd65e4e6f upstream.
Currently no error is emitted, but this infrastructure will used by the next patch to allow source address validation for mcast sockets.
Since early demux can do a route lookup and an ipv4 route lookup can return an error code this is consistent with the current ipv4 route infrastructure.
[bwh: Backported to 3.16:
- Drop change to net_protocol::early_demux_handler
- Keep using NET_INC_STATS_BH() in ip_rcv_finish()
- Fix up additional return statement in udp_v4_early_demux()
- Adjust context]
---
include/net/protocol.h +1 -1
@@ -39,7 +39,7 @@/* This is used to register protocols. */ struct net_protocol { -void (*early_demux)(struct sk_buff *skb); +int (*early_demux)(struct sk_buff *skb);int (*handler)(struct sk_buff *skb);void (*err_handler)(struct sk_buff *skb,u32 info); unsigned int no_policy:1,
include/net/tcp.h +1 -1
@@ -350,7 +350,7 @@ void tcp_v4_err(struct sk_buff *skb, u32void tcp_shutdown (struct sock *sk,int how); -void tcp_v4_early_demux (struct sk_buff *skb); +int tcp_v4_early_demux (struct sk_buff *skb);int tcp_v4_rcv (struct sk_buff *skb);int tcp_v4_tw_remember_stamp (struct inet_timewait_sock *tw);
include/net/udp.h +1 -1
@@ -177,7 +177,7 @@ int udp_lib_get_port(struct sock *sk, un unsigned int hash2_nulladdr);/* net/ipv4/udp.c */ -void udp_v4_early_demux (struct sk_buff *skb); +int udp_v4_early_demux (struct sk_buff *skb);int udp_get_port (struct sock *sk,unsigned short snum,int (*saddr_cmp)(const struct sock *,const struct sock *));
net/ipv4/ip_input.c +13 -9
@@ -313,6 +313,7 @@ static int ip_rcv_finish(struct sk_buff {const struct iphdr *iph =ip_hdr (skb);struct rtable *rt; +int err;if (sysctl_ip_early_demux && !skb_dst (skb) && skb->sk ==NULL ) {const struct net_protocol *ipprot;
@@ -320,7 +321,9 @@ static int ip_rcv_finish(struct sk_buff ipprot =rcu_dereference (inet_protos[protocol]);if (ipprot && ipprot->early_demux) { - ipprot->early_demux (skb); + err = ipprot->early_demux (skb); +if (unlikely (err)) + goto drop_error;/* must reload iph, skb->head might have changed */ iph =ip_hdr (skb); }
@@ -331,14 +334,10 @@ static int ip_rcv_finish(struct sk_buff* how the packet travels inside Linux networking. */ if (!skb_dst (skb)) { -int err =ip_route_input_noref (skb, iph->daddr, iph->saddr, - iph->tos, skb->dev); -if (unlikely (err)) { -if (err == -EXDEV ) -NET_INC_STATS_BH (dev_net (skb->dev), -LINUX_MIB_IPRPFILTER ); - goto drop; - } + err =ip_route_input_noref (skb, iph->daddr, iph->saddr, + iph->tos, skb->dev); +if (unlikely (err)) + goto drop_error; }#ifdef CONFIG_IP_ROUTE_CLASSID
@@ -368,6 +367,11 @@ static int ip_rcv_finish(struct sk_buff drop:kfree_skb (skb);return NET_RX_DROP ; + +drop_error: +if (err == -EXDEV ) +NET_INC_STATS_BH (dev_net (skb->dev),LINUX_MIB_IPRPFILTER ); + goto drop; }/*
net/ipv4/tcp_ipv4.c +5 -4
@@ -1616,23 +1616,23 @@ csum_err: }EXPORT_SYMBOL (tcp_v4_do_rcv); -void tcp_v4_early_demux (struct sk_buff *skb) +int tcp_v4_early_demux (struct sk_buff *skb) {const struct iphdr *iph;const struct tcphdr *th;struct sock *sk;if (skb->pkt_type !=PACKET_HOST ) -return ; +return 0 ;if (!pskb_may_pull (skb,skb_transport_offset (skb) +sizeof (struct tcphdr ))) -return ; +return 0 ; iph =ip_hdr (skb); th =tcp_hdr (skb);if (th->doff <sizeof (struct tcphdr ) /4 ) -return ; +return 0 ; sk = __inet_lookup_established(dev_net(skb->dev), &tcp_hashinfo, iph->saddr, th->source,
@@ -1651,6 +1651,7 @@ void tcp_v4_early_demux(struct sk_buff *skb_dst_set_noref (skb, dst); } } +return 0 ; }/* Packet is added to VJ-style prequeue for processing in process
net/ipv4/udp.c +7 -6
@@ -1950,7 +1950,7 @@ static struct sock *__udp4_lib_demux_looreturn result; } -void udp_v4_early_demux (struct sk_buff *skb) +int udp_v4_early_demux (struct sk_buff *skb) {struct net *net =dev_net (skb->dev);const struct iphdr *iph;
@@ -1962,7 +1962,7 @@ void udp_v4_early_demux(struct sk_buff */* validate the packet */ if (!pskb_may_pull (skb,skb_transport_offset (skb) +sizeof (struct udphdr ))) -return ; +return 0 ; iph =ip_hdr (skb); uh =udp_hdr (skb);
@@ -1972,14 +1972,14 @@ void udp_v4_early_demux(struct sk_buff *struct in_device *in_dev =__in_dev_get_rcu (skb->dev);if (!in_dev) -return ; +return 0 ;/* we are supposed to accept bcast packets */ if (skb->pkt_type ==PACKET_MULTICAST ) { ours =ip_check_mc_rcu (in_dev, iph->daddr, iph->saddr, iph->protocol);if (!ours) -return ; +return 0 ; } sk = __udp4_lib_mcast_demux_lookup(net, uh->dest, iph->daddr,
@@ -1988,11 +1988,11 @@ void udp_v4_early_demux(struct sk_buff * sk =__udp4_lib_demux_lookup (net, uh->dest, iph->daddr, uh->source, iph->saddr, dif); }else { -return ; +return 0 ; }if (!sk) -return ; +return 0 ; skb->sk = sk; skb->destructor = sock_edemux;
@@ -2009,6 +2009,7 @@ void udp_v4_early_demux(struct sk_buff *skb_dst_set_noref (skb, dst); } } +return 0 ; }int udp_rcv (struct sk_buff *skb)
PATCH 77/204 udp: perform source validation for mcast early demux
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
commit bc044e8db7962e727a75b591b9851ff2ac5cf846 upstream.
The UDP early demux can leverate the rx dst cache even for multicast unconnected sockets.
In such scenario the ipv4 source address is validated only on the first packet in the given flow. After that, when we fetch the dst entry from the socket rx cache, we stop enforcing the rp_filter and we even start accepting any kind of martian addresses.
Disabling the dst cache for unconnected multicast socket will cause large performace regression, nearly reducing by half the max ingress tput.
Instead we factor out a route helper to completely validate an skb source address for multicast packets and we call it from the UDP early demux for mcast packets landing on unconnected sockets, after successful fetching the related cached dst entry.
This still gives a measurable, but limited performance regression:
rp_filter = 0 rp_filter = 1
edmux disabled: 1182 Kpps 1127 Kpps
edmux before: 2238 Kpps 2238 Kpps
edmux after: 2037 Kpps 2019 Kpps
The above figures are on top of current net tree. Applying the net-next commit 6e617de84e87 ("net: avoid a full fib lookup when rp_filter is disabled.") the delta with rp_filter == 0 will decrease even more.
--- include/net/route.h | 4 +++- net/ipv4/route.c | 46 ++++++++++++++++++++++++++-------------------- net/ipv4/udp.c | 13 ++++++++++++- 3 files changed, 41 insertions(+), 22 deletions(-)
include/net/route.h +3 -1
@@ -159,7 +159,9 @@ static inline struct rtable *ip_route_ou fl4->fl4_gre_key = gre_key;return ip_route_output_key (net, fl4); } - +int ip_mc_validate_source (struct sk_buff *skb,__be32 daddr,__be32 saddr, +u8 tos,struct net_device *dev, +struct in_device *in_dev,u32 *itag);int ip_route_input_noref (struct sk_buff *skb,__be32 dst,__be32 src,u8 tos,struct net_device *devin);
net/ipv4/route.c +25 -19
78 lines not on this page · raw message
net/ipv4/udp.c +12 -1
@@ -1953,6 +1953,7 @@ static struct sock *__udp4_lib_demux_looint udp_v4_early_demux (struct sk_buff *skb) {struct net *net =dev_net (skb->dev); +struct in_device *in_dev =NULL ;const struct iphdr *iph;const struct udphdr *uh;struct sock *sk;
@@ -1969,7 +1970,7 @@ int udp_v4_early_demux(struct sk_buff *sif (skb->pkt_type ==PACKET_BROADCAST || skb->pkt_type ==PACKET_MULTICAST ) { -struct in_device *in_dev =__in_dev_get_rcu (skb->dev); + in_dev =__in_dev_get_rcu (skb->dev);if (!in_dev)return 0 ;
@@ -2001,6 +2002,8 @@ int udp_v4_early_demux(struct sk_buff *sif (dst) dst =dst_check (dst,0 );if (dst) { +u32 itag =0 ; +/* DST_NOCACHE can not be used without taking a reference */ if (dst->flags &DST_NOCACHE ) {if (likely (atomic_inc_not_zero (&dst->__refcnt)))
@@ -2008,6 +2011,14 @@ int udp_v4_early_demux(struct sk_buff *s }else {skb_dst_set_noref (skb, dst); } + +/* for unconnected multicast sockets we need to validate +* the source on each packet +*/ +if (!inet_sk (sk)->inet_daddr && in_dev) +return ip_mc_validate_source (skb, iph->daddr, + iph->saddr, iph->tos, + skb->dev, in_dev, &itag); }return 0 ; }
PATCH 78/204 l2tp: fix l2tp_eth module loading
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Nault <[email protected]>
commit 9f775ead5e570e7e19015b9e4e2f3dd6e71a5935 upstream.
The l2tp_eth module crashes if its netlink callbacks are run when the pernet data aren't initialised.
We should normally register_pernet_device() before the genl callbacks. However, the pernet data only maintain a list of l2tpeth interfaces, and this list is never used. So let's just drop pernet handling instead.
--- net/l2tp/l2tp_eth.c | 51 ++------------------------------------------------- 1 file changed, 2 insertions(+), 49 deletions(-)
net/l2tp/l2tp_eth.c +2 -49
@@ -41,7 +41,6 @@ struct l2tp_eth {struct net_device *dev;struct sock *tunnel_sock;struct l2tp_session *session; -struct list_head list;atomic_long_t tx_bytes;atomic_long_t tx_packets;atomic_long_t tx_dropped;
@@ -55,17 +54,6 @@ struct l2tp_eth_sess {struct net_device *dev; }; -/* per-net private data for this module */ -static unsigned int l2tp_eth_net_id; -struct l2tp_eth_net { -struct list_head l2tp_eth_dev_list; -spinlock_t l2tp_eth_lock; -}; - -static inline struct l2tp_eth_net *l2tp_eth_pernet (struct net *net) -{ -return net_generic (net, l2tp_eth_net_id); -}static struct lock_class_key l2tp_eth_tx_busylock;static int l2tp_eth_dev_init (struct net_device *dev)
@@ -81,12 +69,6 @@ static int l2tp_eth_dev_init(struct net_static void l2tp_eth_dev_uninit (struct net_device *dev) { -struct l2tp_eth *priv =netdev_priv (dev); -struct l2tp_eth_net *pn =l2tp_eth_pernet (dev_net (dev)); - -spin_lock (&pn->l2tp_eth_lock); -list_del_init (&priv->list); -spin_unlock (&pn->l2tp_eth_lock);dev_put (dev); }
@@ -216,7 +198,6 @@ static int l2tp_eth_create(struct net *nstruct l2tp_eth *priv;struct l2tp_eth_sess *spriv;int rc; -struct l2tp_eth_net *pn;if (cfg->ifname) { dev =dev_get_by_name (net, cfg->ifname);
@@ -251,7 +232,6 @@ static int l2tp_eth_create(struct net *n priv =netdev_priv (dev); priv->dev = dev; priv->session = session; -INIT_LIST_HEAD (&priv->list); priv->tunnel_sock = tunnel->sock; session->recv_skb = l2tp_eth_dev_recv;
@@ -272,10 +252,6 @@ static int l2tp_eth_create(struct net *nstrlcpy (session->ifname, dev->name,IFNAMSIZ );dev_hold (dev); - pn =l2tp_eth_pernet (dev_net (dev)); -spin_lock (&pn->l2tp_eth_lock); -list_add (&priv->list, &pn->l2tp_eth_dev_list); -spin_unlock (&pn->l2tp_eth_lock);return 0 ;
@@ -288,22 +264,6 @@ out:return rc; } -static __net_init int l2tp_eth_init_net (struct net *net) -{ -struct l2tp_eth_net *pn =net_generic (net, l2tp_eth_net_id); - -INIT_LIST_HEAD (&pn->l2tp_eth_dev_list); -spin_lock_init (&pn->l2tp_eth_lock); - -return 0 ; -} - -static struct pernet_operations l2tp_eth_net_ops = { - .init = l2tp_eth_init_net, - .id = &l2tp_eth_net_id, - .size =sizeof (struct l2tp_eth_net ), -}; -static const struct l2tp_nl_cmd_ops l2tp_eth_nl_cmd_ops = { .session_create = l2tp_eth_create,
@@ -317,25 +277,18 @@ static int __init l2tp_eth_init(void) err =l2tp_nl_register_ops (L2TP_PWTYPE_ETH , &l2tp_eth_nl_cmd_ops);if (err) - goto out; - - err =register_pernet_device (&l2tp_eth_net_ops); -if (err) - goto out_unreg; + goto err;pr_info ("L2TP ethernet pseudowire support (L2TPv3)\n" );return 0 ; -out_unreg: -l2tp_nl_unregister_ops (L2TP_PWTYPE_ETH ); -out: +err:return err; } static void __exit l2tp_eth_exit(void) { -unregister_pernet_device (&l2tp_eth_net_ops);l2tp_nl_unregister_ops (L2TP_PWTYPE_ETH ); }
PATCH 79/204 brcmfmac: Add length checks on firmware events
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hante Meuleman <[email protected]>
commit 0aedbcaf6f182690790d98d90d5fe1e64c846c34 upstream.
Add additional length checks on firmware events to create more robust code.
[bwh: Backported to 3.16:
- Drop changes to brcmf_wowl_nd_results()
- Adjust filenames, context]
---
drivers/net/wireless/brcm80211/brcmfmac/fweh.c +12 -45
@@ -26,50 +26,6 @@#include "fwil.h" /** -* struct brcm_ethhdr - broadcom specific ether header. -* -* @subtype: subtype for this packet. -* @length: TODO: length of appended data. -* @version: version indication. -* @oui: OUI of this packet. -* @usr_subtype: subtype for this OUI. -*/ -struct brcm_ethhdr { -__be16 subtype; -__be16 length; -u8 version; -u8 oui[3 ]; -__be16 usr_subtype; -} __packed; - -struct brcmf_event_msg_be { -__be16 version; -__be16 flags; -__be32 event_type; -__be32 status; -__be32 reason; -__be32 auth_type; -__be32 datalen; -u8 addr[ETH_ALEN ]; -char ifname[IFNAMSIZ ]; -u8 ifidx; -u8 bsscfgidx; -} __packed; - -/** -* struct brcmf_event - contents of broadcom event packet. -* -* @eth: standard ether header. -* @hdr: broadcom specific ether header. -* @msg: common part of the actual event message. -*/ -struct brcmf_event { -struct ethhdr eth; -struct brcm_ethhdr hdr; -struct brcmf_event_msg_be msg; -} __packed; - -/** * struct brcmf_fweh_queue_item - event item on event queue. * * @q: list element for queuing.
@@ -85,6 +41,7 @@ struct brcmf_fweh_queue_item {u8 ifidx;u8 ifaddr[ETH_ALEN ];struct brcmf_event_msg_be emsg; +u32 datalen;u8 data[0 ]; };
@@ -292,6 +249,11 @@ static void brcmf_fweh_event_worker(strubrcmf_dbg_hex_dump (BRCMF_EVENT_ON (), event->data,min_t (u32, emsg.datalen,64 ),"event payload, len=%d\n" , emsg.datalen); +if (emsg.datalen > event->datalen) { +brcmf_err ("event invalid length header=%d, msg=%d\n" , + event->datalen, emsg.datalen); + goto event_free; + }/* special handling of interface event */ if (event->code ==BRCMF_E_IF ) {
@@ -423,7 +385,8 @@ int brcmf_fweh_activate_events(struct br* dispatch the event to a registered handler (using worker). */ void brcmf_fweh_process_event (struct brcmf_pub *drvr, -struct brcmf_event *event_packet) +struct brcmf_event *event_packet, +u32 packet_len) {enum brcmf_fweh_event_code code;struct brcmf_fweh_info *fweh = &drvr->fweh;
@@ -443,6 +406,9 @@ void brcmf_fweh_process_event(struct brcif (code !=BRCMF_E_IF && !fweh->evt_handler[code])return ; +if (datalen >BRCMF_DCMD_MAXLEN ) +return ; +if (in_interrupt ()) alloc_flag =GFP_ATOMIC ;
@@ -456,6 +422,7 @@ void brcmf_fweh_process_event(struct brc/* use memcpy to get aligned event message */ memcpy (&event->emsg, &event_packet->msg,sizeof (event->emsg));memcpy (event->data, data, datalen); + event->datalen = datalen;memcpy (event->ifaddr, event_packet->eth.h_dest,ETH_ALEN );brcmf_fweh_queue_event (fweh, event);
drivers/net/wireless/brcm80211/brcmfmac/fweh.h +55 -13
108 lines not on this page · raw message
drivers/net/wireless/brcm80211/brcmfmac/p2p.c +10 -0
@@ -1363,6 +1363,11 @@ int brcmf_p2p_notify_action_frame_rx(stru16 mgmt_type;u8 action; +if (e->datalen <sizeof (*rxframe)) { +brcmf_dbg (SCAN ,"Event data to small. Ignore\n" ); +return 0 ; + } + ch.chspec =be16_to_cpu (rxframe->chanspec); cfg->d11inf.decchspec (&ch);/* Check if wpa_supplicant has registered for this frame */
@@ -1861,6 +1866,11 @@ s32 brcmf_p2p_notify_rx_mgmt_p2p_proberebrcmf_dbg (INFO ,"Enter: event %d reason %d\n" , e->event_code, e->reason); +if (e->datalen <sizeof (*rxframe)) { +brcmf_dbg (SCAN ,"Event data to small. Ignore\n" ); +return 0 ; + } + ch.chspec =be16_to_cpu (rxframe->chanspec); cfg->d11inf.decchspec (&ch);
drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +5 -0
@@ -3036,6 +3036,11 @@ brcmf_notify_sched_scan_results(struct bbrcmf_dbg (SCAN ,"Enter\n" ); +if (e->datalen < (sizeof (*pfn_result) +sizeof (*netinfo))) { +brcmf_dbg (SCAN ,"Event data to small. Ignore\n" ); +return 0 ; + } +if (e->event_code ==BRCMF_E_PFN_NET_LOST ) {brcmf_dbg (SCAN ,"PFN NET LOST event. Do Nothing\n" );return 0 ;
PATCH 80/204 brcmfmac: Add check for short event packets
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Kevin Cernekee <[email protected]>
commit dd2349121bb1b8ff688c3ca6a2a0bea9d8c142ca upstream.
The length of the data in the received skb is currently passed into brcmf_fweh_process_event() as packet_len, but this value is not checked. event_packet should be followed by DATALEN bytes of additional event data. Ensure that the received packet actually contains at least DATALEN bytes of additional data, to avoid copying uninitialized memory into event->data.
--- drivers/net/wireless/brcm80211/brcmfmac/fweh.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/brcm80211/brcmfmac/fweh.c +2 -1
@@ -406,7 +406,8 @@ void brcmf_fweh_process_event(struct brcif (code !=BRCMF_E_IF && !fweh->evt_handler[code])return ; -if (datalen >BRCMF_DCMD_MAXLEN ) +if (datalen >BRCMF_DCMD_MAXLEN || + datalen +sizeof (*event_packet) > packet_len)return ;if (in_interrupt ())
PATCH 81/204 ALSA: usx2y: Suppress kernel warning at page allocation failures
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 7682e399485fe19622b6fd82510b1f4551e48a25 upstream.
The usx2y driver allocates the stream read/write buffers in continuous pages depending on the stream setup, and this may spew the kernel warning messages with a stack trace like:
WARNING: CPU: 1 PID: 1846 at mm/page_alloc.c:3883 __alloc_pages_slowpath+0x1ef2/0x2d70 Modules linked in: CPU: 1 PID: 1846 Comm: kworker/1:2 Not tainted ....
It may confuse user as if it were any serious error, although this is no fatal error and the driver handles the error case gracefully. Since the driver has already some sanity check of the given size (128 and 256 pages), it can't pass any crazy value. So it's merely page fragmentation.
This patch adds __GFP_NOWARN to each caller for suppressing such kernel warnings. The original issue was spotted by syzkaller.
--- sound/usb/usx2y/usb_stream.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
sound/usb/usx2y/usb_stream.c +4 -2
@@ -191,7 +191,8 @@ struct usb_stream *usb_stream_new(struct } pg =get_order (read_size); - sk->s = (void *)__get_free_pages (GFP_KERNEL |__GFP_COMP|__GFP_ZERO, pg); + sk->s = (void *)__get_free_pages (GFP_KERNEL |__GFP_COMP|__GFP_ZERO| + __GFP_NOWARN, pg);if (!sk->s) {snd_printk (KERN_WARNING "couldn't __get_free_pages()\n" ); goto out;
@@ -211,7 +212,8 @@ struct usb_stream *usb_stream_new(struct pg =get_order (write_size); sk->write_page = - (void *)__get_free_pages (GFP_KERNEL |__GFP_COMP|__GFP_ZERO, pg); + (void *)__get_free_pages (GFP_KERNEL |__GFP_COMP|__GFP_ZERO| + __GFP_NOWARN, pg);if (!sk->write_page) {snd_printk (KERN_WARNING "couldn't __get_free_pages()\n" );usb_stream_free (sk);
PATCH 82/204 scsi: sd: Implement blacklist option for WRITE SAME w/ UNMAP
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Martin K. Petersen" <[email protected]>
commit 28a0bc4120d38a394499382ba21d6965a67a3703 upstream.
SBC-4 states:
"A MAXIMUM UNMAP LBA COUNT field set to a non-zero value indicates the
maximum number of LBAs that may be unmapped by an UNMAP command"
"A MAXIMUM WRITE SAME LENGTH field set to a non-zero value indicates
the maximum number of contiguous logical blocks that the device server allows to be unmapped or written in a single WRITE SAME command."
Despite the spec being clear on the topic, some devices incorrectly expect WRITE SAME commands with the UNMAP bit set to be limited to the value reported in MAXIMUM UNMAP LBA COUNT in the Block Limits VPD.
Implement a blacklist option that can be used to accommodate devices with this behavior.
--- drivers/scsi/scsi_scan.c | 3 +++ drivers/scsi/sd.c | 16 ++++++++++++---- include/scsi/scsi_device.h | 1 + include/scsi/scsi_devinfo.h | 1 + 4 files changed, 17 insertions(+), 4 deletions(-)
drivers/scsi/scsi_scan.c +3 -0
@@ -962,6 +962,9 @@ static int scsi_add_lun(struct scsi_deviif (*bflags &BLIST_NO_DIF ) sdev->no_dif =1 ; +if (*bflags &BLIST_UNMAP_LIMIT_WS ) + sdev->unmap_limit_for_ws =1 ; + sdev->eh_timeout =SCSI_DEFAULT_EH_TIMEOUT ;if (*bflags &BLIST_TRY_VPD_PAGES )
drivers/scsi/sd.c +12 -4
@@ -651,13 +651,21 @@ static void sd_config_discard(struct scsbreak ;case SD_LBP_WS16 : - max_blocks =min_not_zero (sdkp->max_ws_blocks, - (u32 )SD_MAX_WS16_BLOCKS ); +if (sdkp->device->unmap_limit_for_ws) + max_blocks = sdkp->max_unmap_blocks; +else + max_blocks = sdkp->max_ws_blocks; + + max_blocks =min_not_zero (max_blocks, (u32 )SD_MAX_WS16_BLOCKS );break ;case SD_LBP_WS10 : - max_blocks =min_not_zero (sdkp->max_ws_blocks, - (u32 )SD_MAX_WS10_BLOCKS ); +if (sdkp->device->unmap_limit_for_ws) + max_blocks = sdkp->max_unmap_blocks; +else + max_blocks = sdkp->max_ws_blocks; + + max_blocks =min_not_zero (max_blocks, (u32 )SD_MAX_WS10_BLOCKS );break ;case SD_LBP_ZERO :
include/scsi/scsi_device.h +1 -0
@@ -175,6 +175,7 @@ struct scsi_device { unsigned wce_default_on:1; /* Cache is ON by default */ unsigned no_dif:1; /* T10 PI (DIF) should be disabled */ unsigned broken_fua:1; /* Don't set FUA bit */ + unsigned unmap_limit_for_ws:1; /* Use the UNMAP limit for WRITE SAME */atomic_t disk_events_disable_depth;/* disable depth for disk events */
include/scsi/scsi_devinfo.h +1 -0
@@ -37,5 +37,6 @@#define BLIST_TRY_VPD_PAGES 0x10000000/* Attempt to read VPD pages */ #define BLIST_NO_RSOC 0x20000000/* don't try to issue RSOC */ #define BLIST_MAX_1024 0x40000000/* maximum 1024 sector cdb length */ +#define BLIST_UNMAP_LIMIT_WS 0x80000000/* Use UNMAP limit for WRITE SAME */ #endif
PATCH 83/204 USB: serial: qcserial: add Dell DW5818, DW5819
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Shrirang Bagul <[email protected]>
commit f5d9644c5fca7d8e8972268598bb516a7eae17f9 upstream.
Dell Wireless 5819/5818 devices are re-branded Sierra Wireless MC74 series which will by default boot with vid 0x413c and pid's 0x81cf, 0x81d0, 0x81d1, 0x81d2.
--- drivers/usb/serial/qcserial.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/serial/qcserial.c +4 -0
@@ -172,6 +172,10 @@ static const struct usb_device_id id_tab {DEVICE_SWI(0x413c, 0x81b3)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card (rev3) */ {DEVICE_SWI(0x413c, 0x81b5)}, /* Dell Wireless 5811e QDL */ {DEVICE_SWI(0x413c, 0x81b6)}, /* Dell Wireless 5811e QDL */ + {DEVICE_SWI(0x413c, 0x81cf)}, /* Dell Wireless 5819 */ + {DEVICE_SWI(0x413c, 0x81d0)}, /* Dell Wireless 5819 */ + {DEVICE_SWI(0x413c, 0x81d1)}, /* Dell Wireless 5818 */ + {DEVICE_SWI(0x413c, 0x81d2)}, /* Dell Wireless 5818 *//* Huawei devices */ {DEVICE_HWI(0x03f0, 0x581d)}, /* HP lt4112 LTE/HSPA+ Gobi 4G Modem (Huawei me906e) */
PATCH 84/204 kernel/params.c: align add_sysfs_param documentation with code
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jean Delvare <[email protected]>
commit 630cc2b30a42c70628368a412beb4a5e5dd71abe upstream.
This parameter is named kp, so the documentation should use that.
--- kernel/params.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/params.c +1 -1
@@ -581,7 +581,7 @@ EXPORT_SYMBOL(__kernel_param_unlock);/* * add_sysfs_param - add a parameter to sysfs * @mk: struct module_kobject -* @kparam: the actual parameter definition to add to sysfs +* @kp: the actual parameter definition to add to sysfs * @name: name of parameter * * Create a kobject if for a (per-module) parameter if mp NULL, and
PATCH 85/204 sh: sh7722: remove nonexistent GPIO_PTQ7 to fix pinctrl registration
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
commit b78412b8300a8453b78d2c1b0b925b66493bb011 upstream.
Patch series "sh: sh7722/sh7757i/sh7264/sh7269: Fix pinctrl registration", v2.
Magnus Damm reported that on sh7722/Migo-R, pinctrl registration fails with:
sh-pfc pfc-sh7722: pin 0 already registered sh-pfc pfc-sh7722: error during pin registration sh-pfc pfc-sh7722: could not register: -22
sh-pfc: probe of pfc-sh7722 failed with error -22
pinmux_pins[] is initialized through PINMUX_GPIO(), using designated array initializers, where the GPIO_* enums serve as indices. Apparently GPIO_PTQ7 was defined in the enum, but never used. If enum values are defined, but never used, pinmux_pins[] contains (zero-filled) holes. Hence such entries are treated as pin zero, which was registered before, and pinctrl registration fails.
I can't see how this ever worked, as at the time of commit f5e25ae52fef ("sh-pfc: Add sh7722 pinmux support"), pinmux_gpios[] in drivers/pinctrl/sh-pfc/pfc-sh7722.c already had the hole, and drivers/pinctrl/core.c already had the check.
Some scripting revealed a few more broken drivers:
- sh7757 has four holes, due to nonexistent GPIO_PT[JLNQ]7_RESV.
- sh7264 and sh7269 define GPIO_PH[0-7], but don't use it with
PINMUX_GPIO().
Patch 1 fixes the issue on sh7722, and was tested. Patches 3-4 should fix the issue on the other 3 SoCs, but was untested due to lack of hardware.
This patch (of 4):
On sh7722/Migo-R, pinctrl registration fails with:
sh-pfc pfc-sh7722: pin 0 already registered sh-pfc pfc-sh7722: error during pin registration sh-pfc pfc-sh7722: could not register: -22
sh-pfc: probe of pfc-sh7722 failed with error -22
pinmux_pins[] is initialized through PINMUX_GPIO(), using designated array initializers, where the GPIO_* enums serve as indices. As GPIO_PTQ7 is defined in the enum, but never used, pinmux_pins[] contains a (zero-filled) hole. Hence this entry is treated as pin zero, which was registered before, and pinctrl registration fails.
According to the datasheet, port PTQ7 does not exist. Hence remove GPIO_PTQ7 from the enum to fix this.
--- arch/sh/include/cpu-sh4/cpu/sh7722.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sh/include/cpu-sh4/cpu/sh7722.h +1 -1
@@ -67,7 +67,7 @@ enum {GPIO_PTN3 ,GPIO_PTN2 ,GPIO_PTN1 ,GPIO_PTN0 ,/* PTQ */ -GPIO_PTQ7 ,GPIO_PTQ6 ,GPIO_PTQ5 ,GPIO_PTQ4 , +GPIO_PTQ6 ,GPIO_PTQ5 ,GPIO_PTQ4 ,GPIO_PTQ3 ,GPIO_PTQ2 ,GPIO_PTQ1 ,GPIO_PTQ0 , /* PTR */
PATCH 86/204 sh: sh7757: remove nonexistent GPIO_PT[JLNQ]7_RESV to fix pinctrl registration
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
commit d8ce38f69843a56da044e56b6c16aecfbc3c6e39 upstream.
Commit 3810e96056ff ("sh: modify pinmux for SH7757 2nd cut") renamed GPIO_PT[JLNQ]7 to GPIO_PT[JLNQ]7_RESV, and removed the existing users from the pinmux_pins[] array.
However, pinmux_pins[] is initialized through PINMUX_GPIO(), using designated array initializers, where the GPIO_* enums serve as indices. Hence entries were not really removed, but replaced by (zero-filled) holes. Such entries are treated as pin zero, which was registered before, thus leading to pinctrl registration failures, as seen on sh7722:
sh-pfc pfc-sh7722: pin 0 already registered sh-pfc pfc-sh7722: error during pin registration sh-pfc pfc-sh7722: could not register: -22
sh-pfc: probe of pfc-sh7722 failed with error -22
Remove GPIO_PT[JLNQ]7_RESV from the enum to fix this.
--- arch/sh/include/cpu-sh4/cpu/sh7757.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/sh/include/cpu-sh4/cpu/sh7757.h +4 -4
@@ -40,7 +40,7 @@ enum {/* PTJ */ GPIO_PTJ0 ,GPIO_PTJ1 ,GPIO_PTJ2 ,GPIO_PTJ3 , -GPIO_PTJ4 ,GPIO_PTJ5 ,GPIO_PTJ6 ,GPIO_PTJ7_RESV , +GPIO_PTJ4 ,GPIO_PTJ5 ,GPIO_PTJ6 ,/* PTK */ GPIO_PTK0, GPIO_PTK1, GPIO_PTK2, GPIO_PTK3,
@@ -48,7 +48,7 @@ enum {/* PTL */ GPIO_PTL0 ,GPIO_PTL1 ,GPIO_PTL2 ,GPIO_PTL3 , -GPIO_PTL4 ,GPIO_PTL5 ,GPIO_PTL6 ,GPIO_PTL7_RESV , +GPIO_PTL4 ,GPIO_PTL5 ,GPIO_PTL6 ,/* PTM */ GPIO_PTM0, GPIO_PTM1, GPIO_PTM2, GPIO_PTM3,
@@ -56,7 +56,7 @@ enum {/* PTN */ GPIO_PTN0 ,GPIO_PTN1 ,GPIO_PTN2 ,GPIO_PTN3 , -GPIO_PTN4 ,GPIO_PTN5 ,GPIO_PTN6 ,GPIO_PTN7_RESV , +GPIO_PTN4 ,GPIO_PTN5 ,GPIO_PTN6 ,/* PTO */ GPIO_PTO0, GPIO_PTO1, GPIO_PTO2, GPIO_PTO3,
@@ -68,7 +68,7 @@ enum {/* PTQ */ GPIO_PTQ0 ,GPIO_PTQ1 ,GPIO_PTQ2 ,GPIO_PTQ3 , -GPIO_PTQ4 ,GPIO_PTQ5 ,GPIO_PTQ6 ,GPIO_PTQ7_RESV , +GPIO_PTQ4 ,GPIO_PTQ5 ,GPIO_PTQ6 ,/* PTR */ GPIO_PTR0, GPIO_PTR1, GPIO_PTR2, GPIO_PTR3,
PATCH 87/204 sh: sh7264: remove nonexistent GPIO_PH[0-7] to fix pinctrl registration
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
commit eae3df7e82318d798f45dedf111e241805ec7a4a upstream.
Pinmux_pins[] is initialized through PINMUX_GPIO(), using designated array initializers, where the GPIO_* enums serve as indices. If enum values are defined, but never used, pinmux_pins[] contains (zero-filled) holes. Such entries are treated as pin zero, which was registered before, thus leading to pinctrl registration failures, as seen on sh7722:
sh-pfc pfc-sh7722: pin 0 already registered sh-pfc pfc-sh7722: error during pin registration sh-pfc pfc-sh7722: could not register: -22
sh-pfc: probe of pfc-sh7722 failed with error -22
Remove GPIO_PH[0-7] from the enum to fix this.
--- arch/sh/include/cpu-sh2a/cpu/sh7264.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/sh/include/cpu-sh2a/cpu/sh7264.h +1 -3
@@ -43,9 +43,7 @@ enum {GPIO_PG7 ,GPIO_PG6 ,GPIO_PG5 ,GPIO_PG4 ,GPIO_PG3 ,GPIO_PG2 ,GPIO_PG1 ,GPIO_PG0 , -/* Port H */ -GPIO_PH7 ,GPIO_PH6 ,GPIO_PH5 ,GPIO_PH4 , -GPIO_PH3 ,GPIO_PH2 ,GPIO_PH1 ,GPIO_PH0 , +/* Port H - Port H does not have a Data Register */ /* Port I - not on device */
PATCH 88/204 sh: sh7269: remove nonexistent GPIO_PH[0-7] to fix pinctrl registration
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
commit d9d73e81fe82fdf4ee65a48c26531edc04108349 upstream.
Pinmux_pins[] is initialized through PINMUX_GPIO(), using designated array initializers, where the GPIO_* enums serve as indices. If enum values are defined, but never used, pinmux_pins[] contains (zero-filled) holes. Such entries are treated as pin zero, which was registered before, thus leading to pinctrl registration failures, as seen on sh7722:
sh-pfc pfc-sh7722: pin 0 already registered sh-pfc pfc-sh7722: error during pin registration sh-pfc pfc-sh7722: could not register: -22
sh-pfc: probe of pfc-sh7722 failed with error -22
Remove GPIO_PH[0-7] from the enum to fix this.
--- arch/sh/include/cpu-sh2a/cpu/sh7269.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/sh/include/cpu-sh2a/cpu/sh7269.h +1 -3
@@ -45,9 +45,7 @@ enum {GPIO_PG7 ,GPIO_PG6 ,GPIO_PG5 ,GPIO_PG4 ,GPIO_PG3 ,GPIO_PG2 ,GPIO_PG1 ,GPIO_PG0 , -/* Port H */ -GPIO_PH7 ,GPIO_PH6 ,GPIO_PH5 ,GPIO_PH4 , -GPIO_PH3 ,GPIO_PH2 ,GPIO_PH1 ,GPIO_PH0 , +/* Port H - Port H does not have a Data Register */ /* Port I - not on device */
PATCH 89/204 mm/memory_hotplug: change pfn_to_section_nr/section_nr_to_pfn macro to inline function
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: YASUAKI ISHIMATSU <[email protected]>
commit 1dd2bfc86818ddbc95f98e312e7704350223fd7d upstream.
pfn_to_section_nr() and section_nr_to_pfn() are defined as macro. pfn_to_section_nr() has no issue even if it is defined as macro. But section_nr_to_pfn() has overflow issue if sec is defined as int.
section_nr_to_pfn() just shifts sec by PFN_SECTION_SHIFT. If sec is defined as unsigned long, section_nr_to_pfn() returns pfn as 64 bit value. But if sec is defined as int, section_nr_to_pfn() returns pfn as 32 bit value.
__remove_section() calculates start_pfn using section_nr_to_pfn() and scn_nr defined as int. So if hot-removed memory address is over 16TB, overflow issue occurs and section_nr_to_pfn() does not calculate correct pfn.
To make callers use proper arg, the patch changes the macros to inline functions.
--- include/linux/mmzone.h | 10 ++++++++-- mm/memory_hotplug.c | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-)
include/linux/mmzone.h +8 -2
@@ -1094,8 +1094,14 @@ static inline unsigned long early_pfn_to#error Allocator MAX_ORDER exceeds SECTION_SIZE#endif -#define pfn_to_section_nr (pfn) ((pfn) >> PFN_SECTION_SHIFT) -#define section_nr_to_pfn (sec) ((sec) << PFN_SECTION_SHIFT) +static inline unsigned long pfn_to_section_nr (unsigned long pfn) +{ +return pfn >>PFN_SECTION_SHIFT ; +} +static inline unsigned long section_nr_to_pfn (unsigned long sec) +{ +return sec <<PFN_SECTION_SHIFT ; +}#define SECTION_ALIGN_UP (pfn) (((pfn) + PAGES_PER_SECTION - 1) & PAGE_SECTION_MASK)#define SECTION_ALIGN_DOWN (pfn) ((pfn) & PAGE_SECTION_MASK)
mm/memory_hotplug.c +1 -1
@@ -735,7 +735,7 @@ static int __remove_section(struct zonereturn ret; scn_nr =__section_nr (ms); - start_pfn =section_nr_to_pfn (scn_nr); + start_pfn =section_nr_to_pfn ((unsigned long )scn_nr);__remove_zone (zone, start_pfn);sparse_remove_one_section (zone, ms);
PATCH 90/204 mm/memory_hotplug: define find_{smallest|biggest}_section_pfn as unsigned long
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: YASUAKI ISHIMATSU <[email protected]>
commit d09b0137d204bebeaafed672bc5a244e9ac92edb upstream.
find_{smallest|biggest}_section_pfn()s find the smallest/biggest section and return the pfn of the section. But the functions are defined as int. So the functions always return 0x00000000 - 0xffffffff. It means if memory address is over 16TB, the functions does not work correctly.
To handle 64 bit value, the patch defines find_{smallest|biggest}_section_pfn() as unsigned long.
--- mm/memory_hotplug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/memory_hotplug.c +2 -2
@@ -520,7 +520,7 @@ EXPORT_SYMBOL_GPL(__add_pages);#ifdef CONFIG_MEMORY_HOTREMOVE /* find the smallest valid pfn in the range [start_pfn, end_pfn) */ -static int find_smallest_section_pfn (int nid,struct zone *zone, +static unsigned long find_smallest_section_pfn (int nid,struct zone *zone,unsigned long start_pfn,unsigned long end_pfn) {
@@ -545,7 +545,7 @@ static int find_smallest_section_pfn(int }/* find the biggest valid pfn in the range [start_pfn, end_pfn). */ -static int find_biggest_section_pfn (int nid,struct zone *zone, +static unsigned long find_biggest_section_pfn (int nid,struct zone *zone,unsigned long start_pfn,unsigned long end_pfn) {
PATCH 91/204 Smack: remove unneeded NULL-termination from securtity label
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Konstantin Khlebnikov <[email protected]>
commit da1b63566c469bf3e2b24182114422e16b1aa34c upstream.
Values of extended attributes are stored as binary blobs. NULL-termination of them isn't required. It just wastes disk space and confuses command-line tools like getfattr because they have to print that zero byte at the end.
This patch removes terminating zero byte from initial security label in smack_inode_init_security and cuts it out in function smack_inode_getsecurity which is used by syscall getxattr. This change seems completely safe, because function smk_parse_smack ignores everything after first zero byte.
--- security/smack/smack_lsm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
security/smack/smack_lsm.c +3 -3
@@ -674,7 +674,7 @@ static int smack_inode_init_security(str }if (len) - *len =strlen (isp) +1 ; + *len =strlen (isp);return 0 ; }
@@ -1078,7 +1078,7 @@ static int smack_inode_getsecurity(constif (strcmp (name,XATTR_SMACK_SUFFIX ) ==0 ) { isp =smk_of_inode (inode); - ilen =strlen (isp) +1 ; + ilen =strlen (isp); *buffer = isp;return ilen; }
@@ -1103,7 +1103,7 @@ static int smack_inode_getsecurity(constelse return -EOPNOTSUPP ; - ilen =strlen (isp) +1 ; + ilen =strlen (isp);if (rc ==0 ) { *buffer = isp; rc = ilen;
PATCH 92/204 lsm: fix smack_inode_removexattr and xattr_getsecurity memleak
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Casey Schaufler <[email protected]>
commit 57e7ba04d422c3d41c8426380303ec9b7533ded9 upstream.
security_inode_getsecurity() provides the text string value of a security attribute. It does not provide a "secctx".
The code in xattr_getsecurity() that calls security_inode_getsecurity() and then calls security_release_secctx() happened to work because SElinux and Smack treat the attribute and the secctx the same way. It fails for cap_inode_getsecurity(), because that module has no secctx that ever needs releasing. It turns out that Smack is the one that's doing things wrong by not allocating memory when instructed to do so by the "alloc" parameter.
The fix is simple enough. Change the security_release_secctx() to kfree() because it isn't a secctx being returned by security_inode_getsecurity(). Change Smack to allocate the string when told to do so.
Note: this also fixes memory leaks for LSMs which implement inode_getsecurity but not release_secctx, such as capabilities.
--- fs/xattr.c | 2 +- security/smack/smack_lsm.c | 55 +++++++++++++++++++++------------------------- 2 files changed, 26 insertions(+), 31 deletions(-)
fs/xattr.c +1 -1
@@ -163,7 +163,7 @@ xattr_getsecurity(struct inode *inode, c }memcpy (value, buffer, len); out: -security_release_secctx (buffer, len); +kfree (buffer); out_noalloc:return len; }
security/smack/smack_lsm.c +27 -32
77 lines not on this page · raw message
PATCH 93/204 nl80211: Define policy for packet pattern attributes
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Peng Xu <[email protected]>
commit ad670233c9e1d5feb365d870e30083ef1b889177 upstream.
Define a policy for packet pattern attributes in order to fix a potential read over the end of the buffer during nla_get_u32() of the NL80211_PKTPAT_OFFSET attribute.
Note that the data there can always be read due to SKB allocation (with alignment and struct skb_shared_info at the end), but the data might be uninitialized. This could be used to leak some data from uninitialized vmalloc() memory, but most drivers don't allow an offset (so you'd just get -EINVAL if the data is non-zero) or just allow it with a fixed value - 100 or 128 bytes, so anything above that would get -EINVAL. With brcmfmac the limit is 1500 so (at least) one byte could be obtained.
---
net/wireless/nl80211.c +10 -2
@@ -464,6 +464,14 @@ nl80211_match_policy[NL80211_SCHED_SCAN_ [NL80211_SCHED_SCAN_MATCH_ATTR_RSSI] = { .type = NLA_U32 }, }; +/* policy for packet pattern attributes */ +static const struct nla_policy +nl80211_packet_pattern_policy[MAX_NL80211_PKTPAT +1 ] = { + [NL80211_PKTPAT_MASK ] = { .type =NLA_BINARY , }, + [NL80211_PKTPAT_PATTERN ] = { .type =NLA_BINARY , }, + [NL80211_PKTPAT_OFFSET ] = { .type =NLA_U32 }, +}; + static int nl80211_prepare_wdev_dump(struct sk_buff *skb, struct netlink_callback *cb, struct cfg80211_registered_device **rdev,
@@ -8573,7 +8581,7 @@ static int nl80211_set_wowlan(struct sk_u8 *mask_pat;nla_parse (pat_tb,MAX_NL80211_PKTPAT ,nla_data (pat), -nla_len (pat),NULL ); +nla_len (pat), nl80211_packet_pattern_policy); err = -EINVAL ;if (!pat_tb[NL80211_PKTPAT_MASK ] || !pat_tb[NL80211_PKTPAT_PATTERN ])
@@ -8801,7 +8809,7 @@ static int nl80211_parse_coalesce_rule(su8 *mask_pat;nla_parse (pat_tb,MAX_NL80211_PKTPAT ,nla_data (pat), -nla_len (pat),NULL ); +nla_len (pat), nl80211_packet_pattern_policy);if (!pat_tb[NL80211_PKTPAT_MASK ] || !pat_tb[NL80211_PKTPAT_PATTERN ])return -EINVAL ;
PATCH 94/204 netfilter: x_tables: avoid stack-out-of-bounds read in xt_copy_counters_from_user
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit e466af75c074e76107ae1cd5a2823e9c61894ffb upstream.
syzkaller reports an out of bound read in strlcpy(), triggered by xt_copy_counters_from_user()
Fix this by using memcpy(), then forcing a zero byte at the last position of the destination, as Florian did for the non COMPAT code.
--- net/netfilter/x_tables.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/x_tables.c +2 -2
@@ -860,7 +860,7 @@ void *xt_copy_counters_from_user(const vif (copy_from_user (&compat_tmp, user,sizeof (compat_tmp)) !=0 )return ERR_PTR (-EFAULT ); -strlcpy (info->name, compat_tmp.name,sizeof (info->name)); +memcpy (info->name, compat_tmp.name,sizeof (info->name) -1 ); info->num_counters = compat_tmp.num_counters; user +=sizeof (compat_tmp); }else
@@ -873,9 +873,9 @@ void *xt_copy_counters_from_user(const vif (copy_from_user (info, user,sizeof (*info)) !=0 )return ERR_PTR (-EFAULT ); - info->name[sizeof (info->name) -1 ] ='\0' ; user +=sizeof (*info); } + info->name[sizeof (info->name) -1 ] ='\0' ; size =sizeof (struct xt_counters ); size *= info->num_counters;
PATCH 95/204 ALSA: seq: Fix copy_from_user() call inside lock
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 5803b023881857db32ffefa0d269c90280a67ee0 upstream.
The event handler in the virmidi sequencer code takes a read-lock for the linked list traverse, while it's calling snd_seq_dump_var_event() in the loop. The latter function may expand the user-space data depending on the event type. It eventually invokes copy_from_user(), which might be a potential dead-lock.
The sequencer core guarantees that the user-space data is passed only with atomic=0 argument, but snd_virmidi_dev_receive_event() ignores it and always takes read-lock(). For avoiding the problem above, this patch introduces rwsem for non-atomic case, while keeping rwlock for atomic case.
Also while we're at it: the superfluous irq flags is dropped in snd_virmidi_input_open().
--- include/sound/seq_virmidi.h | 1 + sound/core/seq/seq_virmidi.c | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-)
include/sound/seq_virmidi.h +1 -0
@@ -60,6 +60,7 @@ struct snd_virmidi_dev {int port;/* created/attached port */ unsigned int flags;/* SNDRV_VIRMIDI_* */ rwlock_t filelist_lock; +struct rw_semaphore filelist_sem;struct list_head filelist; };
sound/core/seq/seq_virmidi.c +19 -8
@@ -77,13 +77,17 @@ static void snd_virmidi_init_event(struc* decode input event and put to read buffer of each opened file */ static int snd_virmidi_dev_receive_event (struct snd_virmidi_dev *rdev, -struct snd_seq_event *ev) +struct snd_seq_event *ev, +bool atomic) {struct snd_virmidi *vmidi;unsigned char msg[4 ];int len; -read_lock (&rdev->filelist_lock); +if (atomic) +read_lock (&rdev->filelist_lock); +else +down_read (&rdev->filelist_sem);list_for_each_entry (vmidi, &rdev->filelist, list) {if (!vmidi->trigger)continue ;
@@ -97,7 +101,10 @@ static int snd_virmidi_dev_receive_eventsnd_rawmidi_receive (vmidi->substream, msg, len); } } -read_unlock (&rdev->filelist_lock); +if (atomic) +read_unlock (&rdev->filelist_lock); +else +up_read (&rdev->filelist_sem);return 0 ; }
@@ -115,7 +122,7 @@ int snd_virmidi_receive(struct snd_rawmistruct snd_virmidi_dev *rdev; rdev = rmidi->private_data; - return snd_virmidi_dev_receive_event(rdev, ev); + return snd_virmidi_dev_receive_event(rdev, ev, true); }#endif /* 0 */
@@ -130,7 +137,7 @@ static int snd_virmidi_event_input(struc rdev = private_data;if (!(rdev->flags &SNDRV_VIRMIDI_USE ))return 0 ;/* ignored */ -return snd_virmidi_dev_receive_event (rdev, ev); +return snd_virmidi_dev_receive_event (rdev, ev, atomic); }/*
@@ -209,7 +216,6 @@ static int snd_virmidi_input_open(structstruct snd_virmidi_dev *rdev = substream->rmidi->private_data;struct snd_rawmidi_runtime *runtime = substream->runtime;struct snd_virmidi *vmidi; -unsigned long flags; vmidi =kzalloc (sizeof (*vmidi),GFP_KERNEL );if (vmidi ==NULL )
@@ -223,9 +229,11 @@ static int snd_virmidi_input_open(struct vmidi->client = rdev->client; vmidi->port = rdev->port; runtime->private_data = vmidi; -write_lock_irqsave (&rdev->filelist_lock, flags); +down_write (&rdev->filelist_sem); +write_lock_irq (&rdev->filelist_lock);list_add_tail (&vmidi->list, &rdev->filelist); -write_unlock_irqrestore (&rdev->filelist_lock, flags); +write_unlock_irq (&rdev->filelist_lock); +up_write (&rdev->filelist_sem); vmidi->rdev = rdev;return 0 ; }
@@ -264,9 +272,11 @@ static int snd_virmidi_input_close(strucstruct snd_virmidi_dev *rdev = substream->rmidi->private_data;struct snd_virmidi *vmidi = substream->runtime->private_data; +down_write (&rdev->filelist_sem);write_lock_irq (&rdev->filelist_lock);list_del (&vmidi->list);write_unlock_irq (&rdev->filelist_lock); +up_write (&rdev->filelist_sem);snd_midi_event_free (vmidi->parser); substream->runtime->private_data =NULL ;kfree (vmidi);
@@ -520,6 +530,7 @@ int snd_virmidi_new(struct snd_card *car rdev->rmidi = rmidi; rdev->device = device; rdev->client =-1 ; +init_rwsem (&rdev->filelist_sem);rwlock_init (&rdev->filelist_lock);INIT_LIST_HEAD (&rdev->filelist); rdev->seq_mode =SNDRV_VIRMIDI_SEQ_DISPATCH ;
PATCH 96/204 udp: fix bcast packet reception
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
commit 996b44fcef8f216ea0b6b6e74468c5a77b5e341f upstream.
The commit bc044e8db796 ("udp: perform source validation for mcast early demux") does not take into account that broadcast packets lands in the same code path and they need different checks for the source address - notably, zero source address are valid for bcast and invalid for mcast.
As a result, 2nd and later broadcast packets with 0 source address landing to the same socket are dropped. This breaks dhcp servers.
Since we don't have stringent performance requirements for ingress broadcast traffic, fix it by disabling UDP early demux such traffic.
--- net/ipv4/udp.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
net/ipv4/udp.c +5 -9
@@ -1968,20 +1968,16 @@ int udp_v4_early_demux(struct sk_buff *s iph =ip_hdr (skb); uh =udp_hdr (skb); -if (skb->pkt_type ==PACKET_BROADCAST || - skb->pkt_type ==PACKET_MULTICAST ) { +if (skb->pkt_type ==PACKET_MULTICAST ) { in_dev =__in_dev_get_rcu (skb->dev);if (!in_dev)return 0 ; -/* we are supposed to accept bcast packets */ -if (skb->pkt_type ==PACKET_MULTICAST ) { - ours =ip_check_mc_rcu (in_dev, iph->daddr, iph->saddr, - iph->protocol); -if (!ours) -return 0 ; - } + ours =ip_check_mc_rcu (in_dev, iph->daddr, iph->saddr, + iph->protocol); +if (!ours) +return 0 ; sk =__udp4_lib_mcast_demux_lookup (net, uh->dest, iph->daddr, uh->source, iph->saddr, dif);
PATCH 97/204 workqueue: replace pool->manager_arb mutex with a flag
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
commit 692b48258dda7c302e777d7d5f4217244478f1f6 upstream.
Josef reported a HARDIRQ-safe -> HARDIRQ-unsafe lock order detected by lockdep:
[ 1270.472259] WARNING: HARDIRQ-safe -> HARDIRQ-unsafe lock order detected
[ 1270.472783] 4.14.0-rc1-xfstests-12888-g76833e8 #110 Not tainted
[ 1270.473240] -----------------------------------------------------
[ 1270.473710] kworker/u5:2/5157 [HC0[0]:SC0[0]:HE0:SE1] is trying to acquire:
[ 1270.474239] (&(&lock->wait_lock)->rlock){+.+.}, at: [<ffffffff8da253d2>] __mutex_unlock_slowpath+0xa2/0x280
[ 1270.474994]
[ 1270.474994] and this task is already holding:
[ 1270.475440] (&pool->lock/1){-.-.}, at: [<ffffffff8d2992f6>] worker_thread+0x366/0x3c0
[ 1270.476046] which would create a new lock dependency:
[ 1270.476436] (&pool->lock/1){-.-.} -> (&(&lock->wait_lock)->rlock){+.+.}
[ 1270.476949]
[ 1270.476949] but this new dependency connects a HARDIRQ-irq-safe lock:
[ 1270.477553] (&pool->lock/1){-.-.}
...
[ 1270.488900] to a HARDIRQ-irq-unsafe lock:
[ 1270.489327] (&(&lock->wait_lock)->rlock){+.+.}
...
[ 1270.494735] Possible interrupt unsafe locking scenario:
[ 1270.494735]
[ 1270.495250] CPU0 CPU1
[ 1270.495600] ---- ----
[ 1270.495947] lock(&(&lock->wait_lock)->rlock);
[ 1270.496295] local_irq_disable();
[ 1270.496753] lock(&pool->lock/1);
[ 1270.497205] lock(&(&lock->wait_lock)->rlock);
[ 1270.497744] <Interrupt>
[ 1270.497948] lock(&pool->lock/1);, which will cause a irq inversion deadlock if the above lock scenario happens.
The root cause of this safe -> unsafe lock order is the mutex_unlock(pool->manager_arb) in manage_workers() with pool->lock held.
Unlocking mutex while holding an irq spinlock was never safe and this problem has been around forever but it never got noticed because the only time the mutex is usually trylocked while holding irqlock making actual failures very unlikely and lockdep annotation missed the condition until the recent b9c16a0e1f73 ("locking/mutex: Fix lockdep_assert_held() fail").
Using mutex for pool->manager_arb has always been a bit of stretch. It primarily is an mechanism to arbitrate managership between workers which can easily be done with a pool flag. The only reason it became a mutex is that pool destruction path wants to exclude parallel managing operations.
This patch replaces the mutex with a new pool flag POOL_MANAGER_ACTIVE and make the destruction path wait for the current manager on a wait queue.
v2: Drop unnecessary flag clearing before pool destruction as
suggested by Boqun.
--- kernel/workqueue.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-)
kernel/workqueue.c +15 -22
@@ -68,6 +68,7 @@ enum {* attach_mutex to avoid changing binding state while * worker_attach_to_pool() is in progress. */ +POOL_MANAGER_ACTIVE =1 <<0 ,/* being managed */ POOL_DISASSOCIATED = 1 << 2, /* cpu can't serve workers *//* worker flags */
@@ -158,7 +159,6 @@ struct worker_pool {/* L: hash of busy workers */ /* see manage_workers() for details on the two manager mutexes */ -struct mutex manager_arb;/* manager arbitration */ struct mutex attach_mutex;/* attach/detach exclusion */ struct list_head workers;/* A: attached workers */ struct completion *detach_completion;/* all workers detached */
@@ -288,6 +288,7 @@ static struct workqueue_attrs *wq_updatestatic DEFINE_MUTEX (wq_pool_mutex);/* protects pools and workqueues list */ static DEFINE_SPINLOCK (wq_mayday_lock);/* protects wq->maydays list */ +static DECLARE_WAIT_QUEUE_HEAD (wq_manager_wait);/* wait for manager to go away */ static LIST_HEAD (workqueues);/* PL: list of all workqueues */ static bool workqueue_freezing;/* PL: have wqs started freezing? */
@@ -793,7 +794,7 @@ static bool need_to_create_worker(struct/* Do we have too many workers and should some go away? */ static bool too_many_workers (struct worker_pool *pool) { -bool managing =mutex_is_locked (&pool->manager_arb); +bool managing = pool->flags &POOL_MANAGER_ACTIVE ;int nr_idle = pool->nr_idle + managing;/* manager is considered idle */ int nr_busy = pool->nr_workers - nr_idle;
@@ -1996,22 +1997,15 @@ static bool manage_workers(struct worker {struct worker_pool *pool = worker->pool; -/* -* Anyone who successfully grabs manager_arb wins the arbitration -* and becomes the manager. mutex_trylock() on pool->manager_arb -* failure while holding pool->lock reliably indicates that someone -* else is managing the pool and the worker which failed trylock -* can proceed to executing work items. This means that anyone -* grabbing manager_arb is responsible for actually performing -* manager duties. If manager_arb is grabbed and released without -* actual management, the pool may stall indefinitely. -*/ -if (!mutex_trylock (&pool->manager_arb)) +if (pool->flags &POOL_MANAGER_ACTIVE )return false; + pool->flags |=POOL_MANAGER_ACTIVE ; +maybe_create_worker (pool); -mutex_unlock (&pool->manager_arb); + pool->flags &= ~POOL_MANAGER_ACTIVE ; +wake_up (&wq_manager_wait);return true; }
@@ -3490,7 +3484,6 @@ static int init_worker_pool(struct workesetup_timer (&pool->mayday_timer, pool_mayday_timeout, (unsigned long )pool); -mutex_init (&pool->manager_arb);mutex_init (&pool->attach_mutex);INIT_LIST_HEAD (&pool->workers);
@@ -3546,13 +3539,15 @@ static void put_unbound_pool(struct workhash_del (&pool->hash_node);/* -* Become the manager and destroy all workers. Grabbing -* manager_arb prevents @pool's workers from blocking on -* attach_mutex. +* Become the manager and destroy all workers. This prevents +* @pool's workers from blocking on attach_mutex. We're the last +* manager and @pool gets freed with the flag set. */ -mutex_lock (&pool->manager_arb); -spin_lock_irq (&pool->lock); +wait_event_lock_irq (wq_manager_wait, + !(pool->flags &POOL_MANAGER_ACTIVE ), pool->lock); + pool->flags |=POOL_MANAGER_ACTIVE ; +while ((worker =first_idle_worker (pool)))destroy_worker (worker);WARN_ON (pool->nr_workers || pool->nr_idle);
@@ -3566,8 +3561,6 @@ static void put_unbound_pool(struct workif (pool->detach_completion)wait_for_completion (pool->detach_completion); -mutex_unlock (&pool->manager_arb); -/* shut down the timers */ del_timer_sync (&pool->idle_timer);del_timer_sync (&pool->mayday_timer);
PATCH 98/204 crypto: shash - Fix zero-length shash ahash digest crash
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
commit b61907bb42409adf9b3120f741af7c57dd7e3db2 upstream.
The shash ahash digest adaptor function may crash if given a zero-length input together with a null SG list. This is because it tries to read the SG list before looking at the length.
This patch fixes it by checking the length first.
--- crypto/shash.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
crypto/shash.c +5 -3
@@ -274,12 +274,14 @@ static int shash_async_finup(struct ahasint shash_ahash_digest (struct ahash_request *req,struct shash_desc *desc) { -struct scatterlist *sg = req->src; -unsigned int offset = sg->offset;unsigned int nbytes = req->nbytes; +struct scatterlist *sg; +unsigned int offset;int err; -if (nbytes <min (sg->length, ((unsigned int )(PAGE_SIZE )) - offset)) { +if (nbytes && + (sg = req->src, offset = sg->offset, + nbytes <min (sg->length, ((unsigned int )(PAGE_SIZE )) - offset))) {void *data; data =kmap_atomic (sg_page (sg));
PATCH 99/204 direct-io: Prevent NULL pointer access in submit_page_section
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Gruenbacher <[email protected]>
commit 899f0429c7d3eed886406cd72182bee3b96aa1f9 upstream.
In the code added to function submit_page_section by commit b1058b981, sdio->bio can currently be NULL when calling dio_bio_submit. This then leads to a NULL pointer access in dio_bio_submit, so check for a NULL bio in submit_page_section before trying to submit it instead.
Fixes xfstest generic/250 on gfs2.
--- fs/direct-io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/direct-io.c +2 -1
@@ -812,7 +812,8 @@ out:*/ if (sdio->boundary) { ret =dio_send_cur_page (dio, sdio, map_bh); -dio_bio_submit (dio, sdio); +if (sdio->bio) +dio_bio_submit (dio, sdio);page_cache_release (sdio->cur_page); sdio->cur_page =NULL ; }
PATCH 100/204 more bio_map_user_iov() leak fixes
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit 2b04e8f6bbb196cab4b232af0f8d48ff2c7a8058 upstream.
we need to take care of failure exit as well - pages already in bio should be dropped by analogue of bio_unmap_pages(), since their refcounts had been bumped only once per reference in bio.
--- block/bio.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
block/bio.c +9 -5
@@ -1286,6 +1286,7 @@ static struct bio *__bio_map_user_iov(ststruct bio *bio;int cur_page =0 ;int ret, offset; +struct bio_vec *bvec;for (i =0 ; i < iov_count; i++) {unsigned long uaddr = (unsigned long )iov[i].iov_base;
@@ -1329,7 +1330,12 @@ static struct bio *__bio_map_user_iov(st ret =get_user_pages_fast (uaddr, local_nr_pages, write_to_vm, &pages[cur_page]); -if (ret < local_nr_pages) { +if (unlikely (ret < local_nr_pages)) { +for (j = cur_page; j < page_limit; j++) { +if (!pages[j]) +break ; +put_page (pages[j]); + } ret = -EFAULT ; goto out_unmap; }
@@ -1384,10 +1390,8 @@ static struct bio *__bio_map_user_iov(streturn bio; out_unmap: -for (i =0 ; i < nr_pages; i++) { -if (!pages[i]) -break ; -page_cache_release (pages[i]); +bio_for_each_segment_all (bvec, bio, j) { +put_page (bvec->bv_page); } out:kfree (pages);
PATCH 101/204 USB: dummy-hcd: Fix deadlock caused by disconnect detection
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit ab219221a5064abfff9f78c323c4a257b16cdb81 upstream.
The dummy-hcd driver calls the gadget driver's disconnect callback under the wrong conditions. It should invoke the callback when Vbus power is turned off, but instead it does so when the D+ pullup is turned off.
This can cause a deadlock in the composite core when a gadget driver is unregistered:
[ 88.361471] ============================================
[ 88.362014] WARNING: possible recursive locking detected
[ 88.362580] 4.14.0-rc2+ #9 Not tainted
[ 88.363010] --------------------------------------------
[ 88.363561] v4l_id/526 is trying to acquire lock:
[ 88.364062] (&(&cdev->lock)->rlock){....}, at: [<ffffffffa0547e03>] composite_disconnect+0x43/0x100 [libcomposite]
[ 88.365051]
[ 88.365051] but task is already holding lock:
[ 88.365826] (&(&cdev->lock)->rlock){....}, at: [<ffffffffa0547b09>] usb_function_deactivate+0x29/0x80 [libcomposite]
[ 88.366858]
[ 88.366858] other info that might help us debug this:
[ 88.368301] Possible unsafe locking scenario:
[ 88.368301]
[ 88.369304] CPU0
[ 88.369701] ----
[ 88.370101] lock(&(&cdev->lock)->rlock);
[ 88.370623] lock(&(&cdev->lock)->rlock);
[ 88.371145]
[ 88.371145] *** DEADLOCK ***
[ 88.371145]
[ 88.372211] May be due to missing lock nesting notation
[ 88.372211]
[ 88.373191] 2 locks held by v4l_id/526:
[ 88.373715] #0: (&(&cdev->lock)->rlock){....}, at: [<ffffffffa0547b09>] usb_function_deactivate+0x29/0x80 [libcomposite]
[ 88.374814] #1: (&(&dum_hcd->dum->lock)->rlock){....}, at: [<ffffffffa05bd48d>] dummy_pullup+0x7d/0xf0 [dummy_hcd]
[ 88.376289]
[ 88.376289] stack backtrace:
[ 88.377726] CPU: 0 PID: 526 Comm: v4l_id Not tainted 4.14.0-rc2+ #9
[ 88.378557] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
[ 88.379504] Call Trace:
[ 88.380019] dump_stack+0x86/0xc7
[ 88.380605] __lock_acquire+0x841/0x1120
[ 88.381252] lock_acquire+0xd5/0x1c0
[ 88.381865] ? composite_disconnect+0x43/0x100 [libcomposite]
[ 88.382668] _raw_spin_lock_irqsave+0x40/0x54
[ 88.383357] ? composite_disconnect+0x43/0x100 [libcomposite]
[ 88.384290] composite_disconnect+0x43/0x100 [libcomposite]
[ 88.385490] set_link_state+0x2d4/0x3c0 [dummy_hcd]
[ 88.386436] dummy_pullup+0xa7/0xf0 [dummy_hcd]
[ 88.387195] usb_gadget_disconnect+0xd8/0x160 [udc_core]
[ 88.387990] usb_gadget_deactivate+0xd3/0x160 [udc_core]
[ 88.388793] usb_function_deactivate+0x64/0x80 [libcomposite]
[ 88.389628] uvc_function_disconnect+0x1e/0x40 [usb_f_uvc]This patch changes the code to test the port-power status bit rather than the port-connect status bit when deciding whether to isue the callback.
---
drivers/usb/gadget/dummy_hcd.c +5 -2
@@ -355,6 +355,7 @@ static void set_link_state_by_speed(strustatic void set_link_state (struct dummy_hcd *dum_hcd) {struct dummy *dum = dum_hcd->dum; +unsigned int power_bit; dum_hcd->active =0 ;if (dum->pullup)
@@ -365,19 +366,21 @@ static void set_link_state(struct dummy_return ;set_link_state_by_speed (dum_hcd); + power_bit = (dummy_hcd_to_hcd (dum_hcd)->speed ==HCD_USB3 ? +USB_SS_PORT_STAT_POWER :USB_PORT_STAT_POWER );if ((dum_hcd->port_status &USB_PORT_STAT_ENABLE ) ==0 || dum_hcd->active) dum_hcd->resuming =0 ;/* if !connected or reset */ -if ((dum_hcd->port_status &USB_PORT_STAT_CONNECTION ) ==0 || +if ((dum_hcd->port_status & power_bit) ==0 || (dum_hcd->port_status &USB_PORT_STAT_RESET ) !=0 ) {/* * We're connected and not reset (reset occurred now), * and driver attached - disconnect! */ -if ((dum_hcd->old_status &USB_PORT_STAT_CONNECTION ) !=0 && +if ((dum_hcd->old_status & power_bit) !=0 && (dum_hcd->old_status &USB_PORT_STAT_RESET ) ==0 && dum->ints_enabled) {stop_activity (dum);
PATCH 102/204 usb: renesas_usbhs: Fix DMAC sequence for receiving zero-length packet
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Kazuya Mizuguchi <[email protected]>
commit 29c7f3e68eec4ae94d85ad7b5dfdafdb8089f513 upstream.
The DREQE bit of the DnFIFOSEL should be set to 1 after the DE bit of USB-DMAC on R-Car SoCs is set to 1 after the USB-DMAC received a zero-length packet. Otherwise, a transfer completion interruption of USB-DMAC doesn't happen. Even if the driver changes the sequence, normal operations (transmit/receive without zero-length packet) will not cause any side-effects. So, this patch fixes the sequence anyway.
--- drivers/usb/renesas_usbhs/fifo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/renesas_usbhs/fifo.c +1 -1
@@ -828,9 +828,9 @@ static void xfer_work(struct work_structdev_dbg (dev," %s %d (%d/ %d)\n" , fifo->name,usbhs_pipe_number (pipe), pkt->length, pkt->zero); -usbhsf_dma_start (pipe, fifo);usbhs_pipe_set_trans_count_if_bulk (pipe, pkt->trans);dma_async_issue_pending (chan); +usbhsf_dma_start (pipe, fifo);usbhs_pipe_enable (pipe); xfer_work_end:
PATCH 103/204 usb: gadget: composite: Fix use-after-free in usb_composite_overwrite_options
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Gabbasov <[email protected]>
commit aec17e1e249567e82b26dafbb86de7d07fde8729 upstream.
KASAN enabled configuration reports an error
BUG: KASAN: use-after-free in usb_composite_overwrite_options+...
[libcomposite] at addr ...
Read of size 1 by task ...when some driver is un-bound and then bound again.
For example, this happens with FunctionFS driver when "ffs-test" test application is run several times in a row.
If the driver has empty manufacturer ID string in initial static data, it is then replaced with generated string. After driver unbinding the generated string is freed, but the driver data still keep that pointer. And if the driver is then bound again, that pointer is re-used for string emptiness check.
The fix is to clean up the driver string data upon its unbinding to drop the pointer to freed memory.
--- drivers/usb/gadget/composite.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/gadget/composite.c +5 -0
@@ -1815,6 +1815,8 @@ static DEVICE_ATTR_RO(suspended);static void __composite_unbind (struct usb_gadget *gadget,bool unbind_driver) {struct usb_composite_dev *cdev =get_gadget_data (gadget); +struct usb_gadget_strings *gstr = cdev->driver->strings[0 ]; +struct usb_string *dev_str = gstr->strings;/* composite_disconnect() must already have been called * by the underlying peripheral controller driver!
@@ -1834,6 +1836,9 @@ static void __composite_unbind(struct uscomposite_dev_cleanup (cdev); +if (dev_str[USB_GADGET_MANUFACTURER_IDX ].s == cdev->def_manufacturer) + dev_str[USB_GADGET_MANUFACTURER_IDX ].s ="" ; +kfree (cdev->def_manufacturer);kfree (cdev);set_gadget_data (gadget,NULL );
PATCH 104/204 ALSA: caiaq: Fix stray URB at probe error path
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 99fee508245825765ff60155fed43f970ff83a8f upstream.
caiaq driver doesn't kill the URB properly at its error path during the probe, which may lead to a use-after-free error later. This patch addresses it.
--- sound/usb/caiaq/device.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
sound/usb/caiaq/device.c +9 -3
@@ -469,10 +469,12 @@ static int init_card(struct snd_usb_caia err =snd_usb_caiaq_send_command (cdev,EP1_CMD_GET_DEVICE_INFO ,NULL ,0 );if (err) -return err; + goto err_kill_urb; -if (!wait_event_timeout (cdev->ep1_wait_queue, cdev->spec_received,HZ )) -return -ENODEV ; +if (!wait_event_timeout (cdev->ep1_wait_queue, cdev->spec_received,HZ )) { + err = -ENODEV ; + goto err_kill_urb; + }usb_string (usb_dev, usb_dev->descriptor.iManufacturer, cdev->vendor_name,CAIAQ_USB_STR_LEN );
@@ -507,6 +509,10 @@ static int init_card(struct snd_usb_caiasetup_card (cdev);return 0 ; + + err_kill_urb: +usb_kill_urb (&cdev->ep1_in_urb); +return err; } static int snd_probe(struct usb_interface *intf,
PATCH 105/204 scsi: libiscsi: fix shifting of DID_REQUEUE host byte
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
commit eef9ffdf9cd39b2986367bc8395e2772bc1284ba upstream.
The SCSI host byte should be shifted left by 16 in order to have scsi_decide_disposition() do the right thing (.i.e. requeue the command).
--- drivers/scsi/libiscsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/libiscsi.c +1 -1
@@ -1727,7 +1727,7 @@ int iscsi_queuecommand(struct Scsi_Hostif (test_bit (ISCSI_SUSPEND_BIT , &conn->suspend_tx)) { reason =FAILURE_SESSION_IN_RECOVERY ; - sc->result =DID_REQUEUE ; + sc->result =DID_REQUEUE <<16 ; goto fault; }
PATCH 106/204 iommu/exynos: Remove initconst attribute to avoid potential kernel oops
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
commit 9d25e3cc83d731ae4eeb017fd07562fde3f80bef upstream.
Exynos SYSMMU registers standard platform device with sysmmu_of_match table, what means that this table is accessed every time a new platform device is registered in a system. This might happen also after the boot, so the table must not be attributed as initconst to avoid potential kernel oops caused by access to freed memory.
--- drivers/iommu/exynos-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/exynos-iommu.c +1 -1
@@ -676,7 +676,7 @@ static int __init exynos_sysmmu_probe(streturn 0 ; } -static const struct of_device_id sysmmu_of_match[]__initconst = { +static const struct of_device_id sysmmu_of_match[] = { { .compatible ="samsung,exynos-sysmmu" , }, { }, };
PATCH 107/204 KVM: nVMX: fix guest CR4 loading when emulating L2 to L1 exit
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Haozhong Zhang <[email protected]>
commit 8eb3f87d903168bdbd1222776a6b1e281f50513e upstream.
When KVM emulates an exit from L2 to L1, it loads L1 CR4 into the guest CR4. Before this CR4 loading, the guest CR4 refers to L2 CR4. Because these two CR4's are in different levels of guest, we should vmx_set_cr4() rather than kvm_set_cr4() here. The latter, which is used to handle guest writes to its CR4, checks the guest change to CR4 and may fail if the change is invalid.
The failure may cause trouble. Consider we start
a L1 guest with non-zero L1 PCID in use,
(i.e. L1 CR4.PCIDE == 1 && L1 CR3.PCID != 0)
and
a L2 guest with L2 PCID disabled,
(i.e. L2 CR4.PCIDE == 0)and following events may happen:
1. If kvm_set_cr4() is used in load_vmcs12_host_state() to load L1 CR4 into guest CR4 (in VMCS01) for L2 to L1 exit, it will fail because of PCID check. As a result, the guest CR4 recorded in L0 KVM (i.e. vcpu->arch.cr4) is left to the value of L2 CR4.
2. Later, if L1 attempts to change its CR4, e.g., clearing VMXE bit, kvm_set_cr4() in L0 KVM will think L1 also wants to enable PCID, because the wrong L2 CR4 is used by L0 KVM as L1 CR4. As L1 CR3.PCID != 0, L0 KVM will inject GP to L1 guest.
--- arch/x86/kvm/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/vmx.c +1 -1
@@ -8670,7 +8670,7 @@ static void load_vmcs12_host_state(struc* (KVM doesn't change it)- no reason to call set_cr4_guest_host_mask(); */ vcpu->arch.cr4_guest_owned_bits = ~vmcs_readl (CR4_GUEST_HOST_MASK ); -kvm_set_cr4 (vcpu, vmcs12->host_cr4); +vmx_set_cr4 (vcpu, vmcs12->host_cr4);nested_ept_uninit_mmu_context (vcpu);
PATCH 108/204 bus: mbus: fix window size calculation for 4GB windows
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jan Luebbe <[email protected]>
commit 2bbbd96357ce76cc45ec722c00f654aa7b189112 upstream.
At least the Armada XP SoC supports 4GB on a single DRAM window. Because the size register values contain the actual size - 1, the MSB is set in that case. For example, the SDRAM window's control register's value is 0xffffffe1 for 4GB (bits 31 to 24 contain the size).
The MBUS driver reads back each window's size from registers and calculates the actual size as (control_reg | ~DDR_SIZE_MASK) + 1, which overflows for 32 bit values, resulting in other miscalculations further on (a bad RAM window for the CESA crypto engine calculated by mvebu_mbus_setup_cpu_target_nooverlap() in my case).
This patch changes the type in 'struct mbus_dram_window' from u32 to u64, which allows us to keep using the same register calculation code in most MBUS-using drivers (which calculate ->size - 1 again).
--- drivers/bus/mvebu-mbus.c | 2 +- include/linux/mbus.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/bus/mvebu-mbus.c +1 -1
@@ -523,7 +523,7 @@ mvebu_mbus_default_setup_cpu_target(struif (mbus->hw_io_coherency) w->mbus_attr |=ATTR_HW_COHERENCY ; w->base = base &DDR_BASE_CS_LOW_MASK ; - w->size = (size | ~DDR_SIZE_MASK ) +1 ; + w->size = (u64)(size | ~DDR_SIZE_MASK ) +1 ; } } mvebu_mbus_dram_info.num_cs = cs;
include/linux/mbus.h +2 -2
@@ -29,8 +29,8 @@ struct mbus_dram_target_infostruct mbus_dram_window {u8 cs_index;u8 mbus_attr; -u32 base; -u32 size; +u64 base; +u64 size; } cs[4 ]; };
PATCH 109/204 KEYS: encrypted: fix dereference of NULL user_key_payload
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 13923d0865ca96312197962522e88bc0aedccd74 upstream.
A key of type "encrypted" references a "master key" which is used to encrypt and decrypt the encrypted key's payload. However, when we accessed the master key's payload, we failed to handle the case where the master key has been revoked, which sets the payload pointer to NULL. Note that request_key() *does* skip revoked keys, but there is still a window where the key can be revoked before we acquire its semaphore.
Fix it by checking for a NULL payload, treating it like a key which was already revoked at the time it was requested.
This was an issue for master keys of type "user" only. Master keys can also be of type "trusted", but those cannot be revoked.
--- security/keys/encrypted-keys/encrypted.c | 7 +++++++ 1 file changed, 7 insertions(+)
security/keys/encrypted-keys/encrypted.c +7 -0
@@ -315,6 +315,13 @@ static struct key *request_user_key(consdown_read (&ukey->sem); upayload = ukey->payload.data; +if (!upayload) { +/* key was revoked before we acquired its semaphore */ +up_read (&ukey->sem); +key_put (ukey); + ukey =ERR_PTR (-EKEYREVOKED ); + goto error; + } *master_key = upayload->data; *master_keylen = upayload->datalen; error:
PATCH 110/204 FS-Cache: fix dereference of NULL user_key_payload
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit d124b2c53c7bee6569d2a2d0b18b4a1afde00134 upstream.
When the file /proc/fs/fscache/objects (available with CONFIG_FSCACHE_OBJECT_LIST=y) is opened, we request a user key with description "fscache:objlist", then access its payload. However, a revoked key has a NULL payload, and we failed to check for this. request_key() *does* skip revoked keys, but there is still a window where the key can be revoked before we access its payload.
Fix it by checking for a NULL payload, treating it like a key which was already revoked at the time it was requested.
--- fs/fscache/object-list.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/fscache/object-list.c +7 -0
@@ -330,6 +330,13 @@ static void fscache_objlist_config(strucrcu_read_lock (); confkey = key->payload.data; +if (!confkey) { +/* key was revoked */ +rcu_read_unlock (); +key_put (key); + goto no_config; + } + buf = confkey->data;for (len = confkey->datalen -1 ; len >=0 ; len--) {
PATCH 111/204 lib/digsig: fix dereference of NULL user_key_payload
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 192cabd6a296cbc57b3d8c05c4c89d87fc102506 upstream.
digsig_verify() requests a user key, then accesses its payload. However, a revoked key has a NULL payload, and we failed to check for this. request_key() *does* skip revoked keys, but there is still a window where the key can be revoked before we acquire its semaphore.
Fix it by checking for a NULL payload, treating it like a key which was already revoked at the time it was requested.
--- lib/digsig.c | 6 ++++++ 1 file changed, 6 insertions(+)
lib/digsig.c +6 -0
@@ -86,6 +86,12 @@ static int digsig_verify_rsa(struct keydown_read (&key->sem); ukp = key->payload.data; +if (!ukp) { +/* key was revoked before we acquired its semaphore */ + err = -EKEYREVOKED ; + goto err1; + } +if (ukp->datalen <sizeof (*pkh)) goto err1;
PATCH 112/204 ecryptfs: fix dereference of NULL user_key_payload
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit f66665c09ab489a11ca490d6a82df57cfc1bea3e upstream.
In eCryptfs, we failed to verify that the authentication token keys are not revoked before dereferencing their payloads, which is problematic because the payload of a revoked key is NULL. request_key() *does* skip revoked keys, but there is still a window where the key can be revoked before we acquire the key semaphore.
Fix it by updating ecryptfs_get_key_payload_data() to return -EKEYREVOKED if the key payload is NULL. For completeness we check this for "encrypted" keys as well as "user" keys, although encrypted keys cannot be revoked currently.
Alternatively we could use key_validate(), but since we'll also need to fix ecryptfs_get_key_payload_data() to validate the payload length, it seems appropriate to just check the payload pointer.
[bwh: Backported to 3.16: user key payload is key->payload.data, not
key->payload.data[0]]
---
fs/ecryptfs/ecryptfs_kernel.h +17 -8
@@ -84,11 +84,16 @@ struct ecryptfs_page_crypt_context {static inline struct ecryptfs_auth_tok *ecryptfs_get_encrypted_key_payload_data (struct key *key) { -if (key->type == &key_type_encrypted) -return (struct ecryptfs_auth_tok *) - (&((struct encrypted_key_payload *)key->payload.data)->payload_data); -else +struct encrypted_key_payload *payload; + +if (key->type != &key_type_encrypted)return NULL ; + + payload = key->payload.data; +if (!payload) +return ERR_PTR (-EKEYREVOKED ); + +return (struct ecryptfs_auth_tok *)payload->payload_data; }static inline struct key *ecryptfs_get_encrypted_key (char *sig)
@@ -114,13 +119,17 @@ static inline struct ecryptfs_auth_tok * ecryptfs_get_key_payload_data(struct key *key) {struct ecryptfs_auth_tok *auth_tok; +struct user_key_payload *ukp; auth_tok =ecryptfs_get_encrypted_key_payload_data (key); -if (!auth_tok) -return (struct ecryptfs_auth_tok *) - (((struct user_key_payload *)key->payload.data)->data); -else +if (auth_tok)return auth_tok; + + ukp = key->payload.data; +if (!ukp) +return ERR_PTR (-EKEYREVOKED ); + +return (struct ecryptfs_auth_tok *)ukp->data; }#define ECRYPTFS_MAX_KEYSET_SIZE 1024
fs/ecryptfs/keystore.c +8 -1
@@ -459,7 +459,8 @@ out:* @auth_tok_key: key containing the authentication token * @auth_tok: authentication token * -* Returns zero on valid auth tok; -EINVAL otherwise +* Returns zero on valid auth tok; -EINVAL if the payload is invalid; or +* -EKEYREVOKED if the key was revoked before we acquired its semaphore. */ static int ecryptfs_verify_auth_tok_from_key(struct key *auth_tok_key,
@@ -468,6 +469,12 @@ ecryptfs_verify_auth_tok_from_key(structint rc =0 ; (*auth_tok) =ecryptfs_get_key_payload_data (auth_tok_key); +if (IS_ERR (*auth_tok)) { + rc =PTR_ERR (*auth_tok); + *auth_tok =NULL ; + goto out; + } +if (ecryptfs_verify_version ((*auth_tok)->version)) {printk (KERN_ERR "Data structure version mismatch. Userspace " "tools must match eCryptfs kernel module with major "
PATCH 113/204 iommu/amd: Finish TLB flush in amd_iommu_unmap()
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Joerg Roedel <[email protected]>
commit ce76353f169a6471542d999baf3d29b121dce9c0 upstream.
The function only sends the flush command to the IOMMU(s), but does not wait for its completion when it returns. Fix that.
--- drivers/iommu/amd_iommu.c | 1 + 1 file changed, 1 insertion(+)
drivers/iommu/amd_iommu.c +1 -0
@@ -3440,6 +3440,7 @@ static size_t amd_iommu_unmap(struct iommutex_unlock (&domain->api_lock);domain_flush_tlb_pde (domain); +domain_flush_complete (domain);return unmap_size; }
PATCH 114/204 include/linux/of.h: provide of_n_{addr,size}_cells wrappers for !CONFIG_OF
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit 8a1ac5dc7be09883051b1bf89a5e57d7ad850fa5 upstream.
The pci-rcar driver is enabled for compile tests, and this has shown that the driver cannot build without CONFIG_OF, following the inclusion of commit f8f2fe7355fb ("PCI: rcar: Use new OF interrupt mapping when possible"):
drivers/pci/host/pcie-rcar.c: In function 'pci_dma_range_parser_init':
drivers/pci/host/pcie-rcar.c:1039:2: error: implicit declaration of function 'of_n_addr_cells' [-Werror=implicit-function-declaration]
parser->pna = of_n_addr_cells(node);
^As pointed out by Ben Dooks and Geert Uytterhoeven, this is actually supposed to build fine, which we can achieve if we make the declaration of of_irq_parse_and_map_pci conditional on CONFIG_OF and provide an empty inline function otherwise, as we do for a lot of other of interfaces.
This lets us build the rcar_pci driver again without CONFIG_OF for build testing. All platforms using this driver select OF, so this doesn't change anything for the users.
--- include/linux/of.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
include/linux/of.h +10 -0
@@ -503,6 +503,16 @@ static inline struct device_node *of_getreturn NULL ; } +static inline int of_n_addr_cells (struct device_node *np) +{ +return 0 ; + +} +static inline int of_n_size_cells (struct device_node *np) +{ +return 0 ; +} +static inline int of_property_read_u64 (const struct device_node *np,const char *propname,u64 *out_value) {
PATCH 115/204 fs/mpage.c: fix mpage_writepage() for pages with buffers
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Wilcox <[email protected]>
commit f892760aa66a2d657deaf59538fb69433036767c upstream.
When using FAT on a block device which supports rw_page, we can hit BUG_ON(!PageLocked(page)) in try_to_free_buffers(). This is because we call clean_buffers() after unlocking the page we've written. Introduce a new clean_page_buffers() which cleans all buffers associated with a page and call it from within bdev_write_page().
--- fs/block_dev.c | 6 ++++-- fs/mpage.c | 14 +++++++++++--- include/linux/buffer_head.h | 1 + 3 files changed, 16 insertions(+), 5 deletions(-)
fs/block_dev.c +4 -2
@@ -419,10 +419,12 @@ int bdev_write_page(struct block_devicereturn -EOPNOTSUPP ;set_page_writeback (page); result = ops->rw_page (bdev, sector +get_start_sect (bdev), page, rw); -if (result) +if (result) {end_page_writeback (page); -else + }else { +clean_page_buffers (page);unlock_page (page); + }return result; }EXPORT_SYMBOL_GPL (bdev_write_page);
fs/mpage.c +11 -3
@@ -457,6 +457,16 @@ static void clean_buffers(struct page *ptry_to_free_buffers (page); } +/* +* For situations where we want to clean all buffers attached to a page. +* We don't need to calculate how many buffers are attached to the page, +* we just need to specify a number larger than the maximum number of buffers. +*/ +void clean_page_buffers (struct page *page) +{ +clean_buffers (page, ~0U ); +} +static int __mpage_writepage (struct page *page,struct writeback_control *wbc,void *data) {
@@ -594,10 +604,8 @@ alloc_new:if (bio ==NULL ) {if (first_unmapped == blocks_per_page) {if (!bdev_write_page (bdev, blocks[0 ] << (blkbits -9 ), - page, wbc)) { -clean_buffers (page, first_unmapped); + page, wbc)) goto out; - } } bio =mpage_alloc (bdev, blocks[0 ] << (blkbits -9 ),bio_get_nr_vecs (bdev),GFP_NOFS |__GFP_HIGH);
include/linux/buffer_head.h +1 -0
@@ -222,6 +222,7 @@ int generic_write_end(struct file *, str loff_t, unsigned, unsigned, struct page *, void *);void page_zero_new_buffers (struct page *page,unsigned from,unsigned to); +void clean_page_buffers (struct page *page);int cont_write_begin (struct file *,struct address_space *,loff_t ,unsigned ,unsigned ,struct page **,void **,get_block_t *,loff_t *);
PATCH 116/204 l2tp: check ps->sock before running pppol2tp_session_ioctl()
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Nault <[email protected]>
commit 5903f594935a3841137c86b9d5b75143a5b7121c upstream.
When pppol2tp_session_ioctl() is called by pppol2tp_tunnel_ioctl(), the session may be unconnected. That is, it was created by pppol2tp_session_create() and hasn't been connected with pppol2tp_connect(). In this case, ps->sock is NULL, so we need to check for this case in order to avoid dereferencing a NULL pointer.
--- net/l2tp/l2tp_ppp.c | 3 +++ 1 file changed, 3 insertions(+)
net/l2tp/l2tp_ppp.c +3 -0
@@ -1007,6 +1007,9 @@ static int pppol2tp_session_ioctl(struct session->name, cmd, arg); sk = ps->sock; +if (!sk) +return -EBADR ; +sock_hold (sk);switch (cmd) {
PATCH 117/204 USB: serial: metro-usb: add MS7820 device id
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 31dc3f819bac28a0990b36510197560258ab7421 upstream.
Add device-id entry for (Honeywell) Metrologic MS7820 bar code scanner.
The device has two interfaces (in this mode?); a vendor-specific interface with two interrupt endpoints and a second HID interface, which we do not bind to.
--- drivers/usb/serial/metro-usb.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/serial/metro-usb.c +1 -0
@@ -45,6 +45,7 @@ struct metrousb_private {static const struct usb_device_id id_table[] = { {USB_DEVICE (FOCUS_VENDOR_ID ,FOCUS_PRODUCT_ID_BI ) }, {USB_DEVICE (FOCUS_VENDOR_ID ,FOCUS_PRODUCT_ID_UNI ) }, + {USB_DEVICE_INTERFACE_CLASS (0x0c2e ,0x0730 ,0xff ) },/* MS7820 */ { },/* Terminating entry. */ };MODULE_DEVICE_TABLE (usb, id_table);
PATCH 118/204 net: enable interface alias removal via rtnl
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Dichtel <[email protected]>
commit 2459b4c635858094df78abb9ca87d99f89fe8ca5 upstream.
IFLA_IFALIAS is defined as NLA_STRING. It means that the minimal length of the attribute is 1 ("\0"). However, to remove an alias, the attribute length must be 0 (see dev_set_alias()).
Let's define the type to NLA_BINARY to allow 0-length string, so that the alias can be removed.
Example:
$ ip l s dummy0 alias foo
$ ip l l dev dummy0
5: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether ae:20:30:4f:a7:f3 brd ff:ff:ff:ff:ff:ff
alias fooBefore the patch:
$ ip l s dummy0 alias "" RTNETLINK answers: Numerical result out of range
After the patch:
$ ip l s dummy0 alias ""
$ ip l l dev dummy0
5: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether ae:20:30:4f:a7:f3 brd ff:ff:ff:ff:ff:ff--- net/core/rtnetlink.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/core/rtnetlink.c +4 -1
@@ -1187,7 +1187,10 @@ static const struct nla_policy ifla_poli [IFLA_LINKINFO] = { .type = NLA_NESTED }, [IFLA_NET_NS_PID] = { .type = NLA_U32 }, [IFLA_NET_NS_FD] = { .type = NLA_U32 }, - [IFLA_IFALIAS] = { .type = NLA_STRING, .len = IFALIASZ-1 }, +/* IFLA_IFALIAS is a string, but policy is set to NLA_BINARY to +* allow 0-length string (needed to remove an alias). +*/ + [IFLA_IFALIAS] = { .type = NLA_BINARY, .len = IFALIASZ - 1 }, [IFLA_VFINFO_LIST] = {. type = NLA_NESTED }, [IFLA_VF_PORTS] = { .type = NLA_NESTED }, [IFLA_PORT_SELF] = { .type = NLA_NESTED },
PATCH 119/204 tun: call dev_get_valid_name() before register_netdevice()
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Cong Wang <[email protected]>
commit 0ad646c81b2182f7fa67ec0c8c825e0ee165696d upstream.
register_netdevice() could fail early when we have an invalid dev name, in which case ->ndo_uninit() is not called. For tun device, this is a problem because a timer etc. are already initialized and it expects ->ndo_uninit() to clean them up.
We could move these initializations into a ->ndo_init() so that register_netdevice() knows better, however this is still complicated due to the logic in tun_detach().
Therefore, I choose to just call dev_get_valid_name() before register_netdevice(), which is quicker and much easier to audit. And for this specific case, it is already enough.
--- drivers/net/tun.c | 3 +++ include/linux/netdevice.h | 3 +++ net/core/dev.c | 6 +++--- 3 files changed, 9 insertions(+), 3 deletions(-)
drivers/net/tun.c +3 -0
@@ -1647,6 +1647,9 @@ static int tun_set_iff(struct net *net,if (!dev)return -ENOMEM ; + err =dev_get_valid_name (net, dev, name); +if (err) + goto err_free_dev;dev_net_set (dev, net); dev->rtnl_link_ops = &tun_link_ops;
include/linux/netdevice.h +3 -0
@@ -3000,6 +3000,9 @@ void ether_setup(struct net_device *dev)struct net_device *alloc_netdev_mqs (int sizeof_priv,const char *name,void (*setup)(struct net_device *),unsigned int txqs,unsigned int rxqs); +int dev_get_valid_name (struct net *net,struct net_device *dev, +const char *name); +#define alloc_netdev (sizeof_priv, name, setup) \ alloc_netdev_mqs(sizeof_priv, name, setup, 1, 1)
net/core/dev.c +3 -3
@@ -1056,9 +1056,8 @@ static int dev_alloc_name_ns(struct netreturn ret; } -static int dev_get_valid_name (struct net *net, -struct net_device *dev, -const char *name) +int dev_get_valid_name (struct net *net,struct net_device *dev, +const char *name) {BUG_ON (!net);
@@ -1074,6 +1073,7 @@ static int dev_get_valid_name(struct netreturn 0 ; } +EXPORT_SYMBOL (dev_get_valid_name);/** * dev_change_name - change name of a device
PATCH 120/204 scsi: zfcp: fix erp_action use-before-initialize in REC action trace
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Steffen Maier <[email protected]>
commit ab31fd0ce65ec93828b617123792c1bb7c6dcc42 upstream.
v4.10 commit 6f2ce1c6af37 ("scsi: zfcp: fix rport unblock race with LUN recovery") extended accessing parent pointer fields of struct zfcp_erp_action for tracing. If an erp_action has never been enqueued before, these parent pointer fields are uninitialized and NULL. Examples are zfcp objects freshly added to the parent object's children list, before enqueueing their first recovery subsequently. In zfcp_erp_try_rport_unblock(), we iterate such list. Accessing erp_action fields can cause a NULL pointer dereference. Since the kernel can read from lowcore on s390, it does not immediately cause a kernel page fault. Instead it can cause hangs on trying to acquire the wrong erp_action->adapter->dbf->rec_lock in zfcp_dbf_rec_action_lvl()
^bogus^
while holding already other locks with IRQs disabled.
Real life example from attaching lots of LUNs in parallel on many CPUs:
crash> bt 17723
PID: 17723 TASK: ... CPU: 25 COMMAND: "zfcperp0.0.1800"
LOWCORE INFO:
-psw : 0x0404300180000000 0x000000000038e424
-function : _raw_spin_lock_wait_flags at 38e424
...
#0 [fdde8fc90] zfcp_dbf_rec_action_lvl at 3e0004e9862 [zfcp] #1 [fdde8fce8] zfcp_erp_try_rport_unblock at 3e0004dfddc [zfcp] #2 [fdde8fd38] zfcp_erp_strategy at 3e0004e0234 [zfcp] #3 [fdde8fda8] zfcp_erp_thread at 3e0004e0a12 [zfcp] #4 [fdde8fe60] kthread at 173550
#5 [fdde8feb8] kernel_thread_starter at 10add2
zfcp_adapter
zfcp_port
zfcp_unit <address>, 0x404040d600000000
scsi_device NULL, returning early!
zfcp_scsi_dev.status = 0x400000000x40000000 ZFCP_STATUS_COMMON_RUNNING
crash> zfcp_unit <address>
struct zfcp_unit {
erp_action = {
adapter = 0x0,
port = 0x0,
unit = 0x0, },
}
zfcp_erp_action is always fully embedded into its container object. Such container object is never moved in its object tree (only add or delete). Hence, erp_action parent pointers can never change.
To fix the issue, initialize the erp_action parent pointers before adding the erp_action container to any list and thus before it becomes accessible from outside of its initializing function.
In order to also close the time window between zfcp_erp_setup_act() memsetting the entire erp_action to zero and setting the parent pointers again, drop the memset and instead explicitly initialize individually all erp_action fields except for parent pointers. To be extra careful not to introduce any other unintended side effect, even keep zeroing the erp_action fields for list and timer. Also double-check with WARN_ON_ONCE that erp_action parent pointers never change, so we get to know when we would deviate from previous behavior.
--- drivers/s390/scsi/zfcp_aux.c | 5 +++++ drivers/s390/scsi/zfcp_erp.c | 18 +++++++++++------- drivers/s390/scsi/zfcp_scsi.c | 5 +++++ 3 files changed, 21 insertions(+), 7 deletions(-)
drivers/s390/scsi/zfcp_aux.c +5 -0
@@ -356,6 +356,8 @@ struct zfcp_adapter *zfcp_adapter_enqueuINIT_WORK (&adapter->scan_work, zfcp_fc_scan_ports);INIT_WORK (&adapter->ns_up_work, zfcp_fc_sym_name_update); + adapter->erp_action.adapter = adapter; +if (zfcp_qdio_setup (adapter)) goto failed;
@@ -512,6 +514,9 @@ struct zfcp_port *zfcp_port_enqueue(stru port->dev.groups = zfcp_port_attr_groups; port->dev.release = zfcp_port_release; + port->erp_action.adapter = adapter; + port->erp_action.port = port; +if (dev_set_name (&port->dev,"0x%016llx" , (unsigned long long )wwpn)) {kfree (port); goto err_out;
drivers/s390/scsi/zfcp_erp.c +11 -7
@@ -193,9 +193,8 @@ static struct zfcp_erp_action *zfcp_erp_atomic_set_mask (ZFCP_STATUS_COMMON_ERP_INUSE , &zfcp_sdev->status); erp_action = &zfcp_sdev->erp_action; -memset (erp_action,0 ,sizeof (struct zfcp_erp_action )); - erp_action->port = port; - erp_action->sdev = sdev; +WARN_ON_ONCE (erp_action->port != port); +WARN_ON_ONCE (erp_action->sdev != sdev);if (!(atomic_read (&zfcp_sdev->status) &ZFCP_STATUS_COMMON_RUNNING )) act_status |=ZFCP_STATUS_ERP_CLOSE_ONLY ;
@@ -208,8 +207,8 @@ static struct zfcp_erp_action *zfcp_erp_zfcp_erp_action_dismiss_port (port);atomic_set_mask (ZFCP_STATUS_COMMON_ERP_INUSE , &port->status); erp_action = &port->erp_action; -memset (erp_action,0 ,sizeof (struct zfcp_erp_action )); - erp_action->port = port; +WARN_ON_ONCE (erp_action->port != port); +WARN_ON_ONCE (erp_action->sdev !=NULL );if (!(atomic_read (&port->status) &ZFCP_STATUS_COMMON_RUNNING )) act_status |=ZFCP_STATUS_ERP_CLOSE_ONLY ;break ;
@@ -219,7 +218,8 @@ static struct zfcp_erp_action *zfcp_erp_zfcp_erp_action_dismiss_adapter (adapter);atomic_set_mask (ZFCP_STATUS_COMMON_ERP_INUSE , &adapter->status); erp_action = &adapter->erp_action; -memset (erp_action,0 ,sizeof (struct zfcp_erp_action )); +WARN_ON_ONCE (erp_action->port !=NULL ); +WARN_ON_ONCE (erp_action->sdev !=NULL );if (!(atomic_read (&adapter->status) &ZFCP_STATUS_COMMON_RUNNING )) act_status |=ZFCP_STATUS_ERP_CLOSE_ONLY ;
@@ -229,7 +229,11 @@ static struct zfcp_erp_action *zfcp_erp_return NULL ; } - erp_action->adapter = adapter; +WARN_ON_ONCE (erp_action->adapter != adapter); +memset (&erp_action->list,0 ,sizeof (erp_action->list)); +memset (&erp_action->timer,0 ,sizeof (erp_action->timer)); + erp_action->step =ZFCP_ERP_STEP_UNINITIALIZED ; + erp_action->fsf_req_id =0 ; erp_action->action = need; erp_action->status = act_status;
drivers/s390/scsi/zfcp_scsi.c +5 -0
@@ -136,10 +136,15 @@ static int zfcp_scsi_slave_alloc(structstruct zfcp_unit *unit;int npiv = adapter->connection_features &FSF_FEATURE_NPIV_MODE ; + zfcp_sdev->erp_action.adapter = adapter; + zfcp_sdev->erp_action.sdev = sdev; + port =zfcp_get_port_by_wwpn (adapter, rport->port_name);if (!port)return -ENXIO ; + zfcp_sdev->erp_action.port = port; + unit =zfcp_unit_find (port,zfcp_scsi_dev_lun (sdev));if (unit)put_device (&unit->dev);
PATCH 121/204 usb: xhci: Handle error condition in xhci_stop_device()
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mayank Rana <[email protected]>
commit b3207c65dfafae27e7c492cb9188c0dc0eeaf3fd upstream.
xhci_stop_device() calls xhci_queue_stop_endpoint() multiple times without checking the return value. xhci_queue_stop_endpoint() can return error if the HC is already halted or unable to queue commands. This can cause a deadlock condition as xhci_stop_device() would end up waiting indefinitely for a completion for the command that didn't get queued. Fix this by checking the return value and bailing out of xhci_stop_device() in case of error. This patch happens to fix potential memory leaks of the allocated command structures as well.
---
drivers/usb/host/xhci-hub.c +17 -5
@@ -293,15 +293,25 @@ static int xhci_stop_device(struct xhci_ GFP_NOWAIT);if (!command) {spin_unlock_irqrestore (&xhci->lock, flags); -xhci_free_command (xhci, cmd); -return -ENOMEM ; + ret = -ENOMEM ; + goto cmd_cleanup; + } + ret =xhci_queue_stop_endpoint (xhci, command, slot_id, + i, suspend); +if (ret) { +spin_unlock_irqrestore (&xhci->lock, flags); +xhci_free_command (xhci, command); + goto cmd_cleanup; } -xhci_queue_stop_endpoint (xhci, command, slot_id, i, - suspend); } } -xhci_queue_stop_endpoint (xhci, cmd, slot_id,0 , suspend); + ret =xhci_queue_stop_endpoint (xhci, cmd, slot_id,0 , suspend); +if (ret) { +spin_unlock_irqrestore (&xhci->lock, flags); + goto cmd_cleanup; + } +xhci_ring_cmd_db (xhci);spin_unlock_irqrestore (&xhci->lock, flags);
@@ -312,6 +322,8 @@ static int xhci_stop_device(struct xhci_xhci_warn (xhci,"Timeout while waiting for stop endpoint command\n" ); ret = -ETIME ; } + +cmd_cleanup:xhci_free_command (xhci, cmd);return ret; }
PATCH 122/204 usb: cdc_acm: Add quirk for Elatec TWN3
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Maksim Salau <[email protected]>
commit 765fb2f181cad669f2beb87842a05d8071f2be85 upstream.
Elatec TWN3 has the union descriptor on data interface. This results in failure to bind the device to the driver with the following log:
usb 1-1.2: new full speed USB device using streamplug-ehci and address 4 usb 1-1.2: New USB device found, idVendor=09d8, idProduct=0320 usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0 usb 1-1.2: Product: RFID Device (COM)
usb 1-1.2: Manufacturer: OEM
cdc_acm 1-1.2:1.0: Zero length descriptor references
cdc_acm: probe of 1-1.2:1.0 failed with error -22
Adding the NO_UNION_NORMAL quirk for the device fixes the issue.
lsusb -v of the device:
Bus 001 Device 003: ID 09d8:0320
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 2 Communications bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 32 idVendor 0x09d8 idProduct 0x0320 bcdDevice 3.00 iManufacturer 1 OEM iProduct 2 RFID Device (COM) iSerial 0 bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 67
bNumInterfaces 2
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 250mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 2 Communications
bInterfaceSubClass 2 Abstract (modem)
bInterfaceProtocol 1 AT-commands (v.25ter)
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0020 1x 32 bytes
bInterval 2
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 10 CDC Data
bInterfaceSubClass 0 Unused
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0020 1x 32 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0020 1x 32 bytes
bInterval 0
CDC Header:
bcdCDC 1.10
CDC Call Management:
bmCapabilities 0x03
call management
use DataInterface
bDataInterface 1
CDC ACM:
bmCapabilities 0x06
sends break
line coding and serial state
CDC Union:
bMasterInterface 0
bSlaveInterface 1
Device Status: 0x0000
(Bus Powered)
--- drivers/usb/class/cdc-acm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/class/cdc-acm.c +3 -0
@@ -1775,6 +1775,9 @@ static const struct usb_device_id acm_id { USB_DEVICE(0xfff0, 0x0100), /* DATECS FP-2000 */ .driver_info =NO_UNION_NORMAL ,/* reports zero length descriptor */ }, + { USB_DEVICE(0x09d8, 0x0320), /* Elatec GmbH TWN3 */ + .driver_info = NO_UNION_NORMAL, /* has misplaced union descriptor */ + }, { USB_DEVICE(0x2912, 0x0001), /* ATOL FPrint */ .driver_info = CLEAR_HALT_CONDITIONS,
PATCH 123/204 usb: quirks: add quirk for WORLDE MINI MIDI keyboard
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Felipe Balbi <[email protected]>
commit 2811501e6d8f5747d08f8e25b9ecf472d0dc4c7d upstream.
This keyboard doesn't implement Get String descriptors properly even though string indexes are valid. What happens is that when requesting for the String descriptor, the device disconnects and reconnects. Without this quirk, this loop will continue forever.
--- drivers/usb/core/quirks.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/core/quirks.c +4 -0
@@ -218,6 +218,10 @@ static const struct usb_device_id usb_qu/* Corsair Strafe RGB */ { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT }, + /* MIDI keyboard WORLDE MINI */ + { USB_DEVICE(0x1c75, 0x0204), .driver_info = + USB_QUIRK_CONFIG_INTF_STRINGS }, + /* Acer C120 LED Projector */ { USB_DEVICE(0x1de1, 0xc102), .driver_info = USB_QUIRK_NO_LPM },
PATCH 124/204 ALSA: hda: Remove superfluous '-' added by printk conversion
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 6bf88a343db2b3c160edf9b82a74966b31cc80bd upstream.
While converting the error messages to the standard macros in the commit 4e76a8833fac ("ALSA: hda - Replace with standard printk"), a superfluous '-' slipped in the code mistakenly. Its influence is almost negligible, merely shows a dB value as negative integer instead of positive integer (or vice versa) in the rare error message. So let's kill this embarrassing byte to show more correct value.
--- sound/pci/hda/hda_codec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/hda/hda_codec.c +1 -1
@@ -2791,7 +2791,7 @@ static int get_kctl_0dB_offset(struct snreturn -1 ;if (*step_to_check && *step_to_check != step) {snd_printk (KERN_ERR "hda_codec: Mismatching dB step for vmaster slave (%d!=%d)\n" , -- *step_to_check, step); + *step_to_check, step);return -1 ; } *step_to_check = step;
PATCH 125/204 x86/microcode/intel: Disable late loading on model 79
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Borislav Petkov <[email protected]>
commit 723f2828a98c8ca19842042f418fb30dd8cfc0f7 upstream.
Blacklist Broadwell X model 79 for late loading due to an erratum.
---
arch/x86/kernel/cpu/microcode/intel.c +18 -0
@@ -267,6 +267,18 @@ static int get_ucode_fw(void *to, constreturn 0 ; } +static bool is_blacklisted (unsigned int cpu) +{ +struct cpuinfo_x86 *c = &cpu_data (cpu); + +if (c->x86 ==6 && c->x86_model ==0x4F ) { +pr_err_once ("late loading on model 79 is disabled.\n" ); +return true; + } + +return false; +} +static enum ucode_state request_microcode_fw (int cpu,struct device *device,bool refresh_fw) {
@@ -275,6 +287,9 @@ static enum ucode_state request_microcodconst struct firmware *firmware;enum ucode_state ret; +if (is_blacklisted (cpu)) +return UCODE_NFOUND ; +sprintf (name,"intel-ucode/%02x-%02x-%02x" , c->x86, c->x86_model, c->x86_mask);
@@ -299,6 +314,9 @@ static int get_ucode_user(void *to, consstatic enum ucode_state request_microcode_user (int cpu,const void __user *buf,size_t size) { +if (is_blacklisted (cpu)) +return UCODE_NFOUND ; +return generic_load_microcode (cpu, (void *)buf, size, &get_ucode_user); }
PATCH 126/204 Input: ti_am335x_tsc - fix incorrect step config for 5 wire touchscreen
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Lance <[email protected]>
commit cf5dd48907bebaefdb43a8ca079be77e8da2cb20 upstream.
Step config setting for 5 wire touchscreen is incorrect for Y coordinates. It was broken while we moved to DT. If you look close at the offending commit bb76dc09ddfc ("input: ti_am33x_tsc: Order of TSC wires, made configurable"), the change was:
- STEPCONFIG_XNP | STEPCONFIG_YPN;
+ ts_dev->bit_xn | ts_dev->bit_yp;
while bit_xn = STEPCONFIG_XNN and bit_yp = STEPCONFIG_YNN. Not quite the same.
--- drivers/input/touchscreen/ti_am335x_tsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/touchscreen/ti_am335x_tsc.c +1 -1
@@ -157,7 +157,7 @@ static void titsc_step_config(struct titbreak ;case 5 : config |= ts_dev->bit_xp |STEPCONFIG_INP_AN4 | - ts_dev->bit_xn | ts_dev->bit_yp; +STEPCONFIG_XNP |STEPCONFIG_YPN ;break ;case 8 : config |= ts_dev->bit_yp |STEPCONFIG_INP (ts_dev->inp_xp);
PATCH 127/204 parisc: Fix double-word compare and exchange in LWS code on 32-bit kernels
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: John David Anglin <[email protected]>
commit 374b3bf8e8b519f61eb9775888074c6e46b3bf0c upstream.
As discussed on the debian-hppa list, double-wordcompare and exchange operations fail on 32-bit kernels. Looking at the code, I realized that the ",ma" completer does the wrong thing in the "ldw,ma 4(%r26), %r29" instruction. This increments %r26 and causes the following store to write to the wrong location.
Note by Helge Deller:
The patch applies cleanly to stable kernel series if this upstream commit is merged in advance:f4125cfdb300 ("parisc: Avoid trashing sr2 and sr3 in LWS code").
--- arch/parisc/kernel/syscall.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/parisc/kernel/syscall.S +3 -3
@@ -742,7 +742,7 @@ lws_compare_and_swap_2: 10: ldd 0(%sr3,%r25), %r25 11: ldd 0(%sr3,%r24), %r24 #else - /* Load new value into r22/r23 - high/low */ + /* Load old value into r22/r23 - high/low */ 10: ldw 0(%sr3,%r25), %r22 11: ldw 4(%sr3,%r25), %r23 /* Load new value into fr4 for atomic store later */
@@ -834,11 +834,11 @@ cas2_action: copy %r0, %r28 #else /* Compare first word */ -19: ldw,ma 0(%sr3,%r26), %r29 +19: ldw 0(%sr3,%r26), %r29 sub,= %r29, %r22, %r0 b,n cas2_end /* Compare second word */ -20: ldw,ma 4(%sr3,%r26), %r29 +20: ldw 4(%sr3,%r26), %r29 sub,= %r29, %r23, %r0 b,n cas2_end /* Perform the store */
PATCH 128/204 usb: hub: Allow reset retry for USB2 devices on connect bounce
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit 1ac7db63333db1eeff901bfd6bbcd502b4634fa4 upstream.
If the connect status change is set during reset signaling, but the status remains connected just retry port reset.
This solves an issue with connecting a 90W HP Thunderbolt 3 dock with a Lenovo Carbon x1 (5th generation) which causes a 30min loop of a high speed device being re-discovererd before usb ports starts working.
[...]
[ 389.023845] usb 3-1: new high-speed USB device number 55 using xhci_hcd [ 389.491841] usb 3-1: new high-speed USB device number 56 using xhci_hcd [ 389.959928] usb 3-1: new high-speed USB device number 57 using xhci_hcd
[...]
This is caused by a high speed device that doesn't successfully go to the enabled state after the second port reset. Instead the connection bounces (connected, with connect status change), bailing out completely from enumeration just to restart from scratch.
--- drivers/usb/core/hub.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/usb/core/hub.c +7 -4
@@ -2625,13 +2625,16 @@ static int hub_port_wait_reset(struct usif (!(portstatus &USB_PORT_STAT_CONNECTION ))return -ENOTCONN ; -/* bomb out completely if the connection bounced. A USB 3.0 -* connection may bounce if multiple warm resets were issued, +/* Retry if connect change is set but status is still connected. +* A USB 3.0 connection may bounce if multiple warm resets were issued, * but the device may have successfully re-connected. Ignore it. */ if (!hub_is_superspeed (hub->hdev) && - (portchange &USB_PORT_STAT_C_CONNECTION )) -return -ENOTCONN ; + (portchange &USB_PORT_STAT_C_CONNECTION )) { +usb_clear_port_feature (hub->hdev, port1, +USB_PORT_FEAT_C_CONNECTION ); +return -EAGAIN ; + }if (!(portstatus &USB_PORT_STAT_ENABLE ))return -EBUSY ;
PATCH 129/204 can: esd_usb2: Fix can_dlc value for received RTR, frames
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Mätje <[email protected]>
commit 72d92e865d1560723e1957ee3f393688c49ca5bf upstream.
The dlc member of the struct rx_msg contains also the ESD_RTR flag to mark received RTR frames. Without the fix the can_dlc value for received RTR frames would always be set to 8 by get_can_dlc() instead of the received value.
--- drivers/net/can/usb/esd_usb2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/usb/esd_usb2.c +1 -1
@@ -334,7 +334,7 @@ static void esd_usb2_rx_can_msg(struct e } cf->can_id = id &ESD_IDMASK ; - cf->can_dlc =get_can_dlc (msg->msg.rx.dlc); + cf->can_dlc =get_can_dlc (msg->msg.rx.dlc & ~ESD_RTR );if (id &ESD_EXTID ) cf->can_id |=CAN_EFF_FLAG ;
PATCH 130/204 can: gs_usb: fix busy loop if no more TX context is available
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Wolfgang Grandegger <[email protected]>
commit 97819f943063b622eca44d3644067c190dc75039 upstream.
If sending messages with no cable connected, it quickly happens that there is no more TX context available. Then "gs_can_start_xmit()" returns with "NETDEV_TX_BUSY" and the upper layer does retry immediately keeping the CPU busy. To fix that issue, I moved "atomic_dec(&dev->active_tx_urbs)" from "gs_usb_xmit_callback()" to the TX done handling in "gs_usb_receive_bulk_callback()". Renaming "active_tx_urbs" to "active_tx_contexts" and moving it into "gs_[alloc|free]_tx_context()" would also make sense.
--- drivers/net/can/usb/gs_usb.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/net/can/usb/gs_usb.c +2 -8
@@ -356,6 +356,8 @@ static void gs_usb_recieve_bulk_callbackgs_free_tx_context (txc); +atomic_dec (&dev->active_tx_urbs); +netif_wake_queue (netdev); }
@@ -444,14 +446,6 @@ static void gs_usb_xmit_callback(struct urb->transfer_buffer_length, urb->transfer_buffer, urb->transfer_dma); - -atomic_dec (&dev->active_tx_urbs); - -if (!netif_device_present (netdev)) -return ; - -if (netif_queue_stopped (netdev)) -netif_wake_queue (netdev); }static netdev_tx_t gs_can_start_xmit (struct sk_buff *skb,struct net_device *netdev)
PATCH 131/204 sctp: add the missing sock_owned_by_user check in sctp_icmp_redirect
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
commit 1cc276cec9ec574d41cf47dfc0f51406b6f26ab4 upstream.
Now sctp processes icmp redirect packet in sctp_icmp_redirect where it calls sctp_transport_dst_check in which tp->dst can be released.
The problem is before calling sctp_transport_dst_check, it doesn't check sock_owned_by_user, which means tp->dst could be freed while a process is accessing it with owning the socket.
An use-after-free issue could be triggered by this.
This patch is to fix it by checking sock_owned_by_user before calling sctp_transport_dst_check in sctp_icmp_redirect, so that it would not release tp->dst if users still hold sock lock.
Besides, the same issue fixed in commit 45caeaa5ac0b ("dccp/tcp: fix routing redirect race") on sctp also needs this check.
--- net/sctp/input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sctp/input.c +1 -1
@@ -416,7 +416,7 @@ void sctp_icmp_redirect(struct sock *sk, {struct dst_entry *dst; -if (!t) +if (sock_owned_by_user (sk) || !t)return ; dst =sctp_transport_dst_check (t);if (dst)
PATCH 132/204 arm/arm64: KVM: set right LR register value for 32 bit guest when inject abort
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dongjiu Geng <[email protected]>
commit fd6c8c206fc5d0717b0433b191de0715122f33bb upstream.
When a exception is trapped to EL2, hardware uses ELR_ELx to hold the current fault instruction address. If KVM wants to inject a abort to 32 bit guest, it needs to set the LR register for the guest to emulate this abort happened in the guest. Because ARM32 architecture is pipelined execution, so the LR value has an offset to the fault instruction address.
The offsets applied to Link value for exceptions as shown below, which should be added for the ARM32 link register(LR).
Table taken from ARMv8 ARM DDI0487B-B, table G1-10:
Exception Offset, for PE state of:
A32 T32
Undefined Instruction +4 +2
Prefetch Abort +4 +4
Data Abort +8 +8
IRQ or FIQ +4 +4
[ Removed unused variables in inject_abt to avoid compile warnings.
-- Christoffer ]
[bwh: Backported to 3.16:
- Don't delete cpsr variable in inject_abt() as it's still needed
- Adjust context]
---
arch/arm/kvm/emulate.c +2 -3
@@ -295,7 +295,7 @@ void kvm_inject_undefined(struct kvm_vcpu32 return_offset = (is_thumb) ?2 :4 ; new_spsr_value = cpsr; - new_lr_value = *vcpu_pc (vcpu) - return_offset; + new_lr_value = *vcpu_pc (vcpu) + return_offset; *vcpu_cpsr (vcpu) = (cpsr & ~MODE_MASK ) |UND_MODE ; *vcpu_cpsr (vcpu) |=PSR_I_BIT ;
@@ -324,9 +324,8 @@ static void inject_abt(struct kvm_vcpu *unsigned long new_spsr_value;unsigned long cpsr = *vcpu_cpsr (vcpu);u32 sctlr = vcpu->arch.cp15[c1_SCTLR]; -bool is_thumb = (cpsr &PSR_T_BIT );u32 vect_offset; -u32 return_offset = (is_thumb) ?4 :0 ; +u32 return_offset = (is_pabt) ?4 :8 ;bool is_lpae; new_spsr_value = cpsr;
arch/arm64/kvm/inject_fault.c +15 -1
@@ -29,12 +29,26 @@ PSR_I_BIT | PSR_D_BIT)#define EL1_EXCEPT_SYNC_OFFSET 0x200 +/* +* Table taken from ARMv8 ARM DDI0487B-B, table G1-10. +*/ +static const u8 return_offsets[8 ][2 ] = { + [0 ] = {0 ,0 },/* Reset, unused */ + [1 ] = {4 ,2 },/* Undefined */ + [2 ] = {0 ,0 },/* SVC, unused */ + [3 ] = {4 ,4 },/* Prefetch abort */ + [4 ] = {8 ,8 },/* Data abort */ + [5 ] = {0 ,0 },/* HVC, unused */ + [6 ] = {4 ,4 },/* IRQ, unused */ + [7 ] = {4 ,4 },/* FIQ, unused */ +}; +static void prepare_fault32 (struct kvm_vcpu *vcpu,u32 mode,u32 vect_offset) {unsigned long cpsr;unsigned long new_spsr_value = *vcpu_cpsr (vcpu);bool is_thumb = (new_spsr_value &COMPAT_PSR_T_BIT ); -u32 return_offset = (is_thumb) ?4 :0 ; +u32 return_offset = return_offsets[vect_offset >>2 ][is_thumb];u32 sctlr =vcpu_cp15 (vcpu, c1_SCTLR); cpsr = mode |COMPAT_PSR_I_BIT ;
PATCH 133/204 pci_ids: Add PCI device IDs for F15h M60h
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Aravind Gopalakrishnan <[email protected]>
commit 4cbbdb51cc921f95978360fd7a0652d493dadc3e upstream.
Add F3, F4 device IDs to be used in amd_nb.c and amd64_edac.c
--- include/linux/pci_ids.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/pci_ids.h +2 -0
@@ -520,6 +520,8 @@#define PCI_DEVICE_ID_AMD_15H_M10H_F3 0x1403#define PCI_DEVICE_ID_AMD_15H_M30H_NB_F3 0x141d#define PCI_DEVICE_ID_AMD_15H_M30H_NB_F4 0x141e +#define PCI_DEVICE_ID_AMD_15H_M60H_NB_F3 0x1573 +#define PCI_DEVICE_ID_AMD_15H_M60H_NB_F4 0x1574#define PCI_DEVICE_ID_AMD_15H_NB_F0 0x1600#define PCI_DEVICE_ID_AMD_15H_NB_F1 0x1601#define PCI_DEVICE_ID_AMD_15H_NB_F2 0x1602
PATCH 134/204 x86, amd_nb: Add device IDs to NB tables for F15h M60h
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Aravind Gopalakrishnan <[email protected]>
commit 15895a729e02ea55433b912cc31d5c6de16359ec upstream.
Add F3 and F4 PCI device IDs to amd_nb_misc_ids[] and amd_nb_link_ids[] respectively.
--- arch/x86/kernel/amd_nb.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/kernel/amd_nb.c +2 -0
@@ -21,6 +21,7 @@ const struct pci_device_id amd_nb_misc_i { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_NB_F3) }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_M10H_F3) }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_M30H_NB_F3) }, + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_M60H_NB_F3) }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) }, {}
@@ -30,6 +31,7 @@ EXPORT_SYMBOL(amd_nb_misc_ids);static const struct pci_device_id amd_nb_link_ids[] = { {PCI_DEVICE (PCI_VENDOR_ID_AMD ,PCI_DEVICE_ID_AMD_15H_NB_F4 ) }, {PCI_DEVICE (PCI_VENDOR_ID_AMD ,PCI_DEVICE_ID_AMD_15H_M30H_NB_F4 ) }, + {PCI_DEVICE (PCI_VENDOR_ID_AMD ,PCI_DEVICE_ID_AMD_15H_M60H_NB_F4 ) }, {PCI_DEVICE (PCI_VENDOR_ID_AMD ,PCI_DEVICE_ID_AMD_16H_NB_F4 ) }, {PCI_DEVICE (PCI_VENDOR_ID_AMD ,PCI_DEVICE_ID_AMD_16H_M30H_NB_F4 ) }, {}
PATCH 135/204 x86/amd_nb: Add Fam17h Data Fabric as "Northbridge"
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Yazen Ghannam <[email protected]>
commit b791c6b6a55c402367cc544f54921074253db061 upstream.
AMD Fam17h uses a Data Fabric component instead of a traditional Northbridge. However, the DF is similar to a NB in that there is one per die and it uses PCI config D18Fx registers. So let's reuse the existing AMD_NB infrastructure for Data Fabrics.
--- arch/x86/kernel/amd_nb.c | 5 +++++ 1 file changed, 5 insertions(+)
--
To unsubscribe from this list: send the line "unsubscribe linux-edac" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
arch/x86/kernel/amd_nb.c +5 -0
@@ -13,6 +13,9 @@#include <linux/spinlock.h> #include <asm/amd_nb.h> +#define PCI_DEVICE_ID_AMD_17H_DF_F3 0x1463 +#define PCI_DEVICE_ID_AMD_17H_DF_F4 0x1464 +static u32 *flush_words;const struct pci_device_id amd_nb_misc_ids[] = {
@@ -24,6 +27,7 @@ const struct pci_device_id amd_nb_misc_i { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_M60H_NB_F3) }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) }, + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_DF_F3) }, {} };EXPORT_SYMBOL (amd_nb_misc_ids);
@@ -34,6 +38,7 @@ static const struct pci_device_id amd_nb { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_M60H_NB_F4) }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F4) }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F4) }, + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_DF_F4) }, {} };
PATCH 136/204 x86/cpu/AMD: Apply the Erratum 688 fix when the BIOS doesn't
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Borislav Petkov <[email protected]>
commit bfc1168de949cd3e9ca18c3480b5085deff1ea7c upstream.
Some F14h machines have an erratum which, "under a highly specific and detailed set of internal timing conditions" can lead to skipping instructions and RIP corruption.
Add the fix for those machines when their BIOS doesn't apply it or there simply isn't BIOS update for them.
--- arch/x86/kernel/amd_nb.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
arch/x86/kernel/amd_nb.c +41 -0
@@ -18,6 +18,8 @@static u32 *flush_words; +#define PCI_DEVICE_ID_AMD_CNB17H_F4 0x1704 +const struct pci_device_id amd_nb_misc_ids[] = { {PCI_DEVICE (PCI_VENDOR_ID_AMD ,PCI_DEVICE_ID_AMD_K8_NB_MISC ) }, {PCI_DEVICE (PCI_VENDOR_ID_AMD ,PCI_DEVICE_ID_AMD_10H_NB_MISC ) },
@@ -28,6 +30,7 @@ const struct pci_device_id amd_nb_misc_i { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_DF_F3) }, + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CNB17H_F3) }, {} };EXPORT_SYMBOL (amd_nb_misc_ids);
@@ -39,6 +42,7 @@ static const struct pci_device_id amd_nb { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F4) }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F4) }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_DF_F4) }, + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CNB17H_F4) }, {} };
@@ -285,6 +289,41 @@ void amd_flush_garts(void) }EXPORT_SYMBOL_GPL (amd_flush_garts); +static void __fix_erratum_688 (void *info) +{ +#define MSR_AMD64_IC_CFG 0xC0011021 + +msr_set_bit (MSR_AMD64_IC_CFG ,3 ); +msr_set_bit (MSR_AMD64_IC_CFG ,14 ); +} + +/* Apply erratum 688 fix so machines without a BIOS fix work. */ +static __init void fix_erratum_688 (void ) +{ +struct pci_dev *F4 ; +u32 val; + +if (boot_cpu_data.x86 !=0x14 ) +return ; + +if (!amd_northbridges.num) +return ; + +F4 =node_to_amd_nb (0 )->link; +if (!F4 ) +return ; + +if (pci_read_config_dword (F4 ,0x164 , &val)) +return ; + +if (val &BIT (2 )) +return ; + +on_each_cpu (__fix_erratum_688,NULL ,0 ); + +pr_info ("x86/cpu/AMD: CPU erratum 688 worked around\n" ); +} +static __init int init_amd_nbs (void ) {int err =0 ;
@@ -297,6 +336,8 @@ static __init int init_amd_nbs(void)if (amd_cache_gart () <0 )pr_notice ("Cannot initialize GART flush words, GART support disabled\n" ); +fix_erratum_688 (); +return err; }
PATCH 137/204 ipsec: Fix aborted xfrm policy dump crash
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ben Hutchings <[email protected]>
commit 1137b5e2529a8f5ca8ee709288ecba3e68044df2 upstream.
This is a fix for CVE-2017-16939 suitable for older stable branches. The upstream fix is commit 1137b5e2529a8f5ca8ee709288ecba3e68044df2, from which the following explanation is taken:
An independent security researcher, Mohamed Ghannam, has reported this vulnerability to Beyond Security's SecuriTeam Secure Disclosure program.
The xfrm_dump_policy_done function expects xfrm_dump_policy to have been called at least once or it will crash. This can be triggered if a dump fails because the target socket's receive buffer is full.
It was not possible to define a 'start' callback for netlink dumps until Linux 4.5, so instead add a check for the initialisation flag in the 'done' callback.
---
net/xfrm/xfrm_user.c +2 -1
@@ -1570,7 +1570,8 @@ static int xfrm_dump_policy_done(structstruct xfrm_policy_walk *walk = (struct xfrm_policy_walk *) &cb->args[1 ];struct net *net =sock_net (cb->skb->sk); -xfrm_policy_walk_done (walk, net); +if (cb->args[0 ]) +xfrm_policy_walk_done (walk, net);return 0 ; }
PATCH 138/204 ARM: 8715/1: add a private asm/unaligned.h
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit 1cce91dfc8f7990ca3aea896bfb148f240b12860 upstream.
The asm-generic/unaligned.h header provides two different implementations for accessing unaligned variables: the access_ok.h version used when CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is set pretends that all pointers are in fact aligned, while the le_struct.h version convinces gcc that the alignment of a pointer is '1', to make it issue the correct load/store instructions depending on the architecture flags.
On ARMv5 and older, we always use the second version, to let the compiler use byte accesses. On ARMv6 and newer, we currently use the access_ok.h version, so the compiler can use any instruction including stm/ldm and ldrd/strd that will cause an alignment trap. This trap can significantly impact performance when we have to do a lot of fixups and, worse, has led to crashes in the LZ4 decompressor code that does not have a trap handler.
This adds an ARM specific version of asm/unaligned.h that uses the le_struct.h/be_struct.h implementation unconditionally. This should lead to essentially the same code on ARMv6+ as before, with the exception of using regular load/store instructions instead of the trapping instructions multi-register variants.
The crash in the LZ4 decompressor code was probably introduced by the patch replacing the LZ4 implementation, commit 4e1a33b105dd ("lib: update LZ4 compressor module"), so linux-4.11 and higher would be affected most. However, we probably want to have this backported to all older stable kernels as well, to help with the performance issues.
There are two follow-ups that I think we should also work on, but not backport to stable kernels, first to change the asm-generic version of the header to remove the ARM special case, and second to review all other uses of CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS to see if they might be affected by the same problem on ARM.
--- arch/arm/include/asm/Kbuild | 1 - arch/arm/include/asm/unaligned.h | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 arch/arm/include/asm/unaligned.h
arch/arm/include/asm/Kbuild +0 -1
@@ -36,4 +36,3 @@ generic-y += termbits.h generic-y += termios.h generic-y += timex.h generic-y += trace_clock.h -generic-y += unaligned.h
arch/arm/include/asm/unaligned.h new file +27 -0
@@ -0,0 +1,27 @@ +#ifndef __ASM_ARM_UNALIGNED_H +#define __ASM_ARM_UNALIGNED_H + +/* +* We generally want to set CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS on ARMv6+, +* but we don't want to use linux/unaligned/access_ok.h since that can lead +* to traps on unaligned stm/ldm or strd/ldrd. +*/ +#include <asm/byteorder.h> + +#if defined(__LITTLE_ENDIAN) +# include <linux/unaligned/le_struct.h> +# include <linux/unaligned/be_byteshift.h> +# include <linux/unaligned/generic.h> +# define get_unaligned __get_unaligned_le +# define put_unaligned __put_unaligned_le +#elif defined(__BIG_ENDIAN) +# include <linux/unaligned/be_struct.h> +# include <linux/unaligned/le_byteshift.h> +# include <linux/unaligned/generic.h> +# define get_unaligned __get_unaligned_be +# define put_unaligned __put_unaligned_be +#else +# error need to define endianess +#endif + +#endif /* __ASM_ARM_UNALIGNED_H */
PATCH 139/204 can: kvaser_usb: Correct return value in printout
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jimmy Assarsson <[email protected]>
commit 8f65a923e6b628e187d5e791cf49393dd5e8c2f9 upstream.
If the return value from kvaser_usb_send_simple_msg() was non-zero, the return value from kvaser_usb_flush_queue() was printed in the kernel warning.
--- drivers/net/can/usb/kvaser_usb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/can/usb/kvaser_usb.c +2 -1
@@ -1263,7 +1263,8 @@ static int kvaser_usb_close(struct net_dif (err)netdev_warn (netdev,"Cannot flush queue, error %d\n" , err); -if (kvaser_usb_send_simple_msg (dev,CMD_RESET_CHIP , priv->channel)) + err =kvaser_usb_send_simple_msg (dev,CMD_RESET_CHIP , priv->channel); +if (err)netdev_warn (netdev,"Cannot reset card, error %d\n" , err); err =kvaser_usb_stop_chip (priv);
PATCH 140/204 fuse: fix READDIRPLUS skipping an entry
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Miklos Szeredi <[email protected]>
commit c6cdd51404b7ac12dd95173ddfc548c59ecf037f upstream.
Marios Titas running a Haskell program noticed a problem with fuse's
readdirplus: when it is interrupted by a signal, it skips one directory entry.
The reason is that fuse erronously updates ctx->pos after a failed dir_emit().
The issue originates from the patch adding readdirplus support.
--- fs/fuse/dir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/fuse/dir.c +2 -1
@@ -1382,7 +1382,8 @@ static int parse_dirplusfile(char *buf,*/ over = !dir_emit (ctx, dirent->name, dirent->namelen, dirent->ino, dirent->type); - ctx->pos = dirent->off; +if (!over) + ctx->pos = dirent->off; } buf += reclen;
PATCH 141/204 SMB: fix leak of validate negotiate info response buffer
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: David Disseldorp <[email protected]>
commit fe83bebc05228e838ed5cbbc62712ab50dd40e18 upstream.
--- fs/cifs/smb2pdu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/cifs/smb2pdu.c +5 -2
@@ -479,7 +479,7 @@ int smb3_validate_negotiate(const unsign {int rc =0 ;struct validate_negotiate_info_req vneg_inbuf; -struct validate_negotiate_info_rsp *pneg_rsp; +struct validate_negotiate_info_rsp *pneg_rsp =NULL ;u32 rsplen;cifs_dbg (FYI ,"validate negotiate\n" );
@@ -536,7 +536,7 @@ int smb3_validate_negotiate(const unsign/* relax check since Mac returns max bufsize allowed on ioctl */ if (rsplen > CIFSMaxBufSize) -return -EIO ; + goto err_rsp_free; }/* check validate negotiate info response matches what we got earlier */
@@ -555,10 +555,13 @@ int smb3_validate_negotiate(const unsign/* validate negotiate successful */ cifs_dbg (FYI ,"validate negotiate info successful\n" ); +kfree (pneg_rsp);return 0 ; vneg_out:cifs_dbg (VFS ,"protocol revalidation - security settings mismatch\n" ); +err_rsp_free: +kfree (pneg_rsp);return -EIO ; }
PATCH 142/204 SMB: fix validate negotiate info uninitialised memory use
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: David Disseldorp <[email protected]>
commit a2d9daad1d2dfbd307ab158044d1c323d7babbde upstream.
An undersize validate negotiate info server response causes the client to use uninitialised memory for struct validate_negotiate_info_rsp comparisons of Dialect, SecurityMode and/or Capabilities members.
--- fs/cifs/smb2pdu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/cifs/smb2pdu.c +2 -1
@@ -535,7 +535,8 @@ int smb3_validate_negotiate(const unsign rsplen);/* relax check since Mac returns max bufsize allowed on ioctl */ -if (rsplen > CIFSMaxBufSize) +if ((rsplen > CIFSMaxBufSize) + || (rsplen <sizeof (struct validate_negotiate_info_rsp ))) goto err_rsp_free; }
PATCH 143/204 net/unix: don't show information about sockets from other namespaces
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andrei Vagin <[email protected]>
commit 0f5da659d8f1810f44de14acf2c80cd6499623a0 upstream.
socket_diag shows information only about sockets from a namespace where a diag socket lives.
But if we request information about one unix socket, the kernel don't check that its netns is matched with a diag socket namespace, so any user can get information about any unix socket in a system. This looks like a bug.
v2: add a Fixes tag
--- net/unix/diag.c | 2 ++ 1 file changed, 2 insertions(+)
net/unix/diag.c +2 -0
@@ -256,6 +256,8 @@ static int unix_diag_get_exact(struct sk err = -ENOENT ;if (sk ==NULL ) goto out_nosk; +if (!net_eq (sock_net (sk), net)) + goto out; err =sock_diag_check_cookie (sk, req->udiag_cookie);if (err)
PATCH 144/204 xfrm: Clear sk_dst_cache when applying per-socket policy.
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan Basseri <[email protected]>
commit 2b06cdf3e688b98fcc9945873b5d42792bd4eee0 upstream.
If a socket has a valid dst cache, then xfrm_lookup_route will get skipped. However, the cache is not invalidated when applying policy to a socket (i.e. IPV6_XFRM_POLICY). The result is that new policies are sometimes ignored on those sockets. (Note: This was broken for IPv4 and IPv6 at different times.)
This can be demonstrated like so,
1. Create UDP socket.
2. connect() the socket.
3. Apply an outbound XFRM policy to the socket. (setsockopt)
4. send() data on the socket.
Packets will continue to be sent in the clear instead of matching an xfrm or returning a no-match error (EAGAIN). This affects calls to send() and not sendto().
Invalidating the sk_dst_cache is necessary to correctly apply xfrm policies. Since we do this in xfrm_user_policy(), the sk_lock was already acquired in either do_ip_setsockopt() or do_ipv6_setsockopt(), and we may call __sk_dst_reset().
Performance impact should be negligible, since this code is only called when changing xfrm policy, and only affects the socket in question.
Tested: https://android-review.googlesource.com/517555
Tested: https://android-review.googlesource.com/418659
--- net/xfrm/xfrm_state.c | 1 + 1 file changed, 1 insertion(+)
net/xfrm/xfrm_state.c +1 -0
@@ -1877,6 +1877,7 @@ int xfrm_user_policy(struct sock *sk, inif (err >=0 ) {xfrm_sk_policy_insert (sk, err, pol);xfrm_pol_put (pol); +__sk_dst_reset (sk); err =0 ; }
PATCH 145/204 SMB3: Validate negotiate request must always be signed
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit 4587eee04e2ac7ac3ac9fa2bc164fb6e548f99cd upstream.
According to MS-SMB2 3.2.55 validate_negotiate request must always be signed. Some Windows can fail the request if you send it unsigned
See kernel bugzilla bug 197311
--- fs/cifs/smb2pdu.c | 3 +++ 1 file changed, 3 insertions(+)
fs/cifs/smb2pdu.c +3 -0
@@ -1342,6 +1342,9 @@ SMB2_ioctl(const unsigned int xid, struc }else iov[0 ].iov_len =get_rfc1002_length (req) +4 ; +/* validate negotiate request must be signed - see MS-SMB2 3.2.5.5 */ +if (opcode ==FSCTL_VALIDATE_NEGOTIATE_INFO ) + req->hdr.Flags |=SMB2_FLAGS_SIGNED ; rc =SendReceive2 (xid, ses, iov, num_iovecs, &resp_buftype,0 ); rsp = (struct smb2_ioctl_rsp *)iov[0 ].iov_base;
PATCH 146/204 ip6_gre: Reduce log level in ip6gre_err() to debug
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Matt Bennett <[email protected]>
commit a46496ce38eeb401344d5623c1960dbf2f1769be upstream.
Currently error log messages in ip6gre_err are printed at 'warn' level. This is different to most other tunnel types which don't print any messages. These log messages don't provide any information that couldn't be deduced with networking tools. Also it can be annoying to have one end of the tunnel go down and have the logs fill with pointless messages such as "Path to destination invalid or inactive!".
This patch reduces the log level of these messages to 'dbg' level to bring the visible behaviour into line with other tunnel types.
--- net/ipv6/ip6_gre.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
net/ipv6/ip6_gre.c +8 -8
@@ -404,13 +404,13 @@ static void ip6gre_err(struct sk_buff *sstruct ipv6_tlv_tnl_enc_lim *tel;__u32 mtu;case ICMPV6_DEST_UNREACH : -net_warn_ratelimited ("%s: Path to destination invalid or inactive!\n" , - t->parms.name); +net_dbg_ratelimited ("%s: Path to destination invalid or inactive!\n" , + t->parms.name);break ;case ICMPV6_TIME_EXCEED :if (code ==ICMPV6_EXC_HOPLIMIT ) { -net_warn_ratelimited ("%s: Too small hop limit or routing loop in tunnel!\n" , - t->parms.name); +net_dbg_ratelimited ("%s: Too small hop limit or routing loop in tunnel!\n" , + t->parms.name); }break ;case ICMPV6_PARAMPROB :
@@ -421,12 +421,12 @@ static void ip6gre_err(struct sk_buff *sif (teli && teli ==be32_to_cpu (info) -2 ) { tel = (struct ipv6_tlv_tnl_enc_lim *) &skb->data[teli];if (tel->encap_limit ==0 ) { -net_warn_ratelimited ("%s: Too small encapsulation limit or routing loop in tunnel!\n" , - t->parms.name); +net_dbg_ratelimited ("%s: Too small encapsulation limit or routing loop in tunnel!\n" , + t->parms.name); } }else { -net_warn_ratelimited ("%s: Recipient unable to parse tunneled packet!\n" , - t->parms.name); +net_dbg_ratelimited ("%s: Recipient unable to parse tunneled packet!\n" , + t->parms.name); }break ;case ICMPV6_PKT_TOOBIG :
PATCH 147/204 ip6_gre: only increase err_count for some certain type icmpv6 in ip6gre_err
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
commit f8d20b46ce55cf40afb30dcef6d9288f7ef46d9b upstream.
The similar fix in patch 'ipip: only increase err_count for some certain type icmp in ipip_err' is needed for ip6gre_err.
In Jianlin's case, udp netperf broke even when receiving a TooBig icmpv6 packet.
--- net/ipv6/ip6_gre.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
net/ipv6/ip6_gre.c +7 -4
@@ -406,13 +406,16 @@ static void ip6gre_err(struct sk_buff *scase ICMPV6_DEST_UNREACH :net_dbg_ratelimited ("%s: Path to destination invalid or inactive!\n" , t->parms.name); -break ; +if (code !=ICMPV6_PORT_UNREACH ) +break ; +return ;case ICMPV6_TIME_EXCEED :if (code ==ICMPV6_EXC_HOPLIMIT ) {net_dbg_ratelimited ("%s: Too small hop limit or routing loop in tunnel!\n" , t->parms.name); +break ; } -break ; +return ;case ICMPV6_PARAMPROB : teli =0 ;if (code ==ICMPV6_HDR_FIELD )
@@ -428,13 +431,13 @@ static void ip6gre_err(struct sk_buff *snet_dbg_ratelimited ("%s: Recipient unable to parse tunneled packet!\n" , t->parms.name); } -break ; +return ;case ICMPV6_PKT_TOOBIG : mtu =be32_to_cpu (info) - offset;if (mtu <IPV6_MIN_MTU ) mtu =IPV6_MIN_MTU ; t->dev->mtu = mtu; -break ; +return ; }if (time_before (jiffies, t->err_time +IP6TUNNEL_ERR_TIMEO ))
PATCH 148/204 sctp: fix a type cast warnings that causes a_rwnd gets the wrong value
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
commit f6fc6bc0b8e0bb13a210bd7386ffdcb1a5f30ef1 upstream.
These warnings were found by running 'make C=2 M=net/sctp/'.
Commit d4d6fb5787a6 ("sctp: Try not to change a_rwnd when faking a SACK from SHUTDOWN.") expected to use the peers old rwnd and add our flight size to the a_rwnd. But with the wrong Endian, it may not work as well as expected.
So fix it by converting to the right value.
--- net/sctp/sm_sideeffect.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/sctp/sm_sideeffect.c +2 -2
@@ -1627,8 +1627,8 @@ static int sctp_cmd_interpreter(sctp_evecase SCTP_CMD_PROCESS_CTSN :/* Dummy up a SACK for processing. */ sackh.cum_tsn_ack = cmd->obj.be32; - sackh.a_rwnd = asoc->peer.rwnd + - asoc->outqueue.outstanding_bytes; + sackh.a_rwnd =htonl (asoc->peer.rwnd + + asoc->outqueue.outstanding_bytes); sackh.num_gap_ack_blocks =0 ; sackh.num_dup_tsns =0 ; chunk->subh.sack_hdr = &sackh;
PATCH 149/204 x86/uaccess, sched/preempt: Verify access_ok() context
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <[email protected]>
commit 7c4788950ba5922fde976d80b72baf46f14dee8d upstream.
I recently encountered wreckage because access_ok() was used where it should not be, add an explicit WARN when access_ok() is used wrongly.
[bwh: Backported to 3.16:
- Adjust filename
- Include <linux/preempt_mask.h> in <asm/uaccess.h> since it's not included by <linux/uaccess.h>]
--- arch/x86/include/asm/uaccess.h | 13 +++++++++++-- include/linux/preempt_mask.h | 21 +++++++++++++-------- 2 files changed, 24 insertions(+), 10 deletions(-)
arch/x86/include/asm/uaccess.h +12 -2
@@ -7,6 +7,7 @@#include <linux/compiler.h> #include <linux/thread_info.h> #include <linux/string.h> +#include <linux/preempt_mask.h> #include <asm/asm.h> #include <asm/page.h> #include <asm/smap.h>
@@ -66,6 +67,12 @@ static inline bool __chk_range_not_ok(un__chk_range_not_ok ((unsigned long __force )(addr), size, limit); \ }) +#ifdef CONFIG_DEBUG_ATOMIC_SLEEP +# define WARN_ON_IN_IRQ () WARN_ON_ONCE(!in_task()) +#else +# define WARN_ON_IN_IRQ () +#endif +/** * access_ok: - Checks if a user space pointer is valid * @type: Type of access: %VERIFY_READ or %VERIFY_WRITE. Note that
@@ -85,8 +92,11 @@ static inline bool __chk_range_not_ok(un* checks that the pointer is in the user space range - after calling * this function, memory access functions may still return -EFAULT. */ -#define access_ok (type, addr, size) \ - likely(!__range_not_ok(addr, size, user_addr_max())) +#define access_ok (type, addr, size) \ +({ \ + WARN_ON_IN_IRQ(); \ + likely(!__range_not_ok(addr, size, user_addr_max())); \ +})/* * The exception table consists of pairs of addresses relative to the
include/linux/preempt_mask.h +13 -8
@@ -57,19 +57,24 @@/* * Are we doing bottom half or hardware interrupt processing? -* Are we in a softirq context? Interrupt context? -* in_softirq - Are we currently processing softirq or have bh disabled? -* in_serving_softirq - Are we currently processing softirq? +* +* in_irq() - We're in (hard) IRQ context +* in_softirq() - We have BH disabled, or are processing softirqs +* in_interrupt() - We're in NMI,IRQ,SoftIRQ context or have BH disabled +* in_serving_softirq() - We're in softirq context +* in_nmi() - We're in NMI context +* in_task() - We're in task context +* +* Note: due to the BH disabled confusion: in_softirq(),in_interrupt() really +* should not be used in new code. */ #define in_irq () (hardirq_count())#define in_softirq () (softirq_count())#define in_interrupt () (irq_count())#define in_serving_softirq () (softirq_count() & SOFTIRQ_OFFSET) - -/* -* Are we in NMI context? -*/ -#define in_nmi () (preempt_count() & NMI_MASK) +#define in_nmi () (preempt_count() & NMI_MASK) +#define in_task () (!(preempt_count() & \ + (NMI_MASK | HARDIRQ_MASK | SOFTIRQ_OFFSET)))/* * The preempt_count offset after preempt_disable();
PATCH 150/204 workqueue: Fix NULL pointer dereference
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Li Bin <[email protected]>
commit cef572ad9bd7f85035ba8272e5352040e8be0152 upstream.
When queue_work() is used in irq (not in task context), there is a potential case that trigger NULL pointer dereference.
----------------------------------------------------------------worker_thread()
|-spin_lock_irq()
|-process_one_work()
|-worker->current_pwq = pwq |-spin_unlock_irq() |-worker->current_func(work) |-spin_lock_irq()
|-worker->current_pwq = NULL
|-spin_unlock_irq()
//interrupt here |-irq_handler |-__queue_work() //assuming that the wq is draining |-is_chained_work(wq) |-current_wq_worker() //Here, 'current' is the interrupted worker! |-current->current_pwq is NULL here!
|-schedule()
----------------------------------------------------------------
Avoid it by checking for task context in current_wq_worker(), and if not in task context, we shouldn't use the 'current' to check the condition.
--- kernel/workqueue_internal.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/workqueue_internal.h +2 -1
@@ -9,6 +9,7 @@#include <linux/workqueue.h> #include <linux/kthread.h> +#include <linux/preempt.h> struct worker_pool ;
@@ -59,7 +60,7 @@ struct worker {*/ static inline struct worker *current_wq_worker (void ) { -if (current->flags &PF_WQ_WORKER ) +if (in_task () && (current->flags &PF_WQ_WORKER ))return kthread_data (current);return NULL ; }
PATCH 151/204 l2tp: hold tunnel in pppol2tp_connect()
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Nault <[email protected]>
commit f9e56baf03f9d36043a78f16e3e8b2cfd211e09e upstream.
Use l2tp_tunnel_get() in pppol2tp_connect() to ensure the tunnel isn't going to disappear while processing the rest of the function.
--- net/l2tp/l2tp_ppp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/l2tp/l2tp_ppp.c +6 -1
@@ -603,6 +603,7 @@ static int pppol2tp_connect(struct sockeu32 tunnel_id, peer_tunnel_id;u32 session_id, peer_session_id;bool drop_refcnt = false; +bool drop_tunnel = false;int ver =2 ;int fd;
@@ -671,7 +672,9 @@ static int pppol2tp_connect(struct sockeif (tunnel_id ==0 ) goto end; - tunnel =l2tp_tunnel_find (sock_net (sk), tunnel_id); + tunnel =l2tp_tunnel_get (sock_net (sk), tunnel_id); +if (tunnel) + drop_tunnel = true;/* Special case: create tunnel context if session_id and * peer_session_id is 0. Otherwise look up tunnel using supplied
@@ -800,6 +803,8 @@ out_no_ppp: end:if (drop_refcnt)l2tp_session_dec_refcount (session); +if (drop_tunnel) +l2tp_tunnel_dec_refcount (tunnel);release_sock (sk);return error;
PATCH 152/204 ALSA: timer: Add missing mutex lock for compat ioctls
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 79fb0518fec8c8b4ea7f1729f54f293724b3dbb0 upstream.
The races among ioctl and other operations were protected by the commit af368027a49a ("ALSA: timer: Fix race among timer ioctls") and later fixes, but one code path was forgotten in the scenario: the 32bit compat ioctl. As syzkaller recently spotted, a very similar use-after-free may happen with the combination of compat ioctls.
The fix is simply to apply the same ioctl_lock to the compat_ioctl callback, too.
Reference: http://lkml.kernel.org/r/[email protected]
--- sound/core/timer_compat.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
sound/core/timer_compat.c +15 -2
@@ -106,7 +106,8 @@ enum {#endif /* CONFIG_X86_X32 */ }; -static long snd_timer_user_ioctl_compat (struct file *file,unsigned int cmd,unsigned long arg) +static long __snd_timer_user_ioctl_compat (struct file *file,unsigned int cmd, +unsigned long arg) {void __user *argp =compat_ptr (arg);
@@ -127,7 +128,7 @@ static long snd_timer_user_ioctl_compat(case SNDRV_TIMER_IOCTL_PAUSE :case SNDRV_TIMER_IOCTL_PAUSE_OLD :case SNDRV_TIMER_IOCTL_NEXT_DEVICE : -return snd_timer_user_ioctl (file, cmd, (unsigned long )argp); +return __snd_timer_user_ioctl (file, cmd, (unsigned long )argp);case SNDRV_TIMER_IOCTL_INFO32 :return snd_timer_user_info_compat (file, argp);case SNDRV_TIMER_IOCTL_STATUS32 :
@@ -139,3 +140,15 @@ static long snd_timer_user_ioctl_compat( }return -ENOIOCTLCMD ; } + +static long snd_timer_user_ioctl_compat (struct file *file,unsigned int cmd, +unsigned long arg) +{ +struct snd_timer_user *tu = file->private_data; +long ret; + +mutex_lock (&tu->ioctl_lock); + ret =__snd_timer_user_ioctl_compat (file, cmd, arg); +mutex_unlock (&tu->ioctl_lock); +return ret; +}
PATCH 153/204 ALSA: seq: Fix nested rwsem annotation for lockdep splat
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 1f20f9ff57ca23b9f5502fca85ce3977e8496cb1 upstream.
syzkaller reported the lockdep splat due to the possible deadlock of grp->list_mutex of each sequencer client object. Actually this is rather a false-positive report due to the missing nested lock annotations. The sequencer client may deliver the event directly to another client which takes another own lock.
For addressing this issue, this patch replaces the simple down_read() with down_read_nested(). As a lock subclass, the already existing "hop" can be re-used, which indicates the depth of the call.
Reference: http://lkml.kernel.org/r/[email protected]
--- sound/core/seq/seq_clientmgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/seq/seq_clientmgr.c +1 -1
@@ -676,7 +676,7 @@ static int deliver_to_subscribers(structif (atomic)read_lock (&grp->list_lock);else -down_read (&grp->list_mutex); +down_read_nested (&grp->list_mutex, hop);list_for_each_entry (subs, &grp->list_head, src_list) {/* both ports ready? */ if (atomic_read (&subs->ref_count) !=2 )
PATCH 154/204 MIPS: Fix CM region target definitions
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paul Burton <[email protected]>
commit 6a6cba1d945a7511cdfaf338526871195e420762 upstream.
The default CM target field in the GCR_BASE register is encoded with 0 meaning memory & 1 being reserved. However the definitions we use for those bits effectively get these two values backwards - likely because they were copied from the definitions for the CM regions where the target is encoded differently. This results in use setting up GCR_BASE with the reserved target value by default, rather than targeting memory as intended. Although we currently seem to get away with this it's not a great idea to rely upon.
Fix this by changing our macros to match the documentated target values.
The incorrect encoding became used as of commit 9f98f3dd0c51 ("MIPS: Add generic CM probe & access code") in the Linux v3.15 cycle, and was likely carried forwards from older but unused code introduced by commit 39b8d5254246 ("[MIPS] Add support for MIPS CMP platform.") in the v2.6.26 cycle.
Patchwork: https://patchwork.linux-mips.org/patch/17562/
--- arch/mips/include/asm/mips-cm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/include/asm/mips-cm.h +2 -2
@@ -173,8 +173,8 @@ BUILD_CM_Cx_R_(tcid_8_priority, 0x80)#define CM_GCR_BASE_GCRBASE_MSK (_ULCAST_(0x1ffff) << 15)#define CM_GCR_BASE_CMDEFTGT_SHF 0#define CM_GCR_BASE_CMDEFTGT_MSK (_ULCAST_(0x3) << 0) -#define CM_GCR_BASE_CMDEFTGT_DISABLED 0 -#define CM_GCR_BASE_CMDEFTGT_MEM 1 +#define CM_GCR_BASE_CMDEFTGT_MEM 0 +#define CM_GCR_BASE_CMDEFTGT_RESERVED 1#define CM_GCR_BASE_CMDEFTGT_IOCU0 2#define CM_GCR_BASE_CMDEFTGT_IOCU1 3
PATCH 155/204 MIPS: microMIPS: Fix incorrect mask in insn_table_MM
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Gustavo A. R. Silva" <[email protected]>
commit 77238e76b9156d28d86c1e31c00ed2960df0e4de upstream.
It seems that this is a typo error and the proper bit masking is "RT | RS" instead of "RS | RS".
This issue was detected with the help of Coccinelle.
Patchwork: https://patchwork.linux-mips.org/patch/17551/
--- arch/mips/mm/uasm-micromips.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/mm/uasm-micromips.c +1 -1
@@ -83,7 +83,7 @@ static struct insn insn_table_MM[] = { { insn_jr, M(mm_pool32a_op, 0, 0, 0, mm_jalr_op, mm_pool32axf_op), RS }, { insn_lb, M(mm_lb32_op, 0, 0, 0, 0, 0), RT | RS | SIMM }, { insn_ld, 0, 0 }, - { insn_lh, M(mm_lh32_op, 0, 0, 0, 0, 0), RS | RS | SIMM }, + { insn_lh, M(mm_lh32_op, 0, 0, 0, 0, 0), RT | RS | SIMM }, { insn_ll, M(mm_pool32c_op, 0, 0, (mm_ll_func << 1), 0, 0), RS | RT | SIMM }, { insn_lld, 0, 0 }, { insn_lui, M(mm_pool32i_op, mm_lui_op, 0, 0, 0, 0), RS | SIMM },
PATCH 156/204 macvtap: fix TUNSETSNDBUF values > 64k
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Michael S. Tsirkin" <[email protected]>
commit 3ea79249e81e5ed051f2e6480cbde896d99046e8 upstream.
Upon TUNSETSNDBUF, macvtap reads the requested sndbuf size into a local variable u.
commit 39ec7de7092b ("macvtap: fix uninitialized access on TUNSETIFF") changed its type to u16 (which is the right thing to do for all other macvtap ioctls), breaking all values > 64k.
The value of TUNSETSNDBUF is actually a signed 32 bit integer, so the right thing to do is to read it into an int.
--- drivers/net/macvtap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/macvtap.c +2 -2
@@ -1051,10 +1051,10 @@ static long macvtap_ioctl(struct file *freturn 0 ;case TUNSETSNDBUF : -if (get_user (u, up)) +if (get_user (s, sp))return -EFAULT ; - q->sk.sk_sndbuf = u; + q->sk.sk_sndbuf = s;return 0 ;case TUNGETVNETHDRSZ :
PATCH 157/204 tun/tap: sanitize TUNSETSNDBUF input
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Craig Gallek <[email protected]>
commit 93161922c658c714715686cd0cf69b090cb9bf1d upstream.
Syzkaller found several variants of the lockup below by setting negative values with the TUNSETSNDBUF ioctl. This patch adds a sanity check to both the tun and tap versions of this ioctl.
watchdog: BUG: soft lockup - CPU#0 stuck for 22s! [repro:2389] Modules linked in: irq event stamp: 329692056 hardirqs last enabled at (329692055): [<ffffffff824b8381>] _raw_spin_unlock_irqrestore+0x31/0x75 hardirqs last disabled at (329692056): [<ffffffff824b9e58>] apic_timer_interrupt+0x98/0xb0 softirqs last enabled at (35659740): [<ffffffff824bc958>] __do_softirq+0x328/0x48c softirqs last disabled at (35659731): [<ffffffff811c796c>] irq_exit+0xbc/0xd0 CPU: 0 PID: 2389 Comm: repro Not tainted 4.14.0-rc7 #23 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 task: ffff880009452140 task.stack: ffff880006a20000 RIP: 0010:_raw_spin_lock_irqsave+0x11/0x80 RSP: 0018:ffff880006a27c50 EFLAGS: 00000282 ORIG_RAX: ffffffffffffff10 RAX: ffff880009ac68d0 RBX: ffff880006a27ce0 RCX: 0000000000000000 RDX: 0000000000000001 RSI: ffff880006a27ce0 RDI: ffff880009ac6900 RBP: ffff880006a27c60 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000001 R11: 000000000063ff00 R12: ffff880009ac6900 R13: ffff880006a27cf8 R14: 0000000000000001 R15: ffff880006a27cf8 FS: 00007f4be4838700(0000) GS:ffff88000cc00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000020101000 CR3: 0000000009616000 CR4: 00000000000006f0 Call Trace: prepare_to_wait+0x26/0xc0 sock_alloc_send_pskb+0x14e/0x270 ? remove_wait_queue+0x60/0x60 tun_get_user+0x2cc/0x19d0 ? __tun_get+0x60/0x1b0 tun_chr_write_iter+0x57/0x86 __vfs_write+0x156/0x1e0 vfs_write+0xf7/0x230 SyS_write+0x57/0xd0 entry_SYSCALL_64_fastpath+0x1f/0xbe RIP: 0033:0x7f4be4356df9 RSP: 002b:00007ffc18101c08 EFLAGS: 00000293 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f4be4356df9 RDX: 0000000000000046 RSI: 0000000020101000 RDI: 0000000000000005 RBP: 00007ffc18101c40 R08: 0000000000000001 R09: 0000000000000001 R10: 0000000000000001 R11: 0000000000000293 R12: 0000559c75f64780 R13: 00007ffc18101d30 R14: 0000000000000000 R15: 0000000000000000
--- drivers/net/macvtap.c | 2 ++ drivers/net/tun.c | 4 ++++ 2 files changed, 6 insertions(+)
drivers/net/macvtap.c +2 -0
@@ -1053,6 +1053,8 @@ static long macvtap_ioctl(struct file *fcase TUNSETSNDBUF :if (get_user (s, sp))return -EFAULT ; +if (s <=0 ) +return -EINVAL ; q->sk.sk_sndbuf = s;return 0 ;
drivers/net/tun.c +4 -0
@@ -2054,6 +2054,10 @@ static long __tun_chr_ioctl(struct file ret = -EFAULT ;break ; } +if (sndbuf <=0 ) { + ret = -EINVAL ; +break ; + } tun->sndbuf = sndbuf;tun_set_sndbuf (tun);
PATCH 158/204 tcp: fix tcp_mtu_probe() vs highest_sack
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit 2b7cda9c35d3b940eb9ce74b30bbd5eb30db493d upstream.
Based on SNMP values provided by Roman, Yuchung made the observation that some crashes in tcp_sacktag_walk() might be caused by MTU probing.
Looking at tcp_mtu_probe(), I found that when a new skb was placed in front of the write queue, we were not updating tcp highest sack.
If one skb is freed because all its content was copied to the new skb (for MTU probing), then tp->highest_sack could point to a now freed skb.
Bad things would then happen, including infinite loops.
This patch renames tcp_highest_sack_combine() and uses it from tcp_mtu_probe() to fix the bug.
Note that I also removed one test against tp->sacked_out, since we want to replace tp->highest_sack regardless of whatever condition, since keeping a stale pointer to freed skb is a recipe for disaster.
--- include/net/tcp.h | 6 +++--- net/ipv4/tcp_output.c | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-)
include/net/tcp.h +3 -3
@@ -1515,12 +1515,12 @@ static inline void tcp_highest_sack_resetcp_sk (sk)->highest_sack =tcp_write_queue_head (sk); } -/* Called when old skb is about to be deleted (to be combined with new skb) */ -static inline void tcp_highest_sack_combine (struct sock *sk, +/* Called when old skb is about to be deleted and replaced by new skb */ +static inline void tcp_highest_sack_replace (struct sock *sk,struct sk_buff *old,struct sk_buff *new) { -if (tcp_sk (sk)->sacked_out && (old ==tcp_sk (sk)->highest_sack)) +if (old ==tcp_highest_sack (sk))tcp_sk (sk)->highest_sack = new; }
net/ipv4/tcp_output.c +2 -1
@@ -1817,6 +1817,7 @@ static int tcp_mtu_probe(struct sock *sk nskb->ip_summed = skb->ip_summed;tcp_insert_write_queue_before (nskb, skb, sk); +tcp_highest_sack_replace (sk, skb, nskb); len =0 ; tcp_for_write_queue_from_safe(skb, next, sk) {
@@ -2327,7 +2328,7 @@ static void tcp_collapse_retrans(structBUG_ON (tcp_skb_pcount (skb) !=1 ||tcp_skb_pcount (next_skb) !=1 ); -tcp_highest_sack_combine (sk, next_skb, skb); +tcp_highest_sack_replace (sk, next_skb, skb);tcp_unlink_write_queue (next_skb, sk);
PATCH 159/204 KEYS: return full count in keyring_read() if buffer is too small
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 3239b6f29bdfb4b0a2ba59df995fc9e6f4df7f1f upstream.
Commit e645016abc80 ("KEYS: fix writing past end of user-supplied buffer in keyring_read()") made keyring_read() stop corrupting userspace memory when the user-supplied buffer is too small. However it also made the return value in that case be the short buffer size rather than the size required, yet keyctl_read() is actually documented to return the size required. Therefore, switch it over to the documented behavior.
Note that for now we continue to have it fill the short buffer, since it did that before (pre-v3.13) and dump_key_tree_aux() in keyutils arguably relies on it.
--- security/keys/keyring.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-)
security/keys/keyring.c +19 -20
@@ -441,34 +441,33 @@ static long keyring_read(const struct ke char __user *buffer, size_t buflen) {struct keyring_read_iterator_context ctx; -unsigned long nr_keys; -int ret; +long ret;kenter ("{%d},,%zu" ,key_serial (keyring), buflen);if (buflen & (sizeof (key_serial_t) -1 ))return -EINVAL ; - nr_keys = keyring->keys.nr_leaves_on_tree; -if (nr_keys ==0 ) -return 0 ; - -/* Calculate how much data we could return */ -if (!buffer || !buflen) -return nr_keys *sizeof (key_serial_t); - -/* Copy the IDs of the subscribed keys into the buffer */ - ctx.buffer = (key_serial_t __user *)buffer; - ctx.buflen = buflen; - ctx.count =0 ; - ret =assoc_array_iterate (&keyring->keys, keyring_read_iterator, &ctx); -if (ret <0 ) { -kleave (" = %d [iterate]" , ret); -return ret; +/* Copy as many key IDs as fit into the buffer */ +if (buffer && buflen) { + ctx.buffer = (key_serial_t __user *)buffer; + ctx.buflen = buflen; + ctx.count =0 ; + ret =assoc_array_iterate (&keyring->keys, + keyring_read_iterator, &ctx); +if (ret <0 ) { +kleave (" = %ld [iterate]" , ret); +return ret; + } } -kleave (" = %zu [ok]" , ctx.count); -return ctx.count; +/* Return the size of the buffer needed */ + ret = keyring->keys.nr_leaves_on_tree *sizeof (key_serial_t); +if (ret <= buflen) +kleave ("= %ld [ok]" , ret); +else +kleave ("= %ld [buffer too small]" , ret); +return ret; }/*
PATCH 160/204 KEYS: trusted: sanitize all key material
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit ee618b4619b72527aaed765f0f0b74072b281159 upstream.
As the previous patch did for encrypted-keys, zero sensitive any potentially sensitive data related to the "trusted" key type before it is freed. Notably, we were not zeroing the tpm_buf structures in which the actual key is stored for TPM seal and unseal, nor were we zeroing the trusted_key_payload in certain error paths.
[bwh: Backported to 3.16:
- Drop one unapplicable change
- Adjust context]
---
security/keys/trusted.c +21 -27
@@ -69,7 +69,7 @@ static int TSS_sha1(const unsigned char } ret =crypto_shash_digest (&sdesc->shash, data, datalen, digest); -kfree (sdesc); +kzfree (sdesc);return ret; }
@@ -113,7 +113,7 @@ static int TSS_rawhmac(unsigned char *diif (!ret) ret =crypto_shash_final (&sdesc->shash, digest); out: -kfree (sdesc); +kzfree (sdesc);return ret; }
@@ -164,7 +164,7 @@ static int TSS_authhmac(unsigned char *d paramdigest,TPM_NONCE_SIZE , h1, TPM_NONCE_SIZE, h2, 1, &c, 0, 0); out: -kfree (sdesc); +kzfree (sdesc);return ret; }
@@ -245,7 +245,7 @@ static int TSS_checkhmac1(unsigned charif (memcmp (testhmac, authdata,SHA1_DIGEST_SIZE )) ret = -EINVAL ; out: -kfree (sdesc); +kzfree (sdesc);return ret; }
@@ -346,7 +346,7 @@ static int TSS_checkhmac2(unsigned charif (memcmp (testhmac2, authdata2,SHA1_DIGEST_SIZE )) ret = -EINVAL ; out: -kfree (sdesc); +kzfree (sdesc);return ret; }
@@ -563,7 +563,7 @@ static int tpm_seal(struct tpm_buf *tb, *bloblen = storedsize; } out: -kfree (td); +kzfree (td);return ret; }
@@ -677,7 +677,7 @@ static int key_seal(struct trusted_key_pif (ret <0 )pr_info ("trusted_key: srkseal failed (%d)\n" , ret); -kfree (tb); +kzfree (tb);return ret; }
@@ -702,7 +702,7 @@ static int key_unseal(struct trusted_key/* pull migratable flag out of sealed key */ p->migratable = p->key[--p->key_len]; -kfree (tb); +kzfree (tb);return ret; }
@@ -961,12 +961,12 @@ static int trusted_instantiate(struct keif (!ret && options->pcrlock) ret =pcrlock (options->pcrlock); out: -kfree (datablob); -kfree (options); +kzfree (datablob); +kzfree (options);if (!ret)rcu_assign_keypointer (key, payload);else -kfree (payload); +kzfree (payload);return ret; }
@@ -975,8 +975,7 @@ static void trusted_rcu_free(struct rcu_struct trusted_key_payload *p; p = container_of(rcu, struct trusted_key_payload, rcu); -memset (p->key,0 , p->key_len); -kfree (p); +kzfree (p); }/*
@@ -1015,7 +1014,7 @@ static int trusted_update(struct key *ke ret =datablob_parse (datablob, new_p, new_o);if (ret != Opt_update) { ret = -EINVAL ; -kfree (new_p); +kzfree (new_p); goto out; }/* copy old key values, and reseal with new pcrs */
@@ -1028,22 +1027,22 @@ static int trusted_update(struct key *ke ret =key_seal (new_p, new_o);if (ret <0 ) {pr_info ("trusted_key: key_seal failed (%d)\n" , ret); -kfree (new_p); +kzfree (new_p); goto out; }if (new_o->pcrlock) { ret =pcrlock (new_o->pcrlock);if (ret <0 ) {pr_info ("trusted_key: pcrlock failed (%d)\n" , ret); -kfree (new_p); +kzfree (new_p); goto out; } }rcu_assign_keypointer (key, new_p);call_rcu (&p->rcu, trusted_rcu_free); out: -kfree (datablob); -kfree (new_o); +kzfree (datablob); +kzfree (new_o);return ret; }
@@ -1072,24 +1071,19 @@ static long trusted_read(const struct kefor (i =0 ; i < p->blob_len; i++) bufp =hex_byte_pack (bufp, p->blob[i]);if ((copy_to_user (buffer, ascii_buf,2 * p->blob_len)) !=0 ) { -kfree (ascii_buf); +kzfree (ascii_buf);return -EFAULT ; } -kfree (ascii_buf); +kzfree (ascii_buf);return 2 * p->blob_len; }/* -* trusted_destroy - before freeing the key, clear the decrypted data +* trusted_destroy - clear and free the key's payload */ static void trusted_destroy (struct key *key) { -struct trusted_key_payload *p = key->payload.data; - -if (!p) -return ; -memset (p->key,0 , p->key_len); -kfree (key->payload.data); +kzfree (key->payload.data); }struct key_type key_type_trusted = {
PATCH 161/204 KEYS: trusted: fix writing past end of buffer in trusted_read()
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit a3c812f7cfd80cf51e8f5b7034f7418f6beb56c1 upstream.
When calling keyctl_read() on a key of type "trusted", if the user-supplied buffer was too small, the kernel ignored the buffer length and just wrote past the end of the buffer, potentially corrupting userspace memory. Fix it by instead returning the size required, as per the documentation for keyctl_read().
We also don't even fill the buffer at all in this case, as this is slightly easier to implement than doing a short read, and either behavior appears to be permitted. It also makes it match the behavior of the "encrypted" key type.
--- security/keys/trusted.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
security/keys/trusted.c +12 -11
@@ -1061,20 +1061,21 @@ static long trusted_read(const struct ke p =rcu_dereference_key (key);if (!p)return -EINVAL ; -if (!buffer || buflen <=0 ) -return 2 * p->blob_len; - ascii_buf =kmalloc (2 * p->blob_len,GFP_KERNEL ); -if (!ascii_buf) -return -ENOMEM ; - bufp = ascii_buf; -for (i =0 ; i < p->blob_len; i++) - bufp =hex_byte_pack (bufp, p->blob[i]); -if ((copy_to_user (buffer, ascii_buf,2 * p->blob_len)) !=0 ) { +if (buffer && buflen >=2 * p->blob_len) { + ascii_buf =kmalloc (2 * p->blob_len,GFP_KERNEL ); +if (!ascii_buf) +return -ENOMEM ; + + bufp = ascii_buf; +for (i =0 ; i < p->blob_len; i++) + bufp =hex_byte_pack (bufp, p->blob[i]); +if (copy_to_user (buffer, ascii_buf,2 * p->blob_len) !=0 ) { +kzfree (ascii_buf); +return -EFAULT ; + }kzfree (ascii_buf); -return -EFAULT ; } -kzfree (ascii_buf);return 2 * p->blob_len; }
PATCH 162/204 KEYS: fix out-of-bounds read during ASN.1 parsing
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 2eb9eabf1e868fda15808954fb29b0f105ed65f1 upstream.
syzkaller with KASAN reported an out-of-bounds read in asn1_ber_decoder(). It can be reproduced by the following command, assuming CONFIG_X509_CERTIFICATE_PARSER=y and CONFIG_KASAN=y:
keyctl add asymmetric desc $'\x30\x30' @s
The bug is that the length of an ASN.1 data value isn't validated in the case where it is encoded using the short form, causing the decoder to read past the end of the input buffer. Fix it by validating the length.
The bug report was:
BUG: KASAN: slab-out-of-bounds in asn1_ber_decoder+0x10cb/0x1730 lib/asn1_decoder.c:233
Read of size 1 at addr ffff88003cccfa02 by task syz-executor0/6818
CPU: 1 PID: 6818 Comm: syz-executor0 Not tainted 4.14.0-rc7-00008-g5f479447d983 #2
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:16 [inline]
dump_stack+0xb3/0x10b lib/dump_stack.c:52
print_address_description+0x79/0x2a0 mm/kasan/report.c:252
kasan_report_error mm/kasan/report.c:351 [inline]
kasan_report+0x236/0x340 mm/kasan/report.c:409
__asan_report_load1_noabort+0x14/0x20 mm/kasan/report.c:427
asn1_ber_decoder+0x10cb/0x1730 lib/asn1_decoder.c:233
x509_cert_parse+0x1db/0x650 crypto/asymmetric_keys/x509_cert_parser.c:89
x509_key_preparse+0x64/0x7a0 crypto/asymmetric_keys/x509_public_key.c:174
asymmetric_key_preparse+0xcb/0x1a0 crypto/asymmetric_keys/asymmetric_type.c:388
key_create_or_update+0x347/0xb20 security/keys/key.c:855
SYSC_add_key security/keys/keyctl.c:122 [inline]
SyS_add_key+0x1cd/0x340 security/keys/keyctl.c:62
entry_SYSCALL_64_fastpath+0x1f/0xbe
RIP: 0033:0x447c89
RSP: 002b:00007fca7a5d3bd8 EFLAGS: 00000246 ORIG_RAX: 00000000000000f8
RAX: ffffffffffffffda RBX: 00007fca7a5d46cc RCX: 0000000000447c89
RDX: 0000000020006f4a RSI: 0000000020006000 RDI: 0000000020001ff5
RBP: 0000000000000046 R08: fffffffffffffffd R09: 0000000000000000
R10: 0000000000000002 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fca7a5d49c0 R15: 00007fca7a5d4700--- lib/asn1_decoder.c | 3 +++ 1 file changed, 3 insertions(+)
lib/asn1_decoder.c +3 -0
@@ -276,6 +276,9 @@ next_op:if (unlikely (len > datalen - dp)) goto data_overrun_error; } + }else { +if (unlikely (len > datalen - dp)) + goto data_overrun_error; }if (flags &FLAG_CONS ) {
PATCH 163/204 arm64: fix dump_instr when PAN and UAO are in use
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mark Rutland <[email protected]>
commit c5cea06be060f38e5400d796e61cfc8c36e52924 upstream.
If the kernel is set to show unhandled signals, and a user task does not handle a SIGILL as a result of an instruction abort, we will attempt to log the offending instruction with dump_instr before killing the task.
We use dump_instr to log the encoding of the offending userspace instruction. However, dump_instr is also used to dump instructions from kernel space, and internally always switches to KERNEL_DS before dumping the instruction with get_user. When both PAN and UAO are in use, reading a user instruction via get_user while in KERNEL_DS will result in a permission fault, which leads to an Oops.
As we have regs corresponding to the context of the original instruction abort, we can inspect this and only flip to KERNEL_DS if the original abort was taken from the kernel, avoiding this issue. At the same time, remove the redundant (and incorrect) comments regarding the order dump_mem and dump_instr are called in.
--- arch/arm64/kernel/traps.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
arch/arm64/kernel/traps.c +13 -13
@@ -59,8 +59,7 @@ static void dump_mem(const char *lvl, co/* * We need to switch to kernel mode so that we can use __get_user -* to safely read from kernel space. Note that we now dump the -* code first, just in case the backtrace kills us. +* to safely read from kernel space. */ fs =get_fs ();set_fs (KERNEL_DS );
@@ -97,21 +96,12 @@ static void dump_backtrace_entry(unsigne stack + sizeof(struct pt_regs)); } -static void dump_instr (const char *lvl,struct pt_regs *regs) +static void __dump_instr (const char *lvl,struct pt_regs *regs) {unsigned long addr =instruction_pointer (regs); -mm_segment_t fs;char str[sizeof ("00000000 " ) *5 +2 +1 ], *p = str;int i; -/* -* We need to switch to kernel mode so that we can use __get_user -* to safely read from kernel space. Note that we now dump the -* code first, just in case the backtrace kills us. -*/ - fs =get_fs (); -set_fs (KERNEL_DS ); -for (i =-4 ; i <1 ; i++) {unsigned int val, bad;
@@ -125,8 +115,18 @@ static void dump_instr(const char *lvl, } }printk ("%sCode: %s\n" , lvl, str); +} -set_fs (fs); +static void dump_instr (const char *lvl,struct pt_regs *regs) +{ +if (!user_mode (regs)) { +mm_segment_t fs =get_fs (); +set_fs (KERNEL_DS ); +__dump_instr (lvl, regs); +set_fs (fs); + }else { +__dump_instr (lvl, regs); + } }static void dump_backtrace (struct pt_regs *regs,struct task_struct *tsk)
PATCH 164/204 arm64: ensure __dump_instr() checks addr_limit
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mark Rutland <[email protected]>
commit 7a7003b1da010d2b0d1dc8bf21c10f5c73b389f1 upstream.
It's possible for a user to deliberately trigger __dump_instr with a chosen kernel address.
Let's avoid problems resulting from this by using get_user() rather than __get_user(), ensuring that we don't erroneously access kernel memory.
Where we use __dump_instr() on kernel text, we already switch to KERNEL_DS, so this shouldn't adversely affect those cases.
--- arch/arm64/kernel/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kernel/traps.c +1 -1
@@ -105,7 +105,7 @@ static void __dump_instr(const char *lvlfor (i =-4 ; i <1 ; i++) {unsigned int val, bad; - bad =__get_user (val, &((u32 *)addr)[i]); + bad =get_user (val, &((u32 *)addr)[i]);if (!bad) p +=sprintf (p, i ==0 ?"(%08x) " :"%08x " , val);
PATCH 165/204 ocfs2: fstrim: Fix start offset of first cluster group during fstrim
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ashish Samant <[email protected]>
commit 105ddc93f06ebe3e553f58563d11ed63dbcd59f0 upstream.
The first cluster group descriptor is not stored at the start of the group but at an offset from the start. We need to take this into account while doing fstrim on the first cluster group. Otherwise we will wrongly start fstrim a few blocks after the desired start block and the range can cross over into the next cluster group and zero out the group descriptor there. This can cause filesytem corruption that cannot be fixed by fsck.
--- fs/ocfs2/alloc.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
fs/ocfs2/alloc.c +18 -6
@@ -7226,13 +7226,24 @@ out:static int ocfs2_trim_extent (struct super_block *sb,struct ocfs2_group_desc *gd, -u32 start,u32 count) +u64 group,u32 start,u32 count) {u64 discard, bcount; +struct ocfs2_super *osb =OCFS2_SB (sb); bcount =ocfs2_clusters_to_blocks (sb, count); - discard =le64_to_cpu (gd->bg_blkno) + -ocfs2_clusters_to_blocks (sb, start); + discard =ocfs2_clusters_to_blocks (sb, start); + +/* +* For the first cluster group, the gd->bg_blkno is not at the start +* of the group, but at an offset from the start. If we add it while +* calculating discard for first group, we will wrongly start fstrim a +* few blocks after the desried start block and the range can cross +* over into the next cluster group. So, add it only if this is not +* the first cluster group. +*/ +if (group != osb->first_cluster_group_blkno) + discard +=le64_to_cpu (gd->bg_blkno);trace_ocfs2_trim_extent (sb, (unsigned long long )discard, bcount);
@@ -7240,7 +7251,7 @@ static int ocfs2_trim_extent(struct supe }static int ocfs2_trim_group (struct super_block *sb, -struct ocfs2_group_desc *gd, +struct ocfs2_group_desc *gd,u64 group,u32 start,u32 max,u32 minbits) {int ret =0 , count =0 , next;
@@ -7259,7 +7270,7 @@ static int ocfs2_trim_group(struct super next =ocfs2_find_next_bit (bitmap, max, start);if ((next - start) >= minbits) { - ret =ocfs2_trim_extent (sb, gd, + ret =ocfs2_trim_extent (sb, gd, group, start, next - start);if (ret <0 ) {mlog_errno (ret);
@@ -7357,7 +7368,8 @@ int ocfs2_trim_fs(struct super_block *sb } gd = (struct ocfs2_group_desc *)gd_bh->b_data; - cnt =ocfs2_trim_group (sb, gd, first_bit, last_bit, minlen); + cnt =ocfs2_trim_group (sb, gd, group, + first_bit, last_bit, minlen);brelse (gd_bh); gd_bh =NULL ;if (cnt <0 ) {
PATCH 166/204 netfilter/ipvs: clear ipvs_property flag when SKB net namespace changed
In reply to Ben Hutchings3.16.52-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ye Yin <[email protected]>
commit 2b5ec1a5f9738ee7bf8f5ec0526e75e00362c48f upstream.
When run ipvs in two different network namespace at the same host, and one ipvs transport network traffic to the other network namespace ipvs. 'ipvs_property' flag will make the second ipvs take no effect. So we should clear 'ipvs_property' when SKB network namespace changed.
--- include/linux/skbuff.h | 7 +++++++ net/core/skbuff.c | 1 + 2 files changed, 8 insertions(+)
include/linux/skbuff.h +7 -0
@@ -2965,6 +2965,13 @@ static inline void nf_reset_trace(struct#endif } +static inline void ipvs_reset (struct sk_buff *skb) +{ +#if IS_ENABLED (CONFIG_IP_VS ) + skb->ipvs_property =0 ; +#endif +} +/* Note: This doesn't put any conntrack and bridge info in dst. */ static inline void __nf_copy (struct sk_buff *dst,const struct sk_buff *src) {
net/core/skbuff.c +1 -0
@@ -3961,6 +3961,7 @@ void skb_scrub_packet(struct sk_buff *skif (!xnet)return ; +ipvs_reset (skb);skb_orphan (skb); skb->mark =0 ; }