3.12.24-stable review
Subsystems (5)
cover 3.12.24-stable review
This is the start of the stable review cycle for the 3.12.24 release. There are 181 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed Jul 2 11:49:58 2014 Anything received after that time might be too late.
The whole patch series can be found in one patch at:
http://kernel.org/pub/linux/kernel/people/jirislaby/stable-review/patch-3.12.24-rc1.xz
and the diffstat can be found below.
thanks,
js
===============
Aaron Lu (1):
ACPI / video: clean up DMI table for initial black screen problem
Alan Stern (2):
USB: usbtest: add a timeout for scatter-gather tests
USB: EHCI: avoid BIOS handover on the HASEE E200
Aleksander Morgado (2):
usb: qcserial: add Netgear AirCard 341U
usb: qcserial: add additional Sierra Wireless QMI devices
Anatol Pomozov (1):
aio: block io_destroy() until all context requests are completed
Andrzej Zaborowski (1):
efi-pstore: Fix an overflow on 32-bit builds
Andy Lutomirski (1):
x86_32, entry: Do syscall exit work on badsys (CVE-2014-4508)
Anssi Hannula (1):
ALSA: hda - hdmi: Use TFx channel positions instead of FxH
Anton Blanchard (1):
KVM: PPC: Book3S HV: Fix KVM hang with CONFIG_KVM_XICS=n
Ben Hutchings (1):
net/compat: Fix minor information leak in siocdevprivate_ioctl()
Benjamin LaHaise (3):
aio: fix kernel memory disclosure in io_getevents() introduced in
v3.10
aio: fix aio request leak when events are reaped by userspace
aio: fix kernel memory disclosure in io_getevents() introduced in
v3.10Benjamin Poirier (1):
net: Do not enable tx-nocache-copy by default
Bjørn Mork (3):
usb: qcserial: fix multiline comment coding style
usb: qcserial: refactor device layout selection
usb: qcserial: define and use Sierra Wireless layout
Chen Gang (1):
arch/unicore32/mm/alignment.c: include "asm/pgtable.h" to avoid
compiling error
Chris Mason (1):
Btrfs: fix double free in find_lock_delalloc_range
Christian Borntraeger (1):
s390/lowcore: reserve 96 bytes for IRB in lowcore
Dan Carpenter (3):
iio: adc: at91: signedness bug in at91_adc_get_trigger_value_by_name()
Staging: rtl8188eu: overflow in update_sta_support_rate()
applicom: dereferencing NULL on error path
Dave Chinner (3):
xfs: prevent deadlock trying to cover an active log
xfs: prevent stack overflows from page cache allocation
xfs: xfs_remove deadlocks due to inverted AGF vs AGI lock ordering
David Binderman (1):
ACPICA: utstring: Check array index bound before use.
David Henningsson (1):
ALSA: hda - Add quirk for external mic on Lifebook U904
Eric Sandeen (3):
xfs: don't emit corruption noise on fs probes
xfs: don't break from growfs ag update loop on error
btrfs: fix use of uninit "ret" in end_extent_writepage()
Ezequiel Garcia (1):
media: stk1160: Avoid stack-allocated buffer for control URBs
Fathi Boudra (1):
builddeb: use $OBJCOPY variable instead of objcopy
Felipe Balbi (2):
usb: dwc3: gadget: clear stall when disabling endpoint
bluetooth: hci_ldisc: fix deadlock condition
Filipe David Borba Manana (3):
Btrfs: fix tracking of orphan inode count
Btrfs: fix sync fs to actually wait for all data to be persisted
Btrfs: don't leak block group on error
Filipe Manana (1):
Btrfs: send, don't error in the presence of subvols/snapshots
Geyslan G. Bem (1):
xfs: fix possible NULL dereference in xlog_verify_iclog
Goldwyn Rodrigues (1):
ocfs2: revert iput deferring code in ocfs2_drop_dentry_lock
Greg Kroah-Hartman (3):
lzo: properly check for overruns
lz4: ensure length does not wrap
lz4: fix another possible overrun
Guenter Roeck (1):
mfd: sm501: dbg_regs attribute must be read-only
H. Peter Anvin (1):
x86-32, espfix: Remove filter for espfix32 due to race
Huang Rui (1):
usb: usbtest: fix unlink write error with pattern 1
Hugh Dickins (1):
mm: fix sleeping function warning from __put_anon_vma
J. Bruce Fields (2):
GFS2: revert "GFS2: d_splice_alias() can't return error"
nfsd4: fix FREE_STATEID lockowner leak
James Hogan (2):
serial: 8250_dw: Fix LCR workaround regression
MIPS: KVM: Allocate at least 16KB for exception handlers
Jan Kara (5):
ocfs2: move dquot_initialize() in ocfs2_delete_inode() somewhat later
quota: provide function to grab quota structure reference
ocfs2: implement delayed dropping of last dquot reference
ocfs2: avoid blocking in ocfs2_mark_lockres_freeing() in downconvert
thread
ext4: fix zeroing of page during writeback
Jeff Layton (2):
nfsd: don't try to reuse an expired DRC entry off the list
nfsd: don't halt scanning the DRC LRU list when there's an RC_INPROG
entry
Jiang Liu (1):
intel_idle: close avn_cstates array with correct marker
Jianguo Wu (1):
ARM: 8037/1: mm: support big-endian page tables
Jie Liu (3):
xfs: fix the wrong new_size/rnew_size at xfs_iext_realloc_direct()
xfs: fix the extent count when allocating an new indirection array
entry
xfs: don't perform discard if the given range length is less than
block size
Jiri Slaby (1):
Revert "bio-integrity: Fix bio_integrity_verify segment start bug"
Johan Hedberg (2):
Bluetooth: Fix redundant encryption request for reauthentication
Bluetooth: Fix check for connection encryption
Johan Hovold (20):
USB: cdc-acm: fix write and suspend race
USB: cdc-acm: fix write and resume race
USB: cdc-acm: fix broken runtime suspend
USB: cdc-acm: fix runtime PM for control messages
USB: cdc-acm: fix shutdown and suspend race
USB: cdc-acm: fix potential urb leak and PM imbalance in write
USB: cdc-acm: fix I/O after failed open
USB: cdc-acm: fix runtime PM imbalance at shutdown
net: cpsw: fix null dereference at probe
USB: option: fix runtime PM handling
USB: usb_wwan: fix write and suspend race
USB: usb_wwan: fix urb leak at shutdown
USB: usb_wwan: fix potential NULL-deref at resume
USB: usb_wwan: fix potential blocked I/O after resume
USB: sierra: fix AA deadlock in open error path
USB: sierra: fix use after free at suspend/resume
USB: sierra: fix urb and memory leak in resume error path
USB: sierra: fix urb and memory leak on disconnect
USB: sierra: fix remote wakeup
USB: serial: fix potential runtime pm imbalance at device remove
Johannes Weiner (1):
mm: vmscan: clear kswapd's special reclaim powers before exiting
Josef Bacik (4):
Btrfs: do not release metadata for space cache inodes
Btrfs: cleanup transaction on abort
Btrfs: don't delete ordered roots from list during cleanup
Btrfs: fix two use-after-free bugs with transaction cleanup
Jukka Taimisto (1):
Bluetooth: Fix L2CAP deadlock
K. Y. Srinivasan (1):
Drivers: hv: balloon: Ensure pressure reports are posted regularly
Kailang Yang (1):
ALSA: hda/realtek - Add support of ALC891 codec
Kees Cook (1):
HID: core: fix validation of report id 0
Konstantin Khlebnikov (1):
epoll: fix use-after-free in eventpoll_release_file
Krzysztof Kozlowski (2):
extcon: max8997: Fix NULL pointer exception on missing pdata
extcon: max77693: Fix two NULL pointer exceptions on missing pdata
Lai Jiangshan (1):
idr: fix overflow bug during maximum ID calculation at maximum height
Lars-Peter Clausen (5):
ALSA: control: Protect user controls against concurrent access
ALSA: control: Fix replacing user controls
ALSA: control: Don't access controls outside of protected regions
ALSA: control: Handle numid overflow
ALSA: control: Make sure that id->index does not overflow
Li Zhong (1):
powerpc: Fix Oops in rtas_stop_self()
Liam Girdwood (1):
ASoC: max98090: Fix reset at resume time
Lidong Zhong (1):
dlm: keep listening connection alive with sctp mode
Liu Bo (4):
Btrfs: fix NULL pointer crash of deleting a seed device
Btrfs: mark mapping with error flag to report errors to userspace
Btrfs: use right type to get real comparison
Btrfs: fix scrub_print_warning to handle skinny metadata extents
Lv Zheng (1):
ACPI: Fix conflict between customized DSDT and DSDT local copy
Mario Schuknecht (1):
staging: iio: tsl2x7x_core: fix proximity treshold
Mathias Krause (1):
netfilter: ipt_ULOG: fix info leaks
Matthew Dempsky (1):
ptrace: fix fork event messages across pid namespaces
Maurizio Lombardi (1):
ext4: fix wrong assert in ext4_mb_normalize_request()
Mel Gorman (2):
mm: vmscan: do not throttle based on pfmemalloc reserves if node has
no ZONE_NORMAL
mm: page_alloc: use word-based accesses for get/set pageblock bitmaps
Miao Xie (2):
Btrfs: fix BUG_ON() casued by the reserved space migration
Btrfs: output warning instead of error when loading free space cache
failed
Michal Kubecek (1):
xfrm: fix race between netns cleanup and state expire notification
Michal Kubeček (1):
vlan: more careful checksum features handling
Mike Frysinger (1):
x86, x32: Use compat shims for io_{setup,submit}
Mike Qiu (1):
powerpc/mm: fix ".__node_distance" undefined
Mikulas Patocka (1):
matroxfb: perform a dummy read of M_STATUS
Namjae Jeon (1):
ext4: fix data integrity sync in ordered mode
Naoya Horiguchi (3):
mm: add !pte_present() check on existing hugetlb_entry callbacks
hugetlb: restrict hugepage_migration_support() to x86_64 mm/memory-failure.c: support use of a dedicated thread to handle
SIGBUS(BUS_MCEERR_AO)
Nicholas A. Bellinger (1):
target: Explicitly clear ramdisk_mcp backend pages
Nicholas Bellinger (3):
target: Set CMD_T_ACTIVE bit for Task Management Requests
target: Use complete_all for se_cmd->t_transport_stop_comp
iscsi-target: Fix ABORT_TASK + connection reset iscsi_queue_req memory
leak
Olivier Langlois (1):
media: uvcvideo: Fix clock param realtime setting
Paolo Bonzini (1):
KVM: lapic: sync highest ISR to hardware apic on EOI
Paul Bolle (3):
staging: tidspbridge: check for CONFIG_SND_OMAP_SOC_MCBSP
usb: gadget: rename CONFIG_USB_GADGET_PXA25X
ARM: OMAP: replace checks for CONFIG_USB_GADGET_OMAP
Pavel Shilovsky (1):
CIFS: Fix memory leaks in SMB2_open
Peter Meerwald (1):
iio: Fix endianness issue in ak8975_read_axis()
Peter Ujfalusi (1):
ASoC: tlv320aci3x: Fix custom snd_soc_dapm_put_volsw_aic3x() function
Peter Zijlstra (1):
sched: Make scale_rt_power() deal with backward clocks
Petr Mladek (1):
ftrace/x86: Call text_ip_addr() instead of the duplicated code
Prarit Bhargava (1):
ACPI / memhotplug: add parameter to disable memory hotplug
Qu Wenruo (1):
btrfs: Add ctime/mtime update for btrfs device add/remove.
Quentin Casasnovas (1):
drm/radeon: memory leak on bo reservation failure. v2
Rickard Strandqvist (1):
fs: btrfs: volumes.c: Fix for possible null pointer dereference
Roger Quadros (1):
usb: usbtest: Add timetout to simple_io()
Roland Dreier (1):
target: Report correct response length for some commands
Russell King (1):
ARM: stacktrace: avoid listing stacktrace functions in stacktrace
Sachin Prabhu (1):
cifs: Set client guid on per connection basis
Sagi Grimberg (5):
Target/iser: Bail from accept_np if np_thread is trying to close Target/iser: Fix hangs in connection teardown Target/iser: Improve cm events handling
Target/iser: Wait for proper cleanup before unloading Target/iscsi: Fix sendtargets response pdu for iser transport
Stephane Grosjean (1):
can: peak_pci: prevent use after free at netdev removal
Steve French (2):
Check SMB3 dialects against downgrade attacks
Do not send ClientGUID on SMB2.02 dialect
Takashi Iwai (1):
media: ivtv: Fix Oops when no firmware is loaded
Thomas Gleixner (1):
genirq: Sanitize spurious interrupt detection of threaded irqs
Tim Kryger (1):
serial: 8250_dw: Improve unwritable LCR workaround
Tom Gundersen (1):
module: allow multiple calls to MODULE_DEVICE_TABLE() per module
Tomas Winkler (2):
mei: me: read H_CSR after asserting reset
mei: me: fix hw ready reset flow
Tony Luck (2):
mm/memory-failure.c-failure: send right signal code to correct thread mm/memory-failure.c: don't let collect_procs() skip over processes for
MF_ACTION_REQUIRED
Ursula Braun (1):
af_iucv: wrong mapping of sent and confirmed skbs
Vincent Guittot (1):
Revert "sched: Fix sleep time double accounting in enqueue entity"
Viresh Kumar (1):
tick-sched: Check tick_nohz_enabled in tick_nohz_switch_to_nohz()
Wang Shilong (2):
Btrfs: make sure there are not any read requests before stopping
workers
Btrfs: set right total device count for seeding support
Wang, Xiaoming (1):
ALSA: compress: Cancel the optimization of compiler and fix the size
of struct for all platform.
Wendy Xiong (1):
[SCSI] ipr: Add new CCIN definition for Grand Canyon support
Will Deacon (1):
arm64: ptrace: change fs when passing kernel pointer to regset code
Ying Xue (1):
tipc: fix memory leak of publications
Zhichuang SUN (1):
drivers/video/fbdev/fb-puv3.c: Add header files for function
unifb_mmap
xiao jin (2):
USB: usb_wwan: fix urb leak in write error path
USB: usb_wwan: fix race between write and resume
Documentation/kernel-parameters.txt | 3 + Documentation/vm/hwpoison.txt | 5 + arch/arm/kernel/stacktrace.c | 18 +++- arch/arm/mach-omap1/board-h2.c | 2 +- arch/arm/mach-omap1/board-h3.c | 2 +- arch/arm/mach-omap1/board-innovator.c | 2 +- arch/arm/mach-omap1/board-osk.c | 2 +- arch/arm/mm/hugetlbpage.c | 5 - arch/arm/mm/proc-v7-3level.S | 18 +++- arch/arm64/kernel/ptrace.c | 4 + arch/arm64/mm/hugetlbpage.c | 5 - arch/ia64/mm/hugetlbpage.c | 5 - arch/metag/mm/hugetlbpage.c | 5 - arch/mips/kvm/kvm_mips.c | 2 +- arch/mips/mm/hugetlbpage.c | 5 - arch/powerpc/kvm/book3s_hv.c | 4 +- arch/powerpc/mm/hugetlbpage.c | 10 -- arch/powerpc/mm/numa.c | 1 + arch/powerpc/platforms/pseries/hotplug-cpu.c | 5 +- arch/s390/include/asm/lowcore.h | 11 +- arch/s390/mm/hugetlbpage.c | 5 - arch/sh/mm/hugetlbpage.c | 5 - arch/sparc/mm/hugetlbpage.c | 5 - arch/tile/mm/hugetlbpage.c | 5 - arch/unicore32/mm/alignment.c | 1 + arch/x86/Kconfig | 4 + arch/x86/kernel/entry_32.S | 15 +-- arch/x86/kernel/ftrace.c | 11 +- arch/x86/kvm/lapic.c | 62 +++++++---- arch/x86/mm/hugetlbpage.c | 10 -- arch/x86/syscalls/syscall_64.tbl | 6 +- drivers/acpi/acpi_memhotplug.c | 12 +++ drivers/acpi/acpica/utstring.c | 2 +- drivers/acpi/bus.c | 7 ++ drivers/acpi/video.c | 87 +++------------- drivers/bluetooth/hci_ldisc.c | 24 ++++- drivers/bluetooth/hci_uart.h | 1 + drivers/char/applicom.c | 1 - drivers/extcon/extcon-max77693.c | 4 +- drivers/extcon/extcon-max8997.c | 2 +- drivers/firmware/efi/efi-pstore.c | 2 +- drivers/gpu/drm/radeon/radeon_kms.c | 5 +- drivers/hid/hid-core.c | 12 ++- drivers/hv/hv_balloon.c | 29 +++++- drivers/idle/intel_idle.c | 4 +- drivers/iio/adc/at91_adc.c | 16 +-- drivers/iio/magnetometer/ak8975.c | 9 +- drivers/infiniband/ulp/isert/ib_isert.c | 61 ++++++----- drivers/infiniband/ulp/isert/ib_isert.h | 2 +- drivers/media/pci/ivtv/ivtv-alsa-pcm.c | 6 ++ drivers/media/usb/stk1160/stk1160-core.c | 10 +- drivers/media/usb/stk1160/stk1160.h | 1 - drivers/media/usb/uvc/uvc_video.c | 15 ++- drivers/mfd/sm501.c | 2 +- drivers/misc/mei/hw-me.c | 28 +++-- drivers/net/can/sja1000/peak_pci.c | 14 ++- drivers/net/ethernet/ti/cpsw.c | 4 + drivers/scsi/ipr.c | 6 ++ drivers/scsi/ipr.h | 3 + drivers/staging/iio/light/tsl2x7x_core.c | 8 +- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 7 +- drivers/staging/tidspbridge/core/dsp-clock.c | 4 +- drivers/target/iscsi/iscsi_target.c | 17 ++-- drivers/target/target_core_rd.c | 2 +- drivers/target/target_core_sbc.c | 4 +- drivers/target/target_core_spc.c | 9 +- drivers/target/target_core_transport.c | 29 +++++- drivers/tty/serial/8250/8250_dw.c | 43 ++++++-- drivers/usb/class/cdc-acm.c | 104 +++++++++++-------- drivers/usb/class/cdc-acm.h | 2 +- drivers/usb/dwc3/gadget.c | 4 + drivers/usb/gadget/inode.c | 2 +- drivers/usb/host/pci-quirks.c | 19 +++- drivers/usb/misc/usbtest.c | 40 +++++++- drivers/usb/phy/phy-isp1301-omap.c | 2 +- drivers/usb/serial/bus.c | 14 ++- drivers/usb/serial/option.c | 11 +- drivers/usb/serial/qcserial.c | 136 +++++++++++++++---------- drivers/usb/serial/sierra.c | 55 +++++++--- drivers/usb/serial/usb_wwan.c | 125 ++++++++++++----------- drivers/video/fb-puv3.c | 2 + drivers/video/matrox/matroxfb_base.h | 2 +- fs/aio.c | 45 ++++++-- fs/bio-integrity.c | 2 +- fs/btrfs/backref.c | 32 +++--- fs/btrfs/backref.h | 4 +- fs/btrfs/disk-io.c | 122 +++++++++------------- fs/btrfs/extent-tree.c | 3 +- fs/btrfs/extent_io.c | 5 +- fs/btrfs/free-space-cache.c | 4 +- fs/btrfs/inode.c | 21 ++-- fs/btrfs/ioctl.c | 12 ++- fs/btrfs/relocation.c | 6 +- fs/btrfs/scrub.c | 5 +- fs/btrfs/send.c | 4 + fs/btrfs/transaction.c | 50 ++++++--- fs/btrfs/transaction.h | 2 + fs/btrfs/volumes.c | 44 ++++++-- fs/cifs/cifsfs.c | 8 -- fs/cifs/cifsglob.h | 2 + fs/cifs/connect.c | 3 + fs/cifs/smb2ops.c | 1 + fs/cifs/smb2pdu.c | 92 ++++++++++++++++- fs/cifs/smb2pdu.h | 14 ++- fs/cifs/smb2proto.h | 1 + fs/cifs/smbfsctl.h | 2 +- fs/dlm/lowcomms.c | 5 + fs/eventpoll.c | 4 +- fs/ext4/ext4.h | 3 +- fs/ext4/inode.c | 6 +- fs/ext4/mballoc.c | 2 +- fs/ext4/page-io.c | 32 +++--- fs/gfs2/inode.c | 8 ++ fs/nfsd/nfs4state.c | 2 +- fs/nfsd/nfscache.c | 53 +++------- fs/ocfs2/dcache.c | 61 +---------- fs/ocfs2/dcache.h | 12 +-- fs/ocfs2/dlmglue.c | 44 +++++++- fs/ocfs2/dlmglue.h | 3 +- fs/ocfs2/inode.c | 23 +++-- fs/ocfs2/ocfs2.h | 31 ++---- fs/ocfs2/quota.h | 2 + fs/ocfs2/quota_global.c | 35 +++++++ fs/ocfs2/super.c | 36 ++----- fs/proc/task_mmu.c | 2 +- fs/quota/dquot.c | 4 +- fs/xfs/xfs_aops.c | 3 +- fs/xfs/xfs_discard.c | 5 +- fs/xfs/xfs_fsops.c | 22 ++-- fs/xfs/xfs_inode.c | 72 ++++++++----- fs/xfs/xfs_inode_fork.c | 18 ++-- fs/xfs/xfs_iops.c | 9 ++ fs/xfs/xfs_log.c | 56 +++++----- fs/xfs/xfs_log_cil.c | 14 +++ fs/xfs/xfs_log_priv.h | 10 +- fs/xfs/xfs_sb.c | 5 +- include/linux/hugetlb.h | 13 +-- include/linux/irqdesc.h | 4 + include/linux/mempolicy.h | 6 ++ include/linux/mmzone.h | 6 +- include/linux/module.h | 2 +- include/linux/netdevice.h | 14 +++ include/linux/page-flags.h | 12 ++- include/linux/pageblock-flags.h | 37 +++++-- include/linux/ptrace.h | 32 ++++++ include/linux/quotaops.h | 8 ++ include/sound/core.h | 2 + include/target/iscsi/iscsi_transport.h | 3 +- include/target/target_core_backend.h | 1 + include/uapi/sound/compress_offload.h | 2 +- kernel/fork.c | 10 +- kernel/irq/manage.c | 4 +- kernel/irq/spurious.c | 106 ++++++++++++++++++- kernel/sched/fair.c | 15 ++- kernel/time/tick-sched.c | 2 +- lib/idr.c | 8 +- lib/lz4/lz4_decompress.c | 6 +- lib/lzo/lzo1x_decompress_safe.c | 62 +++++++---- mm/Kconfig | 3 + mm/memory-failure.c | 73 +++++++++---- mm/mempolicy.c | 6 +- mm/page-writeback.c | 11 +- mm/page_alloc.c | 52 ++++++---- mm/rmap.c | 8 +- mm/vmscan.c | 46 +++++++-- net/8021q/vlan_dev.c | 4 +- net/bluetooth/hci_conn.c | 11 +- net/bluetooth/l2cap_sock.c | 5 +- net/core/dev.c | 5 - net/ipv4/netfilter/ipt_ULOG.c | 7 +- net/iucv/af_iucv.c | 2 +- net/socket.c | 7 +- net/tipc/name_table.c | 2 +- net/xfrm/xfrm_user.c | 36 +++++-- scripts/mod/file2alias.c | 14 ++- scripts/package/builddeb | 6 +- sound/core/control.c | 78 +++++++++----- sound/core/init.c | 1 + sound/pci/hda/patch_hdmi.c | 6 +- sound/pci/hda/patch_realtek.c | 10 ++ sound/soc/codecs/max98090.c | 3 + sound/soc/codecs/tlv320aic3x.c | 2 +- 182 files changed, 1946 insertions(+), 1126 deletions(-)
Signature · 1 line
2.0.0
PATCH 1/181 Revert "sched: Fix sleep time double accounting in enqueue entity"
From: Vincent Guittot <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 9390675af0835ae1d654d33bfcf16096028550ad upstream.
This reverts commit 282cf499f03ec1754b6c8c945c9674b02631fb0f.
With the current implementation, the load average statistics of a sched entity change according to other activity on the CPU even if this activity is done between the running window of the sched entity and have no influence on the running duration of the task.
When a task wakes up on the same CPU, we currently update last_runnable_update with the return of __synchronize_entity_decay without updating the runnable_avg_sum and runnable_avg_period accordingly. In fact, we have to sync the load_contrib of the se with the rq's blocked_load_contrib before removing it from the latter (with __synchronize_entity_decay) but we must keep last_runnable_update unchanged for updating runnable_avg_sum/period during the next update_entity_load_avg.
--- kernel/sched/fair.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
kernel/sched/fair.c +1 -7
@@ -1579,13 +1579,7 @@ static inline void enqueue_entity_load_avg(struct cfs_rq *cfs_rq, } wakeup =0 ; }else { -/* -* Task re-woke on same cpu (or else migrate_task_rq_fair() -* would have made count negative); we must be careful to avoid -* double-accounting blocked time after synchronizing decays. -*/ - se->avg.last_runnable_update +=__synchronize_entity_decay (se) - <<20 ; +__synchronize_entity_decay (se); }/* migrated tasks did not contribute to our blocked load */
Signature · 1 line
2.0.0
PATCH 2/181 Revert "bio-integrity: Fix bio_integrity_verify segment start bug"
3.12-stable review patch. If anyone has any objections, please let me know.
===============
This reverts commit 7cbcb219e4113e10ce4b036118992abdbc4a8273, misapplied upstream commit 5837c80e870bc3b12ac6a98cdc9ce7a9522a8fb6.
The upstream commit was applied twice to stable-3.12, the second time to bio_integrity_generate. Revert this second application.
--- fs/bio-integrity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/bio-integrity.c +1 -1
@@ -316,7 +316,7 @@ static void bio_integrity_generate(struct bio *bio) bix.disk_name = bio->bi_bdev->bd_disk->disk_name; bix.sector_size = bi->sector_size; -bio_for_each_segment_all (bv, bio, i) { +bio_for_each_segment (bv, bio, i) {void *kaddr =kmap_atomic (bv->bv_page); bix.data_buf = kaddr + bv->bv_offset; bix.data_size = bv->bv_len;
Signature · 1 line
2.0.0
PATCH 3/181 GFS2: revert "GFS2: d_splice_alias() can't return error"
In reply to Jiri SlabyFrom: "J. Bruce Fields" <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit d57b9c9a999a8f4475fe73fba629c964245800ca upstream.
0d0d110720d7960b77c03c9f2597faaff4b484ae asserts that "d_splice_alias() can't return error unless it was given an IS_ERR(inode)".
That was true of the implementation of d_splice_alias, but this is really a problem with d_splice_alias: at a minimum it should be able to return -ELOOP in the case where inserting the given dentry would cause a directory loop.
--- fs/gfs2/inode.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/gfs2/inode.c +8 -0
@@ -583,6 +583,9 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, error =PTR_ERR (inode);if (!IS_ERR (inode)) { d =d_splice_alias (inode, dentry); + error =PTR_ERR (d); +if (IS_ERR (d)) + goto fail_gunlock; error =0 ;if (file) {if (S_ISREG (inode->i_mode)) {
@@ -777,6 +780,11 @@ static struct dentry *__gfs2_lookup(struct inode *dir, struct dentry *dentry, } d =d_splice_alias (inode, dentry); +if (IS_ERR (d)) { +iput (inode); +gfs2_glock_dq_uninit (&gh); +return d; + }if (file &&S_ISREG (inode->i_mode)) error =finish_open (file, dentry, gfs2_open_common, opened);
Signature · 1 line
2.0.0
PATCH 4/181 powerpc: Fix Oops in rtas_stop_self()
In reply to Jiri SlabyFrom: Li Zhong <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 4fb8d027dca0236c811272d342cf185569d91311 upstream.
commit 41dd03a9 may cause Oops in rtas_stop_self().
The reason is that the rtas_args was moved into stack space. For a box with more that 4GB RAM, the stack could easily be outside 32bit range, but RTAS is 32bit.
So the patch moves rtas_args away from stack by adding static before it.
--- arch/powerpc/platforms/pseries/hotplug-cpu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/powerpc/platforms/pseries/hotplug-cpu.c +3 -2
@@ -88,13 +88,14 @@ void set_default_offline_state(int cpu)static void rtas_stop_self (void ) { -struct rtas_args args = { - .token =cpu_to_be32 (rtas_stop_self_token), +static struct rtas_args args = { .nargs =0 , .nret =1 , .rets = &args.args[0 ], }; + args.token =cpu_to_be32 (rtas_stop_self_token); +local_irq_disable ();BUG_ON (rtas_stop_self_token ==RTAS_UNKNOWN_SERVICE );
Signature · 1 line
2.0.0
PATCH 5/181 epoll: fix use-after-free in eventpoll_release_file
In reply to Jiri SlabyFrom: Konstantin Khlebnikov <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit ebe06187bf2aec10d537ce4595e416035367d703 upstream.
This fixes use-after-free of epi->fllink.next inside list loop macro. This loop actually releases elements in the body. The list is rcu-protected but here we cannot hold rcu_read_lock because we need to lock mutex inside.
The obvious solution is to use list_for_each_entry_safe(). RCU-ness isn't essential because nobody can change this list under us, it's final fput for this file.
The bug was introduced by ae10b2b4eb01 ("epoll: optimize EPOLL_CTL_DEL using rcu")
--- fs/eventpoll.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/eventpoll.c +2 -2
@@ -910,7 +910,7 @@ static const struct file_operations eventpoll_fops = {void eventpoll_release_file (struct file *file) {struct eventpoll *ep; -struct epitem *epi; +struct epitem *epi, *next;/* * We don't want to get "file->f_lock" because it is not
@@ -926,7 +926,7 @@ void eventpoll_release_file(struct file *file)* Besides, ep_remove() acquires the lock, so we can't hold it here. */ mutex_lock (&epmutex); -list_for_each_entry_rcu (epi, &file->f_ep_links, fllink) { +list_for_each_entry_safe (epi, next, &file->f_ep_links, fllink) { ep = epi->ep;mutex_lock_nested (&ep->mtx,0 );ep_remove (ep, epi);
Signature · 1 line
2.0.0
PATCH 6/181 tick-sched: Check tick_nohz_enabled in tick_nohz_switch_to_nohz()
In reply to Jiri SlabyFrom: Viresh Kumar <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 27630532ef5ead28b98cfe28d8f95222ef91c2b7 upstream.
Since commit d689fe222 (NOHZ: Check for nohz active instead of nohz enabled) the tick_nohz_switch_to_nohz() function returns because it checks for the tick_nohz_active flag. This can't be set, because the function itself sets it.
Undo the change in tick_nohz_switch_to_nohz().
--- kernel/time/tick-sched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/tick-sched.c +1 -1
@@ -970,7 +970,7 @@ static void tick_nohz_switch_to_nohz(void)struct tick_sched *ts = &__get_cpu_var (tick_cpu_sched);ktime_t next; -if (!tick_nohz_active) +if (!tick_nohz_enabled)return ;local_irq_disable ();
Signature · 1 line
2.0.0
PATCH 7/181 intel_idle: close avn_cstates array with correct marker
In reply to Jiri SlabyFrom: Jiang Liu <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 88390996c95b879ba365888199b45ace3f5ca80b upstream.
Close avn_cstates array with correct marker to avoid overflow in function intel_idle_cpu_init().
[rjw: The problem was introduced when commit 22e580d07f65 was merged
on top of eba682a5aeb6 (intel_idle: shrink states tables).]
--- drivers/idle/intel_idle.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/idle/intel_idle.c +3 -1
@@ -329,7 +329,7 @@ static struct cpuidle_state atom_cstates[CPUIDLE_STATE_MAX] = { { .enter = NULL } }; -static struct cpuidle_state avn_cstates[]__initdata = { +static struct cpuidle_state avn_cstates[] = { { .name ="C1-AVN" , .desc ="MWAIT 0x00" ,
@@ -344,6 +344,8 @@ static struct cpuidle_state avn_cstates[] __initdata = { .exit_latency = 15, .target_residency = 45, .enter = &intel_idle }, + { + .enter = NULL } };/**
Signature · 1 line
2.0.0
PATCH 8/181 tipc: fix memory leak of publications
In reply to Jiri SlabyFrom: Ying Xue <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 1621b94d2a655c8548ddbdfc8ccf907a5bbdc860 upstream.
Commit 1bb8dce57f4d15233688c68990852a10eb1cd79f ("tipc: fix memory leak during module removal") introduced a memory leak issue: when name table is stopped, it's forgotten that publication instances are freed properly. Additionally the useless "continue" statement in tipc_nametbl_stop() is removed as well.
--- net/tipc/name_table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/tipc/name_table.c +1 -1
@@ -962,6 +962,7 @@ static void tipc_purge_publications(struct name_seq *seq)list_for_each_entry_safe (publ, safe, &info->zone_list, zone_list) {tipc_nametbl_remove_publ (publ->type, publ->lower, publ->node, publ->ref, publ->key); +kfree (publ); } }
@@ -986,7 +987,6 @@ void tipc_nametbl_stop(void)hlist_for_each_entry_safe (seq, safe, seq_head, ns_list) {tipc_purge_publications (seq); } -continue ; }kfree (table.types); table.types =NULL ;
Signature · 1 line
2.0.0
PATCH 9/181 nfsd4: fix FREE_STATEID lockowner leak
In reply to Jiri SlabyFrom: "J. Bruce Fields" <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 48385408b45523d9a432c66292d47ef43efcbb94 upstream.
27b11428b7de ("nfsd4: remove lockowner when removing lock stateid") introduced a memory leak.
--- fs/nfsd/nfs4state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/nfs4state.c +1 -1
@@ -3705,7 +3705,7 @@ nfsd4_free_lock_stateid(struct nfs4_ol_stateid *stp)* correspondance, and we have to delete the lockowner when we * delete the lock stateid: */ -unhash_lockowner (lo); +release_lockowner (lo);return nfs_ok; }
Signature · 1 line
2.0.0
PATCH 10/181 ftrace/x86: Call text_ip_addr() instead of the duplicated code
In reply to Jiri SlabyFrom: Petr Mladek <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 964f7b6b785651a75ef1cbad43a393ca52d4b4f7 upstream.
I just went over this when looking at some Xen-related ftrace initialization problems. They were related to Xen code that is not upstream but this clean up would make sense here.
I think that this was already the intention when text_ip_addr() was introduced in the commit 87fbb2ac6073a703930 (ftrace/x86: Use breakpoints for converting function graph caller). Anyway, better do it now before it shots people into their leg ;-)
--- arch/x86/kernel/ftrace.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
arch/x86/kernel/ftrace.c +1 -10
@@ -297,16 +297,7 @@ int ftrace_int3_handler(struct pt_regs *regs)static int ftrace_write (unsigned long ip,const char *val,int size) { -/* -* On x86_64, kernel text mappings are mapped read-only with -* CONFIG_DEBUG_RODATA. So we use the kernel identity mapping instead -* of the kernel text mapping to modify the kernel text. -* -* For 32bit kernels, these mappings are same and we can use -* kernel identity mapping to modify code. -*/ -if (within (ip, (unsigned long )_text, (unsigned long )_etext)) - ip = (unsigned long )__va (__pa_symbol (ip)); + ip =text_ip_addr (ip);return probe_kernel_write ((void *)ip, val, size); }
Signature · 1 line
2.0.0
PATCH 11/181 powerpc/mm: fix ".__node_distance" undefined
In reply to Jiri SlabyFrom: Mike Qiu <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 12c743eb2289bcaace32859d4919417ff5707768 upstream.
CHK include/config/kernel.release CHK include/generated/uapi/linux/version.h CHK include/generated/utsrelease.h
...
Building modules, stage 2.
WARNING: 1 bad relocationsc0000000013d6a30 R_PPC64_ADDR64 uprobes_fetch_type_table
WRAP arch/powerpc/boot/zImage.pseries
WRAP arch/powerpc/boot/zImage.epapr
MODPOST 1849 modules
ERROR: ".__node_distance" [drivers/block/nvme.ko] undefined! make[1]: *** [__modpost] Error 1
make: *** [modules] Error 2
make: *** Waiting for unfinished jobs....
The reason is symbol "__node_distance" not been exported in powerpc.
--- arch/powerpc/mm/numa.c | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/mm/numa.c +1 -0
@@ -232,6 +232,7 @@ int __node_distance(int a, int b)return distance; } +EXPORT_SYMBOL (__node_distance);static void initialize_distance_lookup_table (int nid,const __be32 *associativity)
Signature · 1 line
2.0.0
PATCH 12/181 ipr: Add new CCIN definition for Grand Canyon support
In reply to Jiri SlabyFrom: Wendy Xiong <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 5eeac3e99ae220aea787527d1bfd9e846adf9fac upstream.
Add the appropriate definition and table entry for new hardware support.
--- drivers/scsi/ipr.c | 6 ++++++ drivers/scsi/ipr.h | 3 +++ 2 files changed, 9 insertions(+)
drivers/scsi/ipr.c +6 -0
@@ -10005,6 +10005,12 @@ static struct pci_device_id ipr_pci_table[] = { PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57EF, 0, 0, 0 }, { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROCODILE, PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57F0, 0, 0, 0 }, + { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROCODILE, + PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_2CCA, 0, 0, 0 }, + { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROCODILE, + PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_2CD2, 0, 0, 0 }, + { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROCODILE, + PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_2CCD, 0, 0, 0 }, { } };MODULE_DEVICE_TABLE (pci, ipr_pci_table);
drivers/scsi/ipr.h +3 -0
@@ -107,6 +107,9 @@#define IPR_SUBS_DEV_ID_57EE 0x049A#define IPR_SUBS_DEV_ID_57EF 0x049B#define IPR_SUBS_DEV_ID_57F0 0x049C +#define IPR_SUBS_DEV_ID_2CCA 0x04C7 +#define IPR_SUBS_DEV_ID_2CD2 0x04C8 +#define IPR_SUBS_DEV_ID_2CCD 0x04C9#define IPR_NAME "ipr"/*
Signature · 1 line
2.0.0
PATCH 13/181 sched: Make scale_rt_power() deal with backward clocks
In reply to Jiri SlabyFrom: Peter Zijlstra <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit cadefd3d6cc914d95163ba1eda766bfe7ce1e5b7 upstream.
Mike reported that, while unlikely, its entirely possible for scale_rt_power() to see the time go backwards. This yields rather 'interesting' results.
So like all other sites that deal with clocks; make this one ignore backward clock movement too.
--- kernel/sched/fair.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
kernel/sched/fair.c +6 -1
@@ -4404,6 +4404,7 @@ static unsigned long scale_rt_power(int cpu) {struct rq *rq =cpu_rq (cpu);u64 total, available, age_stamp, avg; +s64 delta;/* * Since we're reading these variables without serialization make sure
@@ -4412,7 +4413,11 @@ static unsigned long scale_rt_power(int cpu) age_stamp =ACCESS_ONCE (rq->age_stamp); avg =ACCESS_ONCE (rq->rt_avg); - total =sched_avg_period () + (rq_clock (rq) - age_stamp); + delta =rq_clock (rq) - age_stamp; +if (unlikely (delta <0 )) + delta =0 ; + + total =sched_avg_period () + delta;if (unlikely (total < avg)) {/* Ensures that power won't end up being negative */
Signature · 1 line
2.0.0
PATCH 14/181 ACPI / memhotplug: add parameter to disable memory hotplug
In reply to Jiri SlabyFrom: Prarit Bhargava <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 00159a2013269bc0a617de885e4b921349192bd0 upstream.
When booting a kexec/kdump kernel on a system that has specific memory hotplug regions the boot will fail with warnings like:
swapper/0: page allocation failure: order:9, mode:0x84d0
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.10.0-65.el7.x86_64 #1 Hardware name: QCI QSSC-S4R/QSSC-S4R, BIOS QSSC-S4R.QCI.01.00.S013.032920111005 03/29/2011 0000000000000000 ffff8800341bd8c8 ffffffff815bcc67 ffff8800341bd950 ffffffff8113b1a0 ffff880036339b00 0000000000000009 00000000000084d0 ffff8800341bd950 ffffffff815b87ee 0000000000000000 0000000000000200 Call Trace: [<ffffffff815bcc67>] dump_stack+0x19/0x1b [<ffffffff8113b1a0>] warn_alloc_failed+0xf0/0x160 [<ffffffff815b87ee>] ? __alloc_pages_direct_compact+0xac/0x196 [<ffffffff8113f14f>] __alloc_pages_nodemask+0x7ff/0xa00 [<ffffffff815b417c>] vmemmap_alloc_block+0x62/0xba [<ffffffff815b41e9>] vmemmap_alloc_block_buf+0x15/0x3b [<ffffffff815b1ff6>] vmemmap_populate+0xb4/0x21b [<ffffffff815b461d>] sparse_mem_map_populate+0x27/0x35 [<ffffffff815b400f>] sparse_add_one_section+0x7a/0x185 [<ffffffff815a1e9f>] __add_pages+0xaf/0x240 [<ffffffff81047359>] arch_add_memory+0x59/0xd0 [<ffffffff815a21d9>] add_memory+0xb9/0x1b0 [<ffffffff81333b9c>] acpi_memory_device_add+0x18d/0x26d [<ffffffff81309a01>] acpi_bus_device_attach+0x7d/0xcd [<ffffffff8132379d>] acpi_ns_walk_namespace+0xc8/0x17f [<ffffffff81309984>] ? acpi_bus_type_and_status+0x90/0x90 [<ffffffff81309984>] ? acpi_bus_type_and_status+0x90/0x90 [<ffffffff81323c8c>] acpi_walk_namespace+0x95/0xc5 [<ffffffff8130a6d6>] acpi_bus_scan+0x8b/0x9d [<ffffffff81a2019a>] acpi_scan_init+0x63/0x160 [<ffffffff81a1ffb5>] acpi_init+0x25d/0x2a6 [<ffffffff81a1fd58>] ? acpi_sleep_proc_init+0x2a/0x2a [<ffffffff810020e2>] do_one_initcall+0xe2/0x190 [<ffffffff819e20c4>] kernel_init_freeable+0x17c/0x207 [<ffffffff819e18d0>] ? do_early_param+0x88/0x88 [<ffffffff8159fea0>] ? rest_init+0x80/0x80 [<ffffffff8159feae>] kernel_init+0xe/0x180 [<ffffffff815cca2c>] ret_from_fork+0x7c/0xb0 [<ffffffff8159fea0>] ? rest_init+0x80/0x80 Mem-Info: Node 0 DMA per-cpu: CPU 0: hi: 0, btch: 1 usd: 0 Node 0 DMA32 per-cpu: CPU 0: hi: 42, btch: 7 usd: 0 active_anon:0 inactive_anon:0 isolated_anon:0 active_file:0 inactive_file:0 isolated_file:0 unevictable:0 dirty:0 writeback:0 unstable:0 free:872 slab_reclaimable:13 slab_unreclaimable:1880 mapped:0 shmem:0 pagetables:0 bounce:0 free_cma:0
because the system has run out of memory at boot time. This occurs because of the following sequence in the boot:
Main kernel boots and sets E820 map. The second kernel is booted with a map generated by the kdump service using memmap= and memmap=exactmap. These parameters are added to the kernel parameters of the kexec/kdump
kernel. The kexec/kdump kernel has limited memory resources so as not
to severely impact the main kernel.
The system then panics and the kdump/kexec kernel boots (which is a completely new kernel boot). During this boot ACPI is initialized and the kernel (as can be seen above) traverses the ACPI namespace and finds an entry for a memory device to be hotadded.
ie)
[<ffffffff815a1e9f>] __add_pages+0xaf/0x240 [<ffffffff81047359>] arch_add_memory+0x59/0xd0 [<ffffffff815a21d9>] add_memory+0xb9/0x1b0 [<ffffffff81333b9c>] acpi_memory_device_add+0x18d/0x26d [<ffffffff81309a01>] acpi_bus_device_attach+0x7d/0xcd [<ffffffff8132379d>] acpi_ns_walk_namespace+0xc8/0x17f [<ffffffff81309984>] ? acpi_bus_type_and_status+0x90/0x90 [<ffffffff81309984>] ? acpi_bus_type_and_status+0x90/0x90 [<ffffffff81323c8c>] acpi_walk_namespace+0x95/0xc5 [<ffffffff8130a6d6>] acpi_bus_scan+0x8b/0x9d [<ffffffff81a2019a>] acpi_scan_init+0x63/0x160 [<ffffffff81a1ffb5>] acpi_init+0x25d/0x2a6
At this point the kernel adds page table information and the the kexec/kdump kernel runs out of memory.
This can also be reproduced by using the memmap=exactmap and mem=X parameters on the main kernel and booting.
This patchset resolves the problem by adding a kernel parameter, acpi_no_memhotplug, to disable ACPI memory hotplug.
--- Documentation/kernel-parameters.txt | 3 +++ drivers/acpi/acpi_memhotplug.c | 12 ++++++++++++ 2 files changed, 15 insertions(+)
Documentation/kernel-parameters.txt +3 -0
@@ -343,6 +343,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted. no: ACPI OperationRegions are not marked as reserved, no further checks are performed. + acpi_no_memhotplug [ACPI] Disable memory hotplug. Useful for kdump + kernels. + add_efi_memmap [EFI; X86] Include EFI memory map in kernel's map of available physical RAM.
drivers/acpi/acpi_memhotplug.c +12 -0
@@ -360,7 +360,19 @@ static void acpi_memory_device_remove(struct acpi_device *device)acpi_memory_device_free (mem_device); } +static bool __initdata acpi_no_memhotplug; +void __init acpi_memory_hotplug_init (void ) { +if (acpi_no_memhotplug) +return ; +acpi_scan_add_handler_with_hotplug (&memory_device_handler,"memory" ); } + +static int __init disable_acpi_memory_hotplug (char *str) +{ + acpi_no_memhotplug = true; +return 1 ; +} +__setup ("acpi_no_memhotplug" , disable_acpi_memory_hotplug);
Signature · 1 line
2.0.0
PATCH 15/181 net: Do not enable tx-nocache-copy by default
In reply to Jiri SlabyFrom: Benjamin Poirier <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit cdb3f4a31b64c3a1c6eef40bc01ebc9594c58a8c upstream.
There are many cases where this feature does not improve performance or even reduces it.
For example, here are the results from tests that I've run using 3.12.6 on one Intel Xeon W3565 and one i7 920 connected by ixgbe adapters. The results are from the Xeon, but they're similar on the i7. All numbers report the mean±stddev over 10 runs of 10s.
1) latency tests similar to what is described in "c6e1a0d net: Allow no-cache copy from user on transmit"
There is no statistically significant difference between tx-nocache-copy on/off.
nic irqs spread out (one queue per cpu)
200x netperf -r 1400,1
tx-nocache-copy off
692000±1000 tps
50/90/95/99% latency (us): 275±2/643.8±0.4/799±1/2474.4±0.3
tx-nocache-copy on
693000±1000 tps
50/90/95/99% latency (us): 274±1/644.1±0.7/800±2/2474.5±0.7200x netperf -r 14000,14000
tx-nocache-copy off
86450±80 tps
50/90/95/99% latency (us): 334.37±0.02/838±1/2100±20/3990±40
tx-nocache-copy on
86110±60 tps
50/90/95/99% latency (us): 334.28±0.01/837±2/2110±20/3990±202) single stream throughput tests
tx-nocache-copy leads to higher service demand
throughput cpu0 cpu1 demand
(Gb/s) (Gcycle) (Gcycle) (cycle/B)nic irqs and netperf on cpu0 (1x netperf -T0,0 -t omni -- -d send)
tx-nocache-copy off 9402±5 9.4±0.2 0.80±0.01 tx-nocache-copy on 9403±3 9.85±0.04 0.838±0.004
nic irqs on cpu0, netperf on cpu1 (1x netperf -T1,1 -t omni -- -d send)
tx-nocache-copy off 9401±5 5.83±0.03 5.0±0.1 0.923±0.007 tx-nocache-copy on 9404±2 5.74±0.03 5.523±0.009 0.958±0.002
As a second example, here are some results from Eric Dumazet with latest net-next.
tx-nocache-copy also leads to higher service demand
(cpu is Intel(R) Xeon(R) CPU X5660 @ 2.80GHz)
lpq83:~# ./ethtool -K eth0 tx-nocache-copy on lpq83:~# perf stat ./netperf -H lpq84 -c MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to lpq84.prod.google.com () port 0 AF_INET Recv Send Send Utilization Service Demand Socket Socket Message Elapsed Send Recv Send Recv Size Size Size Time Throughput local remote local remote bytes bytes bytes secs. 10^6bits/s % S % U us/KB us/KB
87380 16384 16384 10.00 9407.44 2.50 -1.00 0.522 -1.000
Performance counter stats for './netperf -H lpq84 -c':
4282.648396 task-clock # 0.423 CPUs utilized
9,348 context-switches # 0.002 M/sec
88 CPU-migrations # 0.021 K/sec
355 page-faults # 0.083 K/sec
11,812,797,651 cycles # 2.758 GHz [82.79%]
9,020,522,817 stalled-cycles-frontend # 76.36% frontend cycles idle [82.54%]
4,579,889,681 stalled-cycles-backend # 38.77% backend cycles idle [67.33%]
6,053,172,792 instructions # 0.51 insns per cycle
# 1.49 stalled cycles per insn [83.64%]
597,275,583 branches # 139.464 M/sec [83.70%]
8,960,541 branch-misses # 1.50% of all branches [83.65%]
10.128990264 seconds time elapsedlpq83:~# ./ethtool -K eth0 tx-nocache-copy off lpq83:~# perf stat ./netperf -H lpq84 -c MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to lpq84.prod.google.com () port 0 AF_INET Recv Send Send Utilization Service Demand Socket Socket Message Elapsed Send Recv Send Recv Size Size Size Time Throughput local remote local remote bytes bytes bytes secs. 10^6bits/s % S % U us/KB us/KB
87380 16384 16384 10.00 9412.45 2.15 -1.00 0.449 -1.000
Performance counter stats for './netperf -H lpq84 -c':
2847.375441 task-clock # 0.281 CPUs utilized
11,632 context-switches # 0.004 M/sec
49 CPU-migrations # 0.017 K/sec
354 page-faults # 0.124 K/sec
7,646,889,749 cycles # 2.686 GHz [83.34%]
6,115,050,032 stalled-cycles-frontend # 79.97% frontend cycles idle [83.31%]
1,726,460,071 stalled-cycles-backend # 22.58% backend cycles idle [66.55%]
2,079,702,453 instructions # 0.27 insns per cycle
# 2.94 stalled cycles per insn [83.22%]
363,773,213 branches # 127.757 M/sec [83.29%]
4,242,732 branch-misses # 1.17% of all branches [83.51%]
10.128449949 seconds time elapsed--- net/core/dev.c | 5 ----- 1 file changed, 5 deletions(-)
net/core/dev.c +0 -5
@@ -5636,13 +5636,8 @@ int register_netdevice(struct net_device *dev) dev->features |=NETIF_F_SOFT_FEATURES ; dev->wanted_features = dev->features & dev->hw_features; -/* Turn on no cache copy if HW is doing checksum */ if (!(dev->flags &IFF_LOOPBACK )) { dev->hw_features |=NETIF_F_NOCACHE_COPY ; -if (dev->features &NETIF_F_ALL_CSUM ) { - dev->wanted_features |=NETIF_F_NOCACHE_COPY ; - dev->features |=NETIF_F_NOCACHE_COPY ; - } }/* Make NETIF_F_HIGHDMA inheritable to VLAN devices.
Signature · 1 line
2.0.0
PATCH 16/181 net/compat: Fix minor information leak in siocdevprivate_ioctl()
In reply to Jiri SlabyFrom: Ben Hutchings <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 417c3522b3202dacce4873cfb0190459fbce95c5 upstream.
We don't need to check that ifr_data itself is a valid user pointer, but we should check &ifr_data is. Thankfully the copy of ifr_name is checked, so this can only leak a few bytes from immediately above the user address limit.
--- net/socket.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
net/socket.c +2 -5
@@ -3023,19 +3023,16 @@ static int siocdevprivate_ioctl(struct net *net, unsigned int cmd,if (copy_from_user (&tmp_buf[0 ], &(u_ifreq32->ifr_ifrn.ifrn_name[0 ]),IFNAMSIZ ))return -EFAULT ; -if (__get_user (data32, &u_ifreq32->ifr_ifru.ifru_data)) +if (get_user (data32, &u_ifreq32->ifr_ifru.ifru_data))return -EFAULT ; data64 =compat_ptr (data32); u_ifreq64 =compat_alloc_user_space (sizeof (*u_ifreq64)); -/* Don't check these user accesses, just let that get trapped -* in the ioctl handler instead. -*/ if (copy_to_user (&u_ifreq64->ifr_ifrn.ifrn_name[0 ], &tmp_buf[0 ],IFNAMSIZ ))return -EFAULT ; -if (__put_user (data64, &u_ifreq64->ifr_ifru.ifru_data)) +if (put_user (data64, &u_ifreq64->ifr_ifru.ifru_data))return -EFAULT ;return dev_ioctl (net, cmd, u_ifreq64);
Signature · 1 line
2.0.0
PATCH 17/181 vlan: more careful checksum features handling
In reply to Jiri SlabyFrom: Michal Kubeček <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit da08143b85203b581f4a6461b149186b0e9592df upstream.
When combining real_dev's features and vlan_features, simple bitwise AND is used. This doesn't work well for checksum offloading features as if one set has NETIF_F_HW_CSUM and the other NETIF_F_IP_CSUM and/or NETIF_F_IPV6_CSUM, we end up with no checksum offloading. However, from the logical point of view (how can_checksum_protocol() works), NETIF_F_HW_CSUM contains the functionality of NETIF_F_IP_CSUM and NETIF_F_IPV6_CSUM so that the result should be IP/IPV6.
Add helper function netdev_intersect_features() implementing this logic and use it in vlan_dev_fix_features().
--- include/linux/netdevice.h | 14 ++++++++++++++ net/8021q/vlan_dev.c | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-)
include/linux/netdevice.h +14 -0
@@ -2892,6 +2892,20 @@ extern const char *netdev_drivername(const struct net_device *dev);extern void linkwatch_run_queue (void ); +static inline netdev_features_t netdev_intersect_features (netdev_features_t f1, +netdev_features_t f2) +{ +if (f1 &NETIF_F_GEN_CSUM ) + f1 |= (NETIF_F_ALL_CSUM & ~NETIF_F_GEN_CSUM ); +if (f2 &NETIF_F_GEN_CSUM ) + f2 |= (NETIF_F_ALL_CSUM & ~NETIF_F_GEN_CSUM ); + f1 &= f2; +if (f1 &NETIF_F_GEN_CSUM ) + f1 &= ~(NETIF_F_ALL_CSUM & ~NETIF_F_GEN_CSUM ); + +return f1; +} +static inline netdev_features_t netdev_get_wanted_features (struct net_device *dev) {
net/8021q/vlan_dev.c +2 -2
@@ -694,9 +694,9 @@ static netdev_features_t vlan_dev_fix_features(struct net_device *dev,struct net_device *real_dev =vlan_dev_priv (dev)->real_dev;netdev_features_t old_features = features; - features &= real_dev->vlan_features; + features =netdev_intersect_features (features, real_dev->vlan_features); features |=NETIF_F_RXCSUM ; - features &= real_dev->features; + features =netdev_intersect_features (features, real_dev->features); features |= old_features &NETIF_F_SOFT_FEATURES ; features |=NETIF_F_LLTX ;
Signature · 1 line
2.0.0
PATCH 18/181 xfrm: fix race between netns cleanup and state expire notification
In reply to Jiri SlabyFrom: Michal Kubecek <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 21ee543edc0dea36ab58d24523fcd42b8a270df8 upstream.
The xfrm_user module registers its pernet init/exit after xfrm itself so that its net exit function xfrm_user_net_exit() is executed before xfrm_net_exit() which calls xfrm_state_fini() to cleanup the SA's (xfrm states). This opens a window between zeroing net->xfrm.nlsk pointer and deleting all xfrm_state instances which may access it (via the timer). If an xfrm state expires in this window, xfrm_exp_state_notify() will pass null pointer as socket to nlmsg_multicast().
As the notifications are called inside rcu_read_lock() block, it is sufficient to retrieve the nlsk socket with rcu_dereference() and check the it for null.
--- net/xfrm/xfrm_user.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-)
net/xfrm/xfrm_user.c +25 -11
@@ -930,6 +930,20 @@ static struct sk_buff *xfrm_state_netlink(struct sk_buff *in_skb,return skb; } +/* A wrapper for nlmsg_multicast() checking that nlsk is still available. +* Must be called with RCU read lock. +*/ +static inline int xfrm_nlmsg_multicast (struct net *net,struct sk_buff *skb, +u32 pid,unsigned int group) +{ +struct sock *nlsk =rcu_dereference (net->xfrm.nlsk); + +if (nlsk) +return nlmsg_multicast (nlsk, skb, pid, group,GFP_ATOMIC ); +else +return -1 ; +} +static inline size_t xfrm_spdinfo_msgsize (void ) {return NLMSG_ALIGN (4 )
@@ -2253,7 +2267,7 @@ static int xfrm_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,if (build_migrate (skb, m, num_migrate, k, sel, dir, type) <0 )BUG (); -return nlmsg_multicast (net->xfrm.nlsk, skb,0 ,XFRMNLGRP_MIGRATE ,GFP_ATOMIC ); +return xfrm_nlmsg_multicast (net, skb,0 ,XFRMNLGRP_MIGRATE ); }#else static int xfrm_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
@@ -2440,7 +2454,7 @@ static int xfrm_exp_state_notify(struct xfrm_state *x, const struct km_event *c)return -EMSGSIZE ; } -return nlmsg_multicast (net->xfrm.nlsk, skb,0 ,XFRMNLGRP_EXPIRE ,GFP_ATOMIC ); +return xfrm_nlmsg_multicast (net, skb,0 ,XFRMNLGRP_EXPIRE ); }static int xfrm_aevent_state_notify (struct xfrm_state *x,const struct km_event *c)
@@ -2455,7 +2469,7 @@ static int xfrm_aevent_state_notify(struct xfrm_state *x, const struct km_eventif (build_aevent (skb, x, c) <0 )BUG (); -return nlmsg_multicast (net->xfrm.nlsk, skb,0 ,XFRMNLGRP_AEVENTS ,GFP_ATOMIC ); +return xfrm_nlmsg_multicast (net, skb,0 ,XFRMNLGRP_AEVENTS ); }static int xfrm_notify_sa_flush (const struct km_event *c)
@@ -2481,7 +2495,7 @@ static int xfrm_notify_sa_flush(const struct km_event *c)nlmsg_end (skb, nlh); -return nlmsg_multicast (net->xfrm.nlsk, skb,0 ,XFRMNLGRP_SA ,GFP_ATOMIC ); +return xfrm_nlmsg_multicast (net, skb,0 ,XFRMNLGRP_SA ); }static inline size_t xfrm_sa_len (struct xfrm_state *x)
@@ -2568,7 +2582,7 @@ static int xfrm_notify_sa(struct xfrm_state *x, const struct km_event *c)nlmsg_end (skb, nlh); -return nlmsg_multicast (net->xfrm.nlsk, skb,0 ,XFRMNLGRP_SA ,GFP_ATOMIC ); +return xfrm_nlmsg_multicast (net, skb,0 ,XFRMNLGRP_SA ); out_free_skb:kfree_skb (skb);
@@ -2659,7 +2673,7 @@ static int xfrm_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *xt,if (build_acquire (skb, x, xt, xp) <0 )BUG (); -return nlmsg_multicast (net->xfrm.nlsk, skb,0 ,XFRMNLGRP_ACQUIRE ,GFP_ATOMIC ); +return xfrm_nlmsg_multicast (net, skb,0 ,XFRMNLGRP_ACQUIRE ); }/* User gives us xfrm_user_policy_info followed by an array of 0
@@ -2773,7 +2787,7 @@ static int xfrm_exp_policy_notify(struct xfrm_policy *xp, int dir, const structif (build_polexpire (skb, xp, dir, c) <0 )BUG (); -return nlmsg_multicast (net->xfrm.nlsk, skb,0 ,XFRMNLGRP_EXPIRE ,GFP_ATOMIC ); +return xfrm_nlmsg_multicast (net, skb,0 ,XFRMNLGRP_EXPIRE ); }static int xfrm_notify_policy (struct xfrm_policy *xp,int dir,const struct km_event *c)
@@ -2835,7 +2849,7 @@ static int xfrm_notify_policy(struct xfrm_policy *xp, int dir, const struct km_enlmsg_end (skb, nlh); -return nlmsg_multicast (net->xfrm.nlsk, skb,0 ,XFRMNLGRP_POLICY ,GFP_ATOMIC ); +return xfrm_nlmsg_multicast (net, skb,0 ,XFRMNLGRP_POLICY ); out_free_skb:kfree_skb (skb);
@@ -2863,7 +2877,7 @@ static int xfrm_notify_policy_flush(const struct km_event *c)nlmsg_end (skb, nlh); -return nlmsg_multicast (net->xfrm.nlsk, skb,0 ,XFRMNLGRP_POLICY ,GFP_ATOMIC ); +return xfrm_nlmsg_multicast (net, skb,0 ,XFRMNLGRP_POLICY ); out_free_skb:kfree_skb (skb);
@@ -2932,7 +2946,7 @@ static int xfrm_send_report(struct net *net, u8 proto,if (build_report (skb, proto, sel, addr) <0 )BUG (); -return nlmsg_multicast (net->xfrm.nlsk, skb,0 ,XFRMNLGRP_REPORT ,GFP_ATOMIC ); +return xfrm_nlmsg_multicast (net, skb,0 ,XFRMNLGRP_REPORT ); }static inline size_t xfrm_mapping_msgsize (void )
@@ -2984,7 +2998,7 @@ static int xfrm_send_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr,if (build_mapping (skb, x, ipaddr, sport) <0 )BUG (); -return nlmsg_multicast (net->xfrm.nlsk, skb,0 ,XFRMNLGRP_MAPPING ,GFP_ATOMIC ); +return xfrm_nlmsg_multicast (net, skb,0 ,XFRMNLGRP_MAPPING ); }static struct xfrm_mgr netlink_mgr = {
Signature · 1 line
2.0.0
PATCH 19/181 Check SMB3 dialects against downgrade attacks
In reply to Jiri SlabyFrom: Steve French <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit ff1c038addc4f205d5f1ede449426c7d316c0eed upstream.
When we are running SMB3 or SMB3.02 connections which are signed we need to validate the protocol negotiation information, to ensure that the negotiate protocol response was not tampered with.
Add the missing FSCTL which is sent at mount time (immediately after the SMB3 Tree Connect) to validate that the capabilities match what we think the server sent.
"Secure dialect negotiation is introduced in SMB3 to protect against man-in-the-middle attempt to downgrade dialect negotiation. The idea is to prevent an eavesdropper from downgrading the initially negotiated dialect and capabilities between the client and the server."
For more explanation see 2.2.31.4 of MS-SMB2 or
http://blogs.msdn.com/b/openspecification/archive/2012/06/28/smb3-secure-dialect-negotiation.aspx
--- fs/cifs/cifsglob.h | 1 + fs/cifs/smb2ops.c | 1 + fs/cifs/smb2pdu.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/cifs/smb2pdu.h | 12 ++++++--- fs/cifs/smb2proto.h | 1 + fs/cifs/smbfsctl.h | 2 +- 6 files changed, 90 insertions(+), 4 deletions(-)
fs/cifs/cifsglob.h +1 -0
@@ -391,6 +391,7 @@ struct smb_version_operations { const char *, u32 *);int (*set_acl)(struct cifs_ntsd *,__u32 ,struct inode *,const char *,int ); +int (*validate_negotiate)(const unsigned int ,struct cifs_tcon *); };struct smb_version_values {
fs/cifs/smb2ops.c +1 -0
@@ -1059,6 +1059,7 @@ struct smb_version_operations smb30_operations = { .set_oplock_level = smb3_set_oplock_level, .create_lease_buf = smb3_create_lease_buf, .parse_lease_buf = smb3_parse_lease_buf, + .validate_negotiate = smb3_validate_negotiate, };struct smb_version_values smb20_values = {
fs/cifs/smb2pdu.c +77 -0
89 lines not on this page · raw message
fs/cifs/smb2pdu.h +9 -3
@@ -546,13 +546,19 @@ struct copychunk_ioctl {__u32 Reserved2; } __packed; -/* Response and Request are the same format */ -struct validate_negotiate_info { +struct validate_negotiate_info_req {__le32 Capabilities;__u8 Guid[SMB2_CLIENT_GUID_SIZE ];__le16 SecurityMode;__le16 DialectCount; -__le16 Dialect[1 ]; +__le16 Dialects[1 ];/* dialect (someday maybe list) client asked for */ +} __packed; + +struct validate_negotiate_info_rsp { +__le32 Capabilities; +__u8 Guid[SMB2_CLIENT_GUID_SIZE ]; +__le16 SecurityMode; +__le16 Dialect;/* Dialect in use for the connection */ } __packed;#define RSS_CAPABLE 0x00000001
fs/cifs/smb2proto.h +1 -0
@@ -158,5 +158,6 @@ extern int smb2_lockv(const unsigned int xid, struct cifs_tcon *tcon, struct smb2_lock_element *buf);extern int SMB2_lease_break (const unsigned int xid,struct cifs_tcon *tcon,__u8 *lease_key,const __le32 lease_state); +extern int smb3_validate_negotiate (const unsigned int ,struct cifs_tcon *);#endif /* _SMB2PROTO_H */
fs/cifs/smbfsctl.h +1 -1
@@ -90,7 +90,7 @@#define FSCTL_LMR_REQUEST_RESILIENCY 0x001401D4/* BB add struct */ #define FSCTL_LMR_GET_LINK_TRACK_INF 0x001400E8/* BB add struct */ #define FSCTL_LMR_SET_LINK_TRACK_INF 0x001400EC/* BB add struct */ -#define FSCTL_VALIDATE_NEGOTIATE_INFO 0x00140204/* BB add struct */ +#define FSCTL_VALIDATE_NEGOTIATE_INFO 0x00140204/* Perform server-side data movement */ #define FSCTL_SRV_COPYCHUNK 0x001440F2#define FSCTL_SRV_COPYCHUNK_WRITE 0x001480F2
Signature · 1 line
2.0.0
PATCH 20/181 cifs: Set client guid on per connection basis
In reply to Jiri SlabyFrom: Sachin Prabhu <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 39552ea8120a699dbd0360848c4d949f9f0e6deb upstream.
When mounting from a Windows 2012R2 server, we hit the following problem:
1) Mount with any of the following versions - 2.0, 2.1 or 3.0
2) unmount
3) Attempt a mount again using a different SMB version >= 2.0.
You end up with the following failure:
Status code returned 0xc0000203 STATUS_USER_SESSION_DELETED CIFS VFS: Send error in SessSetup = -5
CIFS VFS: cifs_mount failed w/return code = -5
I cannot reproduce this issue using a Windows 2008 R2 server.
This appears to be caused because we use the same client guid for the connection on first mount which we then disconnect and attempt to mount again using a different protocol version. By generating a new guid each time a new connection is Negotiated, we avoid hitting this problem.
--- fs/cifs/cifsfs.c | 8 -------- fs/cifs/cifsglob.h | 1 + fs/cifs/connect.c | 3 +++ fs/cifs/smb2pdu.c | 5 +++-- fs/cifs/smb2pdu.h | 2 -- 5 files changed, 7 insertions(+), 12 deletions(-)
fs/cifs/cifsfs.c +0 -8
@@ -87,10 +87,6 @@ extern mempool_t *cifs_mid_poolp;struct workqueue_struct *cifsiod_wq; -#ifdef CONFIG_CIFS_SMB2 -__u8 cifs_client_guid[SMB2_CLIENT_GUID_SIZE ]; -#endif -/* * Bumps refcount for cifs super block. * Note that it should be only called if a referece to VFS super block is
@@ -1192,10 +1188,6 @@ init_cifs(void)spin_lock_init (&cifs_file_list_lock);spin_lock_init (&GlobalMid_Lock); -#ifdef CONFIG_CIFS_SMB2 -get_random_bytes (cifs_client_guid,SMB2_CLIENT_GUID_SIZE ); -#endif -if (cifs_max_pending <2 ) { cifs_max_pending =2 ;cifs_dbg (FYI ,"cifs_max_pending set to min of 2\n" );
fs/cifs/cifsglob.h +1 -0
@@ -547,6 +547,7 @@ struct TCP_Server_Info {int echo_credits;/* echo reserved slots */ int oplock_credits;/* oplock break reserved slots */ bool echoes:1; /* enable echoes */ +__u8 client_guid[SMB2_CLIENT_GUID_SIZE ];/* Client GUID */ #endif u16 dialect;/* dialect index that server chose */ bool oplocks:1; /* enable oplocks */
fs/cifs/connect.c +3 -0
@@ -2144,6 +2144,9 @@ cifs_get_tcp_session(struct smb_vol *volume_info) sizeof(tcp_ses->srcaddr));memcpy (&tcp_ses->dstaddr, &volume_info->dstaddr,sizeof (tcp_ses->dstaddr)); +#ifdef CONFIG_CIFS_SMB2 +get_random_bytes (tcp_ses->client_guid,SMB2_CLIENT_GUID_SIZE ); +#endif /* * at this point we are the only ones with the pointer * to the struct since the kernel thread not created yet
fs/cifs/smb2pdu.c +3 -2
@@ -375,7 +375,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) req->Capabilities =cpu_to_le32 (ses->server->vals->req_capabilities); -memcpy (req->ClientGUID, cifs_client_guid,SMB2_CLIENT_GUID_SIZE ); +memcpy (req->ClientGUID, server->client_guid,SMB2_CLIENT_GUID_SIZE ); iov[0 ].iov_base = (char *)req;/* 4 for rfc1002 length field */
@@ -478,7 +478,8 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) vneg_inbuf.Capabilities =cpu_to_le32 (tcon->ses->server->vals->req_capabilities); -memcpy (vneg_inbuf.Guid, cifs_client_guid,SMB2_CLIENT_GUID_SIZE ); +memcpy (vneg_inbuf.Guid, tcon->ses->server->client_guid, +SMB2_CLIENT_GUID_SIZE );if (tcon->ses->sign) vneg_inbuf.SecurityMode =
fs/cifs/smb2pdu.h +0 -2
@@ -166,8 +166,6 @@ struct smb2_symlink_err_rsp {#define SMB2_CLIENT_GUID_SIZE 16 -extern __u8 cifs_client_guid[SMB2_CLIENT_GUID_SIZE ]; -struct smb2_negotiate_req {struct smb2_hdr hdr;__le16 StructureSize;/* Must be 36 */
Signature · 1 line
2.0.0
PATCH 21/181 Do not send ClientGUID on SMB2.02 dialect
In reply to Jiri SlabyFrom: Steve French <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 3c5f9be108783c05cade918d29c8711b236acb1d upstream.
ClientGUID must be zero for SMB2.02 dialect. See section 2.2.3 of MS-SMB2. For SMB2.1 and later it must be non-zero.
--- fs/cifs/smb2pdu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/cifs/smb2pdu.c +6 -1
@@ -375,7 +375,12 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) req->Capabilities =cpu_to_le32 (ses->server->vals->req_capabilities); -memcpy (req->ClientGUID, server->client_guid,SMB2_CLIENT_GUID_SIZE ); +/* ClientGUID must be zero for SMB2.02 dialect */ +if (ses->server->vals->protocol_id ==SMB20_PROT_ID ) +memset (req->ClientGUID,0 ,SMB2_CLIENT_GUID_SIZE ); +else +memcpy (req->ClientGUID, server->client_guid, +SMB2_CLIENT_GUID_SIZE ); iov[0 ].iov_base = (char *)req;/* 4 for rfc1002 length field */
Signature · 1 line
2.0.0
PATCH 22/181 Btrfs: fix tracking of orphan inode count
In reply to Jiri SlabyFrom: Filipe David Borba Manana <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 703c88e035242202e3ab48fcbbbe0a7bc62fb7bb upstream.
In inode.c:btrfs_orphan_add() if we failed to insert the orphan item, we would return without decrementing the orphan count that we just incremented before attempting the insertion, leaving the orphan inode count wrong.
In inode.c:btrfs_orphan_del(), we were decrementing the inode orphan count if the bit BTRFS_INODE_ORPHAN_META_RESERVED was set, which is logically wrong because it should be decremented if the bit BTRFS_INODE_HAS_ORPHAN_ITEM was set - after all we increment the count when we set the bit BTRFS_INODE_HAS_ORPHAN_ITEM elsewhere.
--- fs/btrfs/inode.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
fs/btrfs/inode.c +8 -5
@@ -2978,6 +2978,7 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode)if (insert >=1 ) { ret =btrfs_insert_orphan_item (trans, root,btrfs_ino (inode));if (ret) { +atomic_dec (&root->orphan_inodes);if (reserve) {clear_bit (BTRFS_INODE_ORPHAN_META_RESERVED , &BTRFS_I (inode)->runtime_flags);
@@ -3027,14 +3028,16 @@ static int btrfs_orphan_del(struct btrfs_trans_handle *trans, release_rsv =1 ;spin_unlock (&root->orphan_lock); -if (trans && delete_item) - ret =btrfs_del_orphan_item (trans, root,btrfs_ino (inode)); - -if (release_rsv) { -btrfs_orphan_release_metadata (inode); +if (delete_item) {atomic_dec (&root->orphan_inodes); +if (trans) + ret =btrfs_del_orphan_item (trans, root, +btrfs_ino (inode)); } +if (release_rsv) +btrfs_orphan_release_metadata (inode); +return ret; }
Signature · 1 line
2.0.0
PATCH 23/181 Btrfs: fix sync fs to actually wait for all data to be persisted
In reply to Jiri SlabyFrom: Filipe David Borba Manana <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 9b1998598625fb5b798e8291cafda1a8ec17c1bd upstream.
Currently the fs sync function (super.c:btrfs_sync_fs()) doesn't wait for delayed work to finish before returning success to the caller. This change fixes this, ensuring that there's no data loss if a power failure happens right after fs sync returns success to the caller and before the next commit happens.
Steps to reproduce the data loss issue:
$ mkfs.btrfs -f /dev/sdb3
$ mount /dev/sdb3 /mnt/btrfs
$ perl -e '$d = ("\x41" x 6001); open($f,">","/mnt/btrfs/foobar"); print $f $d; close($f);' && btrfs fi sync /mnt/btrfsRight after the btrfs fi sync command (a second or 2 for example), power off the machine and reboot it. The file will be empty, as it can be verified after mounting the filesystem and through btrfs-debug-tree:
$ btrfs-debug-tree /dev/sdb3 | egrep '\(257 INODE_ITEM 0\) itemoff' -B 3 -A 8
item 3 key (256 DIR_INDEX 2) itemoff 3751 itemsize 36
location key (257 INODE_ITEM 0) type FILE
namelen 6 datalen 0 name: foobar
item 4 key (257 INODE_ITEM 0) itemoff 3591 itemsize 160
inode generation 7 transid 7 size 0 block group 0 mode 100644 links 1
item 5 key (257 INODE_REF 256) itemoff 3575 itemsize 16
inode ref index 2 namelen 6 name: foobar
checksum tree key (CSUM_TREE ROOT_ITEM 0)
leaf 29429760 items 0 free space 3995 generation 7 owner 7
fs uuid 6192815c-af2a-4b75-b3db-a959ffb6166e
chunk uuid b529c44b-938c-4d3d-910a-013b4700bcae
uuid tree key (UUID_TREE ROOT_ITEM 0)After this patch, the data loss no longer happens after a power failure and btrfs-debug-tree shows:
$ btrfs-debug-tree /dev/sdb3 | egrep '\(257 INODE_ITEM 0\) itemoff' -B 3 -A 8 item 3 key (256 DIR_INDEX 2) itemoff 3751 itemsize 36 location key (257 INODE_ITEM 0) type FILE namelen 6 datalen 0 name: foobar item 4 key (257 INODE_ITEM 0) itemoff 3591 itemsize 160 inode generation 6 transid 6 size 6001 block group 0 mode 100644 links 1 item 5 key (257 INODE_REF 256) itemoff 3575 itemsize 16 inode ref index 2 namelen 6 name: foobar item 6 key (257 EXTENT_DATA 0) itemoff 3522 itemsize 53 extent data disk byte 12845056 nr 8192 extent data offset 0 nr 8192 ram 8192 extent compression 0 checksum tree key (CSUM_TREE ROOT_ITEM 0)
--- fs/btrfs/ioctl.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
fs/btrfs/ioctl.c +9 -3
@@ -4564,9 +4564,15 @@ long btrfs_ioctl(struct file *file, unsigned intreturn btrfs_ioctl_logical_to_ino (root, argp);case BTRFS_IOC_SPACE_INFO :return btrfs_ioctl_space_info (root, argp); -case BTRFS_IOC_SYNC : -btrfs_sync_fs (file->f_dentry->d_sb,1 ); -return 0 ; +case BTRFS_IOC_SYNC : { +int ret; + + ret =btrfs_start_all_delalloc_inodes (root->fs_info,0 ); +if (ret) +return ret; + ret =btrfs_sync_fs (file->f_dentry->d_sb,1 ); +return ret; + }case BTRFS_IOC_START_SYNC :return btrfs_ioctl_start_sync (root, argp);case BTRFS_IOC_WAIT_SYNC :
Signature · 1 line
2.0.0
PATCH 24/181 Btrfs: don't leak block group on error
In reply to Jiri SlabyFrom: Filipe David Borba Manana <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit e84cc14213e2c81ae5a2da341a9da0d58a1dbfad upstream.
In extent-tree.c:btrfs_write_dirty_block_groups(), if the call to write_one_cache_group() failed, we would return without putting the block group first.
--- fs/btrfs/extent-tree.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/extent-tree.c +1 -2
@@ -3318,10 +3318,9 @@ again: last = cache->key.objectid + cache->key.offset; err =write_one_cache_group (trans, root, path, cache); +btrfs_put_block_group (cache);if (err)/* File system offline */ goto out; - -btrfs_put_block_group (cache); }while (1 ) {
Signature · 1 line
2.0.0
PATCH 25/181 Btrfs: do not release metadata for space cache inodes
In reply to Jiri SlabyFrom: Josef Bacik <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit b6d08f0630d51ec09d67f16f6d7839699bbc0402 upstream.
I've been testing our error paths and I was tripping the BUG_ON() in drop_outstanding_extent because our outstanding_extents is 0 for space cache inodes. This is because we don't reserve metadata space for these inodes since we depend on the global block reserve for our space. To fix this we need to make sure the DO_ACCOUNTING stuff doesn't actually call release_metadata for space cache inodes. With this patch I'm no longer panicing. Thanks,
--- fs/btrfs/inode.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
fs/btrfs/inode.c +7 -1
@@ -1551,7 +1551,13 @@ static void btrfs_clear_bit_hook(struct inode *inode,spin_unlock (&BTRFS_I (inode)->lock); } -if (*bits &EXTENT_DO_ACCOUNTING ) +/* +* We don't reserve metadata space for space cache inodes so we +* don't need to call dellalloc_release_metadata if there is an +* error. +*/ +if (*bits &EXTENT_DO_ACCOUNTING && + root != root->fs_info->tree_root)btrfs_delalloc_release_metadata (inode, len); if (root->root_key.objectid != BTRFS_DATA_RELOC_TREE_OBJECTID
Signature · 1 line
2.0.0
PATCH 26/181 Btrfs: cleanup transaction on abort
In reply to Jiri SlabyFrom: Josef Bacik <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 4e121c06adf53aae478ebce3035116595d063413 upstream.
If we abort not during a transaction commit we won't clean up anything until we unmount. Unfortunately if we abort in the middle of writing out an ordered extent we won't clean it up and if somebody is waiting on that ordered extent they will wait forever. To fix this just make the transaction kthread call the cleanup transaction stuff if it notices theres an error, and make btrfs_end_transaction wake up the transaction kthread if there is an error. Thanks,
--- fs/btrfs/disk-io.c | 3 +++ fs/btrfs/transaction.c | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-)
fs/btrfs/disk-io.c +3 -0
@@ -1780,6 +1780,9 @@ sleep:wake_up_process (root->fs_info->cleaner_kthread);mutex_unlock (&root->fs_info->transaction_kthread_mutex); +if (unlikely (test_bit (BTRFS_FS_STATE_ERROR , + &root->fs_info->fs_state))) +btrfs_cleanup_transaction (root);if (!try_to_freeze ()) {set_current_state (TASK_INTERRUPTIBLE ); if (!kthread_should_stop() &&
fs/btrfs/transaction.c +3 -1
@@ -738,8 +738,10 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,btrfs_run_delayed_iputs (root);if (trans->aborted || -test_bit (BTRFS_FS_STATE_ERROR , &root->fs_info->fs_state)) +test_bit (BTRFS_FS_STATE_ERROR , &root->fs_info->fs_state)) { +wake_up_process (info->transaction_kthread); err = -EIO ; + }assert_qgroups_uptodate (trans);kmem_cache_free (btrfs_trans_handle_cachep, trans);
Signature · 1 line
2.0.0
PATCH 27/181 Btrfs: don't delete ordered roots from list during cleanup
In reply to Jiri SlabyFrom: Josef Bacik <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 1de2cfde93c20a0357ff1dffed901598470facf3 upstream.
During transaction cleanup after an abort we are just removing roots from the ordered roots list which is incorrect. We have a BUG_ON() to make sure that the root is still part of the ordered roots list when we put our ordered extent which we were tripping in this case. So do like we do everywhere else and just move it to the tail of the ordered roots list and allow the normal cleanup to take care of stuff. Thanks,
--- fs/btrfs/disk-io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/disk-io.c +2 -1
@@ -3809,7 +3809,8 @@ static void btrfs_destroy_all_ordered_extents(struct btrfs_fs_info *fs_info)while (!list_empty (&splice)) { root = list_first_entry(&splice, struct btrfs_root, ordered_root); -list_del_init (&root->ordered_root); +list_move_tail (&root->ordered_root, + &fs_info->ordered_roots);btrfs_destroy_ordered_extents (root);
Signature · 1 line
2.0.0
PATCH 28/181 Btrfs: fix two use-after-free bugs with transaction cleanup
In reply to Jiri SlabyFrom: Josef Bacik <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 724e2315db3d59a8201d4a87c7c7a873e60e1ce0 upstream.
I was noticing the slab redzone stuff going off every once and a while during transaction aborts. This was caused by two things
1) We would walk the pending snapshots and set their error to -ECANCELED. We don't need to do this, the snapshot stuff waits for a transaction commit and if there is a problem we just free our pending snapshot object and exit. Doing this was causing us to touch the pending snapshot object after the thing had already been freed.
2) We were freeing the transaction manually with wanton disregard for it's use_count reference counter. To fix this I cleaned up the transaction freeing loop to either wait for the transaction commit to finish if it was in the middle of that (since it will be cleaned and freed up there) or to do the cleanup oursevles.
I also moved the global "kill all things dirty everywhere" stuff outside of the transaction cleanup loop since that only needs to be done once. With this patch I'm no longer seeing slab corruption because of use after frees. Thanks,
--- fs/btrfs/disk-io.c | 111 ++++++++++++++++++------------------------------- fs/btrfs/transaction.c | 22 +++++----- fs/btrfs/transaction.h | 1 + 3 files changed, 52 insertions(+), 82 deletions(-)
fs/btrfs/disk-io.c +40 -71
@@ -64,7 +64,6 @@ static void btrfs_destroy_ordered_operations(struct btrfs_transaction *t,static void btrfs_destroy_ordered_extents (struct btrfs_root *root);static int btrfs_destroy_delayed_refs (struct btrfs_transaction *trans,struct btrfs_root *root); -static void btrfs_evict_pending_snapshots (struct btrfs_transaction *t);static void btrfs_destroy_delalloc_inodes (struct btrfs_root *root); static int btrfs_destroy_marked_extents(struct btrfs_root *root, struct extent_io_tree *dirty_pages,
@@ -3888,24 +3887,6 @@ static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,return ret; } -static void btrfs_evict_pending_snapshots (struct btrfs_transaction *t) -{ -struct btrfs_pending_snapshot *snapshot; -struct list_head splice; - -INIT_LIST_HEAD (&splice); - -list_splice_init (&t->pending_snapshots, &splice); - -while (!list_empty (&splice)) { - snapshot =list_entry (splice.next, - struct btrfs_pending_snapshot, - list); - snapshot->error = -ECANCELED ; -list_del_init (&snapshot->list); - } -} -static void btrfs_destroy_delalloc_inodes (struct btrfs_root *root) {struct btrfs_inode *btrfs_inode;
@@ -4035,6 +4016,8 @@ again:void btrfs_cleanup_one_transaction (struct btrfs_transaction *cur_trans,struct btrfs_root *root) { +btrfs_destroy_ordered_operations (cur_trans, root); +btrfs_destroy_delayed_refs (cur_trans, root);btrfs_block_rsv_release (root, &root->fs_info->trans_block_rsv, cur_trans->dirty_pages.dirty_bytes);
@@ -4042,8 +4025,6 @@ void btrfs_cleanup_one_transaction(struct btrfs_transaction *cur_trans, cur_trans->state =TRANS_STATE_COMMIT_START ;wake_up (&root->fs_info->transaction_blocked_wait); -btrfs_evict_pending_snapshots (cur_trans); - cur_trans->state =TRANS_STATE_UNBLOCKED ;wake_up (&root->fs_info->transaction_wait);
@@ -4067,63 +4048,51 @@ void btrfs_cleanup_one_transaction(struct btrfs_transaction *cur_trans,static int btrfs_cleanup_transaction (struct btrfs_root *root) {struct btrfs_transaction *t; -LIST_HEAD (list);mutex_lock (&root->fs_info->transaction_kthread_mutex);spin_lock (&root->fs_info->trans_lock); -list_splice_init (&root->fs_info->trans_list, &list); - root->fs_info->running_transaction =NULL ; -spin_unlock (&root->fs_info->trans_lock); - -while (!list_empty (&list)) { - t = list_entry(list.next, struct btrfs_transaction, list); - -btrfs_destroy_ordered_operations (t, root); - -btrfs_destroy_all_ordered_extents (root->fs_info); - -btrfs_destroy_delayed_refs (t, root); - -/* -* FIXME: cleanup wait for commit -* We needn't acquire the lock here, because we are during -* the umount, there is no other task which will change it. -*/ - t->state =TRANS_STATE_COMMIT_START ; -smp_mb (); -if (waitqueue_active (&root->fs_info->transaction_blocked_wait)) -wake_up (&root->fs_info->transaction_blocked_wait); - -btrfs_evict_pending_snapshots (t); - - t->state =TRANS_STATE_UNBLOCKED ; -smp_mb (); -if (waitqueue_active (&root->fs_info->transaction_wait)) -wake_up (&root->fs_info->transaction_wait); - -btrfs_destroy_delayed_inodes (root); -btrfs_assert_delayed_root_empty (root); - -btrfs_destroy_all_delalloc_inodes (root->fs_info); - -btrfs_destroy_marked_extents (root, &t->dirty_pages, -EXTENT_DIRTY ); - -btrfs_destroy_pinned_extent (root, - root->fs_info->pinned_extents); - - t->state =TRANS_STATE_COMPLETED ; -smp_mb (); -if (waitqueue_active (&t->commit_wait)) -wake_up (&t->commit_wait); +while (!list_empty (&root->fs_info->trans_list)) { + t =list_first_entry (&root->fs_info->trans_list, + struct btrfs_transaction, list); +if (t->state >=TRANS_STATE_COMMIT_START ) { +atomic_inc (&t->use_count); +spin_unlock (&root->fs_info->trans_lock); +btrfs_wait_for_commit (root, t->transid); +btrfs_put_transaction (t); +spin_lock (&root->fs_info->trans_lock); +continue ; + } +if (t == root->fs_info->running_transaction) { + t->state =TRANS_STATE_COMMIT_DOING ; +spin_unlock (&root->fs_info->trans_lock); +/* +* We wait for 0 num_writers since we don't hold a trans +* handle open currently for this transaction. +*/ +wait_event (t->writer_wait, +atomic_read (&t->num_writers) ==0 ); + }else { +spin_unlock (&root->fs_info->trans_lock); + } +btrfs_cleanup_one_transaction (t, root); -atomic_set (&t->use_count,0 ); +spin_lock (&root->fs_info->trans_lock); +if (t == root->fs_info->running_transaction) + root->fs_info->running_transaction =NULL ;list_del_init (&t->list); -memset (t,0 ,sizeof (*t)); -kmem_cache_free (btrfs_transaction_cachep, t); - } +spin_unlock (&root->fs_info->trans_lock); +btrfs_put_transaction (t); +trace_btrfs_transaction_commit (root); +spin_lock (&root->fs_info->trans_lock); + } +spin_unlock (&root->fs_info->trans_lock); +btrfs_destroy_all_ordered_extents (root->fs_info); +btrfs_destroy_delayed_inodes (root); +btrfs_assert_delayed_root_empty (root); +btrfs_destroy_pinned_extent (root, root->fs_info->pinned_extents); +btrfs_destroy_all_delalloc_inodes (root->fs_info);mutex_unlock (&root->fs_info->transaction_kthread_mutex);return 0 ;
fs/btrfs/transaction.c +11 -11
@@ -57,7 +57,7 @@ static unsigned int btrfs_blocked_trans_types[TRANS_STATE_MAX] = { __TRANS_JOIN_NOLOCK), }; -static void put_transaction (struct btrfs_transaction *transaction) +void btrfs_put_transaction (struct btrfs_transaction *transaction) {WARN_ON (atomic_read (&transaction->use_count) ==0 );if (atomic_dec_and_test (&transaction->use_count)) {
@@ -332,7 +332,7 @@ static void wait_current_trans(struct btrfs_root *root)wait_event (root->fs_info->transaction_wait, cur_trans->state >=TRANS_STATE_UNBLOCKED || cur_trans->aborted); -put_transaction (cur_trans); +btrfs_put_transaction (cur_trans); }else {spin_unlock (&root->fs_info->trans_lock); }
@@ -610,7 +610,7 @@ int btrfs_wait_for_commit(struct btrfs_root *root, u64 transid) }wait_for_commit (root, cur_trans); -put_transaction (cur_trans); +btrfs_put_transaction (cur_trans); out:return ret; }
@@ -729,7 +729,7 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,smp_mb ();if (waitqueue_active (&cur_trans->writer_wait))wake_up (&cur_trans->writer_wait); -put_transaction (cur_trans); +btrfs_put_transaction (cur_trans);if (current->journal_info == trans) current->journal_info =NULL ;
@@ -1506,7 +1506,7 @@ int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans,if (current->journal_info == trans) current->journal_info =NULL ; -put_transaction (cur_trans); +btrfs_put_transaction (cur_trans);return 0 ; }
@@ -1550,8 +1550,8 @@ static void cleanup_transaction(struct btrfs_trans_handle *trans,if (trans->type & __TRANS_FREEZABLE)sb_end_intwrite (root->fs_info->sb); -put_transaction (cur_trans); -put_transaction (cur_trans); +btrfs_put_transaction (cur_trans); +btrfs_put_transaction (cur_trans);trace_btrfs_transaction_commit (root);
@@ -1667,7 +1667,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,wait_for_commit (root, cur_trans); -put_transaction (cur_trans); +btrfs_put_transaction (cur_trans);return ret; }
@@ -1684,7 +1684,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,wait_for_commit (root, prev_trans); -put_transaction (prev_trans); +btrfs_put_transaction (prev_trans); }else {spin_unlock (&root->fs_info->trans_lock); }
@@ -1883,8 +1883,8 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,list_del_init (&cur_trans->list);spin_unlock (&root->fs_info->trans_lock); -put_transaction (cur_trans); -put_transaction (cur_trans); +btrfs_put_transaction (cur_trans); +btrfs_put_transaction (cur_trans);if (trans->type & __TRANS_FREEZABLE)sb_end_intwrite (root->fs_info->sb);
fs/btrfs/transaction.h +1 -0
@@ -166,4 +166,5 @@ int btrfs_wait_marked_extents(struct btrfs_root *root, struct extent_io_tree *dirty_pages, int mark);int btrfs_transaction_blocked (struct btrfs_fs_info *info);int btrfs_transaction_in_commit (struct btrfs_fs_info *info); +void btrfs_put_transaction (struct btrfs_transaction *transaction);#endif
Signature · 1 line
2.0.0
PATCH 29/181 Btrfs: fix BUG_ON() casued by the reserved space migration
In reply to Jiri SlabyFrom: Miao Xie <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 20dd2cbf01888a91fdd921403040a710b275a1ff upstream.
When we did space balance and snapshot creation at the same time, we might meet the following oops:
kernel BUG at fs/btrfs/inode.c:3038!
[SNIP]
Call Trace: [<ffffffffa0411ec7>] btrfs_orphan_cleanup+0x293/0x407 [btrfs] [<ffffffffa042dc45>] btrfs_mksubvol.isra.28+0x259/0x373 [btrfs] [<ffffffffa042de85>] btrfs_ioctl_snap_create_transid+0x126/0x156 [btrfs] [<ffffffffa042dff1>] btrfs_ioctl_snap_create_v2+0xd0/0x121 [btrfs] [<ffffffffa0430b2c>] btrfs_ioctl+0x414/0x1854 [btrfs] [<ffffffff813b60b7>] ? __do_page_fault+0x305/0x379 [<ffffffff811215a9>] vfs_ioctl+0x1d/0x39 [<ffffffff81121d7c>] do_vfs_ioctl+0x32d/0x3e2 [<ffffffff81057fe7>] ? finish_task_switch+0x80/0xb8 [<ffffffff81121e88>] SyS_ioctl+0x57/0x83 [<ffffffff813b39ff>] ? do_device_not_available+0x12/0x14 [<ffffffff813b99c2>] system_call_fastpath+0x16/0x1b [SNIP] RIP [<ffffffffa040da40>] btrfs_orphan_add+0xc3/0x126 [btrfs]
The reason of the problem is that the relocation root creation stole the reserved space, which was reserved for orphan item deletion.
There are several ways to fix this problem, one is to increasing the reserved space size of the space balace, and then we can use that space to create the relocation tree for each fs/file trees. But it is hard to calculate the suitable size because we doesn't know how many fs/file trees we need relocate.
We fixed this problem by reserving the space for relocation root creation actively since the space it need is very small (one tree block, used for root node copy), then we use that reserved space to create the relocation tree. If we don't reserve space for relocation tree creation, we will use the reserved space of the balance.
--- fs/btrfs/relocation.c | 6 ++++-- fs/btrfs/transaction.c | 24 +++++++++++++++++++++++- fs/btrfs/transaction.h | 1 + 3 files changed, 28 insertions(+), 3 deletions(-)
fs/btrfs/relocation.c +4 -2
@@ -1383,6 +1383,7 @@ int btrfs_init_reloc_root(struct btrfs_trans_handle *trans, {struct btrfs_root *reloc_root;struct reloc_control *rc = root->fs_info->reloc_ctl; +struct btrfs_block_rsv *rsv;int clear_rsv =0 ;int ret;
@@ -1396,13 +1397,14 @@ int btrfs_init_reloc_root(struct btrfs_trans_handle *trans, root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)return 0 ; -if (!trans->block_rsv) { +if (!trans->reloc_reserved) { + rsv = trans->block_rsv; trans->block_rsv = rc->block_rsv; clear_rsv =1 ; } reloc_root =create_reloc_root (trans, root, root->root_key.objectid);if (clear_rsv) - trans->block_rsv =NULL ; + trans->block_rsv = rsv; ret =__add_reloc_root (reloc_root);BUG_ON (ret <0 );
fs/btrfs/transaction.c +23 -1
@@ -353,6 +353,17 @@ static int may_wait_transaction(struct btrfs_root *root, int type)return 0 ; } +static inline bool need_reserve_reloc_root (struct btrfs_root *root) +{ +if (!root->fs_info->reloc_ctl || + !root->ref_cows || + root->root_key.objectid ==BTRFS_TREE_RELOC_OBJECTID || + root->reloc_root) +return false; + +return true; +} +static struct btrfs_trans_handle *start_transaction (struct btrfs_root *root,u64 num_items,unsigned int type,enum btrfs_reserve_flush_enum flush)
@@ -360,8 +371,9 @@ start_transaction(struct btrfs_root *root, u64 num_items, unsigned int type,struct btrfs_trans_handle *h;struct btrfs_transaction *cur_trans;u64 num_bytes =0 ; -int ret;u64 qgroup_reserved =0 ; +bool reloc_reserved = false; +int ret;if (test_bit (BTRFS_FS_STATE_ERROR , &root->fs_info->fs_state))return ERR_PTR (-EROFS );
@@ -390,6 +402,14 @@ start_transaction(struct btrfs_root *root, u64 num_items, unsigned int type, } num_bytes =btrfs_calc_trans_metadata_size (root, num_items); +/* +* Do the reservation for the relocation root creation +*/ +if (unlikely (need_reserve_reloc_root (root))) { + num_bytes += root->nodesize; + reloc_reserved = true; + } + ret =btrfs_block_rsv_add (root, &root->fs_info->trans_block_rsv, num_bytes, flush);
@@ -451,6 +471,7 @@ again: h->delayed_ref_elem.seq =0 ; h->type = type; h->allocating_chunk = false; + h->reloc_reserved = false;INIT_LIST_HEAD (&h->qgroup_ref_list);INIT_LIST_HEAD (&h->new_bgs);
@@ -466,6 +487,7 @@ again: h->transid, num_bytes, 1); h->block_rsv = &root->fs_info->trans_block_rsv; h->bytes_reserved = num_bytes; + h->reloc_reserved = reloc_reserved; } h->qgroup_reserved = qgroup_reserved;
fs/btrfs/transaction.h +1 -0
@@ -92,6 +92,7 @@ struct btrfs_trans_handle {short aborted;short adding_csums;bool allocating_chunk; +bool reloc_reserved;unsigned int type;/* * this root is only needed to validate that the root passed to
Signature · 1 line
2.0.0
PATCH 30/181 dlm: keep listening connection alive with sctp mode
In reply to Jiri SlabyFrom: Lidong Zhong <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 883854c5457a97190f7b0ee20f03bcd9664fc0c2 upstream.
The connection struct with nodeid 0 is the listening socket, not a connection to another node. The sctp resend function was not checking that the nodeid was valid (non-zero), so it would mistakenly get and resend on the listening connection when nodeid was zero.
--- fs/dlm/lowcomms.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/dlm/lowcomms.c +5 -0
@@ -617,6 +617,11 @@ static void retry_failed_sctp_send(struct connection *recv_con,int nodeid = sn_send_failed->ssf_info.sinfo_ppid;log_print ("Retry sending %d bytes to node id %d" , len, nodeid); + +if (!nodeid) { +log_print ("Shouldn't resend data via listening connection." ); +return ; + } con =nodeid2con (nodeid,0 );if (!con) {
Signature · 1 line
2.0.0
PATCH 31/181 ocfs2: move dquot_initialize() in ocfs2_delete_inode() somewhat later
In reply to Jiri SlabyFrom: Jan Kara <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit bd62ad7aebd8e8895bb7649ace948040332f27d3 upstream.
Move dquot_initalize() call in ocfs2_delete_inode() after the moment we verify inode is actually a sane one to delete. We certainly don't want to initialize quota for system inodes etc. This also avoids calling into quota code from downconvert thread.
Add more details into the comment why bailing out from ocfs2_delete_inode() when we are in downconvert thread is OK.
--- fs/ocfs2/inode.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
fs/ocfs2/inode.c +9 -7
@@ -814,11 +814,13 @@ static int ocfs2_inode_is_valid_to_delete(struct inode *inode) goto bail; } -/* If we're coming from downconvert_thread we can't go into our own -* voting [hello, deadlock city!], so unforuntately we just -* have to skip deleting this guy. That's OK though because -* the node who's doing the actual deleting should handle it -* anyway. */ +/* +* If we're coming from downconvert_thread we can't go into our own +* voting [hello, deadlock city!] so we cannot delete the inode. But +* since we dropped last inode ref when downconverting dentry lock, +* we cannot have the file open and thus the node doing unlink will +* take care of deleting the inode. +*/ if (current == osb->dc_task) goto bail;
@@ -970,8 +972,6 @@ static void ocfs2_delete_inode(struct inode *inode)if (is_bad_inode (inode) || !OCFS2_I (inode)->ip_blkno) goto bail; -dquot_initialize (inode); -if (!ocfs2_inode_is_valid_to_delete (inode)) {/* It's probably not necessary to truncate_inode_pages * here but we do it for safety anyway (it will most
@@ -980,6 +980,8 @@ static void ocfs2_delete_inode(struct inode *inode) goto bail; } +dquot_initialize (inode); +/* We want to block signals in delete_inode as the lock and * messaging paths may return us -ERESTARTSYS. Which would * cause us to exit early, resulting in inodes being orphaned
Signature · 1 line
2.0.0
PATCH 32/181 quota: provide function to grab quota structure reference
In reply to Jiri SlabyFrom: Jan Kara <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 9f985cb6c45bc3f8b7e161c9658d409d051d576f upstream.
Provide dqgrab() function to get quota structure reference when we are sure it already has at least one active reference. Make use of this function inside quota code.
--- fs/quota/dquot.c | 4 ++-- include/linux/quotaops.h | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-)
fs/quota/dquot.c +2 -2
@@ -528,7 +528,7 @@ restart:if (atomic_read (&dquot->dq_count)) {DEFINE_WAIT (wait); -atomic_inc (&dquot->dq_count); +dqgrab (dquot);prepare_to_wait (&dquot->dq_wait_unused, &wait,TASK_UNINTERRUPTIBLE );spin_unlock (&dq_list_lock);
@@ -632,7 +632,7 @@ int dquot_writeback_dquots(struct super_block *sb, int type)/* Now we have active dquot from which someone is * holding reference so we can safely just increase * use count */ -atomic_inc (&dquot->dq_count); +dqgrab (dquot);spin_unlock (&dq_list_lock);dqstats_inc (DQST_LOOKUPS ); err = sb->dq_op->write_dquot (dquot);
include/linux/quotaops.h +8 -0
@@ -46,6 +46,14 @@ void inode_reclaim_rsv_space(struct inode *inode, qsize_t number);void dquot_initialize (struct inode *inode);void dquot_drop (struct inode *inode);struct dquot *dqget (struct super_block *sb,struct kqid qid); +static inline struct dquot *dqgrab (struct dquot *dquot) +{ +/* Make sure someone else has active reference to dquot */ +WARN_ON_ONCE (!atomic_read (&dquot->dq_count)); +WARN_ON_ONCE (!test_bit (DQ_ACTIVE_B , &dquot->dq_flags)); +atomic_inc (&dquot->dq_count); +return dquot; +}void dqput (struct dquot *dquot); int dquot_scan_active(struct super_block *sb, int (*fn)(struct dquot *dquot, unsigned long priv),
Signature · 1 line
2.0.0
PATCH 33/181 ocfs2: implement delayed dropping of last dquot reference
In reply to Jiri SlabyFrom: Jan Kara <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit e3a767b60fd8a9f5e133f42f4970cff77ec43173 upstream.
We cannot drop last dquot reference from downconvert thread as that creates the following deadlock:
NODE 1 NODE2
holds dentry lock for 'foo'
holds inode lock for GLOBAL_BITMAP_SYSTEM_INODE
dquot_initialize(bar)
ocfs2_dquot_acquire()
ocfs2_inode_lock(USER_QUOTA_SYSTEM_INODE)
...
downconvert thread (triggered from another
node or a different process from NODE2)
ocfs2_dentry_post_unlock()
...
iput(foo)
ocfs2_evict_inode(foo)
ocfs2_clear_inode(foo)
dquot_drop(inode)
...
ocfs2_dquot_release()
ocfs2_inode_lock(USER_QUOTA_SYSTEM_INODE)
- blocks
finds we need more space in
quota file
...
ocfs2_extend_no_holes()
ocfs2_inode_lock(GLOBAL_BITMAP_SYSTEM_INODE)
- deadlocks waiting for
downconvert threadWe solve the problem by postponing dropping of the last dquot reference to a workqueue if it happens from the downconvert thread.
--- fs/ocfs2/ocfs2.h | 5 +++++ fs/ocfs2/quota.h | 2 ++ fs/ocfs2/quota_global.c | 35 +++++++++++++++++++++++++++++++++++ fs/ocfs2/super.c | 8 ++++++++ 4 files changed, 50 insertions(+)
fs/ocfs2/ocfs2.h +5 -0
@@ -30,6 +30,7 @@#include <linux/sched.h> #include <linux/wait.h> #include <linux/list.h> +#include <linux/llist.h> #include <linux/rbtree.h> #include <linux/workqueue.h> #include <linux/kref.h>
@@ -418,6 +419,10 @@ struct ocfs2_superstruct ocfs2_dentry_lock *dentry_lock_list;struct work_struct dentry_lock_work; +/* List of dquot structures to drop last reference to */ +struct llist_head dquot_drop_list; +struct work_struct dquot_drop_work; +wait_queue_head_t osb_mount_event;/* Truncate log info */
fs/ocfs2/quota.h +2 -0
@@ -28,6 +28,7 @@ struct ocfs2_dquot {unsigned int dq_use_count;/* Number of nodes having reference to this entry in global quota file */ s64 dq_origspace;/* Last globally synced space usage */ s64 dq_originodes;/* Last globally synced inode usage */ +struct llist_node list;/* Member of list of dquots to drop */ };/* Description of one chunk to recover in memory */
@@ -110,6 +111,7 @@ int ocfs2_read_quota_phys_block(struct inode *inode, u64 p_block,int ocfs2_create_local_dquot (struct dquot *dquot);int ocfs2_local_release_dquot (handle_t *handle,struct dquot *dquot);int ocfs2_local_write_dquot (struct dquot *dquot); +void ocfs2_drop_dquot_refs (struct work_struct *work);extern const struct dquot_operations ocfs2_quota_operations;extern struct quota_format_type ocfs2_quota_format;
fs/ocfs2/quota_global.c +35 -0
@@ -10,6 +10,7 @@#include <linux/jiffies.h> #include <linux/writeback.h> #include <linux/workqueue.h> +#include <linux/llist.h> #include <cluster/masklog.h>
@@ -679,6 +680,27 @@ static int ocfs2_calc_qdel_credits(struct super_block *sb, int type)OCFS2_INODE_UPDATE_CREDITS ; } +void ocfs2_drop_dquot_refs (struct work_struct *work) +{ + struct ocfs2_super *osb = container_of(work, struct ocfs2_super, + dquot_drop_work); +struct llist_node *list; +struct ocfs2_dquot *odquot, *next_odquot; + + list =llist_del_all (&osb->dquot_drop_list); +llist_for_each_entry_safe (odquot, next_odquot, list, list) { +/* Drop the reference we acquired in ocfs2_dquot_release() */ +dqput (&odquot->dq_dquot); + } +} + +/* +* Called when the last reference to dquot is dropped. If we are called from +* downconvert thread, we cannot do all the handling here because grabbing +* quota lock could deadlock (the node holding the quota lock could need some +* other cluster lock to proceed but with blocked downconvert thread we cannot +* release any lock). +*/ static int ocfs2_release_dquot (struct dquot *dquot) {handle_t *handle;
@@ -694,6 +716,19 @@ static int ocfs2_release_dquot(struct dquot *dquot)/* Check whether we are not racing with some other dqget() */ if (atomic_read (&dquot->dq_count) >1 ) goto out; +/* Running from downconvert thread? Postpone quota processing to wq */ +if (current == osb->dc_task) { +/* +* Grab our own reference to dquot and queue it for delayed +* dropping. Quota code rechecks after calling +* ->release_dquot() and won't free dquot structure. +*/ +dqgrab (dquot); +/* First entry on list -> queue work */ +if (llist_add (&OCFS2_DQUOT (dquot)->list, &osb->dquot_drop_list)) +queue_work (ocfs2_wq, &osb->dquot_drop_work); + goto out; + } status =ocfs2_lock_global_qf (oinfo,1 );if (status <0 ) goto out;
fs/ocfs2/super.c +8 -0
@@ -1945,6 +1945,11 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err)ocfs2_disable_quotas (osb); +/* All dquots should be freed by now */ +WARN_ON (!llist_empty (&osb->dquot_drop_list)); +/* Wait for worker to be done with the work structure in osb */ +cancel_work_sync (&osb->dquot_drop_work); +ocfs2_shutdown_local_alloc (osb);ocfs2_truncate_log_shutdown (osb);
@@ -2275,6 +2280,9 @@ static int ocfs2_initialize_super(struct super_block *sb,INIT_WORK (&osb->dentry_lock_work, ocfs2_drop_dl_inodes); osb->dentry_lock_list =NULL ; +INIT_WORK (&osb->dquot_drop_work, ocfs2_drop_dquot_refs); +init_llist_head (&osb->dquot_drop_list); +/* get some pseudo constants for clustersize bits */ osb->s_clustersize_bits =le32_to_cpu (di->id2.i_super.s_clustersize_bits);
Signature · 1 line
2.0.0
PATCH 34/181 ocfs2: avoid blocking in ocfs2_mark_lockres_freeing() in downconvert thread
In reply to Jiri SlabyFrom: Jan Kara <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 84d86f83f9d0e8431a3c9eae4c47e9d7ff49a411 upstream.
If we are dropping last inode reference from downconvert thread, we will end up calling ocfs2_mark_lockres_freeing() which can block if the lock we are freeing is queued thus creating an A-A deadlock. Luckily, since we are the downconvert thread, we can immediately dequeue the lock and thus avoid waiting in this case.
--- fs/ocfs2/dlmglue.c | 44 +++++++++++++++++++++++++++++++++++++++++--- fs/ocfs2/dlmglue.h | 3 ++- fs/ocfs2/inode.c | 7 ++++--- 3 files changed, 47 insertions(+), 7 deletions(-)
fs/ocfs2/dlmglue.c +41 -3
@@ -3142,22 +3142,60 @@ out:return 0 ; } +static void ocfs2_process_blocked_lock (struct ocfs2_super *osb, +struct ocfs2_lock_res *lockres); +/* Mark the lockres as being dropped. It will no longer be * queued if blocking, but we still may have to wait on it * being dequeued from the downconvert thread before we can consider * it safe to drop. * * You can *not* attempt to call cluster_lock on this lockres anymore. */ -void ocfs2_mark_lockres_freeing (struct ocfs2_lock_res *lockres) +void ocfs2_mark_lockres_freeing (struct ocfs2_super *osb, +struct ocfs2_lock_res *lockres) {int status;struct ocfs2_mask_waiter mw; -unsigned long flags; +unsigned long flags, flags2;ocfs2_init_mask_waiter (&mw);spin_lock_irqsave (&lockres->l_lock, flags); lockres->l_flags |=OCFS2_LOCK_FREEING ; +if (lockres->l_flags &OCFS2_LOCK_QUEUED && current == osb->dc_task) { +/* +* We know the downconvert is queued but not in progress +* because we are the downconvert thread and processing +* different lock. So we can just remove the lock from the +* queue. This is not only an optimization but also a way +* to avoid the following deadlock: +* ocfs2_dentry_post_unlock() +* ocfs2_dentry_lock_put() +* ocfs2_drop_dentry_lock() +* iput() +* ocfs2_evict_inode() +* ocfs2_clear_inode() +* ocfs2_mark_lockres_freeing() +* ... blocks waiting for OCFS2_LOCK_QUEUED +* since we are the downconvert thread which +* should clear the flag. +*/ +spin_unlock_irqrestore (&lockres->l_lock, flags); +spin_lock_irqsave (&osb->dc_task_lock, flags2); +list_del_init (&lockres->l_blocked_list); + osb->blocked_lock_count--; +spin_unlock_irqrestore (&osb->dc_task_lock, flags2); +/* +* Warn if we recurse into another post_unlock call. Strictly +* speaking it isn't a problem but we need to be careful if +* that happens (stack overflow, deadlocks, ...) so warn if +* ocfs2 grows a path for which this can happen. +*/ +WARN_ON_ONCE (lockres->l_ops->post_unlock); +/* Since the lock is freeing we don't do much in the fn below */ +ocfs2_process_blocked_lock (osb, lockres); +return ; + }while (lockres->l_flags &OCFS2_LOCK_QUEUED ) {lockres_add_mask_waiter (lockres, &mw,OCFS2_LOCK_QUEUED ,0 );spin_unlock_irqrestore (&lockres->l_lock, flags);
@@ -3178,7 +3216,7 @@ void ocfs2_simple_drop_lockres(struct ocfs2_super *osb, {int ret; -ocfs2_mark_lockres_freeing (lockres); +ocfs2_mark_lockres_freeing (osb, lockres); ret =ocfs2_drop_lock (osb, lockres);if (ret)mlog_errno (ret);
fs/ocfs2/dlmglue.h +2 -1
@@ -157,7 +157,8 @@ int ocfs2_refcount_lock(struct ocfs2_refcount_tree *ref_tree, int ex);void ocfs2_refcount_unlock (struct ocfs2_refcount_tree *ref_tree,int ex); -void ocfs2_mark_lockres_freeing (struct ocfs2_lock_res *lockres); +void ocfs2_mark_lockres_freeing (struct ocfs2_super *osb, +struct ocfs2_lock_res *lockres);void ocfs2_simple_drop_lockres (struct ocfs2_super *osb,struct ocfs2_lock_res *lockres);
fs/ocfs2/inode.c +4 -3
@@ -1069,6 +1069,7 @@ static void ocfs2_clear_inode(struct inode *inode) {int status;struct ocfs2_inode_info *oi =OCFS2_I (inode); +struct ocfs2_super *osb =OCFS2_SB (inode->i_sb);clear_inode (inode); trace_ocfs2_clear_inode((unsigned long long)oi->ip_blkno,
@@ -1085,9 +1086,9 @@ static void ocfs2_clear_inode(struct inode *inode)/* Do these before all the other work so that we don't bounce * the downconvert thread while waiting to destroy the locks. */ -ocfs2_mark_lockres_freeing (&oi->ip_rw_lockres); -ocfs2_mark_lockres_freeing (&oi->ip_inode_lockres); -ocfs2_mark_lockres_freeing (&oi->ip_open_lockres); +ocfs2_mark_lockres_freeing (osb, &oi->ip_rw_lockres); +ocfs2_mark_lockres_freeing (osb, &oi->ip_inode_lockres); +ocfs2_mark_lockres_freeing (osb, &oi->ip_open_lockres);ocfs2_resv_discard (&OCFS2_SB (inode->i_sb)->osb_la_resmap, &oi->ip_la_data_resv);
Signature · 1 line
2.0.0
PATCH 35/181 ocfs2: revert iput deferring code in ocfs2_drop_dentry_lock
In reply to Jiri SlabyFrom: Goldwyn Rodrigues <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 8ed6b23709b346f7bfc1edab47003a205a6a9f69 upstream.
The following patches are reverted in this patch because these patches caused performance regression in the remote unlink() calls.
ea455f8ab683 - ocfs2: Push out dropping of dentry lock to ocfs2_wq f7b1aa69be13 - ocfs2: Fix deadlock on umount 5fd131893793 - ocfs2: Don't oops in ocfs2_kill_sb on a failed mount
Previous patches in this series removed the possible deadlocks from downconvert thread so the above patches shouldn't be needed anymore.
The regression is caused because these patches delay the iput() in case of dentry unlocks. This also delays the unlocking of the open lockres. The open lockresource is required to test if the inode can be wiped from disk or not. When the deleting node does not get the open lock, it marks it as orphan (even though it is not in use by another node/process) and causes a journal checkpoint. This delays operations following the inode eviction. This also moves the inode to the orphaned inode which further causes more I/O and a lot of unneccessary orphans.
The following script can be used to generate the load causing issues:
declare -a create
declare -a remove
declare -a iterations=(1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384)
unique="`mktemp -u XXXXX`"
script="/tmp/idontknow-${unique}.sh"
cat <<EOF > "${script}"
for n in {1..8}; do mkdir -p test/dir\${n}
eval touch test/dir\${n}/foo{1.."\$1"}
done
EOF
chmod 700 "${script}"
function fcreate ()
{
exec 2>&1 /usr/bin/time --format=%E "${script}" "$1"
}
function fremove ()
{
exec 2>&1 /usr/bin/time --format=%E ssh node2 "cd `pwd`; rm -Rf test*"
}
function fcp ()
{
exec 2>&1 /usr/bin/time --format=%E ssh node3 "cd `pwd`; cp -R test test.new"
}
echo -------------------------------------------------
echo "| # files | create #s | copy #s | remove #s |"
echo -------------------------------------------------
for ((x=0; x < ${#iterations[*]} ; x++)) do
create[$x]="`fcreate ${iterations[$x]}`"
copy[$x]="`fcp ${iterations[$x]}`"
remove[$x]="`fremove`"
printf "| %8d | %9s | %9s | %9s |\n" ${iterations[$x]} ${create[$x]} ${copy[$x]} ${remove[$x]}
done
rm "${script}"
echo "------------------------"--- fs/ocfs2/dcache.c | 61 +++---------------------------------------------------- fs/ocfs2/dcache.h | 12 +---------- fs/ocfs2/ocfs2.h | 28 ++++--------------------- fs/ocfs2/super.c | 30 +-------------------------- 4 files changed, 9 insertions(+), 122 deletions(-)
fs/ocfs2/dcache.c +3 -58
@@ -37,7 +37,6 @@#include "dlmglue.h" #include "file.h" #include "inode.h" -#include "super.h" #include "ocfs2_trace.h" void ocfs2_dentry_attach_gen (struct dentry *dentry)
@@ -346,52 +345,6 @@ out_attach:return ret; } -DEFINE_SPINLOCK (dentry_list_lock); - -/* We limit the number of dentry locks to drop in one go. We have -* this limit so that we don't starve other users of ocfs2_wq. */ -#define DL_INODE_DROP_COUNT 64 - -/* Drop inode references from dentry locks */ -static void __ocfs2_drop_dl_inodes (struct ocfs2_super *osb,int drop_count) -{ -struct ocfs2_dentry_lock *dl; - -spin_lock (&dentry_list_lock); -while (osb->dentry_lock_list && (drop_count <0 || drop_count--)) { - dl = osb->dentry_lock_list; - osb->dentry_lock_list = dl->dl_next; -spin_unlock (&dentry_list_lock); -iput (dl->dl_inode); -kfree (dl); -spin_lock (&dentry_list_lock); - } -spin_unlock (&dentry_list_lock); -} - -void ocfs2_drop_dl_inodes (struct work_struct *work) -{ - struct ocfs2_super *osb = container_of(work, struct ocfs2_super, - dentry_lock_work); - -__ocfs2_drop_dl_inodes (osb,DL_INODE_DROP_COUNT ); -/* -* Don't queue dropping if umount is in progress. We flush the -* list in ocfs2_dismount_volume -*/ -spin_lock (&dentry_list_lock); -if (osb->dentry_lock_list && - !ocfs2_test_osb_flag (osb,OCFS2_OSB_DROP_DENTRY_LOCK_IMMED )) -queue_work (ocfs2_wq, &osb->dentry_lock_work); -spin_unlock (&dentry_list_lock); -} - -/* Flush the whole work queue */ -void ocfs2_drop_all_dl_inodes (struct ocfs2_super *osb) -{ -__ocfs2_drop_dl_inodes (osb,-1 ); -} -/* * ocfs2_dentry_iput() and friends. *
@@ -416,24 +369,16 @@ void ocfs2_drop_all_dl_inodes(struct ocfs2_super *osb)static void ocfs2_drop_dentry_lock (struct ocfs2_super *osb,struct ocfs2_dentry_lock *dl) { +iput (dl->dl_inode);ocfs2_simple_drop_lockres (osb, &dl->dl_lockres);ocfs2_lock_res_free (&dl->dl_lockres); - -/* We leave dropping of inode reference to ocfs2_wq as that can -* possibly lead to inode deletion which gets tricky */ -spin_lock (&dentry_list_lock); -if (!osb->dentry_lock_list && - !ocfs2_test_osb_flag (osb,OCFS2_OSB_DROP_DENTRY_LOCK_IMMED )) -queue_work (ocfs2_wq, &osb->dentry_lock_work); - dl->dl_next = osb->dentry_lock_list; - osb->dentry_lock_list = dl; -spin_unlock (&dentry_list_lock); +kfree (dl); }void ocfs2_dentry_lock_put (struct ocfs2_super *osb,struct ocfs2_dentry_lock *dl) { -int unlock; +int unlock =0 ;BUG_ON (dl->dl_count ==0 );
fs/ocfs2/dcache.h +1 -11
@@ -29,13 +29,8 @@extern const struct dentry_operations ocfs2_dentry_ops;struct ocfs2_dentry_lock { -/* Use count of dentry lock */ unsigned int dl_count; -union { -/* Linked list of dentry locks to release */ -struct ocfs2_dentry_lock *dl_next; -u64 dl_parent_blkno; - }; +u64 dl_parent_blkno;/* * The ocfs2_dentry_lock keeps an inode reference until
@@ -49,14 +44,9 @@ struct ocfs2_dentry_lock {int ocfs2_dentry_attach_lock (struct dentry *dentry,struct inode *inode,u64 parent_blkno); -extern spinlock_t dentry_list_lock; -void ocfs2_dentry_lock_put (struct ocfs2_super *osb,struct ocfs2_dentry_lock *dl); -void ocfs2_drop_dl_inodes (struct work_struct *work); -void ocfs2_drop_all_dl_inodes (struct ocfs2_super *osb); -struct dentry *ocfs2_find_local_alias (struct inode *inode,u64 parent_blkno,int skip_unhashed);
fs/ocfs2/ocfs2.h +4 -24
@@ -275,19 +275,16 @@ enum ocfs2_mount_options OCFS2_MOUNT_HB_GLOBAL = 1 << 14, /* Global heartbeat */ }; -#define OCFS2_OSB_SOFT_RO 0x0001 -#define OCFS2_OSB_HARD_RO 0x0002 -#define OCFS2_OSB_ERROR_FS 0x0004 -#define OCFS2_OSB_DROP_DENTRY_LOCK_IMMED 0x0008 - -#define OCFS2_DEFAULT_ATIME_QUANTUM 60 +#define OCFS2_OSB_SOFT_RO 0x0001 +#define OCFS2_OSB_HARD_RO 0x0002 +#define OCFS2_OSB_ERROR_FS 0x0004 +#define OCFS2_DEFAULT_ATIME_QUANTUM 60struct ocfs2_journal ;struct ocfs2_slot_info ;struct ocfs2_recovery_map ;struct ocfs2_replay_map ;struct ocfs2_quota_recovery ; -struct ocfs2_dentry_lock ;struct ocfs2_super {struct task_struct *commit_task;
@@ -414,11 +411,6 @@ struct ocfs2_superstruct list_head blocked_lock_list;unsigned long blocked_lock_count; -/* List of dentry locks to release. Anyone can add locks to -* the list, ocfs2_wq processes the list */ -struct ocfs2_dentry_lock *dentry_lock_list; -struct work_struct dentry_lock_work; -/* List of dquot structures to drop last reference to */ struct llist_head dquot_drop_list;struct work_struct dquot_drop_work;
@@ -583,18 +575,6 @@ static inline void ocfs2_set_osb_flag(struct ocfs2_super *osb,spin_unlock (&osb->osb_lock); } - -static inline unsigned long ocfs2_test_osb_flag (struct ocfs2_super *osb, -unsigned long flag) -{ -unsigned long ret; - -spin_lock (&osb->osb_lock); - ret = osb->osb_flags & flag; -spin_unlock (&osb->osb_lock); -return ret; -} -static inline void ocfs2_set_ro_flag (struct ocfs2_super *osb,int hard) {
fs/ocfs2/super.c +1 -29
@@ -1238,30 +1238,11 @@ static struct dentry *ocfs2_mount(struct file_system_type *fs_type,return mount_bdev (fs_type, flags, dev_name, data, ocfs2_fill_super); } -static void ocfs2_kill_sb (struct super_block *sb) -{ -struct ocfs2_super *osb =OCFS2_SB (sb); - -/* Failed mount? */ -if (!osb ||atomic_read (&osb->vol_state) ==VOLUME_DISABLED ) - goto out; - -/* Prevent further queueing of inode drop events */ -spin_lock (&dentry_list_lock); -ocfs2_set_osb_flag (osb,OCFS2_OSB_DROP_DENTRY_LOCK_IMMED ); -spin_unlock (&dentry_list_lock); -/* Wait for work to finish and/or remove it */ -cancel_work_sync (&osb->dentry_lock_work); -out: -kill_block_super (sb); -} -static struct file_system_type ocfs2_fs_type = { .owner =THIS_MODULE , .name ="ocfs2" , .mount = ocfs2_mount, - .kill_sb = ocfs2_kill_sb, - + .kill_sb = kill_block_super, .fs_flags =FS_REQUIRES_DEV |FS_RENAME_DOES_D_MOVE , .next =NULL };
@@ -1934,12 +1915,6 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err)debugfs_remove (osb->osb_ctxt); -/* -* Flush inode dropping work queue so that deletes are -* performed while the filesystem is still working -*/ -ocfs2_drop_all_dl_inodes (osb); -/* Orphan scan should be stopped as early as possible */ ocfs2_orphan_scan_stop (osb);
@@ -2277,9 +2252,6 @@ static int ocfs2_initialize_super(struct super_block *sb,INIT_WORK (&journal->j_recovery_work, ocfs2_complete_recovery); journal->j_state =OCFS2_JOURNAL_FREE ; -INIT_WORK (&osb->dentry_lock_work, ocfs2_drop_dl_inodes); - osb->dentry_lock_list =NULL ; -INIT_WORK (&osb->dquot_drop_work, ocfs2_drop_dquot_refs);init_llist_head (&osb->dquot_drop_list);
Signature · 1 line
2.0.0
PATCH 36/181 xfs: fix the wrong new_size/rnew_size at xfs_iext_realloc_direct()
In reply to Jiri SlabyFrom: Jie Liu <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 17ec81c15fd022842f9bc947841ba9fb9eb52591 upstream.
At xfs_iext_realloc_direct(), the new_size is changed by adding if_bytes if originally the extent records are stored at the inline extent buffer, and we have to switch from it to a direct extent list for those new allocated extents, this is wrong. e.g,
Create a file with three extents which was showing as following,
xfs_io -f -c "truncate 100m" /xfs/testme
for i in $(seq 0 5 10); do
offset=$(($i * $((1 << 20)))) xfs_io -c "pwrite $offset 1m" /xfs/testme
done
Inline
------
irec: if_bytes bytes_diff new_size
1st 0 16 16
2nd 16 16 32
Switching
--------- rnew_size
3rd 32 16 48 + 32 = 80 roundup=128
In this case, the desired value of new_size should be 48, and then it will be roundup to 64 and be assigned to rnew_size.
However, this issue has been covered by resetting the if_bytes to the new_size which is calculated at the begnning of xfs_iext_add() before leaving out this function, and in turn make the rnew_size correctly again. Hence, this can not be detected via xfstestes.
This patch fix above problem and revise the new_size comments at xfs_iext_realloc_direct() to make it more readable. Also, fix the comments while switching from the inline extent buffer to a direct extent list to reflect this change.
--- fs/xfs/xfs_inode_fork.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
fs/xfs/xfs_inode_fork.c +2 -7
@@ -1359,7 +1359,7 @@ xfs_iext_remove_indirect(void xfs_iext_realloc_direct (xfs_ifork_t *ifp,/* inode fork pointer */ -int new_size)/* new size of extents */ +int new_size)/* new size of extents after adding */ {int rnew_size;/* real new size of extents */
@@ -1397,13 +1397,8 @@ xfs_iext_realloc_direct( rnew_size - ifp->if_real_bytes); } } -/* -* Switch from the inline extent buffer to a direct -* extent list. Be sure to include the inline extent -* bytes in new_size. -*/ +/* Switch from the inline extent buffer to a direct extent list */ else { - new_size += ifp->if_bytes;if (!is_power_of_2 (new_size)) { rnew_size =roundup_pow_of_two (new_size); }
Signature · 1 line
2.0.0
PATCH 37/181 xfs: prevent deadlock trying to cover an active log
In reply to Jiri SlabyFrom: Dave Chinner <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 2c6e24ce1aa6b3b147c75d488c2797ee258eb22b upstream.
Recent analysis of a deadlocked XFS filesystem from a kernel crash dump indicated that the filesystem was stuck waiting for log space. The short story of the hang on the RHEL6 kernel is this:
- the tail of the log is pinned by an inode
- the inode has been pushed by the xfsaild
- the inode has been flushed to it's backing buffer and is currently flush locked and hence waiting for backing buffer IO to complete and remove it from the AIL
- the backing buffer is marked for write - it is on the delayed write queue
- the inode buffer has been modified directly and logged recently due to unlinked inode list modification
- the backing buffer is pinned in memory as it is in the active CIL context.
- the xfsbufd won't start buffer writeback because it is pinned
- xfssyncd won't force the log because it sees the log as needing to be covered and hence wants to issue a dummy transaction to move the log covering state machine along.
Hence there is no trigger to force the CIL to the log and hence unpin the inode buffer and therefore complete the inode IO, remove it from the AIL and hence move the tail of the log along, allowing transactions to start again.
Mainline kernels also have the same deadlock, though the signature is slightly different - the inode buffer never reaches the delayed write lists because xfs_buf_item_push() sees that it is pinned and hence never adds it to the delayed write list that the xfsaild flushes.
There are two possible solutions here. The first is to simply force the log before trying to cover the log and so ensure that the CIL is emptied before we try to reserve space for the dummy transaction in the xfs_log_worker(). While this might work most of the time, it is still racy and is no guarantee that we don't get stuck in xfs_trans_reserve waiting for log space to come free. Hence it's not the best way to solve the problem.
The second solution is to modify xfs_log_need_covered() to be aware of the CIL. We only should be attempting to cover the log if there is no current activity in the log - covering the log is the process of ensuring that the head and tail in the log on disk are identical (i.e. the log is clean and at idle). Hence, by definition, if there are items in the CIL then the log is not at idle and so we don't need to attempt to cover it.
When we don't need to cover the log because it is active or idle, we issue a log force from xfs_log_worker() - if the log is idle, then this does nothing. However, if the log is active due to there being items in the CIL, it will force the items in the CIL to the log and unpin them.
In the case of the above deadlock scenario, instead of xfs_log_worker() getting stuck in xfs_trans_reserve() attempting to cover the log, it will instead force the log, thereby unpinning the inode buffer, allowing IO to be issued and complete and hence removing the inode that was pinning the tail of the log from the AIL. At that point, everything will start moving along again. i.e. the xfs_log_worker turns back into a watchdog that can alleviate deadlocks based around pinned items that prevent the tail of the log from being moved...
--- fs/xfs/xfs_log.c | 48 +++++++++++++++++++++++++++++------------------- fs/xfs/xfs_log_cil.c | 14 ++++++++++++++ fs/xfs/xfs_log_priv.h | 10 ++++------ 3 files changed, 47 insertions(+), 25 deletions(-)
fs/xfs/xfs_log.c +29 -19
@@ -1000,27 +1000,34 @@ xfs_log_space_wake( }/* -* Determine if we have a transaction that has gone to disk -* that needs to be covered. To begin the transition to the idle state -* firstly the log needs to be idle (no AIL and nothing in the iclogs). -* If we are then in a state where covering is needed, the caller is informed -* that dummy transactions are required to move the log into the idle state. +* Determine if we have a transaction that has gone to disk that needs to be +* covered. To begin the transition to the idle state firstly the log needs to +* be idle. That means the CIL, the AIL and the iclogs needs to be empty before +* we start attempting to cover the log. * -* Because this is called as part of the sync process, we should also indicate -* that dummy transactions should be issued in anything but the covered or -* idle states. This ensures that the log tail is accurately reflected in -* the log at the end of the sync, hence if a crash occurrs avoids replay -* of transactions where the metadata is already on disk. +* Only if we are then in a state where covering is needed, the caller is +* informed that dummy transactions are required to move the log into the idle +* state. +* +* If there are any items in the AIl or CIL, then we do not want to attempt to +* cover the log as we may be in a situation where there isn't log space +* available to run a dummy transaction and this can lead to deadlocks when the +* tail of the log is pinned by an item that is modified in the CIL. Hence +* there's no point in running a dummy transaction at this point because we +* can't start trying to idle the log until both the CIL and AIL are empty. */ int xfs_log_need_covered (xfs_mount_t *mp) { -int needed =0 ;struct xlog *log = mp->m_log; +int needed =0 ;if (!xfs_fs_writable (mp))return 0 ; +if (!xlog_cil_empty (log)) +return 0 ; +spin_lock (&log->l_icloglock);switch (log->l_covered_state) {case XLOG_STATE_COVER_DONE :
@@ -1029,14 +1036,17 @@ xfs_log_need_covered(xfs_mount_t *mp)break ;case XLOG_STATE_COVER_NEED :case XLOG_STATE_COVER_NEED2 : -if (!xfs_ail_min_lsn (log->l_ailp) && -xlog_iclogs_empty (log)) { -if (log->l_covered_state ==XLOG_STATE_COVER_NEED ) - log->l_covered_state =XLOG_STATE_COVER_DONE ; -else - log->l_covered_state =XLOG_STATE_COVER_DONE2 ; - } -/* FALLTHRU */ +if (xfs_ail_min_lsn (log->l_ailp)) +break ; +if (!xlog_iclogs_empty (log)) +break ; + + needed =1 ; +if (log->l_covered_state ==XLOG_STATE_COVER_NEED ) + log->l_covered_state =XLOG_STATE_COVER_DONE ; +else + log->l_covered_state =XLOG_STATE_COVER_DONE2 ; +break ;default : needed =1 ;break ;
fs/xfs/xfs_log_cil.c +14 -0
@@ -711,6 +711,20 @@ xlog_cil_push_foreground(xlog_cil_push (log); } +bool +xlog_cil_empty ( +struct xlog *log) +{ +struct xfs_cil *cil = log->l_cilp; +bool empty = false; + +spin_lock (&cil->xc_push_lock); +if (list_empty (&cil->xc_cil)) + empty = true; +spin_unlock (&cil->xc_push_lock); +return empty; +} +/* * Commit a transaction with the given vector to the Committed Item List. *
fs/xfs/xfs_log_priv.h +4 -6
@@ -514,12 +514,10 @@ xlog_assign_grant_head(atomic64_t *head, int cycle, int space)/* * Committed Item List interfaces */ -int -xlog_cil_init (struct xlog *log); -void -xlog_cil_init_post_recovery (struct xlog *log); -void -xlog_cil_destroy (struct xlog *log); +int xlog_cil_init (struct xlog *log); +void xlog_cil_init_post_recovery (struct xlog *log); +void xlog_cil_destroy (struct xlog *log); +bool xlog_cil_empty (struct xlog *log);/* * CIL force routines
Signature · 1 line
2.0.0
PATCH 38/181 xfs: don't emit corruption noise on fs probes
In reply to Jiri SlabyFrom: Eric Sandeen <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 31625f28ad7be67701dc4cefcf52087addd88af4 upstream.
If we get EWRONGFS due to probing of non-xfs filesystems, there's no need to issue the scary corruption error and backtrace.
--- fs/xfs/xfs_sb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/xfs/xfs_sb.c +3 -2
@@ -633,8 +633,9 @@ xfs_sb_read_verify( out_error:if (error) { -XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , - mp, bp->b_addr); +if (error !=EWRONGFS ) +XFS_CORRUPTION_ERROR (__func__,XFS_ERRLEVEL_LOW , + mp, bp->b_addr);xfs_buf_ioerror (bp, error); } }
Signature · 1 line
2.0.0
PATCH 39/181 xfs: don't break from growfs ag update loop on error
In reply to Jiri SlabyFrom: Eric Sandeen <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 59e5a0e821d838854b3afd030d31f82cee3ecd58 upstream.
When xfs_growfs_data_private() is updating backup superblocks, it bails out on the first error encountered, whether reading or writing:
* If we get an error writing out the alternate superblocks,
* just issue a warning and continue. The real work is
* already done and committed.
This can cause a problem later during repair, because repair looks at all superblocks, and picks the most prevalent one as correct. If we bail out early in the backup superblock loop, we can end up with more "bad" matching superblocks than good, and a post-growfs repair may revert the filesystem to the old geometry.
With the combination of superblock verifiers and old bugs, we're more likely to encounter read errors due to verification.
And perhaps even worse, we don't even properly write any of the newly-added superblocks in the new AGs.
Even with this change, growfs will still say:
xfs_growfs: XFS_IOC_FSGROWFSDATA xfsctl failed: Structure needs cleaning data blocks changed from 319815680 to 335216640
which might be confusing to the user, but it at least communicates that something has gone wrong, and dmesg will probably highlight the need for an xfs_repair.
And this is still best-effort; if verifiers fail on more than half the backup supers, they may still "win" - but that's probably best left to repair to more gracefully handle by doing its own strict verification as part of the backup super "voting."
--- fs/xfs/xfs_fsops.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)
fs/xfs/xfs_fsops.c +13 -9
@@ -153,7 +153,7 @@ xfs_growfs_data_private(xfs_buf_t *bp;int bucket;int dpct; -int error; +int error, saved_error =0 ;xfs_agnumber_t nagcount;xfs_agnumber_t nagimax =0 ;xfs_rfsblock_t nb, nb_mod;
@@ -500,29 +500,33 @@ xfs_growfs_data_private( error =ENOMEM ; } +/* +* If we get an error reading or writing alternate superblocks, +* continue. xfs_repair chooses the "best" superblock based +* on most matches; if we break early, we'll leave more +* superblocks un-updated than updated, and xfs_repair may +* pick them over the properly-updated primary. +*/ if (error) {xfs_warn (mp,"error %d reading secondary superblock for ag %d" , error, agno); -break ; + saved_error = error; +continue ; }xfs_sb_to_disk (XFS_BUF_TO_SBP (bp), &mp->m_sb,XFS_SB_ALL_BITS ); -/* -* If we get an error writing out the alternate superblocks, -* just issue a warning and continue. The real work is -* already done and committed. -*/ error =xfs_bwrite (bp);xfs_buf_relse (bp);if (error) {xfs_warn (mp,"write error %d updating secondary superblock for ag %d" , error, agno); -break ;/* no point in continuing */ + saved_error = error; +continue ; } } -return error; +return saved_error ? saved_error : error; error0:xfs_trans_cancel (tp,XFS_TRANS_ABORT );
Signature · 1 line
2.0.0
PATCH 40/181 xfs: prevent stack overflows from page cache allocation
In reply to Jiri SlabyFrom: Dave Chinner <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit ad22c7a043c2cc6792820e6c5da699935933e87d upstream.
Page cache allocation doesn't always go through ->begin_write and hence we don't always get the opportunity to set the allocation context to GFP_NOFS. Failing to do this means we open up the direct relcaim stack to recurse into the filesystem and consume a significant amount of stack.
On RHEL6.4 kernels we are seeing ra_submit() and generic_file_splice_read() from an nfsd context recursing into the filesystem via the inode cache shrinker and evicting inodes. This is causing truncation to be run (e.g EOF block freeing) and causing bmap btree block merges and free space btree block splits to occur. These btree manipulations are occurring with the call chain already 30 functions deep and hence there is not enough stack space to complete such operations.
To avoid these specific overruns, we need to prevent the page cache allocation from recursing via direct reclaim. We can do that because the allocation functions take the allocation context from that which is stored in the mapping for the inode. We don't set that right now, so the default is GFP_HIGHUSER_MOVABLE, which is effectively a GFP_KERNEL context. We need it to be the equivalent of GFP_NOFS, so when we initialise an inode, set the mapping gfp mask appropriately.
This makes the use of AOP_FLAG_NOFS redundant from other parts of the XFS IO path, so get rid of it.
--- fs/xfs/xfs_aops.c | 3 +-- fs/xfs/xfs_iops.c | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-)
fs/xfs/xfs_aops.c +1 -2
@@ -1569,8 +1569,7 @@ xfs_vm_write_begin(ASSERT (len <=PAGE_CACHE_SIZE ); - page =grab_cache_page_write_begin (mapping, index, - flags |AOP_FLAG_NOFS ); + page =grab_cache_page_write_begin (mapping, index, flags);if (!page)return -ENOMEM ;
fs/xfs/xfs_iops.c +9 -0
@@ -1169,6 +1169,7 @@ xfs_setup_inode( struct xfs_inode *ip) {struct inode *inode = &ip->i_vnode; +gfp_t gfp_mask; inode->i_ino = ip->i_ino; inode->i_state =I_NEW ;
@@ -1229,6 +1230,14 @@ xfs_setup_inode( }/* +* Ensure all page cache allocations are done from GFP_NOFS context to +* prevent direct reclaim recursion back into the filesystem and blowing +* stacks or deadlocking. +*/ + gfp_mask =mapping_gfp_mask (inode->i_mapping); +mapping_set_gfp_mask (inode->i_mapping, (gfp_mask & ~(__GFP_FS))); + +/* * If there is no attribute fork no ACL can exist on this inode, * and it can't have any file capabilities attached to it either. */
Signature · 1 line
2.0.0
PATCH 41/181 xfs: fix possible NULL dereference in xlog_verify_iclog
In reply to Jiri SlabyFrom: "Geyslan G. Bem" <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 643f7c4e5656bd18c769211f933190f7bb738245 upstream.
In xlog_verify_iclog a debug check of the incore log buffers prints an error if icptr is null and then goes on to dereference the pointer regardless. Convert this to an assert so that the intention is clear. This was reported by Coverty.
--- fs/xfs/xfs_log.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
fs/xfs/xfs_log.c +3 -5
@@ -3712,11 +3712,9 @@ xlog_verify_iclog(/* check validity of iclog pointers */ spin_lock (&log->l_icloglock); icptr = log->l_iclog; -for (i=0 ; i < log->l_iclog_bufs; i++) { -if (icptr ==NULL ) -xfs_emerg (log->l_mp,"%s: invalid ptr" , __func__); - icptr = icptr->ic_next; - } +for (i =0 ; i < log->l_iclog_bufs; i++, icptr = icptr->ic_next) +ASSERT (icptr); +if (icptr != log->l_iclog)xfs_emerg (log->l_mp,"%s: corrupt iclog ring" , __func__);spin_unlock (&log->l_icloglock);
Signature · 1 line
2.0.0
PATCH 42/181 xfs: fix the extent count when allocating an new indirection array entry
In reply to Jiri SlabyFrom: Jie Liu <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit bb86d21cba22a045b09d11b71decf5ca7c3d5def upstream.
At xfs_iext_add(), if extent(s) are being appended to the last page in the indirection array and the new extent(s) don't fit in the page, the number of extents(erp->er_extcount) in a new allocated entry should be the minimum value between count and XFS_LINEAR_EXTS, instead of count.
For now, there is no existing test case can demonstrates a problem with the er_extcount being set incorrectly here, but it obviously like a bug.
--- fs/xfs/xfs_inode_fork.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
fs/xfs/xfs_inode_fork.c +4 -5
@@ -1031,15 +1031,14 @@ xfs_iext_add(* the next index needed in the indirection array. */ else { -int count = ext_diff; +uint count = ext_diff;while (count) { erp =xfs_iext_irec_new (ifp, erp_idx); - erp->er_extcount = count; - count -=MIN (count, (int )XFS_LINEAR_EXTS ); -if (count) { + erp->er_extcount =min (count,XFS_LINEAR_EXTS ); + count -= erp->er_extcount; +if (count) erp_idx++; - } } } }
Signature · 1 line
2.0.0
PATCH 43/181 xfs: xfs_remove deadlocks due to inverted AGF vs AGI lock ordering
In reply to Jiri SlabyFrom: Dave Chinner <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 273203699f82667296e1f14344c5a5a6c4600470 upstream.
Removing an inode from the namespace involves removing the directory entry and dropping the link count on the inode. Removing the directory entry can result in locking an AGF (directory blocks were freed) and removing a link count can result in placing the inode on an unlinked list which results in locking an AGI.
The big problem here is that we have an ordering constraint on AGF and AGI locking - inode allocation locks the AGI, then can allocate a new extent for new inodes, locking the AGF after the AGI. Similarly, freeing the inode removes the inode from the unlinked list, requiring that we lock the AGI first, and then freeing the inode can result in an inode chunk being freed and hence freeing disk space requiring that we lock an AGF.
Hence the ordering that is imposed by other parts of the code is AGI before AGF. This means we cannot remove the directory entry before we drop the inode reference count and put it on the unlinked list as this results in a lock order of AGF then AGI, and this can deadlock against inode allocation and freeing. Therefore we must drop the link counts before we remove the directory entry.
This is still safe from a transactional point of view - it is not until we get to xfs_bmap_finish() that we have the possibility of multiple transactions in this operation. Hence as long as we remove the directory entry and drop the link count in the first transaction of the remove operation, there are no transactional constraints on the ordering here.
Change the ordering of the operations in the xfs_remove() function to align the ordering of AGI and AGF locking to match that of the rest of the code.
--- fs/xfs/xfs_inode.c | 72 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 28 deletions(-)
fs/xfs/xfs_inode.c +44 -28
@@ -2370,6 +2370,33 @@ xfs_iunpin_wait(__xfs_iunpin_wait (ip); } +/* +* Removing an inode from the namespace involves removing the directory entry +* and dropping the link count on the inode. Removing the directory entry can +* result in locking an AGF (directory blocks were freed) and removing a link +* count can result in placing the inode on an unlinked list which results in +* locking an AGI. +* +* The big problem here is that we have an ordering constraint on AGF and AGI +* locking - inode allocation locks the AGI, then can allocate a new extent for +* new inodes, locking the AGF after the AGI. Similarly, freeing the inode +* removes the inode from the unlinked list, requiring that we lock the AGI +* first, and then freeing the inode can result in an inode chunk being freed +* and hence freeing disk space requiring that we lock an AGF. +* +* Hence the ordering that is imposed by other parts of the code is AGI before +* AGF. This means we cannot remove the directory entry before we drop the inode +* reference count and put it on the unlinked list as this results in a lock +* order of AGF then AGI, and this can deadlock against inode allocation and +* freeing. Therefore we must drop the link counts before we remove the +* directory entry. +* +* This is still safe from a transactional point of view - it is not until we +* get to xfs_bmap_finish() that we have the possibility of multiple +* transactions in this operation. Hence as long as we remove the directory +* entry and drop the link count in the first transaction of the remove +* operation, there are no transactional constraints on the ordering here. +*/ int xfs_remove( xfs_inode_t *dp,
@@ -2439,6 +2466,7 @@ xfs_remove(/* * If we're removing a directory perform some additional validation. */ + cancel_flags |=XFS_TRANS_ABORT ;if (is_dir) {ASSERT (ip->i_d.di_nlink >=2 );if (ip->i_d.di_nlink !=2 ) {
@@ -2449,31 +2477,16 @@ xfs_remove( error =XFS_ERROR (ENOTEMPTY ); goto out_trans_cancel; } - } -xfs_bmap_init (&free_list, &first_block); - error =xfs_dir_removename (tp, dp, name, ip->i_ino, - &first_block, &free_list, resblks); -if (error) { -ASSERT (error !=ENOENT ); - goto out_bmap_cancel; - } -xfs_trans_ichgtime (tp, dp,XFS_ICHGTIME_MOD |XFS_ICHGTIME_CHG ); - -if (is_dir) { -/* -* Drop the link from ip's "..". -*/ +/* Drop the link from ip's "..". */ error =xfs_droplink (tp, dp);if (error) - goto out_bmap_cancel; + goto out_trans_cancel; -/* -* Drop the "." link from ip to self. -*/ +/* Drop the "." link from ip to self. */ error =xfs_droplink (tp, ip);if (error) - goto out_bmap_cancel; + goto out_trans_cancel; }else {/* * When removing a non-directory we need to log the parent
@@ -2482,20 +2495,24 @@ xfs_remove(*/ xfs_trans_log_inode (tp, dp,XFS_ILOG_CORE ); } +xfs_trans_ichgtime (tp, dp,XFS_ICHGTIME_MOD |XFS_ICHGTIME_CHG ); -/* -* Drop the link from dp to ip. -*/ +/* Drop the link from dp to ip. */ error =xfs_droplink (tp, ip);if (error) - goto out_bmap_cancel; + goto out_trans_cancel; -/* -* Determine if this is the last link while -* we are in the transaction. -*/ +/* Determine if this is the last link while the inode is locked */ link_zero = (ip->i_d.di_nlink ==0 ); +xfs_bmap_init (&free_list, &first_block); + error =xfs_dir_removename (tp, dp, name, ip->i_ino, + &first_block, &free_list, resblks); +if (error) { +ASSERT (error !=ENOENT ); + goto out_bmap_cancel; + } +/* * If this is a synchronous mount, make sure that the * remove transaction goes to disk before returning to
@@ -2525,7 +2542,6 @@ xfs_remove( out_bmap_cancel:xfs_bmap_cancel (&free_list); - cancel_flags |=XFS_TRANS_ABORT ; out_trans_cancel:xfs_trans_cancel (tp, cancel_flags); std_return:
Signature · 1 line
2.0.0
PATCH 44/181 xfs: don't perform discard if the given range length is less than block size
In reply to Jiri SlabyFrom: Jie Liu <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit f9fd0135610084abef6867d984e9951c3099950d upstream.
For discard operation, we should return EINVAL if the given range length is less than a block size, otherwise it will go through the file system to discard data blocks as the end range might be evaluated to -1, e.g, /xfs7: 9811378176 bytes were trimmed
This issue can be triggered via xfstests/generic/288.
Also, it seems to get the request queue pointer via bdev_get_queue() instead of the hard code pointer dereference is not a bad thing.
--- fs/xfs/xfs_discard.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/xfs/xfs_discard.c +3 -2
@@ -158,7 +158,7 @@ xfs_ioc_trim(struct xfs_mount *mp, struct fstrim_range __user *urange) { - struct request_queue *q = mp->m_ddev_targp->bt_bdev->bd_disk->queue; + struct request_queue *q = bdev_get_queue(mp->m_ddev_targp->bt_bdev);unsigned int granularity = q->limits.discard_granularity;struct fstrim_range range;xfs_daddr_t start, end, minlen;
@@ -181,7 +181,8 @@ xfs_ioc_trim(* matter as trimming blocks is an advisory interface. */ if (range.start >=XFS_FSB_TO_B (mp, mp->m_sb.sb_dblocks) || - range.minlen >XFS_FSB_TO_B (mp,XFS_ALLOC_AG_MAX_USABLE (mp))) + range.minlen >XFS_FSB_TO_B (mp,XFS_ALLOC_AG_MAX_USABLE (mp)) || + range.len < mp->m_sb.sb_blocksize)return -XFS_ERROR (EINVAL ); start =BTOBB (range.start);
Signature · 1 line
2.0.0
PATCH 45/181 arch/unicore32/mm/alignment.c: include "asm/pgtable.h" to avoid compiling error
In reply to Jiri SlabyFrom: Chen Gang <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 1ff38c56cbd095c4c0dfa581a859ba3557830f78 upstream.
Need include "asm/pgtable.h" to include "asm-generic/pgtable-nopmd.h", so can let 'pmd_t' defined. The related error with allmodconfig:
CC arch/unicore32/mm/alignment.o
In file included from arch/unicore32/mm/alignment.c:24:
arch/unicore32/include/asm/tlbflush.h:135: error: expected .). before .*. token arch/unicore32/include/asm/tlbflush.h:154: error: expected .). before .*. token In file included from arch/unicore32/mm/alignment.c:27:
arch/unicore32/mm/mm.h:15: error: expected .=., .,., .;., .sm. or ._attribute__. before .*. token arch/unicore32/mm/mm.h:20: error: expected .=., .,., .;., .sm. or ._attribute__. before .*. token arch/unicore32/mm/mm.h:25: error: expected .=., .,., .;., .sm. or ._attribute__. before .*. token make[1]: *** [arch/unicore32/mm/alignment.o] Error 1
make: *** [arch/unicore32/mm] Error 2
--- arch/unicore32/mm/alignment.c | 1 + 1 file changed, 1 insertion(+)
arch/unicore32/mm/alignment.c +1 -0
@@ -21,6 +21,7 @@#include <linux/sched.h> #include <linux/uaccess.h> +#include <asm/pgtable.h> #include <asm/tlbflush.h> #include <asm/unaligned.h>
Signature · 1 line
2.0.0
PATCH 46/181 drivers/video/fbdev/fb-puv3.c: Add header files for function unifb_mmap
In reply to Jiri SlabyFrom: Zhichuang SUN <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
=======
commit fbc6c4a13bbfb420eedfdb26a0a859f9c07e8a7b upstream.
Function unifb_mmap calls functions which are defined in linux/mm.h and asm/pgtable.h
The related error (for unicore32 with unicore32_defconfig):
CC drivers/video/fbdev/fb-puv3.o
drivers/video/fbdev/fb-puv3.c: In function 'unifb_mmap':
drivers/video/fbdev/fb-puv3.c:646: error: implicit declaration of
function 'vm_iomap_memory'
drivers/video/fbdev/fb-puv3.c:646: error: implicit declaration of
function 'pgprot_noncached'
--- drivers/video/fb-puv3.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/video/fb-puv3.c +2 -0
@@ -18,8 +18,10 @@#include <linux/fb.h> #include <linux/init.h> #include <linux/console.h> +#include <linux/mm.h> #include <asm/sizes.h> +#include <asm/pgtable.h> #include <mach/hardware.h> /* Platform_data reserved for unifb registers. */
Signature · 1 line
2.0.0
PATCH 47/181 nfsd: don't try to reuse an expired DRC entry off the list
In reply to Jiri SlabyFrom: Jeff Layton <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit a0ef5e19684f0447da9ff0654a12019c484f57ca upstream.
Currently when we are processing a request, we try to scrape an expired or over-limit entry off the list in preference to allocating a new one from the slab.
This is unnecessarily complicated. Just use the slab layer.
--- fs/nfsd/nfscache.c | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-)
fs/nfsd/nfscache.c +4 -32
@@ -132,13 +132,6 @@ nfsd_reply_cache_alloc(void) }static void -nfsd_reply_cache_unhash (struct svc_cacherep *rp) -{ -hlist_del_init (&rp->c_hash); -list_del_init (&rp->c_lru); -} - -static void nfsd_reply_cache_free_locked (struct svc_cacherep *rp) {if (rp->c_type ==RC_REPLBUFF && rp->c_replvec.iov_base) {
@@ -416,22 +409,8 @@ nfsd_cache_lookup(struct svc_rqst *rqstp)/* * Since the common case is a cache miss followed by an insert, -* preallocate an entry. First, try to reuse the first entry on the LRU -* if it works, then go ahead and prune the LRU list. +* preallocate an entry. */ -spin_lock (&cache_lock); -if (!list_empty (&lru_head)) { - rp = list_first_entry(&lru_head, struct svc_cacherep, c_lru); -if (nfsd_cache_entry_expired (rp) || - num_drc_entries >= max_drc_entries) { -nfsd_reply_cache_unhash (rp); -prune_cache_entries (); - goto search_cache; - } - } - -/* No expired ones available, allocate a new one. */ -spin_unlock (&cache_lock); rp =nfsd_reply_cache_alloc ();spin_lock (&cache_lock);if (likely (rp)) {
@@ -439,7 +418,9 @@ nfsd_cache_lookup(struct svc_rqst *rqstp) drc_mem_usage +=sizeof (*rp); } -search_cache: +/* go ahead and prune the cache */ +prune_cache_entries (); + found =nfsd_cache_search (rqstp, csum);if (found) {if (likely (rp))
@@ -453,15 +434,6 @@ search_cache: goto out; } -/* -* We're keeping the one we just allocated. Are we now over the -* limit? Prune one off the tip of the LRU in trade for the one we -* just allocated if so. -*/ -if (num_drc_entries >= max_drc_entries) -nfsd_reply_cache_free_locked (list_first_entry (&lru_head, - struct svc_cacherep, c_lru)); - nfsdstats.rcmisses++; rqstp->rq_cacherep = rp; rp->c_state =RC_INPROG ;
Signature · 1 line
2.0.0
PATCH 48/181 aio: block io_destroy() until all context requests are completed
In reply to Jiri SlabyFrom: Anatol Pomozov <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit e02ba72aabfade4c9cd6e3263e9b57bf890ad25c upstream.
deletes aio context and all resources related to. It makes sense that no IO operations connected to the context should be running after the context is destroyed. As we removed io_context we have no chance to
get requests status or call io_getevents().
man page for io_destroy says that this function may block until all context's requests are completed. Before kernel 3.11 io_destroy() blocked indeed, but since aio refactoring in 3.11 it is not true anymore.
Here is a pseudo-code that shows a testcase for a race condition discovered in 3.11:
initialize io_context
io_submit(read to buffer)
io_destroy()
// context is destroyed so we can free the resources free(buffers);
// if the buffer is allocated by some other user he'll be surprised // to learn that the buffer still filled by an outstanding operation // from the destroyed io_context
The fix is straight-forward - add a completion struct and wait on it in io_destroy, complete() should be called when number of in-fligh requests reaches zero.
If two or more io_destroy() called for the same context simultaneously then only the first one waits for IO completion, other calls behaviour is undefined.
Tested: ran http://pastebin.com/LrPsQ4RL testcase for several hours and
do not see the race condition anymore.
--- fs/aio.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-)
fs/aio.c +32 -4
@@ -112,6 +112,11 @@ struct kioctx {struct work_struct free_work; +/* +* signals when all in-flight requests are done +*/ +struct completion *requests_done; +struct {/* * This counts the number of available slots in the ringbuffer,
@@ -508,6 +513,10 @@ static void free_ioctx_reqs(struct percpu_ref *ref) { struct kioctx *ctx = container_of(ref, struct kioctx, reqs); +/* At this point we know that there are no any in-flight requests */ +if (ctx->requests_done) +complete (ctx->requests_done); +INIT_WORK (&ctx->free_work, free_ioctx);schedule_work (&ctx->free_work); }
@@ -718,7 +727,8 @@ err:* when the processes owning a context have all exited to encourage * the rapid destruction of the kioctx. */ -static void kill_ioctx (struct mm_struct *mm,struct kioctx *ctx) +static void kill_ioctx (struct mm_struct *mm,struct kioctx *ctx, +struct completion *requests_done) {if (!atomic_xchg (&ctx->dead,1 )) {struct kioctx_table *table;
@@ -747,7 +757,11 @@ static void kill_ioctx(struct mm_struct *mm, struct kioctx *ctx)if (ctx->mmap_size)vm_munmap (ctx->mmap_base, ctx->mmap_size); + ctx->requests_done = requests_done;percpu_ref_kill (&ctx->users); + }else { +if (requests_done) +complete (requests_done); } }
@@ -809,7 +823,7 @@ void exit_aio(struct mm_struct *mm)*/ ctx->mmap_size =0 ; -kill_ioctx (mm, ctx); +kill_ioctx (mm, ctx,NULL ); } }
@@ -1185,7 +1199,7 @@ SYSCALL_DEFINE2(io_setup, unsigned, nr_events, aio_context_t __user *, ctxp)if (!IS_ERR (ioctx)) { ret =put_user (ioctx->user_id, ctxp);if (ret) -kill_ioctx (current->mm, ioctx); +kill_ioctx (current->mm, ioctx,NULL );percpu_ref_put (&ioctx->users); }
@@ -1203,8 +1217,22 @@ SYSCALL_DEFINE1(io_destroy, aio_context_t, ctx) {struct kioctx *ioctx =lookup_ioctx (ctx);if (likely (NULL != ioctx)) { -kill_ioctx (current->mm, ioctx); +struct completion requests_done = +COMPLETION_INITIALIZER_ONSTACK (requests_done); + +/* Pass requests_done to kill_ioctx() where it can be set +* in a thread-safe way. If we try to set it here then we have +* a race condition if two io_destroy() called simultaneously. +*/ +kill_ioctx (current->mm, ioctx, &requests_done);percpu_ref_put (&ioctx->users); + +/* Wait until all IO for the context are done. Otherwise kernel +* keep using user-space buffers even if user thinks the context +* is destroyed. +*/ +wait_for_completion (&requests_done); +return 0 ; }pr_debug ("EINVAL: io_destroy: invalid context id\n" );
Signature · 1 line
2.0.0
PATCH 49/181 nfsd: don't halt scanning the DRC LRU list when there's an RC_INPROG entry
In reply to Jiri SlabyFrom: Jeff Layton <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 1b19453d1c6abcfa7c312ba6c9f11a277568fc94 upstream.
Currently, the DRC cache pruner will stop scanning the list when it hits an entry that is RC_INPROG. It's possible however for a call to take a *very* long time. In that case, we don't want it to block other entries from being pruned if they are expired or we need to trim the cache to get back under the limit.
Fix the DRC cache pruner to just ignore RC_INPROG entries.
--- fs/nfsd/nfscache.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
fs/nfsd/nfscache.c +8 -9
@@ -224,13 +224,6 @@ hash_refile(struct svc_cacherep *rp)hlist_add_head (&rp->c_hash, cache_hash +hash_32 (rp->c_xid, maskbits)); } -static inline bool -nfsd_cache_entry_expired (struct svc_cacherep *rp) -{ -return rp->c_state !=RC_INPROG && -time_after (jiffies, rp->c_timestamp +RC_EXPIRE ); -} -/* * Walk the LRU list and prune off entries that are older than RC_EXPIRE. * Also prune the oldest ones when the total exceeds the max number of entries.
@@ -242,8 +235,14 @@ prune_cache_entries(void)long freed =0 ;list_for_each_entry_safe (rp, tmp, &lru_head, c_lru) { -if (!nfsd_cache_entry_expired (rp) && - num_drc_entries <= max_drc_entries) +/* +* Don't free entries attached to calls that are still +* in-progress, but do keep scanning the list. +*/ +if (rp->c_state ==RC_INPROG ) +continue ; +if (num_drc_entries <= max_drc_entries && +time_before (jiffies, rp->c_timestamp +RC_EXPIRE ))break ;nfsd_reply_cache_free_locked (rp); freed++;
Signature · 1 line
2.0.0
PATCH 50/181 mm: add !pte_present() check on existing hugetlb_entry callbacks
In reply to Jiri SlabyFrom: Naoya Horiguchi <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit d4c54919ed86302094c0ca7d48a8cbd4ee753e92 upstream.
The age table walker doesn't check non-present hugetlb entry in common path, so hugetlb_entry() callbacks must check it. The reason for this behavior is that some callers want to handle it in its own way.
[ I think that reason is bogus, btw - it should just do what the regular
code does, which is to call the "pte_hole()" function for such hugetlb entries - Linus]
However, some callers don't check it now, which causes unpredictable result, for example when we have a race between migrating hugepage and reading /proc/pid/numa_maps. This patch fixes it by adding !pte_present checks on buggy callbacks.
This bug exists for years and got visible by introducing hugepage migration.
ChangeLog v2:
- fix if condition (check !pte_present() instead of pte_present())
--- fs/proc/task_mmu.c | 2 +- mm/mempolicy.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-)
fs/proc/task_mmu.c +1 -1
@@ -1353,7 +1353,7 @@ static int gather_hugetbl_stats(pte_t *pte, unsigned long hmask,struct numa_maps *md;struct page *page; -if (pte_none (*pte)) +if (!pte_present (*pte))return 0 ; page =pte_page (*pte);
mm/mempolicy.c +5 -1
@@ -525,9 +525,13 @@ static void queue_pages_hugetlb_pmd_range(struct vm_area_struct *vma,#ifdef CONFIG_HUGETLB_PAGE int nid;struct page *page; +pte_t entry;spin_lock (&vma->vm_mm->page_table_lock); - page =pte_page (huge_ptep_get ((pte_t *)pmd)); + entry =huge_ptep_get ((pte_t *)pmd); +if (!pte_present (entry)) + goto unlock; + page =pte_page (entry); nid =page_to_nid (page);if (node_isset (nid, *nodes) == !!(flags &MPOL_MF_INVERT )) goto unlock;
Signature · 1 line
2.0.0
PATCH 51/181 serial: 8250_dw: Improve unwritable LCR workaround
In reply to Jiri SlabyFrom: Tim Kryger <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit c49436b657d0a56a6ad90d14a7c3041add7cf64d upstream.
When configured with UART_16550_COMPATIBLE=NO or in versions prior to the introduction of this option, the Designware UART will ignore writes to the LCR if the UART is busy. The current workaround saves a copy of the last written LCR and re-writes it in the ISR for a special interrupt that is raised when a write was ignored.
Unfortunately, interrupts are typically disabled prior to performing a sequence of register writes that include the LCR so the point at which the retry occurs is too late. An example is serial8250_do_set_termios() where an ignored LCR write results in the baud divisor not being set and instead a garbage character is sent out the transmitter.
Furthermore, since serial_port_out() offers no way to indicate failure, a serious effort must be made to ensure that the LCR is actually updated before returning back to the caller. This is difficult, however, as a UART that was busy during the first attempt is likely to still be busy when a subsequent attempt is made unless some extra action is taken.
This updated workaround reads back the LCR after each write to confirm that the new value was accepted by the hardware. Should the hardware ignore a write, the TX/RX FIFOs are cleared and the receive buffer read before attempting to rewrite the LCR out of the hope that doing so will force the UART into an idle state. While this may seem unnecessarily aggressive, writes to the LCR are used to change the baud rate, parity, stop bit, or data length so the data that may be lost is likely not important. Admittedly, this is far from ideal but it seems to be the best that can be done given the hardware limitations.
Lastly, the revised workaround doesn't touch the LCR in the ISR, so it avoids the possibility of a "serial8250: too much work for irq" lock up. This problem is rare in real situations but can be reproduced easily by wiring up two UARTs and running the following commands.
# stty -F /dev/ttyS1 echo # stty -F /dev/ttyS2 echo # cat /dev/ttyS1 & [1] 375 # echo asdf > /dev/ttyS1 asdf
[ 27.700000] serial8250: too much work for irq96 [ 27.700000] serial8250: too much work for irq96 [ 27.710000] serial8250: too much work for irq96 [ 27.710000] serial8250: too much work for irq96 [ 27.720000] serial8250: too much work for irq96 [ 27.720000] serial8250: too much work for irq96 [ 27.730000] serial8250: too much work for irq96 [ 27.730000] serial8250: too much work for irq96 [ 27.740000] serial8250: too much work for irq96
Conflicts:
drivers/tty/serial/8250/8250_dw.c --- drivers/tty/serial/8250/8250_dw.c | 41 ++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-)
drivers/tty/serial/8250/8250_dw.c +32 -9
@@ -56,7 +56,6 @@struct dw8250_data { -int last_lcr;int last_mcr;int line;struct clk *clk;
@@ -76,17 +75,33 @@ static inline int dw8250_modify_msr(struct uart_port *p, int offset, int value)return value; } +static void dw8250_force_idle (struct uart_port *p) +{ +serial8250_clear_and_reinit_fifos (container_of + (p ,struct uart_8250_port ,port )); + (void )p->serial_in (p,UART_RX ); +} +static void dw8250_serial_out (struct uart_port *p,int offset,int value) {struct dw8250_data *d = p->private_data; -if (offset ==UART_LCR ) - d->last_lcr = value; -if (offset ==UART_MCR ) d->last_mcr = value;writeb (value, p->membase + (offset << p->regshift)); + +/* Make sure LCR write wasn't ignored */ +if (offset ==UART_LCR ) { +int tries =1000 ; +while (tries--) { +if (value == p->serial_in (p,UART_LCR )) +return ; +dw8250_force_idle (p); +writeb (value, p->membase + (UART_LCR << p->regshift)); + } +dev_err (p->dev,"Couldn't set LCR to %d\n" , value); + } }static unsigned int dw8250_serial_in (struct uart_port *p,int offset)
@@ -107,13 +122,22 @@ static void dw8250_serial_out32(struct uart_port *p, int offset, int value) {struct dw8250_data *d = p->private_data; -if (offset ==UART_LCR ) - d->last_lcr = value; -if (offset ==UART_MCR ) d->last_mcr = value;writel (value, p->membase + (offset << p->regshift)); + +/* Make sure LCR write wasn't ignored */ +if (offset ==UART_LCR ) { +int tries =1000 ; +while (tries--) { +if (value == p->serial_in (p,UART_LCR )) +return ; +dw8250_force_idle (p); +writel (value, p->membase + (UART_LCR << p->regshift)); + } +dev_err (p->dev,"Couldn't set LCR to %d\n" , value); + } }static unsigned int dw8250_serial_in32 (struct uart_port *p,int offset)
@@ -131,9 +155,8 @@ static int dw8250_handle_irq(struct uart_port *p)if (serial8250_handle_irq (p, iir)) {return 1 ; }else if ((iir &UART_IIR_BUSY ) ==UART_IIR_BUSY ) { -/* Clear the USR and write the LCR again. */ +/* Clear the USR */ (void )p->serial_in (p, d->usr_reg); - p->serial_out (p,UART_LCR , d->last_lcr);return 1 ; }
Signature · 1 line
2.0.0
PATCH 52/181 serial: 8250_dw: Fix LCR workaround regression
In reply to Jiri SlabyFrom: James Hogan <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 6979f8d28049879e6147767d93ba6732c8bd94f4 upstream.
Commit c49436b657d0 (serial: 8250_dw: Improve unwritable LCR workaround) caused a regression. It added a check that the LCR was written properly to detect and workaround the busy quirk, but the behaviour of bit 5 (UART_LCR_SPAR) differs between IP versions 3.00a and 3.14c per the docs. On older versions this caused the check to fail and it would repeatedly force idle and rewrite the LCR register, causing delays and preventing any input from serial being received.
This is fixed by masking out UART_LCR_SPAR before making the comparison.
--- drivers/tty/serial/8250/8250_dw.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_dw.c +4 -2
@@ -95,7 +95,8 @@ static void dw8250_serial_out(struct uart_port *p, int offset, int value)if (offset ==UART_LCR ) {int tries =1000 ;while (tries--) { -if (value == p->serial_in (p,UART_LCR )) +unsigned int lcr = p->serial_in (p,UART_LCR ); +if ((value & ~UART_LCR_SPAR ) == (lcr & ~UART_LCR_SPAR ))return ;dw8250_force_idle (p);writeb (value, p->membase + (UART_LCR << p->regshift));
@@ -131,7 +132,8 @@ static void dw8250_serial_out32(struct uart_port *p, int offset, int value)if (offset ==UART_LCR ) {int tries =1000 ;while (tries--) { -if (value == p->serial_in (p,UART_LCR )) +unsigned int lcr = p->serial_in (p,UART_LCR ); +if ((value & ~UART_LCR_SPAR ) == (lcr & ~UART_LCR_SPAR ))return ;dw8250_force_idle (p);writel (value, p->membase + (UART_LCR << p->regshift));
Signature · 1 line
2.0.0
PATCH 53/181 aio: fix kernel memory disclosure in io_getevents() introduced in v3.10
In reply to Jiri SlabyFrom: Benjamin LaHaise <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit edfbbf388f293d70bf4b7c0bc38774d05e6f711a upstream.
A kernel memory disclosure was introduced in aio_read_events_ring() in v3.10 by commit a31ad380bed817aa25f8830ad23e1a0480fef797. The changes made to aio_read_events_ring() failed to correctly limit the index into ctx->ring_pages[], allowing an attacked to cause the subsequent kmap() of an arbitrary page with a copy_to_user() to copy the contents into userspace. This vulnerability has been assigned CVE-2014-0206. Thanks to Mateusz and Petr for disclosing this issue.
This patch applies to v3.12+. A separate backport is needed for 3.10/3.11.
--- fs/aio.c | 3 +++ 1 file changed, 3 insertions(+)
fs/aio.c +3 -0
@@ -1062,6 +1062,9 @@ static long aio_read_events_ring(struct kioctx *ctx,if (head == tail) goto out; + head %= ctx->nr_events; + tail %= ctx->nr_events; +while (ret < nr) {long avail;struct io_event *ev;
Signature · 1 line
2.0.0
PATCH 54/181 aio: fix aio request leak when events are reaped by userspace
In reply to Jiri SlabyFrom: Benjamin LaHaise <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit f8567a3845ac05bb28f3c1b478ef752762bd39ef upstream.
The aio cleanups and optimizations by kmo that were merged into the 3.10 tree added a regression for userspace event reaping. Specifically, the reference counts are not decremented if the event is reaped in userspace, leading to the application being unable to submit further aio requests. This patch applies to 3.12+. A separate backport is required for 3.10/3.11. This issue was uncovered as part of CVE-2014-0206.
--- fs/aio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/aio.c +1 -2
@@ -1021,6 +1021,7 @@ void aio_complete(struct kiocb *iocb, long res, long res2)/* everything turned out well, dispose of the aiocb. */ kiocb_free (iocb); +put_reqs_available (ctx,1 );/* * We have to order our ring_info tail store above and test
@@ -1103,8 +1104,6 @@ static long aio_read_events_ring(struct kioctx *ctx,flush_dcache_page (ctx->ring_pages[0 ]);pr_debug ("%li h%u t%u\n" , ret, head, tail); - -put_reqs_available (ctx, ret); out:mutex_unlock (&ctx->ring_lock);
Signature · 1 line
2.0.0
PATCH 55/181 mfd: sm501: dbg_regs attribute must be read-only
In reply to Jiri SlabyFrom: Guenter Roeck <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 8a8320c2e78d1b619a8fa8eb5ae946b8691de604 upstream.
Fix:
sm501 sm501: SM501 At b3e00000: Version 050100a0, 8 Mb, IRQ 100 Attribute dbg_regs: write permission without 'store'
------------[ cut here ]------------ WARNING: at drivers/base/core.c:620
dbg_regs does not have a write function and must therefore be marked as read-only.
--- drivers/mfd/sm501.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/sm501.c +1 -1
@@ -1232,7 +1232,7 @@ static ssize_t sm501_dbg_regs(struct device *dev, } -static DEVICE_ATTR(dbg_regs, 0666, sm501_dbg_regs, NULL); +static DEVICE_ATTR(dbg_regs, 0444, sm501_dbg_regs, NULL);/* sm501_init_reg *
Signature · 1 line
2.0.0
PATCH 56/181 KVM: lapic: sync highest ISR to hardware apic on EOI
In reply to Jiri SlabyFrom: Paolo Bonzini <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit fc57ac2c9ca8109ea97fcc594f4be436944230cc upstream.
When Hyper-V enlightenments are in effect, Windows prefers to issue an Hyper-V MSR write to issue an EOI rather than an x2apic MSR write. The Hyper-V MSR write is not handled by the processor, and besides being slower, this also causes bugs with APIC virtualization. The reason is that on EOI the processor will modify the highest in-service interrupt (SVI) field of the VMCS, as explained in section 29.1.4 of the SDM; every other step in EOI virtualization is already done by apic_send_eoi or on VM entry, but this one is missing.
We need to do the same, and be careful not to muck with the isr_count and highest_isr_cache fields that are unused when virtual interrupt delivery is enabled.
--- arch/x86/kvm/lapic.c | 62 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 19 deletions(-)
arch/x86/kvm/lapic.c +43 -19
@@ -360,6 +360,8 @@ static inline void apic_clear_irr(int vec, struct kvm_lapic *apic)static inline void apic_set_isr (int vec,struct kvm_lapic *apic) { +/* Note that we never get here with APIC virtualization enabled. */ +if (!__apic_test_and_set_vector (vec, apic->regs +APIC_ISR )) ++apic->isr_count;BUG_ON (apic->isr_count >MAX_APIC_VECTOR );
@@ -371,12 +373,48 @@ static inline void apic_set_isr(int vec, struct kvm_lapic *apic) apic->highest_isr_cache = vec; } +static inline int apic_find_highest_isr (struct kvm_lapic *apic) +{ +int result; + +/* +* Note that isr_count is always 1, and highest_isr_cache +* is always -1, with APIC virtualization enabled. +*/ +if (!apic->isr_count) +return -1 ; +if (likely (apic->highest_isr_cache !=-1 )) +return apic->highest_isr_cache; + + result =find_highest_vector (apic->regs +APIC_ISR ); +ASSERT (result ==-1 || result >=16 ); + +return result; +} +static inline void apic_clear_isr (int vec,struct kvm_lapic *apic) { -if (__apic_test_and_clear_vector (vec, apic->regs +APIC_ISR )) +struct kvm_vcpu *vcpu; +if (!__apic_test_and_clear_vector (vec, apic->regs +APIC_ISR )) +return ; + + vcpu = apic->vcpu; + +/* +* We do get here for APIC virtualization enabled if the guest +* uses the Hyper-V APIC enlightenment. In this case we may need +* to trigger a new interrupt delivery by writing the SVI field; +* on the other hand isr_count and highest_isr_cache are unused +* and must be left alone. +*/ +if (unlikely (kvm_apic_vid_enabled (vcpu->kvm))) + kvm_x86_ops->hwapic_isr_update (vcpu->kvm, +apic_find_highest_isr (apic)); +else { --apic->isr_count; -BUG_ON (apic->isr_count <0 ); - apic->highest_isr_cache =-1 ; +BUG_ON (apic->isr_count <0 ); + apic->highest_isr_cache =-1 ; + } }int kvm_lapic_find_highest_irr (struct kvm_vcpu *vcpu)
@@ -456,22 +494,6 @@ static void pv_eoi_clr_pending(struct kvm_vcpu *vcpu)__clear_bit (KVM_APIC_PV_EOI_PENDING , &vcpu->arch.apic_attention); } -static inline int apic_find_highest_isr (struct kvm_lapic *apic) -{ -int result; - -/* Note that isr_count is always 1 with vid enabled */ -if (!apic->isr_count) -return -1 ; -if (likely (apic->highest_isr_cache !=-1 )) -return apic->highest_isr_cache; - - result =find_highest_vector (apic->regs +APIC_ISR ); -ASSERT (result ==-1 || result >=16 ); - -return result; -} -void kvm_apic_update_tmr (struct kvm_vcpu *vcpu,u32 *tmr) {struct kvm_lapic *apic = vcpu->arch.apic;
@@ -1605,6 +1627,8 @@ int kvm_get_apic_interrupt(struct kvm_vcpu *vcpu)int vector =kvm_apic_has_interrupt (vcpu);struct kvm_lapic *apic = vcpu->arch.apic; +/* Note that we never get here with APIC virtualization enabled. */ +if (vector ==-1 )return -1 ;
Signature · 1 line
2.0.0
PATCH 57/181 MIPS: KVM: Allocate at least 16KB for exception handlers
In reply to Jiri SlabyFrom: James Hogan <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 7006e2dfda9adfa40251093604db76d7e44263b3 upstream.
Each MIPS KVM guest has its own copy of the KVM exception vector. This contains the TLB refill exception handler at offset 0x000, the general exception handler at offset 0x180, and interrupt exception handlers at offset 0x200 in case Cause_IV=1. A common handler is copied to offset 0x2000 and offset 0x3000 is used for temporarily storing k1 during entry from guest.
However the amount of memory allocated for this purpose is calculated as 0x200 rounded up to the next page boundary, which is insufficient if 4KB pages are in use. This can lead to the common handler at offset 0x2000 being overwritten and infinitely recursive exceptions on the next exit from the guest.
Increase the minimum size from 0x200 to 0x4000 to cover the full use of the page.
--- arch/mips/kvm/kvm_mips.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kvm/kvm_mips.c +1 -1
@@ -303,7 +303,7 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id)if (cpu_has_veic || cpu_has_vint) { size =0x200 +VECTORSPACING *64 ; }else { - size =0x200 ; + size =0x4000 ; }/* Save Linux EBASE */
Signature · 1 line
2.0.0
PATCH 58/181 USB: cdc-acm: fix write and suspend race
In reply to Jiri SlabyFrom: Johan Hovold <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 5a345c20c17d87099224a4be12e69e5bd7023dca upstream.
Fix race between write() and suspend() which could lead to writes being dropped (or I/O while suspended) if the device is runtime suspended while a write request is being processed.
Specifically, suspend() releases the write_lock after determining the device is idle but before incrementing the susp_count, thus leaving a window where a concurrent write() can submit an urb.
that support remote wakeup")
--- drivers/usb/class/cdc-acm.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/usb/class/cdc-acm.c +6 -9
@@ -1420,18 +1420,15 @@ static int acm_suspend(struct usb_interface *intf, pm_message_t message)struct acm *acm =usb_get_intfdata (intf);int cnt; +spin_lock_irq (&acm->read_lock); +spin_lock (&acm->write_lock);if (PMSG_IS_AUTO (message)) { -int b; - -spin_lock_irq (&acm->write_lock); - b = acm->transmitting; -spin_unlock_irq (&acm->write_lock); -if (b) +if (acm->transmitting) { +spin_unlock (&acm->write_lock); +spin_unlock_irq (&acm->read_lock);return -EBUSY ; + } } - -spin_lock_irq (&acm->read_lock); -spin_lock (&acm->write_lock); cnt = acm->susp_count++;spin_unlock (&acm->write_lock);spin_unlock_irq (&acm->read_lock);
Signature · 1 line
2.0.0
PATCH 59/181 USB: cdc-acm: fix write and resume race
In reply to Jiri SlabyFrom: Johan Hovold <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit e144ed28bed10684f9aaec6325ed974d53f76110 upstream.
Fix race between write() and resume() due to improper locking that could lead to writes being reordered.
Resume must be done atomically and susp_count be protected by the write_lock in order to prevent racing with write(). This could otherwise lead to writes being reordered if write() grabs the write_lock after susp_count is decremented, but before the delayed urb is submitted.
that support remote wakeup")
--- drivers/usb/class/cdc-acm.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-)
drivers/usb/class/cdc-acm.c +9 -14
@@ -1447,27 +1447,20 @@ static int acm_resume(struct usb_interface *intf)struct acm *acm =usb_get_intfdata (intf);struct acm_wb *wb;int rv =0 ; -int cnt;spin_lock_irq (&acm->read_lock); - acm->susp_count -=1 ; - cnt = acm->susp_count; -spin_unlock_irq (&acm->read_lock); +spin_lock (&acm->write_lock); -if (cnt) -return 0 ; +if (--acm->susp_count) + goto out;if (test_bit (ASYNCB_INITIALIZED , &acm->port.flags)) { - rv =usb_submit_urb (acm->ctrlurb,GFP_NOIO ); + rv =usb_submit_urb (acm->ctrlurb,GFP_ATOMIC ); -spin_lock_irq (&acm->write_lock);if (acm->delayed_wb) { wb = acm->delayed_wb; acm->delayed_wb =NULL ; -spin_unlock_irq (&acm->write_lock);acm_start_wb (acm, wb); - }else { -spin_unlock_irq (&acm->write_lock); }/*
@@ -1475,12 +1468,14 @@ static int acm_resume(struct usb_interface *intf)* do the write path at all cost */ if (rv <0 ) - goto err_out; + goto out; - rv =acm_submit_read_urbs (acm,GFP_NOIO ); + rv =acm_submit_read_urbs (acm,GFP_ATOMIC ); } +out: +spin_unlock (&acm->write_lock); +spin_unlock_irq (&acm->read_lock); -err_out:return rv; }
Signature · 1 line
2.0.0
PATCH 60/181 USB: cdc-acm: fix broken runtime suspend
In reply to Jiri SlabyFrom: Johan Hovold <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 140cb81ac8c625942a1d695875932c615767a526 upstream.
The current ACM runtime-suspend implementation is broken in several ways:
Firstly, it buffers only the first write request being made while suspended -- any further writes are silently dropped.
Secondly, writes being dropped also leak write urbs, which are never reclaimed (until the device is unbound).
Thirdly, even the single buffered write is not cleared at shutdown (which may happen before the device is resumed), something which can lead to another urb leak as well as a PM usage-counter leak.
Fix this by implementing a delayed-write queue using urb anchors and making sure to discard the queue properly at shutdown.
that support remote wakeup")
--- drivers/usb/class/cdc-acm.c | 32 ++++++++++++++++++++++---------- drivers/usb/class/cdc-acm.h | 2 +- 2 files changed, 23 insertions(+), 11 deletions(-)
drivers/usb/class/cdc-acm.c +22 -10
@@ -559,6 +559,8 @@ static void acm_port_destruct(struct tty_port *port)static void acm_port_shutdown (struct tty_port *port) { struct acm *acm = container_of(port, struct acm, port); +struct urb *urb; +struct acm_wb *wb;int i;dev_dbg (&acm->control->dev,"%s\n" , __func__);
@@ -567,6 +569,16 @@ static void acm_port_shutdown(struct tty_port *port)if (!acm->disconnected) {usb_autopm_get_interface (acm->control);acm_set_control (acm, acm->ctrlout =0 ); + +for (;;) { + urb =usb_get_from_anchor (&acm->delayed); +if (!urb) +break ; + wb = urb->context; + wb->use =0 ; +usb_autopm_put_interface_async (acm->control); + } +usb_kill_urb (acm->ctrlurb);for (i =0 ; i <ACM_NW ; i++)usb_kill_urb (acm->wb[i].urb);
@@ -634,12 +646,9 @@ static int acm_tty_write(struct tty_struct *tty,usb_autopm_get_interface_async (acm->control);if (acm->susp_count) { -if (!acm->delayed_wb) - acm->delayed_wb = wb; -else -usb_autopm_put_interface_async (acm->control); +usb_anchor_urb (wb->urb, &acm->delayed);spin_unlock_irqrestore (&acm->write_lock, flags); -return count;/* A white lie */ +return count; }usb_mark_last_busy (acm->dev);
@@ -1176,6 +1185,7 @@ made_compressed_probe: acm->bInterval = epread->bInterval;tty_port_init (&acm->port); acm->port.ops = &acm_port_ops; +init_usb_anchor (&acm->delayed); buf =usb_alloc_coherent (usb_dev, ctrlsize,GFP_KERNEL , &acm->ctrl_dma);if (!buf) {
@@ -1445,7 +1455,7 @@ static int acm_suspend(struct usb_interface *intf, pm_message_t message)static int acm_resume (struct usb_interface *intf) {struct acm *acm =usb_get_intfdata (intf); -struct acm_wb *wb; +struct urb *urb;int rv =0 ;spin_lock_irq (&acm->read_lock);
@@ -1457,10 +1467,12 @@ static int acm_resume(struct usb_interface *intf)if (test_bit (ASYNCB_INITIALIZED , &acm->port.flags)) { rv =usb_submit_urb (acm->ctrlurb,GFP_ATOMIC ); -if (acm->delayed_wb) { - wb = acm->delayed_wb; - acm->delayed_wb =NULL ; -acm_start_wb (acm, wb); +for (;;) { + urb =usb_get_from_anchor (&acm->delayed); +if (!urb) +break ; + +acm_start_wb (acm, urb->context); }/*
drivers/usb/class/cdc-acm.h +1 -1
@@ -117,7 +117,7 @@ struct acm { unsigned int throttled:1; /* actually throttled */ unsigned int throttle_req:1; /* throttle requested */u8 bInterval; -struct acm_wb *delayed_wb;/* write queued for a device about to be woken */ +struct usb_anchor delayed;/* writes queued for a device about to be woken */ };#define CDC_DATA_INTERFACE_TYPE 0x0a
Signature · 1 line
2.0.0
PATCH 61/181 USB: cdc-acm: fix runtime PM for control messages
In reply to Jiri SlabyFrom: Johan Hovold <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit bae3f4c53585e9a170da9436e0f06919874bda9a upstream.
Fix runtime PM handling of control messages by adding the required PM counter operations.
that support remote wakeup")
--- drivers/usb/class/cdc-acm.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/usb/class/cdc-acm.c +11 -1
@@ -122,13 +122,23 @@ static void acm_release_minor(struct acm *acm)static int acm_ctrl_msg (struct acm *acm,int request,int value,void *buf,int len) { -int retval =usb_control_msg (acm->dev,usb_sndctrlpipe (acm->dev,0 ), +int retval; + + retval =usb_autopm_get_interface (acm->control); +if (retval) +return retval; + + retval =usb_control_msg (acm->dev,usb_sndctrlpipe (acm->dev,0 ), request,USB_RT_ACM , value, acm->control->altsetting[0 ].desc.bInterfaceNumber, buf, len,5000 ); +dev_dbg (&acm->control->dev,"%s - rq 0x%02x, val %#x, len %#x, result %d\n" , __func__, request, value, len, retval); + +usb_autopm_put_interface (acm->control); +return retval <0 ? retval :0 ; }
Signature · 1 line
2.0.0
PATCH 62/181 USB: cdc-acm: fix shutdown and suspend race
In reply to Jiri SlabyFrom: Johan Hovold <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit ed797074031a37bb9bf4a70952fffc606b77274d upstream.
We should stop I/O unconditionally at suspend rather than rely on the tty-port initialised flag (which is set prior to stopping I/O during shutdown) in order to prevent suspend returning with URBs still active.
that support remote wakeup")
--- drivers/usb/class/cdc-acm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/class/cdc-acm.c +1 -2
@@ -1456,8 +1456,7 @@ static int acm_suspend(struct usb_interface *intf, pm_message_t message)if (cnt)return 0 ; -if (test_bit (ASYNCB_INITIALIZED , &acm->port.flags)) -stop_data_traffic (acm); +stop_data_traffic (acm);return 0 ; }
Signature · 1 line
2.0.0
PATCH 63/181 USB: cdc-acm: fix potential urb leak and PM imbalance in write
In reply to Jiri SlabyFrom: Johan Hovold <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 183a45087d126d126e8dd1d9b2602fc129dff9ad upstream.
Make sure to check return value of autopm get in write() in order to avoid urb leak and PM counter imbalance on errors.
that support remote wakeup")
--- drivers/usb/class/cdc-acm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/usb/class/cdc-acm.c +7 -1
@@ -654,7 +654,13 @@ static int acm_tty_write(struct tty_struct *tty,memcpy (wb->buf, buf, count); wb->len = count; -usb_autopm_get_interface_async (acm->control); + stat =usb_autopm_get_interface_async (acm->control); +if (stat) { + wb->use =0 ; +spin_unlock_irqrestore (&acm->write_lock, flags); +return stat; + } +if (acm->susp_count) {usb_anchor_urb (wb->urb, &acm->delayed);spin_unlock_irqrestore (&acm->write_lock, flags);
Signature · 1 line
2.0.0
PATCH 64/181 USB: cdc-acm: fix I/O after failed open
In reply to Jiri SlabyFrom: Johan Hovold <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit e4c36076c2a6195ec62c35b03c3fde84d0087dc8 upstream.
Make sure to kill any already submitted read urbs on read-urb submission failures in open in order to prevent doing I/O for a closed port.
--- drivers/usb/class/cdc-acm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/class/cdc-acm.c +3 -0
@@ -494,6 +494,7 @@ static int acm_port_activate(struct tty_port *port, struct tty_struct *tty) { struct acm *acm = container_of(port, struct acm, port);int retval = -ENODEV ; +int i;dev_dbg (&acm->control->dev,"%s\n" , __func__);
@@ -542,6 +543,8 @@ static int acm_port_activate(struct tty_port *port, struct tty_struct *tty)return 0 ; error_submit_read_urbs: +for (i =0 ; i < acm->rx_buflimit; i++) +usb_kill_urb (acm->read_urbs[i]); acm->ctrlout =0 ;acm_set_control (acm, acm->ctrlout); error_set_control:
Signature · 1 line
2.0.0
PATCH 65/181 USB: cdc-acm: fix runtime PM imbalance at shutdown
In reply to Jiri SlabyFrom: Johan Hovold <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 5292afa657d0e790b7479ad8eef9450c1e040b3d upstream.
Make sure only to decrement the PM counters if they were actually incremented.
Note that the USB PM counter, but not necessarily the driver core PM counter, is reset when the interface is unbound.
that support remote wakeup")
--- drivers/usb/class/cdc-acm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/usb/class/cdc-acm.c +4 -2
@@ -575,12 +575,13 @@ static void acm_port_shutdown(struct tty_port *port)struct urb *urb;struct acm_wb *wb;int i; +int pm_err;dev_dbg (&acm->control->dev,"%s\n" , __func__);mutex_lock (&acm->mutex);if (!acm->disconnected) { -usb_autopm_get_interface (acm->control); + pm_err =usb_autopm_get_interface (acm->control);acm_set_control (acm, acm->ctrlout =0 );for (;;) {
@@ -598,7 +599,8 @@ static void acm_port_shutdown(struct tty_port *port)for (i =0 ; i < acm->rx_buflimit; i++)usb_kill_urb (acm->read_urbs[i]); acm->control->needs_remote_wakeup =0 ; -usb_autopm_put_interface (acm->control); +if (!pm_err) +usb_autopm_put_interface (acm->control); }mutex_unlock (&acm->mutex); }
Signature · 1 line
2.0.0
PATCH 66/181 Drivers: hv: balloon: Ensure pressure reports are posted regularly
In reply to Jiri SlabyFrom: "K. Y. Srinivasan" <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit ae339336dc950b9b05e7ccd3565dd3e8781c06d9 upstream.
The current code posts periodic memory pressure status from a dedicated thread. Under some conditions, especially when we are releasing a lot of memory into the guest, we may not send timely pressure reports back to the host. Fix this issue by reporting pressure in all contexts that can be active in this driver.
--- drivers/hv/hv_balloon.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
drivers/hv/hv_balloon.c +26 -3
@@ -19,6 +19,7 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/kernel.h> +#include <linux/jiffies.h> #include <linux/mman.h> #include <linux/delay.h> #include <linux/init.h>
@@ -459,6 +460,11 @@ static bool do_hot_add;*/ static uint pressure_report_delay =45 ; +/* +* The last time we posted a pressure report to host. +*/ +static unsigned long last_post_time; +module_param (hot_add, bool, (S_IRUGO |S_IWUSR ));MODULE_PARM_DESC (hot_add,"If set attempt memory hot_add" );
@@ -542,6 +548,7 @@ struct hv_dynmem_device {static struct hv_dynmem_device dm_device; +static void post_status (struct hv_dynmem_device *dm);#ifdef CONFIG_MEMORY_HOTPLUG static void hv_bring_pgs_online (unsigned long start_pfn,unsigned long size)
@@ -612,7 +619,7 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size,* have not been "onlined" within the allowed time. */ wait_for_completion_timeout (&dm_device.ol_waitevent,5 *HZ ); - +post_status (&dm_device); }return ;
@@ -951,11 +958,17 @@ static void post_status(struct hv_dynmem_device *dm) {struct dm_status status;struct sysinfo val; +unsigned long now = jiffies; +unsigned long last_post = last_post_time;if (pressure_report_delay >0 ) { --pressure_report_delay;return ; } + +if (!time_after (now, (last_post_time +HZ ))) +return ; +si_meminfo (&val);memset (&status,0 ,sizeof (struct dm_status )); status.hdr.type =DM_STATUS_REPORT ;
@@ -983,6 +996,14 @@ static void post_status(struct hv_dynmem_device *dm)if (status.hdr.trans_id !=atomic_read (&trans_id))return ; +/* +* If the last post time that we sampled has changed, +* we have raced, don't post the status. +*/ +if (last_post != last_post_time) +return ; + + last_post_time = jiffies; vmbus_sendpacket(dm->dev->channel, &status, sizeof(struct dm_status), (unsigned long)NULL,
@@ -1117,7 +1138,7 @@ static void balloon_up(struct work_struct *dummy)if (ret == -EAGAIN )msleep (20 ); - +post_status (&dm_device); }while (ret == -EAGAIN );if (ret) {
@@ -1144,8 +1165,10 @@ static void balloon_down(struct hv_dynmem_device *dm,struct dm_unballoon_response resp;int i; -for (i =0 ; i < range_count; i++) +for (i =0 ; i < range_count; i++) {free_balloon_pages (dm, &range_array[i]); +post_status (&dm_device); + }if (req->more_pages ==1 )return ;
Signature · 1 line
2.0.0
PATCH 67/181 ASoC: max98090: Fix reset at resume time
In reply to Jiri SlabyFrom: Liam Girdwood <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 25b4ab430f8e166c9b63f4db28e7e812d5a59396 upstream.
Reset needs to wait 20ms before other codec IO is performed. This wait was not being performed. Fix this by making sure the reset register is not restored with the cache, but use the manual reset method in resume with the wait.
--- sound/soc/codecs/max98090.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/codecs/max98090.c +3 -0
@@ -255,6 +255,7 @@ static struct reg_default max98090_reg[] = {static bool max98090_volatile_register (struct device *dev,unsigned int reg) {switch (reg) { +case M98090_REG_SOFTWARE_RESET :case M98090_REG_DEVICE_STATUS :case M98090_REG_JACK_STATUS :case M98090_REG_REVISION_ID :
@@ -2360,6 +2361,8 @@ static int max98090_runtime_resume(struct device *dev)regcache_cache_only (max98090->regmap, false); +max98090_reset (max98090); +regcache_sync (max98090->regmap);return 0 ;
Signature · 1 line
2.0.0
PATCH 68/181 ASoC: tlv320aci3x: Fix custom snd_soc_dapm_put_volsw_aic3x() function
In reply to Jiri SlabyFrom: Peter Ujfalusi <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit e6c111fac4464e3f4bf7b3802b517dafc80f8e0f upstream.
For some unknown reason the parameters for snd_soc_test_bits() were in wrong order:
It was:snd_soc_test_bits(codec, val, mask, reg); /* WRONG!!! */
while it should be:snd_soc_test_bits(codec, reg, mask, val);
--- sound/soc/codecs/tlv320aic3x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/tlv320aic3x.c +1 -1
@@ -164,7 +164,7 @@ static int snd_soc_dapm_put_volsw_aic3x(struct snd_kcontrol *kcontrol, mask <<= shift; val <<= shift; - change =snd_soc_test_bits (codec, val, mask, reg); + change =snd_soc_test_bits (codec, reg, mask, val);if (change) { update.kcontrol = kcontrol; update.reg = reg;
Signature · 1 line
2.0.0
PATCH 69/181 staging: iio: tsl2x7x_core: fix proximity treshold
In reply to Jiri SlabyFrom: Mario Schuknecht <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit c404618cd06dad771495fe1cf9d5a63b5664f65f upstream.
Consider high byte of proximity min and max treshold in function 'tsl2x7x_chip_on'. So far, the high byte was not set.
--- drivers/staging/iio/light/tsl2x7x_core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/staging/iio/light/tsl2x7x_core.c +6 -2
@@ -672,9 +672,13 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev) chip->tsl2x7x_config[TSL2X7X_PRX_COUNT ] = chip->tsl2x7x_settings.prox_pulse_count; chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHLO ] = - chip->tsl2x7x_settings.prox_thres_low; + (chip->tsl2x7x_settings.prox_thres_low) &0xFF ; + chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHHI ] = + (chip->tsl2x7x_settings.prox_thres_low >>8 ) &0xFF ; chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHLO ] = - chip->tsl2x7x_settings.prox_thres_high; + (chip->tsl2x7x_settings.prox_thres_high) &0xFF ; + chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHHI ] = + (chip->tsl2x7x_settings.prox_thres_high >>8 ) &0xFF ;/* and make sure we're not already on */ if (chip->tsl2x7x_chip_status ==TSL2X7X_CHIP_WORKING ) {
Signature · 1 line
2.0.0
PATCH 70/181 iio: adc: at91: signedness bug in at91_adc_get_trigger_value_by_name()
In reply to Jiri SlabyFrom: Dan Carpenter <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 4f3bcd878f1d3c730fe00f619b7260c6125d49eb upstream.
at91_adc_get_trigger_value_by_name() was returning -ENOMEM truncated to a positive u8 and that doesn't work. I've changed it to int and refactored it to preserve the error code.
--- drivers/iio/adc/at91_adc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/iio/adc/at91_adc.c +8 -8
@@ -166,12 +166,11 @@ static int at91_adc_channel_init(struct iio_dev *idev)return idev->num_channels; } -static u8 at91_adc_get_trigger_value_by_name (struct iio_dev *idev, +static int at91_adc_get_trigger_value_by_name (struct iio_dev *idev,struct at91_adc_trigger *triggers,const char *trigger_name) {struct at91_adc_state *st =iio_priv (idev); -u8 value =0 ;int i;for (i =0 ; i < st->trigger_number; i++) {
@@ -184,15 +183,16 @@ static u8 at91_adc_get_trigger_value_by_name(struct iio_dev *idev,return -ENOMEM ;if (strcmp (trigger_name, name) ==0 ) { - value = triggers[i].value;kfree (name); -break ; +if (triggers[i].value ==0 ) +return -EINVAL ; +return triggers[i].value; }kfree (name); } -return value; +return -EINVAL ; }static int at91_adc_configure_trigger (struct iio_trigger *trig,bool state)
@@ -202,14 +202,14 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)struct iio_buffer *buffer = idev->buffer;struct at91_adc_reg_desc *reg = st->registers;u32 status =at91_adc_readl (st, reg->trigger_register); -u8 value; +int value;u8 bit; value =at91_adc_get_trigger_value_by_name (idev, st->trigger_list, idev->trig->name); -if (value ==0 ) -return -EINVAL ; +if (value <0 ) +return value;if (state) { st->buffer =kmalloc (idev->scan_bytes,GFP_KERNEL );
Signature · 1 line
2.0.0
PATCH 71/181 iio: Fix endianness issue in ak8975_read_axis()
In reply to Jiri SlabyFrom: Peter Meerwald <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 8ba42fb7b17649c9ab5b5e79d4e90370a0b4645e upstream.
i2c_smbus_read_word_data() does host endian conversion already, no need for le16_to_cpu()
--- drivers/iio/magnetometer/ak8975.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/iio/magnetometer/ak8975.c +1 -8
@@ -352,8 +352,6 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val) {struct ak8975_data *data =iio_priv (indio_dev);struct i2c_client *client = data->client; -u16 meas_reg; -s16 raw;int ret;mutex_lock (&data->lock);
@@ -401,16 +399,11 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val)dev_err (&client->dev,"Read axis data fails\n" ); goto exit; } - meas_reg = ret;mutex_unlock (&data->lock); -/* Endian conversion of the measured values. */ - raw = (s16) (le16_to_cpu (meas_reg)); -/* Clamp to valid range. */ - raw =clamp_t (s16, raw,-4096 ,4095 ); - *val = raw; + *val =clamp_t (s16, ret,-4096 ,4095 );return IIO_VAL_INT ; exit:
Signature · 1 line
2.0.0
PATCH 72/181 lzo: properly check for overruns
In reply to Jiri SlabyFrom: Greg Kroah-Hartman <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 206a81c18401c0cde6e579164f752c4b147324ce upstream.
The lzo decompressor can, if given some really crazy data, possibly overrun some variable types. Modify the checking logic to properly detect overruns before they happen.
--- lib/lzo/lzo1x_decompress_safe.c | 62 +++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 21 deletions(-)
lib/lzo/lzo1x_decompress_safe.c +41 -21
@@ -19,11 +19,31 @@#include <linux/lzo.h> #include "lzodefs.h" -#define HAVE_IP (x) ((size_t)(ip_end - ip) >= (size_t)(x)) -#define HAVE_OP (x) ((size_t)(op_end - op) >= (size_t)(x)) -#define NEED_IP (x) if (!HAVE_IP(x)) goto input_overrun -#define NEED_OP (x) if (!HAVE_OP(x)) goto output_overrun -#define TEST_LB (m_pos) if ((m_pos) < out) goto lookbehind_overrun +#define HAVE_IP (t, x) \ + (((size_t)(ip_end - ip) >= (size_t)(t + x)) && \ + (((t + x) >= t) && ((t + x) >= x))) + +#define HAVE_OP (t, x) \ + (((size_t)(op_end - op) >= (size_t)(t + x)) && \ + (((t + x) >= t) && ((t + x) >= x))) + +#define NEED_IP (t, x) \ + do { \ + if (!HAVE_IP(t, x)) \ + goto input_overrun; \ + } while (0) + +#define NEED_OP (t, x) \ + do { \ + if (!HAVE_OP(t, x)) \ + goto output_overrun; \ + } while (0) + +#define TEST_LB (m_pos) \ + do { \ + if ((m_pos) < out) \ + goto lookbehind_overrun; \ + } while (0)int lzo1x_decompress_safe (const unsigned char *in,size_t in_len,unsigned char *out,size_t *out_len)
@@ -58,14 +78,14 @@ int lzo1x_decompress_safe(const unsigned char *in, size_t in_len,while (unlikely (*ip ==0 )) { t +=255 ; ip++; -NEED_IP (1 ); +NEED_IP (1 ,0 ); } t +=15 + *ip++; } t +=3 ; copy_literal_run:#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS ) -if (likely (HAVE_IP (t +15 ) &&HAVE_OP (t +15 ))) { +if (likely (HAVE_IP (t,15 ) &&HAVE_OP (t,15 ))) {const unsigned char *ie = ip + t;unsigned char *oe = op + t; do {
@@ -81,8 +101,8 @@ copy_literal_run: } else#endif { -NEED_OP (t); -NEED_IP (t +3 ); +NEED_OP (t,0 ); +NEED_IP (t,3 );do { *op++ = *ip++; }while (--t >0 );
@@ -95,7 +115,7 @@ copy_literal_run: m_pos -= t >>2 ; m_pos -= *ip++ <<2 ;TEST_LB (m_pos); -NEED_OP (2 ); +NEED_OP (2 ,0 ); op[0 ] = m_pos[0 ]; op[1 ] = m_pos[1 ]; op +=2 ;
@@ -119,10 +139,10 @@ copy_literal_run:while (unlikely (*ip ==0 )) { t +=255 ; ip++; -NEED_IP (1 ); +NEED_IP (1 ,0 ); } t +=31 + *ip++; -NEED_IP (2 ); +NEED_IP (2 ,0 ); } m_pos = op -1 ; next =get_unaligned_le16 (ip);
@@ -137,10 +157,10 @@ copy_literal_run:while (unlikely (*ip ==0 )) { t +=255 ; ip++; -NEED_IP (1 ); +NEED_IP (1 ,0 ); } t +=7 + *ip++; -NEED_IP (2 ); +NEED_IP (2 ,0 ); } next =get_unaligned_le16 (ip); ip +=2 ;
@@ -154,7 +174,7 @@ copy_literal_run:#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS )if (op - m_pos >=8 ) {unsigned char *oe = op + t; -if (likely (HAVE_OP (t +15 ))) { +if (likely (HAVE_OP (t,15 ))) { do { COPY8(op, m_pos); op += 8;
@@ -164,7 +184,7 @@ copy_literal_run: m_pos +=8 ; }while (op < oe); op = oe; -if (HAVE_IP (6 )) { +if (HAVE_IP (6 ,0 )) { state = next;COPY4 (op, ip); op += next;
@@ -172,7 +192,7 @@ copy_literal_run:continue ; } }else { -NEED_OP (t); +NEED_OP (t,0 );do { *op++ = *m_pos++; }while (op < oe);
@@ -181,7 +201,7 @@ copy_literal_run:#endif {unsigned char *oe = op + t; -NEED_OP (t); +NEED_OP (t,0 ); op[0 ] = m_pos[0 ]; op[1 ] = m_pos[1 ]; op +=2 ;
@@ -194,15 +214,15 @@ match_next: state = next; t = next;#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS ) -if (likely (HAVE_IP (6 ) &&HAVE_OP (4 ))) { +if (likely (HAVE_IP (6 ,0 ) &&HAVE_OP (4 ,0 ))) {COPY4 (op, ip); op += t; ip += t; } else#endif { -NEED_IP (t +3 ); -NEED_OP (t); +NEED_IP (t,3 ); +NEED_OP (t,0 );while (t >0 ) { *op++ = *ip++; t--;
Signature · 1 line
2.0.0
PATCH 73/181 lz4: ensure length does not wrap
In reply to Jiri SlabyFrom: Greg Kroah-Hartman <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 206204a1162b995e2185275167b22468c00d6b36 upstream.
Given some pathologically compressed data, lz4 could possibly decide to wrap a few internal variables, causing unknown things to happen. Catch this before the wrapping happens and abort the decompression.
--- lib/lz4/lz4_decompress.c | 2 ++ 1 file changed, 2 insertions(+)
lib/lz4/lz4_decompress.c +2 -0
@@ -72,6 +72,8 @@ static int lz4_uncompress(const char *source, char *dest, int osize) len = *ip++;for (; len ==255 ; length +=255 ) len = *ip++; +if (unlikely (length > (size_t )(length + len))) + goto _output_error; length += len; }
Signature · 1 line
2.0.0
PATCH 74/181 ALSA: compress: Cancel the optimization of compiler and fix the size of struct for all platform.
In reply to Jiri SlabyFrom: "Wang, Xiaoming" <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 2bd0ae464a6cf7363bbf72c8545e0aa43caa57f0 upstream.
Cancel the optimization of compiler for struct snd_compr_avail which size will be 0x1c in 32bit kernel while 0x20 in 64bit kernel under the optimizer. That will make compaction between 32bit and 64bit. So add packed to fix the size of struct snd_compr_avail to 0x1c for all platform.
--- include/uapi/sound/compress_offload.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/sound/compress_offload.h +1 -1
@@ -80,7 +80,7 @@ struct snd_compr_tstamp {struct snd_compr_avail {__u64 avail;struct snd_compr_tstamp tstamp; -}; +} __attribute__((packed));enum snd_compr_direction {SND_COMPRESS_PLAYBACK =0 ,
Signature · 1 line
2.0.0
PATCH 75/181 ALSA: hda/realtek - Add support of ALC891 codec
In reply to Jiri SlabyFrom: Kailang Yang <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit b6c5fbad16aa5026f508093a8d651c25e1cb6179 upstream.
New codec support for ALC891.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -5134,6 +5134,7 @@ static const struct hda_codec_preset snd_hda_preset_realtek[] = { { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 }, { .id = 0x10ec0671, .name = "ALC671", .patch = patch_alc662 }, { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 }, + { .id = 0x10ec0867, .name = "ALC891", .patch = patch_alc882 }, { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Signature · 1 line
2.0.0
PATCH 76/181 ALSA: hda - Add quirk for external mic on Lifebook U904
In reply to Jiri SlabyFrom: David Henningsson <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 2041d56464a067461d7cc21734a0f024587ed2ff upstream.
According to the bug reporter (Данило Шеган), the external mic starts to work and has proper jack detection if only pin 0x19 is marked properly as an external headset mic.
AlsaInfo at https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/1328587/+attachment/4128991/+files/AlsaInfo.txt
--- sound/pci/hda/patch_realtek.c | 9 +++++++++ 1 file changed, 9 insertions(+)
sound/pci/hda/patch_realtek.c +9 -0
@@ -3689,6 +3689,7 @@ enum {ALC269_FIXUP_HEADSET_MIC ,ALC269_FIXUP_QUANTA_MUTE ,ALC269_FIXUP_LIFEBOOK , +ALC269_FIXUP_LIFEBOOK_EXTMIC ,ALC269_FIXUP_AMIC ,ALC269_FIXUP_DMIC , ALC269VB_FIXUP_AMIC,
@@ -3806,6 +3807,13 @@ static const struct hda_fixup alc269_fixups[] = { .chained = true, .chain_id =ALC269_FIXUP_QUANTA_MUTE }, + [ALC269_FIXUP_LIFEBOOK_EXTMIC] = { + .type = HDA_FIXUP_PINS, + .v.pins = (const struct hda_pintbl []) { + {0x19 ,0x01a1903c },/* headset mic, with jack detect */ + { } + }, + }, [ALC269_FIXUP_AMIC] = { .type = HDA_FIXUP_PINS, .v.pins = (const struct hda_pintbl []) {
@@ -4105,6 +4113,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x104d ,0x9084 ,"Sony VAIO" ,ALC275_FIXUP_SONY_HWEQ ),SND_PCI_QUIRK_VENDOR (0x104d ,"Sony VAIO" ,ALC269_FIXUP_SONY_VAIO ),SND_PCI_QUIRK (0x10cf ,0x1475 ,"Lifebook" ,ALC269_FIXUP_LIFEBOOK ), +SND_PCI_QUIRK (0x10cf ,0x1845 ,"Lifebook U904" ,ALC269_FIXUP_LIFEBOOK_EXTMIC ),SND_PCI_QUIRK (0x17aa ,0x20f2 ,"Thinkpad SL410/510" ,ALC269_FIXUP_SKU_IGNORE ),SND_PCI_QUIRK (0x17aa ,0x215e ,"Thinkpad L512" ,ALC269_FIXUP_SKU_IGNORE ), SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
Signature · 1 line
2.0.0
PATCH 77/181 ALSA: control: Protect user controls against concurrent access
In reply to Jiri SlabyFrom: Lars-Peter Clausen <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 07f4d9d74a04aa7c72c5dae0ef97565f28f17b92 upstream.
The user-control put and get handlers as well as the tlv do not protect against concurrent access from multiple threads. Since the state of the control is not updated atomically it is possible that either two write operations or a write and a read operation race against each other. Both can lead to arbitrary memory disclosure. This patch introduces a new lock that protects user-controls from concurrent access. Since applications typically access controls sequentially than in parallel a single lock per card should be fine.
--- include/sound/core.h | 2 ++ sound/core/control.c | 31 +++++++++++++++++++++++++------ sound/core/init.c | 1 + 3 files changed, 28 insertions(+), 6 deletions(-)
include/sound/core.h +2 -0
@@ -121,6 +121,8 @@ struct snd_card {int user_ctl_count;/* count of all user controls */ struct list_head controls;/* all controls for this card */ struct list_head ctl_files;/* active control files */ +struct mutex user_ctl_lock;/* protects user controls against +concurrent access */ struct snd_info_entry *proc_root;/* root for soundcard specific files */ struct snd_info_entry *proc_id;/* the card id */
sound/core/control.c +25 -6
@@ -992,6 +992,7 @@ static int snd_ctl_elem_unlock(struct snd_ctl_file *file,struct user_element {struct snd_ctl_elem_info info; +struct snd_card *card;void *elem_data;/* element data */ unsigned long elem_data_size;/* size of element data in bytes */ void *tlv_data;/* TLV data */
@@ -1035,7 +1036,9 @@ static int snd_ctl_elem_user_get(struct snd_kcontrol *kcontrol, {struct user_element *ue = kcontrol->private_data; +mutex_lock (&ue->card->user_ctl_lock);memcpy (&ucontrol->value, ue->elem_data, ue->elem_data_size); +mutex_unlock (&ue->card->user_ctl_lock);return 0 ; }
@@ -1044,10 +1047,12 @@ static int snd_ctl_elem_user_put(struct snd_kcontrol *kcontrol, {int change;struct user_element *ue = kcontrol->private_data; - + +mutex_lock (&ue->card->user_ctl_lock); change =memcmp (&ucontrol->value, ue->elem_data, ue->elem_data_size) !=0 ;if (change)memcpy (ue->elem_data, &ucontrol->value, ue->elem_data_size); +mutex_unlock (&ue->card->user_ctl_lock);return change; }
@@ -1067,19 +1072,32 @@ static int snd_ctl_elem_user_tlv(struct snd_kcontrol *kcontrol, new_data =memdup_user (tlv, size);if (IS_ERR (new_data))return PTR_ERR (new_data); +mutex_lock (&ue->card->user_ctl_lock); change = ue->tlv_data_size != size;if (!change) change =memcmp (ue->tlv_data, new_data, size);kfree (ue->tlv_data); ue->tlv_data = new_data; ue->tlv_data_size = size; +mutex_unlock (&ue->card->user_ctl_lock); }else { -if (! ue->tlv_data_size || ! ue->tlv_data) -return -ENXIO ; -if (size < ue->tlv_data_size) -return -ENOSPC ; +int ret =0 ; + +mutex_lock (&ue->card->user_ctl_lock); +if (!ue->tlv_data_size || !ue->tlv_data) { + ret = -ENXIO ; + goto err_unlock; + } +if (size < ue->tlv_data_size) { + ret = -ENOSPC ; + goto err_unlock; + }if (copy_to_user (tlv, ue->tlv_data, ue->tlv_data_size)) -return -EFAULT ; + ret = -EFAULT ; +err_unlock: +mutex_unlock (&ue->card->user_ctl_lock); +if (ret) +return ret; }return change; }
@@ -1211,6 +1229,7 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file, ue =kzalloc (sizeof (struct user_element ) + private_size,GFP_KERNEL );if (ue ==NULL )return -ENOMEM ; + ue->card = card; ue->info = *info; ue->info.access =0 ; ue->elem_data = (char *)ue +sizeof (*ue);
sound/core/init.c +1 -0
@@ -215,6 +215,7 @@ int snd_card_create(int idx, const char *xid,INIT_LIST_HEAD (&card->devices);init_rwsem (&card->controls_rwsem);rwlock_init (&card->ctl_files_rwlock); +mutex_init (&card->user_ctl_lock);INIT_LIST_HEAD (&card->controls);INIT_LIST_HEAD (&card->ctl_files);spin_lock_init (&card->files_lock);
Signature · 1 line
2.0.0
PATCH 78/181 ALSA: control: Fix replacing user controls
In reply to Jiri SlabyFrom: Lars-Peter Clausen <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 82262a46627bebb0febcc26664746c25cef08563 upstream.
There are two issues with the current implementation for replacing user controls. The first is that the code does not check if the control is actually a user control and neither does it check if the control is owned by the process that tries to remove it. That allows userspace applications to remove arbitrary controls, which can cause a user after free if a for example a driver does not expect a control to be removed from under its feed.
The second issue is that on one hand when a control is replaced the user_ctl_count limit is not checked and on the other hand the user_ctl_count is increased (even though the number of user controls does not change). This allows userspace, once the user_ctl_count limit as been reached, to repeatedly replace a control until user_ctl_count overflows. Once that happens new controls can be added effectively bypassing the user_ctl_count limit.
Both issues can be fixed by instead of open-coding the removal of the control that is to be replaced to use snd_ctl_remove_user_ctl(). This function does proper permission checks as well as decrements user_ctl_count after the control has been removed.
Note that by using snd_ctl_remove_user_ctl() the check which returns -EBUSY at beginning of the function if the control already exists is removed. This is not a problem though since the check is quite useless, because the lock that is protecting the control list is released between the check and before adding the new control to the list, which means that it is possible that a different control with the same settings is added to the list after the check. Luckily there is another check that is done while holding the lock in snd_ctl_add(), so we'll rely on that to make sure that the same control is not added twice.
--- sound/core/control.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)
sound/core/control.c +9 -16
@@ -1155,8 +1155,6 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file,struct user_element *ue;int idx, err; -if (!replace && card->user_ctl_count >=MAX_USER_CONTROLS ) -return -ENOMEM ;if (info->count <1 )return -EINVAL ; access = info->access == 0 ? SNDRV_CTL_ELEM_ACCESS_READWRITE :
@@ -1165,21 +1163,16 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file, SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE)); info->id.numid =0 ;memset (&kctl,0 ,sizeof (kctl)); -down_write (&card->controls_rwsem); - _kctl =snd_ctl_find_id (card, &info->id); - err =0 ; -if (_kctl) { -if (replace) - err =snd_ctl_remove (card, _kctl); -else - err = -EBUSY ; - }else { -if (replace) - err = -ENOENT ; + +if (replace) { + err =snd_ctl_remove_user_ctl (file, &info->id); +if (err) +return err; } -up_write (&card->controls_rwsem); -if (err <0 ) -return err; + +if (card->user_ctl_count >=MAX_USER_CONTROLS ) +return -ENOMEM ; +memcpy (&kctl.id, &info->id,sizeof (info->id)); kctl.count = info->owner ? info->owner :1 ; access |=SNDRV_CTL_ELEM_ACCESS_USER ;
Signature · 1 line
2.0.0
PATCH 79/181 ALSA: control: Don't access controls outside of protected regions
In reply to Jiri SlabyFrom: Lars-Peter Clausen <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit fd9f26e4eca5d08a27d12c0933fceef76ed9663d upstream.
A control that is visible on the card->controls list can be freed at any time. This means we must not access any of its memory while not holding the controls_rw_lock. Otherwise we risk a use after free access.
--- sound/core/control.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
sound/core/control.c +10 -5
@@ -331,6 +331,7 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol) {struct snd_ctl_elem_id id;unsigned int idx; +unsigned int count;int err = -EINVAL ;if (! kcontrol)
@@ -359,8 +360,9 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol) card->controls_count += kcontrol->count; kcontrol->id.numid = card->last_numid +1 ; card->last_numid += kcontrol->count; + count = kcontrol->count;up_write (&card->controls_rwsem); -for (idx =0 ; idx < kcontrol->count; idx++, id.index++, id.numid++) +for (idx =0 ; idx < count; idx++, id.index++, id.numid++)snd_ctl_notify (card,SNDRV_CTL_EVENT_MASK_ADD , &id);return 0 ;
@@ -389,6 +391,7 @@ int snd_ctl_replace(struct snd_card *card, struct snd_kcontrol *kcontrol, bool add_on_replace) {struct snd_ctl_elem_id id; +unsigned int count;unsigned int idx;struct snd_kcontrol *old;int ret;
@@ -424,8 +427,9 @@ add: card->controls_count += kcontrol->count; kcontrol->id.numid = card->last_numid +1 ; card->last_numid += kcontrol->count; + count = kcontrol->count;up_write (&card->controls_rwsem); -for (idx =0 ; idx < kcontrol->count; idx++, id.index++, id.numid++) +for (idx =0 ; idx < count; idx++, id.index++, id.numid++)snd_ctl_notify (card,SNDRV_CTL_EVENT_MASK_ADD , &id);return 0 ;
@@ -898,9 +902,9 @@ static int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file, result = kctl->put (kctl, control); }if (result >0 ) { +struct snd_ctl_elem_id id = control->id;up_read (&card->controls_rwsem); -snd_ctl_notify (card,SNDRV_CTL_EVENT_MASK_VALUE , - &control->id); +snd_ctl_notify (card,SNDRV_CTL_EVENT_MASK_VALUE , &id);return 0 ; } }
@@ -1334,8 +1338,9 @@ static int snd_ctl_tlv_ioctl(struct snd_ctl_file *file, } err = kctl->tlv.c (kctl, op_flag, tlv.length, _tlv->tlv);if (err >0 ) { +struct snd_ctl_elem_id id = kctl->id;up_read (&card->controls_rwsem); -snd_ctl_notify (card,SNDRV_CTL_EVENT_MASK_TLV , &kctl->id); +snd_ctl_notify (card,SNDRV_CTL_EVENT_MASK_TLV , &id);return 0 ; } }else {
Signature · 1 line
2.0.0
PATCH 80/181 ALSA: control: Handle numid overflow
In reply to Jiri SlabyFrom: Lars-Peter Clausen <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit ac902c112d90a89e59916f751c2745f4dbdbb4bd upstream.
Each control gets automatically assigned its numids when the control is created. The allocation is done by incrementing the numid by the amount of allocated numids per allocation. This means that excessive creation and destruction of controls (e.g. via SNDRV_CTL_IOCTL_ELEM_ADD/REMOVE) can cause the id to eventually overflow. Currently when this happens for the control that caused the overflow kctl->id.numid + kctl->count will also over flow causing it to be smaller than kctl->id.numid. Most of the code assumes that this is something that can not happen, so we need to make sure that it won't happen
--- sound/core/control.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/core/control.c +4 -0
@@ -289,6 +289,10 @@ static bool snd_ctl_remove_numid_conflict(struct snd_card *card, {struct snd_kcontrol *kctl; +/* Make sure that the ids assigned to the control do not wrap around */ +if (card->last_numid >=UINT_MAX - count) + card->last_numid =0 ; +list_for_each_entry (kctl, &card->controls, list) {if (kctl->id.numid < card->last_numid +1 + count && kctl->id.numid + kctl->count > card->last_numid +1 ) {
Signature · 1 line
2.0.0
PATCH 81/181 ALSA: control: Make sure that id->index does not overflow
In reply to Jiri SlabyFrom: Lars-Peter Clausen <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 883a1d49f0d77d30012f114b2e19fc141beb3e8e upstream.
The ALSA control code expects that the range of assigned indices to a control is continuous and does not overflow. Currently there are no checks to enforce this. If a control with a overflowing index range is created that control becomes effectively inaccessible and unremovable since snd_ctl_find_id() will not be able to find it. This patch adds a check that makes sure that controls with a overflowing index range can not be created.
--- sound/core/control.c | 3 +++ 1 file changed, 3 insertions(+)
sound/core/control.c +3 -0
@@ -343,6 +343,9 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol)if (snd_BUG_ON (!card || !kcontrol->info)) goto error; id = kcontrol->id; +if (id.index >UINT_MAX - kcontrol->count) + goto error; +down_write (&card->controls_rwsem);if (snd_ctl_find_id (card, &id)) {up_write (&card->controls_rwsem);
Signature · 1 line
2.0.0
PATCH 82/181 ALSA: hda - hdmi: Use TFx channel positions instead of FxH
In reply to Jiri SlabyFrom: Anssi Hannula <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 94908a39ce971f25c3695c334d88eec4d2837428 upstream.
Channel map positions FLH, FCH, FRH duplicate positions TFL, TFC, TFR. Both are the speakers above the front speakers (CEA uses "high" and USB audio uses "top" nomenclature).
Since the USB audio code has used the TFx positions since v3.8 (04324ccc75f96, "ALSA: usb-audio: add channel map support") but the HDMI code only just started using FxH in a5b7d510b2220cccb ("ALSA: hda -
hdmi: Fix channel maps with less common speakers") which is not yet in any released kernel, standardize on TFx instead.
--- sound/pci/hda/patch_hdmi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/pci/hda/patch_hdmi.c +3 -3
@@ -743,12 +743,12 @@ static struct channel_map_table map_tables[] = { { SNDRV_CHMAP_RC, RC }, { SNDRV_CHMAP_FLC, FLC }, { SNDRV_CHMAP_FRC, FRC }, - { SNDRV_CHMAP_FLH, FLH }, - { SNDRV_CHMAP_FRH, FRH }, + { SNDRV_CHMAP_TFL, FLH }, + { SNDRV_CHMAP_TFR, FRH }, { SNDRV_CHMAP_FLW, FLW }, { SNDRV_CHMAP_FRW, FRW }, { SNDRV_CHMAP_TC, TC }, - { SNDRV_CHMAP_FCH, FCH }, + { SNDRV_CHMAP_TFC, FCH }, {} /* terminator */ };
Signature · 1 line
2.0.0
PATCH 83/181 KVM: PPC: Book3S HV: Fix KVM hang with CONFIG_KVM_XICS=n
In reply to Jiri SlabyFrom: Anton Blanchard <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 7505258c5fcb0a1cc3c76a47b4cf9506d21d10e6 upstream.
I noticed KVM is broken when KVM in-kernel XICS emulation (CONFIG_KVM_XICS) is disabled.
The problem was introduced in 48eaef05 (KVM: PPC: Book3S HV: use xics_wake_cpu only when defined). It used CONFIG_KVM_XICS to wrap xics_wake_cpu, where CONFIG_PPC_ICP_NATIVE should have been used.
--- arch/powerpc/kvm/book3s_hv.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/powerpc/kvm/book3s_hv.c +1 -3
@@ -82,7 +82,7 @@ void kvmppc_fast_vcpu_kick(struct kvm_vcpu *vcpu)/* CPU points to the first thread of the core */ if (cpu != me && cpu >=0 && cpu < nr_cpu_ids) { -#ifdef CONFIG_KVM_XICS +#ifdef CONFIG_PPC_ICP_NATIVE int real_cpu = cpu + vcpu->arch.ptid;if (paca[real_cpu].kvm_hstate.xics_phys)xics_wake_cpu (real_cpu);
@@ -1092,9 +1092,7 @@ static void kvmppc_start_thread(struct kvm_vcpu *vcpu)smp_wmb ();#if defined(CONFIG_PPC_ICP_NATIVE ) && defined(CONFIG_SMP )if (vcpu->arch.ptid) { -#ifdef CONFIG_KVM_XICS xics_wake_cpu (cpu); -#endif ++vc->n_woken; }#endif
Signature · 1 line
2.0.0
PATCH 84/181 ACPI / video: clean up DMI table for initial black screen problem
In reply to Jiri SlabyFrom: Aaron Lu <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 545ef368e08fda654b6e63ce522c66339aa29156 upstream.
With commit 2c62333a408f "ACPI / video: Quirk initial backlight level 0" we do not need to have the following systems in DMI table, so remove them. HP Pavilion m4, HP 1000 Notebook PC, HP Pavilion g6 Notebook PC, HP Pavilion dm4, Fujitsu E753, HP Folio 13-2000.
With this change, the use_bios_initial_backlight module parameter is no longer needed and thus removed.
Conflicts:
drivers/acpi/video.c
--- drivers/acpi/video.c | 87 ++++++++-------------------------------------------- 1 file changed, 12 insertions(+), 75 deletions(-)
drivers/acpi/video.c +12 -75
@@ -81,13 +81,6 @@ module_param(brightness_switch_enabled, bool, 0644);static bool allow_duplicates;module_param (allow_duplicates, bool,0644 ); -/* -* Some BIOSes claim they use minimum backlight at boot, -* and this may bring dimming screen after boot -*/ -static bool use_bios_initial_backlight =1 ; -module_param (use_bios_initial_backlight, bool,0644 ); -static int register_count;static int acpi_video_bus_add (struct acpi_device *device);static int acpi_video_bus_remove (struct acpi_device *device);
@@ -388,12 +381,6 @@ static int __init video_set_bqc_offset(const struct dmi_system_id *d)return 0 ; } -static int video_ignore_initial_backlight (const struct dmi_system_id *d) -{ - use_bios_initial_backlight =0 ; -return 0 ; -} -static struct dmi_system_id video_dmi_table[]__initdata = {/* * Broken _BQC workaround http://bugzilla.kernel.org/show_bug.cgi?id=13121
@@ -438,54 +425,6 @@ static struct dmi_system_id video_dmi_table[] __initdata = { DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 7720"), }, }, - { - .callback = video_ignore_initial_backlight, - .ident = "HP Folio 13-2000", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"), - DMI_MATCH(DMI_PRODUCT_NAME, "HP Folio 13 - 2000 Notebook PC"), - }, - }, - { - .callback = video_ignore_initial_backlight, - .ident = "Fujitsu E753", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "FUJITSU"), - DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E753"), - }, - }, - { - .callback = video_ignore_initial_backlight, - .ident = "HP Pavilion dm4", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"), - DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dm4 Notebook PC"), - }, - }, - { - .callback = video_ignore_initial_backlight, - .ident = "HP Pavilion g6 Notebook PC", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"), - DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion g6 Notebook PC"), - }, - }, - { - .callback = video_ignore_initial_backlight, - .ident = "HP 1000 Notebook PC", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"), - DMI_MATCH(DMI_PRODUCT_NAME, "HP 1000 Notebook PC"), - }, - }, - { - .callback = video_ignore_initial_backlight, - .ident = "HP Pavilion m4", - .matches = { - DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"), - DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion m4 Notebook PC"), - }, - }, {} };
@@ -827,20 +766,18 @@ acpi_video_init_brightness(struct acpi_video_device *device)if (!device->cap._BQC) goto set_level; -if (use_bios_initial_backlight) { - level =acpi_video_bqc_value_to_level (device, level_old); -/* -* On some buggy laptops, _BQC returns an uninitialized -* value when invoked for the first time, i.e. -* level_old is invalid (no matter whether it's a level -* or an index). Set the backlight to max_level in this case. -*/ -for (i =2 ; i < br->count; i++) -if (level == br->levels[i]) -break ; -if (i == br->count || !level) - level = max_level; - } + level =acpi_video_bqc_value_to_level (device, level_old); +/* +* On some buggy laptops, _BQC returns an uninitialized +* value when invoked for the first time, i.e. +* level_old is invalid (no matter whether it's a level +* or an index). Set the backlight to max_level in this case. +*/ +for (i =2 ; i < br->count; i++) +if (level == br->levels[i]) +break ; +if (i == br->count || !level) + level = max_level; set_level: result =acpi_video_device_lcd_set_level (device, level);
Signature · 1 line
2.0.0
PATCH 85/181 module: allow multiple calls to MODULE_DEVICE_TABLE() per module
In reply to Jiri SlabyFrom: Tom Gundersen <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 21bdd17b21b45ea48e06e23918d681afbe0622e9 upstream.
Commit 78551277e4df5: "Input: i8042 - add PNP modaliases" had a bug, where the second call to MODULE_DEVICE_TABLE() overrode the first resulting in not all the modaliases being exposed.
This fixes the problem by including the name of the device_id table in the __mod_*_device_table alias, allowing us to export several device_id tables per module.
Conflicts:
include/linux/module.h
--- include/linux/module.h | 2 +- scripts/mod/file2alias.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-)
include/linux/module.h +1 -1
@@ -143,7 +143,7 @@ extern const struct gtype##_id __mod_##gtype##_table \#define MODULE_DESCRIPTION (_description) MODULE_INFO(description, _description)#define MODULE_DEVICE_TABLE (type,name) \ - MODULE_GENERIC_TABLE(type##_device,name) + MODULE_GENERIC_TABLE(type##__##name##_device, name)/* Version of form [<epoch>:]<version>[-<extra-version>]. Or for CVS/RCS ID version, everything but the number is stripped.
scripts/mod/file2alias.c +9 -5
@@ -42,7 +42,7 @@ typedef unsigned char __u8;/* This array collects all instances that use the generic do_table */ struct devtable { -const char *device_id;/* name of table, __mod_<name>_device_table. */ +const char *device_id;/* name of table, __mod_<name>__*_device_table. */ unsigned long id_size;void *function; };
@@ -146,7 +146,8 @@ static void device_id_check(const char *modname, const char *device_id,if (size % id_size || size < id_size) {fatal ("%s: sizeof(struct %s_device_id)=%lu is not a modulo " -"of the size of section __mod_%s_device_table=%lu.\n" +"of the size of " +"section __mod_%s__<identifier>_device_table=%lu.\n" "Fix definition of struct %s_device_id " "in mod_devicetable.h\n" , modname, device_id, id_size, device_id, size, device_id);
@@ -1206,7 +1207,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, {void *symval;char *zeros =NULL ; -const char *name; +const char *name, *identifier;unsigned int namelen;/* We're looking for a section relative symbol */
@@ -1217,7 +1218,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,if (ELF_ST_TYPE (sym->st_info) !=STT_OBJECT )return ; -/* All our symbols are of form <prefix>__mod_XXX_device_table. */ +/* All our symbols are of form <prefix>__mod_<name>__<identifier>_device_table. */ name =strstr (symname,"__mod_" );if (!name)return ;
@@ -1227,7 +1228,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,return ;if (strcmp (name + namelen -strlen ("_device_table" ),"_device_table" ))return ; - namelen -=strlen ("_device_table" ); + identifier =strstr (name,"__" ); +if (!identifier) +return ; + namelen = identifier - name;/* Handle all-NULL symbols allocated into .bss */ if (info->sechdrs[get_secindex (info, sym)].sh_type &SHT_NOBITS ) {
Signature · 1 line
2.0.0
PATCH 86/181 drm/radeon: memory leak on bo reservation failure. v2
In reply to Jiri SlabyFrom: Quentin Casasnovas <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 74073c9dd29905645feb6dee03c144657a9844cd upstream.
On bo reservation failure, we end up leaking fpriv.
v2 (chk): rebased and added missing free on vm failure as well
Conflicts:
drivers/gpu/drm/radeon/radeon_kms.c
--- drivers/gpu/drm/radeon/radeon_kms.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_kms.c +4 -1
@@ -501,8 +501,11 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)radeon_vm_init (rdev, &fpriv->vm); r =radeon_bo_reserve (rdev->ring_tmp_bo.bo, false); -if (r) +if (r) { +radeon_vm_fini (rdev, &fpriv->vm); +kfree (fpriv);return r; + }/* map the ib pool buffer read only into * virtual address space */
Signature · 1 line
2.0.0
PATCH 87/181 mei: me: read H_CSR after asserting reset
In reply to Jiri SlabyFrom: Tomas Winkler <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit c40765d919d25d2d44d99c4ce39e48808f137e1e upstream.
According the spec the host should read H_CSR again after asserting reset H_RST to ensure that reset was read by the firmware
--- drivers/misc/mei/hw-me.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/misc/mei/hw-me.c +13 -1
@@ -186,7 +186,19 @@ static int mei_me_hw_reset(struct mei_device *dev, bool intr_enable) dev->recvd_hw_ready = false;mei_me_reg_write (hw,H_CSR , hcsr); -if (dev->dev_state ==MEI_DEV_POWER_DOWN ) +/* +* Host reads the H_CSR once to ensure that the +* posted write to H_CSR completes. +*/ + hcsr =mei_hcsr_read (hw); + +if ((hcsr &H_RST ) ==0 ) +dev_warn (&dev->pdev->dev,"H_RST is not set = 0x%08X" , hcsr); + +if ((hcsr &H_RDY ) ==H_RDY ) +dev_warn (&dev->pdev->dev,"H_RDY is not cleared 0x%08X" , hcsr); + +if (intr_enable == false)mei_me_hw_reset_release (dev);return 0 ;
Signature · 1 line
2.0.0
PATCH 88/181 mei: me: fix hw ready reset flow
In reply to Jiri SlabyFrom: Tomas Winkler <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit b04ada92ffaabb868497a1fce8e4f6bf74e5488f upstream
We cleared H_RST for H_CSR on spurious interrupt generated when ME_RDY while cleared and not while ME_RDY is set. The spurious interrupt is not delivered on all platforms in this case the
driver may fail to initialize.
--- drivers/misc/mei/hw-me.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/misc/mei/hw-me.c +7 -7
@@ -164,6 +164,9 @@ static void mei_me_hw_reset_release(struct mei_device *dev) hcsr |=H_IG ; hcsr &= ~H_RST ;mei_hcsr_set (hw, hcsr); + +/* complete this write before we set host ready on another CPU */ +mmiowb (); }/** * mei_me_hw_reset - resets fw via mei csr register.
@@ -214,6 +217,7 @@ static int mei_me_hw_reset(struct mei_device *dev, bool intr_enable)static void mei_me_host_set_ready (struct mei_device *dev) {struct mei_me_hw *hw =to_me_hw (dev); + hw->host_hw_state =mei_hcsr_read (hw); hw->host_hw_state |=H_IE |H_IG |H_RDY ;mei_hcsr_set (hw, hw->host_hw_state); }
@@ -506,19 +510,15 @@ irqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id)/* check if we need to start the dev */ if (!mei_host_is_ready (dev)) {if (mei_hw_is_ready (dev)) { +mei_me_hw_reset_release (dev);dev_dbg (&dev->pdev->dev,"we need to start the dev.\n" ); dev->recvd_hw_ready = true;wake_up_interruptible (&dev->wait_hw_ready); - -mutex_unlock (&dev->device_lock); -return IRQ_HANDLED ; }else { -dev_dbg (&dev->pdev->dev,"Reset Completed.\n" ); -mei_me_hw_reset_release (dev); -mutex_unlock (&dev->device_lock); -return IRQ_HANDLED ; +dev_dbg (&dev->pdev->dev,"Spurious Interrupt\n" ); } + goto end; }/* check slots available for reading */ slots =mei_count_full_read_slots (dev);
Signature · 1 line
2.0.0
PATCH 89/181 usb: qcserial: fix multiline comment coding style
In reply to Jiri SlabyFrom: Bjørn Mork <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit ce1b066136a30079c4e6e81e015ad9bc2180d46f upstream.
Use a consistent style for all multiline comments.
--- drivers/usb/serial/qcserial.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/usb/serial/qcserial.c +6 -3
@@ -225,12 +225,14 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)/* default to enabling interface */ altsetting =0 ; -/* Composite mode; don't bind to the QMI/net interface as that +/* +* Composite mode; don't bind to the QMI/net interface as that * gets handled by other drivers. */ if (is_gobi1k) { -/* Gobi 1K USB layout: +/* +* Gobi 1K USB layout: * 0: DM/DIAG (use libqcdm from ModemManager for communication) * 1: serial port (doesn't respond) * 2: AT-capable modem port
@@ -244,7 +246,8 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)else altsetting =-1 ; }else { -/* Gobi 2K+ USB layout: +/* +* Gobi 2K+ USB layout: * 0: QMI/net * 1: DM/DIAG (use libqcdm from ModemManager for communication) * 2: AT-capable modem port
Signature · 1 line
2.0.0
PATCH 90/181 usb: qcserial: refactor device layout selection
In reply to Jiri SlabyFrom: Bjørn Mork <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit d712ca91db6d5463ca5a9b06eb6ba937c59a15fa upstream.
Preparing for more supported standard device layouts. Keeping the matching macros unchanged to avoid breaking stable backporting of new device additions.
--- drivers/usb/serial/qcserial.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
drivers/usb/serial/qcserial.c +16 -6
@@ -22,8 +22,14 @@#define DRIVER_AUTHOR "Qualcomm Inc"#define DRIVER_DESC "Qualcomm USB Serial driver" +/* standard device layouts supported by this driver */ +enum qcserial_layouts { +QCSERIAL_G2K =0 ,/* Gobi 2000 */ +QCSERIAL_G1K =1 ,/* Gobi 1000 */ +}; +#define DEVICE_G1K (v, p) \ - USB_DEVICE(v, p), .driver_info = 1 + USB_DEVICE(v, p), .driver_info = QCSERIAL_G1Kstatic const struct usb_device_id id_table[] = {/* Gobi 1000 devices */
@@ -178,11 +184,8 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)int retval = -ENODEV ;__u8 nintf;__u8 ifnum; -bool is_gobi1k = id->driver_info ? true : false;int altsetting =-1 ; -dev_dbg (dev,"Is Gobi 1000 = %d\n" , is_gobi1k); - nintf = serial->dev->actconfig->desc.bNumInterfaces;dev_dbg (dev,"Num Interfaces = %d\n" , nintf); ifnum = intf->desc.bInterfaceNumber;
@@ -230,7 +233,8 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)* gets handled by other drivers. */ -if (is_gobi1k) { +switch (id->driver_info) { +case QCSERIAL_G1K :/* * Gobi 1K USB layout: * 0: DM/DIAG (use libqcdm from ModemManager for communication)
@@ -245,7 +249,8 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)dev_dbg (dev,"Modem port found\n" ); else altsetting =-1 ; - }else { +break ; +case QCSERIAL_G2K :/* * Gobi 2K+ USB layout: * 0: QMI/net
@@ -273,6 +278,11 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)dev_dbg (dev,"Gobi 2K+ NMEA GPS interface found\n" );break ; } +break ; +default : +dev_err (dev,"unsupported device layout type: %lu\n" , + id->driver_info); +break ; } done:
Signature · 1 line
2.0.0
PATCH 91/181 usb: qcserial: define and use Sierra Wireless layout
In reply to Jiri SlabyFrom: Bjørn Mork <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 8bc7a069402e1a443ded8088a8be0dc8aa1c2c9b upstream.
All the "non Gobi" Qualcomm based devices handled by this driver share a common standard Sierra Wireless specific layout. Adding code specifically for this layout allow us to reduce the number of match entries per device from three to one.
This change will result in a penalty wrt stable backports, but simplifies new Sierra device addtitions in the long term.
--- drivers/usb/serial/qcserial.c | 98 +++++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 45 deletions(-)
drivers/usb/serial/qcserial.c +53 -45
@@ -26,10 +26,13 @@enum qcserial_layouts {QCSERIAL_G2K =0 ,/* Gobi 2000 */ QCSERIAL_G1K =1 ,/* Gobi 1000 */ +QCSERIAL_SWI =2 ,/* Sierra Wireless */ };#define DEVICE_G1K (v, p) \ USB_DEVICE(v, p), .driver_info = QCSERIAL_G1K +#define DEVICE_SWI (v, p) \ + USB_DEVICE(v, p), .driver_info = QCSERIAL_SWIstatic const struct usb_device_id id_table[] = {/* Gobi 1000 devices */
@@ -132,46 +135,20 @@ static const struct usb_device_id id_table[] = { {USB_DEVICE(0x12D1, 0x14F1)}, /* Sony Gobi 3000 Composite */ {USB_DEVICE(0x0AF0, 0x8120)}, /* Option GTM681W */ -/* non Gobi Qualcomm serial devices */ - {USB_DEVICE_INTERFACE_NUMBER(0x0f3d, 0x68a2, 0)}, /* Sierra Wireless MC7700 Device Management */ - {USB_DEVICE_INTERFACE_NUMBER(0x0f3d, 0x68a2, 2)}, /* Sierra Wireless MC7700 NMEA */ - {USB_DEVICE_INTERFACE_NUMBER(0x0f3d, 0x68a2, 3)}, /* Sierra Wireless MC7700 Modem */ - {USB_DEVICE_INTERFACE_NUMBER(0x114f, 0x68a2, 0)}, /* Sierra Wireless MC7750 Device Management */ - {USB_DEVICE_INTERFACE_NUMBER(0x114f, 0x68a2, 2)}, /* Sierra Wireless MC7750 NMEA */ - {USB_DEVICE_INTERFACE_NUMBER(0x114f, 0x68a2, 3)}, /* Sierra Wireless MC7750 Modem */ - {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x68a2, 0)}, /* Sierra Wireless MC7710 Device Management */ - {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x68a2, 2)}, /* Sierra Wireless MC7710 NMEA */ - {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x68a2, 3)}, /* Sierra Wireless MC7710 Modem */ - {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x68c0, 0)}, /* Sierra Wireless MC73xx Device Management */ - {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x68c0, 2)}, /* Sierra Wireless MC73xx NMEA */ - {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x68c0, 3)}, /* Sierra Wireless MC73xx Modem */ - {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x901c, 0)}, /* Sierra Wireless EM7700 Device Management */ - {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x901c, 2)}, /* Sierra Wireless EM7700 NMEA */ - {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x901c, 3)}, /* Sierra Wireless EM7700 Modem */ - {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x901f, 0)}, /* Sierra Wireless EM7355 Device Management */ - {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x901f, 2)}, /* Sierra Wireless EM7355 NMEA */ - {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x901f, 3)}, /* Sierra Wireless EM7355 Modem */ - {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9041, 0)}, /* Sierra Wireless MC7305/MC7355 Device Management */ - {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9041, 2)}, /* Sierra Wireless MC7305/MC7355 NMEA */ - {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9041, 3)}, /* Sierra Wireless MC7305/MC7355 Modem */ - {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9051, 0)}, /* Netgear AirCard 340U Device Management */ - {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9051, 2)}, /* Netgear AirCard 340U NMEA */ - {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9051, 3)}, /* Netgear AirCard 340U Modem */ - {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a2, 0)}, /* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card Device Management */ - {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a2, 2)}, /* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card NMEA */ - {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a2, 3)}, /* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card Modem */ - {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a3, 0)}, /* Dell Wireless 5570 HSPA+ (42Mbps) Mobile Broadband Card Device Management */ - {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a3, 2)}, /* Dell Wireless 5570 HSPA+ (42Mbps) Mobile Broadband Card NMEA */ - {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a3, 3)}, /* Dell Wireless 5570 HSPA+ (42Mbps) Mobile Broadband Card Modem */ - {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a4, 0)}, /* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card Device Management */ - {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a4, 2)}, /* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card NMEA */ - {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a4, 3)}, /* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card Modem */ - {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a8, 0)}, /* Dell Wireless 5808 Gobi(TM) 4G LTE Mobile Broadband Card Device Management */ - {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a8, 2)}, /* Dell Wireless 5808 Gobi(TM) 4G LTE Mobile Broadband Card NMEA */ - {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a8, 3)}, /* Dell Wireless 5808 Gobi(TM) 4G LTE Mobile Broadband Card Modem */ - {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a9, 0)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card Device Management */ - {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a9, 2)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card NMEA */ - {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a9, 3)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card Modem */ +/* non-Gobi Sierra Wireless devices */ + {DEVICE_SWI(0x0f3d, 0x68a2)}, /* Sierra Wireless MC7700 */ + {DEVICE_SWI(0x114f, 0x68a2)}, /* Sierra Wireless MC7750 */ + {DEVICE_SWI(0x1199, 0x68a2)}, /* Sierra Wireless MC7710 */ + {DEVICE_SWI(0x1199, 0x68c0)}, /* Sierra Wireless MC73xx */ + {DEVICE_SWI(0x1199, 0x901c)}, /* Sierra Wireless EM7700 */ + {DEVICE_SWI(0x1199, 0x901f)}, /* Sierra Wireless EM7355 */ + {DEVICE_SWI(0x1199, 0x9041)}, /* Sierra Wireless MC7305/MC7355 */ + {DEVICE_SWI(0x1199, 0x9051)}, /* Netgear AirCard 340U */ + {DEVICE_SWI(0x413c, 0x81a2)}, /* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card */ + {DEVICE_SWI(0x413c, 0x81a3)}, /* Dell Wireless 5570 HSPA+ (42Mbps) Mobile Broadband Card */ + {DEVICE_SWI(0x413c, 0x81a4)}, /* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card */ + {DEVICE_SWI(0x413c, 0x81a8)}, /* Dell Wireless 5808 Gobi(TM) 4G LTE Mobile Broadband Card */ + {DEVICE_SWI(0x413c, 0x81a9)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card */ { } /* Terminating entry */ };
@@ -220,11 +197,6 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id) goto done; } -if (nintf <3 || nintf >4 ) { -dev_err (dev,"unknown number of interfaces: %d\n" , nintf); - goto done; - } -/* default to enabling interface */ altsetting =0 ;
@@ -242,6 +214,12 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)* 2: AT-capable modem port * 3: QMI/net */ +if (nintf <3 || nintf >4 ) { +dev_err (dev,"unknown number of interfaces: %d\n" , nintf); + altsetting =-1 ; + goto done; + } +if (ifnum ==0 ) {dev_dbg (dev,"Gobi 1K DM/DIAG interface found\n" ); altsetting =1 ;
@@ -258,6 +236,12 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)* 2: AT-capable modem port * 3: NMEA */ +if (nintf <3 || nintf >4 ) { +dev_err (dev,"unknown number of interfaces: %d\n" , nintf); + altsetting =-1 ; + goto done; + } +switch (ifnum) {case 0 :/* Don't claim the QMI/net interface */
@@ -279,6 +263,30 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)break ; }break ; +case QCSERIAL_SWI : +/* +* Sierra Wireless layout: +* 0: DM/DIAG (use libqcdm from ModemManager for communication) +* 2: NMEA +* 3: AT-capable modem port +* 8: QMI/net +*/ +switch (ifnum) { +case 0 : +dev_dbg (dev,"DM/DIAG interface found\n" ); +break ; +case 2 : +dev_dbg (dev,"NMEA GPS interface found\n" ); +break ; +case 3 : +dev_dbg (dev,"Modem port found\n" ); +break ; +default : +/* don't claim any unsupported interface */ + altsetting =-1 ; +break ; + } +break ;default :dev_err (dev,"unsupported device layout type: %lu\n" , id->driver_info);
Signature · 1 line
2.0.0
PATCH 92/181 usb: qcserial: add Netgear AirCard 341U
In reply to Jiri SlabyFrom: Aleksander Morgado <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit ff1fcd50bc2459744e6f948310bc18eb7d6e8c72 upstream.
--- drivers/usb/serial/qcserial.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/serial/qcserial.c +1 -0
@@ -144,6 +144,7 @@ static const struct usb_device_id id_table[] = { {DEVICE_SWI(0x1199, 0x901f)}, /* Sierra Wireless EM7355 */ {DEVICE_SWI(0x1199, 0x9041)}, /* Sierra Wireless MC7305/MC7355 */ {DEVICE_SWI(0x1199, 0x9051)}, /* Netgear AirCard 340U */ + {DEVICE_SWI(0x1199, 0x9055)}, /* Netgear AirCard 341U */ {DEVICE_SWI(0x413c, 0x81a2)}, /* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card */ {DEVICE_SWI(0x413c, 0x81a3)}, /* Dell Wireless 5570 HSPA+ (42Mbps) Mobile Broadband Card */ {DEVICE_SWI(0x413c, 0x81a4)}, /* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card */
Signature · 1 line
2.0.0
PATCH 93/181 usb: qcserial: add additional Sierra Wireless QMI devices
In reply to Jiri SlabyFrom: Aleksander Morgado <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 0ce5fb58564fd85aa8fd2d24209900e2e845317b upstream.
A set of new VID/PIDs retrieved from the out-of-tree GobiNet/GobiSerial Sierra Wireless drivers.
--- drivers/usb/serial/qcserial.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/usb/serial/qcserial.c +6 -0
@@ -142,9 +142,15 @@ static const struct usb_device_id id_table[] = { {DEVICE_SWI(0x1199, 0x68c0)}, /* Sierra Wireless MC73xx */ {DEVICE_SWI(0x1199, 0x901c)}, /* Sierra Wireless EM7700 */ {DEVICE_SWI(0x1199, 0x901f)}, /* Sierra Wireless EM7355 */ + {DEVICE_SWI(0x1199, 0x9040)}, /* Sierra Wireless Modem */ {DEVICE_SWI(0x1199, 0x9041)}, /* Sierra Wireless MC7305/MC7355 */ {DEVICE_SWI(0x1199, 0x9051)}, /* Netgear AirCard 340U */ + {DEVICE_SWI(0x1199, 0x9053)}, /* Sierra Wireless Modem */ + {DEVICE_SWI(0x1199, 0x9054)}, /* Sierra Wireless Modem */ {DEVICE_SWI(0x1199, 0x9055)}, /* Netgear AirCard 341U */ + {DEVICE_SWI(0x1199, 0x9056)}, /* Sierra Wireless Modem */ + {DEVICE_SWI(0x1199, 0x9060)}, /* Sierra Wireless Modem */ + {DEVICE_SWI(0x1199, 0x9061)}, /* Sierra Wireless Modem */ {DEVICE_SWI(0x413c, 0x81a2)}, /* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card */ {DEVICE_SWI(0x413c, 0x81a3)}, /* Dell Wireless 5570 HSPA+ (42Mbps) Mobile Broadband Card */ {DEVICE_SWI(0x413c, 0x81a4)}, /* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card */
Signature · 1 line
2.0.0
PATCH 94/181 usb: usbtest: Add timetout to simple_io()
In reply to Jiri SlabyFrom: Roger Quadros <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit e5e4746510d140261918aecce2e5e3aa4456f7e9 upstream.
Without a timetout some tests e.g. test_halt() can remain stuck forever.
--- drivers/usb/misc/usbtest.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/usb/misc/usbtest.c +11 -3
@@ -10,6 +10,7 @@#include <linux/usb.h> +#define SIMPLE_IO_TIMEOUT 10000/* in milliseconds */ /*-------------------------------------------------------------------------*/
@@ -366,6 +367,7 @@ static int simple_io(int max = urb->transfer_buffer_length;struct completion completion;int retval =0 ; +unsigned long expire; urb->context = &completion;while (retval ==0 && iterations-- >0 ) {
@@ -378,9 +380,15 @@ static int simple_io(if (retval !=0 )break ; -/* NOTE: no timeouts; can't be broken out of by interrupt */ -wait_for_completion (&completion); - retval = urb->status; + expire =msecs_to_jiffies (SIMPLE_IO_TIMEOUT ); +if (!wait_for_completion_timeout (&completion, expire)) { +usb_kill_urb (urb); + retval = (urb->status == -ENOENT ? + -ETIMEDOUT : urb->status); + }else { + retval = urb->status; + } + urb->dev = udev;if (retval ==0 &&usb_pipein (urb->pipe)) retval =simple_check_buf (tdev, urb);
Signature · 1 line
2.0.0
PATCH 95/181 can: peak_pci: prevent use after free at netdev removal
In reply to Jiri SlabyFrom: Stephane Grosjean <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 0b5a958cf4df3a5cd578b861471e62138f55c85e upstream.
As remarked by Christopher R. Baker in his post at
http://marc.info/?l=linux-can&m=139707295706465&w=2
there's a possibility for an use after free condition at device removal.
This simplified patch introduces an additional variable to prevent the issue. Thanks for catching this.
--- drivers/net/can/sja1000/peak_pci.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/net/can/sja1000/peak_pci.c +9 -5
@@ -551,7 +551,7 @@ static int peak_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) {struct sja1000_priv *priv;struct peak_pci_chan *chan; -struct net_device *dev; +struct net_device *dev, *prev_dev;void __iomem *cfg_base, *reg_base;u16 sub_sys_id, icr;int i, err, channels;
@@ -687,11 +687,13 @@ failure_remove_channels:writew (0x0 , cfg_base +PITA_ICR +2 ); chan =NULL ; -for (dev =pci_get_drvdata (pdev); dev; dev = chan->prev_dev) { -unregister_sja1000dev (dev); -free_sja1000dev (dev); +for (dev =pci_get_drvdata (pdev); dev; dev = prev_dev) { priv =netdev_priv (dev); chan = priv->priv; + prev_dev = chan->prev_dev; + +unregister_sja1000dev (dev); +free_sja1000dev (dev); }/* free any PCIeC resources too */
@@ -725,10 +727,12 @@ static void peak_pci_remove(struct pci_dev *pdev)/* Loop over all registered devices */ while (1 ) { +struct net_device *prev_dev = chan->prev_dev; +dev_info (&pdev->dev,"removing device %s\n" , dev->name);unregister_sja1000dev (dev);free_sja1000dev (dev); - dev = chan->prev_dev; + dev = prev_dev;if (!dev) {/* do that only for first channel */
Signature · 1 line
2.0.0
PATCH 96/181 af_iucv: wrong mapping of sent and confirmed skbs
In reply to Jiri SlabyFrom: Ursula Braun <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit f5738e2ef88070ef1372e6e718124d88e9abe4ac upstream.
When sending data through IUCV a MESSAGE COMPLETE interrupt signals that sent data memory can be freed or reused again. With commit f9c41a62bba3f3f7ef3541b2a025e3371bcbba97 "af_iucv: fix recvmsg by replacing skb_pull() function" the MESSAGE COMPLETE callback iucv_callback_txdone() identifies the wrong skb as being confirmed, which leads to data corruption. This patch fixes the skb mapping logic in iucv_callback_txdone().
--- net/iucv/af_iucv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/iucv/af_iucv.c +1 -1
@@ -1829,7 +1829,7 @@ static void iucv_callback_txdone(struct iucv_path *path,spin_lock_irqsave (&list->lock, flags);while (list_skb != (struct sk_buff *)list) { -if (msg->tag !=IUCV_SKB_CB (list_skb)->tag) { +if (msg->tag ==IUCV_SKB_CB (list_skb)->tag) { this = list_skb;break ; }
Signature · 1 line
2.0.0
PATCH 97/181 net: cpsw: fix null dereference at probe
In reply to Jiri SlabyFrom: Johan Hovold <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 6954cc1f238199e971ec905c5cc87120806ac981 upstream.
Fix null-pointer dereference at probe when the mdio platform device is missing (e.g. when it has been disabled in DT).
--- drivers/net/ethernet/ti/cpsw.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/ti/cpsw.c +4 -0
@@ -1797,6 +1797,10 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data, mdio_node =of_find_node_by_phandle (be32_to_cpup (parp)); phyid =be32_to_cpup (parp+1 ); mdio =of_find_device_by_node (mdio_node); +if (!mdio) { +pr_err ("Missing mdio platform device\n" ); +return -EINVAL ; + }snprintf (slave_data->phy_id,sizeof (slave_data->phy_id),PHY_ID_FMT , mdio->name, phyid);
Signature · 1 line
2.0.0
PATCH 98/181 extcon: max8997: Fix NULL pointer exception on missing pdata
In reply to Jiri SlabyFrom: Krzysztof Kozlowski <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit dfee4111febf3d9ef3a640b2cd6205c75f4e7e3d upstream.
Fix NULL pointer exception when platform data is not supplied. The driver dereferenced pdata pointer where it could be NULL.
--- drivers/extcon/extcon-max8997.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/extcon/extcon-max8997.c +1 -1
@@ -712,7 +712,7 @@ static int max8997_muic_probe(struct platform_device *pdev) goto err_irq; } -if (pdata->muic_pdata) { +if (pdata && pdata->muic_pdata) {struct max8997_muic_platform_data *muic_pdata = pdata->muic_pdata;
Signature · 1 line
2.0.0
PATCH 99/181 extcon: max77693: Fix two NULL pointer exceptions on missing pdata
In reply to Jiri SlabyFrom: Krzysztof Kozlowski <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit d5653f2b7304f05eeb45d84f123cf02f840b8537 upstream.
Fix NULL pointer exceptions when platform data is not supplied.
Trace of one exception:
Unable to handle kernel NULL pointer dereference at virtual address 00000008 pgd = c0004000 [00000008] *pgd=00000000 Internal error: Oops: 5 [#1] PREEMPT SMP ARM Modules linked in: CPU: 2 PID: 1 Comm: swapper/0 Not tainted 3.14.0-12045-gead5dd4687a6-dirty #1628 task: eea80000 ti: eea88000 task.ti: eea88000 PC is at max77693_muic_probe+0x27c/0x528 LR is at regmap_write+0x50/0x60 pc : [<c041d1c8>] lr : [<c02eba60>] psr: 20000113
sp : eea89e38 ip : 00000000 fp : c098a834
r10: ee1a5a10 r9 : 00000005 r8 : c098a83c
r7 : 0000000a r6 : c098a774 r5 : 00000005 r4 : eeb006d0 r3 : c0697bd8 r2 : 00000000 r1 : 00000001 r0 : 00000000
Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel
Control: 10c5387d Table: 4000404a DAC: 00000015 Process swapper/0 (pid: 1, stack limit = 0xeea88240)
Stack: (0xeea89e38 to 0xeea8a000)
9e20: c08499fc eeb006d0
9e40: 00000000 00000000 c0915f98 00000001 00000000 ee1a5a10 c098a730 c09a88b8 9e60: 00000000 c098a730 c0915f98 00000000 00000000 c02d6aa0 c02d6a88 ee1a5a10 9e80: c0a712c8 c02d54e4 00001204 c0628b00 ee1a5a10 c098a730 ee1a5a44 00000000 9ea0: eea88000 c02d57b4 00000000 c098a730 c02d5728 c02d3a24 ee813e5c eeb9d534 9ec0: c098a730 ee22f700 c097c720 c02d4b14 c08174ec c098a730 00000006 c098a730 9ee0: 00000006 c092fd30 c09b8500 c02d5df8 00000000 c093cbb8 00000006 c0008928 9f00: 000000c3 ef7fc785 00000000 ef7fc794 00000000 c08af968 00000072 eea89f30 9f20: ef7fc85e c065f198 000000c3 c003e87c 00000003 00000000 c092fd3c 00000000 9f40: c08af618 c0826d58 00000006 00000006 c0956f58 c093cbb8 00000006 c092fd30 9f60: c09b8500 000000c3 c092fd3c c08e8510 00000000 c08e8bb0 00000006 00000006 9f80: c08e8510 c0c0c0c0 00000000 c0628fac 00000000 00000000 00000000 00000000 9fa0: 00000000 c0628fb4 00000000 c000f038 00000000 00000000 00000000 00000000 9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 9fe0: 00000000 00000000 00000000 00000000 00000013 00000000 c0c0c0c0 c0c0c0c0 [<c041d1c8>] (max77693_muic_probe) from [<c02d6aa0>] (platform_drv_probe+0x18/0x48) [<c02d6aa0>] (platform_drv_probe) from [<c02d54e4>] (driver_probe_device+0x140/0x384) [<c02d54e4>] (driver_probe_device) from [<c02d57b4>] (__driver_attach+0x8c/0x90) [<c02d57b4>] (__driver_attach) from [<c02d3a24>] (bus_for_each_dev+0x54/0x88) [<c02d3a24>] (bus_for_each_dev) from [<c02d4b14>] (bus_add_driver+0xe8/0x204) [<c02d4b14>] (bus_add_driver) from [<c02d5df8>] (driver_register+0x78/0xf4) [<c02d5df8>] (driver_register) from [<c0008928>] (do_one_initcall+0xc4/0x174) [<c0008928>] (do_one_initcall) from [<c08e8bb0>] (kernel_init_freeable+0xfc/0x1c8) [<c08e8bb0>] (kernel_init_freeable) from [<c0628fb4>] (kernel_init+0x8/0xec) [<c0628fb4>] (kernel_init) from [<c000f038>] (ret_from_fork+0x14/0x3c)
Code: caffffe7 e59d200c e3550001 b3a05001 (e5923008) ---[ end trace 85db969ce011bde7 ]---
--- drivers/extcon/extcon-max77693.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/extcon/extcon-max77693.c +2 -2
@@ -1180,7 +1180,7 @@ static int max77693_muic_probe(struct platform_device *pdev)/* Initialize MUIC register by using platform data or default data */ -if (pdata->muic_data) { +if (pdata && pdata->muic_data) { init_data = pdata->muic_data->init_data; num_init_data = pdata->muic_data->num_init_data; }else {
@@ -1213,7 +1213,7 @@ static int max77693_muic_probe(struct platform_device *pdev) = init_data[i].data; } -if (pdata->muic_data) { +if (pdata && pdata->muic_data) {struct max77693_muic_platform_data *muic_pdata = pdata->muic_data;/*
Signature · 1 line
2.0.0
PATCH 100/181 staging: tidspbridge: check for CONFIG_SND_OMAP_SOC_MCBSP
In reply to Jiri SlabyFrom: Paul Bolle <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit d3921a03a89acb1b9ca599590c0131c89f8737d8 upstream.
Commit d0f47ff17f29 ("ASoC: OMAP: Build config cleanup for McBSP") removed the Kconfig symbol OMAP_MCBSP. It left two checks for CONFIG_OMAP_MCBSP untouched.
Convert these to checks for CONFIG_SND_OMAP_SOC_MCBSP. That must be correct, since that re-enables calls to functions that are all found in sound/soc/omap/mcbsp.c. And that file is built only if CONFIG_SND_OMAP_SOC_MCBSP is defined.
--- drivers/staging/tidspbridge/core/dsp-clock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/tidspbridge/core/dsp-clock.c +2 -2
@@ -226,7 +226,7 @@ int dsp_clk_enable(enum dsp_clk_id clk_id)case GPT_CLK : status =omap_dm_timer_start (timer[clk_id -1 ]);break ; -#ifdef CONFIG_OMAP_MCBSP +#ifdef CONFIG_SND_OMAP_SOC_MCBSP case MCBSP_CLK :omap_mcbsp_request (MCBSP_ID (clk_id));omap2_mcbsp_set_clks_src (MCBSP_ID (clk_id),MCBSP_CLKS_PAD_SRC );
@@ -302,7 +302,7 @@ int dsp_clk_disable(enum dsp_clk_id clk_id)case GPT_CLK : status =omap_dm_timer_stop (timer[clk_id -1 ]);break ; -#ifdef CONFIG_OMAP_MCBSP +#ifdef CONFIG_SND_OMAP_SOC_MCBSP case MCBSP_CLK :omap2_mcbsp_set_clks_src (MCBSP_ID (clk_id),MCBSP_CLKS_PRCM_SRC );omap_mcbsp_free (MCBSP_ID (clk_id));
Signature · 1 line
2.0.0
PATCH 101/181 Staging: rtl8188eu: overflow in update_sta_support_rate()
In reply to Jiri SlabyFrom: Dan Carpenter <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 9dbd79aeb9842144d9a114a979a12c0949ee11eb upstream.
The ->SupportedRates[] array has NDIS_802_11_LENGTH_RATES_EX (16) elements. Since "ie_len" comes from then network and can go up to 255 then it means we should add a range check to prevent memory corruption.
--- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/staging/rtl8188eu/core/rtw_wlan_util.c +6 -1
@@ -1607,13 +1607,18 @@ int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_l pIE = (struct ndis_802_11_var_ie *)rtw_get_ie (pvar_ie, _SUPPORTEDRATES_IE_, &ie_len, var_ie_len);if (pIE ==NULL )return _FAIL; +if (ie_len >NDIS_802_11_LENGTH_RATES_EX ) +return _FAIL;memcpy (pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, pIE->data, ie_len); supportRateNum = ie_len; pIE = (struct ndis_802_11_var_ie *)rtw_get_ie (pvar_ie, _EXT_SUPPORTEDRATES_IE_, &ie_len, var_ie_len); -if (pIE) +if (pIE) { +if (supportRateNum + ie_len >NDIS_802_11_LENGTH_RATES_EX ) +return _FAIL;memcpy ((pmlmeinfo->FW_sta_info[cam_idx].SupportedRates + supportRateNum), pIE->data, ie_len); + }return _SUCCESS; }
Signature · 1 line
2.0.0
PATCH 102/181 applicom: dereferencing NULL on error path
In reply to Jiri SlabyFrom: Dan Carpenter <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 8bab797c6e5724a43b7666ad70860712365cdb71 upstream.
This is a static checker fix. The "dev" variable is always NULL after the while statement so we would be dereferencing a NULL pointer here.
--- drivers/char/applicom.c | 1 - 1 file changed, 1 deletion(-)
drivers/char/applicom.c +0 -1
@@ -345,7 +345,6 @@ out:free_irq (apbs[i].irq, &dummy);iounmap (apbs[i].RamIO); } -pci_disable_device (dev);return ret; }
Signature · 1 line
2.0.0
PATCH 103/181 usb: usbtest: fix unlink write error with pattern 1
In reply to Jiri SlabyFrom: Huang Rui <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit e4d58f5dcb7d7be45df8def31881ebfae99c75da upstream.
TEST 12 and TEST 24 unlinks the URB write request for N times. When host and gadget both initialize pattern 1 (mod 63) data series to transfer, the gadget side will complain the wrong data which is not expected. Because in host side, usbtest doesn't fill the data buffer as mod 63 and this patch fixed it.
[20285.488974] dwc3 dwc3.0.auto: ep1out-bulk: Transfer Not Ready [20285.489181] dwc3 dwc3.0.auto: ep1out-bulk: reason Transfer Not Active [20285.489423] dwc3 dwc3.0.auto: ep1out-bulk: req ffff8800aa6cb480 dma aeb50800 length 512 last [20285.489727] dwc3 dwc3.0.auto: ep1out-bulk: cmd 'Start Transfer' params 00000000 a9eaf000 00000000 [20285.490055] dwc3 dwc3.0.auto: Command Complete --> 0 [20285.490281] dwc3 dwc3.0.auto: ep1out-bulk: Transfer Not Ready [20285.490492] dwc3 dwc3.0.auto: ep1out-bulk: reason Transfer Active [20285.490713] dwc3 dwc3.0.auto: ep1out-bulk: endpoint busy [20285.490909] dwc3 dwc3.0.auto: ep1out-bulk: Transfer Complete [20285.491117] dwc3 dwc3.0.auto: request ffff8800aa6cb480 from ep1out-bulk completed 512/512 ===> 0 [20285.491431] zero gadget: bad OUT byte, buf[1] = 0 [20285.491605] dwc3 dwc3.0.auto: ep1out-bulk: cmd 'Set Stall' params 00000000 00000000 00000000 [20285.491915] dwc3 dwc3.0.auto: Command Complete --> 0 [20285.492099] dwc3 dwc3.0.auto: queing request ffff8800aa6cb480 to ep1out-bulk length 512 [20285.492387] dwc3 dwc3.0.auto: ep1out-bulk: Transfer Not Ready [20285.492595] dwc3 dwc3.0.auto: ep1out-bulk: reason Transfer Not Active [20285.492830] dwc3 dwc3.0.auto: ep1out-bulk: req ffff8800aa6cb480 dma aeb51000 length 512 last [20285.493135] dwc3 dwc3.0.auto: ep1out-bulk: cmd 'Start Transfer' params 00000000 a9eaf000 00000000 [20285.493465] dwc3 dwc3.0.auto: Command Complete --> 0
--- drivers/usb/misc/usbtest.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/usb/misc/usbtest.c +10 -0
@@ -1157,6 +1157,11 @@ static int unlink1(struct usbtest_dev *dev, int pipe, int size, int async) urb->context = &completion; urb->complete = unlink1_callback; +if (usb_pipeout (urb->pipe)) { +simple_fill_buf (urb); + urb->transfer_flags |=URB_ZERO_PACKET ; + } +/* keep the endpoint busy. there are lots of hc/hcd-internal * states, and testing should get to all of them over time. *
@@ -1287,6 +1292,11 @@ static int unlink_queued(struct usbtest_dev *dev, int pipe, unsigned num, unlink_queued_callback, &ctx); ctx.urbs[i]->transfer_dma = buf_dma; ctx.urbs[i]->transfer_flags =URB_NO_TRANSFER_DMA_MAP ; + +if (usb_pipeout (ctx.urbs[i]->pipe)) { +simple_fill_buf (ctx.urbs[i]); + ctx.urbs[i]->transfer_flags |=URB_ZERO_PACKET ; + } }/* Submit all the URBs and then unlink URBs num - 4 and num - 2. */
Signature · 1 line
2.0.0
PATCH 104/181 USB: usbtest: add a timeout for scatter-gather tests
In reply to Jiri SlabyFrom: Alan Stern <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 32b36eeae6a859670d2939a7d6136cb5e9ed64f8 upstream.
In usbtest, tests 5 - 8 use the scatter-gather library in usbcore without any sort of timeout. If there's a problem in the gadget or host controller being tested, the test can hang.
This patch adds a 10-second timeout to the tests, so that they will fail gracefully with an ETIMEDOUT error instead of hanging.
--- drivers/usb/misc/usbtest.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
drivers/usb/misc/usbtest.c +15 -1
@@ -7,7 +7,7 @@#include <linux/moduleparam.h> #include <linux/scatterlist.h> #include <linux/mutex.h> - +#include <linux/timer.h> #include <linux/usb.h> #define SIMPLE_IO_TIMEOUT 10000/* in milliseconds */
@@ -484,6 +484,14 @@ alloc_sglist(int nents, int max, int vary)return sg; } +static void sg_timeout (unsigned long _req) +{ +struct usb_sg_request *req = (struct usb_sg_request *) _req; + + req->status = -ETIMEDOUT ; +usb_sg_cancel (req); +} + static int perform_sglist( struct usbtest_dev *tdev, unsigned iterations,
@@ -495,6 +503,9 @@ static int perform_sglist( {struct usb_device *udev =testdev_to_usbdev (tdev);int retval =0 ; +struct timer_list sg_timer; + +setup_timer_on_stack (&sg_timer, sg_timeout, (unsigned long ) req);while (retval ==0 && iterations-- >0 ) { retval = usb_sg_init(req, udev, pipe,
@@ -505,7 +516,10 @@ static int perform_sglist(if (retval)break ; +mod_timer (&sg_timer, jiffies + +msecs_to_jiffies (SIMPLE_IO_TIMEOUT ));usb_sg_wait (req); +del_timer_sync (&sg_timer); retval = req->status;/* FIXME check resulting data pattern */
Signature · 1 line
2.0.0
PATCH 105/181 usb: gadget: rename CONFIG_USB_GADGET_PXA25X
In reply to Jiri SlabyFrom: Paul Bolle <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit d30f2065d6da377cc76771aca5a9850cfca8723b upstream.
Commit 193ab2a60700 ("usb: gadget: allow multiple gadgets to be built") basically renamed the Kconfig symbol USB_GADGET_PXA25X to USB_PXA25X. It did not rename the related macros in use at that time. Commit c0a39151a405 ("ARM: pxa: fix inconsistent CONFIG_USB_PXA27X") did so for all but one macro. Rename that last macro too now.
--- drivers/usb/gadget/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/inode.c +1 -1
@@ -1504,7 +1504,7 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) }break ; -#ifndef CONFIG_USB_GADGET_PXA25X +#ifndef CONFIG_USB_PXA25X /* PXA automagically handles this request too */ case USB_REQ_GET_CONFIGURATION :if (ctrl->bRequestType !=0x80 )
Signature · 1 line
2.0.0
PATCH 106/181 usb: dwc3: gadget: clear stall when disabling endpoint
In reply to Jiri SlabyFrom: Felipe Balbi <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 687ef9817df7ed960d14575b9033dde3d04631fe upstream.
so it seems like DWC3 IP doesn't clear stalls automatically when we disable an endpoint, because of that, we _must_ make sure stalls are cleared before clearing the proper bit in DALEPENA register.
--- drivers/usb/dwc3/gadget.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/dwc3/gadget.c +4 -0
@@ -586,6 +586,10 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep)dwc3_remove_requests (dwc, dep); +/* make sure HW endpoint isn't stalled */ +if (dep->flags &DWC3_EP_STALL ) +__dwc3_gadget_ep_set_halt (dep,0 ); + reg =dwc3_readl (dwc->regs,DWC3_DALEPENA ); reg &= ~DWC3_DALEPENA_EP (dep->number);dwc3_writel (dwc->regs,DWC3_DALEPENA , reg);
Signature · 1 line
2.0.0
PATCH 107/181 ARM: OMAP: replace checks for CONFIG_USB_GADGET_OMAP
In reply to Jiri SlabyFrom: Paul Bolle <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 77c2f02edbeda9409a7cf3fd66233015820c213a upstream.
Commit 193ab2a60700 ("usb: gadget: allow multiple gadgets to be built") apparently required that checks for CONFIG_USB_GADGET_OMAP would be replaced with checks for CONFIG_USB_OMAP. Do so now for the remaining checks for CONFIG_USB_GADGET_OMAP, even though these checks have basically been broken since v3.1.
And, since we're touching this code, use the IS_ENABLED() macro, so things will now (hopefully) also work if USB_OMAP is modular.
--- arch/arm/mach-omap1/board-h2.c | 2 +- arch/arm/mach-omap1/board-h3.c | 2 +- arch/arm/mach-omap1/board-innovator.c | 2 +- arch/arm/mach-omap1/board-osk.c | 2 +- drivers/usb/phy/phy-isp1301-omap.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
arch/arm/mach-omap1/board-h2.c +1 -1
@@ -343,7 +343,7 @@ static struct omap_usb_config h2_usb_config __initdata = {/* usb1 has a Mini-AB port and external isp1301 transceiver */ .otg = 2, -#ifdef CONFIG_USB_GADGET_OMAP +#if IS_ENABLED (CONFIG_USB_OMAP ) .hmc_mode = 19, /* 0:host(off) 1:dev|otg 2:disabled *//* .hmc_mode = 21,*/ /* 0:host(off) 1:dev(loopback) 2:host(loopback) */ #elif defined(CONFIG_USB_OHCI_HCD ) || defined(CONFIG_USB_OHCI_HCD_MODULE )
arch/arm/mach-omap1/board-h3.c +1 -1
@@ -366,7 +366,7 @@ static struct omap_usb_config h3_usb_config __initdata = {/* usb1 has a Mini-AB port and external isp1301 transceiver */ .otg = 2, -#ifdef CONFIG_USB_GADGET_OMAP +#if IS_ENABLED (CONFIG_USB_OMAP ) .hmc_mode = 19, /* 0:host(off) 1:dev|otg 2:disabled */#elif defined(CONFIG_USB_OHCI_HCD ) || defined(CONFIG_USB_OHCI_HCD_MODULE )/* NONSTANDARD CABLE NEEDED (B-to-Mini-B) */
arch/arm/mach-omap1/board-innovator.c +1 -1
@@ -312,7 +312,7 @@ static struct omap_usb_config h2_usb_config __initdata = {/* usb1 has a Mini-AB port and external isp1301 transceiver */ .otg = 2, -#ifdef CONFIG_USB_GADGET_OMAP +#if IS_ENABLED (CONFIG_USB_OMAP ) .hmc_mode = 19, /* 0:host(off) 1:dev|otg 2:disabled *//* .hmc_mode = 21,*/ /* 0:host(off) 1:dev(loopback) 2:host(loopback) */ #elif defined(CONFIG_USB_OHCI_HCD ) || defined(CONFIG_USB_OHCI_HCD_MODULE )
arch/arm/mach-omap1/board-osk.c +1 -1
@@ -280,7 +280,7 @@ static struct omap_usb_config osk_usb_config __initdata = {* be used, with a NONSTANDARD gender-bending cable/dongle, as * a peripheral. */ -#ifdef CONFIG_USB_GADGET_OMAP +#if IS_ENABLED (CONFIG_USB_OMAP ) .register_dev = 1, .hmc_mode = 0,#else
drivers/usb/phy/phy-isp1301-omap.c +1 -1
@@ -1295,7 +1295,7 @@ isp1301_set_host(struct usb_otg *otg, struct usb_bus *host)return isp1301_otg_enable (isp);return 0 ; -#elif !defined(CONFIG_USB_GADGET_OMAP ) +#elif !IS_ENABLED (CONFIG_USB_OMAP )// FIXME update its refcount otg->host = host;
Signature · 1 line
2.0.0
PATCH 108/181 USB: EHCI: avoid BIOS handover on the HASEE E200
In reply to Jiri SlabyFrom: Alan Stern <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit b0a50e92bda3c4aeb8017d4e6c6e92146ebd5c9b upstream.
Leandro Liptak reports that his HASEE E200 computer hangs when we ask the BIOS to hand over control of the EHCI host controller. This definitely sounds like a bug in the BIOS, but at the moment there is no way to fix it.
This patch works around the problem by avoiding the handoff whenever the motherboard and BIOS version match those of Leandro's computer.
--- drivers/usb/host/pci-quirks.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/usb/host/pci-quirks.c +16 -3
@@ -645,6 +645,14 @@ static const struct dmi_system_id ehci_dmi_nohandoff_table[] = { DMI_MATCH(DMI_BIOS_VERSION, "Lucid-"), }, }, + { + /* HASEE E200 */ + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "HASEE"), + DMI_MATCH(DMI_BOARD_NAME, "E210"), + DMI_MATCH(DMI_BIOS_VERSION, "6.00"), + }, + }, { } };
@@ -654,9 +662,14 @@ static void ehci_bios_handoff(struct pci_dev *pdev, {int try_handoff =1 , tried_handoff =0 ; -/* The Pegatron Lucid tablet sporadically waits for 98 seconds trying -* the handoff on its unused controller. Skip it. */ -if (pdev->vendor ==0x8086 && pdev->device ==0x283a ) { +/* +* The Pegatron Lucid tablet sporadically waits for 98 seconds trying +* the handoff on its unused controller. Skip it. +* +* The HASEE E200 hangs when the semaphore is set (bugzilla #77021). +*/ +if (pdev->vendor ==0x8086 && (pdev->device ==0x283a || + pdev->device ==0x27cc )) {if (dmi_check_system (ehci_dmi_nohandoff_table)) try_handoff =0 ; }
Signature · 1 line
2.0.0
PATCH 109/181 USB: option: fix runtime PM handling
In reply to Jiri SlabyFrom: Johan Hovold <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit acf47d4f9c39b1cba467aa9442fc2efe0b1da741 upstream.
Fix potential I/O while runtime suspended due to missing PM operations in send_setup.
option driver")
--- drivers/usb/serial/option.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/usb/serial/option.c +10 -1
@@ -1925,6 +1925,7 @@ static int option_send_setup(struct usb_serial_port *port)struct option_private *priv = intfdata->private;struct usb_wwan_port_private *portdata;int val =0 ; +int res; portdata =usb_get_serial_port_data (port);
@@ -1933,9 +1934,17 @@ static int option_send_setup(struct usb_serial_port *port)if (portdata->rts_state) val |=0x02 ; -return usb_control_msg (serial->dev,usb_rcvctrlpipe (serial->dev,0 ), + res =usb_autopm_get_interface (serial->interface); +if (res) +return res; + + res =usb_control_msg (serial->dev,usb_rcvctrlpipe (serial->dev,0 ),0x22 ,0x21 , val, priv->bInterfaceNumber,NULL ,0 ,USB_CTRL_SET_TIMEOUT ); + +usb_autopm_put_interface (serial->interface); + +return res; }MODULE_AUTHOR (DRIVER_AUTHOR );
Signature · 1 line
2.0.0
PATCH 110/181 hugetlb: restrict hugepage_migration_support() to x86_64
In reply to Jiri SlabyFrom: Naoya Horiguchi <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit c177c81e09e517bbf75b67762cdab1b83aba6976 upstream.
Currently hugepage migration is available for all archs which support pmd-level hugepage, but testing is done only for x86_64 and there're bugs for other archs. So to avoid breaking such archs, this patch limits the availability strictly to x86_64 until developers of other archs get interested in enabling this feature.
Simply disabling hugepage migration on non-x86_64 archs is not enough to fix the reported problem where sys_move_pages() hits the BUG_ON() in follow_page(FOLL_GET), so let's fix this by checking if hugepage migration is supported in vma_migratable().
--- arch/arm/mm/hugetlbpage.c | 5 ----- arch/arm64/mm/hugetlbpage.c | 5 ----- arch/ia64/mm/hugetlbpage.c | 5 ----- arch/metag/mm/hugetlbpage.c | 5 ----- arch/mips/mm/hugetlbpage.c | 5 ----- arch/powerpc/mm/hugetlbpage.c | 10 ---------- arch/s390/mm/hugetlbpage.c | 5 ----- arch/sh/mm/hugetlbpage.c | 5 ----- arch/sparc/mm/hugetlbpage.c | 5 ----- arch/tile/mm/hugetlbpage.c | 5 ----- arch/x86/Kconfig | 4 ++++ arch/x86/mm/hugetlbpage.c | 10 ---------- include/linux/hugetlb.h | 13 +++++-------- include/linux/mempolicy.h | 6 ++++++ mm/Kconfig | 3 +++ 15 files changed, 18 insertions(+), 73 deletions(-)
arch/arm/mm/hugetlbpage.c +0 -5
@@ -56,8 +56,3 @@ int pmd_huge(pmd_t pmd) {return pmd_val (pmd) && !(pmd_val (pmd) &PMD_TABLE_BIT ); } - -int pmd_huge_support (void ) -{ -return 1 ; -}
arch/arm64/mm/hugetlbpage.c +0 -5
@@ -58,11 +58,6 @@ int pud_huge(pud_t pud)#endif } -int pmd_huge_support (void ) -{ -return 1 ; -} -static __init int setup_hugepagesz (char *opt) {unsigned long ps =memparse (opt, &opt);
arch/ia64/mm/hugetlbpage.c +0 -5
@@ -114,11 +114,6 @@ int pud_huge(pud_t pud)return 0 ; } -int pmd_huge_support (void ) -{ -return 0 ; -} -struct page *follow_huge_pmd (struct mm_struct *mm,unsigned long address,pmd_t *pmd,int write) {
arch/metag/mm/hugetlbpage.c +0 -5
@@ -110,11 +110,6 @@ int pud_huge(pud_t pud)return 0 ; } -int pmd_huge_support (void ) -{ -return 1 ; -} -struct page *follow_huge_pmd (struct mm_struct *mm,unsigned long address,pmd_t *pmd,int write) {
arch/mips/mm/hugetlbpage.c +0 -5
@@ -85,11 +85,6 @@ int pud_huge(pud_t pud)return (pud_val (pud) & _PAGE_HUGE) !=0 ; } -int pmd_huge_support (void ) -{ -return 1 ; -} -struct page *follow_huge_pmd (struct mm_struct *mm,unsigned long address,pmd_t *pmd,int write)
arch/powerpc/mm/hugetlbpage.c +0 -10
@@ -86,11 +86,6 @@ int pgd_huge(pgd_t pgd)*/ return ((pgd_val(pgd) & 0x3) != 0x0); } - -int pmd_huge_support (void ) -{ -return 1 ; -}#else int pmd_huge (pmd_t pmd) {
@@ -106,11 +101,6 @@ int pgd_huge(pgd_t pgd) {return 0 ; } - -int pmd_huge_support (void ) -{ -return 0 ; -}#endif pte_t *huge_pte_offset (struct mm_struct *mm,unsigned long addr)
arch/s390/mm/hugetlbpage.c +0 -5
@@ -223,11 +223,6 @@ int pud_huge(pud_t pud)return 0 ; } -int pmd_huge_support (void ) -{ -return 1 ; -} -struct page *follow_huge_pmd (struct mm_struct *mm,unsigned long address,pmd_t *pmdp,int write) {
arch/sh/mm/hugetlbpage.c +0 -5
@@ -83,11 +83,6 @@ int pud_huge(pud_t pud)return 0 ; } -int pmd_huge_support (void ) -{ -return 0 ; -} -struct page *follow_huge_pmd (struct mm_struct *mm,unsigned long address,pmd_t *pmd,int write) {
arch/sparc/mm/hugetlbpage.c +0 -5
@@ -234,11 +234,6 @@ int pud_huge(pud_t pud)return 0 ; } -int pmd_huge_support (void ) -{ -return 0 ; -} -struct page *follow_huge_pmd (struct mm_struct *mm,unsigned long address,pmd_t *pmd,int write) {
arch/tile/mm/hugetlbpage.c +0 -5
@@ -166,11 +166,6 @@ int pud_huge(pud_t pud)return !!(pud_val (pud) & _PAGE_HUGE_PAGE); } -int pmd_huge_support (void ) -{ -return 1 ; -} -struct page *follow_huge_pmd (struct mm_struct *mm,unsigned long address,pmd_t *pmd,int write) {
arch/x86/Kconfig +4 -0
@@ -1881,6 +1881,10 @@ config USE_PERCPU_NUMA_NODE_ID def_bool y depends on NUMA +config ARCH_ENABLE_HUGEPAGE_MIGRATION + def_bool y + depends on X86_64 && HUGETLB_PAGE && MIGRATION + menu "Power management and ACPI options" config ARCH_HIBERNATION_HEADER
arch/x86/mm/hugetlbpage.c +0 -10
@@ -58,11 +58,6 @@ follow_huge_pmd(struct mm_struct *mm, unsigned long address, {return NULL ; } - -int pmd_huge_support (void ) -{ -return 0 ; -}#else struct page *
@@ -80,11 +75,6 @@ int pud_huge(pud_t pud) {return !!(pud_val (pud) & _PAGE_PSE); } - -int pmd_huge_support (void ) -{ -return 1 ; -}#endif /* x86_64 also uses this file */
include/linux/hugetlb.h +5 -8
@@ -387,15 +387,13 @@ static inline pgoff_t basepage_index(struct page *page)extern void dissolve_free_huge_pages (unsigned long start_pfn,unsigned long end_pfn); -int pmd_huge_support (void ); -/* -* Currently hugepage migration is enabled only for pmd-based hugepage. -* This function will be updated when hugepage migration is more widely -* supported. -*/ static inline int hugepage_migration_support (struct hstate *h) { -return pmd_huge_support () && (huge_page_shift (h) ==PMD_SHIFT ); +#ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION +return huge_page_shift (h) ==PMD_SHIFT ; +#else +return 0 ; +#endif }#else /* CONFIG_HUGETLB_PAGE */
@@ -425,7 +423,6 @@ static inline pgoff_t basepage_index(struct page *page) return page->index; }#define dissolve_free_huge_pages (s, e) do {} while (0) -#define pmd_huge_support () 0#define hugepage_migration_support (h) 0#endif /* CONFIG_HUGETLB_PAGE */
include/linux/mempolicy.h +6 -0
@@ -175,6 +175,12 @@ static inline int vma_migratable(struct vm_area_struct *vma) {if (vma->vm_flags & (VM_IO |VM_PFNMAP ))return 0 ; + +#ifndef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION +if (vma->vm_flags &VM_HUGETLB ) +return 0 ; +#endif +/* * Migration allocates pages in the highest zone. If we cannot * do so then migration (at least from node to node) is not
mm/Kconfig +3 -0
@@ -254,6 +254,9 @@ config MIGRATION pages as migration can relocate pages to satisfy a huge page allocation instead of reclaiming. +config ARCH_ENABLE_HUGEPAGE_MIGRATION + boolean + config PHYS_ADDR_T_64BIT def_bool 64BIT || ARCH_PHYS_ADDR_T_64BIT
Signature · 1 line
2.0.0
PATCH 111/181 mm: vmscan: do not throttle based on pfmemalloc reserves if node has no ZONE_NORMAL
In reply to Jiri SlabyFrom: Mel Gorman <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 675becce15f320337499bc1a9356260409a5ba29 upstream.
throttle_direct_reclaim() is meant to trigger during swap-over-network during which the min watermark is treated as a pfmemalloc reserve. It throttes on the first node in the zonelist but this is flawed.
The user-visible impact is that a process running on CPU whose local memory node has no ZONE_NORMAL will stall for prolonged periods of time, possibly indefintely. This is due to throttle_direct_reclaim thinking the pfmemalloc reserves are depleted when in fact they don't exist on that node.
On a NUMA machine running a 32-bit kernel (I know) allocation requests from CPUs on node 1 would detect no pfmemalloc reserves and the process gets throttled. This patch adjusts throttling of direct reclaim to throttle based on the first node in the zonelist that has a usable ZONE_NORMAL or lower zone.
--- mm/vmscan.c | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-)
mm/vmscan.c +37 -6
@@ -2484,10 +2484,17 @@ static bool pfmemalloc_watermark_ok(pg_data_t *pgdat)for (i =0 ; i <=ZONE_NORMAL ; i++) { zone = &pgdat->node_zones[i]; +if (!populated_zone (zone)) +continue ; + pfmemalloc_reserve +=min_wmark_pages (zone); free_pages +=zone_page_state (zone,NR_FREE_PAGES ); } +/* If there are no reserves (unexpected config) then do not throttle */ +if (!pfmemalloc_reserve) +return true; + wmark_ok = free_pages > pfmemalloc_reserve /2 ;/* kswapd must be awake if processes are being throttled */
@@ -2512,9 +2519,9 @@ static bool pfmemalloc_watermark_ok(pg_data_t *pgdat)static bool throttle_direct_reclaim (gfp_t gfp_mask,struct zonelist *zonelist,nodemask_t *nodemask) { +struct zoneref *z;struct zone *zone; -int high_zoneidx =gfp_zone (gfp_mask); -pg_data_t *pgdat; +pg_data_t *pgdat =NULL ;/* * Kernel threads should not be throttled as they may be indirectly
@@ -2533,10 +2540,34 @@ static bool throttle_direct_reclaim(gfp_t gfp_mask, struct zonelist *zonelist,if (fatal_signal_pending (current)) goto out; -/* Check if the pfmemalloc reserves are ok */ -first_zones_zonelist (zonelist, high_zoneidx,NULL , &zone); - pgdat = zone->zone_pgdat; -if (pfmemalloc_watermark_ok (pgdat)) +/* +* Check if the pfmemalloc reserves are ok by finding the first node +* with a usable ZONE_NORMAL or lower zone. The expectation is that +* GFP_KERNEL will be required for allocating network buffers when +* swapping over the network so ZONE_HIGHMEM is unusable. +* +* Throttling is based on the first usable node and throttled processes +* wait on a queue until kswapd makes progress and wakes them. There +* is an affinity then between processes waking up and where reclaim +* progress has been made assuming the process wakes on the same node. +* More importantly, processes running on remote nodes will not compete +* for remote pfmemalloc reserves and processes on different nodes +* should make reasonable progress. +*/ +for_each_zone_zonelist_nodemask (zone, z, zonelist, + gfp_mask, nodemask) { +if (zone_idx (zone) >ZONE_NORMAL ) +continue ; + +/* Throttle based on the first usable node */ + pgdat = zone->zone_pgdat; +if (pfmemalloc_watermark_ok (pgdat)) + goto out; +break ; + } + +/* If no zone was usable by the allocation flags then do not throttle */ +if (!pgdat) goto out;/* Account for the throttling */
Signature · 1 line
2.0.0
PATCH 112/181 mm: page_alloc: use word-based accesses for get/set pageblock bitmaps
In reply to Jiri SlabyFrom: Mel Gorman <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit e58469bafd0524e848c3733bc3918d854595e20f upstream.
The test_bit operations in get/set pageblock flags are expensive. This patch reads the bitmap on a word basis and use shifts and masks to isolate the bits of interest. Similarly masks are used to set a local copy of the bitmap and then use cmpxchg to update the bitmap if there have been no other changes made in parallel.
In a test running dd onto tmpfs the overhead of the pageblock-related functions went from 1.27% in profiles to 0.5%.
In addition to the performance benefits, this patch closes races that are possible between:
a) get_ and set_pageblock_migratetype(), where get_pageblock_migratetype() reads part of the bits before and other part of the bits after set_pageblock_migratetype() has updated them.
b) set_pageblock_migratetype() and set_pageblock_skip(), where the non-atomic read-modify-update set bit operation in set_pageblock_skip() will cause lost updates to some bits changed in the set_pageblock_migratetype().
Joonsoo Kim first reported the case a) via code inspection. Vlastimil Babka's testing with a debug patch showed that either a) or b) occurs roughly once per mmtests' stress-highalloc benchmark (although not necessarily in the same pageblock). Furthermore during development of unrelated compaction patches, it was observed that frequent calls to {start,undo}_isolate_page_range() the race occurs several thousands of times and has resulted in NULL pointer dereferences in move_freepages() and free_one_page() in places where free_list[migratetype] is manipulated by e.g. list_move(). Further debugging confirmed that migratetype had invalid value of 6, causing out of bounds access to the free_list array.
That confirmed that the race exist, although it may be extremely rare, and currently only fatal where page isolation is performed due to memory hot remove. Races on pageblocks being updated by set_pageblock_migratetype(), where both old and new migratetype are lower MIGRATE_RESERVE, currently cannot result in an invalid value being observed, although theoretically they may still lead to unexpected creation or destruction of MIGRATE_RESERVE pageblocks. Furthermore, things could get suddenly worse when memory isolation is used more, or when new migratetypes are added.
After this patch, the race has no longer been observed in testing.
--- include/linux/mmzone.h | 6 ++++- include/linux/pageblock-flags.h | 37 ++++++++++++++++++++++++----- mm/page_alloc.c | 52 +++++++++++++++++++++++++---------------- 3 files changed, 68 insertions(+), 27 deletions(-)
include/linux/mmzone.h +5 -1
@@ -75,9 +75,13 @@ enum {extern int page_group_by_mobility_disabled; +#define NR_MIGRATETYPE_BITS (PB_migrate_end - PB_migrate + 1) +#define MIGRATETYPE_MASK ((1UL << NR_MIGRATETYPE_BITS) - 1) +static inline int get_pageblock_migratetype (struct page *page) { -return get_pageblock_flags_group (page, PB_migrate, PB_migrate_end); +BUILD_BUG_ON (PB_migrate_end - PB_migrate !=2 ); +return get_pageblock_flags_mask (page, PB_migrate_end,MIGRATETYPE_MASK ); }struct free_area {
include/linux/pageblock-flags.h +31 -6
@@ -30,9 +30,12 @@ enum pageblock_bits { PB_migrate, PB_migrate_end = PB_migrate +3 -1 ,/* 3 bits required for migrate types */ -#ifdef CONFIG_COMPACTION PB_migrate_skip,/* If set the block is skipped by compaction */ -#endif /* CONFIG_COMPACTION */ + +/* +* Assume the bits will always align on a word. If this assumption +* changes then get/set pageblock needs updating. +*/ NR_PAGEBLOCK_BITS };
@@ -62,11 +65,33 @@ extern int pageblock_order;/* Forward declaration */ struct page ; +unsigned long get_pageblock_flags_mask (struct page *page, +unsigned long end_bitidx, +unsigned long mask); +void set_pageblock_flags_mask (struct page *page, +unsigned long flags, +unsigned long end_bitidx, +unsigned long mask); +/* Declarations for getting and setting flags. See mm/page_alloc.c */ -unsigned long get_pageblock_flags_group (struct page *page, -int start_bitidx,int end_bitidx); -void set_pageblock_flags_group (struct page *page,unsigned long flags, -int start_bitidx,int end_bitidx); +static inline unsigned long get_pageblock_flags_group (struct page *page, +int start_bitidx,int end_bitidx) +{ +unsigned long nr_flag_bits = end_bitidx - start_bitidx +1 ; +unsigned long mask = (1 << nr_flag_bits) -1 ; + +return get_pageblock_flags_mask (page, end_bitidx, mask); +} + +static inline void set_pageblock_flags_group (struct page *page, +unsigned long flags, +int start_bitidx,int end_bitidx) +{ +unsigned long nr_flag_bits = end_bitidx - start_bitidx +1 ; +unsigned long mask = (1 << nr_flag_bits) -1 ; + +set_pageblock_flags_mask (page, flags, end_bitidx, mask); +}#ifdef CONFIG_COMPACTION #define get_pageblock_skip (page) \
mm/page_alloc.c +32 -20
85 lines not on this page · raw message
Signature · 1 line
2.0.0
PATCH 113/181 mm/memory-failure.c-failure: send right signal code to correct thread
In reply to Jiri SlabyFrom: Tony Luck <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit a70ffcac741d31a406c1d2b832ae43d658e7e1cf upstream.
When a thread in a multi-threaded application hits a machine check because of an uncorrectable error in memory - we want to send the SIGBUS with si.si_code = BUS_MCEERR_AR to that thread. Currently we fail to do that if the active thread is not the primary thread in the process. collect_procs() just finds primary threads and this test:
if ((flags & MF_ACTION_REQUIRED) && t == current) {will see that the thread we found isn't the current thread and so send a si.si_code = BUS_MCEERR_AO to the primary (and nothing to the active thread at this time).
We can fix this by checking whether "current" shares the same mm with the process that collect_procs() said owned the page. If so, we send the SIGBUS to current (with code BUS_MCEERR_AR).
--- mm/memory-failure.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/memory-failure.c +2 -2
@@ -208,9 +208,9 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,#endif si.si_addr_lsb =compound_order (compound_head (page)) +PAGE_SHIFT ; -if ((flags &MF_ACTION_REQUIRED ) && t == current) { +if ((flags &MF_ACTION_REQUIRED ) && t->mm == current->mm) { si.si_code =BUS_MCEERR_AR ; - ret =force_sig_info (SIGBUS , &si, t); + ret =force_sig_info (SIGBUS , &si, current); }else {/* * Don't use force here, it's convenient if the signal
Signature · 1 line
2.0.0
PATCH 114/181 mm/memory-failure.c: don't let collect_procs() skip over processes for MF_ACTION_REQUIRED
In reply to Jiri SlabyFrom: Tony Luck <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 74614de17db6fb472370c426d4f934d8d616edf2 upstream.
When Linux sees an "action optional" machine check (where h/w has reported an error that is not in the current execution path) we generally do not want to signal a process, since most processes do not have a SIGBUS handler - we'd just prematurely terminate the process for a problem that they might never actually see.
task_early_kill() decides whether to consider a process - and it checks whether this specific process has been marked for early signals with "prctl", or if the system administrator has requested early signals for all processes using /proc/sys/vm/memory_failure_early_kill.
But for MF_ACTION_REQUIRED case we must not defer. The error is in the execution path of the current thread so we must send the SIGBUS immediatley.
Fix by passing a flag argument through collect_procs*() to task_early_kill() so it knows whether we can defer or must take action.
--- mm/memory-failure.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
mm/memory-failure.c +12 -9
@@ -384,10 +384,12 @@ static void kill_procs(struct list_head *to_kill, int forcekill, int trapno, } } -static int task_early_kill (struct task_struct *tsk) +static int task_early_kill (struct task_struct *tsk,int force_early) {if (!tsk->mm)return 0 ; +if (force_early) +return 1 ;if (tsk->flags &PF_MCE_PROCESS )return !!(tsk->flags &PF_MCE_EARLY );return sysctl_memory_failure_early_kill;
@@ -397,7 +399,7 @@ static int task_early_kill(struct task_struct *tsk)* Collect processes when the error hit an anonymous page. */ static void collect_procs_anon (struct page *page,struct list_head *to_kill, -struct to_kill **tkc) +struct to_kill **tkc,int force_early) {struct vm_area_struct *vma;struct task_struct *tsk;
@@ -413,7 +415,7 @@ static void collect_procs_anon(struct page *page, struct list_head *to_kill,for_each_process (tsk) {struct anon_vma_chain *vmac; -if (!task_early_kill (tsk)) +if (!task_early_kill (tsk, force_early))continue ;anon_vma_interval_tree_foreach (vmac, &av->rb_root, pgoff, pgoff) {
@@ -432,7 +434,7 @@ static void collect_procs_anon(struct page *page, struct list_head *to_kill,* Collect processes when the error hit a file mapped page. */ static void collect_procs_file (struct page *page,struct list_head *to_kill, -struct to_kill **tkc) +struct to_kill **tkc,int force_early) {struct vm_area_struct *vma;struct task_struct *tsk;
@@ -443,7 +445,7 @@ static void collect_procs_file(struct page *page, struct list_head *to_kill,for_each_process (tsk) {pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT -PAGE_SHIFT ); -if (!task_early_kill (tsk)) +if (!task_early_kill (tsk, force_early))continue ; vma_interval_tree_foreach(vma, &mapping->i_mmap, pgoff,
@@ -469,7 +471,8 @@ static void collect_procs_file(struct page *page, struct list_head *to_kill,* First preallocate one tokill structure outside the spin locks, * so that we can kill at least one process reasonably reliable. */ -static void collect_procs (struct page *page,struct list_head *tokill) +static void collect_procs (struct page *page,struct list_head *tokill, +int force_early) {struct to_kill *tk;
@@ -480,9 +483,9 @@ static void collect_procs(struct page *page, struct list_head *tokill)if (!tk)return ;if (PageAnon (page)) -collect_procs_anon (page, tokill, &tk); +collect_procs_anon (page, tokill, &tk, force_early);else -collect_procs_file (page, tokill, &tk); +collect_procs_file (page, tokill, &tk, force_early);kfree (tk); }
@@ -967,7 +970,7 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn,* there's nothing that can be done. */ if (kill) -collect_procs (ppage, &tokill); +collect_procs (ppage, &tokill, flags &MF_ACTION_REQUIRED ); ret =try_to_unmap (ppage, ttu);if (ret !=SWAP_SUCCESS )
Signature · 1 line
2.0.0
PATCH 115/181 mm/memory-failure.c: support use of a dedicated thread to handle SIGBUS(BUS_MCEERR_AO)
In reply to Jiri SlabyFrom: Naoya Horiguchi <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 3ba08129e38437561df44c36b7ea9081185d5333 upstream.
Currently memory error handler handles action optional errors in the deferred manner by default. And if a recovery aware application wants to handle it immediately, it can do it by setting PF_MCE_EARLY flag. However, such signal can be sent only to the main thread, so it's problematic if the application wants to have a dedicated thread to handler such signals.
So this patch adds dedicated thread support to memory error handler. We have PF_MCE_EARLY flags for each thread separately, so with this patch AO signal is sent to the thread with PF_MCE_EARLY flag set, not the main thread. If you want to implement a dedicated thread, you call prctl() to set PF_MCE_EARLY on the thread.
Memory error handler collects processes to be killed, so this patch lets it check PF_MCE_EARLY flag on each thread in the collecting routines.
No behavioral change for all non-early kill cases.
Tony said:
: The old behavior was crazy - someone with a multithreaded process might : well expect that if they call prctl(PF_MCE_EARLY) in just one thread, then : that thread would see the SIGBUS with si_code = BUS_MCEERR_A0 - even if : that thread wasn't the main thread for the process.
--- Documentation/vm/hwpoison.txt | 5 ++++ mm/memory-failure.c | 56 +++++++++++++++++++++++++++++++++---------- 2 files changed, 48 insertions(+), 13 deletions(-)
Documentation/vm/hwpoison.txt +5 -0
@@ -84,6 +84,11 @@ PR_MCE_KILL PR_MCE_KILL_EARLY: Early kill PR_MCE_KILL_LATE: Late kill PR_MCE_KILL_DEFAULT: Use system global default + Note that if you want to have a dedicated thread which handles + the SIGBUS(BUS_MCEERR_AO) on behalf of the process, you should + call prctl(PR_MCE_KILL_EARLY) on the designated thread. Otherwise, + the SIGBUS is sent to the main thread. + PR_MCE_KILL_GET return current mode
mm/memory-failure.c +43 -13
92 lines not on this page · raw message
Signature · 1 line
2.0.0
PATCH 116/181 mm: fix sleeping function warning from __put_anon_vma
In reply to Jiri SlabyFrom: Hugh Dickins <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 7f39dda9d86fb4f4f17af0de170decf125726f8c upstream.
Trinity reports BUG:
sleeping function called from invalid context at kernel/locking/rwsem.c:47 in_atomic(): 0, irqs_disabled(): 0, pid: 5787, name: trinity-c27
__might_sleep < down_write < __put_anon_vma < page_get_anon_vma < migrate_pages < compact_zone < compact_zone_order < try_to_compact_pages ..
Right, since conversion to mutex then rwsem, we should not put_anon_vma() from inside an rcu_read_lock()ed section: fix the two places that did so. And add might_sleep() to anon_vma_free(), as suggested by Peter Zijlstra.
--- mm/rmap.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
mm/rmap.c +5 -3
@@ -103,6 +103,7 @@ static inline void anon_vma_free(struct anon_vma *anon_vma)* LOCK should suffice since the actual taking of the lock must * happen _before_ what follows. */ +might_sleep ();if (rwsem_is_locked (&anon_vma->root->rwsem)) {anon_vma_lock_write (anon_vma);anon_vma_unlock_write (anon_vma);
@@ -426,8 +427,9 @@ struct anon_vma *page_get_anon_vma(struct page *page)* above cannot corrupt). */ if (!page_mapped (page)) { +rcu_read_unlock ();put_anon_vma (anon_vma); - anon_vma =NULL ; +return NULL ; } out:rcu_read_unlock ();
@@ -477,9 +479,9 @@ struct anon_vma *page_lock_anon_vma_read(struct page *page) }if (!page_mapped (page)) { +rcu_read_unlock ();put_anon_vma (anon_vma); - anon_vma =NULL ; - goto out; +return NULL ; }/* we pinned the anon_vma, its safe to sleep */
Signature · 1 line
2.0.0
PATCH 117/181 HID: core: fix validation of report id 0
In reply to Jiri SlabyFrom: Kees Cook <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 1b15d2e5b8077670b1e6a33250a0d9577efff4a5 upstream.
Some drivers use the first HID report in the list instead of using an index. In these cases, validation uses ID 0, which was supposed to mean "first known report". This fixes the problem, which was causing at least the lgff family of devices to stop working since hid_validate_values was being called with ID 0, but the devices used single numbered IDs for their reports:
0x05, 0x01, /* Usage Page (Desktop), */ 0x09, 0x05, /* Usage (Gamepad), */ 0xA1, 0x01, /* Collection (Application), */ 0xA1, 0x02, /* Collection (Logical), */ 0x85, 0x01, /* Report ID (1), */
...
--- drivers/hid/hid-core.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/hid/hid-core.c +11 -1
@@ -842,7 +842,17 @@ struct hid_report *hid_validate_values(struct hid_device *hid,* ->numbered being checked, which may not always be the case when * drivers go to access report values. */ - report = hid->report_enum[type].report_id_hash[id]; +if (id ==0 ) { +/* +* Validating on id 0 means we should examine the first +* report in the list. +*/ + report =list_entry ( + hid->report_enum[type].report_list.next, + struct hid_report, list); + }else { + report = hid->report_enum[type].report_id_hash[id]; + }if (!report) {hid_err (hid,"missing %s %u\n" , hid_report_names[type], id);return NULL ;
Signature · 1 line
2.0.0
PATCH 118/181 mm: vmscan: clear kswapd's special reclaim powers before exiting
In reply to Jiri SlabyFrom: Johannes Weiner <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 71abdc15adf8c702a1dd535f8e30df50758848d2 upstream.
When kswapd exits, it can end up taking locks that were previously held by allocating tasks while they waited for reclaim. Lockdep currently warns about this:
Quoted 34 lines · Gu Zheng
inconsistent {RECLAIM_FS-ON-W} -> {IN-RECLAIM_FS-R} usage. kswapd2/1151 [HC0[0]:SC0[0]:HE1:SE1] takes:
(&sig->group_rwsem){+++++?}, at:exit_signals+0x24/0x130
{RECLAIM_FS-ON-W} state was registered at:mark_held_locks+0xb9/0x140 lockdep_trace_alloc+0x7a/0xe0 kmem_cache_alloc_trace+0x37/0x240 flex_array_alloc+0x99/0x1a0 cgroup_attach_task+0x63/0x430 attach_task_by_pid+0x210/0x280 cgroup_procs_write+0x16/0x20 cgroup_file_write+0x120/0x2c0 vfs_write+0xc0/0x1f0 SyS_write+0x4c/0xa0 tracesys+0xdd/0xe2 irq event stamp: 49 hardirqs last enabled at (49): _raw_spin_unlock_irqrestore+0x36/0x70 hardirqs last disabled at (48): _raw_spin_lock_irqsave+0x2b/0xa0 softirqs last enabled at (0): copy_process.part.24+0x627/0x15f0 softirqs last disabled at (0): (null)other info that might help us debug this:
Possible unsafe locking scenario:CPU0 ---- lock(&sig->group_rwsem); <Interrupt> lock(&sig->group_rwsem);*** DEADLOCK ***
no locks held by kswapd2/1151.
Quoted 13 lines
stack backtrace: CPU: 30 PID: 1151 Comm: kswapd2 Not tainted 3.10.39+ #4 Call Trace: dump_stack+0x19/0x1b print_usage_bug+0x1f7/0x208 mark_lock+0x21d/0x2a0 __lock_acquire+0x52a/0xb60 lock_acquire+0xa2/0x140 down_read+0x51/0xa0 exit_signals+0x24/0x130 do_exit+0xb5/0xa50 kthread+0xdb/0x100 ret_from_fork+0x7c/0xb0
This is because the kswapd thread is still marked as a reclaimer at the time of exit. But because it is exiting, nobody is actually waiting on it to make reclaim progress anymore, and it's nothing but a regular thread at this point. Be tidy and strip it of all its powers (PF_MEMALLOC, PF_SWAPWRITE, PF_KSWAPD, and the lockdep reclaim state) before returning from the thread function.
--- mm/vmscan.c | 3 +++ 1 file changed, 3 insertions(+)
mm/vmscan.c +3 -0
@@ -3298,7 +3298,10 @@ static int kswapd(void *p) } } + tsk->flags &= ~(PF_MEMALLOC |PF_SWAPWRITE |PF_KSWAPD ); current->reclaim_state =NULL ; +lockdep_clear_current_reclaim_state (); +return 0 ; }
Signature · 1 line
2.0.0
PATCH 119/181 ptrace: fix fork event messages across pid namespaces
In reply to Jiri SlabyFrom: Matthew Dempsky <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 4e52365f279564cef0ddd41db5237f0471381093 upstream.
When tracing a process in another pid namespace, it's important for fork event messages to contain the child's pid as seen from the tracer's pid namespace, not the parent's. Otherwise, the tracer won't be able to correlate the fork event with later SIGTRAP signals it receives from the child.
We still risk a race condition if a ptracer from a different pid namespace attaches after we compute the pid_t value. However, sending a bogus fork event message in this unlikely scenario is still a vast improvement over the status quo where we always send bogus fork event messages to debuggers in a different pid namespace than the forking process.
--- include/linux/ptrace.h | 32 ++++++++++++++++++++++++++++++++ kernel/fork.c | 10 +++++++--- 2 files changed, 39 insertions(+), 3 deletions(-)
include/linux/ptrace.h +32 -0
@@ -5,6 +5,7 @@#include <linux/sched.h> /* For struct task_struct. */ #include <linux/err.h> /* for IS_ERR_VALUE */ #include <linux/bug.h> /* For BUG_ON. */ +#include <linux/pid_namespace.h> /* For task_active_pid_ns. */ #include <uapi/linux/ptrace.h> /*
@@ -129,6 +130,37 @@ static inline void ptrace_event(int event, unsigned long message) }/** +* ptrace_event_pid - possibly stop for a ptrace event notification +* @event: %PTRACE_EVENT_* value to report +* @pid: process identifier for %PTRACE_GETEVENTMSG to return +* +* Check whether @event is enabled and, if so, report @event and @pid +* to the ptrace parent. @pid is reported as the pid_t seen from the +* the ptrace parent's pid namespace. +* +* Called without locks. +*/ +static inline void ptrace_event_pid (int event,struct pid *pid) +{ +/* +* FIXME: There's a potential race if a ptracer in a different pid +* namespace than parent attaches between computing message below and +* when we acquire tasklist_lock in ptrace_stop(). If this happens, +* the ptracer will get a bogus pid from PTRACE_GETEVENTMSG. +*/ +unsigned long message =0 ; +struct pid_namespace *ns; + +rcu_read_lock (); + ns =task_active_pid_ns (rcu_dereference (current->parent)); +if (ns) + message =pid_nr_ns (pid, ns); +rcu_read_unlock (); + +ptrace_event (event, message); +} + +/** * ptrace_init_task - initialize ptrace state for a new child * @child: new child task * @ptrace: true if child should be ptrace'd by parent's tracer
kernel/fork.c +7 -3
@@ -1609,10 +1609,12 @@ long do_fork(unsigned long clone_flags,*/ if (!IS_ERR (p)) {struct completion vfork; +struct pid *pid;trace_sched_process_fork (current, p); - nr =task_pid_vnr (p); + pid =get_task_pid (p,PIDTYPE_PID ); + nr =pid_vnr (pid);if (clone_flags &CLONE_PARENT_SETTID )put_user (nr, parent_tidptr);
@@ -1627,12 +1629,14 @@ long do_fork(unsigned long clone_flags,/* forking complete and child started to run, tell ptracer */ if (unlikely (trace)) -ptrace_event (trace, nr); +ptrace_event_pid (trace, pid);if (clone_flags &CLONE_VFORK ) {if (!wait_for_vfork_done (p, &vfork)) -ptrace_event (PTRACE_EVENT_VFORK_DONE , nr); +ptrace_event_pid (PTRACE_EVENT_VFORK_DONE , pid); } + +put_pid (pid); }else { nr =PTR_ERR (p); }
Signature · 1 line
2.0.0
PATCH 120/181 arm64: ptrace: change fs when passing kernel pointer to regset code
In reply to Jiri SlabyFrom: Will Deacon <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit c168870704bcde6bb63d05f7882b620dd3985a46 upstream.
Our compat PTRACE_POKEUSR implementation simply passes the user data to regset_copy_from_user after some simple range checking. Unfortunately, the data in question has already been copied to the kernel stack by this point, so the subsequent access_ok check fails and the ptrace request returns -EFAULT. This causes problems tracing fork() with older versions of strace.
This patch briefly changes the fs to KERNEL_DS, so that the access_ok check passes even with a kernel address.
--- arch/arm64/kernel/ptrace.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/kernel/ptrace.c +4 -0
@@ -823,6 +823,7 @@ static int compat_ptrace_write_user(struct task_struct *tsk, compat_ulong_t off, compat_ulong_t val) {int ret; +mm_segment_t old_fs =get_fs ();if (off &3 || off >=COMPAT_USER_SZ )return -EIO ;
@@ -830,10 +831,13 @@ static int compat_ptrace_write_user(struct task_struct *tsk, compat_ulong_t off,if (off >=sizeof (compat_elf_gregset_t))return 0 ; +set_fs (KERNEL_DS ); ret =copy_regset_from_user (tsk, &user_aarch32_view,REGSET_COMPAT_GPR , off,sizeof (compat_ulong_t), &val); +set_fs (old_fs); +return ret; }
Signature · 1 line
2.0.0
PATCH 121/181 idr: fix overflow bug during maximum ID calculation at maximum height
In reply to Jiri SlabyFrom: Lai Jiangshan <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 3afb69cb5572b3c8c898c00880803cf1a49852c4 upstream.
idr_replace() open-codes the logic to calculate the maximum valid ID given the height of the idr tree; unfortunately, the open-coded logic doesn't account for the fact that the top layer may have unused slots and over-shifts the limit to zero when the tree is at its maximum height.
The following test code shows it fails to replace the value for id=((1<<27)+42):
static void test5(void)
{
int id;
DEFINE_IDR(test_idr);
#define TEST5_START ((1<<27)+42) /* use the highest layer */ printk(KERN_INFO "Start test5\n");
id = idr_alloc(&test_idr, (void *)1, TEST5_START, 0, GFP_KERNEL);
BUG_ON(id != TEST5_START);
TEST_BUG_ON(idr_replace(&test_idr, (void *)2, TEST5_START) != (void *)1);
idr_destroy(&test_idr);
printk(KERN_INFO "End of test5\n");}
Fix the bug by using idr_max() which correctly takes into account the maximum allowed shift.
sub_alloc() shares the same problem and may incorrectly fail with -EAGAIN; however, this bug doesn't affect correct operation because idr_get_empty_slot(), which already uses idr_max(), retries with the increased @id in such cases.
--- lib/idr.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
lib/idr.c +3 -5
@@ -250,7 +250,7 @@ static int sub_alloc(struct idr *idp, int *starting_id, struct idr_layer **pa, id = (id | ((1 << (IDR_BITS * l)) -1 )) +1 ;/* if already at the top layer, we need to grow */ -if (id >=1 << (idp->layers *IDR_BITS )) { +if (id >idr_max (idp->layers)) { *starting_id = id;return -EAGAIN ; }
@@ -827,12 +827,10 @@ void *idr_replace(struct idr *idp, void *ptr, int id)if (!p)return ERR_PTR (-EINVAL ); - n = (p->layer+1 ) *IDR_BITS ; - -if (id >= (1 << n)) +if (id >idr_max (p->layer +1 ))return ERR_PTR (-EINVAL ); - n -=IDR_BITS ; + n = p->layer *IDR_BITS ;while ((n >0 ) && p) { p = p->ary[(id >> n) &IDR_MASK ]; n -=IDR_BITS ;
Signature · 1 line
2.0.0
PATCH 122/181 s390/lowcore: reserve 96 bytes for IRB in lowcore
In reply to Jiri SlabyFrom: Christian Borntraeger <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 993072ee67aa179c48c85eb19869804e68887d86 upstream.
The IRB might be 96 bytes if the extended-I/O-measurement facility is used. This feature is currently not used by Linux, but struct irb already has the emw defined. So let's make the irb in lowcore match the size of the internal data structure to be future proof.
We also have to add a pad, to correctly align the paste.
The bigger irb field also circumvents a bug in some QEMU versions that always write the emw field on test subchannel and therefore destroy the paste definitions of this CPU. Running under these QEMU version broke some timing functions in the VDSO and all users of these functions, e.g. some JREs.
--- arch/s390/include/asm/lowcore.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
arch/s390/include/asm/lowcore.h +6 -5
@@ -142,9 +142,9 @@ struct _lowcore {__u8 pad_0x02fc[0x0300 -0x02fc ];/* 0x02fc */ /* Interrupt response block */ -__u8 irb[64 ];/* 0x0300 */ +__u8 irb[96 ];/* 0x0300 */ -__u8 pad_0x0340[0x0e00 -0x0340 ];/* 0x0340 */ +__u8 pad_0x0360[0x0e00 -0x0360 ];/* 0x0360 */ /* * 0xe00 contains the address of the IPL Parameter Information
@@ -288,12 +288,13 @@ struct _lowcore {__u8 pad_0x03a0[0x0400 -0x03a0 ];/* 0x03a0 */ /* Interrupt response block. */ -__u8 irb[64 ];/* 0x0400 */ +__u8 irb[96 ];/* 0x0400 */ +__u8 pad_0x0460[0x0480 -0x0460 ];/* 0x0460 */ /* Per cpu primary space access list */ -__u32 paste[16 ];/* 0x0440 */ +__u32 paste[16 ];/* 0x0480 */ -__u8 pad_0x0480[0x0e00 -0x0480 ];/* 0x0480 */ +__u8 pad_0x04c0[0x0e00 -0x04c0 ];/* 0x04c0 */ /* * 0xe00 contains the address of the IPL Parameter Information
Signature · 1 line
2.0.0
PATCH 123/181 ext4: fix data integrity sync in ordered mode
In reply to Jiri SlabyFrom: Namjae Jeon <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 1c8349a17137b93f0a83f276c764a6df1b9a116e upstream.
When we perform a data integrity sync we tag all the dirty pages with PAGECACHE_TAG_TOWRITE at start of ext4_da_writepages. Later we check for this tag in write_cache_pages_da and creates a struct mpage_da_data containing contiguously indexed pages tagged with this tag and sync these pages with a call to mpage_da_map_and_submit. This process is done in while loop until all the PAGECACHE_TAG_TOWRITE pages are synced. We also do journal start and stop in each iteration. journal_stop could initiate journal commit which would call ext4_writepage which in turn will call ext4_bio_write_page even for delayed OR unwritten buffers. When ext4_bio_write_page is called for such buffers, even though it does not sync them but it clears the PAGECACHE_TAG_TOWRITE of the corresponding page and hence these pages are also not synced by the currently running data integrity sync. We will end up with dirty pages although sync is completed.
This could cause a potential data loss when the sync call is followed by a truncate_pagecache call, which is exactly the case in collapse_range. (It will cause generic/127 failure in xfstests)
To avoid this issue, we can use set_page_writeback_keepwrite instead of set_page_writeback, which doesn't clear TOWRITE tag.
--- fs/ext4/ext4.h | 3 ++- fs/ext4/inode.c | 6 ++++-- fs/ext4/page-io.c | 8 ++++++-- include/linux/page-flags.h | 12 +++++++++++- mm/page-writeback.c | 11 ++++++----- 5 files changed, 29 insertions(+), 11 deletions(-)
fs/ext4/ext4.h +2 -1
@@ -2749,7 +2749,8 @@ extern void ext4_io_submit(struct ext4_io_submit *io);extern int ext4_bio_write_page (struct ext4_io_submit *io,struct page *page,int len, -struct writeback_control *wbc); +struct writeback_control *wbc, +bool keep_towrite);/* mmp.c */ extern int ext4_multi_mount_protect (struct super_block *,ext4_fsblk_t );
fs/ext4/inode.c +4 -2
@@ -1835,6 +1835,7 @@ static int ext4_writepage(struct page *page,struct buffer_head *page_bufs =NULL ;struct inode *inode = page->mapping->host;struct ext4_io_submit io_submit; +bool keep_towrite = false;trace_ext4_writepage (page); size =i_size_read (inode);
@@ -1865,6 +1866,7 @@ static int ext4_writepage(struct page *page,unlock_page (page);return 0 ; } + keep_towrite = true; }if (PageChecked (page) &&ext4_should_journal_data (inode))
@@ -1881,7 +1883,7 @@ static int ext4_writepage(struct page *page,unlock_page (page);return -ENOMEM ; } - ret =ext4_bio_write_page (&io_submit, page, len, wbc); + ret =ext4_bio_write_page (&io_submit, page, len, wbc, keep_towrite);ext4_io_submit (&io_submit);/* Drop io_end reference we got from init */ ext4_put_io_end_defer (io_submit.io_end);
@@ -1900,7 +1902,7 @@ static int mpage_submit_page(struct mpage_da_data *mpd, struct page *page)else len =PAGE_CACHE_SIZE ;clear_page_dirty_for_io (page); - err =ext4_bio_write_page (&mpd->io_submit, page, len, mpd->wbc); + err =ext4_bio_write_page (&mpd->io_submit, page, len, mpd->wbc, false);if (!err) mpd->wbc->nr_to_write--; mpd->first_page++;
fs/ext4/page-io.c +6 -2
@@ -400,7 +400,8 @@ submit_and_retry:int ext4_bio_write_page (struct ext4_io_submit *io,struct page *page,int len, -struct writeback_control *wbc) +struct writeback_control *wbc, +bool keep_towrite) {struct inode *inode = page->mapping->host;unsigned block_start, blocksize;
@@ -413,7 +414,10 @@ int ext4_bio_write_page(struct ext4_io_submit *io,BUG_ON (!PageLocked (page));BUG_ON (PageWriteback (page)); -set_page_writeback (page); +if (keep_towrite) +set_page_writeback_keepwrite (page); +else +set_page_writeback (page);ClearPageError (page);/*
include/linux/page-flags.h +11 -1
@@ -317,13 +317,23 @@ CLEARPAGEFLAG(Uptodate, uptodate)extern void cancel_dirty_page (struct page *page,unsigned int account_size);int test_clear_page_writeback (struct page *page); -int test_set_page_writeback (struct page *page); +int __test_set_page_writeback (struct page *page,bool keep_write); + +#define test_set_page_writeback (page) \ + __test_set_page_writeback(page, false) +#define test_set_page_writeback_keepwrite (page) \ + __test_set_page_writeback(page, true)static inline void set_page_writeback (struct page *page) {test_set_page_writeback (page); } +static inline void set_page_writeback_keepwrite (struct page *page) +{ +test_set_page_writeback_keepwrite (page); +} +#ifdef CONFIG_PAGEFLAGS_EXTENDED /* * System with lots of page flags available. This allows separate
mm/page-writeback.c +6 -5
@@ -2398,7 +2398,7 @@ int test_clear_page_writeback(struct page *page)return ret; } -int test_set_page_writeback (struct page *page) +int __test_set_page_writeback (struct page *page,bool keep_write) {struct address_space *mapping =page_mapping (page);int ret;
@@ -2423,9 +2423,10 @@ int test_set_page_writeback(struct page *page)radix_tree_tag_clear (&mapping->page_tree,page_index (page),PAGECACHE_TAG_DIRTY ); -radix_tree_tag_clear (&mapping->page_tree, -page_index (page), -PAGECACHE_TAG_TOWRITE ); +if (!keep_write) +radix_tree_tag_clear (&mapping->page_tree, +page_index (page), +PAGECACHE_TAG_TOWRITE );spin_unlock_irqrestore (&mapping->tree_lock, flags); }else { ret =TestSetPageWriteback (page);
@@ -2436,7 +2437,7 @@ int test_set_page_writeback(struct page *page)return ret; } -EXPORT_SYMBOL (test_set_page_writeback); +EXPORT_SYMBOL (__test_set_page_writeback);/* * Return true if any of the pages in the mapping are marked with the
Signature · 1 line
2.0.0
PATCH 124/181 ext4: fix zeroing of page during writeback
In reply to Jiri SlabyFrom: Jan Kara <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit eeece469dedadf3918bad50ad80f4616a0064e90 upstream.
Tail of a page straddling inode size must be zeroed when being written out due to POSIX requirement that modifications of mmaped page beyond inode size must not be written to the file. ext4_bio_write_page() did this only for blocks fully beyond inode size but didn't properly zero blocks partially beyond inode size. Fix this.
The problem has been uncovered by mmap_11-4 test in openposix test suite (part of LTP).
--- fs/ext4/page-io.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-)
fs/ext4/page-io.c +11 -13
@@ -421,6 +421,17 @@ int ext4_bio_write_page(struct ext4_io_submit *io,ClearPageError (page);/* +* Comments copied from block_write_full_page_endio: +* +* The page straddles i_size. It must be zeroed out on each and every +* writepage invocation because it may be mmapped. "A file is mapped +* in multiples of the page size. For a file that is not a multiple of +* the page size, the remaining memory is zeroed when mapped, and +* writes to that region are not written out to the file." +*/ +if (len <PAGE_CACHE_SIZE ) +zero_user_segment (page, len,PAGE_CACHE_SIZE ); +/* * In the first loop we prepare and mark buffers to submit. We have to * mark all buffers in the page before submitting so that * end_page_writeback() cannot be called from ext4_bio_end_io() when IO
@@ -431,19 +442,6 @@ int ext4_bio_write_page(struct ext4_io_submit *io, do { block_start = bh_offset(bh); if (block_start >= len) { - /* - * Comments copied from block_write_full_page_endio: - * - * The page straddles i_size. It must be zeroed out on - * each and every writepage invocation because it may - * be mmapped. "A file is mapped in multiples of the - * page size. For a file that is not a multiple of - * the page size, the remaining memory is zeroed when - * mapped, and writes to that region are not written - * out to the file." - */ - zero_user_segment(page, block_start, - block_start + blocksize); clear_buffer_dirty(bh); set_buffer_uptodate(bh); continue;
Signature · 1 line
2.0.0
PATCH 125/181 ext4: fix wrong assert in ext4_mb_normalize_request()
In reply to Jiri SlabyFrom: Maurizio Lombardi <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit b5b60778558cafad17bbcbf63e0310bd3c68eb17 upstream.
The variable "size" is expressed as number of blocks and not as number of clusters, this could trigger a kernel panic when using ext4 with the size of a cluster different from the size of a block.
--- fs/ext4/mballoc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/mballoc.c +1 -1
@@ -3135,7 +3135,7 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac, }BUG_ON (start + size <= ac->ac_o_ex.fe_logical && start > ac->ac_o_ex.fe_logical); -BUG_ON (size <=0 || size >EXT4_CLUSTERS_PER_GROUP (ac->ac_sb)); +BUG_ON (size <=0 || size >EXT4_BLOCKS_PER_GROUP (ac->ac_sb));/* now prepare goal request */
Signature · 1 line
2.0.0
PATCH 126/181 matroxfb: perform a dummy read of M_STATUS
In reply to Jiri SlabyFrom: Mikulas Patocka <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 972754cfaee94d6e25acf94a497bc0a864d91b7e upstream.
I had occasional screen corruption with the matrox framebuffer driver and I found out that the reason for the corruption is that the hardware blitter accesses the videoram while it is being written to.
The matrox driver has a macro WaitTillIdle() that should wait until the blitter is idle, but it sometimes doesn't work. I added a dummy read mga_inl(M_STATUS) to WaitTillIdle() to fix the problem. The dummy read will flush the write buffer in the PCI chipset, and the next read of M_STATUS will return the hardware status.
Since applying this patch, I had no screen corruption at all.
--- drivers/video/matrox/matroxfb_base.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/matrox/matroxfb_base.h +1 -1
@@ -698,7 +698,7 @@ void matroxfb_unregister_driver(struct matroxfb_driver* drv);#define mga_fifo (n) do {} while ((mga_inl(M_FIFOSTATUS) & 0xFF) < (n)) -#define WaitTillIdle () do {} while (mga_inl(M_STATUS) & 0x10000) +#define WaitTillIdle () do { mga_inl(M_STATUS); do {} while (mga_inl(M_STATUS) & 0x10000); } while (0)/* code speedup */ #ifdef CONFIG_FB_MATROX_MILLENIUM
Signature · 1 line
2.0.0
PATCH 127/181 USB: usb_wwan: fix urb leak in write error path
In reply to Jiri SlabyFrom: xiao jin <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit db0904737947d509844e171c9863ecc5b4534005 upstream.
When enable usb serial for modem data, sometimes the tty is blocked in tty_wait_until_sent because portdata->out_busy always is set and have no chance to be cleared.
We find a bug in write error path. usb_wwan_write set portdata->out_busy firstly, then try autopm async with error. No out urb submit and no usb_wwan_outdat_callback to this write, portdata->out_busy can't be cleared.
This patch clear portdata->out_busy if usb_wwan_write try autopm async with error.
option driver")
--- drivers/usb/serial/usb_wwan.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/serial/usb_wwan.c +3 -1
@@ -228,8 +228,10 @@ int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port, usb_pipeendpoint(this_urb->pipe), i); err =usb_autopm_get_interface_async (port->serial->interface); -if (err <0 ) +if (err <0 ) { +clear_bit (i, &portdata->out_busy);break ; + }/* send the data */ memcpy (this_urb->transfer_buffer, buf, todo);
Signature · 1 line
2.0.0
PATCH 128/181 USB: usb_wwan: fix race between write and resume
In reply to Jiri SlabyFrom: xiao jin <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit d9e93c08d8d985e5ef89436ebc9f4aad7e31559f upstream.
We find a race between write and resume. usb_wwan_resume run play_delayed() and spin_unlock, but intfdata->suspended still is not set to zero. At this time usb_wwan_write is called and anchor the urb to delay list. Then resume keep running but the delayed urb have no chance to be commit until next resume. If the time of next resume is far away, tty will be blocked in tty_wait_until_sent during time. The race also can lead to writes being reordered.
This patch put play_Delayed and intfdata->suspended together in the spinlock, it's to avoid the write race during resume.
option driver")
--- drivers/usb/serial/usb_wwan.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/usb/serial/usb_wwan.c +2 -6
@@ -664,17 +664,15 @@ int usb_wwan_resume(struct usb_serial *serial) } } +spin_lock_irq (&intfdata->susp_lock);for (i =0 ; i < serial->num_ports; i++) {/* walk all ports */ port = serial->port[i]; portdata =usb_get_serial_port_data (port);/* skip closed ports */ -spin_lock_irq (&intfdata->susp_lock); -if (!portdata || !portdata->opened) { -spin_unlock_irq (&intfdata->susp_lock); +if (!portdata || !portdata->opened)continue ; - }for (j =0 ; j <N_IN_URB ; j++) { urb = portdata->in_urbs[j];
@@ -687,9 +685,7 @@ int usb_wwan_resume(struct usb_serial *serial) } }play_delayed (port); -spin_unlock_irq (&intfdata->susp_lock); } -spin_lock_irq (&intfdata->susp_lock); intfdata->suspended =0 ;spin_unlock_irq (&intfdata->susp_lock); err_out:
Signature · 1 line
2.0.0
PATCH 129/181 USB: usb_wwan: fix write and suspend race
In reply to Jiri SlabyFrom: Johan Hovold <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 170fad9e22df0063eba0701adb966786d7a4ec5a upstream.
Fix race between write() and suspend() which could lead to writes being dropped (or I/O while suspended) if the device is runtime suspended while a write request is being processed.
Specifically, suspend() releases the susp_lock after determining the device is idle but before setting the suspended flag, thus leaving a window where a concurrent write() can submit an urb.
option driver")
--- drivers/usb/serial/usb_wwan.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/usb/serial/usb_wwan.c +5 -8
@@ -583,20 +583,17 @@ static void stop_read_write_urbs(struct usb_serial *serial)int usb_wwan_suspend (struct usb_serial *serial,pm_message_t message) {struct usb_wwan_intf_private *intfdata = serial->private; -int b; +spin_lock_irq (&intfdata->susp_lock);if (PMSG_IS_AUTO (message)) { -spin_lock_irq (&intfdata->susp_lock); - b = intfdata->in_flight; -spin_unlock_irq (&intfdata->susp_lock); - -if (b) +if (intfdata->in_flight) { +spin_unlock_irq (&intfdata->susp_lock);return -EBUSY ; + } } - -spin_lock_irq (&intfdata->susp_lock); intfdata->suspended =1 ;spin_unlock_irq (&intfdata->susp_lock); +stop_read_write_urbs (serial);return 0 ;
Signature · 1 line
2.0.0
PATCH 130/181 USB: usb_wwan: fix urb leak at shutdown
In reply to Jiri SlabyFrom: Johan Hovold <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 79eed03e77d481b55d85d1cfe5a1636a0d3897fd upstream.
The delayed-write queue was never emptied at shutdown (close), something which could lead to leaked urbs if the port is closed before being runtime resumed due to a write.
When this happens the output buffer would not drain on close (closing_wait timeout), and after consecutive opens, writes could be corrupted with previously buffered data, transfered with reduced throughput or completely blocked.
Note that unbusy_queued_urb() was simply moved out of CONFIG_PM.
option driver")
--- drivers/usb/serial/usb_wwan.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-)
drivers/usb/serial/usb_wwan.c +22 -12
@@ -414,12 +414,26 @@ int usb_wwan_open(struct tty_struct *tty, struct usb_serial_port *port) }EXPORT_SYMBOL (usb_wwan_open); +static void unbusy_queued_urb (struct urb *urb, +struct usb_wwan_port_private *portdata) +{ +int i; + +for (i =0 ; i <N_OUT_URB ; i++) { +if (urb == portdata->out_urbs[i]) { +clear_bit (i, &portdata->out_busy); +break ; + } + } +} +void usb_wwan_close (struct usb_serial_port *port) {int i;struct usb_serial *serial = port->serial;struct usb_wwan_port_private *portdata;struct usb_wwan_intf_private *intfdata = port->serial->private; +struct urb *urb; portdata =usb_get_serial_port_data (port);
@@ -428,6 +442,14 @@ void usb_wwan_close(struct usb_serial_port *port) portdata->opened =0 ;spin_unlock_irq (&intfdata->susp_lock); +for (;;) { + urb =usb_get_from_anchor (&portdata->delayed); +if (!urb) +break ; +unbusy_queued_urb (urb, portdata); +usb_autopm_put_interface_async (serial->interface); + } +for (i =0 ; i <N_IN_URB ; i++)usb_kill_urb (portdata->in_urbs[i]);for (i =0 ; i <N_OUT_URB ; i++)
@@ -600,18 +622,6 @@ int usb_wwan_suspend(struct usb_serial *serial, pm_message_t message) }EXPORT_SYMBOL (usb_wwan_suspend); -static void unbusy_queued_urb (struct urb *urb,struct usb_wwan_port_private *portdata) -{ -int i; - -for (i =0 ; i <N_OUT_URB ; i++) { -if (urb == portdata->out_urbs[i]) { -clear_bit (i, &portdata->out_busy); -break ; - } - } -} -static void play_delayed (struct usb_serial_port *port) {struct usb_wwan_intf_private *data;
Signature · 1 line
2.0.0
PATCH 131/181 USB: usb_wwan: fix potential NULL-deref at resume
In reply to Jiri SlabyFrom: Johan Hovold <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 9096f1fbba916c2e052651e9de82fcfb98d4bea7 upstream.
The interrupt urb was submitted unconditionally at resume, something which could lead to a NULL-pointer dereference in the urb completion handler as resume may be called after the port and port data is gone.
Fix this by making sure the interrupt urb is only submitted and active when the port is open.
option driver")
--- drivers/usb/serial/usb_wwan.c | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-)
drivers/usb/serial/usb_wwan.c +19 -24
@@ -388,6 +388,14 @@ int usb_wwan_open(struct tty_struct *tty, struct usb_serial_port *port) portdata =usb_get_serial_port_data (port); intfdata = serial->private; +if (port->interrupt_in_urb) { + err =usb_submit_urb (port->interrupt_in_urb,GFP_KERNEL ); +if (err) { +dev_dbg (&port->dev,"%s: submit int urb failed: %d\n" , + __func__, err); + } + } +/* Start reading from the IN endpoint */ for (i =0 ; i <N_IN_URB ; i++) { urb = portdata->in_urbs[i];
@@ -454,6 +462,7 @@ void usb_wwan_close(struct usb_serial_port *port)usb_kill_urb (portdata->in_urbs[i]);for (i =0 ; i <N_OUT_URB ; i++)usb_kill_urb (portdata->out_urbs[i]); +usb_kill_urb (port->interrupt_in_urb);/* balancing - important as an error cannot be handled*/ usb_autopm_get_interface_no_resume (serial->interface);
@@ -491,7 +500,6 @@ int usb_wwan_port_probe(struct usb_serial_port *port)struct usb_wwan_port_private *portdata;struct urb *urb;u8 *buffer; -int err;int i;if (!port->bulk_in_size || !port->bulk_out_size)
@@ -531,13 +539,6 @@ int usb_wwan_port_probe(struct usb_serial_port *port)usb_set_serial_port_data (port, portdata); -if (port->interrupt_in_urb) { - err =usb_submit_urb (port->interrupt_in_urb,GFP_KERNEL ); -if (err) -dev_dbg (&port->dev,"%s: submit irq_in urb failed %d\n" , - __func__, err); - } -return 0 ; bail_out_error2:
@@ -655,22 +656,6 @@ int usb_wwan_resume(struct usb_serial *serial)struct urb *urb;int err =0 ; -/* get the interrupt URBs resubmitted unconditionally */ -for (i =0 ; i < serial->num_ports; i++) { - port = serial->port[i]; -if (!port->interrupt_in_urb) { -dev_dbg (&port->dev,"%s: No interrupt URB for port\n" , __func__); -continue ; - } - err =usb_submit_urb (port->interrupt_in_urb,GFP_NOIO ); -dev_dbg (&port->dev,"Submitted interrupt URB for port (result %d)\n" , err); -if (err <0 ) { -dev_err (&port->dev,"%s: Error %d for interrupt URB\n" , - __func__, err); - goto err_out; - } - } -spin_lock_irq (&intfdata->susp_lock);for (i =0 ; i < serial->num_ports; i++) {/* walk all ports */
@@ -681,6 +666,16 @@ int usb_wwan_resume(struct usb_serial *serial)if (!portdata || !portdata->opened)continue ; +if (port->interrupt_in_urb) { + err =usb_submit_urb (port->interrupt_in_urb, +GFP_ATOMIC ); +if (err) { +dev_err (&port->dev, +"%s: submit int urb failed: %d\n" , + __func__, err); + } + } +for (j =0 ; j <N_IN_URB ; j++) { urb = portdata->in_urbs[j]; err =usb_submit_urb (urb,GFP_ATOMIC );
Signature · 1 line
2.0.0
PATCH 132/181 USB: usb_wwan: fix potential blocked I/O after resume
In reply to Jiri SlabyFrom: Johan Hovold <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit fb7ad4f93d9f0f7d49beda32f5e7becb94b29a4d upstream.
Keep trying to submit urbs rather than bail out on first read-urb submission error, which would also prevent I/O for any further ports from being resumed.
Instead keep an error count, for all types of failed submissions, and let USB core know that something went wrong.
Also make sure to always clear the suspended flag. Currently a failed read-urb submission would prevent cached writes as well as any subsequent writes from being submitted until next suspend-resume cycle, something which may not even necessarily happen.
Note that USB core currently only logs an error if an interface resume failed.
option driver")
--- drivers/usb/serial/usb_wwan.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
drivers/usb/serial/usb_wwan.c +17 -8
@@ -623,12 +623,12 @@ int usb_wwan_suspend(struct usb_serial *serial, pm_message_t message) }EXPORT_SYMBOL (usb_wwan_suspend); -static void play_delayed (struct usb_serial_port *port) +static int play_delayed (struct usb_serial_port *port) {struct usb_wwan_intf_private *data;struct usb_wwan_port_private *portdata;struct urb *urb; -int err; +int err =0 ; portdata =usb_get_serial_port_data (port); data = port->serial->private;
@@ -645,6 +645,8 @@ static void play_delayed(struct usb_serial_port *port)break ; } } + +return err; }int usb_wwan_resume (struct usb_serial *serial)
@@ -654,7 +656,8 @@ int usb_wwan_resume(struct usb_serial *serial)struct usb_wwan_intf_private *intfdata = serial->private;struct usb_wwan_port_private *portdata;struct urb *urb; -int err =0 ; +int err; +int err_count =0 ;spin_lock_irq (&intfdata->susp_lock);for (i =0 ; i < serial->num_ports; i++) {
@@ -673,25 +676,31 @@ int usb_wwan_resume(struct usb_serial *serial)dev_err (&port->dev,"%s: submit int urb failed: %d\n" , __func__, err); + err_count++; } } + err =play_delayed (port); +if (err) + err_count++; +for (j =0 ; j <N_IN_URB ; j++) { urb = portdata->in_urbs[j]; err =usb_submit_urb (urb,GFP_ATOMIC );if (err <0 ) {dev_err (&port->dev,"%s: Error %d for bulk URB %d\n" , __func__, err, i); -spin_unlock_irq (&intfdata->susp_lock); - goto err_out; + err_count++; } } -play_delayed (port); } intfdata->suspended =0 ;spin_unlock_irq (&intfdata->susp_lock); -err_out: -return err; + +if (err_count) +return -EIO ; + +return 0 ; }EXPORT_SYMBOL (usb_wwan_resume);#endif
Signature · 1 line
2.0.0
PATCH 133/181 USB: sierra: fix AA deadlock in open error path
In reply to Jiri SlabyFrom: Johan Hovold <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 353fe198602e8b4d1c7bdcceb8e60955087201b1 upstream.
Fix AA deadlock in open error path that would call close() and try to grab the already held disc_mutex.
--- drivers/usb/serial/sierra.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/usb/serial/sierra.c +13 -8
@@ -824,14 +824,9 @@ static int sierra_open(struct tty_struct *tty, struct usb_serial_port *port) usb_sndbulkpipe(serial->dev, endpoint) | USB_DIR_IN); err =sierra_submit_rx_urbs (port,GFP_KERNEL ); -if (err) { -/* get rid of everything as in close */ -sierra_close (port); -/* restore balance for autopm */ -if (!serial->disconnected) -usb_autopm_put_interface (serial->interface); -return err; - } +if (err) + goto err_submit; +sierra_send_setup (port); serial->interface->needs_remote_wakeup =1 ;
@@ -841,6 +836,16 @@ static int sierra_open(struct tty_struct *tty, struct usb_serial_port *port)usb_autopm_put_interface (serial->interface);return 0 ; + +err_submit: +sierra_stop_rx_urbs (port); + +for (i =0 ; i < portdata->num_in_urbs; i++) { +sierra_release_urb (portdata->in_urbs[i]); + portdata->in_urbs[i] =NULL ; + } + +return err; }
Signature · 1 line
2.0.0
PATCH 134/181 USB: sierra: fix use after free at suspend/resume
In reply to Jiri SlabyFrom: Johan Hovold <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 8452727de70f6ad850cd6d0aaa18b5d9050aa63b upstream.
Fix use after free or NULL-pointer dereference during suspend and resume.
The port data may never have been allocated (port probe failed) or may already have been released by port_remove (e.g. driver is unloaded) when suspend and resume are called.
online")
--- drivers/usb/serial/sierra.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/usb/serial/sierra.c +6 -0
@@ -941,6 +941,7 @@ static int sierra_port_remove(struct usb_serial_port *port)struct sierra_port_private *portdata; portdata =usb_get_serial_port_data (port); +usb_set_serial_port_data (port,NULL );kfree (portdata);return 0 ;
@@ -957,6 +958,8 @@ static void stop_read_write_urbs(struct usb_serial *serial)for (i =0 ; i < serial->num_ports; ++i) { port = serial->port[i]; portdata =usb_get_serial_port_data (port); +if (!portdata) +continue ;sierra_stop_rx_urbs (port);usb_kill_anchored_urbs (&portdata->active); }
@@ -999,6 +1002,9 @@ static int sierra_resume(struct usb_serial *serial) port = serial->port[i]; portdata =usb_get_serial_port_data (port); +if (!portdata) +continue ; +while ((urb =usb_get_from_anchor (&portdata->delayed))) {usb_anchor_urb (urb, &portdata->active); intfdata->in_flight++;
Signature · 1 line
2.0.0
PATCH 135/181 USB: sierra: fix urb and memory leak in resume error path
In reply to Jiri SlabyFrom: Johan Hovold <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 7fdd26a01eb7b6cb6855ff8f69ef4a720720dfcb upstream.
Neither the transfer buffer or the urb itself were released in the resume error path for delayed writes. Also on errors, the remainder of the queue was not even processed, which leads to further urb and buffer leaks.
The same error path also failed to balance the outstanding-urb counter, something which results in degraded throughput or completely blocked writes.
Fix this by releasing urb and buffer and balancing counters on errors, and by always processing the whole queue even when submission of one urb fails.
online")
--- drivers/usb/serial/sierra.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/usb/serial/sierra.c +6 -2
@@ -1012,8 +1012,12 @@ static int sierra_resume(struct usb_serial *serial)if (err <0 ) { intfdata->in_flight--;usb_unanchor_urb (urb); -usb_scuttle_anchored_urbs (&portdata->delayed); -break ; +kfree (urb->transfer_buffer); +usb_free_urb (urb); +spin_lock (&portdata->lock); + portdata->outstanding_urbs--; +spin_unlock (&portdata->lock); +continue ; } }
Signature · 1 line
2.0.0
PATCH 136/181 USB: sierra: fix urb and memory leak on disconnect
In reply to Jiri SlabyFrom: Johan Hovold <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 014333f77c0b71123d6ef7d31a9724e0699c9548 upstream.
The delayed-write queue was never emptied on disconnect, something which would lead to leaked urbs and transfer buffers if the device is disconnected before being runtime resumed due to a write.
online")
--- drivers/usb/serial/sierra.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/usb/serial/sierra.c +13 -0
@@ -767,6 +767,7 @@ static void sierra_close(struct usb_serial_port *port)struct usb_serial *serial = port->serial;struct sierra_port_private *portdata;struct sierra_intf_private *intfdata = port->serial->private; +struct urb *urb; portdata =usb_get_serial_port_data (port);
@@ -788,6 +789,18 @@ static void sierra_close(struct usb_serial_port *port) portdata->opened =0 ;spin_unlock_irq (&intfdata->susp_lock); +for (;;) { + urb =usb_get_from_anchor (&portdata->delayed); +if (!urb) +break ; +kfree (urb->transfer_buffer); +usb_free_urb (urb); +usb_autopm_put_interface_async (serial->interface); +spin_lock (&portdata->lock); + portdata->outstanding_urbs--; +spin_unlock (&portdata->lock); + } +sierra_stop_rx_urbs (port);for (i =0 ; i < portdata->num_in_urbs; i++) {sierra_release_urb (portdata->in_urbs[i]);
Signature · 1 line
2.0.0
PATCH 137/181 USB: sierra: fix remote wakeup
In reply to Jiri SlabyFrom: Johan Hovold <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 80cc0fcbdaeaf10d04ba27779a2d7ceb73d2717a upstream.
Make sure that needs_remote_wake up is always set when there are open ports.
Currently close() would unconditionally set needs_remote_wakeup to 0 even though there might still be open ports. This could lead to blocked input and possibly dropped data on devices that do not support remote wakeup (and which must therefore not be runtime suspended while open).
Add an open_ports counter (protected by the susp_lock) and only clear needs_remote_wakeup when the last port is closed.
online")
--- drivers/usb/serial/sierra.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/usb/serial/sierra.c +5 -2
@@ -58,6 +58,7 @@ struct sierra_intf_private {spinlock_t susp_lock; unsigned int suspended:1;int in_flight; +unsigned int open_ports; };static int sierra_set_power_state (struct usb_device *udev,__u16 swiState)
@@ -776,7 +777,6 @@ static void sierra_close(struct usb_serial_port *port)mutex_lock (&serial->disc_mutex);if (!serial->disconnected) { - serial->interface->needs_remote_wakeup =0 ;/* odd error handling due to pm counters */ if (!usb_autopm_get_interface (serial->interface))sierra_send_setup (port);
@@ -787,6 +787,8 @@ static void sierra_close(struct usb_serial_port *port)mutex_unlock (&serial->disc_mutex);spin_lock_irq (&intfdata->susp_lock); portdata->opened =0 ; +if (--intfdata->open_ports ==0 ) + serial->interface->needs_remote_wakeup =0 ;spin_unlock_irq (&intfdata->susp_lock);for (;;) {
@@ -842,9 +844,10 @@ static int sierra_open(struct tty_struct *tty, struct usb_serial_port *port)sierra_send_setup (port); - serial->interface->needs_remote_wakeup =1 ;spin_lock_irq (&intfdata->susp_lock); portdata->opened =1 ; +if (++intfdata->open_ports ==1 ) + serial->interface->needs_remote_wakeup =1 ;spin_unlock_irq (&intfdata->susp_lock);usb_autopm_put_interface (serial->interface);
Signature · 1 line
2.0.0
PATCH 138/181 USB: serial: fix potential runtime pm imbalance at device remove
In reply to Jiri SlabyFrom: Johan Hovold <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit c14829fad88dbeda57253590695b85ba51270621 upstream.
Only call usb_autopm_put_interface() if the corresponding usb_autopm_get_interface() was successful.
This prevents a potential runtime PM counter imbalance should usb_autopm_get_interface() fail. Note that the USB PM usage counter is reset when the interface is unbound, but that the runtime PM counter may be left unbalanced.
Also add comment on why we don't need to worry about racing resume/suspend on autopm_get failures.
against probe/remove")
--- drivers/usb/serial/bus.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/usb/serial/bus.c +11 -3
@@ -97,13 +97,19 @@ static int usb_serial_device_remove(struct device *dev)struct usb_serial_port *port;int retval =0 ;int minor; +int autopm_err; port =to_usb_serial_port (dev);if (!port)return -ENODEV ; -/* make sure suspend/resume doesn't race against port_remove */ -usb_autopm_get_interface (port->serial->interface); +/* +* Make sure suspend/resume doesn't race against port_remove. +* +* Note that no further runtime PM callbacks will be made if +* autopm_get fails. +*/ + autopm_err =usb_autopm_get_interface (port->serial->interface); minor = port->minor;tty_unregister_device (usb_serial_tty_driver, minor);
@@ -117,7 +123,9 @@ static int usb_serial_device_remove(struct device *dev)dev_info (dev,"%s converter now disconnected from ttyUSB%d\n" , driver->description, minor); -usb_autopm_put_interface (port->serial->interface); +if (!autopm_err) +usb_autopm_put_interface (port->serial->interface); +return retval; }
Signature · 1 line
2.0.0
PATCH 139/181 media: ivtv: Fix Oops when no firmware is loaded
In reply to Jiri SlabyFrom: Takashi Iwai <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit deb29e90221a6d4417aa67be971613c353180331 upstream.
When ivtv PCM device is accessed at the state where no firmware is loaded, it oopses like:
BUG: unable to handle kernel NULL pointer dereference at 0000000000000050
IP: [<ffffffffa049a881>] try_mailbox.isra.0+0x11/0x50 [ivtv]
Call Trace:
[<ffffffffa049aa20>] ivtv_api_call+0x160/0x6b0 [ivtv]
[<ffffffffa049af86>] ivtv_api+0x16/0x40 [ivtv]
[<ffffffffa049b10c>] ivtv_vapi+0xac/0xc0 [ivtv]
[<ffffffffa049d40d>] ivtv_start_v4l2_encode_stream+0x19d/0x630 [ivtv]
[<ffffffffa0530653>] snd_ivtv_pcm_capture_open+0x173/0x1c0 [ivtv_alsa]
[<ffffffffa04526f1>] snd_pcm_open_substream+0x51/0x100 [snd_pcm]
[<ffffffffa0452853>] snd_pcm_open+0xb3/0x260 [snd_pcm]
[<ffffffffa0452a37>] snd_pcm_capture_open+0x37/0x50 [snd_pcm]
[<ffffffffa033f557>] snd_open+0xa7/0x1e0 [snd]
[<ffffffff8118a628>] chrdev_open+0x88/0x1d0
[<ffffffff811840be>] do_dentry_open+0x1de/0x270
[<ffffffff81193a73>] do_last+0x1c3/0xec0
[<ffffffff81194826>] path_openat+0xb6/0x670
[<ffffffff81195b65>] do_filp_open+0x35/0x80
[<ffffffff81185449>] do_sys_open+0x129/0x210
[<ffffffff815b782d>] system_call_fastpath+0x1a/0x1fThis patch adds the check of firmware at PCM open callback like other open callbacks of this driver.
Bugzilla: https://apibugzilla.novell.com/show_bug.cgi?id=875440
--- drivers/media/pci/ivtv/ivtv-alsa-pcm.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/media/pci/ivtv/ivtv-alsa-pcm.c +6 -0
@@ -159,6 +159,12 @@ static int snd_ivtv_pcm_capture_open(struct snd_pcm_substream *substream)/* Instruct the CX2341[56] to start sending packets */ snd_ivtv_lock (itvsc); + +if (ivtv_init_on_first_open (itv)) { +snd_ivtv_unlock (itvsc); +return -ENXIO ; + } + s = &itv->streams[IVTV_ENC_STREAM_TYPE_PCM ];v4l2_fh_init (&item.fh, s->vdev);
Signature · 1 line
2.0.0
PATCH 140/181 media: stk1160: Avoid stack-allocated buffer for control URBs
In reply to Jiri SlabyFrom: Ezequiel Garcia <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 85ac1a1772bb41da895bad83a81f6a62c8f293f6 upstream.
Currently stk1160_read_reg() uses a stack-allocated char to get the read control value. This is wrong because usb_control_msg() requires a kmalloc-ed buffer.
This commit fixes such issue by kmalloc'ating a 1-byte buffer to receive the read value.
While here, let's remove the urb_buf array which was meant for a similar purpose, but never really used.
--- drivers/media/usb/stk1160/stk1160-core.c | 10 +++++++++- drivers/media/usb/stk1160/stk1160.h | 1 - 2 files changed, 9 insertions(+), 2 deletions(-)
drivers/media/usb/stk1160/stk1160-core.c +9 -1
@@ -67,17 +67,25 @@ int stk1160_read_reg(struct stk1160 *dev, u16 reg, u8 *value) {int ret;int pipe =usb_rcvctrlpipe (dev->udev,0 ); +u8 *buf; *value =0 ; + + buf =kmalloc (sizeof (u8),GFP_KERNEL ); +if (!buf) +return -ENOMEM ; ret =usb_control_msg (dev->udev, pipe,0x00 ,USB_DIR_IN |USB_TYPE_VENDOR |USB_RECIP_DEVICE , -0x00 , reg, value,sizeof (u8),HZ ); +0x00 , reg, buf,sizeof (u8),HZ );if (ret <0 ) {stk1160_err ("read failed on reg 0x%x (%d)\n" , reg, ret); +kfree (buf);return ret; } + *value = *buf; +kfree (buf);return 0 ; }
drivers/media/usb/stk1160/stk1160.h +0 -1
@@ -143,7 +143,6 @@ struct stk1160 {int num_alt;struct stk1160_isoc_ctl isoc_ctl; -char urb_buf[255 ];/* urb control msg buffer */ /* frame properties */ int width;/* current frame width */
Signature · 1 line
2.0.0
PATCH 141/181 ACPICA: utstring: Check array index bound before use.
In reply to Jiri SlabyFrom: David Binderman <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 5d42b0fa25df7ef2f575107597c1aaebe2407d10 upstream.
ACPICA BZ 1077. David Binderman.
References: https://bugs.acpica.org/show_bug.cgi?id=1077
--- drivers/acpi/acpica/utstring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/acpica/utstring.c +1 -1
@@ -353,7 +353,7 @@ void acpi_ut_print_string(char *string, u16 max_length) }acpi_os_printf ("\"" ); -for (i =0 ; string[i] && (i < max_length); i++) { +for (i =0 ; (i < max_length) && string[i]; i++) {/* Escape sequences */
Signature · 1 line
2.0.0
PATCH 142/181 ACPI: Fix conflict between customized DSDT and DSDT local copy
In reply to Jiri SlabyFrom: Lv Zheng <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 73577d1df8e1f31f6b1a5eebcdbc334eb0330e47 upstream.
This patch fixes the following issue:
If DSDT is customized, no local DSDT copy is needed.
References: https://bugzilla.kernel.org/show_bug.cgi?id=69711
--- drivers/acpi/bus.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/acpi/bus.c +7 -0
@@ -57,6 +57,12 @@ EXPORT_SYMBOL(acpi_root_dir); #ifdef CONFIG_X86 +#ifdef CONFIG_ACPI_CUSTOM_DSDT +static inline int set_copy_dsdt(const struct dmi_system_id *id) +{ + return 0; +} +#else static int set_copy_dsdt(const struct dmi_system_id *id) { printk(KERN_NOTICE "%s detected - "
@@ -64,6 +70,7 @@ static int set_copy_dsdt(const struct dmi_system_id *id) acpi_gbl_copy_dsdt_locally =1 ;return 0 ; } +#endif static struct dmi_system_id dsdt_dmi_table[]__initdata = {/*
Signature · 1 line
2.0.0
PATCH 143/181 media: uvcvideo: Fix clock param realtime setting
In reply to Jiri SlabyFrom: Olivier Langlois <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 3b35fc81e7ec552147a4fd843d0da0bbbe4ef253 upstream.
timestamps in v4l2 buffers returned to userspace are updated in uvc_video_clock_update() which uses timestamps fetched from uvc_video_clock_decode() by calling unconditionally ktime_get_ts().
Hence setting the module clock param to realtime has no effect before this patch.
This has been tested with ffmpeg:
ffmpeg -y -f v4l2 -input_format yuyv422 -video_size 640x480 -framerate 30 -i /dev/video0 \
-f alsa -acodec pcm_s16le -ar 16000 -ac 1 -i default \
-c:v libx264 -preset ultrafast \
-c:a libfdk_aac \
out.mkv
and inspecting the v4l2 input starting timestamp.
--- drivers/media/usb/uvc/uvc_video.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/media/usb/uvc/uvc_video.c +10 -5
@@ -361,6 +361,14 @@ static int uvc_commit_video(struct uvc_streaming *stream,* Clocks and timestamps */ +static inline void uvc_video_get_ts (struct timespec *ts) +{ +if (uvc_clock_param ==CLOCK_MONOTONIC ) +ktime_get_ts (ts); +else +ktime_get_real_ts (ts); +} +static void uvc_video_clock_decode (struct uvc_streaming *stream,struct uvc_buffer *buf,const __u8 *data,int len)
@@ -420,7 +428,7 @@ uvc_video_clock_decode(struct uvc_streaming *stream, struct uvc_buffer *buf, stream->clock.last_sof = dev_sof; host_sof =usb_get_current_frame_number (stream->dev->udev); -ktime_get_ts (&ts); +uvc_video_get_ts (&ts);/* The UVC specification allows device implementations that can't obtain * the USB frame number to keep their own frame counters as long as they
@@ -1010,10 +1018,7 @@ static int uvc_video_decode_start(struct uvc_streaming *stream,return -ENODATA ; } -if (uvc_clock_param ==CLOCK_MONOTONIC ) -ktime_get_ts (&ts); -else -ktime_get_real_ts (&ts); +uvc_video_get_ts (&ts); buf->buf.v4l2_buf.sequence = stream->sequence; buf->buf.v4l2_buf.timestamp.tv_sec = ts.tv_sec;
Signature · 1 line
2.0.0
PATCH 144/181 ARM: stacktrace: avoid listing stacktrace functions in stacktrace
In reply to Jiri SlabyFrom: Russell King <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 3683f44c42e991d313dc301504ee0fca1aeb8580 upstream.
While debugging the FEC ethernet driver using stacktrace, it was noticed that the stacktraces always begin as follows:
[<c00117b4>] save_stack_trace_tsk+0x0/0x98 [<c0011870>] save_stack_trace+0x24/0x28 ...
This is because the stack trace code includes the stack frames for itself. This is incorrect behaviour, and also leads to "skip" doing the wrong thing (which is the number of stack frames to avoid recording.)
Perversely, it does the right thing when passed a non-current thread. Fix this by ensuring that we have a known constant number of frames above the main stack trace function, and always skip these.
--- arch/arm/kernel/stacktrace.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
arch/arm/kernel/stacktrace.c +13 -5
@@ -83,13 +83,16 @@ static int save_trace(struct stackframe *frame, void *d)return trace->nr_entries >= trace->max_entries; } -void save_stack_trace_tsk (struct task_struct *tsk,struct stack_trace *trace) +/* This must be noinline to so that our skip calculation works correctly */ +static noinline void __save_stack_trace(struct task_struct *tsk, +struct stack_trace *trace,unsigned int nosched) {struct stack_trace_data data;struct stackframe frame; data.trace = trace; data.skip = trace->skip; + data.no_sched_functions = nosched;if (tsk != current) {#ifdef CONFIG_SMP
@@ -102,7 +105,6 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace) trace->entries[trace->nr_entries++] =ULONG_MAX ;return ;#else - data.no_sched_functions =1 ; frame.fp =thread_saved_fp (tsk); frame.sp =thread_saved_sp (tsk); frame.lr =0 ;/* recovered from the stack */
@@ -111,11 +113,12 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace) }else { registerunsigned long current_sp asm ("sp" ); - data.no_sched_functions =0 ; +/* We don't want this function nor the caller */ + data.skip +=2 ; frame.fp = (unsigned long )__builtin_frame_address (0 ); frame.sp = current_sp; frame.lr = (unsigned long )__builtin_return_address (0 ); - frame.pc = (unsigned long )save_stack_trace_tsk; + frame.pc = (unsigned long )__save_stack_trace; }walk_stackframe (&frame, save_trace, &data);
@@ -123,9 +126,14 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace) trace->entries[trace->nr_entries++] = ULONG_MAX; } +void save_stack_trace_tsk (struct task_struct *tsk,struct stack_trace *trace) +{ +__save_stack_trace (tsk, trace,1 ); +} +void save_stack_trace (struct stack_trace *trace) { -save_stack_trace_tsk (current, trace); +__save_stack_trace (current, trace,0 ); }EXPORT_SYMBOL_GPL (save_stack_trace);#endif
Signature · 1 line
2.0.0
PATCH 145/181 ARM: 8037/1: mm: support big-endian page tables
In reply to Jiri SlabyFrom: Jianguo Wu <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 86f40622af7329375e38f282f6c0aab95f3e5f72 upstream.
When enable LPAE and big-endian in a hisilicon board, while specify mem=384M mem=512M@7680M, will get bad page state:
Freeing unused kernel memory: 180K (c0466000 - c0493000)
BUG: Bad page state in process init pfn:fa442 page:c7749840 count:0 mapcount:-1 mapping: (null) index:0x0 page flags: 0x40000400(reserved) Modules linked in: CPU: 0 PID: 1 Comm: init Not tainted 3.10.27+ #66 [<c000f5f0>] (unwind_backtrace+0x0/0x11c) from [<c000cbc4>] (show_stack+0x10/0x14) [<c000cbc4>] (show_stack+0x10/0x14) from [<c009e448>] (bad_page+0xd4/0x104) [<c009e448>] (bad_page+0xd4/0x104) from [<c009e520>] (free_pages_prepare+0xa8/0x14c) [<c009e520>] (free_pages_prepare+0xa8/0x14c) from [<c009f8ec>] (free_hot_cold_page+0x18/0xf0) [<c009f8ec>] (free_hot_cold_page+0x18/0xf0) from [<c00b5444>] (handle_pte_fault+0xcf4/0xdc8) [<c00b5444>] (handle_pte_fault+0xcf4/0xdc8) from [<c00b6458>] (handle_mm_fault+0xf4/0x120) [<c00b6458>] (handle_mm_fault+0xf4/0x120) from [<c0013754>] (do_page_fault+0xfc/0x354) [<c0013754>] (do_page_fault+0xfc/0x354) from [<c0008400>] (do_DataAbort+0x2c/0x90) [<c0008400>] (do_DataAbort+0x2c/0x90) from [<c0008fb4>] (__dabt_usr+0x34/0x40)
The bad pfn:fa442 is not system memory(mem=384M mem=512M@7680M), after debugging, I find in page fault handler, will get wrong pfn from pte just after set pte, as follow:do_anonymous_page()
{
...
set_pte_at(mm, address, page_table, entry);
//debug code
pfn = pte_pfn(entry);
pr_info("pfn:0x%lx, pte:0x%llxn", pfn, pte_val(entry));
//read out the pte just set
new_pte = pte_offset_map(pmd, address);
new_pfn = pte_pfn(*new_pte);
pr_info("new pfn:0x%lx, new pte:0x%llxn", pfn, pte_val(entry));
...
}pfn: 0x1fa4f5, pte:0xc00001fa4f575f
new_pfn:0xfa4f5, new_pte:0xc00000fa4f5f5f //new pfn/pte is wrong.
The bug is happened in cpu_v7_set_pte_ext(ptep, pte):
An LPAE PTE is a 64bit quantity, passed to cpu_v7_set_pte_ext in the r2 and r3 registers. On an LE kernel, r2 contains the LSB of the PTE, and r3 the MSB.
On a BE kernel, the assignment is reversed.
Unfortunately, the current code always assumes the LE case, leading to corruption of the PTE when clearing/setting bits.
This patch fixes this issue much like it has been done already in the cpu_v7_switch_mm case.
--- arch/arm/mm/proc-v7-3level.S | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
arch/arm/mm/proc-v7-3level.S +13 -5
@@ -64,6 +64,14 @@ ENTRY(cpu_v7_switch_mm) mov pc, lr ENDPROC(cpu_v7_switch_mm) +#ifdef __ARMEB__ +#define rl r3 +#define rh r2 +#else +#define rl r2 +#define rh r3 +#endif + /* * cpu_v7_set_pte_ext(ptep, pte) *
@@ -73,13 +81,13 @@ ENDPROC(cpu_v7_switch_mm) */ ENTRY(cpu_v7_set_pte_ext) #ifdef CONFIG_MMU - tst r2, #L_PTE_VALID + tst rl, #L_PTE_VALID beq 1f - tst r3, #1 << (57 - 32) @ L_PTE_NONE - bicne r2, #L_PTE_VALID + tst rh, #1 << (57 - 32) @ L_PTE_NONE + bicne rl, #L_PTE_VALID bne 1f - tst r3, #1 << (55 - 32) @ L_PTE_DIRTY - orreq r2, #L_PTE_RDONLY + tst rh, #1 << (55 - 32) @ L_PTE_DIRTY + orreq rl, #L_PTE_RDONLY 1: strd r2, r3, [r0] ALT_SMP(W(nop)) ALT_UP (mcr p15, 0, r0, c7, c10, 1) @ flush_pte
Signature · 1 line
2.0.0
PATCH 146/181 bluetooth: hci_ldisc: fix deadlock condition
In reply to Jiri SlabyFrom: Felipe Balbi <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit da64c27d3c93ee9f89956b9de86c4127eb244494 upstream.
LDISCs shouldn't call tty->ops->write() from within ->write_wakeup().
->write_wakeup() is called with port lock taken and IRQs disabled, tty->ops->write() will try to acquire the same port lock and we will deadlock.
--- drivers/bluetooth/hci_ldisc.c | 24 +++++++++++++++++++----- drivers/bluetooth/hci_uart.h | 1 + 2 files changed, 20 insertions(+), 5 deletions(-)
drivers/bluetooth/hci_ldisc.c +19 -5
@@ -118,10 +118,6 @@ static inline struct sk_buff *hci_uart_dequeue(struct hci_uart *hu)int hci_uart_tx_wakeup (struct hci_uart *hu) { -struct tty_struct *tty = hu->tty; -struct hci_dev *hdev = hu->hdev; -struct sk_buff *skb; -if (test_and_set_bit (HCI_UART_SENDING , &hu->tx_state)) {set_bit (HCI_UART_TX_WAKEUP , &hu->tx_state);return 0 ;
@@ -129,6 +125,22 @@ int hci_uart_tx_wakeup(struct hci_uart *hu)BT_DBG ("" ); +schedule_work (&hu->write_work); + +return 0 ; +} + +static void hci_uart_write_work (struct work_struct *work) +{ + struct hci_uart *hu = container_of(work, struct hci_uart, write_work); +struct tty_struct *tty = hu->tty; +struct hci_dev *hdev = hu->hdev; +struct sk_buff *skb; + +/* REVISIT: should we cope with bad skbs or ->write() returning +* and error value ? +*/ + restart:clear_bit (HCI_UART_TX_WAKEUP , &hu->tx_state);
@@ -153,7 +165,6 @@ restart: goto restart;clear_bit (HCI_UART_SENDING , &hu->tx_state); -return 0 ; }static void hci_uart_init_work (struct work_struct *work)
@@ -289,6 +300,7 @@ static int hci_uart_tty_open(struct tty_struct *tty) tty->receive_room =65536 ;INIT_WORK (&hu->init_ready, hci_uart_init_work); +INIT_WORK (&hu->write_work, hci_uart_write_work);spin_lock_init (&hu->rx_lock);
@@ -326,6 +338,8 @@ static void hci_uart_tty_close(struct tty_struct *tty)if (hdev)hci_uart_close (hdev); +cancel_work_sync (&hu->write_work); +if (test_and_clear_bit (HCI_UART_PROTO_SET , &hu->flags)) {if (hdev) {if (test_bit (HCI_UART_REGISTERED , &hu->flags))
drivers/bluetooth/hci_uart.h +1 -0
@@ -68,6 +68,7 @@ struct hci_uart {unsigned long hdev_flags;struct work_struct init_ready; +struct work_struct write_work;struct hci_uart_proto *proto;void *priv;
Signature · 1 line
2.0.0
PATCH 147/181 Bluetooth: Fix L2CAP deadlock
In reply to Jiri SlabyFrom: Jukka Taimisto <[email protected]>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 8a96f3cd22878fc0bb564a8478a6e17c0b8dca73 upstream.
-[0x01 Introduction
We have found a programming error causing a deadlock in Bluetooth subsystem of Linux kernel. The problem is caused by missing release_sock() call when L2CAP connection creation fails due full accept queue.
The issue can be reproduced with 3.15-rc5 kernel and is also present in earlier kernels.
-[0x02 Details
The problem occurs when multiple L2CAP connections are created to a PSM which contains listening socket (like SDP) and left pending, for example, configuration (the underlying ACL link is not disconnected between connections).
When L2CAP connection request is received and listening socket is found the l2cap_sock_new_connection_cb() function (net/bluetooth/l2cap_sock.c) is called. This function locks the 'parent' socket and then checks if the accept queue is full.
1178 lock_sock(parent);
1179
1180 /* Check for backlog size */
1181 if (sk_acceptq_is_full(parent)) {
1182 BT_DBG("backlog full %d", parent->sk_ack_backlog);
1183 return NULL;
1184 }
If case the accept queue is full NULL is returned, but the 'parent' socket is not released. Thus when next L2CAP connection request is received the code blocks on lock_sock() since the parent is still locked.
Also note that for connections already established and waiting for configuration to complete a timeout will occur and l2cap_chan_timeout() (net/bluetooth/l2cap_core.c) will be called. All threads calling this function will also be blocked waiting for the channel mutex since the thread which is waiting on lock_sock() alread holds the channel mutex.
We were able to reproduce this by sending continuously L2CAP connection request followed by disconnection request containing invalid CID. This left the created connections pending configuration.
After the deadlock occurs it is impossible to kill bluetoothd, btmon will not get any more data etc. requiring reboot to recover.
-[0x03 Fix
Releasing the 'parent' socket when l2cap_sock_new_connection_cb() returns NULL seems to fix the issue.
--- net/bluetooth/l2cap_sock.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/bluetooth/l2cap_sock.c +4 -1
@@ -949,13 +949,16 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(struct l2cap_chan *chan)/* Check for backlog size */ if (sk_acceptq_is_full (parent)) {BT_DBG ("backlog full %d" , parent->sk_ack_backlog); +release_sock (parent);return NULL ; } sk =l2cap_sock_alloc (sock_net (parent),NULL ,BTPROTO_L2CAP ,GFP_ATOMIC ); -if (!sk) +if (!sk) { +release_sock (parent);return NULL ; + }bt_sock_reclassify_lock (sk,BTPROTO_L2CAP );
Signature · 1 line
2.0.0