3.16.66-rc1 review
Subsystems (4)
cover 3.16.66-rc1 review
This is the start of the stable review cycle for the 3.16.66 release. There are 202 patches in this series, which will be posted as responses to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed May 01 18:00:00 UTC 2019. Anything received after that time might be too late.
All the patches have also been committed to the linux-3.16.y-rc branch of
https://git.kernel.org/pub/scm/linux/kernel/git/bwh/linux-stable-rc.git . A shortlog and diffstat can be found below.
Ben.
-------------
Aaro Koskinen (1):
MIPS: OCTEON: don't set octeon_dma_bar_type if PCI is disabled
[dcf300a69ac307053dfb35c2e33972e754a98bce]
Alex Williamson (1):
vfio/type1: Limit DMA mappings per container
[492855939bdb59c6f947b0b5b44af9ad82b7e38c]
Alexander Popov (1):
KVM: x86: Fix single-step debugging
[5cc244a20b86090c087073c124284381cdf47234]
Alexandru Ardelean (1):
dmaengine: dmatest: unmap data on a single code-path when xfer done
[0255200bd29afc320c6ea4c1adf8bdc13a9b3c15]
Andrea Arcangeli (1):
coredump: fix race condition between mmget_not_zero()/get_task_mm() and core dumping
[04f5866e41fb70690e28397487d8bd8eea7d712a]
Andy Lutomirski (1):
x86/uaccess: Don't leak the AC flag into __put_user() value evaluation
[2a418cf3f5f1caf911af288e978d61c9844b0695]
Andy Shevchenko (1):
dmaengine: dmatest: Abort test in case of mapping error
[6454368a804c4955ccd116236037536f81e5b1f1]
Arend van Spriel (5):
brcmfmac: add subtype check for event handling in data path
[a4176ec356c73a46c07c181c6d04039fafa34a9f]
brcmfmac: assure SSID length from firmware is limited
[1b5e2423164b3670e8bc9174e4762d297990deff]
brcmfmac: consolidate ifp lookup in driver core
[75effb03ee8e4c9d4bbc909118ce5444b047dfde]
brcmfmac: make brcmf_proto_hdrpull() return struct brcmf_if instance
[796cfb65e3ed01a9b08e3a0b93e34120c54bbbd2]
brcmfmac: revise handling events in receive path
[9c349892ccc90c6de2baaa69cc78449f58082273]
Aya Levin (1):
net/mlx4_core: Add masking for a few queries on HCA caps
[a40ded6043658444ee4dd6ee374119e4e98b33fc]
B-Ak (1):
ASoC: tlv320aic32x4: Kernel OOPS while entering DAPM standby mode
[667e9334fa64da2273e36ce131b05ac9e47c5769]
Ben Hutchings (1):
binfmt_elf: Fix missing SIGKILL for empty PIE
[not upstream; fixes bad backport]
Bin Liu (1):
usb: phy: am335x: fix race condition in _probe
[a53469a68eb886e84dd8b69a1458a623d3591793]
Borislav Petkov (1):
x86/a.out: Clear the dump structure initially
[10970e1b4be9c74fce8ab6e3c34a7d718f063f2c]
Charles Keepax (1):
ALSA: compress: Fix stop handling on compressed capture streams
[4f2ab5e1d13d6aa77c55f4914659784efd776eb4]
Charles Yeh (1):
USB: serial: pl2303: add new PID to support PL2303TB
[4dcf9ddc9ad5ab649abafa98c5a4d54b1a33dabb]
Christian Borntraeger (1):
s390/early: improve machine detection
[03aa047ef2db4985e444af6ee1c1dd084ad9fb4c]
Christoph Paasch (1):
net/packet: Set __GFP_NOWARN upon allocation in alloc_pg_vec
[398f0132c14754fcd03c1c4f8e7176d001ce8ea1]
Cong Wang (1):
team: avoid complex list operations in team_nl_cmd_options_set()
[2fdeee2549231b1f989f011bb18191f5660d3745]
Dan Carpenter (4):
ALSA: cs46xx: Potential NULL dereference in probe
[1524f4e47f90b27a3ac84efbdd94c63172246a6f]
mfd: ab8500-core: Return zero in get_register_interruptible()
[10628e3ecf544fa2e4e24f8e112d95c37884dc98]
scsi: bnx2fc: Fix error handling in probe()
[b2d3492fc591b1fb46b81d79ca1fc44cac6ae0ae]
skge: potential memory corruption in skge_get_regs()
[294c149a209c6196c2de85f512b52ef50f519949]
Daniel Drake (1):
x86/kaslr: Fix incorrect i8254 outb() parameters
[7e6fc2f50a3197d0e82d1c0e86282976c9e6c8a4]
Daniele Palmas (1):
usb: cdc-acm: send ZLP for Telit 3G Intel based modems
[34aabf918717dd14e05051896aaecd3b16b53d95]
Darrick J. Wong (2):
tmpfs: fix link accounting when a tmpfile is linked in
[1062af920c07f5b54cf5060fde3339da6df0cf6b]
tmpfs: fix uninitialized return value in shmem_link
[29b00e609960ae0fcff382f4c7079dd0874a5311]
David Hildenbrand (1):
mm: migrate: don't rely on __PageMovable() of newpage after unlocking it
[e0a352fabce61f730341d119fbedf71ffdb8663f]
David Howells (1):
assoc_array: Fix shortcut creation
[bb2ba2d75a2d673e76ddaf13a9bd30d6a8b1bb08]
Davidlohr Bueso (1):
arc: do not export symbols in troubleshoot.c
[be2a7fce397d82b7dc3fdbc61fb0bdab118e65ca]
Dexuan Cui (1):
Drivers: hv: vmbus: Check for ring when getting debug info
[ba50bf1ce9a51fc97db58b96d01306aa70bc3979]
Eric Biggers (5):
KEYS: allow reaching the keys quotas exactly
[a08bf91ce28ed3ae7b6fef35d843fef8dc8c2cd9]
KEYS: always initialize keyring_index_key::desc_len
[ede0fa98a900e657d1fcd80b50920efc896c1a4c]
KEYS: restrict /proc/keys by credentials at open time
[4aa68e07d845562561f5e73c04aa521376e95252]
KEYS: user: Align the payload buffer
[cc1780fc42c76c705dd07ea123f1143dc5057630]
crypto: authenc - fix parsing key with misaligned rta_len
[8f9c469348487844328e162db57112f7d347c49f]
Eric Dumazet (3):
batman-adv: fix uninit-value in batadv_interface_tx()
[4ffcbfac60642f63ae3d80891f573ba7e94a265c]
net/x25: fix a race in x25_bind()
[797a22bd5298c2674d927893f46cadf619dad11d]
vxlan: test dev->flags & IFF_UP before calling netif_rx()
[4179cb5a4c924cd233eaadd081882425bc98f44e]Eric W. Biederman (4):
ipc/shm: Fix pid freeing.
[2236d4d39035b9839944603ec4b65ce71180a9ea]
signal: Always notice exiting tasks
[35634ffa1751b6efd8cf75010b509dcb0263e29b]
signal: Better detection of synchronous signals
[7146db3317c67b517258cb5e1b08af387da0618b]
signal: Restore the stop PTRACE_EVENT_EXIT
[cf43a757fd49442bc38f76088b70c2299eed2c2f]
Eugene Loh (1):
kallsyms: Handle too long symbols in kallsyms.c
[6db2983cd8064808141ccefd75218f5b4345ffae]
Eugeniy Paltsev (1):
ARC: U-boot: check arguments paranoidly
[a66f2e57bd566240d8b3884eedf503928fbbe557]
Felix Fietkau (1):
mac80211: ensure that mgmt tx skbs have tailroom for encryption
[9d0f50b80222dc273e67e4e14410fcfa4130a90c]
Feras Daoud (1):
IB/ipoib: Fix for use-after-free in ipoib_cm_tx_start
[6ab4aba00f811a5265acc4d3eb1863bb3ca60562]
Florian Westphal (1):
netfilter: nf_tables: nft_compat: fix refcount leak on xt module
[b8e9dc1c75714ceb53615743e1036f76e00f5a17]
Franky Lin (1):
brcmfmac: screening firmware event packet
[c56caa9db8abbbfb9e31325e0897705aa897db37]
Gabriel Krisman Bertazi (1):
sd: Clear PS bit before Mode Select.
[2c5d16d6a9e7218e57b716e4fd9d77c776d21471]
Gavin Li (1):
brcmfmac: fix incorrect event channel deduction
[8e290cecdd0178f3d4cf7d463c51dc7e462843b4]
Gerald Schaefer (1):
s390/smp: fix CPU hotplug deadlock with CPU rescan
[b7cb707c373094ce4008d4a6ac9b6b366ec52da5]
Greg Kroah-Hartman (3):
debugfs: fix debugfs_rename parameter checking
[d88c93f090f708c18195553b352b9f205e65418f]
tty: Handle problem if line discipline does not have receive_buf
[27cfb3a53be46a54ec5e0bd04e51995b74c90343]
tty: mark Siemens R3964 line discipline as BROKEN
[c7084edc3f6d67750f50d4183134c4fb5712a5c8]
Grygorii Strashko (1):
net: phy: micrel: ksz9031: reconfigure autoneg after phy autoneg workaround
[c1a8d0a3accf64a014d605e6806ce05d1c17adf1]
Guenter Roeck (1):
unicore32: Fix build error
[ca98565a6182a960cd857d7546267a0775154eb8]
Gustavo A. R. Silva (4):
char/mwave: fix potential Spectre v1 vulnerability
[701956d4018e5d5438570e39e8bda47edd32c489]
ipmi: msghandler: Fix potential Spectre v1 vulnerabilities
[a7102c7461794a5bb31af24b08e9e0f50038897a]
perf tests evsel-tp-sched: Fix bitwise operator
[489338a717a0dfbbd5a3fabccf172b78f0ac9015]
usb: gadget: udc: net2272: Fix bitwise and boolean operations
[07c69f1148da7de3978686d3af9263325d9d60bd]
Hangbin Liu (1):
sit: check if IPv6 enabled before calling ip6_err_gen_icmpv6_unreach()
[173656accaf583698bac3f9e269884ba60d51ef4]
Hans de Goede (2):
ACPI: power: Skip duplicate power resource references in _PRx
[7d7b467cb95bf29597b417d4990160d4ea6d69b9]
libata: Add NOLPM quirk for SAMSUNG MZ7TE512HMHP-000L1 SSD
[dd957493baa586f1431490f97f9c7c45eaf8ab10]
Heiner Kallweit (1):
net: phy: micrel: set soft_reset callback to genphy_soft_reset for KSZ9031
[1d16073a326891c2a964e4cb95bc18fbcafb5f74]
Hui Peng (1):
ALSA: usb-audio: Fix an out-of-bound read in create_composite_quirks
[cbb2ebf70daf7f7d97d3811a2ff8e39655b8c184]
Icenowy Zheng (2):
USB: storage: add quirk for SMI SM3350
[0a99cc4b8ee83885ab9f097a3737d1ab28455ac0]
USB: storage: don't insert sane sense for SPC3+ when bad sense specified
[c5603d2fdb424849360fe7e3f8c1befc97571b8c]
Ilya Dryomov (1):
rbd: don't return 0 on unmap if RBD_DEV_FLAG_REMOVING is set
[85f5a4d666fd9be73856ed16bb36c5af5b406b29]
Ingo Molnar (1):
perf/core: Fix impossible ring-buffer sizes warning
[528871b456026e6127d95b1b2bd8e3a003dc1614]
Ivan Mironov (3):
drm/fb-helper: Ignore the value of fb_var_screeninfo.pixclock
[66a8d5bfb518f9f12d47e1d2dce1732279f9451e]
drm/fb-helper: Partially bring back workaround for bugs of SDL 1.2
[62d85b3bf9d978ed4b6b2aeef5cf0ccf1423906e]
scsi: sd: Fix cache_type_store()
[44759979a49bfd2d20d789add7fa81a21eb1a4ab]
Jack Stocker (1):
USB: Add USB_QUIRK_DELAY_CTRL_MSG quirk for Corsair K70 RGB
[3483254b89438e60f719937376c5e0ce2bc46761]
Jacob Wen (1):
l2tp: copy 4 more bytes to linear part if necessary
[91c524708de6207f59dd3512518d8a1c7b434ee3]
Jann Horn (2):
fuse: call pipe_buf_release() under pipe lock
[9509941e9c534920ccc4771ae70bd6cbbe79df1c]
mm: enforce min addr even if capable() in expand_downwards()
[0a1d52994d440e21def1c2174932410b4f2a98a1]
Jason Gunthorpe (1):
packet: Do not leak dev refcounts on error exit
[d972f3dce8d161e2142da0ab1ef25df00e2f21a9]
Jiri Olsa (1):
perf/x86: Add check_period PMU callback
[81ec3f3c4c4d78f2d3b6689c9816bfbdf7417dbb]
John Garry (1):
scsi: libsas: Fix rphy phy_identifier for PHYs with end devices attached
[ffeafdd2bf0b280d67ec1a47ea6287910d271f3f]
John Johansen (1):
apparmor: provide userspace flag indicating binfmt_elf_mmap change
[34c426acb75cc21bdf84685e106db0c1a3565057]
Jonathan Bakker (1):
Input: bma150 - register input device after setting private data
[90cc55f067f6ca0e64e5e52883ece47d8af7b67b]
Jonathan Hunter (1):
mfd: tps6586x: Handle interrupts on suspend
[ac4ca4b9f4623ba5e1ea7a582f286567c611e027]
Jonathan Neuschäfer (1):
mmc: spi: Fix card detection during probe
[c9bd505dbd9d3dc80c496f88eafe70affdcf1ba6]
Jose Abreu (1):
net: stmmac: Fix a race in EEE enable callback
[8a7493e58ad688eb23b81e45461c5d314f4402f1]
Julian Wiedmann (3):
s390/qeth: cancel close_dev work before removing a card
[c2780c1a3fb724560b1d44f7976e0de17bf153c7]
s390/qeth: conclude all event processing before offlining a card
[c0a2e4d10d9366ada133a8ae4ff2f32397f8b15b]
s390/qeth: fix use-after-free in error path
[afa0c5904ba16d59b0454f7ee4c807dae350f432]
Jun-Ru Chang (1):
MIPS: Remove function size check in get_frame_info()
[2b424cfc69728224fcb5fad138ea7260728e0901]
Kal Conley (1):
net/packet: fix 4gb buffer limit due to overflow check
[fc62814d690cf62189854464f4bd07457d5e9e50]
Kan Liang (1):
perf/x86/intel/uncore: Add Node ID mask
[9e63a7894fd302082cf3627fe90844421a6cbe7f]
Kangjie Lu (1):
ASoC: atom: fix a missing check of snd_pcm_lib_malloc_pages
[44fabd8cdaaa3acb80ad2bb3b5c61ae2136af661]
Kees Cook (1):
Yama: Check for pid death before checking ancestry
[9474f4e7cd71a633fa1ef93b7daefd44bbdfd482]
Leonid Iziumtsev (1):
dmaengine: imx-dma: fix wrong callback invoke
[341198eda723c8c1cddbb006a89ad9e362502ea2]
Linus Torvalds (1):
binfmt_elf: switch to new creds when switching to new mm
[9f834ec18defc369d73ccf9e87a2790bfa05bf46]
Linus Walleij (1):
ARM: dts: kirkwood: Fix polarity of GPIO fan lines
[b5f034845e70916fd33e172fad5ad530a29c10ab]
Liping Zhang (1):
netfilter: nft_compat: fix crash when related match/target module is removed
[4b512e1c1f8de6b9ceb796ecef8658e0a083cab7]
Logan Gunthorpe (1):
scsi: isci: initialize shost fully before calling scsi_add_host()
[cc29a1b0a3f2597ce887d339222fa85b9307706d]
Lukas Wunner (2):
dmaengine: bcm2835: Fix abort of transactions
[9e528c799d17a4ac37d788c81440b50377dd592d]
dmaengine: bcm2835: Fix interrupt race on RT
[f7da7782aba92593f7b82f03d2409a1c5f4db91b]
Manfred Schlaegl (1):
can: dev: __can_get_echo_skb(): fix bogous check for non-existing skb by removing it
[7b12c8189a3dc50638e7d53714c88007268d47ef]
Manuel Reinhardt (1):
ALSA: usb-audio: Fix implicit fb endpoint setup by quirk
[2bc16b9f3223d049b57202ee702fcb5b9b507019]
Marcel Holtmann (2):
Bluetooth: Check L2CAP option sizes returned from l2cap_get_conf_opt
[af3d5d1c87664a4f150fcf3534c6567cb19909b0]
Bluetooth: Verify that l2cap_get_conf_opt provides large enough buffer
[7c9cbd0b5e38a1672fcd137894ace3b042dfbf69]
Mark Rutland (1):
perf/core: Don't WARN() for impossible ring-buffer sizes
[9dff0aa95a324e262ffb03f425d00e4751f3294e]
Martin Kepplinger (1):
mtd: rawnand: gpmi: fix MX28 bus master lockup problem
[d5d27fd9826b59979b184ec288e4812abac0e988]
Martin Schwidefsky (1):
s390/mm: always force a load of the primary ASCE on context switch
[a38662084c8bdb829ff486468c7ea801c13fcc34]
Martin Sperl (1):
dmaengine: bcm2835: add additional defines for DMA-registers
[e42685d7a7d5afa6278561ffd85c475eae246be3]
Matthias Schwarzott (1):
media: em28xx: Fix use-after-free when disconnecting
[910b0797fa9e8af09c44a3fa36cb310ba7a7218d]
Matti Kurkela (2):
Input: elantech - enable 3rd button support on Fujitsu CELSIUS H780
[e8b22d0a329f0fb5c7ef95406872d268f01ee3b1]
Input: elantech - force needed quirks on Fujitsu H760
[f9a703a54d16ba2470391c4b12236ee56591d50c]
Max Schulze (1):
USB: serial: simple: add Motorola Tetra TPG2200 device id
[b81c2c33eab79dfd3650293b2227ee5c6036585c]
Michael Straube (1):
staging: rtl8188eu: Add device code for D-Link DWA-121 rev B1
[5f74a8cbb38d10615ed46bc3e37d9a4c9af8045a]
Miklos Szeredi (2):
fuse: decrement NR_WRITEBACK_TEMP on the right page
[a2ebba824106dabe79937a9f29a875f837e1b6d4]
fuse: handle zero sized retrieve correctly
[97e1532ef81acb31c30f9e75bf00306c33a77812]
Naoya Horiguchi (1):
mm: hwpoison: use do_send_sig_info() instead of force_sig()
[6376360ecbe525a9c17b3d081dfd88ba3e4ed65b]
Nathan Sullivan (1):
net/phy: micrel: Add workaround for bad autoneg
[d2fd719bcb0e83cb39cfee22ee800f98a56eceb3]
Naveen N. Rao (1):
powerpc/signal: Properly handle return value from uprobe_deny_signal()
[46725b17f1c6c815a41429259b3f070c01e71bc1]
Nicolas Pitre (2):
vt: always call notifier with the console lock held
[7e1d226345f89ad5d0216a9092c81386c89b4983]
vt: invoke notifier on screen size change
[0c9b1965faddad7534b6974b5b36c4ad37998f8e]
Nikos Tsironis (1):
dm thin: fix bug where bio that overwrites thin block ignores FUA
[4ae280b4ee3463fa57bbe6eede26b97daff8a0f1]
Oleg Nesterov (1):
mm/mmap.c: expand_downwards: don't require the gap if !vm_prev
[32e4e6d5cbb0c0e427391635991fe65e17797af8]
Oliver Hartkopp (1):
can: bcm: check timer values before ktime conversion
[93171ba6f1deffd82f381d36cb13177872d023f6]
Pablo Neira Ayuso (2):
netfilter: nf_tables: fix flush after rule deletion in the same batch
[23b7ca4f745f21c2b9cfcb67fdd33733b3ae7e66]
netfilter: nft_compat: use-after-free when deleting targets
[753c111f655e38bbd52fc01321266633f022ebe2]
Paolo Abeni (1):
vsock: cope with memory allocation failure at socket creation time
[225d9464268599a5b4d094d02ec17808e44c7553]
Paul Elder (1):
usb: gadget: musb: fix short isoc packets with inventra dma
[c418fd6c01fbc5516a2cd1eaf1df1ec86869028a]
Paul Fulghum (1):
tty/n_hdlc: fix __might_sleep warning
[fc01d8c61ce02c034e67378cd3e645734bc18c8c]
Paul Moore (1):
netlabel: fix out-of-bounds memory accesses
[5578de4834fe0f2a34fedc7374be691443396d1f]
Pavel Shilovsky (3):
CIFS: Do not consider -ENODATA as stat failure for reads
[082aaa8700415f6471ec9c5ef0c8307ca214989a]
CIFS: Do not count -ENODATA as failure for query directory
[8e6e72aeceaaed5aeeb1cb43d3085de7ceb14f79]
CIFS: Do not hide EINTR after sending network packets
[ee13919c2e8d1f904e035ad4b4239029a8994131]
Peng Hao (1):
ARM: pxa: ssp: unneeded to free devm_ allocated data
[ba16adeb346387eb2d1ada69003588be96f098fa]
Peter Zijlstra (1):
perf/core: Fix perf_event_open() vs. execve() race
[79c9ce57eb2d5f1497546a3946b4ae21b6fdc438]
Rajasingh Thavamani (1):
net: phy: Micrel KSZ8061: link failure after cable connect
[232ba3a51cc224b339c7114888ed7f0d4d95695e]
Richard Weinberger (28):
Clean up signal_delivered()
[10b1c7ac8bfed429cf3dcb0225482c8dc1485d8e]
Rip out get_signal_to_deliver()
[828b1f65d23cf8a68795739f6dd08fc8abd9ee64]
arc: Use get_signal() signal_setup_done()
[f6dd2a3f1f8d8df640cfa2d60f85c0b818af1593]
arm64: Use get_signal() signal_setup_done()
[00554fa4f80279db92f82c4f52c8ae72711f173e]
avr32: Use get_signal() signal_setup_done()
[d809709a8845954a95c2ac86c13bd0dfd549c1ae]
blackfin: Use get_signal() signal_setup_done()
[1270cff147a39f7da5b25225dca6ca3132ca6130]
c6x: Use get_signal() signal_setup_done()
[e19c025bc9a184ed9c5daf06ffb89abc81d1696a]
cris: Use get_signal() signal_setup_done()
[fa0197722eb7559a6a9733881bbb8d9e76364f33]
frv: Use get_signal() signal_setup_done()
[720f36b983224ac52b6acdd8b646ce30f6b38763]
hexagon: Use get_signal() signal_setup_done()
[ac443624490f7033aefd06713e7761aee5977de3]
ia64: Use get_signal() signal_setup_done()
[98c20309b97fc30001adf643cf876125f334fd8a]
m32r: Use get_signal() signal_setup_done()
[0f5bef660a7c3b030eb60ceb29e3b2d89f894f56]
m68k: Use get_signal() signal_setup_done()
[0d97500d393012690f3579056629bea0369e6554]
microblaze: Use get_signal() signal_setup_done()
[9c53c7ec14a5738ae3117d7d71b7abf630526c9f]
mips: Use get_signal() signal_setup_done()
[81d103bf80678669c56658185e758fc3f9845d71]
mips: Use sigsp()
[7c4f563507c33ca97dcfbd62dba1e9232575d499]
mn10300: Use get_signal() signal_setup_done()
[8b166553a9aaf39774bc22f5e93c965584303929]
parisc: Use get_signal() signal_setup_done()
[e4dc894b61776733629b24507031dd46f5ba5efc]
powerpc: Use get_signal() signal_setup_done()
[129b69df9c9074750245fca8aa92df5cc1a86ef4]
powerpc: Use sigsp()
[059ade650ae57cfd371af690fdba887af04aded8]
s390: Use get_signal() signal_setup_done()
[067bf2d4d3a7aedc5982f6a58716054e5004b801]
score: Use get_signal() signal_setup_done()
[2bb12b773feb3e792145961e57ab356e6134d4a5]
sh: Use get_signal() signal_setup_done()
[b46e848768acc458ba94feef162b8901592dbb9c]
tile: Use get_signal() signal_setup_done()
[b3707c7ed013d36752272ca2f9ed20dc8aed92e4]
tracehook_signal_handler: Remove sig, info, ka and regs
[df5601f9c3d831b4c478b004a1ed90a18643adbe]
um: Use get_signal() signal_setup_done()
[307627eebbb0bc41b21e74d78b932362a6c1b38d]
unicore32: Use get_signal() signal_setup_done()
[649671c90eaf3cbbd0cd03460b6a92c0b674a32e]
xtensa: Use get_signal() signal_setup_done()
[5bdb7611eb7987102f3c0fef1220dd64b6fbd9fd]Ross Lagerwall (1):
cifs: Fix potential OOB access of lock element array
[b9a74cde94957d82003fb9f7ab4777938ca851cd]
Rundong Ge (1):
net: dsa: slave: Don't propagate flag changes on down slave interfaces
[17ab4f61b8cd6f9c38e9d0b935d86d73b5d0d2b5]
Russell King (1):
ARM: iop32x/n2100: fix PCI IRQ mapping
[db4090920ba2d61a5827a23e441447926a02ffee]
Sakari Ailus (1):
media: v4l: ioctl: Validate num_planes for debug messages
[7fe9f01c04c2673bd6662c35b664f0f91888b96f]
Samir Virmani (1):
uart: Fix crash in uart_write and uart_put_char
[aff9cf5955185d1f183227e46c5f8673fa483813]
Sergei Shtylyov (1):
mmc: tmio_mmc_core: don't claim spurious interrupts
[5c27ff5db1491a947264d6d4e4cbe43ae6535bae]
Sergei Trofimovich (1):
alpha: fix page fault handling for r16-r18 targets
[491af60ffb848b59e82f7c9145833222e0bf27a5]
Shakeel Butt (1):
mm, oom: fix use-after-free in oom_kill_process
[cefc7ef3c87d02fc9307835868ff721ea12cc597]
Sheng Lan (1):
net: netem: fix skb length BUG_ON in __skb_to_sgvec
[5845f706388a4cde0f6b80f9e5d33527e942b7d9]
Shuah Khan (1):
[media] media: em28xx-dvb - fix em28xx_dvb_resume() to not unregister i2c and dvb
[6eb5e3399e8f45aa191ad21c0556bece8ea559f2]
Shubhrajyoti Datta (1):
i2c: cadence: Fix the hold bit setting
[d358def706880defa4c9e87381c5bf086a97d5f9]
Stefan Haberland (1):
s390/dasd: fix using offset into zero size array error
[4a8ef6999bce998fa5813023a9a6b56eea329dba]
Suravee Suthikulpanit (1):
iommu/amd: Fix IOMMU page flush when detach device from a domain
[9825bd94e3a2baae1f4874767ae3a7d4c049720e]
Sven Eckelmann (2):
batman-adv: Avoid WARN on net_device without parent in netns
[955d3411a17f590364238bd0d3329b61f20c1cd2]
batman-adv: Force mac header to start of data on xmit
[9114daa825fc3f335f9bea3313ce667090187280]
Takashi Iwai (2):
ALSA: usb-audio: Always check descriptor sizes in parser code
[3e96d7280f16e2f787307f695a31296b9e4a1cd7]
ALSA: usb-audio: Avoid access before bLength check in build_audio_procunit()
[f4351a199cc120ff9d59e06d02e8657d08e6cc46]
Thomas Hellstrom (2):
drm/vmwgfx: Fix setting of dma masks
[4cbfa1e6c09e98450aab3240e5119b0ab2c9795b]
drm/vmwgfx: Return error code from vmw_execbuf_copy_fence_user
[728354c005c36eaf44b6e5552372b67e60d17f56]
Thomas Richter (1):
perf test: Fix failure of 'evsel-tp-sched' test on s390
[03d309711d687460d1345de8a0363f45b1c8cd11]
Tina Zhang (1):
drm/modes: Prevent division by zero htotal
[a2fcd5c84f7a7825e028381b10182439067aa90d]
Vineet Gupta (2):
ARC: mm: do_page_fault fixes #1: relinquish mmap_sem if signal arrives while handle_mm_fault
[4d447455e73b47c43dd35fcc38ed823d3182a474]
ARC: show_regs: lockdep: avoid page allocator...
[ab6c03676cb190156603cf4c5ecf97aa406c9c53]
Vitaly Kuznetsov (1):
x86/kvm/nVMX: read from MSR_IA32_VMX_PROCBASED_CTLS2 only when it is available
[6b1971c694975e49af302229202c0043568b1791]
Vlad Tsyrklevich (1):
omap2fb: Fix stack memory disclosure
[a01421e4484327fe44f8e126793ed5a48a221e24]
Waiman Long (1):
fs/dcache: Fix incorrect nr_dentry_unused accounting in shrink_dcache_sb()
[1dbd449c9943e3145148cc893c2461b72ba6fef0]
Willem de Bruijn (2):
packet: validate address length
[99137b7888f4058087895d035d81c6b2d31015c5]
packet: validate address length if non-zero
[6b8d95f1795c42161dc0984b6863e95d6acf24ed]
Yi Zeng (1):
i2c: dev: prevent adapter retries and timeout being set as minus value
[6ebec961d59bccf65d08b13fc1ad4e6272a89338]
YueHaibing (2):
mdio_bus: Fix use-after-free on device_register fails
[6ff7b060535e87c2ae14dd8548512abfdda528fb]
net: nfc: Fix NULL dereference on nfc_llcp_build_tlv fails
[58bdd544e2933a21a51eecf17c3f5f94038261b5]
YunQiang Su (1):
Disable MSI also when pcie-octeon.pcie_disable on
[a214720cbf50cd8c3f76bbb9c3f5c283910e9d33]
Yunjian Wang (1):
net: bridge: Fix ethernet header pointer before check skb forwardable
[28c1382fa28f2e2d9d0d6f25ae879b5af2ecbd03]
Zach Brown (1):
net/phy: micrel: configure intterupts after autoneg workaround
[b866203d872d5deeafcecd25ea429d6748b5bd56]
Zheng Yan (1):
ceph: avoid repeatedly adding inode to mdsc->snap_flush_list
[04242ff3ac0abbaa4362f97781dac268e6c3541a]Zhiqiang Liu (1):
net: fix IPv6 prefix route residue
[e75913c93f7cd5f338ab373c34c93a655bd309cb]
Makefile | 4 +- arch/alpha/mm/fault.c | 2 +- arch/arc/kernel/head.S | 4 +- arch/arc/kernel/setup.c | 88 ++++++++++---- arch/arc/kernel/signal.c | 39 +++--- arch/arc/kernel/troubleshoot.c | 27 ++--- arch/arc/mm/fault.c | 13 +- arch/arm/boot/dts/kirkwood-dnskw.dtsi | 4 +- arch/arm/mach-iop32x/n2100.c | 3 +- arch/arm/plat-pxa/ssp.c | 3 - arch/arm64/include/asm/signal32.h | 11 +- arch/arm64/kernel/signal.c | 48 ++++---- arch/arm64/kernel/signal32.c | 14 +-- arch/avr32/kernel/signal.c | 43 +++---- arch/blackfin/kernel/signal.c | 39 +++--- arch/c6x/kernel/signal.c | 43 +++---- arch/cris/arch-v10/kernel/signal.c | 79 +++++------- arch/cris/arch-v32/kernel/signal.c | 77 +++++------- arch/frv/kernel/signal.c | 99 +++++++-------- arch/hexagon/kernel/signal.c | 45 +++---- arch/ia64/kernel/signal.c | 46 ++++--- arch/m32r/kernel/signal.c | 47 ++++---- arch/m68k/kernel/signal.c | 63 ++++------ arch/microblaze/kernel/signal.c | 48 +++----- arch/mips/include/asm/abi.h | 10 +- arch/mips/kernel/process.c | 7 +- arch/mips/kernel/signal-common.h | 2 +- arch/mips/kernel/signal.c | 72 +++++------ arch/mips/kernel/signal32.c | 39 +++--- arch/mips/kernel/signal_n32.c | 20 ++-- arch/mips/pci/msi-octeon.c | 4 +- arch/mips/pci/pci-octeon.c | 10 +- arch/mn10300/kernel/signal.c | 89 ++++++-------- arch/parisc/kernel/signal.c | 58 ++++----- arch/powerpc/kernel/signal.c | 41 ++----- arch/powerpc/kernel/signal.h | 14 +-- arch/powerpc/kernel/signal_32.c | 36 +++--- arch/powerpc/kernel/signal_64.c | 28 ++--- arch/s390/include/asm/mmu_context.h | 12 +- arch/s390/kernel/compat_signal.c | 79 ++++++------ arch/s390/kernel/early.c | 4 +- arch/s390/kernel/entry.h | 4 +- arch/s390/kernel/setup.c | 2 + arch/s390/kernel/signal.c | 78 +++++------- arch/s390/kernel/smp.c | 4 + arch/score/kernel/signal.c | 43 +++---- arch/sh/kernel/signal_32.c | 79 +++++------- arch/sh/kernel/signal_64.c | 82 +++++-------- arch/tile/include/asm/compat.h | 3 +- arch/tile/kernel/compat_signal.c | 29 ++--- arch/tile/kernel/signal.c | 54 ++++----- arch/um/include/shared/frame_kern.h | 12 +- arch/um/kernel/signal.c | 27 ++--- arch/unicore32/kernel/signal.c | 51 ++++---- arch/x86/boot/compressed/aslr.c | 4 +- arch/x86/ia32/ia32_aout.c | 6 +- arch/x86/include/asm/uaccess.h | 7 +- arch/x86/kernel/cpu/perf_event.c | 9 ++ arch/x86/kernel/cpu/perf_event.h | 21 ++++ arch/x86/kernel/cpu/perf_event_intel.c | 9 ++ arch/x86/kernel/cpu/perf_event_intel_uncore.c | 4 +- arch/x86/kvm/vmx.c | 7 +- arch/x86/kvm/x86.c | 3 +- arch/x86/um/signal.c | 45 ++++--- arch/xtensa/kernel/signal.c | 43 +++---- crypto/authenc.c | 14 ++- drivers/acpi/power.c | 22 ++++ drivers/ata/libata-core.c | 1 + drivers/block/rbd.c | 9 +- drivers/char/Kconfig | 2 +- drivers/char/ipmi/ipmi_msghandler.c | 6 + drivers/char/mwave/mwavedd.c | 7 ++ drivers/dma/bcm2835-dma.c | 124 +++++++++++-------- drivers/dma/dmatest.c | 30 ++--- drivers/dma/imx-dma.c | 8 +- drivers/gpu/drm/drm_fb_helper.c | 133 ++++++++++++--------- drivers/gpu/drm/drm_modes.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 9 +- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 2 +- drivers/hv/hyperv_vmbus.h | 5 +- drivers/hv/ring_buffer.c | 31 +++-- drivers/hv/vmbus_drv.c | 91 +++++++++----- drivers/i2c/busses/i2c-cadence.c | 9 +- drivers/i2c/i2c-dev.c | 6 + drivers/infiniband/ulp/ipoib/ipoib.h | 1 - drivers/infiniband/ulp/ipoib/ipoib_cm.c | 3 +- drivers/input/misc/bma150.c | 9 +- drivers/input/mouse/elantech.c | 23 ++++ drivers/iommu/amd_iommu.c | 15 ++- drivers/md/dm-thin.c | 55 ++++++++- drivers/media/usb/em28xx/em28xx-dvb.c | 20 +--- drivers/media/v4l2-core/v4l2-ioctl.c | 4 +- drivers/mfd/ab8500-core.c | 2 +- drivers/mfd/tps6586x.c | 24 ++++ drivers/mmc/host/mmc_spi.c | 1 + drivers/mmc/host/tmio_mmc_pio.c | 8 +- drivers/mtd/nand/gpmi-nand/gpmi-lib.c | 13 +- drivers/net/can/dev.c | 27 ++--- drivers/net/ethernet/marvell/skge.c | 6 +- drivers/net/ethernet/mellanox/mlx4/fw.c | 68 +++++++---- .../net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 22 ++-- drivers/net/phy/mdio_bus.c | 1 - drivers/net/phy/micrel.c | 41 ++++++- drivers/net/team/team.c | 27 +---- drivers/net/vxlan.c | 13 +- drivers/net/wireless/brcm80211/brcmfmac/bcdc.c | 29 ++--- drivers/net/wireless/brcm80211/brcmfmac/dhd.h | 2 +- drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h | 4 +- .../net/wireless/brcm80211/brcmfmac/dhd_linux.c | 76 +++++++++--- drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 32 +++-- drivers/net/wireless/brcm80211/brcmfmac/fweh.h | 16 ++- drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c | 11 +- drivers/net/wireless/brcm80211/brcmfmac/proto.h | 18 ++- drivers/net/wireless/brcm80211/brcmfmac/usb.c | 2 +- .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c | 2 + drivers/s390/block/dasd_eckd.c | 8 ++ drivers/s390/char/sclp_config.c | 2 + drivers/s390/net/qeth_core.h | 3 +- drivers/s390/net/qeth_core_main.c | 35 ++++-- drivers/s390/net/qeth_l2_main.c | 7 +- drivers/s390/net/qeth_l3_main.c | 3 + drivers/scsi/bnx2fc/bnx2fc_io.c | 4 +- drivers/scsi/isci/init.c | 14 +-- drivers/scsi/libsas/sas_expander.c | 2 + drivers/scsi/sd.c | 7 ++ drivers/staging/rtl8188eu/os_dep/usb_intf.c | 1 + drivers/tty/n_hdlc.c | 1 + drivers/tty/serial/serial_core.c | 12 +- drivers/tty/tty_io.c | 3 +- drivers/tty/vt/vt.c | 3 +- drivers/usb/class/cdc-acm.c | 7 ++ drivers/usb/core/quirks.c | 3 +- drivers/usb/gadget/net2272.c | 2 +- drivers/usb/musb/musb_gadget.c | 13 +- drivers/usb/musb/musbhsdma.c | 21 ++-- drivers/usb/phy/phy-am335x.c | 5 +- drivers/usb/serial/pl2303.c | 1 + drivers/usb/serial/pl2303.h | 2 + drivers/usb/serial/usb-serial-simple.c | 3 +- drivers/usb/storage/scsiglue.c | 8 +- drivers/usb/storage/unusual_devs.h | 12 ++ drivers/vfio/vfio_iommu_type1.c | 15 +++ drivers/video/fbdev/omap2/omapfb/omapfb-ioctl.c | 2 + fs/binfmt_elf.c | 3 +- fs/ceph/snap.c | 3 +- fs/cifs/file.c | 8 +- fs/cifs/smb2file.c | 4 +- fs/cifs/smb2pdu.c | 6 +- fs/cifs/transport.c | 2 +- fs/dcache.c | 6 +- fs/debugfs/inode.c | 7 ++ fs/fuse/dev.c | 4 +- fs/fuse/file.c | 2 +- fs/proc/task_mmu.c | 22 +++- include/keys/user-type.h | 2 +- include/linux/perf_event.h | 5 + include/linux/sched.h | 21 ++++ include/linux/signal.h | 15 +-- include/linux/tracehook.h | 8 +- include/sound/compress_driver.h | 6 +- ipc/shm.c | 4 +- kernel/events/core.c | 70 ++++++++--- kernel/events/ring_buffer.c | 3 + kernel/signal.c | 105 ++++++++++++---- lib/assoc_array.c | 8 +- mm/memory-failure.c | 3 +- mm/migrate.c | 8 +- mm/mmap.c | 24 ++-- mm/oom_kill.c | 8 ++ mm/shmem.c | 12 +- net/batman-adv/hard-interface.c | 4 +- net/batman-adv/soft-interface.c | 4 + net/bluetooth/l2cap_core.c | 83 ++++++++----- net/bridge/br_forward.c | 26 ++-- net/can/bcm.c | 27 +++++ net/dsa/slave.c | 13 +- net/ipv4/cipso_ipv4.c | 6 +- net/ipv6/addrconf.c | 3 +- net/ipv6/sit.c | 3 +- net/l2tp/l2tp_core.c | 5 +- net/mac80211/tx.c | 9 +- net/netfilter/nf_tables_api.c | 3 + net/netfilter/nft_compat.c | 120 +++++++++++-------- net/nfc/llcp_commands.c | 20 ++++ net/nfc/llcp_core.c | 24 +++- net/packet/af_packet.c | 12 +- net/sched/sch_netem.c | 10 +- net/vmw_vsock/vmci_transport.c | 4 + net/x25/af_x25.c | 13 +- scripts/kallsyms.c | 4 +- security/apparmor/apparmorfs.c | 1 + security/keys/key.c | 4 +- security/keys/keyring.c | 4 +- security/keys/proc.c | 11 +- security/keys/request_key.c | 1 + security/keys/request_key_auth.c | 2 +- security/yama/yama_lsm.c | 4 +- sound/pci/cs46xx/dsp_spos.c | 3 + sound/soc/codecs/tlv320aic32x4.c | 4 + sound/soc/intel/sst-mfld-platform-pcm.c | 8 +- sound/usb/card.c | 5 + sound/usb/mixer.c | 10 +- sound/usb/pcm.c | 9 +- sound/usb/quirks-table.h | 6 + sound/usb/stream.c | 31 +++-- tools/perf/tests/evsel-tp-sched.c | 8 +- 206 files changed, 2364 insertions(+), 1834 deletions(-)
Signature · 2 lines
Ben Hutchings Teamwork is essential - it allows you to blame someone else.
PATCH 1/202 batman-adv: Avoid WARN on net_device without parent in netns
3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit 955d3411a17f590364238bd0d3329b61f20c1cd2 upstream.
It is not allowed to use WARN* helpers on potential incorrect input from the user or transient problems because systems configured as panic_on_warn will reboot due to such a problem.
A NULL return value of __dev_get_by_index can be caused by various problems which can either be related to the system configuration or problems (incorrectly returned network namespaces) in other (virtual) net_device drivers. batman-adv should not cause a (harmful) WARN in this situation and instead only report it via a simple message.
---
net/batman-adv/hard-interface.c +3 -1
@@ -89,8 +89,10 @@ static bool batadv_is_on_batman_iface(co/* recurse over the parent device */ parent_dev =__dev_get_by_index (&init_net, net_dev->iflink);/* if we got a NULL parent_dev there is something broken.. */ -if (WARN (!parent_dev,"Cannot find parent device" )) +if (!parent_dev) { +pr_err ("Cannot find parent device\n" );return false; + } ret =batadv_is_on_batman_iface (parent_dev);
PATCH 2/202 batman-adv: Force mac header to start of data on xmit
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit 9114daa825fc3f335f9bea3313ce667090187280 upstream.
The caller of ndo_start_xmit may not already have called skb_reset_mac_header. The returned value of skb_mac_header/eth_hdr therefore can be in the wrong position and even outside the current skbuff. This for example happens when the user binds to the device using a PF_PACKET-SOCK_RAW with enabled qdisc-bypass:
int opt = 4; setsockopt(sock, SOL_PACKET, PACKET_QDISC_BYPASS, &opt, sizeof(opt));
Since eth_hdr is used all over the codebase, the batadv_interface_tx function must always take care of resetting it.
--- net/batman-adv/soft-interface.c | 2 ++ 1 file changed, 2 insertions(+)
net/batman-adv/soft-interface.c +2 -0
@@ -180,6 +180,8 @@ static int batadv_interface_tx(struct sk soft_iface->trans_start = jiffies; vid =batadv_get_vid (skb,0 ); + +skb_reset_mac_header (skb); ethhdr =eth_hdr (skb);switch (ntohs (ethhdr->h_proto)) {
PATCH 3/202 ACPI: power: Skip duplicate power resource references in _PRx
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit 7d7b467cb95bf29597b417d4990160d4ea6d69b9 upstream.
Some ACPI tables contain duplicate power resource references like this:
Name (_PR0, Package (0x04) // _PR0: Power Resources for D0
{
P28P,
P18P,
P18P,
CLK4
})This causes a WARN_ON in sysfs_add_link_to_group() because we end up adding a link to the same acpi_device twice:
sysfs: cannot create duplicate filename '/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/808622C1:00/OVTI2680:00/power_resources_D0/LNXPOWER:0a'
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.19.12-301.fc29.x86_64 #1 Hardware name: Insyde CherryTrail/Type2 - Board Product Name, BIOS jumperx.T87.KFBNEEA02 04/13/2016 Call Trace: dump_stack+0x5c/0x80 sysfs_warn_dup.cold.3+0x17/0x2a sysfs_do_create_link_sd.isra.2+0xa9/0xb0 sysfs_add_link_to_group+0x30/0x50 acpi_power_expose_list+0x74/0xa0 acpi_power_add_remove_device+0x50/0xa0 acpi_add_single_object+0x26b/0x5f0 acpi_bus_check_add+0xc4/0x250 ...
To address this issue, make acpi_extract_power_resources() check for duplicates and simply skip them when found.
--- drivers/acpi/power.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
drivers/acpi/power.c +22 -0
@@ -132,6 +132,23 @@ void acpi_power_resources_list_free(stru } } +static bool acpi_power_resource_is_dup (union acpi_object *package, +unsigned int start,unsigned int i) +{ +acpi_handle rhandle, dup; +unsigned int j; + +/* The caller is expected to check the package element types */ + rhandle = package->package.elements[i].reference.handle; +for (j = start; j < i; j++) { + dup = package->package.elements[j].reference.handle; +if (dup == rhandle) +return true; + } + +return false; +} +int acpi_extract_power_resources (union acpi_object *package,unsigned int start,struct list_head *list) {
@@ -151,6 +168,11 @@ int acpi_extract_power_resources(union a err = -ENODEV ;break ; } + +/* Some ACPI tables contain duplicate power resource references */ +if (acpi_power_resource_is_dup (package, start, i)) +continue ; + err =acpi_add_power_resource (rhandle);if (err)break ;
PATCH 4/202 mfd: ab8500-core: Return zero in get_register_interruptible()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 10628e3ecf544fa2e4e24f8e112d95c37884dc98 upstream.
This function is supposed to return zero on success or negative error codes on error. Unfortunately, there is a bug so it sometimes returns non-zero, positive numbers on success.
I noticed this bug during review and I can't test it. It does appear that the return is sometimes propogated back to _regmap_read() where all non-zero returns are treated as failure so this may affect run time.
--- drivers/mfd/ab8500-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/ab8500-core.c +1 -1
@@ -259,7 +259,7 @@ static int get_register_interruptible(stmutex_unlock (&ab8500->lock);dev_vdbg (ab8500->dev,"rd: addr %#x => data %#x\n" , addr, ret); -return ret; +return (ret <0 ) ? ret :0 ; } static int ab8500_get_register(struct device *dev, u8 bank,
PATCH 5/202 mfd: tps6586x: Handle interrupts on suspend
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan Hunter <[email protected]>
commit ac4ca4b9f4623ba5e1ea7a582f286567c611e027 upstream.
The tps6586x driver creates an irqchip that is used by its various child devices for managing interrupts. The tps6586x-rtc device is one of its children that uses the tps6586x irqchip. When using the tps6586x-rtc as a wake-up device from suspend, the following is seen:
PM: Syncing filesystems ... done.
Freezing user space processes ... (elapsed 0.001 seconds) done. OOM killer disabled.
Freezing remaining freezable tasks ... (elapsed 0.000 seconds) done. Disabling non-boot CPUs ...
Entering suspend state LP1
Enabling non-boot CPUs ...
CPU1 is up
tps6586x 3-0034: failed to read interrupt status
tps6586x 3-0034: failed to read interrupt status
The reason why the tps6586x interrupt status cannot be read is because the tps6586x interrupt is not masked during suspend and when the tps6586x-rtc interrupt occurs, to wake-up the device, the interrupt is seen before the i2c controller has been resumed in order to read the tps6586x interrupt status.
The tps6586x-rtc driver sets it's interrupt as a wake-up source during suspend, which gets propagated to the parent tps6586x interrupt. However, the tps6586x-rtc driver cannot disable it's interrupt during suspend otherwise we would never be woken up and so the tps6586x must disable it's interrupt instead.
Prevent the tps6586x interrupt handler from executing on exiting suspend before the i2c controller has been resumed by disabling the tps6586x interrupt on entering suspend and re-enabling it on resuming from suspend.
--- drivers/mfd/tps6586x.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/mfd/tps6586x.c +24 -0
@@ -601,6 +601,29 @@ static int tps6586x_i2c_remove(struct i2return 0 ; } +static int __maybe_unused tps6586x_i2c_suspend (struct device *dev) +{ +struct tps6586x *tps6586x =dev_get_drvdata (dev); + +if (tps6586x->client->irq) +disable_irq (tps6586x->client->irq); + +return 0 ; +} + +static int __maybe_unused tps6586x_i2c_resume (struct device *dev) +{ +struct tps6586x *tps6586x =dev_get_drvdata (dev); + +if (tps6586x->client->irq) +enable_irq (tps6586x->client->irq); + +return 0 ; +} + +static SIMPLE_DEV_PM_OPS(tps6586x_pm_ops, tps6586x_i2c_suspend, + tps6586x_i2c_resume); +static const struct i2c_device_id tps6586x_id_table[] = { {"tps6586x" ,0 }, { },
@@ -612,6 +635,7 @@ static struct i2c_driver tps6586x_driver .name = "tps6586x", .owner = THIS_MODULE, .of_match_table = of_match_ptr(tps6586x_of_match), + .pm = &tps6586x_pm_ops, }, .probe = tps6586x_i2c_probe, .remove = tps6586x_i2c_remove,
PATCH 6/202 ALSA: usb-audio: Avoid access before bLength check in build_audio_procunit()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit f4351a199cc120ff9d59e06d02e8657d08e6cc46 upstream.
The parser for the processing unit reads bNrInPins field before the bLength sanity check, which may lead to an out-of-bound access when a malformed descriptor is given. Fix it by assignment after the bLength check.
--- sound/usb/mixer.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
sound/usb/mixer.c +8 -2
@@ -1787,7 +1787,7 @@ static int build_audio_procunit(struct m char *name) {struct uac_processing_unit_descriptor *desc = raw_desc; -int num_ins = desc->bNrInPins; +int num_ins;struct usb_mixer_elem_info *cval;struct snd_kcontrol *kctl;int i, err, nameid, type, len;
@@ -1802,7 +1802,13 @@ static int build_audio_procunit(struct m 0, NULL, default_value_info }; -if (desc->bLength <13 || desc->bLength <13 + num_ins || +if (desc->bLength <13 ) { +usb_audio_err (state->chip,"invalid %s descriptor (id %d)\n" , name, unitid); +return -EINVAL ; + } + + num_ins = desc->bNrInPins; +if (desc->bLength <13 + num_ins || desc->bLength < num_ins +uac_processing_unit_bControlSize (desc, state->mixer->protocol)) {usb_audio_err (state->chip,"invalid %s descriptor (id %d)\n" , name, unitid);return -EINVAL ;
PATCH 7/202 ALSA: usb-audio: Always check descriptor sizes in parser code
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 3e96d7280f16e2f787307f695a31296b9e4a1cd7 upstream.
There are a few places where we access the data without checking the actual object size from the USB audio descriptor. This may result in OOB access, as recently reported.
This patch addresses these missing checks. Most of added codes are simple bLength checks in the caller side. For the input and output terminal parsers, we put the length check in the parser functions. For the input terminal, a new argument is added to distinguish between UAC1 and the rest, as they treat different objects.
[bwh: Backported to 3.16:
- Drop changes in parse_audio_input_terminal() and UAC3 handling
- Adjust context, indentation]
---
sound/usb/card.c +5 -0
@@ -258,6 +258,11 @@ static int snd_usb_create_streams(structreturn -EINVAL ; } +if (h1->bLength <sizeof (*h1)) { +dev_err (&dev->dev,"cannot find UAC_HEADER\n" ); +return -EINVAL ; + } +if (!h1->bInCollection) {dev_info (&dev->dev,"skipping empty audio interface (v1)\n" );return -EINVAL ;
sound/usb/stream.c +21 -10
@@ -412,12 +412,8 @@ static int parse_uac_endpoint_attributes csep =snd_usb_find_desc (alts->extra, alts->extralen,NULL ,USB_DT_CS_ENDPOINT );if (!csep || csep->bLength <7 || - csep->bDescriptorSubtype !=UAC_EP_GENERAL ) { -usb_audio_warn (chip, -"%u:%d : no or invalid class specific endpoint descriptor\n" , - iface_no, altsd->bAlternateSetting); -return 0 ; - } + csep->bDescriptorSubtype !=UAC_EP_GENERAL ) + goto error;if (protocol ==UAC_VERSION_1 ) { attributes = csep->bmAttributes;
@@ -425,6 +421,8 @@ static int parse_uac_endpoint_attributesstruct uac2_iso_endpoint_descriptor *csep2 = (struct uac2_iso_endpoint_descriptor *) csep; +if (csep2->bLength <sizeof (*csep2)) + goto error; attributes = csep->bmAttributes &UAC_EP_CS_ATTR_FILL_MAX ;/* emulate the endpoint attributes of a v1 device */
@@ -433,6 +431,12 @@ static int parse_uac_endpoint_attributes }return attributes; + + error: +usb_audio_warn (chip, +"%u:%d : no or invalid class specific endpoint descriptor\n" , + iface_no, altsd->bAlternateSetting); +return 0 ; }/* find an input terminal descriptor (either UAC1 or UAC2) with the given
@@ -440,13 +444,17 @@ static int parse_uac_endpoint_attributes*/ static void *snd_usb_find_input_terminal_descriptor (struct usb_host_interface *ctrl_iface, -int terminal_id) +int terminal_id,bool uac2) {struct uac2_input_terminal_descriptor *term =NULL ; +size_t minlen = uac2 ?sizeof (struct uac2_input_terminal_descriptor ) : +sizeof (struct uac_input_terminal_descriptor );while ((term =snd_usb_find_csint_desc (ctrl_iface->extra, ctrl_iface->extralen, term,UAC_INPUT_TERMINAL ))) { +if (term->bLength < minlen) +continue ;if (term->bTerminalID == terminal_id)return term; }
@@ -463,7 +471,8 @@ static struct uac2_output_terminal_descrwhile ((term =snd_usb_find_csint_desc (ctrl_iface->extra, ctrl_iface->extralen, term,UAC_OUTPUT_TERMINAL ))) { -if (term->bTerminalID == terminal_id) +if (term->bLength >=sizeof (*term) && + term->bTerminalID == terminal_id)return term; }
@@ -561,7 +570,8 @@ int snd_usb_parse_audio_interface(struct format =le16_to_cpu (as->wFormatTag);/* remember the format value */ iterm =snd_usb_find_input_terminal_descriptor (chip->ctrl_intf, - as->bTerminalLink); + as->bTerminalLink, + false);if (iterm) { num_channels = iterm->bNrChannels; chconfig =le16_to_cpu (iterm->wChannelConfig);
@@ -597,7 +607,8 @@ int snd_usb_parse_audio_interface(struct/* lookup the terminal associated to this interface * to extract the clock */ input_term =snd_usb_find_input_terminal_descriptor (chip->ctrl_intf, - as->bTerminalLink); + as->bTerminalLink, + true);if (input_term) { clock = input_term->bCSourceID;if (!chconfig && (num_channels == input_term->bNrChannels))
PATCH 8/202 ALSA: usb-audio: Fix an out-of-bound read in create_composite_quirks
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hui Peng <[email protected]>
commit cbb2ebf70daf7f7d97d3811a2ff8e39655b8c184 upstream.
In create_composite_quirk, the terminating condition of for loops is quirk->ifnum < 0. So any composite quirks should end with struct snd_usb_audio_quirk object with ifnum < 0.
for (quirk = quirk_comp->data; quirk->ifnum >= 0; ++quirk) {
.....
}the data field of Bower's & Wilkins PX headphones usb device device quirks do not end with {.ifnum = -1}, wihch may result in out-of-bound read.
This Patch fix the bug by adding an ending quirk object.
--- sound/usb/quirks-table.h | 6 ++++++ 1 file changed, 6 insertions(+)
sound/usb/quirks-table.h +6 -0
@@ -3304,6 +3304,12 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge } } }, + { + .ifnum = -1 + }, + { + .ifnum = -1 + }, } } },
PATCH 9/202 USB: serial: simple: add Motorola Tetra TPG2200 device id
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Max Schulze <[email protected]>
commit b81c2c33eab79dfd3650293b2227ee5c6036585c upstream.
Add new Motorola Tetra device id for Motorola Solutions TETRA PEI device
T: Bus=02 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 4 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=0cad ProdID=9016 Rev=24.16 S: Manufacturer=Motorola Solutions, Inc. S: Product=TETRA PEI interface C: #Ifs= 2 Cfg#= 1 Atr=80 MxPwr=500mA I: If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=usb_serial_simple I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=usb_serial_simple
--- drivers/usb/serial/usb-serial-simple.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/serial/usb-serial-simple.c +2 -1
@@ -88,7 +88,8 @@ DEVICE(moto_modem, MOTO_IDS);/* Motorola Tetra driver */ #define MOTOROLA_TETRA_IDS () \ { USB_DEVICE(0x0cad, 0x9011) },/* Motorola Solutions TETRA PEI */ \ - { USB_DEVICE(0x0cad, 0x9012) } /* MTP6550 */ + { USB_DEVICE(0x0cad, 0x9012) }, /* MTP6550 */ \ + { USB_DEVICE(0x0cad, 0x9016) } /* TPG2200 */DEVICE (motorola_tetra,MOTOROLA_TETRA_IDS );/* Novatel Wireless GPS driver */
PATCH 10/202 usb: cdc-acm: send ZLP for Telit 3G Intel based modems
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Daniele Palmas <[email protected]>
commit 34aabf918717dd14e05051896aaecd3b16b53d95 upstream.
Telit 3G Intel based modems require zero packet to be sent if out data size is equal to the endpoint max packet size.
--- drivers/usb/class/cdc-acm.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/class/cdc-acm.c +7 -0
@@ -1903,6 +1903,13 @@ static const struct usb_device_id acm_id .driver_info = IGNORE_DEVICE, }, + { USB_DEVICE(0x1bc7, 0x0021), /* Telit 3G ACM only composition */ + .driver_info =SEND_ZERO_PACKET , + }, + { USB_DEVICE(0x1bc7, 0x0023), /* Telit 3G ACM + ECM composition */ + .driver_info = SEND_ZERO_PACKET, + }, + /* control interfaces without any protocol set */ { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, USB_CDC_PROTO_NONE) },
PATCH 11/202 USB: storage: don't insert sane sense for SPC3+ when bad sense specified
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Icenowy Zheng <[email protected]>
commit c5603d2fdb424849360fe7e3f8c1befc97571b8c upstream.
Currently the code will set US_FL_SANE_SENSE flag unconditionally if device claims SPC3+, however we should allow US_FL_BAD_SENSE flag to prevent this behavior, because SMI SM3350 UFS-USB bridge controller, which claims SPC4, will show strange behavior with 96-byte sense (put the chip into a wrong state that cannot read/write anything).
Check the presence of US_FL_BAD_SENSE when assuming US_FL_SANE_SENSE on SPC4+ devices.
--- drivers/usb/storage/scsiglue.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/usb/storage/scsiglue.c +6 -2
@@ -223,8 +223,12 @@ static int slave_configure(struct scsi_dif (!(us->fflags &US_FL_NEEDS_CAP16 )) sdev->try_rc_10_first =1 ; -/* assume SPC3 or latter devices support sense size > 18 */ -if (sdev->scsi_level >SCSI_SPC_2 ) +/* +* assume SPC3 or latter devices support sense size > 18 +* unless US_FL_BAD_SENSE quirk is specified. +*/ +if (sdev->scsi_level >SCSI_SPC_2 && + !(us->fflags &US_FL_BAD_SENSE )) us->fflags |=US_FL_SANE_SENSE ;/* USB-IDE bridges tend to report SK = 0x04 (Non-recoverable
PATCH 12/202 USB: storage: add quirk for SMI SM3350
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Icenowy Zheng <[email protected]>
commit 0a99cc4b8ee83885ab9f097a3737d1ab28455ac0 upstream.
The SMI SM3350 USB-UFS bridge controller cannot handle long sense request correctly and will make the chip refuse to do read/write when requested long sense.
Add a bad sense quirk for it.
--- drivers/usb/storage/unusual_devs.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/usb/storage/unusual_devs.h +12 -0
@@ -1194,6 +1194,18 @@ UNUSUAL_DEV( 0x090c, 0x1132, 0x0000, 0xf USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_FIX_CAPACITY ), +/* +* Reported by Icenowy Zheng <[email protected]> +* The SMI SM3350 USB-UFS bridge controller will enter a wrong state +* that do not process read/write command if a long sense is requested, +* so force to use 18-byte sense. +*/ +UNUSUAL_DEV (0x090c ,0x3350 ,0x0000 ,0xffff , +"SMI" , +"SM3350 UFS-to-USB-Mass-Storage bridge" , +USB_SC_DEVICE ,USB_PR_DEVICE ,NULL , + US_FL_BAD_SENSE ), +/* Reported by Paul Hartman <[email protected]> * This card reader returns "Illegal Request, Logical Block Address * Out of Range" for the first READ(10) after a new card is inserted.
PATCH 13/202 USB: Add USB_QUIRK_DELAY_CTRL_MSG quirk for Corsair K70 RGB
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jack Stocker <[email protected]>
commit 3483254b89438e60f719937376c5e0ce2bc46761 upstream.
To match the Corsair Strafe RGB, the Corsair K70 RGB also requires USB_QUIRK_DELAY_CTRL_MSG to completely resolve boot connection issues discussed here: https://github.com/ckb-next/ckb-next/issues/42.
Otherwise roughly 1 in 10 boots the keyboard will fail to be detected.
Patch that applied delay control quirk for Corsair Strafe RGB:cb88a0588717 ("usb: quirks: add control message delay for 1b1c:1b20")
Previous K70 RGB patch to add delay-init quirk:7a1646d92257 ("Add delay-init quirk for Corsair K70 RGB keyboards")
--- drivers/usb/core/quirks.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/core/quirks.c +2 -1
@@ -240,7 +240,8 @@ static const struct usb_device_id usb_qu { USB_DEVICE(0x1a40, 0x0101), .driver_info = USB_QUIRK_HUB_SLOW_RESET }, /* Corsair K70 RGB */ - { USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT }, + { USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT | + USB_QUIRK_DELAY_CTRL_MSG }, /* Corsair Strafe */ { USB_DEVICE(0x1b1c, 0x1b15), .driver_info = USB_QUIRK_DELAY_INIT |
PATCH 14/202 ASoC: tlv320aic32x4: Kernel OOPS while entering DAPM standby mode
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: b-ak <[email protected]>
commit 667e9334fa64da2273e36ce131b05ac9e47c5769 upstream.
During the bootup of the kernel, the DAPM bias level is in the OFF state. As soon as the DAPM framework kicks in it pushes the codec into STANDBY state.
The probe function doesn't prepare the clock, and STANDBY state does a clk_disable_unprepare() without checking the previous state. This leads to an OOPS.
Not transitioning from an OFF state to the STANDBY state fixes the problem.
[bwh: Backported to 3.16:
- Open-code snd_soc_component_get_bias_level()
- Adjust context]
--- sound/soc/codecs/tlv320aic32x4.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/soc/codecs/tlv320aic32x4.c +4 -0
@@ -534,6 +534,10 @@ static int aic32x4_set_bias_level(structcase SND_SOC_BIAS_PREPARE :break ;case SND_SOC_BIAS_STANDBY : +/* Initial cold start */ +if (codec->dapm.bias_level ==SND_SOC_BIAS_OFF ) +break ; +/* Switch off BCLK_N Divider */ snd_soc_update_bits (codec,AIC32X4_BCLKN ,AIC32X4_BCLKEN ,0 );
PATCH 15/202 ASoC: atom: fix a missing check of snd_pcm_lib_malloc_pages
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Kangjie Lu <[email protected]>
commit 44fabd8cdaaa3acb80ad2bb3b5c61ae2136af661 upstream.
snd_pcm_lib_malloc_pages() may fail, so let's check its status and return its error code upstream.
--- sound/soc/intel/sst-mfld-platform-pcm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
sound/soc/intel/sst-mfld-platform-pcm.c +7 -1
@@ -383,7 +383,13 @@ static snd_pcm_uframes_t sst_platform_pcstatic int sst_platform_pcm_hw_params (struct snd_pcm_substream *substream,struct snd_pcm_hw_params *params) { -snd_pcm_lib_malloc_pages (substream,params_buffer_bytes (params)); +int ret; + + ret = +snd_pcm_lib_malloc_pages (substream, +params_buffer_bytes (params)); +if (ret) +return ret;memset (substream->runtime->dma_area,0 ,params_buffer_bytes (params));return 0 ;
PATCH 16/202 ALSA: cs46xx: Potential NULL dereference in probe
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 1524f4e47f90b27a3ac84efbdd94c63172246a6f upstream.
The "chip->dsp_spos_instance" can be NULL on some of the ealier error paths in snd_cs46xx_create().
--- sound/pci/cs46xx/dsp_spos.c | 3 +++ 1 file changed, 3 insertions(+)
sound/pci/cs46xx/dsp_spos.c +3 -0
@@ -899,6 +899,9 @@ int cs46xx_dsp_proc_done (struct snd_cs4struct dsp_spos_instance * ins = chip->dsp_spos_instance;int i; +if (!ins) +return 0 ; +snd_info_free_entry (ins->proc_sym_info_entry); ins->proc_sym_info_entry =NULL ;
PATCH 17/202 packet: validate address length
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Willem de Bruijn <[email protected]>
commit 99137b7888f4058087895d035d81c6b2d31015c5 upstream.
Packet sockets with SOCK_DGRAM may pass an address for use in dev_hard_header. Ensure that it is of sufficient length.
--- net/packet/af_packet.c | 4 ++++ 1 file changed, 4 insertions(+)
net/packet/af_packet.c +4 -0
@@ -2301,6 +2301,8 @@ static int tpacket_snd(struct packet_soc proto = saddr->sll_protocol; addr = saddr->sll_addr; dev =dev_get_by_index (sock_net (&po->sk), saddr->sll_ifindex); +if (addr && dev && saddr->sll_halen < dev->addr_len) + goto out; } err = -ENXIO ;
@@ -2461,6 +2463,8 @@ static int packet_snd(struct socket *soc proto = saddr->sll_protocol; addr = saddr->sll_addr; dev =dev_get_by_index (sock_net (sk), saddr->sll_ifindex); +if (addr && dev && saddr->sll_halen < dev->addr_len) + goto out; } err = -ENXIO ;
PATCH 18/202 packet: validate address length if non-zero
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Willem de Bruijn <[email protected]>
commit 6b8d95f1795c42161dc0984b6863e95d6acf24ed upstream.
Validate packet socket address length if a length is given. Zero length is equivalent to not setting an address.
--- net/packet/af_packet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/packet/af_packet.c +2 -2
@@ -2299,7 +2299,7 @@ static int tpacket_snd(struct packet_soc sll_addr))) goto out; proto = saddr->sll_protocol; - addr = saddr->sll_addr; + addr = saddr->sll_halen ? saddr->sll_addr :NULL ; dev =dev_get_by_index (sock_net (&po->sk), saddr->sll_ifindex);if (addr && dev && saddr->sll_halen < dev->addr_len) goto out;
@@ -2461,7 +2461,7 @@ static int packet_snd(struct socket *socif (msg->msg_namelen < (saddr->sll_halen + offsetof(struct sockaddr_ll , sll_addr))) goto out; proto = saddr->sll_protocol; - addr = saddr->sll_addr; + addr = saddr->sll_halen ? saddr->sll_addr :NULL ; dev =dev_get_by_index (sock_net (sk), saddr->sll_ifindex);if (addr && dev && saddr->sll_halen < dev->addr_len) goto out;
PATCH 19/202 packet: Do not leak dev refcounts on error exit
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
commit d972f3dce8d161e2142da0ab1ef25df00e2f21a9 upstream.
'dev' is non NULL when the addr_len check triggers so it must goto a label that does the dev_put otherwise dev will have a leaked refcount.
This bug causes the ib_ipoib module to become unloadable when using systemd-network as it triggers this check on InfiniBand links.
--- net/packet/af_packet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/packet/af_packet.c +2 -2
@@ -2302,7 +2302,7 @@ static int tpacket_snd(struct packet_soc addr = saddr->sll_halen ? saddr->sll_addr :NULL ; dev =dev_get_by_index (sock_net (&po->sk), saddr->sll_ifindex);if (addr && dev && saddr->sll_halen < dev->addr_len) - goto out; + goto out_put; } err = -ENXIO ;
@@ -2464,7 +2464,7 @@ static int packet_snd(struct socket *soc addr = saddr->sll_halen ? saddr->sll_addr :NULL ; dev =dev_get_by_index (sock_net (sk), saddr->sll_ifindex);if (addr && dev && saddr->sll_halen < dev->addr_len) - goto out; + goto out_unlock; } err = -ENXIO ;
PATCH 20/202 sd: Clear PS bit before Mode Select.
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Gabriel Krisman Bertazi <[email protected]>
commit 2c5d16d6a9e7218e57b716e4fd9d77c776d21471 upstream.
According to SPC-4, in a Mode Select, the PS bit in Mode Pages is reserved and must be set to 0 by the driver. In the sd implementation, function cache_type_store does a Mode Sense, which might set the PS bit on the read buffer, followed by a Mode Select, which receives the same buffer, without explicitly clearing the PS bit. So, in cases where target supports saving the Mode Page to a non-volatile location, we end up doing a Mode Select with the PS bit set, which could cause an illegal request error if the target is checking this.
This was observed on a new firmware change, which was subsequently reverted, but this changes sd.c to be more compliant with SPC-4.
This patch clears the PS bit in the buffer returned by Mode Select, right before it is used in the Mode Select command.
--- drivers/scsi/sd.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/sd.c +1 -0
@@ -192,6 +192,7 @@ cache_type_store(struct device *dev, str buffer_data[2 ] &= ~0x05 ; buffer_data[2 ] |= wce <<2 | rcd; sp = buffer_data[0 ] &0x80 ?1 :0 ; + buffer_data[0 ] &= ~0x80 ;if (scsi_mode_select (sdp,1 , sp,8 , buffer_data, len,SD_TIMEOUT ,SD_MAX_RETRIES , &data, &sshdr)) {
PATCH 21/202 scsi: sd: Fix cache_type_store()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ivan Mironov <[email protected]>
commit 44759979a49bfd2d20d789add7fa81a21eb1a4ab upstream.
Changing of caching mode via /sys/devices/.../scsi_disk/.../cache_type may fail if device responds to MODE SENSE command with DPOFUA flag set, and then checks this flag to be not set on MODE SELECT command.
In this scenario, when trying to change cache_type, write always fails:
# echo "none" >cache_type bash: echo: write error: Invalid argument
And following appears in dmesg:
[13007.865745] sd 1:0:1:0: [sda] Sense Key : Illegal Request [current] [13007.865753] sd 1:0:1:0: [sda] Add. Sense: Invalid field in parameter list
=46romSBC-4 r15, 6.5.1 "Mode pages overview", description of DEVICE-SPECIFIC PARAMETER field in the mode parameter header:
... The write protect (WP) bit for mode data sent with a MODE SELECT command shall be ignored by the device server. ... The DPOFUA bit is reserved for mode data sent with a MODE SELECT command. ...
The remaining bits in the DEVICE-SPECIFIC PARAMETER byte are also reserved and shall be set to zero.
[mkp: shuffled commentary to commit description]
--- drivers/scsi/sd.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/scsi/sd.c +6 -0
@@ -194,6 +194,12 @@ cache_type_store(struct device *dev, str sp = buffer_data[0 ] &0x80 ?1 :0 ; buffer_data[0 ] &= ~0x80 ; +/* +* Ensure WP, DPOFUA, and RESERVED fields are cleared in +* received mode parameter buffer before doing MODE SELECT. +*/ + data.device_specific =0 ; +if (scsi_mode_select (sdp,1 , sp,8 , buffer_data, len,SD_TIMEOUT ,SD_MAX_RETRIES , &data, &sshdr)) {if (scsi_sense_valid (&sshdr))
PATCH 22/202 scsi: isci: initialize shost fully before calling scsi_add_host()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Logan Gunthorpe <[email protected]>
commit cc29a1b0a3f2597ce887d339222fa85b9307706d upstream.
scsi_mq_setup_tags(), which is called by scsi_add_host(), calculates the command size to allocate based on the prot_capabilities. In the isci driver, scsi_host_set_prot() is called after scsi_add_host() so the command size gets calculated to be smaller than it needs to be. Eventually, scsi_mq_init_request() locates the 'prot_sdb' after the command assuming it was sized correctly and a buffer overrun may occur.
However, seeing blk_mq_alloc_rqs() rounds up to the nearest cache line size, the mistake can go unnoticed.
The bug was noticed after the struct request size was reduced by commit 9d037ad707ed ("block: remove req->timeout_list")
Which likely reduced the allocated space for the request by an entire cache line, enough that the overflow could be hit and it caused a panic, on boot, at:
RIP: 0010:t10_pi_complete+0x77/0x1c0
Call Trace:
<IRQ>
sd_done+0xf5/0x340
scsi_finish_command+0xc3/0x120
blk_done_softirq+0x83/0xb0
__do_softirq+0xa1/0x2e6
irq_exit+0xbc/0xd0
call_function_single_interrupt+0xf/0x20
</IRQ>sd_done() would call scsi_prot_sg_count() which reads the number of entities in 'prot_sdb', but seeing 'prot_sdb' is located after the end of the allocated space it reads a garbage number and erroneously calls t10_pi_complete().
To prevent this, the calls to scsi_host_set_prot() are moved into isci_host_alloc() before the call to scsi_add_host(). Out of caution, also move the similar call to scsi_host_set_guard().
--- drivers/scsi/isci/init.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/scsi/isci/init.c +7 -7
@@ -598,6 +598,13 @@ static struct isci_host *isci_host_alloc shost->max_lun = ~0 ; shost->max_cmd_len =MAX_COMMAND_SIZE ; +/* turn on DIF support */ +scsi_host_set_prot (shost, +SHOST_DIF_TYPE1_PROTECTION | +SHOST_DIF_TYPE2_PROTECTION | +SHOST_DIF_TYPE3_PROTECTION ); +scsi_host_set_guard (shost,SHOST_DIX_GUARD_CRC ); + err =scsi_add_host (shost, &pdev->dev);if (err) goto err_shost;
@@ -685,13 +692,6 @@ static int isci_pci_probe(struct pci_dev goto err_host_alloc; } pci_info->hosts[i] = h; - -/* turn on DIF support */ -scsi_host_set_prot (to_shost (h), -SHOST_DIF_TYPE1_PROTECTION | -SHOST_DIF_TYPE2_PROTECTION | -SHOST_DIF_TYPE3_PROTECTION ); -scsi_host_set_guard (to_shost (h),SHOST_DIX_GUARD_CRC ); } err =isci_setup_interrupts (pdev);
PATCH 23/202 Drivers: hv: vmbus: Check for ring when getting debug info
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dexuan Cui <[email protected]>
commit ba50bf1ce9a51fc97db58b96d01306aa70bc3979 upstream.
fc96df16a1ce is good and can already fix the "return stack garbage" issue, but let's also improve hv_ringbuffer_get_debuginfo(), which would silently return stack garbage, if people forget to check channel->state or ring_info->ring_buffer, when using the function in the future.
Having an error check in the function would eliminate the potential risk.
Add a Fixes tag to indicate the patch depdendency.
--- drivers/hv/ring_buffer.c | 31 +++++++------- drivers/hv/vmbus_drv.c | 91 +++++++++++++++++++++++++++------------- include/linux/hyperv.h | 5 ++- 3 files changed, 79 insertions(+), 48 deletions(-)
drivers/hv/ring_buffer.c +14 -15
@@ -329,26 +329,25 @@ static u32 hv_copyto_ringbuffer(* Get various debug metrics for the specified ring buffer * */ -void hv_ringbuffer_get_debuginfo (struct hv_ring_buffer_info *ring_info, -struct hv_ring_buffer_debug_info *debug_info) +int hv_ringbuffer_get_debuginfo (struct hv_ring_buffer_info *ring_info, +struct hv_ring_buffer_debug_info *debug_info) {u32 bytes_avail_towrite;u32 bytes_avail_toread; -if (ring_info->ring_buffer) { -hv_get_ringbuffer_availbytes (ring_info, - &bytes_avail_toread, - &bytes_avail_towrite); +if (!ring_info->ring_buffer) +return -EINVAL ; - debug_info->bytes_avail_toread = bytes_avail_toread; - debug_info->bytes_avail_towrite = bytes_avail_towrite; - debug_info->current_read_index = - ring_info->ring_buffer->read_index; - debug_info->current_write_index = - ring_info->ring_buffer->write_index; - debug_info->current_interrupt_mask = - ring_info->ring_buffer->interrupt_mask; - } +hv_get_ringbuffer_availbytes (ring_info, + &bytes_avail_toread, + &bytes_avail_towrite); + debug_info->bytes_avail_toread = bytes_avail_toread; + debug_info->bytes_avail_towrite = bytes_avail_towrite; + debug_info->current_read_index = ring_info->ring_buffer->read_index; + debug_info->current_write_index = ring_info->ring_buffer->write_index; + debug_info->current_interrupt_mask + = ring_info->ring_buffer->interrupt_mask; +return 0 ; }/*
drivers/hv/vmbus_drv.c +61 -30
181 lines not on this page · raw message
drivers/hv/hyperv_vmbus.h +3 -2
@@ -580,8 +580,9 @@ int hv_ringbuffer_read(struct hv_ring_bu u32 offset, bool *signal); -void hv_ringbuffer_get_debuginfo (struct hv_ring_buffer_info *ring_info, -struct hv_ring_buffer_debug_info *debug_info); + +int hv_ringbuffer_get_debuginfo (struct hv_ring_buffer_info *ring_info, +struct hv_ring_buffer_debug_info *debug_info);void hv_begin_read (struct hv_ring_buffer_info *rbi);
PATCH 24/202 drm/fb-helper: Partially bring back workaround for bugs of SDL 1.2
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ivan Mironov <[email protected]>
commit 62d85b3bf9d978ed4b6b2aeef5cf0ccf1423906e upstream.
SDL 1.2 sets all fields related to the pixel format to zero in some cases[1]. Prior to commit db05c48197759 ("drm: fb-helper: Reject all pixel format changing requests"), there was an unintentional workaround for this that existed for more than a decade. First in device-specific DRM drivers, then here in drm_fb_helper.c.
Previous code containing this workaround just ignores pixel format fields from userspace code. Not a good thing either, as this way, driver may silently use pixel format different from what client actually requested, and this in turn will lead to displaying garbage on the screen. I think that returning EINVAL to userspace in this particular case is the right option, so I decided to left code from problematic commit untouched instead of just reverting it entirely.
Here is the steps required to reproduce this problem exactly:
1) Compile fceux[2] with SDL 1.2.15 and without GTK or OpenGL support. SDL should be compiled with fbdev support (which is on by default).
2) Create /etc/fb.modes with following contents (values seems not used, and just required to trigger problematic code in SDL):
mode "test"
geometry 1 1 1 1 1
timings 1 1 1 1 1 1 1
endmode
3) Create ~/.fceux/fceux.cfg with following contents:
SDL.Hotkeys.Quit = 27
SDL.DoubleBuffering = 1
4) Ensure that screen resolution is at least 1280x960 (e.g. append "video=Virtual-1:1280x960-32" to the kernel cmdline for qemu/QXL).
5) Try to run fceux on VT with some ROM file[3]:
# ./fceux color_test.nes
[1] SDL 1.2.15 source code, src/video/fbcon/SDL_fbvideo.c, FB_SetVideoMode()
[2] http://www.fceux.com
[3] Example ROM: https://github.com/bokuweb/rustynes/blob/master/roms/color_test.nes
[bwh: Backported to 3.16:
- Use fb->depth instead of fb->format->depth
- Adjust context]
--- drivers/gpu/drm/drm_fb_helper.c | 126 ++++++++++++++++++-------------- 1 file changed, 73 insertions(+), 53 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +73 -53
@@ -769,6 +769,64 @@ static bool drm_fb_pixel_format_equal(co var_1->transp.msb_right == var_2->transp.msb_right; } +static void drm_fb_helper_fill_pixel_fmt (struct fb_var_screeninfo *var, +u8 depth) +{ +switch (depth) { +case 8 : + var->red.offset =0 ; + var->green.offset =0 ; + var->blue.offset =0 ; + var->red.length =8 ;/* 8bit DAC */ + var->green.length =8 ; + var->blue.length =8 ; + var->transp.offset =0 ; + var->transp.length =0 ; +break ; +case 15 : + var->red.offset =10 ; + var->green.offset =5 ; + var->blue.offset =0 ; + var->red.length =5 ; + var->green.length =5 ; + var->blue.length =5 ; + var->transp.offset =15 ; + var->transp.length =1 ; +break ; +case 16 : + var->red.offset =11 ; + var->green.offset =5 ; + var->blue.offset =0 ; + var->red.length =5 ; + var->green.length =6 ; + var->blue.length =5 ; + var->transp.offset =0 ; +break ; +case 24 : + var->red.offset =16 ; + var->green.offset =8 ; + var->blue.offset =0 ; + var->red.length =8 ; + var->green.length =8 ; + var->blue.length =8 ; + var->transp.offset =0 ; + var->transp.length =0 ; +break ; +case 32 : + var->red.offset =16 ; + var->green.offset =8 ; + var->blue.offset =0 ; + var->red.length =8 ; + var->green.length =8 ; + var->blue.length =8 ; + var->transp.offset =24 ; + var->transp.length =8 ; +break ; +default : +break ; + } +} +/** * drm_fb_helper_check_var - implementation for ->fb_check_var * @var: screeninfo to check
@@ -796,6 +854,20 @@ int drm_fb_helper_check_var(struct fb_va }/* +* Workaround for SDL 1.2, which is known to be setting all pixel format +* fields values to zero in some cases. We treat this situation as a +* kind of "use some reasonable autodetected values". +*/ +if (!var->red.offset && !var->green.offset && + !var->blue.offset && !var->transp.offset && + !var->red.length && !var->green.length && + !var->blue.length && !var->transp.length && + !var->red.msb_right && !var->green.msb_right && + !var->blue.msb_right && !var->transp.msb_right) { +drm_fb_helper_fill_pixel_fmt (var, fb->depth); + } + +/* * drm fbdev emulation doesn't support changing the pixel format at all, * so reject all pixel format changing requests. */
@@ -1058,59 +1130,7 @@ void drm_fb_helper_fill_var(struct fb_in info->var.height =-1 ; info->var.width =-1 ; -switch (fb->depth) { -case 8 : - info->var.red.offset =0 ; - info->var.green.offset =0 ; - info->var.blue.offset =0 ; - info->var.red.length =8 ;/* 8bit DAC */ - info->var.green.length =8 ; - info->var.blue.length =8 ; - info->var.transp.offset =0 ; - info->var.transp.length =0 ; -break ; -case 15 : - info->var.red.offset =10 ; - info->var.green.offset =5 ; - info->var.blue.offset =0 ; - info->var.red.length =5 ; - info->var.green.length =5 ; - info->var.blue.length =5 ; - info->var.transp.offset =15 ; - info->var.transp.length =1 ; -break ; -case 16 : - info->var.red.offset =11 ; - info->var.green.offset =5 ; - info->var.blue.offset =0 ; - info->var.red.length =5 ; - info->var.green.length =6 ; - info->var.blue.length =5 ; - info->var.transp.offset =0 ; -break ; -case 24 : - info->var.red.offset =16 ; - info->var.green.offset =8 ; - info->var.blue.offset =0 ; - info->var.red.length =8 ; - info->var.green.length =8 ; - info->var.blue.length =8 ; - info->var.transp.offset =0 ; - info->var.transp.length =0 ; -break ; -case 32 : - info->var.red.offset =16 ; - info->var.green.offset =8 ; - info->var.blue.offset =0 ; - info->var.red.length =8 ; - info->var.green.length =8 ; - info->var.blue.length =8 ; - info->var.transp.offset =24 ; - info->var.transp.length =8 ; -break ; -default : -break ; - } +drm_fb_helper_fill_pixel_fmt (&info->var, fb->depth); info->var.xres = fb_width; info->var.yres = fb_height;
PATCH 25/202 drm/fb-helper: Ignore the value of fb_var_screeninfo.pixclock
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ivan Mironov <[email protected]>
commit 66a8d5bfb518f9f12d47e1d2dce1732279f9451e upstream.
Strict requirement of pixclock to be zero breaks support of SDL 1.2 which contains hardcoded table of supported video modes with non-zero pixclock values[1].
To better understand which pixclock values are considered valid and how driver should handle these values, I briefly examined few existing fbdev drivers and documentation in Documentation/fb/. And it looks like there are no strict rules on that and actual behaviour varies:
* some drivers treat (pixclock == 0) as "use defaults" (uvesafb.c);
* some treat (pixclock == 0) as invalid value which leads to -EINVAL (clps711x-fb.c);
* some pass converted pixclock value to hardware (uvesafb.c);
* some are trying to find nearest value from predefined table (vga16fb.c, video_gx.c).
Given this, I believe that it should be safe to just ignore this value if changing is not supported. It seems that any portable fbdev application which was not written only for one specific device working under one specific kernel version should not rely on any particular behaviour of pixclock anyway.
However, while enabling SDL1 applications to work out of the box when there is no /etc/fb.modes with valid settings, this change affects the video mode choosing logic in SDL. Depending on current screen resolution, contents of /etc/fb.modes and resolution requested by application, this may lead to user-visible difference (not always):
image will be displayed in a right way, but it will be aligned to the left instead of center. There is no "right behaviour" here as well, as emulated fbdev, opposing to old fbdev drivers, simply ignores any requsts of video mode changes with resolutions smaller than current.
The easiest way to reproduce this problem is to install sdl-sopwith[2], remove /etc/fb.modes file if it exists, and then try to run sopwith from console without X. At least in Fedora 29, sopwith may be simply installed from standard repositories.
[1] SDL 1.2.15 source code, src/video/fbcon/SDL_fbvideo.c, vesa_timings
[2] http://sdl-sopwith.sourceforge.net/
--- drivers/gpu/drm/drm_fb_helper.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_fb_helper.c +6 -1
@@ -838,9 +838,14 @@ int drm_fb_helper_check_var(struct fb_vastruct drm_fb_helper *fb_helper = info->par;struct drm_framebuffer *fb = fb_helper->fb; -if (var->pixclock !=0 ||in_dbg_master ()) +if (in_dbg_master ())return -EINVAL ; +if (var->pixclock !=0 ) { +DRM_DEBUG ("fbdev emulation doesn't support changing the pixel clock, value of pixclock is ignored\n" ); + var->pixclock =0 ; + } +/* Need to resize the fb object !!! */ if (var->bits_per_pixel > fb->bits_per_pixel || var->xres > fb->width || var->yres > fb->height ||
PATCH 26/202 rbd: don't return 0 on unmap if RBD_DEV_FLAG_REMOVING is set
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Dryomov <[email protected]>
commit 85f5a4d666fd9be73856ed16bb36c5af5b406b29 upstream.
There is a window between when RBD_DEV_FLAG_REMOVING is set and when the device is removed from rbd_dev_list. During this window, we set "already" and return 0.
Returning 0 from write(2) can confuse userspace tools because 0 indicates that nothing was written. In particular, "rbd unmap" will retry the write multiple times a second:
10:28:05.463299 write(4, "0", 1) = 0 10:28:05.463509 write(4, "0", 1) = 0 10:28:05.463720 write(4, "0", 1) = 0 10:28:05.463942 write(4, "0", 1) = 0 10:28:05.464155 write(4, "0", 1) = 0
--- drivers/block/rbd.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/block/rbd.c +4 -5
@@ -5422,7 +5422,6 @@ static ssize_t do_rbd_remove(struct bus_struct list_head *tmp;int dev_id;unsigned long ul; -bool already = false;int ret; ret =kstrtoul (buf,10 , &ul);
@@ -5447,13 +5446,13 @@ static ssize_t do_rbd_remove(struct bus_spin_lock_irq (&rbd_dev->lock);if (rbd_dev->open_count) ret = -EBUSY ; -else - already =test_and_set_bit (RBD_DEV_FLAG_REMOVING , - &rbd_dev->flags); +else if (test_and_set_bit (RBD_DEV_FLAG_REMOVING , + &rbd_dev->flags)) + ret = -EINPROGRESS ;spin_unlock_irq (&rbd_dev->lock); }spin_unlock (&rbd_dev_list_lock); -if (ret <0 || already) +if (ret)return ret;rbd_dev_header_unwatch_sync (rbd_dev);
PATCH 27/202 ARM: dts: kirkwood: Fix polarity of GPIO fan lines
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
commit b5f034845e70916fd33e172fad5ad530a29c10ab upstream.
These two lines are active high, not active low. The bug was found when we changed the kernel to respect the polarity defined in the device tree.
--- arch/arm/boot/dts/kirkwood-dnskw.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/boot/dts/kirkwood-dnskw.dtsi +2 -2
@@ -35,8 +35,8 @@ compatible = "gpio-fan"; pinctrl-0 = <&pmx_fan_high_speed &pmx_fan_low_speed>; pinctrl-names = "default"; - gpios = <&gpio1 14 GPIO_ACTIVE_LOW - &gpio1 13 GPIO_ACTIVE_LOW>; + gpios = <&gpio1 14 GPIO_ACTIVE_HIGH + &gpio1 13 GPIO_ACTIVE_HIGH>; gpio-fan,speed-map = <0 0 3000 1 6000 2>;
PATCH 28/202 crypto: authenc - fix parsing key with misaligned rta_len
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 8f9c469348487844328e162db57112f7d347c49f upstream.
Keys for "authenc" AEADs are formatted as an rtattr containing a 4-byte 'enckeylen', followed by an authentication key and an encryption key. crypto_authenc_extractkeys() parses the key to find the inner keys.
However, it fails to consider the case where the rtattr's payload is longer than 4 bytes but not 4-byte aligned, and where the key ends before the next 4-byte aligned boundary. In this case, 'keylen -= RTA_ALIGN(rta->rta_len);' underflows to a value near UINT_MAX. This causes a buffer overread and crash during crypto_ahash_setkey().
Fix it by restricting the rtattr payload to the expected size.
Reproducer using AF_ALG:
#include <linux/if_alg.h>
#include <linux/rtnetlink.h>
#include <sys/socket.h>
int main()
{
int fd;
struct sockaddr_alg addr = {
.salg_type = "aead",
.salg_name = "authenc(hmac(sha256),cbc(aes))",
};
struct {
struct rtattr attr;
__be32 enckeylen;
char keys[1];
} __attribute__((packed)) key = {
.attr.rta_len = sizeof(key),
.attr.rta_type = 1 /* CRYPTO_AUTHENC_KEYA_PARAM */,
};
fd = socket(AF_ALG, SOCK_SEQPACKET, 0);
bind(fd, (void *)&addr, sizeof(addr));
setsockopt(fd, SOL_ALG, ALG_SET_KEY, &key, sizeof(key));
}It caused:
BUG: unable to handle kernel paging request at ffff88007ffdc000 PGD 2e01067 P4D 2e01067 PUD 2e04067 PMD 2e05067 PTE 0 Oops: 0000 [#1] SMP CPU: 0 PID: 883 Comm: authenc Not tainted 4.20.0-rc1-00108-g00c9fe37a7f27 #13 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-20181126_142135-anatol 04/01/2014 RIP: 0010:sha256_ni_transform+0xb3/0x330 arch/x86/crypto/sha256_ni_asm.S:155 [...] Call Trace: sha256_ni_finup+0x10/0x20 arch/x86/crypto/sha256_ssse3_glue.c:321 crypto_shash_finup+0x1a/0x30 crypto/shash.c:178 shash_digest_unaligned+0x45/0x60 crypto/shash.c:186 crypto_shash_digest+0x24/0x40 crypto/shash.c:202 hmac_setkey+0x135/0x1e0 crypto/hmac.c:66 crypto_shash_setkey+0x2b/0xb0 crypto/shash.c:66 shash_async_setkey+0x10/0x20 crypto/shash.c:223 crypto_ahash_setkey+0x2d/0xa0 crypto/ahash.c:202 crypto_authenc_setkey+0x68/0x100 crypto/authenc.c:96 crypto_aead_setkey+0x2a/0xc0 crypto/aead.c:62 aead_setkey+0xc/0x10 crypto/algif_aead.c:526 alg_setkey crypto/af_alg.c:223 [inline] alg_setsockopt+0xfe/0x130 crypto/af_alg.c:256 __sys_setsockopt+0x6d/0xd0 net/socket.c:1902 __do_sys_setsockopt net/socket.c:1913 [inline] __se_sys_setsockopt net/socket.c:1910 [inline] __x64_sys_setsockopt+0x1f/0x30 net/socket.c:1910 do_syscall_64+0x4a/0x180 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe
--- crypto/authenc.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
crypto/authenc.c +11 -3
@@ -62,14 +62,22 @@ int crypto_authenc_extractkeys(struct crreturn -EINVAL ;if (rta->rta_type !=CRYPTO_AUTHENC_KEYA_PARAM )return -EINVAL ; -if (RTA_PAYLOAD (rta) <sizeof (*param)) + +/* +* RTA_OK() didn't align the rtattr's payload when validating that it +* fits in the buffer. Yet, the keys should start on the next 4-byte +* aligned boundary. To avoid confusion, require that the rtattr +* payload be exactly the param struct, which has a 4-byte aligned size. +*/ +if (RTA_PAYLOAD (rta) !=sizeof (*param))return -EINVAL ; +BUILD_BUG_ON (sizeof (*param) %RTA_ALIGNTO ); param =RTA_DATA (rta); keys->enckeylen =be32_to_cpu (param->enckeylen); - key +=RTA_ALIGN (rta->rta_len); - keylen -=RTA_ALIGN (rta->rta_len); + key += rta->rta_len; + keylen -= rta->rta_len;if (keylen < keys->enckeylen)return -EINVAL ;
PATCH 29/202 Disable MSI also when pcie-octeon.pcie_disable on
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: YunQiang Su <[email protected]>
commit a214720cbf50cd8c3f76bbb9c3f5c283910e9d33 upstream.
Octeon has an boot-time option to disable pcie.
Since MSI depends on PCI-E, we should also disable MSI also with this option is on in order to avoid inadvertently accessing PCIe registers.
--- arch/mips/pci/msi-octeon.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/mips/pci/msi-octeon.c +3 -1
@@ -371,7 +371,9 @@ int __init octeon_msi_initialize(void)int irq;struct irq_chip *msi; -if (octeon_dma_bar_type ==OCTEON_DMA_BAR_TYPE_PCIE ) { +if (octeon_dma_bar_type ==OCTEON_DMA_BAR_TYPE_INVALID ) { +return 0 ; + }else if (octeon_dma_bar_type ==OCTEON_DMA_BAR_TYPE_PCIE ) { msi_rcv_reg[0 ] =CVMX_PEXP_NPEI_MSI_RCV0 ; msi_rcv_reg[1 ] =CVMX_PEXP_NPEI_MSI_RCV1 ; msi_rcv_reg[2 ] =CVMX_PEXP_NPEI_MSI_RCV2 ;
PATCH 30/202 i2c: dev: prevent adapter retries and timeout being set as minus value
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Yi Zeng <[email protected]>
commit 6ebec961d59bccf65d08b13fc1ad4e6272a89338 upstream.
If adapter->retries is set to a minus value from user space via ioctl, it will make __i2c_transfer and __i2c_smbus_xfer skip the calling to adapter->algo->master_xfer and adapter->algo->smbus_xfer that is registered by the underlying bus drivers, and return value 0 to all the callers. The bus driver will never be accessed anymore by all users, besides, the users may still get successful return value without any error or information log print out.
If adapter->timeout is set to minus value from user space via ioctl, it will make the retrying loop in __i2c_transfer and __i2c_smbus_xfer always break after the the first try, due to the time_after always returns true.
--- drivers/i2c/i2c-dev.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/i2c/i2c-dev.c +6 -0
@@ -467,9 +467,15 @@ static long i2cdev_ioctl(struct file *fireturn i2cdev_ioctl_smbus (client, arg);case I2C_RETRIES : +if (arg >INT_MAX ) +return -EINVAL ; + client->adapter->retries = arg;break ;case I2C_TIMEOUT : +if (arg >INT_MAX ) +return -EINVAL ; +/* For historical reasons, user-space sets the timeout * value in units of 10 ms. */
PATCH 31/202 CIFS: Do not hide EINTR after sending network packets
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Shilovsky <[email protected]>
commit ee13919c2e8d1f904e035ad4b4239029a8994131 upstream.
Currently we hide EINTR code returned from sock_sendmsg() and return 0 instead. This makes a caller think that we successfully completed the network operation which is not true. Fix this by properly returning EINTR to callers.
--- fs/cifs/transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/transport.c +1 -1
@@ -376,7 +376,7 @@ uncork:if (rc <0 && rc != -EINTR )cifs_dbg (VFS ,"Error %d sending data on socket to server\n" , rc); -else +else if (rc >0 ) rc =0 ;return rc;
PATCH 32/202 cifs: Fix potential OOB access of lock element array
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ross Lagerwall <[email protected]>
commit b9a74cde94957d82003fb9f7ab4777938ca851cd upstream.
If maxBuf is small but non-zero, it could result in a zero sized lock element array which we would then try and access OOB.
--- fs/cifs/file.c | 8 ++++---- fs/cifs/smb2file.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-)
fs/cifs/file.c +4 -4
@@ -1066,10 +1066,10 @@ cifs_push_mandatory_locks(struct cifsFil/* * Accessing maxBuf is racy with cifs_reconnect - need to store value -* and check it for zero before using. +* and check it before using. */ max_buf = tcon->ses->server->maxBuf; -if (!max_buf) { +if (max_buf < (sizeof (struct smb_hdr ) +sizeof (LOCKING_ANDX_RANGE ))) {free_xid (xid);return -EINVAL ; }
@@ -1403,10 +1403,10 @@ cifs_unlock_range(struct cifsFileInfo *c/* * Accessing maxBuf is racy with cifs_reconnect - need to store value -* and check it for zero before using. +* and check it before using. */ max_buf = tcon->ses->server->maxBuf; -if (!max_buf) +if (max_buf < (sizeof (struct smb_hdr ) +sizeof (LOCKING_ANDX_RANGE )))return -EINVAL ; max_num = (max_buf - sizeof(struct smb_hdr)) /
fs/cifs/smb2file.c +2 -2
@@ -101,10 +101,10 @@ smb2_unlock_range(struct cifsFileInfo *c/* * Accessing maxBuf is racy with cifs_reconnect - need to store value -* and check it for zero before using. +* and check it before using. */ max_buf = tcon->ses->server->maxBuf; -if (!max_buf) +if (max_buf <sizeof (struct smb2_lock_element ))return -EINVAL ; max_num = max_buf /sizeof (struct smb2_lock_element );
PATCH 33/202 omap2fb: Fix stack memory disclosure
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Vlad Tsyrklevich <[email protected]>
commit a01421e4484327fe44f8e126793ed5a48a221e24 upstream.
Using [1] for static analysis I found that the OMAPFB_QUERY_PLANE, OMAPFB_GET_COLOR_KEY, OMAPFB_GET_DISPLAY_INFO, and OMAPFB_GET_VRAM_INFO cases could all leak uninitialized stack memory--either due to uninitialized padding or 'reserved' fields.
Fix them by clearing the shared union used to store copied out data.
[1] https://github.com/vlad902/kernel-uninitialized-memory-checker
--- drivers/video/fbdev/omap2/omapfb/omapfb-ioctl.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/video/fbdev/omap2/omapfb/omapfb-ioctl.c +2 -0
@@ -606,6 +606,8 @@ int omapfb_ioctl(struct fb_info *fbi, unint r =0 ; +memset (&p,0 ,sizeof (p)); +switch (cmd) {case OMAPFB_SYNC_GFX :DBG ("ioctl SYNC_GFX\n" );
PATCH 34/202 s390/early: improve machine detection
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Christian Borntraeger <[email protected]>
commit 03aa047ef2db4985e444af6ee1c1dd084ad9fb4c upstream.
Right now the early machine detection code check stsi 3.2.2 for "KVM" and set MACHINE_IS_VM if this is different. As the console detection uses diagnose 8 if MACHINE_IS_VM returns true this will crash Linux early for any non z/VM system that sets a different value than KVM. So instead of assuming z/VM, do not set any of MACHINE_IS_LPAR, MACHINE_IS_VM, or MACHINE_IS_KVM.
--- arch/s390/kernel/early.c | 4 ++-- arch/s390/kernel/setup.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-)
arch/s390/kernel/early.c +2 -2
@@ -232,10 +232,10 @@ static noinline __init void detect_machiif (stsi (vmms,3 ,2 ,2 ) || !vmms->count)return ; -/* Running under KVM? If not we assume z/VM */ +/* Detect known hypervisors */ if (!memcmp (vmms->vm[0 ].cpi,"\xd2\xe5\xd4" ,3 )) S390_lowcore.machine_flags |=MACHINE_FLAG_KVM ; -else +else if (!memcmp (vmms->vm[0 ].cpi,"\xa9\x61\xe5\xd4" ,4 )) S390_lowcore.machine_flags |=MACHINE_FLAG_VM ; }
arch/s390/kernel/setup.c +2 -0
@@ -831,6 +831,8 @@ void __init setup_arch(char **cmdline_p)pr_info ("Linux is running under KVM in 64-bit mode\n" ); else if (MACHINE_IS_LPAR) pr_info("Linux is running natively in 64-bit mode\n"); + else + pr_info("Linux is running as a guest in 64-bit mode\n");#endif /* CONFIG_64BIT */ /* Have one command line that is parsed and saved in /proc/cmdline */
PATCH 35/202 s390/mm: always force a load of the primary ASCE on context switch
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Martin Schwidefsky <[email protected]>
commit a38662084c8bdb829ff486468c7ea801c13fcc34 upstream.
The ASCE of an mm_struct can be modified after a task has been created, e.g. via crst_table_downgrade for a compat process. The active_mm logic to avoid the switch_mm call if the next task is a kernel thread can lead to a situation where switch_mm is called where 'prev == next' is true but 'prev->context.asce == next->context.asce' is not.
This can lead to a situation where a CPU uses the outdated ASCE to run a task. The result can be a crash, endless loops and really subtle problem due to TLBs being created with an invalid ASCE.
[bwh: Backported to 3.16:
- Keep the updates of mm_context_t::attach_count conditional on prev != next
- Keep the update of mm_context_t::cpu_attach_mask conditional on both MACHINE_HAS_TLB_LC and prev != next
- Adjust context]
---
arch/s390/include/asm/mmu_context.h +6 -6
@@ -69,17 +69,17 @@ static inline void switch_mm(struct mm_s {int cpu =smp_processor_id (); -if (prev == next) -return ;if (MACHINE_HAS_TLB_LC )cpumask_set_cpu (cpu, &next->context.cpu_attach_mask);/* Clear old ASCE by loading the kernel ASCE. */ __ctl_load (S390_lowcore.kernel_asce,1 ,1 );__ctl_load (S390_lowcore.kernel_asce,7 ,7 ); -atomic_inc (&next->context.attach_count); -atomic_dec (&prev->context.attach_count); -if (MACHINE_HAS_TLB_LC ) -cpumask_clear_cpu (cpu, &prev->context.cpu_attach_mask); +if (prev != next) { +atomic_inc (&next->context.attach_count); +atomic_dec (&prev->context.attach_count); +if (MACHINE_HAS_TLB_LC ) +cpumask_clear_cpu (cpu, &prev->context.cpu_attach_mask); + } S390_lowcore.user_asce = next->context.asce_bits |__pa (next->pgd); }
PATCH 36/202 s390/smp: fix CPU hotplug deadlock with CPU rescan
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Gerald Schaefer <[email protected]>
commit b7cb707c373094ce4008d4a6ac9b6b366ec52da5 upstream.
smp_rescan_cpus() is called without the device_hotplug_lock, which can lead to a dedlock when a new CPU is found and immediately set online by a udev rule.
This was observed on an older kernel version, where the cpu_hotplug_begin() loop was still present, and it resulted in hanging chcpu and systemd-udev processes. This specific deadlock will not show on current kernels. However, there may be other possible deadlocks, and since smp_rescan_cpus() can still trigger a CPU hotplug operation, the device_hotplug_lock should be held.
For reference, this was the deadlock with the old cpu_hotplug_begin() loop:
chcpu (rescan) systemd-udevd
echo 1 > /sys/../rescan
-> smp_rescan_cpus()
-> (*) get_online_cpus()
(increases refcount)
-> smp_add_present_cpu()
(new CPU found)
-> register_cpu()
-> device_add()
-> udev "add" event triggered -----------> udev rule sets CPU online
-> echo 1 > /sys/.../online
-> lock_device_hotplug_sysfs()
(this is missing in rescan path)
-> device_online()
-> (**) device_lock(new CPU dev)
-> cpu_up()
-> cpu_hotplug_begin()
(loops until refcount == 0)
-> deadlock with (*)
-> bus_probe_device()
-> device_attach()
-> device_lock(new CPU dev)
-> deadlock with (**)Fix this by taking the device_hotplug_lock in the CPU rescan path.
--- arch/s390/kernel/smp.c | 4 ++++ drivers/s390/char/sclp_config.c | 2 ++ 2 files changed, 6 insertions(+)
arch/s390/kernel/smp.c +4 -0
@@ -1032,7 +1032,11 @@ static ssize_t __ref rescan_store(struct {int rc; + rc =lock_device_hotplug_sysfs (); +if (rc) +return rc; rc =smp_rescan_cpus (); +unlock_device_hotplug ();return rc ? rc : count; } static DEVICE_ATTR(rescan, 0200, NULL, rescan_store);
drivers/s390/char/sclp_config.c +2 -0
@@ -43,7 +43,9 @@ static void sclp_cpu_capability_notify(sstatic void __ref sclp_cpu_change_notify (struct work_struct *work) { +lock_device_hotplug ();smp_rescan_cpus (); +unlock_device_hotplug (); }static void sclp_conf_receiver_fn (struct evbuf_header *evbuf)
PATCH 37/202 x86/kaslr: Fix incorrect i8254 outb() parameters
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Drake <[email protected]>
commit 7e6fc2f50a3197d0e82d1c0e86282976c9e6c8a4 upstream.
The outb() function takes parameters value and port, in that order. Fix the parameters used in the kalsr i8254 fallback code.
--- arch/x86/boot/compressed/aslr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/boot/compressed/aslr.c +2 -2
@@ -25,8 +25,8 @@ static inline u16 i8254(void)u16 status, timer; do { - outb(I8254_PORT_CONTROL, - I8254_CMD_READBACK | I8254_SELECT_COUNTER0); + outb(I8254_CMD_READBACK | I8254_SELECT_COUNTER0, + I8254_PORT_CONTROL); status = inb(I8254_PORT_COUNTER0); timer = inb(I8254_PORT_COUNTER0); timer |= inb(I8254_PORT_COUNTER0) << 8;
PATCH 38/202 staging: rtl8188eu: Add device code for D-Link DWA-121 rev B1
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Michael Straube <[email protected]>
commit 5f74a8cbb38d10615ed46bc3e37d9a4c9af8045a upstream.
This device was added to the stand-alone driver on github. Add it to the staging driver as well.
--- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/rtl8188eu/os_dep/usb_intf.c +1 -0
@@ -59,6 +59,7 @@ static struct usb_device_id rtw_usb_id_t {USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */ {USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */ {USB_DEVICE(0x2001, 0x3311)}, /* DLink GO-USB-N150 REV B1 */ + {USB_DEVICE(0x2001, 0x331B)}, /* D-Link DWA-121 rev B1 */ {USB_DEVICE(0x2357, 0x010c)}, /* TP-Link TL-WN722N v2 */ {USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */ {USB_DEVICE(USB_VENDER_ID_REALTEK, 0xffef)}, /* Rosewill RNX-N150NUB */
PATCH 39/202 net/phy: micrel: Add workaround for bad autoneg
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Sullivan <[email protected]>
commit d2fd719bcb0e83cb39cfee22ee800f98a56eceb3 upstream.
Very rarely, the KSZ9031 will appear to complete autonegotiation, but will drop all traffic afterwards. When this happens, the idle error count will read 0xFF after autonegotiation completes. Reset the PHY when in that state.
[bwh: Backported to 3.16 as dependency of commit 1d16073a3268
"net: phy: micrel: set soft_reset callback to genphy_soft_reset for KSZ9031"]
--- drivers/net/phy/micrel.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
drivers/net/phy/micrel.c +22 -1
@@ -415,6 +415,27 @@ static int ksz8873mll_read_status(structreturn 0 ; } +static int ksz9031_read_status (struct phy_device *phydev) +{ +int err; +int regval; + + err =genphy_read_status (phydev); +if (err) +return err; + +/* Make sure the PHY is not broken. Read idle error count, +* and reset the PHY if it is maxed out. +*/ + regval =phy_read (phydev,MII_STAT1000 ); +if ((regval &0xFF ) ==0xFF ) { +phy_init_hw (phydev); + phydev->link =0 ; + } + +return 0 ; +} +static int ksz8873mll_config_aneg (struct phy_device *phydev) {return 0 ;
@@ -575,7 +596,7 @@ static struct phy_driver ksphy_driver[] .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, .config_init = ksz9031_config_init, .config_aneg = genphy_config_aneg, - .read_status = genphy_read_status, + .read_status = ksz9031_read_status, .ack_interrupt = kszphy_ack_interrupt, .config_intr = ksz9021_config_intr, .suspend = genphy_suspend,
PATCH 40/202 net/phy: micrel: configure intterupts after autoneg workaround
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Zach Brown <[email protected]>
commit b866203d872d5deeafcecd25ea429d6748b5bd56 upstream.
The commit ("net/phy: micrel: Add workaround for bad autoneg") fixes an autoneg failure case by resetting the hardware. This turns off intterupts. Things will work themselves out if the phy polls, as it will figure out it's state during a poll. However if the phy uses only intterupts, the phy will stall, since interrupts are off. This patch fixes the issue by calling config_intr after resetting the phy.
--- drivers/net/phy/micrel.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/phy/micrel.c +2 -0
@@ -431,6 +431,8 @@ static int ksz9031_read_status(struct phif ((regval &0xFF ) ==0xFF ) {phy_init_hw (phydev); phydev->link =0 ; +if (phydev->drv->config_intr &&phy_interrupt_is_valid (phydev)) + phydev->drv->config_intr (phydev); }return 0 ;
PATCH 41/202 net: phy: micrel: ksz9031: reconfigure autoneg after phy autoneg workaround
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Grygorii Strashko <[email protected]>
commit c1a8d0a3accf64a014d605e6806ce05d1c17adf1 upstream.
Under some circumstances driver will perform PHY reset in ksz9031_read_status() to fix autoneg failure case (idle error count = 0xFF). When this happens ksz9031 will not detect link status change any more when connecting to Netgear 1G switch (link can be recovered sometimes by restarting netdevice "ifconfig down up"). Reproduced with TI am572x board equipped with ksz9031 PHY while connecting to Netgear 1G switch.
Fix the issue by reconfiguring autonegotiation after PHY reset in ksz9031_read_status().
--- drivers/net/phy/micrel.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/phy/micrel.c +1 -0
@@ -433,6 +433,7 @@ static int ksz9031_read_status(struct ph phydev->link =0 ;if (phydev->drv->config_intr &&phy_interrupt_is_valid (phydev)) phydev->drv->config_intr (phydev); +return genphy_config_aneg (phydev); }return 0 ;
PATCH 42/202 net: phy: micrel: set soft_reset callback to genphy_soft_reset for KSZ9031
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Heiner Kallweit <[email protected]>
commit 1d16073a326891c2a964e4cb95bc18fbcafb5f74 upstream.
So far genphy_soft_reset was used automatically if the PHY driver didn't implement the soft_reset callback. This changed with the mentioned commit and broke KSZ9031. To fix this configure the KSZ9031 PHY driver to use genphy_soft_reset.
--- drivers/net/phy/micrel.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/phy/micrel.c +1 -0
@@ -596,6 +596,7 @@ static struct phy_driver ksphy_driver[] .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, .config_init = ksz9031_config_init, .config_aneg = genphy_config_aneg, + .soft_reset = genphy_soft_reset, .read_status = ksz9031_read_status, .ack_interrupt = kszphy_ack_interrupt, .config_intr = ksz9021_config_intr,
PATCH 43/202 fuse: handle zero sized retrieve correctly
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Miklos Szeredi <[email protected]>
commit 97e1532ef81acb31c30f9e75bf00306c33a77812 upstream.
Dereferencing req->page_descs[0] will Oops if req->max_pages is zero.
--- fs/fuse/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fuse/dev.c +1 -1
@@ -1652,7 +1652,6 @@ static int fuse_retrieve(struct fuse_con req->in.h.nodeid = outarg->nodeid; req->in.numargs =2 ; req->in.argpages =1 ; - req->page_descs[0 ].offset = offset; req->end = fuse_retrieve_end; index = outarg->offset >>PAGE_CACHE_SHIFT ;
@@ -1667,6 +1666,7 @@ static int fuse_retrieve(struct fuse_con this_num =min_t (unsigned, num,PAGE_CACHE_SIZE - offset); req->pages[req->num_pages] = page; + req->page_descs[req->num_pages].offset = offset; req->page_descs[req->num_pages].length = this_num; req->num_pages++;
PATCH 44/202 fuse: call pipe_buf_release() under pipe lock
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit 9509941e9c534920ccc4771ae70bd6cbbe79df1c upstream.
Some of the pipe_buf_release() handlers seem to assume that the pipe is locked - in particular, anon_pipe_buf_release() accesses pipe->tmp_page without taking any extra locks. From a glance through the callers of pipe_buf_release(), it looks like FUSE is the only one that calls pipe_buf_release() without having the pipe locked.
This bug should only lead to a memory leak, nothing terrible.
--- fs/fuse/dev.c | 2 ++ 1 file changed, 2 insertions(+)
fs/fuse/dev.c +2 -0
@@ -1978,10 +1978,12 @@ static ssize_t fuse_dev_splice_write(str ret =fuse_dev_do_write (fc, &cs, len); +pipe_lock (pipe);for (idx =0 ; idx < nbuf; idx++) {struct pipe_buffer *buf = &bufs[idx]; buf->ops->release (pipe, buf); } +pipe_unlock (pipe); out:kfree (bufs);return ret;
PATCH 45/202 fuse: decrement NR_WRITEBACK_TEMP on the right page
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Miklos Szeredi <[email protected]>
commit a2ebba824106dabe79937a9f29a875f837e1b6d4 upstream.
NR_WRITEBACK_TEMP is accounted on the temporary page in the request, not the page cache page.
--- fs/fuse/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fuse/file.c +1 -1
@@ -1846,7 +1846,7 @@ static bool fuse_writepage_in_flight(strspin_unlock (&fc->lock);dec_bdi_stat (bdi,BDI_WRITEBACK ); -dec_zone_page_state (page,NR_WRITEBACK_TEMP ); +dec_zone_page_state (new_req->pages[0 ],NR_WRITEBACK_TEMP );bdi_writeout_inc (bdi);fuse_writepage_free (fc, new_req);fuse_request_free (new_req);
PATCH 46/202 media: v4l: ioctl: Validate num_planes for debug messages
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sakari Ailus <[email protected]>
commit 7fe9f01c04c2673bd6662c35b664f0f91888b96f upstream.
The num_planes field in struct v4l2_pix_format_mplane is used in a loop before validating it. As the use is printing a debug message in this case, just cap the value to the maximum allowed.
--- drivers/media/v4l2-core/v4l2-ioctl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-ioctl.c +3 -1
@@ -247,6 +247,7 @@ static void v4l_print_format(const voidconst struct v4l2_sliced_vbi_format *sliced;const struct v4l2_window *win;const struct v4l2_sdr_format *sdr; +u32 planes;unsigned i;pr_cont ("type=%s" ,prt_names (p->type, v4l2_type_names));
@@ -279,7 +280,8 @@ static void v4l_print_format(const void (mp->pixelformat >>24 ) &0xff ,prt_names (mp->field, v4l2_field_names), mp->colorspace, mp->num_planes); -for (i =0 ; i < mp->num_planes; i++) + planes =min_t (u32, mp->num_planes,VIDEO_MAX_PLANES ); +for (i =0 ; i < planes; i++)printk (KERN_DEBUG "plane %u: bytesperline=%u sizeimage=%u\n" , i, mp->plane_fmt[i].bytesperline, mp->plane_fmt[i].sizeimage);
PATCH 47/202 Yama: Check for pid death before checking ancestry
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
commit 9474f4e7cd71a633fa1ef93b7daefd44bbdfd482 upstream.
It's possible that a pid has died before we take the rcu lock, in which case we can't walk the ancestry list as it may be detached. Instead, check for death first before doing the walk.
--- security/yama/yama_lsm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
security/yama/yama_lsm.c +3 -1
@@ -299,7 +299,9 @@ int yama_ptrace_access_check(struct taskbreak ;case YAMA_SCOPE_RELATIONAL :rcu_read_lock (); -if (!task_is_descendant (current, child) && +if (!pid_alive (child)) + rc = -EPERM ; +if (!rc && !task_is_descendant (current, child) && !ptracer_exception_found (current, child) && !ns_capable (__task_cred (child)->user_ns,CAP_SYS_PTRACE )) rc = -EPERM ;
PATCH 48/202 USB: serial: pl2303: add new PID to support PL2303TB
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Charles Yeh <[email protected]>
commit 4dcf9ddc9ad5ab649abafa98c5a4d54b1a33dabb upstream.
Add new PID to support PL2303TB (TYPE_HX)
--- drivers/usb/serial/pl2303.c | 1 + drivers/usb/serial/pl2303.h | 2 ++ 2 files changed, 3 insertions(+)
drivers/usb/serial/pl2303.c +1 -0
@@ -47,6 +47,7 @@ static const struct usb_device_id id_tab { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_HCR331) }, { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MOTOROLA) }, { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_ZTEK) }, + { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_TB) }, { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) }, { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) }, { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) },
drivers/usb/serial/pl2303.h +2 -0
@@ -13,6 +13,7 @@#define PL2303_VENDOR_ID 0x067b#define PL2303_PRODUCT_ID 0x2303 +#define PL2303_PRODUCT_ID_TB 0x2304#define PL2303_PRODUCT_ID_RSAQ2 0x04bb#define PL2303_PRODUCT_ID_DCU11 0x1234#define PL2303_PRODUCT_ID_PHAROS 0xaaa0
@@ -25,6 +26,7 @@#define PL2303_PRODUCT_ID_MOTOROLA 0x0307#define PL2303_PRODUCT_ID_ZTEK 0xe1f1 +#define ATEN_VENDOR_ID 0x0557#define ATEN_VENDOR_ID2 0x0547#define ATEN_PRODUCT_ID 0x2008
PATCH 49/202 arc: do not export symbols in troubleshoot.c
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Davidlohr Bueso <[email protected]>
commit be2a7fce397d82b7dc3fdbc61fb0bdab118e65ca upstream.
print_task_path_n_nm() is local to this file, its only user being show_regs(). Mark the function static and avoid the EXPORT_SYMBOL.
[bwh: Backported to 3.16 as dependency of commit ab6c03676cb1
"ARC: show_regs: lockdep: avoid page allocator..."]
--- arch/arc/kernel/troubleshoot.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arc/kernel/troubleshoot.c +1 -2
@@ -52,7 +52,7 @@ static void show_callee_regs(struct callprint_reg_file (&(cregs->r13),13 ); } -void print_task_path_n_nm (struct task_struct *tsk,char *buf) +static void print_task_path_n_nm (struct task_struct *tsk,char *buf) {struct path path;char *path_nm =NULL ;
@@ -77,7 +77,6 @@ void print_task_path_n_nm(struct task_st done:pr_info ("Path: %s\n" , path_nm); } -EXPORT_SYMBOL (print_task_path_n_nm);static void show_faulting_vma (unsigned long address,char *buf) {
PATCH 50/202 ARC: show_regs: lockdep: avoid page allocator...
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Vineet Gupta <[email protected]>
commit ab6c03676cb190156603cf4c5ecf97aa406c9c53 upstream.
and use smaller/on-stack buffer instead
The motivation for this change was lockdep splat like below.
| potentially unexpected fatal signal 11. | BUG: sleeping function called from invalid context at ../mm/page_alloc.c:4317 | in_atomic(): 1, irqs_disabled(): 0, pid: 57, name: segv | no locks held by segv/57. | Preemption disabled at: | [<8182f17e>] get_signal+0x4a6/0x7c4 | CPU: 0 PID: 57 Comm: segv Not tainted 4.17.0+ #23 | | Stack Trace: | arc_unwind_core.constprop.1+0xd0/0xf4 | __might_sleep+0x1f6/0x234 | __get_free_pages+0x174/0xca0 | show_regs+0x22/0x330 | get_signal+0x4ac/0x7c4 # print_fatal_signals() -> preempt_disable() | do_signal+0x30/0x224 | resume_user_mode_begin+0x90/0xd8
So signal handling core calls show_regs() with preemption disabled but an ensuing GFP_KERNEL page allocator call is flagged by lockdep.
We could have switched to GFP_NOWAIT, but turns out that is not enough anways and eliding page allocator call leads to less code and instruction traces to sift thru when debugging pesky crashes.
FWIW, this patch doesn't cure the lockdep splat (which next patch does).
--- arch/arc/kernel/troubleshoot.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
arch/arc/kernel/troubleshoot.c +12 -14
@@ -15,6 +15,8 @@#include <linux/file.h> #include <asm/arcregs.h> +#define ARC_PATH_MAX 256 +/* * Common routine to print scratch regs (r0-r12) or callee regs (r13-r25) * -Prints 3 regs per line and a CR.
@@ -52,12 +54,13 @@ static void show_callee_regs(struct callprint_reg_file (&(cregs->r13),13 ); } -static void print_task_path_n_nm (struct task_struct *tsk,char *buf) +static void print_task_path_n_nm (struct task_struct *tsk) {struct path path;char *path_nm =NULL ;struct mm_struct *mm;struct file *exe_file; +char buf[ARC_PATH_MAX ]; mm =get_task_mm (tsk);if (!mm)
@@ -70,7 +73,7 @@ static void print_task_path_n_nm(struct path = exe_file->f_path;path_get (&exe_file->f_path);fput (exe_file); - path_nm =d_path (&path, buf,255 ); + path_nm =d_path (&path, buf,ARC_PATH_MAX -1 );path_put (&path); }
@@ -78,13 +81,12 @@ done:pr_info ("Path: %s\n" , path_nm); } -static void show_faulting_vma (unsigned long address,char *buf) +static void show_faulting_vma (unsigned long address) {struct vm_area_struct *vma;struct inode *inode;unsigned long ino =0 ;dev_t dev =0 ; -char *nm = buf;struct mm_struct *active_mm = current->active_mm;/* can't use print_vma_addr() yet as it doesn't check for
@@ -98,9 +100,12 @@ static void show_faulting_vma(unsigned l*/ if (vma && (vma->vm_start <= address)) {struct file *file = vma->vm_file; +char buf[ARC_PATH_MAX ]; +char *nm ="?" ; +if (file) {struct path *path = &file->f_path; - nm =d_path (path, buf,PAGE_SIZE -1 ); + nm =d_path (path, buf,ARC_PATH_MAX -1 ); inode =file_inode (vma->vm_file); dev = inode->i_sb->s_dev; ino = inode->i_ino;
@@ -165,13 +170,8 @@ void show_regs(struct pt_regs *regs) {struct task_struct *tsk = current;struct callee_regs *cregs; -char *buf; - buf = (char *)__get_free_page (GFP_TEMPORARY ); -if (!buf) -return ; - -print_task_path_n_nm (tsk, buf); +print_task_path_n_nm (tsk);show_regs_print_info (KERN_INFO );show_ecr_verbose (regs);
@@ -181,7 +181,7 @@ void show_regs(struct pt_regs *regs) (void *)regs->blink, (void *)regs->ret);if (user_mode (regs)) -show_faulting_vma (regs->ret, buf);/* faulting code, not data */ +show_faulting_vma (regs->ret);/* faulting code, not data */ pr_info ("[STAT32]: 0x%08lx" , regs->status32);
@@ -205,8 +205,6 @@ void show_regs(struct pt_regs *regs) cregs = (struct callee_regs *)current->thread.callee_reg;if (cregs)show_callee_regs (cregs); - -free_page ((unsigned long )buf); } void show_kernel_fault_diag(const char *str, struct pt_regs *regs,
PATCH 51/202 ARC: mm: do_page_fault fixes #1: relinquish mmap_sem if signal arrives while handle_mm_fault
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Vineet Gupta <[email protected]>
commit 4d447455e73b47c43dd35fcc38ed823d3182a474 upstream.
do_page_fault() forgot to relinquish mmap_sem if a signal came while handling handle_mm_fault() - due to say a ctl+c or oom etc. This would later cause a deadlock by acquiring it twice.
This came to light when running libc testsuite tst-tls3-malloc test but is likely also the cause for prior seen LTP failures. Using lockdep clearly showed what the issue was.
| # while true; do ./tst-tls3-malloc ; done
| Didn't expect signal from child: got `Segmentation fault'
| ^C
| ============================================
| WARNING: possible recursive locking detected
| 4.17.0+ #25 Not tainted
| --------------------------------------------
| tst-tls3-malloc/510 is trying to acquire lock:
| 606c7728 (&mm->mmap_sem){++++}, at: __might_fault+0x28/0x5c
|
|but task is already holding lock:
|606c7728 (&mm->mmap_sem){++++}, at: do_page_fault+0x9c/0x2a0
|
| other info that might help us debug this:
| Possible unsafe locking scenario:
|
| CPU0
| ----
| lock(&mm->mmap_sem);
| lock(&mm->mmap_sem);
|
| *** DEADLOCK ***
|------------------------------------------------------------
What the change does is not obvious (note to myself)
prior code was
| do_page_fault | | down_read() <-- lock taken | handle_mm_fault <-- signal pending as this runs | if fatal_signal_pending | if VM_FAULT_ERROR | up_read | if user_mode | return <-- lock still held, this was the BUG
New code
| do_page_fault | | down_read() <-- lock taken | handle_mm_fault <-- signal pending as this runs | if fatal_signal_pending | if VM_FAULT_RETRY | return <-- not same case as above, but still OK since | core mm already relinq lock for FAULT_RETRY | ... | | < Now falls through for bug case above > | | up_read() <-- lock relinquished
--- arch/arc/mm/fault.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
arch/arc/mm/fault.c +9 -4
@@ -131,12 +131,17 @@ good_area:*/ fault =handle_mm_fault (mm, vma, address, flags); -/* If Pagefault was interrupted by SIGKILL, exit page fault "early" */ if (unlikely (fatal_signal_pending (current))) { -if ((fault &VM_FAULT_ERROR ) && !(fault &VM_FAULT_RETRY )) -up_read (&mm->mmap_sem); -if (user_mode (regs)) + +/* +* if fault retry, mmap_sem already relinquished by core mm +* so OK to return to user mode (with signal handled first) +*/ +if (fault &VM_FAULT_RETRY ) { +if (!user_mode (regs)) + goto no_context;return ; + } }if (likely (!(fault &VM_FAULT_ERROR ))) {
PATCH 52/202 net: bridge: Fix ethernet header pointer before check skb forwardable
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Yunjian Wang <[email protected]>
commit 28c1382fa28f2e2d9d0d6f25ae879b5af2ecbd03 upstream.
The skb header should be set to ethernet header before using is_skb_forwardable. Because the ethernet header length has been considered in is_skb_forwardable(including dev->hard_header_len length).
To reproduce the issue:
1, add 2 ports on linux bridge br using following commands:
$ brctl addbr br $ brctl addif br eth0 $ brctl addif br eth1 2, the MTU of eth0 and eth1 is 1500 3, send a packet(Data 1480, UDP 8, IP 20, Ethernet 14, VLAN 4) from eth0 to eth1
So the expect result is packet larger than 1500 cannot pass through eth0 and eth1. But currently, the packet passes through success, it means eth1's MTU limit doesn't take effect.
[bwh: Backported to 3.16:
- br_dev_queue_push_xmit() has to call nf_bridge_maybe_copy_header() before pushing the Ethernet header
- adjust context, indentation]
---
net/bridge/br_forward.c +15 -11
@@ -38,16 +38,21 @@ static inline int should_deliver(const sint br_dev_queue_push_xmit (struct sk_buff *skb) {/* ip_fragment doesn't copy the MAC header */ -if (nf_bridge_maybe_copy_header (skb) || - !is_skb_forwardable (skb->dev, skb)) { -kfree_skb (skb); - }else { -skb_push (skb,ETH_HLEN ); -br_drop_fake_rtable (skb); -dev_queue_xmit (skb); - } +if (nf_bridge_maybe_copy_header (skb)) + goto drop; + +skb_push (skb,ETH_HLEN ); +if (!is_skb_forwardable (skb->dev, skb)) + goto drop; + +br_drop_fake_rtable (skb); +dev_queue_xmit (skb);return 0 ; + +drop: +kfree_skb (skb); +return 0 ; }int br_forward_finish (struct sk_buff *skb)
@@ -66,12 +71,11 @@ static void __br_deliver(const struct ne skb->dev = to->dev;if (unlikely (netpoll_tx_running (to->br->dev))) { +skb_push (skb,ETH_HLEN );if (!is_skb_forwardable (skb->dev, skb))kfree_skb (skb); -else { -skb_push (skb,ETH_HLEN ); +else br_netpoll_send_skb (to, skb); - }return ; }
PATCH 53/202 uart: Fix crash in uart_write and uart_put_char
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Samir Virmani <[email protected]>
commit aff9cf5955185d1f183227e46c5f8673fa483813 upstream.
We were experiencing a crash similar to the one reported as part of commit:a5ba1d95e46e ("uart: fix race between uart_put_char() and uart_shutdown()") in our testbed as well. We continue to observe the same crash after integrating the commit a5ba1d95e46e ("uart: fix race between uart_put_char() and uart_shutdown()")
On reviewing the change, the port lock should be taken prior to checking for if (!circ->buf) in fn. __uart_put_char and other fns. that update the buffer uart_state->xmit.
Traceback:
[11/27/2018 06:24:32.4870] Unable to handle kernel NULL pointer dereference
at virtual address 0000003b
[11/27/2018 06:24:32.4950] PC is at memcpy+0x48/0x180 [11/27/2018 06:24:32.4950] LR is at uart_write+0x74/0x120 [11/27/2018 06:24:32.4950] pc : [<ffffffc0002e6808>]
lr : [<ffffffc0003747cc>] pstate: 000001c5
[11/27/2018 06:24:32.4950] sp : ffffffc076433d30 [11/27/2018 06:24:32.4950] x29: ffffffc076433d30 x28: 0000000000000140 [11/27/2018 06:24:32.4950] x27: ffffffc0009b9d5e x26: ffffffc07ce36580 [11/27/2018 06:24:32.4950] x25: 0000000000000000 x24: 0000000000000140 [11/27/2018 06:24:32.4950] x23: ffffffc000891200 x22: ffffffc01fc34000 [11/27/2018 06:24:32.4950] x21: 0000000000000fff x20: 0000000000000076 [11/27/2018 06:24:32.4950] x19: 0000000000000076 x18: 0000000000000000 [11/27/2018 06:24:32.4950] x17: 000000000047cf08 x16: ffffffc000099e68 [11/27/2018 06:24:32.4950] x15: 0000000000000018 x14: 776d726966205948 [11/27/2018 06:24:32.4950] x13: 50203a6c6974755f x12: 74647075205d3333 [11/27/2018 06:24:32.4950] x11: 3a35323a36203831 x10: 30322f37322f3131 [11/27/2018 06:24:32.4950] x9 : 5b205d303638342e x8 : 746164206f742070 [11/27/2018 06:24:32.4950] x7 : 7520736920657261 x6 : 000000000000003b [11/27/2018 06:24:32.4950] x5 : 000000000000817a x4 : 0000000000000008 [11/27/2018 06:24:32.4950] x3 : 2f37322f31312a5b x2 : 000000000000006e [11/27/2018 06:24:32.4950] x1 : ffffffc0009b9cf0 x0 : 000000000000003b
[11/27/2018 06:24:32.4950] CPU2: stopping
[11/27/2018 06:24:32.4950] CPU: 2 PID: 0 Comm: swapper/2 Tainted: P D O 4.1.51 #3
[11/27/2018 06:24:32.4950] Hardware name: Broadcom-v8A (DT) [11/27/2018 06:24:32.4950] Call trace:
[11/27/2018 06:24:32.4950] [<ffffffc0000883b8>] dump_backtrace+0x0/0x150 [11/27/2018 06:24:32.4950] [<ffffffc00008851c>] show_stack+0x14/0x20 [11/27/2018 06:24:32.4950] [<ffffffc0005ee810>] dump_stack+0x90/0xb0 [11/27/2018 06:24:32.4950] [<ffffffc00008e844>] handle_IPI+0x18c/0x1a0 [11/27/2018 06:24:32.4950] [<ffffffc000080c68>] gic_handle_irq+0x88/0x90
[bwh: Backported to 3.16:
- Keep open-coding uart_port_lock()
- Adjust context]
--- drivers/tty/serial/serial_core.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/tty/serial/serial_core.c +8 -4
@@ -480,10 +480,12 @@ static inline int __uart_put_char(structunsigned long flags;int ret =0 ; -if (!circ->buf) +spin_lock_irqsave (&port->lock, flags); +if (!circ->buf) { +spin_unlock_irqrestore (&port->lock, flags);return 0 ; + } -spin_lock_irqsave (&port->lock, flags);if (uart_circ_chars_free (circ) !=0 ) { circ->buf[circ->head] = c; circ->head = (circ->head +1 ) & (UART_XMIT_SIZE -1 );
@@ -524,12 +526,14 @@ static int uart_write(struct tty_struct } port = state->uart_port; +spin_lock_irqsave (&port->lock, flags); circ = &state->xmit; -if (!circ->buf) +if (!circ->buf) { +spin_unlock_irqrestore (&port->lock, flags);return 0 ; + } -spin_lock_irqsave (&port->lock, flags);while (1 ) { c =CIRC_SPACE_TO_END (circ->head, circ->tail,UART_XMIT_SIZE );if (count < c)
PATCH 54/202 tty/n_hdlc: fix __might_sleep warning
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paul Fulghum <[email protected]>
commit fc01d8c61ce02c034e67378cd3e645734bc18c8c upstream.
Fix __might_sleep warning[1] in tty/n_hdlc.c read due to copy_to_user call while current is TASK_INTERRUPTIBLE. This is a false positive since the code path does not depend on current state remaining TASK_INTERRUPTIBLE. The loop breaks out and sets TASK_RUNNING after calling copy_to_user.
This patch supresses the warning by setting TASK_RUNNING before calling copy_to_user.
[1] https://syzkaller.appspot.com/bug?id=17d5de7f1fcab794cb8c40032f893f52de899324
--- drivers/tty/n_hdlc.c | 1 + 1 file changed, 1 insertion(+)
drivers/tty/n_hdlc.c +1 -0
@@ -598,6 +598,7 @@ static ssize_t n_hdlc_tty_read(struct tt/* too large for caller's buffer */ ret = -EOVERFLOW ; }else { +__set_current_state (TASK_RUNNING );if (copy_to_user (buf, rbuf->buf, rbuf->count)) ret = -EFAULT ;else
PATCH 55/202 vt: always call notifier with the console lock held
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Pitre <[email protected]>
commit 7e1d226345f89ad5d0216a9092c81386c89b4983 upstream.
Every invocation of notify_write() and notify_update() is performed under the console lock, except for one case. Let's fix that.
--- drivers/tty/vt/vt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/vt/vt.c +1 -1
@@ -2415,8 +2415,8 @@ rescan_last_byte: }FLUSH console_conditional_schedule (); -console_unlock ();notify_update (vc); +console_unlock ();return n;#undef FLUSH }
PATCH 56/202 vt: invoke notifier on screen size change
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Pitre <[email protected]>
commit 0c9b1965faddad7534b6974b5b36c4ad37998f8e upstream.
User space using poll() on /dev/vcs devices are not awaken when a screen size change occurs. Let's fix that.
--- drivers/tty/vt/vt.c | 1 + 1 file changed, 1 insertion(+)
drivers/tty/vt/vt.c +1 -0
@@ -953,6 +953,7 @@ static int vc_do_resize(struct tty_strucif (CON_IS_VISIBLE (vc))update_screen (vc);vt_event_post (VT_EVENT_RESIZE , vc->vc_num, vc->vc_num); +notify_update (vc);return err; }
PATCH 57/202 char/mwave: fix potential Spectre v1 vulnerability
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Gustavo A. R. Silva" <[email protected]>
commit 701956d4018e5d5438570e39e8bda47edd32c489 upstream.
ipcnum is indirectly controlled by user-space, hence leading to a potential exploitation of the Spectre variant 1 vulnerability.
This issue was detected with the help of Smatch:
drivers/char/mwave/mwavedd.c:299 mwave_ioctl() warn: potential spectre issue 'pDrvData->IPCs' [w] (local cap)
Fix this by sanitizing ipcnum before using it to index pDrvData->IPCs.
Notice that given that speculation windows are large, the policy is to kill the speculation on the first load and not worry if it can be completed with a dependent load/store [1].
[1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2
--- drivers/char/mwave/mwavedd.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/char/mwave/mwavedd.c +7 -0
@@ -59,6 +59,7 @@#include <linux/mutex.h> #include <linux/delay.h> #include <linux/serial_8250.h> +#include <linux/nospec.h> #include "smapi.h" #include "mwavedd.h" #include "3780i.h"
@@ -289,6 +290,8 @@ static long mwave_ioctl(struct file *fil ipcnum);return -EINVAL ; } + ipcnum =array_index_nospec (ipcnum, +ARRAY_SIZE (pDrvData->IPCs)); PRINTK_3(TRACE_MWAVE, "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC" " ipcnum %x entry usIntCount %x\n",
@@ -317,6 +320,8 @@ static long mwave_ioctl(struct file *fil " Invalid ipcnum %x\n", ipcnum);return -EINVAL ; } + ipcnum =array_index_nospec (ipcnum, +ARRAY_SIZE (pDrvData->IPCs)); PRINTK_3(TRACE_MWAVE, "mwavedd::mwave_ioctl IOCTL_MW_GET_IPC" " ipcnum %x, usIntCount %x\n",
@@ -383,6 +388,8 @@ static long mwave_ioctl(struct file *fil ipcnum);return -EINVAL ; } + ipcnum =array_index_nospec (ipcnum, +ARRAY_SIZE (pDrvData->IPCs));mutex_lock (&mwave_mutex);if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { pDrvData->IPCs[ipcnum].bIsEnabled = FALSE;
PATCH 58/202 tty: Handle problem if line discipline does not have receive_buf
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit 27cfb3a53be46a54ec5e0bd04e51995b74c90343 upstream.
Some tty line disciplines do not have a receive buf callback, so properly check for that before calling it. If they do not have this callback, just eat the character quietly, as we can't fail this call.
--- drivers/tty/tty_io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/tty/tty_io.c +2 -1
@@ -2219,7 +2219,8 @@ static int tiocsti(struct tty_struct *ttreturn -EFAULT ;tty_audit_tiocsti (tty, ch); ld =tty_ldisc_ref_wait (tty); - ld->ops->receive_buf (tty, &ch, &mbz,1 ); +if (ld->ops->receive_buf) + ld->ops->receive_buf (tty, &ch, &mbz,1 );tty_ldisc_deref (ld);return 0 ; }
PATCH 59/202 can: dev: __can_get_echo_skb(): fix bogous check for non-existing skb by removing it
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Manfred Schlaegl <[email protected]>
commit 7b12c8189a3dc50638e7d53714c88007268d47ef upstream.
This patch revert commit 7da11ba5c506
("can: dev: __can_get_echo_skb(): print error message, if trying to echo non existing skb")
After introduction of this change we encountered following new error message on various i.MX plattforms (flexcan):
| flexcan 53fc8000.can can0: __can_get_echo_skb: BUG! Trying to echo non | existing skb: can_priv::echo_skb[0]
The introduction of the message was a mistake because priv->echo_skb[idx] = NULL is a perfectly valid in following case: If CAN_RAW_LOOPBACK is disabled (setsockopt) in applications, the pkt_type of the tx skb's given to can_put_echo_skb is set to PACKET_LOOPBACK. In this case can_put_echo_skb will not set priv->echo_skb[idx]. It is therefore kept NULL.
As additional argument for revert: The order of check and usage of idx was changed. idx is used to access an array element before checking it's boundaries.
--- drivers/net/can/dev.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)
drivers/net/can/dev.c +13 -14
@@ -425,8 +425,6 @@ EXPORT_SYMBOL_GPL(can_put_echo_skb);struct sk_buff *__can_get_echo_skb (struct net_device *dev,unsigned int idx,u8 *len_ptr) {struct can_priv *priv =netdev_priv (dev); -struct sk_buff *skb = priv->echo_skb[idx]; -struct canfd_frame *cf;if (idx >= priv->echo_skb_max) { netdev_err(dev, "%s: BUG! Trying to access can_priv::echo_skb out of bounds (%u/max %u)\n",
@@ -434,20 +432,21 @@ struct sk_buff *__can_get_echo_skb(strucreturn NULL ; } -if (!skb) { -netdev_err (dev,"%s: BUG! Trying to echo non existing skb: can_priv::echo_skb[%u]\n" , - __func__, idx); -return NULL ; - } +if (priv->echo_skb[idx]) { +/* Using "struct canfd_frame::len" for the frame +* length is supported on both CAN and CANFD frames. +*/ +struct sk_buff *skb = priv->echo_skb[idx]; +struct canfd_frame *cf = (struct canfd_frame *)skb->data; +u8 len = cf->len; -/* Using "struct canfd_frame::len" for the frame -* length is supported on both CAN and CANFD frames. -*/ - cf = (struct canfd_frame *)skb->data; - *len_ptr = cf->len; - priv->echo_skb[idx] =NULL ; + *len_ptr = len; + priv->echo_skb[idx] =NULL ; + +return skb; + } -return skb; +return NULL ; }/*
PATCH 60/202 can: bcm: check timer values before ktime conversion
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Hartkopp <[email protected]>
commit 93171ba6f1deffd82f381d36cb13177872d023f6 upstream.
Kyungtae Kim detected a potential integer overflow in bcm_[rx|tx]_setup() when the conversion into ktime multiplies the given value with NSEC_PER_USEC (1000).
Reference: https://marc.info/?l=linux-can&m=154732118819828&w=2
Add a check for the given tv_usec, so that the value stays below one second. Additionally limit the tv_sec value to a reasonable value for CAN related use-cases of 400 days and ensure all values to be positive.
--- net/can/bcm.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
net/can/bcm.c +27 -0
@@ -67,6 +67,9 @@*/ #define MAX_NFRAMES 256 +/* limit timers to 400 days for sending/timeouts */ +#define BCM_TIMER_SEC_MAX (400 * 24 * 60 * 60) +/* use of last_frames[index].can_dlc */ #define RX_RECV 0x40/* received data for this element */ #define RX_THR 0x80/* element not been sent due to throttle feature */
@@ -133,6 +136,22 @@ static inline struct bcm_sock *bcm_sk(coreturn (struct bcm_sock *)sk; } +/* check limitations for timeval provided by user */ +static bool bcm_is_invalid_tv (struct bcm_msg_head *msg_head) +{ +if ((msg_head->ival1.tv_sec <0 ) || + (msg_head->ival1.tv_sec >BCM_TIMER_SEC_MAX ) || + (msg_head->ival1.tv_usec <0 ) || + (msg_head->ival1.tv_usec >=USEC_PER_SEC ) || + (msg_head->ival2.tv_sec <0 ) || + (msg_head->ival2.tv_sec >BCM_TIMER_SEC_MAX ) || + (msg_head->ival2.tv_usec <0 ) || + (msg_head->ival2.tv_usec >=USEC_PER_SEC )) +return true; + +return false; +} +#define CFSIZ sizeof(struct can_frame)#define OPSIZ sizeof(struct bcm_op)#define MHSIZ sizeof(struct bcm_msg_head)
@@ -851,6 +870,10 @@ static int bcm_tx_setup(struct bcm_msg_hif (msg_head->nframes <1 || msg_head->nframes >MAX_NFRAMES )return -EINVAL ; +/* check timeval limitations */ +if ((msg_head->flags &SETTIMER ) &&bcm_is_invalid_tv (msg_head)) +return -EINVAL ; +/* check the given can_id */ op =bcm_find_op (&bo->tx_ops, msg_head->can_id, ifindex);
@@ -1018,6 +1041,10 @@ static int bcm_rx_setup(struct bcm_msg_h (!(msg_head->can_id & CAN_RTR_FLAG))))return -EINVAL ; +/* check timeval limitations */ +if ((msg_head->flags &SETTIMER ) &&bcm_is_invalid_tv (msg_head)) +return -EINVAL ; +/* check the given can_id */ op =bcm_find_op (&bo->rx_ops, msg_head->can_id, ifindex);if (op) {
PATCH 61/202 ipmi: msghandler: Fix potential Spectre v1 vulnerabilities
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Gustavo A. R. Silva" <[email protected]>
commit a7102c7461794a5bb31af24b08e9e0f50038897a upstream.
channel and addr->channel are indirectly controlled by user-space, hence leading to a potential exploitation of the Spectre variant 1 vulnerability.
These issues were detected with the help of Smatch:
drivers/char/ipmi/ipmi_msghandler.c:1381 ipmi_set_my_address() warn: potential spectre issue 'user->intf->addrinfo' [w] (local cap) drivers/char/ipmi/ipmi_msghandler.c:1401 ipmi_get_my_address() warn: potential spectre issue 'user->intf->addrinfo' [r] (local cap) drivers/char/ipmi/ipmi_msghandler.c:1421 ipmi_set_my_LUN() warn: potential spectre issue 'user->intf->addrinfo' [w] (local cap) drivers/char/ipmi/ipmi_msghandler.c:1441 ipmi_get_my_LUN() warn: potential spectre issue 'user->intf->addrinfo' [r] (local cap) drivers/char/ipmi/ipmi_msghandler.c:2260 check_addr() warn: potential spectre issue 'intf->addrinfo' [r] (local cap)
Fix this by sanitizing channel and addr->channel before using them to index user->intf->addrinfo and intf->addrinfo, correspondingly.
Notice that given that speculation windows are large, the policy is to kill the speculation on the first load and not worry if it can be completed with a dependent load/store [1].
[1] https://lore.kernel.org/lkml/[email protected]/
---
drivers/char/ipmi/ipmi_msghandler.c +6 -0
@@ -46,6 +46,7 @@#include <linux/proc_fs.h> #include <linux/rcupdate.h> #include <linux/interrupt.h> +#include <linux/nospec.h> #define PFX "IPMI message handler: "
@@ -1116,6 +1117,7 @@ int ipmi_set_my_address(ipmi_user_t us {if (channel >=IPMI_MAX_CHANNELS )return -EINVAL ; + channel =array_index_nospec (channel,IPMI_MAX_CHANNELS ); user->intf->channels[channel].address = address;return 0 ; }
@@ -1127,6 +1129,7 @@ int ipmi_get_my_address(ipmi_user_t us {if (channel >=IPMI_MAX_CHANNELS )return -EINVAL ; + channel =array_index_nospec (channel,IPMI_MAX_CHANNELS ); *address = user->intf->channels[channel].address;return 0 ; }
@@ -1138,6 +1141,7 @@ int ipmi_set_my_LUN(ipmi_user_t user, {if (channel >=IPMI_MAX_CHANNELS )return -EINVAL ; + channel =array_index_nospec (channel,IPMI_MAX_CHANNELS ); user->intf->channels[channel].lun =LUN &0x3 ;return 0 ; }
@@ -1149,6 +1153,7 @@ int ipmi_get_my_LUN(ipmi_user_t user, {if (channel >=IPMI_MAX_CHANNELS )return -EINVAL ; + channel =array_index_nospec (channel,IPMI_MAX_CHANNELS ); *address = user->intf->channels[channel].lun;return 0 ; }
@@ -1875,6 +1880,7 @@ static int check_addr(ipmi_smi_t i {if (addr->channel >=IPMI_MAX_CHANNELS )return -EINVAL ; + addr->channel =array_index_nospec (addr->channel,IPMI_MAX_CHANNELS ); *lun = intf->channels[addr->channel].lun; *saddr = intf->channels[addr->channel].address;return 0 ;
PATCH 62/202 ARM: pxa: ssp: unneeded to free devm_ allocated data
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Peng Hao <[email protected]>
commit ba16adeb346387eb2d1ada69003588be96f098fa upstream.
devm_ allocated data will be automatically freed. The free of devm_ allocated data is invalid.
--- arch/arm/plat-pxa/ssp.c | 3 --- 1 file changed, 3 deletions(-)
arch/arm/plat-pxa/ssp.c +0 -3
@@ -239,8 +239,6 @@ static int pxa_ssp_remove(struct platforif (ssp ==NULL )return -ENODEV ; -iounmap (ssp->mmio_base); - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );release_mem_region (res->start,resource_size (res));
@@ -250,7 +248,6 @@ static int pxa_ssp_remove(struct platforlist_del (&ssp->node);mutex_unlock (&ssp_lock); -kfree (ssp);return 0 ; }
PATCH 63/202 drm/modes: Prevent division by zero htotal
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Tina Zhang <[email protected]>
commit a2fcd5c84f7a7825e028381b10182439067aa90d upstream.
This patch prevents division by zero htotal.
Quoted 62 lines · In a follow-up mail Tina
Quoted 3 lines
How did you manage to get here with htotal == 0? This needs backtraces (or if this is just about static checkers, a mention of that).
-DanielIn GVT-g, we are trying to enable a virtual display w/o setting timings for a pipe (a.k.a htotal=0), then we met the following kernel panic:
[ 32.832048] divide error: 0000 [#1] SMP PTI [ 32.833614] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.18.0-rc4-sriov+ #33 [ 32.834438] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.10.1-0-g8891697-dirty-20180511_165818-tinazhang-linux-1 04/01/2014 [ 32.835901] RIP: 0010:drm_mode_hsync+0x1e/0x40 [ 32.836004] Code: 31 c0 c3 90 90 90 90 90 90 90 90 90 0f 1f 44 00 00 8b 87 d8 00 00 00 85 c0 75 22 8b 4f 68 85 c9 78 1b 69 47 58 e8 03 00 00 99 <f7> f9 b9 d3 4d 62 10 05 f4 01 00 00 f7 e1 89 d0 c1 e8 06 f3 c3 66 [ 32.836004] RSP: 0000:ffffc900000ebb90 EFLAGS: 00010206 [ 32.836004] RAX: 0000000000000000 RBX: ffff88001c67c8a0 RCX: 0000000000000000 [ 32.836004] RDX: 0000000000000000 RSI: ffff88001c67c000 RDI: ffff88001c67c8a0 [ 32.836004] RBP: ffff88001c7d03a0 R08: ffff88001c67c8a0 R09: ffff88001c7d0330 [ 32.836004] R10: ffffffff822c3a98 R11: 0000000000000001 R12: ffff88001c67c000 [ 32.836004] R13: ffff88001c7d0370 R14: ffffffff8207eb78 R15: ffff88001c67c800 [ 32.836004] FS: 0000000000000000(0000) GS:ffff88001da00000(0000) knlGS:0000000000000000 [ 32.836004] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 32.836004] CR2: 0000000000000000 CR3: 000000000220a000 CR4: 00000000000006f0 [ 32.836004] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 32.836004] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 32.836004] Call Trace: [ 32.836004] intel_mode_from_pipe_config+0x72/0x90 [ 32.836004] intel_modeset_setup_hw_state+0x569/0xf90 [ 32.836004] intel_modeset_init+0x905/0x1db0 [ 32.836004] i915_driver_load+0xb8c/0x1120 [ 32.836004] i915_pci_probe+0x4d/0xb0 [ 32.836004] local_pci_probe+0x44/0xa0 [ 32.836004] ? pci_assign_irq+0x27/0x130 [ 32.836004] pci_device_probe+0x102/0x1c0 [ 32.836004] driver_probe_device+0x2b8/0x480 [ 32.836004] __driver_attach+0x109/0x110 [ 32.836004] ? driver_probe_device+0x480/0x480 [ 32.836004] bus_for_each_dev+0x67/0xc0 [ 32.836004] ? klist_add_tail+0x3b/0x70 [ 32.836004] bus_add_driver+0x1e8/0x260 [ 32.836004] driver_register+0x5b/0xe0 [ 32.836004] ? mipi_dsi_bus_init+0x11/0x11 [ 32.836004] do_one_initcall+0x4d/0x1eb [ 32.836004] kernel_init_freeable+0x197/0x237 [ 32.836004] ? rest_init+0xd0/0xd0 [ 32.836004] kernel_init+0xa/0x110 [ 32.836004] ret_from_fork+0x35/0x40 [ 32.836004] Modules linked in: [ 32.859183] ---[ end trace 525608b0ed0e8665 ]--- [ 32.859722] RIP: 0010:drm_mode_hsync+0x1e/0x40 [ 32.860287] Code: 31 c0 c3 90 90 90 90 90 90 90 90 90 0f 1f 44 00 00 8b 87 d8 00 00 00 85 c0 75 22 8b 4f 68 85 c9 78 1b 69 47 58 e8 03 00 00 99 <f7> f9 b9 d3 4d 62 10 05 f4 01 00 00 f7 e1 89 d0 c1 e8 06 f3 c3 66 [ 32.862680] RSP: 0000:ffffc900000ebb90 EFLAGS: 00010206 [ 32.863309] RAX: 0000000000000000 RBX: ffff88001c67c8a0 RCX: 0000000000000000 [ 32.864182] RDX: 0000000000000000 RSI: ffff88001c67c000 RDI: ffff88001c67c8a0 [ 32.865206] RBP: ffff88001c7d03a0 R08: ffff88001c67c8a0 R09: ffff88001c7d0330 [ 32.866359] R10: ffffffff822c3a98 R11: 0000000000000001 R12: ffff88001c67c000 [ 32.867213] R13: ffff88001c7d0370 R14: ffffffff8207eb78 R15: ffff88001c67c800 [ 32.868075] FS: 0000000000000000(0000) GS:ffff88001da00000(0000) knlGS:0000000000000000 [ 32.868983] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 32.869659] CR2: 0000000000000000 CR3: 000000000220a000 CR4: 00000000000006f0 [ 32.870599] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 32.871598] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 32.872549] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
Quoted 1 line
Since
drm_mode_hsync()has the logic to checkmode->htotal, I just extend it to cover the case htotal==0.
--- drivers/gpu/drm/drm_modes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_modes.c +1 -1
@@ -682,7 +682,7 @@ int drm_mode_hsync(const struct drm_dispif (mode->hsync)return mode->hsync; -if (mode->htotal <0 ) +if (mode->htotal <=0 )return 0 ; calc_val = (mode->clock *1000 ) / mode->htotal;/* hsync in Hz */
PATCH 64/202 iommu/amd: Fix IOMMU page flush when detach device from a domain
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Suravee Suthikulpanit <[email protected]>
commit 9825bd94e3a2baae1f4874767ae3a7d4c049720e upstream.
When a VM is terminated, the VFIO driver detaches all pass-through devices from VFIO domain by clearing domain id and page table root pointer from each device table entry (DTE), and then invalidates the DTE. Then, the VFIO driver unmap pages and invalidate IOMMU pages.
Currently, the IOMMU driver keeps track of which IOMMU and how many devices are attached to the domain. When invalidate IOMMU pages, the driver checks if the IOMMU is still attached to the domain before issuing the invalidate page command.
However, since VFIO has already detached all devices from the domain, the subsequent INVALIDATE_IOMMU_PAGES commands are being skipped as there is no IOMMU attached to the domain. This results in data corruption and could cause the PCI device to end up in indeterministic state.
Fix this by invalidate IOMMU pages when detach a device, and before decrementing the per-domain device reference counts.
--- drivers/iommu/amd_iommu.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/iommu/amd_iommu.c +11 -4
@@ -2185,14 +2185,11 @@ static void do_attach(struct iommu_dev_dstatic void do_detach (struct iommu_dev_data *dev_data) { +struct protection_domain *domain = dev_data->domain;struct amd_iommu *iommu; iommu = amd_iommu_rlookup_table[dev_data->devid]; -/* decrease reference counters */ - dev_data->domain->dev_iommu[iommu->index] -=1 ; - dev_data->domain->dev_cnt -=1 ; -/* Update data structures */ dev_data->domain =NULL ;list_del (&dev_data->list);
@@ -2200,6 +2197,16 @@ static void do_detach(struct iommu_dev_d/* Flush the DTE entry */ device_flush_dte (dev_data); + +/* Flush IOTLB */ +domain_flush_tlb_pde (domain); + +/* Wait for the flushes to finish */ +domain_flush_complete (domain); + +/* decrease reference counters - needs to happen after the flushes */ + domain->dev_iommu[iommu->index] -=1 ; + domain->dev_cnt -=1 ; }/*
PATCH 65/202 net/mlx4_core: Add masking for a few queries on HCA caps
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Aya Levin <[email protected]>
commit a40ded6043658444ee4dd6ee374119e4e98b33fc upstream.
Driver reads the query HCA capabilities without the corresponding masks. Without the correct masks, the base addresses of the queues are unaligned. In addition some reserved bits were wrongly read. Using the correct masks, ensures alignment of the base addresses and allows future firmware versions safe use of the reserved bits.
[bwh: Backported to 3.16:
- There are no num_sys_eqs or dmfs_high_steer_mode parameters
- Adjust context]
---
drivers/net/ethernet/mellanox/mlx4/fw.c +42 -26
@@ -1542,9 +1542,10 @@ int mlx4_QUERY_HCA(struct mlx4_dev *dev, {struct mlx4_cmd_mailbox *mailbox;__be32 *outbox; +u64 qword_field;u32 dword_field; -int err;u8 byte_field; +int err;#define QUERY_HCA_GLOBAL_CAPS_OFFSET 0x04#define QUERY_HCA_CORE_CLOCK_OFFSET 0x0c
@@ -1566,18 +1567,30 @@ int mlx4_QUERY_HCA(struct mlx4_dev *dev,/* QPC/EEC/CQC/EQC/RDMARC attributes */ -MLX4_GET (param->qpc_base, outbox,INIT_HCA_QPC_BASE_OFFSET ); -MLX4_GET (param->log_num_qps, outbox,INIT_HCA_LOG_QP_OFFSET ); -MLX4_GET (param->srqc_base, outbox,INIT_HCA_SRQC_BASE_OFFSET ); -MLX4_GET (param->log_num_srqs, outbox,INIT_HCA_LOG_SRQ_OFFSET ); -MLX4_GET (param->cqc_base, outbox,INIT_HCA_CQC_BASE_OFFSET ); -MLX4_GET (param->log_num_cqs, outbox,INIT_HCA_LOG_CQ_OFFSET ); -MLX4_GET (param->altc_base, outbox,INIT_HCA_ALTC_BASE_OFFSET ); -MLX4_GET (param->auxc_base, outbox,INIT_HCA_AUXC_BASE_OFFSET ); -MLX4_GET (param->eqc_base, outbox,INIT_HCA_EQC_BASE_OFFSET ); -MLX4_GET (param->log_num_eqs, outbox,INIT_HCA_LOG_EQ_OFFSET ); -MLX4_GET (param->rdmarc_base, outbox,INIT_HCA_RDMARC_BASE_OFFSET ); -MLX4_GET (param->log_rd_per_qp, outbox,INIT_HCA_LOG_RD_OFFSET ); +MLX4_GET (qword_field, outbox,INIT_HCA_QPC_BASE_OFFSET ); + param->qpc_base = qword_field & ~((u64 )0x1f ); +MLX4_GET (byte_field, outbox,INIT_HCA_LOG_QP_OFFSET ); + param->log_num_qps = byte_field &0x1f ; +MLX4_GET (qword_field, outbox,INIT_HCA_SRQC_BASE_OFFSET ); + param->srqc_base = qword_field & ~((u64 )0x1f ); +MLX4_GET (byte_field, outbox,INIT_HCA_LOG_SRQ_OFFSET ); + param->log_num_srqs = byte_field &0x1f ; +MLX4_GET (qword_field, outbox,INIT_HCA_CQC_BASE_OFFSET ); + param->cqc_base = qword_field & ~((u64 )0x1f ); +MLX4_GET (byte_field, outbox,INIT_HCA_LOG_CQ_OFFSET ); + param->log_num_cqs = byte_field &0x1f ; +MLX4_GET (qword_field, outbox,INIT_HCA_ALTC_BASE_OFFSET ); + param->altc_base = qword_field; +MLX4_GET (qword_field, outbox,INIT_HCA_AUXC_BASE_OFFSET ); + param->auxc_base = qword_field; +MLX4_GET (qword_field, outbox,INIT_HCA_EQC_BASE_OFFSET ); + param->eqc_base = qword_field & ~((u64 )0x1f ); +MLX4_GET (byte_field, outbox,INIT_HCA_LOG_EQ_OFFSET ); + param->log_num_eqs = byte_field &0x1f ; +MLX4_GET (qword_field, outbox,INIT_HCA_RDMARC_BASE_OFFSET ); + param->rdmarc_base = qword_field & ~((u64 )0x1f ); +MLX4_GET (byte_field, outbox,INIT_HCA_LOG_RD_OFFSET ); + param->log_rd_per_qp = byte_field &0x7 ;MLX4_GET (dword_field, outbox,INIT_HCA_FLAGS_OFFSET );if (dword_field & (1 <<INIT_HCA_DEVICE_MANAGED_FLOW_STEERING_EN )) {
@@ -1592,18 +1605,18 @@ int mlx4_QUERY_HCA(struct mlx4_dev *dev,/* steering attributes */ if (param->steering_mode ==MLX4_STEERING_MODE_DEVICE_MANAGED ) {MLX4_GET (param->mc_base, outbox,INIT_HCA_FS_BASE_OFFSET ); -MLX4_GET (param->log_mc_entry_sz, outbox, -INIT_HCA_FS_LOG_ENTRY_SZ_OFFSET ); -MLX4_GET (param->log_mc_table_sz, outbox, -INIT_HCA_FS_LOG_TABLE_SZ_OFFSET ); +MLX4_GET (byte_field, outbox,INIT_HCA_FS_LOG_ENTRY_SZ_OFFSET ); + param->log_mc_entry_sz = byte_field &0x1f ; +MLX4_GET (byte_field, outbox,INIT_HCA_FS_LOG_TABLE_SZ_OFFSET ); + param->log_mc_table_sz = byte_field &0x1f ; }else {MLX4_GET (param->mc_base, outbox,INIT_HCA_MC_BASE_OFFSET ); -MLX4_GET (param->log_mc_entry_sz, outbox, -INIT_HCA_LOG_MC_ENTRY_SZ_OFFSET ); -MLX4_GET (param->log_mc_hash_sz, outbox, -INIT_HCA_LOG_MC_HASH_SZ_OFFSET ); -MLX4_GET (param->log_mc_table_sz, outbox, -INIT_HCA_LOG_MC_TABLE_SZ_OFFSET ); +MLX4_GET (byte_field, outbox,INIT_HCA_LOG_MC_ENTRY_SZ_OFFSET ); + param->log_mc_entry_sz = byte_field &0x1f ; +MLX4_GET (byte_field, outbox,INIT_HCA_LOG_MC_HASH_SZ_OFFSET ); + param->log_mc_hash_sz = byte_field &0x1f ; +MLX4_GET (byte_field, outbox,INIT_HCA_LOG_MC_TABLE_SZ_OFFSET ); + param->log_mc_table_sz = byte_field &0x1f ; }/* CX3 is capable of extending CQEs/EQEs from 32 to 64 bytes */
@@ -1616,15 +1629,18 @@ int mlx4_QUERY_HCA(struct mlx4_dev *dev,/* TPT attributes */ MLX4_GET (param->dmpt_base, outbox,INIT_HCA_DMPT_BASE_OFFSET ); -MLX4_GET (param->mw_enabled, outbox,INIT_HCA_TPT_MW_OFFSET ); -MLX4_GET (param->log_mpt_sz, outbox,INIT_HCA_LOG_MPT_SZ_OFFSET ); +MLX4_GET (byte_field, outbox,INIT_HCA_TPT_MW_OFFSET ); + param->mw_enabled = byte_field >>7 ; +MLX4_GET (byte_field, outbox,INIT_HCA_LOG_MPT_SZ_OFFSET ); + param->log_mpt_sz = byte_field &0x3f ;MLX4_GET (param->mtt_base, outbox,INIT_HCA_MTT_BASE_OFFSET );MLX4_GET (param->cmpt_base, outbox,INIT_HCA_CMPT_BASE_OFFSET );/* UAR attributes */ MLX4_GET (param->uar_page_sz, outbox,INIT_HCA_UAR_PAGE_SZ_OFFSET ); -MLX4_GET (param->log_uar_sz, outbox,INIT_HCA_LOG_UAR_SZ_OFFSET ); +MLX4_GET (byte_field, outbox,INIT_HCA_LOG_UAR_SZ_OFFSET ); + param->log_uar_sz = byte_field &0xf ; out:mlx4_free_cmd_mailbox (dev, mailbox);
PATCH 66/202 debugfs: fix debugfs_rename parameter checking
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit d88c93f090f708c18195553b352b9f205e65418f upstream.
debugfs_rename() needs to check that the dentries passed into it really are valid, as sometimes they are not (i.e. if the return value of another debugfs call is passed into this one.) So fix this up by properly checking if the two parent directories are errors (they are allowed to be NULL), and if the dentry to rename is not NULL or an error.
--- fs/debugfs/inode.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/debugfs/inode.c +7 -0
@@ -622,6 +622,13 @@ struct dentry *debugfs_rename(struct denstruct dentry *dentry =NULL , *trap;struct name_snapshot old_name; +if (IS_ERR (old_dir)) +return old_dir; +if (IS_ERR (new_dir)) +return new_dir; +if (IS_ERR_OR_NULL (old_dentry)) +return old_dentry; + trap =lock_rename (new_dir, old_dir);/* Source or destination directories don't exist? */ if (!old_dir->d_inode || !new_dir->d_inode)
PATCH 67/202 KVM: x86: Fix single-step debugging
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Popov <[email protected]>
commit 5cc244a20b86090c087073c124284381cdf47234 upstream.
The single-step debugging of KVM guests on x86 is broken: if we run gdb 'stepi' command at the breakpoint when the guest interrupts are enabled, RIP always jumps to native_apic_mem_write(). Then other nasty effects follow.
Long investigation showed that on Jun 7, 2017 the
commit c8401dda2f0a00cd25c0 ("KVM: x86: fix singlestepping over syscall") introduced the kvm_run.debug corruption: kvm_vcpu_do_singlestep() can be called without X86_EFLAGS_TF set.
Let's fix it. Please consider that for -stable.
--- arch/x86/kvm/x86.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kvm/x86.c +1 -2
@@ -5400,8 +5400,7 @@ restart:kvm_make_request (KVM_REQ_EVENT , vcpu); vcpu->arch.emulate_regs_need_sync_to_vcpu = false;kvm_rip_write (vcpu, ctxt->eip); -if (r ==EMULATE_DONE && - (ctxt->tf || (vcpu->guest_debug &KVM_GUESTDBG_SINGLESTEP ))) +if (r ==EMULATE_DONE && ctxt->tf)kvm_vcpu_do_singlestep (vcpu, &r);kvm_set_rflags (vcpu, ctxt->eflags); }else
PATCH 68/202 IB/ipoib: Fix for use-after-free in ipoib_cm_tx_start
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Feras Daoud <[email protected]>
commit 6ab4aba00f811a5265acc4d3eb1863bb3ca60562 upstream.
The following BUG was reported by kasan:
BUG: KASAN: use-after-free in ipoib_cm_tx_start+0x430/0x1390 [ib_ipoib]
Read of size 80 at addr ffff88034c30bcd0 by task kworker/u16:1/24020
Workqueue: ipoib_wq ipoib_cm_tx_start [ib_ipoib]
Call Trace:
dump_stack+0x9a/0xeb
print_address_description+0xe3/0x2e0
kasan_report+0x18a/0x2e0
? ipoib_cm_tx_start+0x430/0x1390 [ib_ipoib]
memcpy+0x1f/0x50
ipoib_cm_tx_start+0x430/0x1390 [ib_ipoib]
? kvm_clock_read+0x1f/0x30
? ipoib_cm_skb_reap+0x610/0x610 [ib_ipoib]
? __lock_is_held+0xc2/0x170
? process_one_work+0x880/0x1960
? process_one_work+0x912/0x1960
process_one_work+0x912/0x1960
? wq_pool_ids_show+0x310/0x310
? lock_acquire+0x145/0x440
worker_thread+0x87/0xbb0
? process_one_work+0x1960/0x1960
kthread+0x314/0x3d0
? kthread_create_worker_on_cpu+0xc0/0xc0
ret_from_fork+0x3a/0x50
Allocated by task 0:
kasan_kmalloc+0xa0/0xd0
kmem_cache_alloc_trace+0x168/0x3e0
path_rec_create+0xa2/0x1f0 [ib_ipoib]
ipoib_start_xmit+0xa98/0x19e0 [ib_ipoib]
dev_hard_start_xmit+0x159/0x8d0
sch_direct_xmit+0x226/0xb40
__dev_queue_xmit+0x1d63/0x2950
neigh_update+0x889/0x1770
arp_process+0xc47/0x21f0
arp_rcv+0x462/0x760
__netif_receive_skb_core+0x1546/0x2da0
netif_receive_skb_internal+0xf2/0x590
napi_gro_receive+0x28e/0x390
ipoib_ib_handle_rx_wc_rss+0x873/0x1b60 [ib_ipoib]
ipoib_rx_poll_rss+0x17d/0x320 [ib_ipoib]
net_rx_action+0x427/0xe30
__do_softirq+0x28e/0xc42
Freed by task 26680:
__kasan_slab_free+0x11d/0x160
kfree+0xf5/0x360
ipoib_flush_paths+0x532/0x9d0 [ib_ipoib]
ipoib_set_mode_rss+0x1ad/0x560 [ib_ipoib]
set_mode+0xc8/0x150 [ib_ipoib]
kernfs_fop_write+0x279/0x440
__vfs_write+0xd8/0x5c0
vfs_write+0x15e/0x470
ksys_write+0xb8/0x180
do_syscall_64+0x9b/0x420
entry_SYSCALL_64_after_hwframe+0x49/0xbe
The buggy address belongs to the object at ffff88034c30bcc8
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 8 bytes inside of
512-byte region [ffff88034c30bcc8, ffff88034c30bec8)
The buggy address belongs to the page:The following race between change mode and xmit flow is the reason for this use-after-free:
Change mode Send packet 1 to GID XX Send packet 2 to GID XX
| | |
start | |
| | |
| | |
| Create new path for GID XX |
| and update neigh path |
| | |
| | |
| | |
flush_paths | |
| |
queue_work(cm.start_task) |
| Path for GID XX not found
| create new path
|
| start_task runs with old
released path
There is no locking to protect the lifetime of the path through the ipoib_cm_tx struct, so delete it entirely and always use the newly looked up path under the priv->lock.
--- drivers/infiniband/ulp/ipoib/ipoib.h | 1 - drivers/infiniband/ulp/ipoib/ipoib_cm.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/infiniband/ulp/ipoib/ipoib.h +0 -1
@@ -228,7 +228,6 @@ struct ipoib_cm_tx {struct list_head list;struct net_device *dev;struct ipoib_neigh *neigh; -struct ipoib_path *path;struct ipoib_cm_tx_buf *tx_ring;unsigned tx_head;unsigned tx_tail;
drivers/infiniband/ulp/ipoib/ipoib_cm.c +1 -2
@@ -1279,7 +1279,6 @@ struct ipoib_cm_tx *ipoib_cm_create_tx(s neigh->cm = tx; tx->neigh = neigh; - tx->path = path; tx->dev = dev;list_add (&tx->list, &priv->cm.start_list);set_bit (IPOIB_FLAG_INITIALIZED , &tx->flags);
@@ -1338,7 +1337,7 @@ static void ipoib_cm_tx_start(struct wor neigh->daddr + QPN_AND_OPTIONS_OFFSET); goto free_neigh; } -memcpy (&pathrec, &p->path->pathrec,sizeof pathrec); +memcpy (&pathrec, &path->pathrec,sizeof (pathrec));spin_unlock_irqrestore (&priv->lock, flags);netif_tx_unlock_bh (dev);
PATCH 69/202 kallsyms: Handle too long symbols in kallsyms.c
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eugene Loh <[email protected]>
commit 6db2983cd8064808141ccefd75218f5b4345ffae upstream.
When checking for symbols with excessively long names, account for null terminating character.
--- scripts/kallsyms.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/kallsyms.c +2 -2
@@ -121,8 +121,8 @@ static int read_symbol(FILE *in, structfprintf (stderr,"Read error or end of file.\n" );return -1 ; } -if (strlen (str) >KSYM_NAME_LEN ) { -fprintf (stderr,"Symbol %s too long for kallsyms (%zu vs %d).\n" +if (strlen (str) >=KSYM_NAME_LEN ) { +fprintf (stderr,"Symbol %s too long for kallsyms (%zu >= %d).\n" "Please increase KSYM_NAME_LEN both in kernel and kallsyms.c\n" , str,strlen (str),KSYM_NAME_LEN );return -1 ;
PATCH 70/202 usb: gadget: udc: net2272: Fix bitwise and boolean operations
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Gustavo A. R. Silva" <[email protected]>
commit 07c69f1148da7de3978686d3af9263325d9d60bd upstream.
(!x & y) strikes again.
Fix bitwise and boolean operations by enclosing the expression:
intcsr & (1 << NET2272_PCI_IRQ)
in parentheses, before applying the boolean operator '!'.
Notice that this code has been there since 2011. So, it would be helpful if someone can double-check this.
This issue was detected with the help of Coccinelle.
--- drivers/usb/gadget/net2272.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/net2272.c +1 -1
@@ -2072,7 +2072,7 @@ static irqreturn_t net2272_irq(int irq,#if defined(PLX_PCI_RDK2 )/* see if PCI int for us by checking irqstat */ intcsr =readl (dev->rdk2.fpga_base_addr +RDK2_IRQSTAT ); -if (!intcsr & (1 <<NET2272_PCI_IRQ )) { +if (!(intcsr & (1 <<NET2272_PCI_IRQ ))) {spin_unlock (&dev->lock);return IRQ_NONE ; }
PATCH 71/202 usb: phy: am335x: fix race condition in _probe
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Bin Liu <[email protected]>
commit a53469a68eb886e84dd8b69a1458a623d3591793 upstream.
power off the phy should be done before populate the phy. Otherwise, am335x_init() could be called by the phy owner to power on the phy first, then am335x_phy_probe() turns off the phy again without the caller knowing it.
--- drivers/usb/phy/phy-am335x.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/usb/phy/phy-am335x.c +1 -4
@@ -56,9 +56,6 @@ static int am335x_phy_probe(struct platfif (ret)return ret; - ret =usb_add_phy_dev (&am_phy->usb_phy_gen.phy); -if (ret) -return ret; am_phy->usb_phy_gen.phy.init = am335x_init; am_phy->usb_phy_gen.phy.shutdown = am335x_shutdown;
@@ -77,7 +74,7 @@ static int am335x_phy_probe(struct platfdevice_set_wakeup_enable (dev, false);phy_ctrl_power (am_phy->phy_ctrl, am_phy->id, false); -return 0 ; +return usb_add_phy_dev (&am_phy->usb_phy_gen.phy); }static int am335x_phy_remove (struct platform_device *pdev)
PATCH 72/202 s390/dasd: fix using offset into zero size array error
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Haberland <[email protected]>
commit 4a8ef6999bce998fa5813023a9a6b56eea329dba upstream.
Dan Carpenter reported the following:
The patch 52898025cf7d: "[S390] dasd: security and PSF update patch for EMC CKD ioctl" from Mar 8, 2010, leads to the following static checker warning:
drivers/s390/block/dasd_eckd.c:4486 dasd_symm_io() error: using offset into zero size array 'psf_data[]'
drivers/s390/block/dasd_eckd.c
4458 /* Copy parms from caller */
4459 rc = -EFAULT;
4460 if (copy_from_user(&usrparm, argp, sizeof(usrparm)))
^^^^^^^The user can specify any "usrparm.psf_data_len". They choose zero by mistake.
4461 goto out;
4462 if (is_compat_task()) {
4463 /* Make sure pointers are sane even on 31 bit. */ 4464 rc = -EINVAL; 4465 if ((usrparm.psf_data >> 32) != 0) 4466 goto out; 4467 if ((usrparm.rssd_result >> 32) != 0) 4468 goto out; 4469 usrparm.psf_data &= 0x7fffffffULL; 4470 usrparm.rssd_result &= 0x7fffffffULL; 4471 } 4472 /* alloc I/O data area */ 4473 psf_data = kzalloc(usrparm.psf_data_len, GFP_KERNEL | GFP_DMA); 4474 rssd_result = kzalloc(usrparm.rssd_result_len, GFP_KERNEL | GFP_DMA);
4475 if (!psf_data || !rssd_result) {
kzalloc() returns a ZERO_SIZE_PTR (0x16).
4476 rc = -ENOMEM; 4477 goto out_free; 4478 } 4479 4480 /* get syscall header from user space */ 4481 rc = -EFAULT; 4482 if (copy_from_user(psf_data, 4483 (void __user *)(unsigned long) usrparm.psf_data, 4484 usrparm.psf_data_len))
That all works great.
4485 goto out_free; 4486 psf0 = psf_data[0]; 4487 psf1 = psf_data[1];
But now we're assuming that "->psf_data_len" was at least 2 bytes.
Fix this by checking the user specified length psf_data_len.
--- drivers/s390/block/dasd_eckd.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/s390/block/dasd_eckd.c +8 -0
@@ -3945,6 +3945,14 @@ static int dasd_symm_io(struct dasd_devi usrparm.psf_data &=0x7fffffffULL ; usrparm.rssd_result &=0x7fffffffULL ; } +/* at least 2 bytes are accessed and should be allocated */ +if (usrparm.psf_data_len <2 ) { +DBF_DEV_EVENT (DBF_WARNING , device, +"Symmetrix ioctl invalid data length %d" , + usrparm.psf_data_len); + rc = -EINVAL ; + goto out; + }/* alloc I/O data area */ psf_data =kzalloc (usrparm.psf_data_len,GFP_KERNEL |GFP_DMA ); rssd_result =kzalloc (usrparm.rssd_result_len,GFP_KERNEL |GFP_DMA );
PATCH 73/202 scsi: bnx2fc: Fix error handling in probe()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit b2d3492fc591b1fb46b81d79ca1fc44cac6ae0ae upstream.
There are two issues here. First if cmgr->hba is not set early enough then it leads to a NULL dereference. Second if we don't completely initialize cmgr->io_bdt_pool[] then we end up dereferencing uninitialized pointers.
--- drivers/scsi/bnx2fc/bnx2fc_io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/bnx2fc/bnx2fc_io.c +2 -2
@@ -271,6 +271,7 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alreturn NULL ; } + cmgr->hba = hba; cmgr->free_list =kzalloc (sizeof (*cmgr->free_list) * arr_sz,GFP_KERNEL );if (!cmgr->free_list) {
@@ -287,7 +288,6 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_al goto mem_err; } - cmgr->hba = hba; cmgr->cmds = (struct bnx2fc_cmd **)(cmgr +1 );for (i =0 ; i < arr_sz; i++) {
@@ -326,7 +326,7 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_al/* Allocate pool of io_bdts - one for each bnx2fc_cmd */ mem_size = num_ios *sizeof (struct io_bdt *); - cmgr->io_bdt_pool =kmalloc (mem_size,GFP_KERNEL ); + cmgr->io_bdt_pool =kzalloc (mem_size,GFP_KERNEL );if (!cmgr->io_bdt_pool) { printk(KERN_ERR PFX "failed to alloc io_bdt_pool\n"); goto mem_err;
PATCH 74/202 MIPS: OCTEON: don't set octeon_dma_bar_type if PCI is disabled
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Aaro Koskinen <[email protected]>
commit dcf300a69ac307053dfb35c2e33972e754a98bce upstream.
Don't set octeon_dma_bar_type if PCI is disabled. This avoids creation of the MSI irqchip later on, and saves a bit of memory.
--- arch/mips/pci/pci-octeon.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/mips/pci/pci-octeon.c +5 -5
@@ -575,6 +575,11 @@ static int __init octeon_pci_setup(void)if (octeon_has_feature (OCTEON_FEATURE_PCIE ))return 0 ; +if (!octeon_is_pci_host ()) { +pr_notice ("Not in host mode, PCI Controller not initialized\n" ); +return 0 ; + } +/* Point pcibios_map_irq() to the PCI version of it */ octeon_pcibios_map_irq = octeon_pci_pcibios_map_irq;
@@ -586,11 +591,6 @@ static int __init octeon_pci_setup(void)else octeon_dma_bar_type =OCTEON_DMA_BAR_TYPE_BIG ; -if (!octeon_is_pci_host ()) { -pr_notice ("Not in host mode, PCI Controller not initialized\n" ); -return 0 ; - } -/* PCI I/O and PCI MEM values */ set_io_port_base (OCTEON_PCI_IOSPACE_BASE ); ioport_resource.start =0 ;
PATCH 75/202 CIFS: Do not count -ENODATA as failure for query directory
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Shilovsky <[email protected]>
commit 8e6e72aeceaaed5aeeb1cb43d3085de7ceb14f79 upstream.
--- fs/cifs/smb2pdu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/cifs/smb2pdu.c +2 -2
@@ -2260,8 +2260,8 @@ SMB2_query_directory(const unsigned intif (rc == -ENODATA && rsp->hdr.Status ==STATUS_NO_MORE_FILES ) { srch_inf->endOfSearch = true; rc =0 ; - } -cifs_stats_fail_inc (tcon,SMB2_QUERY_DIRECTORY_HE ); + }else +cifs_stats_fail_inc (tcon,SMB2_QUERY_DIRECTORY_HE ); goto qdir_exit; }
PATCH 76/202 CIFS: Do not consider -ENODATA as stat failure for reads
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Shilovsky <[email protected]>
commit 082aaa8700415f6471ec9c5ef0c8307ca214989a upstream.
When doing reads beyound the end of a file the server returns error STATUS_END_OF_FILE error which is mapped to -ENODATA. Currently we report it as a failure which confuses read stats. Change it to not consider -ENODATA as failure for stat purposes.
--- fs/cifs/smb2pdu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/smb2pdu.c +1 -1
@@ -1861,7 +1861,7 @@ smb2_readv_callback(struct mid_q_entry * rdata->result = -EIO ; } -if (rdata->result) +if (rdata->result && rdata->result != -ENODATA )cifs_stats_fail_inc (tcon,SMB2_READ_HE );queue_work (cifsiod_wq, &rdata->work);
PATCH 77/202 ARM: iop32x/n2100: fix PCI IRQ mapping
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Russell King <[email protected]>
commit db4090920ba2d61a5827a23e441447926a02ffee upstream.
Booting 4.20 on a TheCUS N2100 results in a kernel oops while probing PCI, due to n2100_pci_map_irq() having been discarded during boot.
--- arch/arm/mach-iop32x/n2100.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/mach-iop32x/n2100.c +1 -2
@@ -75,8 +75,7 @@ void __init n2100_map_io(void)/* * N2100 PCI. */ -static int __init -n2100_pci_map_irq (const struct pci_dev *dev,u8 slot,u8 pin) +static int n2100_pci_map_irq (const struct pci_dev *dev,u8 slot,u8 pin) {int irq;
PATCH 78/202 usb: gadget: musb: fix short isoc packets with inventra dma
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paul Elder <[email protected]>
commit c418fd6c01fbc5516a2cd1eaf1df1ec86869028a upstream.
Handling short packets (length < max packet size) in the Inventra DMA engine in the MUSB driver causes the MUSB DMA controller to hang. An example of a problem that is caused by this problem is when streaming video out of a UVC gadget, only the first video frame is transferred.
For short packets (mode-0 or mode-1 DMA), MUSB_TXCSR_TXPKTRDY must be set manually by the driver. This was previously done in musb_g_tx (musb_gadget.c), but incorrectly (all csr flags were cleared, and only MUSB_TXCSR_MODE and MUSB_TXCSR_TXPKTRDY were set). Fixing that problem allows some requests to be transferred correctly, but multiple requests were often put together in one USB packet, and caused problems if the packet size was not a multiple of 4. Instead, set MUSB_TXCSR_TXPKTRDY in dma_controller_irq (musbhsdma.c), just like host mode transfers.
This topic was originally tackled by Nicolas Boichat [0] [1] and is discussed further at [2] as part of his GSoC project [3].
[0] https://groups.google.com/forum/?hl=en#!topic/beagleboard-gsoc/k8Azwfp75CU
[1] https://gitorious.org/beagleboard-usbsniffer/beagleboard-usbsniffer-kernel/commit/b0be3b6cc195ba732189b04f1d43ec843c3e54c9?p=beagleboard-usbsniffer:beagleboard-usbsniffer-kernel.git;a=patch;h=b0be3b6cc195ba732189b04f1d43ec843c3e54c9
[2] http://beagleboard-usbsniffer.blogspot.com/2010/07/musb-isochronous-transfers-fixed.html
[3] http://elinux.org/BeagleBoard/GSoC/USBSniffer
[bwh: Backported to 3.16:
- Fold in the earlier commit fb91cddc54e7 "usb: musb: Remove DMA ifdef for musb_gadget.c short_packet"
- Adjust context]
--- drivers/usb/musb/musb_gadget.c | 13 +------------ drivers/usb/musb/musbhsdma.c | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 22 deletions(-)
drivers/usb/musb/musb_gadget.c +3 -10
@@ -488,10 +488,8 @@ void musb_g_tx(struct musb *musb, u8 epn }if (request) { -u8 is_dma =0 ;if (dma && (csr &MUSB_TXCSR_DMAENAB )) { - is_dma =1 ; csr |=MUSB_TXCSR_P_WZC_BITS ; csr &= ~(MUSB_TXCSR_DMAENAB |MUSB_TXCSR_P_UNDERRUN |MUSB_TXCSR_TXPKTRDY |MUSB_TXCSR_AUTOSET );
@@ -507,15 +505,10 @@ void musb_g_tx(struct musb *musb, u8 epn* First, maybe a terminating short packet. Some DMA * engines might handle this by themselves. */ - if ((request->zero && request->length +if ((request->zero && request->length) && (request->length % musb_ep->packet_sz ==0 ) - && (request->actual == request->length)) -#if defined(CONFIG_USB_INVENTRA_DMA ) || defined(CONFIG_USB_UX500_DMA ) - || (is_dma && (!dma->desired_mode || - (request->actual & - (musb_ep->packet_sz - 1)))) -#endif - ) { + && (request->actual == request->length)) { +/* * On DMA completion, FIFO may not be * available yet...
drivers/usb/musb/musbhsdma.c +11 -10
@@ -319,12 +319,10 @@ static irqreturn_t dma_controller_irq(in channel->status =MUSB_DMA_STATUS_FREE ;/* completed */ -if ((devctl &MUSB_DEVCTL_HM ) - && (musb_channel->transmit) - && ((channel->desired_mode ==0 ) - || (channel->actual_len & - (musb_channel->max_packet_sz -1 ))) - ) { +if (musb_channel->transmit && + (!channel->desired_mode || + (channel->actual_len % + musb_channel->max_packet_sz))) {u8 epnum = musb_channel->epnum;int offset =MUSB_EP_OFFSET (epnum,MUSB_TXCSR );
@@ -336,11 +334,14 @@ static irqreturn_t dma_controller_irq(in*/ musb_ep_select (mbase, epnum); txcsr =musb_readw (mbase, offset); - txcsr &= ~(MUSB_TXCSR_DMAENAB +if (channel->desired_mode ==1 ) { + txcsr &= ~(MUSB_TXCSR_DMAENAB |MUSB_TXCSR_AUTOSET ); -musb_writew (mbase, offset, txcsr); -/* Send out the packet */ - txcsr &= ~MUSB_TXCSR_DMAMODE ; +musb_writew (mbase, offset, txcsr); +/* Send out the packet */ + txcsr &= ~MUSB_TXCSR_DMAMODE ; + txcsr |=MUSB_TXCSR_DMAENAB ; + } txcsr |=MUSB_TXCSR_TXPKTRDY ;musb_writew (mbase, offset, txcsr); }
PATCH 79/202 fs/dcache: Fix incorrect nr_dentry_unused accounting in shrink_dcache_sb()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Waiman Long <[email protected]>
commit 1dbd449c9943e3145148cc893c2461b72ba6fef0 upstream.
The nr_dentry_unused per-cpu counter tracks dentries in both the LRU lists and the shrink lists where the DCACHE_LRU_LIST bit is set.
The shrink_dcache_sb() function moves dentries from the LRU list to a shrink list and subtracts the dentry count from nr_dentry_unused. This is incorrect as the nr_dentry_unused count will also be decremented in shrink_dentry_list() via d_shrink_del().
To fix this double decrement, the decrement in the shrink_dcache_sb() function is taken out.
--- fs/dcache.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
fs/dcache.c +1 -5
@@ -1063,15 +1063,11 @@ static enum lru_status dentry_lru_isolat*/ void shrink_dcache_sb (struct super_block *sb) { -long freed; -do {LIST_HEAD (dispose); - freed =list_lru_walk (&sb->s_dentry_lru, +list_lru_walk (&sb->s_dentry_lru, dentry_lru_isolate_shrink, &dispose,1024 ); - -this_cpu_sub (nr_dentry_unused, freed);shrink_dentry_list (&dispose);cond_resched (); }while (list_lru_count (&sb->s_dentry_lru) >0 );
PATCH 80/202 l2tp: copy 4 more bytes to linear part if necessary
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jacob Wen <[email protected]>
commit 91c524708de6207f59dd3512518d8a1c7b434ee3 upstream.
The size of L2TPv2 header with all optional fields is 14 bytes. l2tp_udp_recv_core only moves 10 bytes to the linear part of a skb. This may lead to l2tp_recv_common read data outside of a skb.
This patch make sure that there is at least 14 bytes in the linear part of a skb to meet the maximum need of l2tp_udp_recv_core and l2tp_recv_common. The minimum size of both PPP HDLC-like frame and Ethernet frame is larger than 14 bytes, so we are safe to do so.
Also remove L2TP_HDR_SIZE_NOSEQ, it is unused now.
--- net/l2tp/l2tp_core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/l2tp/l2tp_core.c +2 -3
@@ -82,8 +82,7 @@#define L2TP_SLFLAG_S 0x40000000#define L2TP_SL_SEQ_MASK 0x00ffffff -#define L2TP_HDR_SIZE_SEQ 10 -#define L2TP_HDR_SIZE_NOSEQ 6 +#define L2TP_HDR_SIZE_MAX 14/* Default trace flags */ #define L2TP_DEFAULT_DEBUG_FLAGS 0
@@ -897,7 +896,7 @@ static int l2tp_udp_recv_core(struct l2t__skb_pull (skb,sizeof (struct udphdr ));/* Short packet? */ -if (!pskb_may_pull (skb,L2TP_HDR_SIZE_SEQ )) { +if (!pskb_may_pull (skb,L2TP_HDR_SIZE_MAX )) {l2tp_info (tunnel,L2TP_MSG_DATA ,"%s: recv short packet (len=%d)\n" , tunnel->name, skb->len);
PATCH 81/202 mac80211: ensure that mgmt tx skbs have tailroom for encryption
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
commit 9d0f50b80222dc273e67e4e14410fcfa4130a90c upstream.
Some drivers use IEEE80211_KEY_FLAG_SW_MGMT_TX to indicate that management frames need to be software encrypted. Since normal data packets are still encrypted by the hardware, crypto_tx_tailroom_needed_cnt gets decremented after key upload to hw. This can lead to passing skbs to ccmp_encrypt_skb, which don't have the necessary tailroom for software encryption.
Change the code to add tailroom for encrypted management packets, even if crypto_tx_tailroom_needed_cnt is 0.
---
net/mac80211/tx.c +8 -1
@@ -1465,9 +1465,16 @@ static int ieee80211_skb_resize(struct i int head_need, bool may_encrypt) {struct ieee80211_local *local = sdata->local; +struct ieee80211_hdr *hdr; +bool enc_tailroom;int tail_need =0 ; -if (may_encrypt && sdata->crypto_tx_tailroom_needed_cnt) { + hdr = (struct ieee80211_hdr *) skb->data; + enc_tailroom = may_encrypt && + (sdata->crypto_tx_tailroom_needed_cnt || +ieee80211_is_mgmt (hdr->frame_control)); + +if (enc_tailroom) { tail_need =IEEE80211_ENCRYPT_TAILROOM ; tail_need -=skb_tailroom (skb); tail_need =max_t (int, tail_need,0 );
PATCH 82/202 skge: potential memory corruption in skge_get_regs()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 294c149a209c6196c2de85f512b52ef50f519949 upstream.
The "p" buffer is 0x4000 bytes long. B3_RI_WTO_R1 is 0x190. The value of "regs->len" is in the 1-0x4000 range. The bug here is that "regs->len - B3_RI_WTO_R1" can be a negative value which would lead to memory corruption and an abrupt crash.
--- drivers/net/ethernet/marvell/skge.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/skge.c +4 -2
@@ -152,8 +152,10 @@ static void skge_get_regs(struct net_devmemset (p,0 , regs->len);memcpy_fromio (p, io,B3_RAM_ADDR ); -memcpy_fromio (p +B3_RI_WTO_R1 , io +B3_RI_WTO_R1 , - regs->len -B3_RI_WTO_R1 ); +if (regs->len >B3_RI_WTO_R1 ) { +memcpy_fromio (p +B3_RI_WTO_R1 , io +B3_RI_WTO_R1 , + regs->len -B3_RI_WTO_R1 ); + } }/* Wake on Lan only supported on Yukon chips with rev 1 or above */
PATCH 83/202 mm, oom: fix use-after-free in oom_kill_process
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Shakeel Butt <[email protected]>
commit cefc7ef3c87d02fc9307835868ff721ea12cc597 upstream.
Syzbot instance running on upstream kernel found a use-after-free bug in oom_kill_process. On further inspection it seems like the process selected to be oom-killed has exited even before reaching read_lock(&tasklist_lock) in oom_kill_process(). More specifically the tsk->usage is 1 which is due to get_task_struct() in oom_evaluate_task() and the put_task_struct within for_each_thread() frees the tsk and for_each_thread() tries to access the tsk. The easiest fix is to do get/put across the for_each_thread() on the selected task.
Now the next question is should we continue with the oom-kill as the previously selected task has exited? However before adding more complexity and heuristics, let's answer why we even look at the children of oom-kill selected task? The select_bad_process() has already selected the worst process in the system/memcg. Due to race, the selected process might not be the worst at the kill time but does that matter? The userspace can use the oom_score_adj interface to prefer children to be killed before the parent. I looked at the history but it seems like this is there before git history.
--- mm/oom_kill.c | 8 ++++++++ 1 file changed, 8 insertions(+)
mm/oom_kill.c +8 -0
@@ -466,6 +466,13 @@ void oom_kill_process(struct task_struct* still freeing memory. */ read_lock (&tasklist_lock); + +/* +* The task 'p' might have already exited before reaching here. The +* put_task_struct() will free task_struct 'p' while the loop still try +* to access the field of 'p', so, get an extra reference. +*/ +get_task_struct (p);for_each_thread (p, t) {list_for_each_entry (child, &t->children, sibling) {unsigned int child_points;
@@ -485,6 +492,7 @@ void oom_kill_process(struct task_struct } } } +put_task_struct (p);read_unlock (&tasklist_lock); p =find_lock_task_mm (victim);
PATCH 84/202 mm: hwpoison: use do_send_sig_info() instead of force_sig()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Naoya Horiguchi <[email protected]>
commit 6376360ecbe525a9c17b3d081dfd88ba3e4ed65b upstream.
Currently memory_failure() is racy against process's exiting, which results in kernel crash by null pointer dereference.
The root cause is that memory_failure() uses force_sig() to forcibly kill asynchronous (meaning not in the current context) processes. As discussed in thread https://lkml.org/lkml/2010/6/8/236 years ago for OOM fixes, this is not a right thing to do. OOM solves this issue by using do_send_sig_info() as done in commit d2d393099de2 ("signal:oom_kill_task: use SEND_SIG_FORCED instead of force_sig()"), so this patch is suggesting to do the same for hwpoison. do_send_sig_info() properly accesses to siglock with lock_task_sighand(), so is free from the reported race.
I confirmed that the reported bug reproduces with inserting some delay in kill_procs(), and it never reproduces with this patch.
Note that memory_failure() can send another type of signal using force_sig_mceerr(), and the reported race shouldn't happen on it because force_sig_mceerr() is called only for synchronous processes (i.e. BUS_MCEERR_AR happens only when some process accesses to the corrupted memory.)
--- mm/memory-failure.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
mm/memory-failure.c +2 -1
@@ -360,7 +360,8 @@ static void kill_procs(struct list_headprintk (KERN_ERR "MCE %#lx: forcibly killing %s:%d because of failure to unmap corrupted page\n" , pfn, tk->tsk->comm, tk->tsk->pid); -force_sig (SIGKILL , tk->tsk); +do_send_sig_info (SIGKILL ,SEND_SIG_PRIV , + tk->tsk,PIDTYPE_PID ); }/*
PATCH 85/202 mm: migrate: don't rely on __PageMovable() of newpage after unlocking it
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand <[email protected]>
commit e0a352fabce61f730341d119fbedf71ffdb8663f upstream.
We had a race in the old balloon compaction code before b1123ea6d3b3 ("mm: balloon: use general non-lru movable page feature") refactored it that became visible after backporting 195a8c43e93d ("virtio-balloon:
deflate via a page list") without the refactoring.
The bug existed from commit d6d86c0a7f8d ("mm/balloon_compaction:
redesign ballooned pages management") till b1123ea6d3b3 ("mm: balloon:
use general non-lru movable page feature"). d6d86c0a7f8d ("mm/balloon_compaction: redesign ballooned pages management") was backported to 3.12, so the broken kernels are stable kernels [3.12 - 4.7].
There was a subtle race between dropping the page lock of the newpage in __unmap_and_move() and checking for __is_movable_balloon_page(newpage).
Just after dropping this page lock, virtio-balloon could go ahead and deflate the newpage, effectively dequeueing it and clearing PageBalloon, in turn making __is_movable_balloon_page(newpage) fail.
This resulted in dropping the reference of the newpage via putback_lru_page(newpage) instead of put_page(newpage), leading to page->lru getting modified and a !LRU page ending up in the LRU lists. With 195a8c43e93d ("virtio-balloon: deflate via a page list") backported, one would suddenly get corrupted lists in release_pages_balloon():
- WARNING: CPU: 13 PID: 6586 at lib/list_debug.c:59 __list_del_entry+0xa1/0xd0
- list_del corruption. prev->next should be ffffe253961090a0, but was dead000000000100
Nowadays this race is no longer possible, but it is hidden behind very ugly handling of __ClearPageMovable() and __PageMovable().
__ClearPageMovable() will not make __PageMovable() fail, only PageMovable(). So the new check (__PageMovable(newpage)) will still hold even after newpage was dequeued by virtio-balloon.
If anybody would ever change that special handling, the BUG would be introduced again. So instead, make it explicit and use the information of the original isolated page before migration.
This patch can be backported fairly easy to stable kernels (in contrast to the refactoring).
[bwh: Backported to 3.16:
- Add the is_lru flag variable to unmap_and_move()
- Keep using __is_movable_balloon_page() instead of __PageMovable()
- Adjust context]
---
mm/migrate.c +6 -2
@@ -927,6 +927,7 @@ static int unmap_and_move(new_page_t getint rc =0 ;int *result =NULL ;struct page *newpage =get_new_page (page, private, &result); +bool is_lru = !__is_movable_balloon_page (page);if (!newpage)return -ENOMEM ;
@@ -959,12 +960,15 @@ out:/* * If migration was not successful and there's a freeing callback, use * it. Otherwise, putback_lru_page() will drop the reference grabbed -* during isolation. +* during isolation. Use the old state of the isolated source page to +* determine if we migrated a LRU page. newpage was already unlocked +* and possibly modified by its owner - don't rely on the page +* state. */ if (rc !=MIGRATEPAGE_SUCCESS && put_new_page) {ClearPageSwapBacked (newpage);put_new_page (newpage, private); - }else if (unlikely (__is_movable_balloon_page (newpage))) { + }else if (unlikely (!is_lru)) {/* drop our reference, page already in the balloon */ put_page (newpage); }else
PATCH 86/202 dmaengine: imx-dma: fix wrong callback invoke
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Leonid Iziumtsev <[email protected]>
commit 341198eda723c8c1cddbb006a89ad9e362502ea2 upstream.
Once the "ld_queue" list is not empty, next descriptor will migrate into "ld_active" list. The "desc" variable will be overwritten during that transition. And later the dmaengine_desc_get_callback_invoke() will use it as an argument. As result we invoke wrong callback.
That behaviour was in place since:
commit fcaaba6c7136 ("dmaengine: imx-dma: fix callback path in tasklet"). But after commit 4cd13c21b207 ("softirq: Let ksoftirqd do its job") things got worse, since possible delay between tasklet_schedule() from DMA irq handler and actual tasklet function execution got bigger. And that gave more time for new DMA request to be submitted and to be put into "ld_queue" list.
It has been noticed that DMA issue is causing problems for "mxc-mmc" driver. While stressing the system with heavy network traffic and writing/reading to/from sd card simultaneously the timeout may happen:
10013000.sdhci: mxcmci_watchdog: read time out (status = 0x30004900)
That often lead to file system corruption.
--- drivers/dma/imx-dma.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/dma/imx-dma.c +4 -4
@@ -624,7 +624,7 @@ static void imxdma_tasklet(unsigned long {struct imxdma_channel *imxdmac = (void *)data;struct imxdma_engine *imxdma = imxdmac->imxdma; -struct imxdma_desc *desc; +struct imxdma_desc *desc, *next_desc;unsigned long flags;spin_lock_irqsave (&imxdma->lock, flags);
@@ -654,10 +654,10 @@ static void imxdma_tasklet(unsigned longlist_move_tail (imxdmac->ld_active.next, &imxdmac->ld_free);if (!list_empty (&imxdmac->ld_queue)) { - desc = list_first_entry(&imxdmac->ld_queue, struct imxdma_desc, - node); + next_desc =list_first_entry (&imxdmac->ld_queue, + struct imxdma_desc, node);list_move_tail (imxdmac->ld_queue.next, &imxdmac->ld_active); -if (imxdma_xfer_desc (desc) <0 ) +if (imxdma_xfer_desc (next_desc) <0 )dev_warn (imxdma->dev,"%s: channel: %d couldn't xfer desc\n" , __func__, imxdmac->channel); }
PATCH 87/202 dmaengine: bcm2835: add additional defines for DMA-registers
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Martin Sperl <[email protected]>
commit e42685d7a7d5afa6278561ffd85c475eae246be3 upstream.
Add additional defines describing the DMA registers as well as adding some more documentation to those registers.
[bwh: Backported to 3.16 as dependency of commit 9e528c799d17
"dmaengine: bcm2835: Fix abort of transactions"]
--- drivers/dma/bcm2835-dma.c | 57 +++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 8 deletions(-)
drivers/dma/bcm2835-dma.c +48 -7
@@ -91,26 +91,67 @@ struct bcm2835_desc {#define BCM2835_DMA_CS 0x00#define BCM2835_DMA_ADDR 0x04 +#define BCM2835_DMA_TI 0x08#define BCM2835_DMA_SOURCE_AD 0x0c#define BCM2835_DMA_DEST_AD 0x10 -#define BCM2835_DMA_NEXTCB 0x1C +#define BCM2835_DMA_LEN 0x14 +#define BCM2835_DMA_STRIDE 0x18 +#define BCM2835_DMA_NEXTCB 0x1c +#define BCM2835_DMA_DEBUG 0x20/* DMA CS Control and Status bits */ -#define BCM2835_DMA_ACTIVE BIT(0) -#define BCM2835_DMA_INT BIT(2) +#define BCM2835_DMA_ACTIVE BIT(0)/* activate the DMA */ +#define BCM2835_DMA_END BIT(1)/* current CB has ended */ +#define BCM2835_DMA_INT BIT(2)/* interrupt status */ +#define BCM2835_DMA_DREQ BIT(3)/* DREQ state */ #define BCM2835_DMA_ISPAUSED BIT(4)/* Pause requested or not active */ #define BCM2835_DMA_ISHELD BIT(5)/* Is held by DREQ flow control */ -#define BCM2835_DMA_ERR BIT(8) +#define BCM2835_DMA_WAITING_FOR_WRITES BIT(6)/* waiting for last +* AXI-write to ack +*/ +#define BCM2835_DMA_ERR BIT(8) +#define BCM2835_DMA_PRIORITY (x) ((x & 15) << 16)/* AXI priority */ +#define BCM2835_DMA_PANIC_PRIORITY (x) ((x & 15) << 20)/* panic priority */ +/* current value of TI.BCM2835_DMA_WAIT_RESP */ +#define BCM2835_DMA_WAIT_FOR_WRITES BIT(28) +#define BCM2835_DMA_DIS_DEBUG BIT(29)/* disable debug pause signal */ #define BCM2835_DMA_ABORT BIT(30)/* Stop current CB, go to next, WO */ #define BCM2835_DMA_RESET BIT(31)/* WO, self clearing */ +/* Transfer information bits - also bcm2835_cb.info field */ #define BCM2835_DMA_INT_EN BIT(0) +#define BCM2835_DMA_TDMODE BIT(1)/* 2D-Mode */ +#define BCM2835_DMA_WAIT_RESP BIT(3)/* wait for AXI-write to be acked */ #define BCM2835_DMA_D_INC BIT(4) -#define BCM2835_DMA_D_DREQ BIT(6) +#define BCM2835_DMA_D_WIDTH BIT(5)/* 128bit writes if set */ +#define BCM2835_DMA_D_DREQ BIT(6)/* enable DREQ for destination */ +#define BCM2835_DMA_D_IGNORE BIT(7)/* ignore destination writes */ #define BCM2835_DMA_S_INC BIT(8) -#define BCM2835_DMA_S_DREQ BIT(10) +#define BCM2835_DMA_S_WIDTH BIT(9)/* 128bit writes if set */ +#define BCM2835_DMA_S_DREQ BIT(10)/* enable SREQ for source */ +#define BCM2835_DMA_S_IGNORE BIT(11)/* ignore source reads - read 0 */ +#define BCM2835_DMA_BURST_LENGTH (x) ((x & 15) << 12) +#define BCM2835_DMA_PER_MAP (x) ((x & 31) << 16)/* REQ source */ +#define BCM2835_DMA_WAIT (x) ((x & 31) << 21)/* add DMA-wait cycles */ +#define BCM2835_DMA_NO_WIDE_BURSTS BIT(26)/* no 2 beat write bursts */ -#define BCM2835_DMA_PER_MAP (x) ((x) << 16) +/* debug register bits */ +#define BCM2835_DMA_DEBUG_LAST_NOT_SET_ERR BIT(0) +#define BCM2835_DMA_DEBUG_FIFO_ERR BIT(1) +#define BCM2835_DMA_DEBUG_READ_ERR BIT(2) +#define BCM2835_DMA_DEBUG_OUTSTANDING_WRITES_SHIFT 4 +#define BCM2835_DMA_DEBUG_OUTSTANDING_WRITES_BITS 4 +#define BCM2835_DMA_DEBUG_ID_SHIFT 16 +#define BCM2835_DMA_DEBUG_ID_BITS 9 +#define BCM2835_DMA_DEBUG_STATE_SHIFT 16 +#define BCM2835_DMA_DEBUG_STATE_BITS 9 +#define BCM2835_DMA_DEBUG_VERSION_SHIFT 25 +#define BCM2835_DMA_DEBUG_VERSION_BITS 3 +#define BCM2835_DMA_DEBUG_LITE BIT(28) + +/* shared registers for all dma channels */ +#define BCM2835_DMA_INT_STATUS 0xfe0 +#define BCM2835_DMA_ENABLE 0xff0#define BCM2835_DMA_DATA_TYPE_S8 1#define BCM2835_DMA_DATA_TYPE_S16 2
PATCH 88/202 dmaengine: bcm2835: Fix interrupt race on RT
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Wunner <[email protected]>
commit f7da7782aba92593f7b82f03d2409a1c5f4db91b upstream.
If IRQ handlers are threaded (either because CONFIG_PREEMPT_RT_BASE is enabled or "threadirqs" was passed on the command line) and if system load is sufficiently high that wakeup latency of IRQ threads degrades, SPI DMA transactions on the BCM2835 occasionally break like this:
ks8851 spi0.0: SPI transfer timed out
bcm2835-dma 3f007000.dma: DMA transfer could not be terminated ks8851 spi0.0 eth2: ks8851_rdfifo: spi_sync() failed
The root cause is an assumption made by the DMA driver which is documented in a code comment in bcm2835_dma_terminate_all():
/*
* Stop DMA activity: we assume the callback will not be called
* after bcm_dma_abort() returns (even if it does, it will see
* c->desc is NULL and exit.)
*/
That assumption falls apart if the IRQ handler bcm2835_dma_callback() is
threaded: A client may terminate a descriptor and issue a new one before the IRQ handler had a chance to run. In fact the IRQ handler may miss an *arbitrary* number of descriptors. The result is the following race condition:
1. A descriptor finishes, its interrupt is deferred to the IRQ thread.
2. A client calls dma_terminate_async() which sets channel->desc = NULL.
3. The client issues a new descriptor. Because channel->desc is NULL, bcm2835_dma_issue_pending() immediately starts the descriptor.
4. Finally the IRQ thread runs and writes BCM2835_DMA_INT to the CS register to acknowledge the interrupt. This clears the ACTIVE flag, so the newly issued descriptor is paused in the middle of the transaction. Because channel->desc is not NULL, the IRQ thread finalizes the descriptor and tries to start the next one.
I see two possible solutions: The first is to call synchronize_irq() in bcm2835_dma_issue_pending() to wait until the IRQ thread has finished before issuing a new descriptor. The downside of this approach is unnecessary latency if clients desire rapidly terminating and re-issuing descriptors and don't have any use for an IRQ callback. (The SPI TX DMA channel is a case in point.)
A better alternative is to make the IRQ thread recognize that it has missed descriptors and avoid finalizing the newly issued descriptor. So first of all, set the ACTIVE flag when acknowledging the interrupt. This keeps a newly issued descriptor running.
If the descriptor was finished, the channel remains idle despite the ACTIVE flag being set. However the ACTIVE flag can then no longer be used to check whether the channel is idle, so instead check whether the register containing the current control block address is zero and finalize the current descriptor only if so.
That way, there is no impact on latency and throughput if the client doesn't care for the interrupt: Only minimal additional overhead is introduced for non-cyclic descriptors as one further MMIO read is necessary per interrupt to check for idleness of the channel. Cyclic descriptors are sped up slightly by removing one MMIO write per interrupt.
--- drivers/dma/bcm2835-dma.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-)
drivers/dma/bcm2835-dma.c +17 -13
@@ -197,7 +197,12 @@ static int bcm2835_dma_abort(void __iomelong int timeout =10000 ; cs =readl (chan_base +BCM2835_DMA_CS ); -if (!(cs &BCM2835_DMA_ACTIVE )) + +/* +* A zero control block address means the channel is idle. +* (The ACTIVE flag in the CS register is not a reliable indicator.) +*/ +if (!readl (chan_base +BCM2835_DMA_ADDR ))return 0 ;/* Write 0 to the active bit - Pause the DMA */
@@ -252,8 +257,15 @@ static irqreturn_t bcm2835_dma_callback(spin_lock_irqsave (&c->vc.lock, flags); -/* Acknowledge interrupt */ -writel (BCM2835_DMA_INT , c->chan_base +BCM2835_DMA_CS ); +/* +* Clear the INT flag to receive further interrupts. Keep the channel +* active in case the descriptor is cyclic or in case the client has +* already terminated the descriptor and issued a new one. (May happen +* if this IRQ handler is threaded.) If the channel is finished, it +* will remain idle despite the ACTIVE flag being set. +*/ +writel (BCM2835_DMA_INT |BCM2835_DMA_ACTIVE , + c->chan_base +BCM2835_DMA_CS ); d = c->desc;
@@ -262,9 +274,6 @@ static irqreturn_t bcm2835_dma_callback(vchan_cyclic_callback (&d->vd); } -/* Keep the DMA engine running */ -writel (BCM2835_DMA_ACTIVE , c->chan_base +BCM2835_DMA_CS ); -spin_unlock_irqrestore (&c->vc.lock, flags);return IRQ_HANDLED ;
@@ -507,19 +516,14 @@ static int bcm2835_dma_terminate_all(strlist_del_init (&c->node);spin_unlock (&d->lock); -/* -* Stop DMA activity: we assume the callback will not be called -* after bcm_dma_abort() returns (even if it does, it will see -* c->desc is NULL and exit.) -*/ +/* stop DMA activity */ if (c->desc) { c->desc =NULL ;bcm2835_dma_abort (c->chan_base);/* Wait for stopping */ while (--timeout) { -if (!(readl (c->chan_base +BCM2835_DMA_CS ) & -BCM2835_DMA_ACTIVE )) +if (!readl (c->chan_base +BCM2835_DMA_ADDR ))break ;cpu_relax ();
PATCH 89/202 dmaengine: bcm2835: Fix abort of transactions
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Wunner <[email protected]>
commit 9e528c799d17a4ac37d788c81440b50377dd592d upstream.
There are multiple issues with bcm2835_dma_abort() (which is called on termination of a transaction):
* The algorithm to abort the transaction first pauses the channel by clearing the ACTIVE flag in the CS register, then waits for the PAUSED flag to clear. Page 49 of the spec documents the latter as follows:
"Indicates if the DMA is currently paused and not transferring data.
This will occur if the active bit has been cleared [...]"
https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf
So the function is entering an infinite loop because it is waiting for PAUSED to clear which is always set due to the function having cleared the ACTIVE flag. The only thing that's saving it from itself is the upper bound of 10000 loop iterations.
The code comment says that the intention is to "wait for any current AXI transfer to complete", so the author probably wanted to check the WAITING_FOR_OUTSTANDING_WRITES flag instead. Amend the function accordingly.
* The CS register is only read at the beginning of the function. It needs to be read again after pausing the channel and before checking for outstanding writes, otherwise writes which were issued between the register read at the beginning of the function and pausing the channel may not be waited for.
* The function seeks to abort the transfer by writing 0 to the NEXTCONBK register and setting the ABORT and ACTIVE flags. Thereby, the 0 in NEXTCONBK is sought to be loaded into the CONBLK_AD register. However experimentation has shown this approach to not work: The CONBLK_AD register remains the same as before and the CS register contains 0x00000030 (PAUSED | DREQ_STOPS_DMA). In other words, the control block is not aborted but merely paused and it will be resumed once the next DMA transaction is started. That is absolutely not the desired behavior.
A simpler approach is to set the channel's RESET flag instead. This reliably zeroes the NEXTCONBK as well as the CS register. It requires less code and only a single MMIO write. This is also what popular user space DMA drivers do, e.g.:
https://github.com/metachris/RPIO/blob/master/source/c_pwm/pwm.c
Note that the spec is contradictory whether the NEXTCONBK register is writeable at all. On the one hand, page 41 claims:
"The value loaded into the NEXTCONBK register can be overwritten so that the linked list of Control Block data structures can be dynamically altered. However it is only safe to do this when the DMA is paused."
On the other hand, page 40 specifies:
"Only three registers in each channel's register set are directly writeable (CS, CONBLK_AD and DEBUG). The other registers (TI, SOURCE_AD, DEST_AD, TXFR_LEN, STRIDE & NEXTCONBK), are automatically loaded from a Control Block data structure held in external memory."
--- drivers/dma/bcm2835-dma.c | 41 +++++++++------------------------------ 1 file changed, 9 insertions(+), 32 deletions(-)
drivers/dma/bcm2835-dma.c +9 -32
@@ -191,13 +191,11 @@ static void bcm2835_dma_desc_free(structkfree (desc); } -static int bcm2835_dma_abort (void __iomem *chan_base) +static int bcm2835_dma_abort (struct bcm2835_chan *c) { -unsigned long cs; +void __iomem *chan_base = c->chan_base;long int timeout =10000 ; - cs =readl (chan_base +BCM2835_DMA_CS ); -/* * A zero control block address means the channel is idle. * (The ACTIVE flag in the CS register is not a reliable indicator.)
@@ -209,25 +207,16 @@ static int bcm2835_dma_abort(void __iomewritel (0 , chan_base +BCM2835_DMA_CS );/* Wait for any current AXI transfer to complete */ -while ((cs &BCM2835_DMA_ISPAUSED ) && --timeout) { +while ((readl (chan_base +BCM2835_DMA_CS ) & +BCM2835_DMA_WAITING_FOR_WRITES ) && --timeout)cpu_relax (); - cs =readl (chan_base +BCM2835_DMA_CS ); - } -/* We'll un-pause when we set of our next DMA */ +/* Peripheral might be stuck and fail to signal AXI write responses */ if (!timeout) -return -ETIMEDOUT ; - -if (!(cs &BCM2835_DMA_ACTIVE )) -return 0 ; - -/* Terminate the control block chain */ -writel (0 , chan_base +BCM2835_DMA_NEXTCB ); - -/* Abort the whole DMA */ -writel (BCM2835_DMA_ABORT |BCM2835_DMA_ACTIVE , - chan_base +BCM2835_DMA_CS ); +dev_err (c->vc.chan.device->dev, +"failed to complete outstanding writes\n" ); +writel (BCM2835_DMA_RESET , chan_base +BCM2835_DMA_CS );return 0 ; }
@@ -506,7 +495,6 @@ static int bcm2835_dma_terminate_all(str {struct bcm2835_dmadev *d =to_bcm2835_dma_dev (c->vc.chan.device);unsigned long flags; -int timeout =10000 ;LIST_HEAD (head);spin_lock_irqsave (&c->vc.lock, flags);
@@ -519,18 +507,7 @@ static int bcm2835_dma_terminate_all(str/* stop DMA activity */ if (c->desc) { c->desc =NULL ; -bcm2835_dma_abort (c->chan_base); - -/* Wait for stopping */ -while (--timeout) { -if (!readl (c->chan_base +BCM2835_DMA_ADDR )) -break ; - -cpu_relax (); - } - -if (!timeout) -dev_err (d->ddev.dev,"DMA transfer could not be terminated\n" ); +bcm2835_dma_abort (c); }vchan_get_all_descriptors (&c->vc, &head);
PATCH 90/202 perf/x86/intel/uncore: Add Node ID mask
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Kan Liang <[email protected]>
commit 9e63a7894fd302082cf3627fe90844421a6cbe7f upstream.
Some PCI uncore PMUs cannot be registered on an 8-socket system (HPE Superdome Flex).
To understand which Socket the PCI uncore PMUs belongs to, perf retrieves the local Node ID of the uncore device from CPUNODEID(0xC0) of the PCI configuration space, and the mapping between Socket ID and Node ID from GIDNIDMAP(0xD4). The Socket ID can be calculated accordingly.
The local Node ID is only available at bit 2:0, but current code doesn't mask it. If a BIOS doesn't clear the rest of the bits, an incorrect Node ID will be fetched.
Filter the Node ID by adding a mask.
--- arch/x86/kernel/cpu/perf_event_intel_uncore.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/perf_event_intel_uncore.c +3 -1
@@ -1004,6 +1004,8 @@ static struct pci_driver snbep_uncore_pc .id_table = snbep_uncore_pci_ids, }; +#define NODE_ID_MASK 0x7 +/* * build pci bus to socket mapping */
@@ -1024,7 +1026,7 @@ static int snbep_pci2phy_map_init(int de err =pci_read_config_dword (ubox_dev,0x40 , &config);if (err)break ; - nodeid = config; + nodeid = config &NODE_ID_MASK ;/* get the Node ID mapping */ err =pci_read_config_dword (ubox_dev,0x54 , &config);if (err)
PATCH 91/202 perf/core: Don't WARN() for impossible ring-buffer sizes
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mark Rutland <[email protected]>
commit 9dff0aa95a324e262ffb03f425d00e4751f3294e upstream.
The perf tool uses /proc/sys/kernel/perf_event_mlock_kb to determine how large its ringbuffer mmap should be. This can be configured to arbitrary values, which can be larger than the maximum possible allocation from kmalloc.
When this is configured to a suitably large value (e.g. thanks to the perf fuzzer), attempting to use perf record triggers a WARN_ON_ONCE() in __alloc_pages_nodemask():
WARNING: CPU: 2 PID: 5666 at mm/page_alloc.c:4511 __alloc_pages_nodemask+0x3f8/0xbc8
Let's avoid this by checking that the requested allocation is possible before calling kzalloc.
--- kernel/events/ring_buffer.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/events/ring_buffer.c +3 -0
@@ -282,6 +282,9 @@ struct ring_buffer *rb_alloc(int nr_page size =sizeof (struct ring_buffer ); size += nr_pages *sizeof (void *); +if (order_base_2 (size) >=MAX_ORDER ) + goto fail; + rb =kzalloc (size,GFP_KERNEL );if (!rb) goto fail;
PATCH 92/202 dmaengine: dmatest: unmap data on a single code-path when xfer done
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alexandru Ardelean <[email protected]>
commit 0255200bd29afc320c6ea4c1adf8bdc13a9b3c15 upstream.
After the DMA transfer is done, we don't need to call the un-mapping code in 3 places. One is enough.
[bwh: Backported to 3.16 as dependency of commit 6454368a804c
"dmaengine: dmatest: Abort test in case of mapping error"]
--- drivers/dma/dmatest.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/dma/dmatest.c +2 -4
@@ -638,14 +638,14 @@ static int dmatest_func(void *data) status =dma_async_is_tx_complete (chan, cookie,NULL ,NULL ); +dmaengine_unmap_put (um); +if (!done->done) { -dmaengine_unmap_put (um);result ("test timed out" , total_tests, src_off, dst_off, len,0 ); failed_tests++;continue ; }else if (status !=DMA_COMPLETE ) { -dmaengine_unmap_put (um); result(status == DMA_ERROR ? "completion error status" : "completion busy status", total_tests, src_off,
@@ -654,8 +654,6 @@ static int dmatest_func(void *data)continue ; } -dmaengine_unmap_put (um); -if (params->noverify) {verbose_result ("test passed" , total_tests, src_off, dst_off, len,0 );
PATCH 93/202 dmaengine: dmatest: Abort test in case of mapping error
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
commit 6454368a804c4955ccd116236037536f81e5b1f1 upstream.
In case of mapping error the DMA addresses are invalid and continuing will screw system memory or potentially something else.
[ 222.480310] dmatest: dma0chan7-copy0: summary 1 tests, 3 failures 6 iops 349 KB/s (0) ... [ 240.912725] check: Corrupted low memory at 00000000c7c75ac9 (2940 phys) = 5656000000000000 [ 240.921998] check: Corrupted low memory at 000000005715a1cd (2948 phys) = 279f2aca5595ab2b [ 240.931280] check: Corrupted low memory at 000000002f4024c0 (2950 phys) = 5e5624f349e793cf
...
Abort any test if mapping failed.
--- drivers/dma/dmatest.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-)
drivers/dma/dmatest.c +14 -18
@@ -562,11 +562,9 @@ static int dmatest_func(void *data) srcs[i] = um->addr[i] + src_off; ret =dma_mapping_error (dev->dev, um->addr[i]);if (ret) { -dmaengine_unmap_put (um);result ("src mapping error" , total_tests, src_off, dst_off, len, ret); - failed_tests++; -continue ; + goto error_unmap_continue; } um->to_cnt++; }
@@ -581,11 +579,9 @@ static int dmatest_func(void *data) DMA_BIDIRECTIONAL); ret =dma_mapping_error (dev->dev, dsts[i]);if (ret) { -dmaengine_unmap_put (um);result ("dst mapping error" , total_tests, src_off, dst_off, len, ret); - failed_tests++; -continue ; + goto error_unmap_continue; } um->bidi_cnt++; }
@@ -610,12 +606,10 @@ static int dmatest_func(void *data) }if (!tx) { -dmaengine_unmap_put (um);result ("prep error" , total_tests, src_off, dst_off, len, ret);msleep (100 ); - failed_tests++; -continue ; + goto error_unmap_continue; } done->done = false;
@@ -624,12 +618,10 @@ static int dmatest_func(void *data) cookie = tx->tx_submit (tx);if (dma_submit_error (cookie)) { -dmaengine_unmap_put (um);result ("submit error" , total_tests, src_off, dst_off, len, ret);msleep (100 ); - failed_tests++; -continue ; + goto error_unmap_continue; }dma_async_issue_pending (chan);
@@ -638,22 +630,20 @@ static int dmatest_func(void *data) status =dma_async_is_tx_complete (chan, cookie,NULL ,NULL ); -dmaengine_unmap_put (um); -if (!done->done) {result ("test timed out" , total_tests, src_off, dst_off, len,0 ); - failed_tests++; -continue ; + goto error_unmap_continue; }else if (status !=DMA_COMPLETE ) {result (status ==DMA_ERROR ?"completion error status" :"completion busy status" , total_tests, src_off, dst_off, len, ret); - failed_tests++; -continue ; + goto error_unmap_continue; } +dmaengine_unmap_put (um); +if (params->noverify) {verbose_result ("test passed" , total_tests, src_off, dst_off, len,0 );
@@ -688,6 +678,12 @@ static int dmatest_func(void *data)verbose_result ("test passed" , total_tests, src_off, dst_off, len,0 ); } + +continue ; + +error_unmap_continue: +dmaengine_unmap_put (um); + failed_tests++; } runtime =ktime_us_delta (ktime_get (), ktime);
PATCH 94/202 perf tests evsel-tp-sched: Fix bitwise operator
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Gustavo A. R. Silva" <[email protected]>
commit 489338a717a0dfbbd5a3fabccf172b78f0ac9015 upstream.
Notice that the use of the bitwise OR operator '|' always leads to true in this particular case, which seems a bit suspicious due to the context in which this expression is being used.
Fix this by using bitwise AND operator '&' instead.
This bug was detected with the help of Coccinelle.
--- tools/perf/tests/evsel-tp-sched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/evsel-tp-sched.c +1 -1
@@ -14,7 +14,7 @@ static int perf_evsel__test_field(structreturn -1 ; } - is_signed = !!(field->flags |FIELD_IS_SIGNED ); + is_signed = !!(field->flags &FIELD_IS_SIGNED );if (should_be_signed && !is_signed) {pr_debug ("%s: \"%s\" signedness(%d) is wrong, should be %d\n" , evsel->name, name, is_signed, should_be_signed);
PATCH 95/202 perf test: Fix failure of 'evsel-tp-sched' test on s390
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Richter <[email protected]>
commit 03d309711d687460d1345de8a0363f45b1c8cd11 upstream.
Commit 489338a717a0 ("perf tests evsel-tp-sched: Fix bitwise operator") causes test case 14 "Parse sched tracepoints fields" to fail on s390.
This test succeeds on x86.
In fact this test now fails on all architectures with type char treated as type unsigned char.
The root cause is the signed-ness of character arrays in the tracepoints sched_switch for structure members prev_comm and next_comm.
On s390 the output of:
[root@m35lp76 perf]# cat /sys/kernel/debug/tracing/events/sched/sched_switch/format
name: sched_switch
ID: 287
format:
field:unsigned short common_type; offset:0; size:2; signed:0;
...
field:char prev_comm[16]; offset:8; size:16; signed:0;
...
field:char next_comm[16]; offset:40; size:16; signed:0;
reveals the character arrays prev_comm and next_comm are per default unsigned char and have values in the range of 0..255.
On x86 both fields are signed as this output shows:
[root@f29]# cat /sys/kernel/debug/tracing/events/sched/sched_switch/format name: sched_switch ID: 287 format: field:unsigned short common_type; offset:0; size:2; signed:0; ... field:char prev_comm[16]; offset:8; size:16; signed:1; ... field:char next_comm[16]; offset:40; size:16; signed:1;
and the character arrays prev_comm and next_comm are per default signed char and have values in the range of -1..127. The implementation of type char is architecture specific.
Since the character arrays in both tracepoints sched_switch and sched_wakeup should contain ascii characters, simply omit the check for signedness in the test case.
Output before:
[root@m35lp76 perf]# ./perf test -F 14
14: Parse sched tracepoints fields :
--- start ---
sched:sched_switch: "prev_comm" signedness(0) is wrong, should be 1 sched:sched_switch: "next_comm" signedness(0) is wrong, should be 1 sched:sched_wakeup: "comm" signedness(0) is wrong, should be 1 ---- end ----
14: Parse sched tracepoints fields : FAILED!
[root@m35lp76 perf]#
Output after:
[root@m35lp76 perf]# ./perf test -Fv 14
14: Parse sched tracepoints fields :
--- start ---
---- end ----
Parse sched tracepoints fields: Ok
[root@m35lp76 perf]#
--- tools/perf/tests/evsel-tp-sched.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/tests/evsel-tp-sched.c +3 -3
@@ -40,7 +40,7 @@ int test__perf_evsel__tp_sched_test(voidreturn -1 ; } -if (perf_evsel__test_field (evsel,"prev_comm" ,16 , true)) +if (perf_evsel__test_field (evsel,"prev_comm" ,16 , false)) ret =-1 ;if (perf_evsel__test_field (evsel,"prev_pid" ,4 , true))
@@ -52,7 +52,7 @@ int test__perf_evsel__tp_sched_test(voidif (perf_evsel__test_field (evsel,"prev_state" ,sizeof (long ), true)) ret =-1 ; -if (perf_evsel__test_field (evsel,"next_comm" ,16 , true)) +if (perf_evsel__test_field (evsel,"next_comm" ,16 , false)) ret =-1 ;if (perf_evsel__test_field (evsel,"next_pid" ,4 , true))
@@ -65,7 +65,7 @@ int test__perf_evsel__tp_sched_test(void evsel =perf_evsel__newtp ("sched" ,"sched_wakeup" ); -if (perf_evsel__test_field (evsel,"comm" ,16 , true)) +if (perf_evsel__test_field (evsel,"comm" ,16 , false)) ret =-1 ;if (perf_evsel__test_field (evsel,"pid" ,4 , true))
PATCH 96/202 s390/qeth: fix use-after-free in error path
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Julian Wiedmann <[email protected]>
commit afa0c5904ba16d59b0454f7ee4c807dae350f432 upstream.
The error path in qeth_alloc_qdio_buffers() that takes care of cleaning up the Output Queues is buggy. It first frees the queue, but then calls qeth_clear_outq_buffers() with that very queue struct.
Make the call to qeth_clear_outq_buffers() part of the free action (in the correct order), and while at it fix the naming of the helper.
[bwh: Backported to 3.16:
- Add the qeth_free_output_queue() function, which didn't exist here
- Keep using kfree() to free to free the qeth_qdio_out_q structure]
--- drivers/s390/net/qeth_core_main.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/s390/net/qeth_core_main.c +13 -8
@@ -1288,6 +1288,15 @@ static void qeth_free_buffer_pool(struct } } +static void qeth_free_output_queue (struct qeth_qdio_out_q *q) +{ +if (!q) +return ; + +qeth_clear_outq_buffers (q,1 ); +kfree (q); +} +static void qeth_free_qdio_buffers (struct qeth_card *card) {int i, j;
@@ -1308,10 +1317,8 @@ static void qeth_free_qdio_buffers(strucqeth_free_buffer_pool (card);/* free outbound qdio_qs */ if (card->qdio.out_qs) { -for (i =0 ; i < card->qdio.no_out_queues; ++i) { -qeth_clear_outq_buffers (card->qdio.out_qs[i],1 ); -kfree (card->qdio.out_qs[i]); - } +for (i =0 ; i < card->qdio.no_out_queues; i++) +qeth_free_output_queue (card->qdio.out_qs[i]);kfree (card->qdio.out_qs); card->qdio.out_qs =NULL ; }
@@ -2483,10 +2490,8 @@ out_freeoutqbufs: card->qdio.out_qs[i]->bufs[j] =NULL ; } out_freeoutq: -while (i >0 ) { -kfree (card->qdio.out_qs[--i]); -qeth_clear_outq_buffers (card->qdio.out_qs[i],1 ); - } +while (i >0 ) +qeth_free_output_queue (card->qdio.out_qs[--i]);kfree (card->qdio.out_qs); card->qdio.out_qs =NULL ; out_freepool:
PATCH 97/202 s390/qeth: cancel close_dev work before removing a card
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Julian Wiedmann <[email protected]>
commit c2780c1a3fb724560b1d44f7976e0de17bf153c7 upstream.
A card's close_dev work is scheduled on a driver-wide workqueue. If the card is removed and freed while the work is still active, this causes a use-after-free.
So make sure that the work is completed before freeing the card.
--- drivers/s390/net/qeth_core.h | 1 + drivers/s390/net/qeth_l2_main.c | 2 ++ drivers/s390/net/qeth_l3_main.c | 1 + 3 files changed, 4 insertions(+)
drivers/s390/net/qeth_core.h +1 -0
@@ -18,6 +18,7 @@#include <linux/bitops.h> #include <linux/seq_file.h> #include <linux/ethtool.h> +#include <linux/workqueue.h> #include <net/ipv6.h> #include <net/if_inet6.h>
drivers/s390/net/qeth_l2_main.c +1 -0
@@ -924,6 +924,7 @@ static void qeth_l2_remove_device(structif (cgdev->state ==CCWGROUP_ONLINE )qeth_l2_set_offline (cgdev); +cancel_work_sync (&card->close_dev_work);if (card->dev) {unregister_netdev (card->dev);free_netdev (card->dev);
drivers/s390/net/qeth_l3_main.c +1 -0
@@ -3342,6 +3342,7 @@ static void qeth_l3_remove_device(structif (cgdev->state ==CCWGROUP_ONLINE )qeth_l3_set_offline (cgdev); +cancel_work_sync (&card->close_dev_work);if (card->dev) {unregister_netdev (card->dev);free_netdev (card->dev);
PATCH 98/202 s390/qeth: conclude all event processing before offlining a card
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Julian Wiedmann <[email protected]>
commit c0a2e4d10d9366ada133a8ae4ff2f32397f8b15b upstream.
Work for Bridgeport events is currently placed on a driver-wide workqueue. If the card is removed and freed while any such work is still active, this causes a use-after-free.
So put the events on a per-card queue, where we can control their lifetime. As we also don't want stale events to last beyond an offline & online cycle, flush this queue when setting the card offline.
[bwh: Backported to 3.16:
- Add gdev parameter to qeth_alloc_card(), as done upstream by commit 121ca39aa558 "s390/qeth: uninstall IRQ handler on device removal"
- Adjust context]
--- drivers/s390/net/qeth_core.h | 2 +- drivers/s390/net/qeth_core_main.c | 10 ++++++++-- drivers/s390/net/qeth_l2_main.c | 6 ++++-- drivers/s390/net/qeth_l3_main.c | 2 ++ 4 files changed, 15 insertions(+), 5 deletions(-)
drivers/s390/net/qeth_core.h +1 -1
@@ -793,6 +793,7 @@ struct qeth_card {struct qeth_seqno seqno;struct qeth_card_options options; +struct workqueue_struct *event_wq;wait_queue_head_t wait_q;spinlock_t vlanlock;spinlock_t mclock;
@@ -903,7 +904,6 @@ extern const struct attribute_group *qetextern const struct attribute_group qeth_device_attr_group;extern const struct attribute_group qeth_device_blkt_group;extern const struct device_type qeth_generic_devtype; -extern struct workqueue_struct *qeth_wq;const char *qeth_get_cardname_short (struct qeth_card *);int qeth_realloc_buffer_pool (struct qeth_card *,int );
drivers/s390/net/qeth_core_main.c +10 -4
@@ -67,8 +67,7 @@ static void qeth_notify_skbs(struct qethstatic void qeth_release_skbs (struct qeth_qdio_out_buffer *buf);static int qeth_init_qdio_out_buf (struct qeth_qdio_out_q *,int ); -struct workqueue_struct *qeth_wq; -EXPORT_SYMBOL_GPL (qeth_wq); +static struct workqueue_struct *qeth_wq;static void qeth_close_dev_handler (struct work_struct *work) {
@@ -1497,7 +1496,7 @@ static void qeth_core_sl_print(struct se CARD_BUS_ID(card), card->info.mcl_level); } -static struct qeth_card *qeth_alloc_card (void ) +static struct qeth_card *qeth_alloc_card (struct ccwgroup_device *gdev) {struct qeth_card *card;
@@ -1511,6 +1510,10 @@ static struct qeth_card *qeth_alloc_cardQETH_DBF_TEXT (SETUP ,0 ,"iptbdnom" ); goto out_card; } + + card->event_wq =alloc_ordered_workqueue ("%s" ,0 ,dev_name (&gdev->dev)); +if (!card->event_wq) + goto out_wq;if (qeth_setup_channel (&card->read)) goto out_ip;if (qeth_setup_channel (&card->write))
@@ -1523,6 +1526,8 @@ static struct qeth_card *qeth_alloc_card out_channel:qeth_clean_channel (&card->read); out_ip: +destroy_workqueue (card->event_wq); +out_wq:kfree (card->ip_tbd_list); out_card:kfree (card);
@@ -4869,6 +4874,7 @@ static void qeth_core_free_card(struct qQETH_DBF_HEX (SETUP ,2 , &card,sizeof (void *));qeth_clean_channel (&card->read);qeth_clean_channel (&card->write); +destroy_workqueue (card->event_wq);kfree (card->ip_tbd_list);qeth_free_qdio_buffers (card);unregister_service_level (&card->qeth_service_level);
@@ -5332,7 +5338,7 @@ static int qeth_core_probe_device(structQETH_DBF_TEXT_ (SETUP ,2 ,"%s" ,dev_name (&gdev->dev)); - card =qeth_alloc_card (); + card =qeth_alloc_card (gdev);if (!card) {QETH_DBF_TEXT_ (SETUP ,2 ,"1err%d" , -ENOMEM ); rc = -ENOMEM ;
drivers/s390/net/qeth_l2_main.c +4 -2
@@ -407,6 +407,8 @@ static int qeth_l2_stop_card(struct qethqeth_clear_cmd_buffers (&card->read);qeth_clear_cmd_buffers (&card->write); } + +flush_workqueue (card->event_wq);return rc; }
@@ -1542,7 +1544,7 @@ static void qeth_bridge_state_change(str data->card = card;memcpy (&data->qports, qports,sizeof (struct qeth_sbp_state_change ) + extrasize); -queue_work (qeth_wq, &data->worker); +queue_work (card->event_wq, &data->worker); }struct qeth_bridge_host_data {
@@ -1614,7 +1616,7 @@ static void qeth_bridge_host_event(struc data->card = card;memcpy (&data->hostevs, hostevs,sizeof (struct qeth_ipacmd_addr_change ) + extrasize); -queue_work (qeth_wq, &data->worker); +queue_work (card->event_wq, &data->worker); }/* SETBRIDGEPORT support; sending commands */
drivers/s390/net/qeth_l3_main.c +2 -0
@@ -2180,6 +2180,8 @@ static int qeth_l3_stop_card(struct qethqeth_clear_cmd_buffers (&card->read);qeth_clear_cmd_buffers (&card->write); } + +flush_workqueue (card->event_wq);return rc; }
PATCH 99/202 MIPS: Remove function size check in get_frame_info()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jun-Ru Chang <[email protected]>
commit 2b424cfc69728224fcb5fad138ea7260728e0901 upstream.
Patch (b6c7a324df37b "MIPS: Fix get_frame_info() handling of microMIPS function size.") introduces additional function size check for microMIPS by only checking insn between ip and ip + func_size. However, func_size in get_frame_info() is always 0 if KALLSYMS is not enabled. This causes get_frame_info() to return immediately without calculating correct frame_size, which in turn causes "Can't analyze schedule() prologue" warning messages at boot time.
This patch removes func_size check, and let the frame_size check run up to 128 insns for both MIPS and microMIPS.
--- arch/mips/kernel/process.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
arch/mips/kernel/process.c +3 -4
@@ -373,7 +373,7 @@ static inline int is_sp_move_ins(union mstatic int get_frame_info (struct mips_frame_info *info) {bool is_mmips =IS_ENABLED (CONFIG_CPU_MICROMIPS ); -union mips_instruction insn, *ip, *ip_end; +union mips_instruction insn, *ip;const unsigned int max_insns =128 ;unsigned int last_insn_size =0 ;unsigned int i;
@@ -385,10 +385,9 @@ static int get_frame_info(struct mips_frif (!ip) goto err; - ip_end = (void *)ip + info->func_size; - -for (i =0 ; i < max_insns && ip < ip_end; i++) { +for (i =0 ; i < max_insns; i++) { ip = (void *)ip + last_insn_size; +if (is_mmips &&mm_insn_16bit (ip->halfword[0 ])) { insn.word = ip->halfword[0 ] <<16 ; last_insn_size =2 ;
PATCH 100/202 net: dsa: slave: Don't propagate flag changes on down slave interfaces
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Rundong Ge <[email protected]>
commit 17ab4f61b8cd6f9c38e9d0b935d86d73b5d0d2b5 upstream.
The unbalance of master's promiscuity or allmulti will happen after ifdown and ifup a slave interface which is in a bridge.
When we ifdown a slave interface , both the 'dsa_slave_close' and 'dsa_slave_change_rx_flags' will clear the master's flags. The flags of master will be decrease twice.
In the other hand, if we ifup the slave interface again, since the slave's flags were cleared the 'dsa_slave_open' won't set the master's flag, only 'dsa_slave_change_rx_flags' that triggered by 'br_add_if' will set the master's flags. The flags of master is increase once.
Only propagating flag changes when a slave interface is up makes sure this does not happen. The 'vlan_dev_change_rx_flags' had the same problem and was fixed, and changes here follows that fix.
--- net/dsa/slave.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
net/dsa/slave.c +8 -5
@@ -117,11 +117,14 @@ static void dsa_slave_change_rx_flags(st {struct dsa_slave_priv *p =netdev_priv (dev);struct net_device *master = p->parent->dst->master_netdev; - -if (change &IFF_ALLMULTI ) -dev_set_allmulti (master, dev->flags &IFF_ALLMULTI ?1 :-1 ); -if (change &IFF_PROMISC ) -dev_set_promiscuity (master, dev->flags &IFF_PROMISC ?1 :-1 ); +if (dev->flags &IFF_UP ) { +if (change &IFF_ALLMULTI ) +dev_set_allmulti (master, + dev->flags &IFF_ALLMULTI ?1 :-1 ); +if (change &IFF_PROMISC ) +dev_set_promiscuity (master, + dev->flags &IFF_PROMISC ?1 :-1 ); + } }static void dsa_slave_set_rx_mode (struct net_device *dev)
PATCH 101/202 drm/vmwgfx: Return error code from vmw_execbuf_copy_fence_user
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Hellstrom <[email protected]>
commit 728354c005c36eaf44b6e5552372b67e60d17f56 upstream.
The function was unconditionally returning 0, and a caller would have to rely on the returned fence pointer being NULL to detect errors. However, the function vmw_execbuf_copy_fence_user() would expect a non-zero error code in that case and would BUG otherwise.
So make sure we return a proper non-zero error code if the fence pointer returned is NULL.
--- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +1 -1
@@ -2326,7 +2326,7 @@ int vmw_execbuf_fence_commands(struct dr *p_fence =NULL ; } -return 0 ; +return ret; }/**
PATCH 102/202 drm/vmwgfx: Fix setting of dma masks
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Hellstrom <[email protected]>
commit 4cbfa1e6c09e98450aab3240e5119b0ab2c9795b upstream.
Previously we set only the dma mask and not the coherent mask. Fix that. Also, for clarity, make sure both are initially set to 64 bits.
--- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +6 -3
@@ -567,13 +567,16 @@ out_fixup:static int vmw_dma_masks (struct vmw_private *dev_priv) {struct drm_device *dev = dev_priv->dev; +int ret =0 ; -if (intel_iommu_enabled && + ret =dma_set_mask_and_coherent (dev->dev,DMA_BIT_MASK (64 )); +if (dev_priv->map_mode != vmw_dma_phys && (sizeof (unsigned long ) ==4 || vmw_restrict_dma_mask)) {DRM_INFO ("Restricting DMA addresses to 44 bits.\n" ); -return dma_set_mask (dev->dev,DMA_BIT_MASK (44 )); +return dma_set_mask_and_coherent (dev->dev,DMA_BIT_MASK (44 )); } -return 0 ; + +return ret; }#else static int vmw_dma_masks (struct vmw_private *dev_priv)
PATCH 103/202 ALSA: compress: Fix stop handling on compressed capture streams
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Charles Keepax <[email protected]>
commit 4f2ab5e1d13d6aa77c55f4914659784efd776eb4 upstream.
It is normal user behaviour to start, stop, then start a stream again without closing it. Currently this works for compressed playback streams but not capture ones.
The states on a compressed capture stream go directly from OPEN to PREPARED, unlike a playback stream which moves to SETUP and waits for a write of data before moving to PREPARED. Currently however, when a stop is sent the state is set to SETUP for both types of streams. This leaves a capture stream in the situation where a new start can't be sent as that requires the state to be PREPARED and a new set_params can't be sent as that requires the state to be OPEN. The only option being to close the stream, and then reopen.
Correct this issues by allowing snd_compr_drain_notify to set the state depending on the stream direction, as we already do in set_params.
--- include/sound/compress_driver.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
include/sound/compress_driver.h +5 -1
@@ -176,7 +176,11 @@ static inline void snd_compr_drain_notifif (snd_BUG_ON (!stream))return ; - stream->runtime->state =SNDRV_PCM_STATE_SETUP ; +if (stream->direction ==SND_COMPRESS_PLAYBACK ) + stream->runtime->state =SNDRV_PCM_STATE_SETUP ; +else + stream->runtime->state =SNDRV_PCM_STATE_PREPARED ; +wake_up (&stream->runtime->sleep); }
PATCH 104/202 mtd: rawnand: gpmi: fix MX28 bus master lockup problem
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Martin Kepplinger <[email protected]>
commit d5d27fd9826b59979b184ec288e4812abac0e988 upstream.
Disable BCH soft reset according to MX23 erratum #2847 ("BCH soft reset may cause bus master lock up") for MX28 too. It has the same problem.
Observed problem: once per 100,000+ MX28 reboots NAND read failed on DMA timeout errors:
[ 1.770823] UBI: attaching mtd3 to ubi0 [ 2.768088] gpmi_nand: DMA timeout, last DMA :1 [ 3.958087] gpmi_nand: BCH timeout, last DMA :1 [ 4.156033] gpmi_nand: Error in ECC-based read: -110 [ 4.161136] UBI warning: ubi_io_read: error -110 while reading 64 bytes from PEB 0:0, read only 0 bytes, retry [ 4.171283] step 1 error [ 4.173846] gpmi_nand: Chip: 0, Error -1
Without BCH soft reset we successfully executed 1,000,000 MX28 reboots.
I have a quote from NXP regarding this problem, from July 18th 2016:
"As the i.MX23 and i.MX28 are of the same generation, they share many characteristics. Unfortunately, also the erratas may be shared. In case of the documented erratas and the workarounds, you can also apply the workaround solution of one device on the other one. This have been reported, but I’m afraid that there are not an estimated date for updating the Errata documents.
Please accept our apologies for any inconveniences this may cause."
--- drivers/mtd/nand/gpmi-nand/gpmi-lib.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/mtd/nand/gpmi-nand/gpmi-lib.c +6 -7
@@ -168,9 +168,10 @@ int gpmi_init(struct gpmi_nand_data *thi/* * Reset BCH here, too. We got failures otherwise :( -* See later BCH reset for explanation of MX23 handling +* See later BCH reset for explanation of MX23 and MX28 handling */ - ret =gpmi_reset_block (r->bch_regs,GPMI_IS_MX23 (this)); + ret =gpmi_reset_block (r->bch_regs, +GPMI_IS_MX23 (this) ||GPMI_IS_MX28 (this));if (ret) goto err_out;
@@ -275,12 +276,10 @@ int bch_set_geometry(struct gpmi_nand_da/* * Due to erratum #2847 of the MX23, the BCH cannot be soft reset on this * chip, otherwise it will lock up. So we skip resetting BCH on the MX23. -* On the other hand, the MX28 needs the reset, because one case has been -* seen where the BCH produced ECC errors constantly after 10000 -* consecutive reboots. The latter case has not been seen on the MX23 -* yet, still we don't know if it could happen there as well. +* and MX28. */ - ret =gpmi_reset_block (r->bch_regs,GPMI_IS_MX23 (this)); + ret =gpmi_reset_block (r->bch_regs, +GPMI_IS_MX23 (this) ||GPMI_IS_MX28 (this));if (ret) goto err_out;
PATCH 105/202 Input: bma150 - register input device after setting private data
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan Bakker <[email protected]>
commit 90cc55f067f6ca0e64e5e52883ece47d8af7b67b upstream.
Otherwise we introduce a race condition where userspace can request input before we're ready leading to null pointer dereference such as
input: bma150 as /devices/platform/i2c-gpio-2/i2c-5/5-0038/input/input3
Unable to handle kernel NULL pointer dereference at virtual address 00000018 pgd = (ptrval) [00000018] *pgd=55dac831, *pte=00000000, *ppte=00000000 Internal error: Oops: 17 [#1] PREEMPT ARM Modules linked in: bma150 input_polldev [last unloaded: bma150] CPU: 0 PID: 2870 Comm: accelerometer Not tainted 5.0.0-rc3-dirty #46 Hardware name: Samsung S5PC110/S5PV210-based board PC is at input_event+0x8/0x60 LR is at bma150_report_xyz+0x9c/0xe0 [bma150] pc : [<80450f70>] lr : [<7f0a614c>] psr: 800d0013
sp : a4c1fd78 ip : 00000081 fp : 00020000
r10: 00000000 r9 : a5e2944c r8 : a7455000
r7 : 00000016 r6 : 00000101 r5 : a7617940 r4 : 80909048
r3 : fffffff2 r2 : 00000000 r1 : 00000003 r0 : 00000000
Flags: Nzcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none
Control: 10c5387d Table: 54e34019 DAC: 00000051
Process accelerometer (pid: 2870, stack limit = 0x(ptrval))
Stackck: (0xa4c1fd78 to 0xa4c20000)
fd60: fffffff3 fc813f6c
fd80: 40410581 d7530ce3 a5e2817c a7617f00 a5e29404 a5e2817c 00000000 7f008324
fda0: a5e28000 8044f59c a5fdd9d0 a5e2945c a46a4a00 a5e29668 a7455000 80454f10
fdc0: 80909048 a5e29668 a5fdd9d0 a46a4a00 806316d0 00000000 a46a4a00 801df5f0
fde0: 00000000 d7530ce3 a4c1fec0 a46a4a00 00000000 a5fdd9d0 a46a4a08 801df53c
fe00: 00000000 801d74bc a4c1fec0 00000000 a4c1ff70 00000000 a7038da8 00000000
fe20: a46a4a00 801e91fc a411bbe0 801f2e88 00000004 00000000 80909048 00000041
fe40: 00000000 00020000 00000000 dead4ead a6a88da0 00000000 ffffe000 806fcae8
fe60: a4c1fec8 00000000 80909048 00000002 a5fdd9d0 a7660110 a411bab0 00000001
fe80: dead4ead ffffffff ffffffff a4c1fe8c a4c1fe8c d7530ce3 20000013 80909048
fea0: 80909048 a4c1ff70 00000001 fffff000 a4c1e000 00000005 00026038 801eabd8
fec0: a7660110 a411bab0 b9394901 00000006 a696201b 76fb3000 00000000 a7039720
fee0: a5fdd9d0 00000101 00000002 00000096 00000000 00000000 00000000 a4c1ff00
ff00: a6b310f4 805cb174 a6b310f4 00000010 00000fe0 00000010 a4c1e000 d7530ce3
ff20: 00000003 a5f41400 a5f41424 00000000 a6962000 00000000 00000003 00000002
ff40: ffffff9c 000a0000 80909048 d7530ce3 a6962000 00000003 80909048 ffffff9c
ff60: a6962000 801d890c 00000000 00000000 00020000 a7590000 00000004 00000100
ff80: 00000001 d7530ce3 000288b8 00026320 000288b8 00000005 80101204 a4c1e000
ffa0: 00000005 80101000 000288b8 00026320 000288b8 000a0000 00000000 00000000
ffc0: 000288b8 00026320 000288b8 00000005 7eef3bac 000264e8 00028ad8 00026038
ffe0: 00000005 7eef3300 76f76e91 76f78546 800d0030 000288b8 00000000 00000000 [<80450f70>] (input_event) from [<a5e2817c>] (0xa5e2817c)
Code: e1a08148 eaffffa8 e351001f 812fff1e (e590c018) ---[ end trace 1c691ee85f2ff243 ]---
--- drivers/input/misc/bma150.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/input/misc/bma150.c +5 -4
@@ -483,13 +483,14 @@ static int bma150_register_input_device( idev->close = bma150_irq_close;input_set_drvdata (idev, bma150); + bma150->input = idev; + error =input_register_device (idev);if (error) {input_free_device (idev);return error; } - bma150->input = idev;return 0 ; }
@@ -512,15 +513,15 @@ static int bma150_register_polled_devicebma150_init_input_device (bma150, ipoll_dev->input); + bma150->input_polled = ipoll_dev; + bma150->input = ipoll_dev->input; + error =input_register_polled_device (ipoll_dev);if (error) {input_free_polled_device (ipoll_dev);return error; } - bma150->input_polled = ipoll_dev; - bma150->input = ipoll_dev->input; -return 0 ; }
PATCH 106/202 libata: Add NOLPM quirk for SAMSUNG MZ7TE512HMHP-000L1 SSD
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit dd957493baa586f1431490f97f9c7c45eaf8ab10 upstream.
We've received a bugreport that using LPM with a SAMSUNG MZ7TE512HMHP-000L1 SSD leads to system instability, we already have a quirk for the MZ7TD256HAFV-000L9, which is also a Samsun EVO 840 / PM851 OEM model, so it seems some of these models have a LPM issue.
This commits adds a NOLPM quirk for the model string from the new bugeport, to avoid the reported stability issues.
--- drivers/ata/libata-core.c | 1 + 1 file changed, 1 insertion(+)
drivers/ata/libata-core.c +1 -0
@@ -4250,6 +4250,7 @@ static const struct ata_blacklist_entry { "SAMSUNG MZMPC128HBFU-000MV", "CXM14M1Q", ATA_HORKAGE_NOLPM, }, { "SAMSUNG SSD PM830 mSATA *", "CXM13D1Q", ATA_HORKAGE_NOLPM, }, { "SAMSUNG MZ7TD256HAFV-000L9", NULL, ATA_HORKAGE_NOLPM, }, + { "SAMSUNG MZ7TE512HMHP-000L1", "EXT06L0Q", ATA_HORKAGE_NOLPM, }, /* devices that don't properly handle queued TRIM commands */ { "Micron_M500IT_*", "MU01", ATA_HORKAGE_NO_NCQ_TRIM, },
PATCH 107/202 arc: Use get_signal() signal_setup_done()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit f6dd2a3f1f8d8df640cfa2d60f85c0b818af1593 upstream.
Use the more generic functions get_signal() signal_setup_done() for signal delivery.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"
- Adjust to apply after "ARC: signal handling robustify"]
--- arch/arc/kernel/signal.c | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-)
arch/arc/kernel/signal.c +15 -24
@@ -189,14 +189,13 @@ static inline int map_sig(int sig) }static int -setup_rt_frame (int signo,struct k_sigaction *ka,siginfo_t *info, -sigset_t *set,struct pt_regs *regs) +setup_rt_frame (struct ksignal *ksig,sigset_t *set,struct pt_regs *regs) {struct rt_sigframe __user *sf;unsigned int magic =0 ;int err =0 ; - sf =get_sigframe (ka, regs,sizeof (struct rt_sigframe )); + sf =get_sigframe (&ksig->ka, regs,sizeof (struct rt_sigframe ));if (!sf)return 1 ;
@@ -215,8 +214,8 @@ setup_rt_frame(int signo, struct k_sigac* #2: struct siginfo * #3: struct ucontext (completely populated) */ -if (unlikely (ka->sa.sa_flags &SA_SIGINFO )) { - err |=copy_siginfo_to_user (&sf->info, info); +if (unlikely (ksig->ka.sa.sa_flags &SA_SIGINFO )) { + err |=copy_siginfo_to_user (&sf->info, &ksig->info); err |=__put_user (0 , &sf->uc.uc_flags); err |=__put_user (NULL , &sf->uc.uc_link); err |=__save_altstack (&sf->uc.uc_stack, regs->sp);
@@ -237,19 +236,19 @@ setup_rt_frame(int signo, struct k_sigacreturn err;/* #1 arg to the user Signal handler */ - regs->r0 =map_sig (signo); + regs->r0 =map_sig (ksig->sig);/* setup PC of user space signal handler */ - regs->ret = (unsigned long )ka->sa.sa_handler; + regs->ret = (unsigned long )ksig->ka.sa.sa_handler;/* * handler returns using sigreturn stub provided already by userpsace * If not, nuke the process right away */ -if (!(ka->sa.sa_flags &SA_RESTORER )) +if (!(ksig->ka.sa.sa_flags &SA_RESTORER ))return 1 ; - regs->blink = (unsigned long )ka->sa.sa_restorer; + regs->blink = (unsigned long )ksig->ka.sa.sa_restorer;/* User Stack for signal handler will be above the frame just carved */ regs->sp = (unsigned long )sf;
@@ -311,38 +310,30 @@ static void arc_restart_syscall(struct k* OK, we're invoking a handler */ static void -handle_signal (unsigned long sig,struct k_sigaction *ka,siginfo_t *info, -struct pt_regs *regs) +handle_signal (struct ksignal *ksig,struct pt_regs *regs) {sigset_t *oldset =sigmask_to_save ();int failed;/* Set up the stack frame */ - failed =setup_rt_frame (sig, ka, info, oldset, regs); + failed =setup_rt_frame (ksig, oldset, regs); -if (failed) -force_sigsegv (sig, current); -else -signal_delivered (sig, info, ka, regs,0 ); +signal_setup_done (failed, ksig,0 ); }void do_signal (struct pt_regs *regs) { -struct k_sigaction ka; -siginfo_t info; -int signr; +struct ksignal ksig;int restart_scall; - signr =get_signal_to_deliver (&info, &ka, regs,NULL ); - restart_scall =in_syscall (regs) &&syscall_restartable (regs); -if (signr >0 ) { +if (get_signal (&ksig)) {if (restart_scall) { -arc_restart_syscall (&ka, regs); +arc_restart_syscall (&ksig.ka, regs);syscall_wont_restart (regs);/* No more restarts */ } -handle_signal (signr, &ka, &info, regs); +handle_signal (&ksig, regs);return ; }
PATCH 108/202 arm64: Use get_signal() signal_setup_done()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit 00554fa4f80279db92f82c4f52c8ae72711f173e upstream.
Use the more generic functions get_signal() signal_setup_done() for signal delivery.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- arch/arm64/include/asm/signal32.h | 11 ++++--- arch/arm64/kernel/signal.c | 48 +++++++++++++------------------ arch/arm64/kernel/signal32.c | 14 ++++----- 3 files changed, 32 insertions(+), 41 deletions(-)
arch/arm64/include/asm/signal32.h +5 -6
@@ -24,22 +24,21 @@extern const compat_ulong_t aarch32_sigret_code[6 ]; -int compat_setup_frame (int usig,struct k_sigaction *ka,sigset_t *set, +int compat_setup_frame (int usig,struct ksignal *ksig,sigset_t *set,struct pt_regs *regs); -int compat_setup_rt_frame (int usig,struct k_sigaction *ka,siginfo_t *info, -sigset_t *set,struct pt_regs *regs); +int compat_setup_rt_frame (int usig,struct ksignal *ksig,sigset_t *set, +struct pt_regs *regs);void compat_setup_restart_syscall (struct pt_regs *regs);#else -static inline int compat_setup_frame (int usid,struct k_sigaction *ka, +static inline int compat_setup_frame (int usid,struct ksignal *ksig,sigset_t *set,struct pt_regs *regs) {return -ENOSYS ; } -static inline int compat_setup_rt_frame (int usig,struct k_sigaction *ka, -siginfo_t *info,sigset_t *set, +static inline int compat_setup_rt_frame (int usig,struct ksignal *ksig,sigset_t *set,struct pt_regs *regs) {return -ENOSYS ;
arch/arm64/kernel/signal.c +20 -28
116 lines not on this page · raw message
arch/arm64/kernel/signal32.c +7 -7
@@ -543,18 +543,18 @@ static int compat_setup_sigframe(struct/* * 32-bit signal handling routines called from signal.c */ -int compat_setup_rt_frame (int usig,struct k_sigaction *ka,siginfo_t *info, +int compat_setup_rt_frame (int usig,struct ksignal *ksig,sigset_t *set,struct pt_regs *regs) {struct compat_rt_sigframe __user *frame;int err =0 ; - frame =compat_get_sigframe (ka, regs,sizeof (*frame)); + frame =compat_get_sigframe (&ksig->ka, regs,sizeof (*frame));if (!frame)return 1 ; - err |=copy_siginfo_to_user32 (&frame->info, info); + err |=copy_siginfo_to_user32 (&frame->info, &ksig->info);__put_user_error (0 , &frame->sig.uc.uc_flags, err);__put_user_error (0 , &frame->sig.uc.uc_link, err);
@@ -564,7 +564,7 @@ int compat_setup_rt_frame(int usig, stru err |=compat_setup_sigframe (&frame->sig, regs, set);if (err ==0 ) { -compat_setup_return (regs, ka, frame->sig.retcode, frame, usig); +compat_setup_return (regs, &ksig->ka, frame->sig.retcode, frame, usig); regs->regs[1 ] = (compat_ulong_t )(unsigned long )&frame->info; regs->regs[2 ] = (compat_ulong_t )(unsigned long )&frame->sig.uc; }
@@ -572,13 +572,13 @@ int compat_setup_rt_frame(int usig, strureturn err; } -int compat_setup_frame (int usig,struct k_sigaction *ka,sigset_t *set, +int compat_setup_frame (int usig,struct ksignal *ksig,sigset_t *set,struct pt_regs *regs) {struct compat_sigframe __user *frame;int err =0 ; - frame =compat_get_sigframe (ka, regs,sizeof (*frame)); + frame =compat_get_sigframe (&ksig->ka, regs,sizeof (*frame));if (!frame)return 1 ;
@@ -587,7 +587,7 @@ int compat_setup_frame(int usig, struct err |=compat_setup_sigframe (frame, regs, set);if (err ==0 ) -compat_setup_return (regs, ka, frame->retcode, frame, usig); +compat_setup_return (regs, &ksig->ka, frame->retcode, frame, usig);return err; }
PATCH 109/202 avr32: Use get_signal() signal_setup_done()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit d809709a8845954a95c2ac86c13bd0dfd549c1ae upstream.
Use the more generic functions get_signal() signal_setup_done() for signal delivery.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- arch/avr32/kernel/signal.c | 43 ++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 25 deletions(-)
arch/avr32/kernel/signal.c +18 -25
@@ -138,13 +138,12 @@ get_sigframe(struct k_sigaction *ka, str }static int -setup_rt_frame (int sig,struct k_sigaction *ka,siginfo_t *info, -sigset_t *set,struct pt_regs *regs) +setup_rt_frame (struct ksignal *ksig,sigset_t *set,struct pt_regs *regs) {struct rt_sigframe __user *frame;int err =0 ; - frame =get_sigframe (ka, regs,sizeof (*frame)); + frame =get_sigframe (&ksig->ka, regs,sizeof (*frame)); err = -EFAULT ;if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame))) goto out;
@@ -164,7 +163,7 @@ setup_rt_frame(int sig, struct k_sigacti err =__put_user (0x3008d733 | (__NR_rt_sigreturn <<20 ), &frame->retcode); - err |=copy_siginfo_to_user (&frame->info, info); + err |=copy_siginfo_to_user (&frame->info, &ksig->info);/* Set up the ucontext */ err |=__put_user (0 , &frame->uc.uc_flags);
@@ -176,12 +175,12 @@ setup_rt_frame(int sig, struct k_sigactiif (err) goto out; - regs->r12 = sig; + regs->r12 = ksig->sig; regs->r11 = (unsigned long ) &frame->info; regs->r10 = (unsigned long ) &frame->uc; regs->sp = (unsigned long ) frame; -if (ka->sa.sa_flags &SA_RESTORER ) - regs->lr = (unsigned long )ka->sa.sa_restorer; +if (ksig->ka.sa.sa_flags &SA_RESTORER ) + regs->lr = (unsigned long )ksig->ka.sa.sa_restorer;else {printk (KERN_NOTICE "[%s:%d] did not set SA_RESTORER\n" , current->comm, current->pid);
@@ -189,10 +188,10 @@ setup_rt_frame(int sig, struct k_sigacti }pr_debug ("SIG deliver [%s:%d]: sig=%d sp=0x%lx pc=0x%lx->0x%p lr=0x%lx\n" , - current->comm, current->pid, sig, regs->sp, - regs->pc, ka->sa.sa_handler, regs->lr); + current->comm, current->pid, ksig->sig, regs->sp, + regs->pc, ksig->ka.sa.sa_handler, regs->lr); - regs->pc = (unsigned long ) ka->sa.sa_handler; + regs->pc = (unsigned long )ksig->ka.sa.sa_handler; out:return err;
@@ -208,15 +207,14 @@ static inline void setup_syscall_restart }static inline void -handle_signal (unsigned long sig,struct k_sigaction *ka,siginfo_t *info, -struct pt_regs *regs,int syscall) +handle_signal (struct ksignal *ksig,struct pt_regs *regs,int syscall) {int ret;/* * Set up the stack frame */ - ret =setup_rt_frame (sig, ka, info,sigmask_to_save (), regs); + ret =setup_rt_frame (ksig,sigmask_to_save (), regs);/* * Check that the resulting registers are sane
@@ -226,10 +224,7 @@ handle_signal(unsigned long sig, struct/* * Block the signal if we were successful. */ -if (ret !=0 ) -force_sigsegv (sig, current); -else -signal_delivered (sig, info, ka, regs,0 ); +signal_setup_done (ret, ksig,0 ); }/*
@@ -239,9 +234,7 @@ handle_signal(unsigned long sig, struct*/ static void do_signal (struct pt_regs *regs,int syscall) { -siginfo_t info; -int signr; -struct k_sigaction ka; +struct ksignal ksig;/* * We want the common case to go fast, which is why we may in
@@ -251,18 +244,18 @@ static void do_signal(struct pt_regs *reif (!user_mode (regs))return ; - signr =get_signal_to_deliver (&info, &ka, regs,NULL ); +get_signal (&ksig);if (syscall) {switch (regs->r12) {case -ERESTART_RESTARTBLOCK :case -ERESTARTNOHAND : -if (signr >0 ) { +if (ksig.sig >0 ) { regs->r12 = -EINTR ;break ; }/* fall through */ case -ERESTARTSYS : -if (signr >0 && !(ka.sa.sa_flags &SA_RESTART )) { +if (ksig.sig >0 && !(ksig.ka.sa.sa_flags &SA_RESTART )) { regs->r12 = -EINTR ;break ; }
@@ -272,13 +265,13 @@ static void do_signal(struct pt_regs *re } } -if (signr ==0 ) { +if (!ksig.sig) {/* No signal to deliver -- put the saved sigmask back */ restore_saved_sigmask ();return ; } -handle_signal (signr, &ka, &info, regs, syscall); +handle_signal (&ksig, regs, syscall); } asmlinkage void do_notify_resume(struct pt_regs *regs, struct thread_info *ti)
PATCH 110/202 blackfin: Use get_signal() signal_setup_done()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit 1270cff147a39f7da5b25225dca6ca3132ca6130 upstream.
Use the more generic functions get_signal() signal_setup_done() for signal delivery.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- arch/blackfin/kernel/signal.c | 39 +++++++++++++++-------------------- 1 file changed, 17 insertions(+), 22 deletions(-)
arch/blackfin/kernel/signal.c +17 -22
@@ -152,23 +152,22 @@ static inline void *get_sigframe(struct }static int -setup_rt_frame (int sig,struct k_sigaction *ka,siginfo_t * info, -sigset_t * set,struct pt_regs *regs) +setup_rt_frame (struct ksignal *ksig,sigset_t *set,struct pt_regs *regs) {struct rt_sigframe *frame;int err =0 ; - frame =get_sigframe (ka, regs,sizeof (*frame)); + frame =get_sigframe (&ksig->ka, regs,sizeof (*frame)); err |=__put_user ((current_thread_info ()->exec_domain &¤t_thread_info ()->exec_domain->signal_invmap - && sig <32 + && ksig->sig <32 ?current_thread_info ()->exec_domain-> - signal_invmap[sig] : sig), &frame->sig); + signal_invmap[ksig->sig] : ksig->sig), &frame->sig); err |=__put_user (&frame->info, &frame->pinfo); err |=__put_user (&frame->uc, &frame->puc); - err |=copy_siginfo_to_user (&frame->info, info); + err |=copy_siginfo_to_user (&frame->info, &ksig->info);/* Create the ucontext. */ err |=__put_user (0 , &frame->uc.uc_flags);
@@ -183,7 +182,7 @@ setup_rt_frame(int sig, struct k_sigacti/* Set up registers for signal handler */ if (current->personality &FDPIC_FUNCPTRS ) {struct fdpic_func_descriptor __user *funcptr = - (struct fdpic_func_descriptor *) ka->sa.sa_handler; + (struct fdpic_func_descriptor *) ksig->ka.sa.sa_handler;u32 pc, p3; err |=__get_user (pc, &funcptr->text); err |=__get_user (p3, &funcptr->GOT);
@@ -192,7 +191,7 @@ setup_rt_frame(int sig, struct k_sigacti regs->pc = pc; regs->p3 = p3; }else - regs->pc = (unsigned long )ka->sa.sa_handler; + regs->pc = (unsigned long )ksig->ka.sa.sa_handler;wrusp ((unsigned long )frame); regs->rets =SIGRETURN_STUB ;
@@ -237,20 +236,19 @@ handle_restart(struct pt_regs *regs, str* OK, we're invoking a handler */ static void -handle_signal (int sig,siginfo_t *info,struct k_sigaction *ka, -struct pt_regs *regs) +handle_signal (struct ksignal *ksig,struct pt_regs *regs) { +int ret; +/* are we from a system call? to see pt_regs->orig_p0 */ if (regs->orig_p0 >=0 )/* If so, check system call restarting.. */ -handle_restart (regs, ka,1 ); +handle_restart (regs, &ksig->ka,1 );/* set up the stack frame */ -if (setup_rt_frame (sig, ka, info,sigmask_to_save (), regs) <0 ) -force_sigsegv (sig, current); -else -signal_delivered (sig, info, ka, regs, -test_thread_flag (TIF_SINGLESTEP )); + ret =setup_rt_frame (ksig,sigmask_to_save (), regs); + +signal_setup_done (ret, ksig,test_thread_flag (TIF_SINGLESTEP )); }/*
@@ -264,16 +262,13 @@ handle_signal(int sig, siginfo_t *info,*/ asmlinkage void do_signal(struct pt_regs *regs) { -siginfo_t info; -int signr; -struct k_sigaction ka; +struct ksignal ksig; current->thread.esp0 = (unsigned long )regs; - signr =get_signal_to_deliver (&info, &ka, regs,NULL ); -if (signr >0 ) { +if (get_signal (&ksig)) {/* Whee! Actually deliver the signal. */ -handle_signal (signr, &info, &ka, regs); +handle_signal (&ksig, regs);return ; }
PATCH 111/202 c6x: Use get_signal() signal_setup_done()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit e19c025bc9a184ed9c5daf06ffb89abc81d1696a upstream.
Use the more generic functions get_signal() signal_setup_done() for signal delivery.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- arch/c6x/kernel/signal.c | 43 +++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 25 deletions(-)
arch/c6x/kernel/signal.c +18 -25
@@ -146,21 +146,21 @@ static inline void __user *get_sigframe(return (void __user *)((sp - framesize) & ~7 ); } -static int setup_rt_frame (int signr,struct k_sigaction *ka,siginfo_t *info, -sigset_t *set,struct pt_regs *regs) +static int setup_rt_frame (struct ksignal *ksig,sigset_t *set, +struct pt_regs *regs) {struct rt_sigframe __user *frame;unsigned long __user *retcode;int err =0 ; - frame =get_sigframe (ka, regs,sizeof (*frame)); + frame =get_sigframe (&ksig->ka, regs,sizeof (*frame));if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame))) - goto segv_and_exit; +return -EFAULT ; err |=__put_user (&frame->info, &frame->pinfo); err |=__put_user (&frame->uc, &frame->puc); - err |=copy_siginfo_to_user (&frame->info, info); + err |=copy_siginfo_to_user (&frame->info, &ksig->info);/* Clear all the bits of the ucontext we don't use. */ err |=__clear_user (&frame->uc, offsetof(struct ucontext , uc_mcontext));
@@ -188,7 +188,7 @@ static int setup_rt_frame(int signr, str#undef COPYif (err) - goto segv_and_exit; +return -EFAULT ;flush_icache_range ((unsigned long ) &frame->retcode, (unsigned long ) &frame->retcode +RETCODE_SIZE );
@@ -198,10 +198,10 @@ static int setup_rt_frame(int signr, str/* Change user context to branch to signal handler */ regs->sp = (unsigned long ) frame -8 ; regs->b3 = (unsigned long ) retcode; - regs->pc = (unsigned long ) ka->sa.sa_handler; + regs->pc = (unsigned long ) ksig->ka.sa.sa_handler;/* Give the signal number to the handler */ - regs->a4 = signr; + regs->a4 = ksig->sig;/* * For realtime signals we must also set the second and third
@@ -212,10 +212,6 @@ static int setup_rt_frame(int signr, str regs->a6 = (unsigned long )&frame->uc;return 0 ; - -segv_and_exit: -force_sigsegv (signr, current); -return -EFAULT ; } static inline void
@@ -245,10 +241,11 @@ do_restart:/* * handle the actual delivery of a signal to userspace */ -static void handle_signal (int sig, -siginfo_t *info,struct k_sigaction *ka, -struct pt_regs *regs,int syscall) +static void handle_signal (struct ksignal *ksig,struct pt_regs *regs, +int syscall) { +int ret; +/* Are we from a system call? */ if (syscall) {/* If so, check system call restarting.. */
@@ -259,7 +256,7 @@ static void handle_signal(int sig,break ;case -ERESTARTSYS : -if (!(ka->sa.sa_flags &SA_RESTART )) { +if (!(ksig->ka.sa.sa_flags &SA_RESTART )) { regs->a4 = -EINTR ;break ; }
@@ -272,9 +269,8 @@ static void handle_signal(int sig, }/* Set up the stack frame */ -if (setup_rt_frame (sig, ka, info,sigmask_to_save (), regs) <0 ) -return ; -signal_delivered (sig, info, ka, regs,0 ); + ret =setup_rt_frame (ksig,sigmask_to_save (), regs); +signal_setup_done (ret, ksig,0 ); }/*
@@ -282,18 +278,15 @@ static void handle_signal(int sig,*/ static void do_signal (struct pt_regs *regs,int syscall) { -struct k_sigaction ka; -siginfo_t info; -int signr; +struct ksignal ksig;/* we want the common case to go fast, which is why we may in certain * cases get here from kernel mode */ if (!user_mode (regs))return ; - signr =get_signal_to_deliver (&info, &ka, regs,NULL ); -if (signr >0 ) { -handle_signal (signr, &info, &ka, regs, syscall); +if (get_signal (&ksig)) { +handle_signal (&ksig, regs, syscall);return ; }
PATCH 112/202 cris: Use get_signal() signal_setup_done()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit fa0197722eb7559a6a9733881bbb8d9e76364f33 upstream.
Use the more generic functions get_signal() signal_setup_done() for signal delivery.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- arch/cris/arch-v10/kernel/signal.c | 79 +++++++++++++----------------- arch/cris/arch-v32/kernel/signal.c | 77 ++++++++++++----------------- 2 files changed, 63 insertions(+), 93 deletions(-)
arch/cris/arch-v10/kernel/signal.c +33 -46
@@ -228,33 +228,33 @@ get_sigframe(struct k_sigaction *ka, str* user-mode trampoline. */ -static int setup_frame (int sig,struct k_sigaction *ka, -sigset_t *set,struct pt_regs *regs) +static int setup_frame (struct ksignal *ksig,sigset_t *set, +struct pt_regs *regs) {struct sigframe __user *frame;unsigned long return_ip;int err =0 ; - frame =get_sigframe (ka, regs,sizeof (*frame)); + frame =get_sigframe (&ksig->ka, regs,sizeof (*frame));if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame))) - goto give_sigsegv; +return -EFAULT ; err |=setup_sigcontext (&frame->sc, regs, set->sig[0 ]);if (err) - goto give_sigsegv; +return -EFAULT ;if (_NSIG_WORDS >1 ) { err |=__copy_to_user (frame->extramask, &set->sig[1 ],sizeof (frame->extramask)); }if (err) - goto give_sigsegv; +return -EFAULT ;/* Set up to return from userspace. If provided, use a stub already in userspace. */ -if (ka->sa.sa_flags &SA_RESTORER ) { - return_ip = (unsigned long )ka->sa.sa_restorer; +if (ksig->ka.sa.sa_flags &SA_RESTORER ) { + return_ip = (unsigned long )ksig->ka.sa.sa_restorer; }else {/* trampoline - the desired return ip is the retcode itself */ return_ip = (unsigned long )&frame->retcode;
@@ -265,42 +265,38 @@ static int setup_frame(int sig, struct k }if (err) - goto give_sigsegv; +return -EFAULT ;/* Set up registers for signal handler */ - regs->irp = (unsigned long ) ka->sa.sa_handler;/* what we enter NOW */ + regs->irp = (unsigned long ) ksig->ka.sa.sa_handler;/* what we enter NOW */ regs->srp = return_ip;/* what we enter LATER */ - regs->r10 = sig;/* first argument is signo */ + regs->r10 = ksig->sig;/* first argument is signo */ /* actually move the usp to reflect the stacked frame */ wrusp ((unsigned long )frame);return 0 ; - -give_sigsegv: -force_sigsegv (sig, current); -return -EFAULT ; } -static int setup_rt_frame (int sig,struct k_sigaction *ka,siginfo_t *info, -sigset_t *set,struct pt_regs *regs) +static int setup_rt_frame (struct ksignal *ksig,sigset_t *set, +struct pt_regs *regs) {struct rt_sigframe __user *frame;unsigned long return_ip;int err =0 ; - frame =get_sigframe (ka, regs,sizeof (*frame)); + frame =get_sigframe (&ksig->ka, regs,sizeof (*frame));if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame))) - goto give_sigsegv; +return -EFAULT ; err |=__put_user (&frame->info, &frame->pinfo); err |=__put_user (&frame->uc, &frame->puc); - err |=copy_siginfo_to_user (&frame->info, info); + err |=copy_siginfo_to_user (&frame->info, &ksig->info);if (err) - goto give_sigsegv; +return -EFAULT ;/* Clear all the bits of the ucontext we don't use. */ err |=__clear_user (&frame->uc, offsetof(struct ucontext , uc_mcontext));
@@ -312,12 +308,12 @@ static int setup_rt_frame(int sig, struc err |=__save_altstack (&frame->uc.uc_stack,rdusp ());if (err) - goto give_sigsegv; +return -EFAULT ;/* Set up to return from userspace. If provided, use a stub already in userspace. */ -if (ka->sa.sa_flags &SA_RESTORER ) { - return_ip = (unsigned long )ka->sa.sa_restorer; +if (ksig->ka.sa.sa_flags &SA_RESTORER ) { + return_ip = (unsigned long )ksig->ka.sa.sa_restorer; }else {/* trampoline - the desired return ip is the retcode itself */ return_ip = (unsigned long )&frame->retcode;
@@ -329,18 +325,18 @@ static int setup_rt_frame(int sig, struc }if (err) - goto give_sigsegv; +return -EFAULT ;/* TODO what is the current->exec_domain stuff and invmap ? */ /* Set up registers for signal handler */ /* What we enter NOW */ - regs->irp = (unsigned long ) ka->sa.sa_handler; + regs->irp = (unsigned long ) ksig->ka.sa.sa_handler;/* What we enter LATER */ regs->srp = return_ip;/* First argument is signo */ - regs->r10 = sig; + regs->r10 = ksig->sig;/* Second argument is (siginfo_t *) */ regs->r11 = (unsigned long )&frame->info;/* Third argument is unused */
@@ -350,19 +346,14 @@ static int setup_rt_frame(int sig, strucwrusp ((unsigned long )frame);return 0 ; - -give_sigsegv: -force_sigsegv (sig, current); -return -EFAULT ; }/* * OK, we're invoking a handler */ -static inline void handle_signal (int canrestart,unsigned long sig, -siginfo_t *info,struct k_sigaction *ka, -struct pt_regs *regs) +static inline void handle_signal (int canrestart,struct ksignal *ksig, +struct pt_regs *regs) {sigset_t *oldset =sigmask_to_save ();int ret;
@@ -383,7 +374,7 @@ static inline void handle_signal(int can/* ERESTARTSYS means to restart the syscall if * there is no handler or the handler was * registered with SA_RESTART */ -if (!(ka->sa.sa_flags &SA_RESTART )) { +if (!(ksig->ka.sa.sa_flags &SA_RESTART )) { regs->r10 = -EINTR ;break ; }
@@ -396,13 +387,12 @@ static inline void handle_signal(int can }/* Set up the stack frame */ -if (ka->sa.sa_flags &SA_SIGINFO ) - ret =setup_rt_frame (sig, ka, info, oldset, regs); +if (ksig->ka.sa.sa_flags &SA_SIGINFO ) + ret =setup_rt_frame (ksig, oldset, regs);else - ret =setup_frame (sig, ka, oldset, regs); + ret =setup_frame (ksig, oldset, regs); -if (ret ==0 ) -signal_delivered (sig, info, ka, regs,0 ); +signal_setup_done (ret, ksig,0 ); }/*
@@ -419,9 +409,7 @@ static inline void handle_signal(int canvoid do_signal (int canrestart,struct pt_regs *regs) { -siginfo_t info; -int signr; -struct k_sigaction ka; +struct ksignal ksig;/* * We want the common case to go fast, which
@@ -432,10 +420,9 @@ void do_signal(int canrestart, struct ptif (!user_mode (regs))return ; - signr =get_signal_to_deliver (&info, &ka, regs,NULL ); -if (signr >0 ) { +if (get_signal (&ksig)) {/* Whee! Actually deliver the signal. */ -handle_signal (canrestart, signr, &info, &ka, regs); +handle_signal (canrestart, &ksig, regs);return ; }
arch/cris/arch-v32/kernel/signal.c +30 -47
203 lines not on this page · raw message
PATCH 113/202 frv: Use get_signal() signal_setup_done()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit 720f36b983224ac52b6acdd8b646ce30f6b38763 upstream.
Use the more generic functions get_signal() signal_setup_done() for signal delivery.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- arch/frv/kernel/signal.c | 99 ++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 59 deletions(-)
arch/frv/kernel/signal.c +41 -60
@@ -180,17 +180,17 @@ static inline void __user *get_sigframe(/* * */ -static int setup_frame (int sig,struct k_sigaction *ka,sigset_t *set) +static int setup_frame (struct ksignal *ksig,sigset_t *set) {struct sigframe __user *frame; -int rsig; +int rsig, sig = ksig->sig;set_fs (USER_DS ); - frame =get_sigframe (ka,sizeof (*frame)); + frame =get_sigframe (&ksig->ka,sizeof (*frame));if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame))) - goto give_sigsegv; +return -EFAULT ; rsig = sig; if (sig < 32 &&
@@ -199,22 +199,22 @@ static int setup_frame(int sig, struct k rsig = __current_thread_info->exec_domain->signal_invmap[sig];if (__put_user (rsig, &frame->sig) <0 ) - goto give_sigsegv; +return -EFAULT ;if (setup_sigcontext (&frame->sc, set->sig[0 ])) - goto give_sigsegv; +return -EFAULT ;if (_NSIG_WORDS >1 ) {if (__copy_to_user (frame->extramask, &set->sig[1 ],sizeof (frame->extramask))) - goto give_sigsegv; +return -EFAULT ; }/* Set up to return from userspace. If provided, use a stub * already in userspace. */ -if (ka->sa.sa_flags &SA_RESTORER ) { -if (__put_user (ka->sa.sa_restorer, &frame->pretcode) <0 ) - goto give_sigsegv; +if (ksig->ka.sa.sa_flags &SA_RESTORER ) { +if (__put_user (ksig->ka.sa.sa_restorer, &frame->pretcode) <0 ) +return -EFAULT ; }else {/* Set up the following code on the stack:
@@ -224,7 +224,7 @@ static int setup_frame(int sig, struct kif (__put_user ((__sigrestore_t )frame->retcode, &frame->pretcode) ||__put_user (0x8efc0000 |__NR_sigreturn, &frame->retcode[0 ]) ||__put_user (0xc0700000 , &frame->retcode[1 ])) - goto give_sigsegv; +return -EFAULT ;flush_icache_range ((unsigned long ) frame->retcode, (unsigned long ) (frame->retcode +2 ));
@@ -233,14 +233,14 @@ static int setup_frame(int sig, struct k/* Set up registers for the signal handler */ if (current->personality &FDPIC_FUNCPTRS ) {struct fdpic_func_descriptor __user *funcptr = - (struct fdpic_func_descriptor __user *) ka->sa.sa_handler; + (struct fdpic_func_descriptor __user *) ksig->ka.sa.sa_handler;struct fdpic_func_descriptor desc;if (copy_from_user (&desc, funcptr,sizeof (desc))) - goto give_sigsegv; +return -EFAULT ; __frame->pc = desc.text; __frame->gr15 = desc.GOT; }else { - __frame->pc = (unsigned long ) ka->sa.sa_handler; + __frame->pc = (unsigned long ) ksig->ka.sa.sa_handler; __frame->gr15 =0 ; }
@@ -255,29 +255,23 @@ static int setup_frame(int sig, struct k#endif return 0 ; - -give_sigsegv: -force_sigsegv (sig, current); -return -EFAULT ; - }/* end setup_frame() */ /*****************************************************************************/ /* * */ -static int setup_rt_frame (int sig,struct k_sigaction *ka,siginfo_t *info, -sigset_t *set) +static int setup_rt_frame (struct ksignal *ksig,sigset_t *set) {struct rt_sigframe __user *frame; -int rsig; +int rsig, sig = ksig->sig;set_fs (USER_DS ); - frame =get_sigframe (ka,sizeof (*frame)); + frame =get_sigframe (&ksig->ka,sizeof (*frame));if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame))) - goto give_sigsegv; +return -EFAULT ; rsig = sig; if (sig < 32 &&
@@ -288,28 +282,28 @@ static int setup_rt_frame(int sig, strucif (__put_user (rsig, &frame->sig) ||__put_user (&frame->info, &frame->pinfo) ||__put_user (&frame->uc, &frame->puc)) - goto give_sigsegv; +return -EFAULT ; -if (copy_siginfo_to_user (&frame->info, info)) - goto give_sigsegv; +if (copy_siginfo_to_user (&frame->info, &ksig->info)) +return -EFAULT ;/* Create the ucontext. */ if (__put_user (0 , &frame->uc.uc_flags) ||__put_user (NULL , &frame->uc.uc_link) ||__save_altstack (&frame->uc.uc_stack, __frame->sp)) - goto give_sigsegv; +return -EFAULT ;if (setup_sigcontext (&frame->uc.uc_mcontext, set->sig[0 ])) - goto give_sigsegv; +return -EFAULT ;if (__copy_to_user (&frame->uc.uc_sigmask, set,sizeof (*set))) - goto give_sigsegv; +return -EFAULT ;/* Set up to return from userspace. If provided, use a stub * already in userspace. */ -if (ka->sa.sa_flags &SA_RESTORER ) { -if (__put_user (ka->sa.sa_restorer, &frame->pretcode)) - goto give_sigsegv; +if (ksig->ka.sa.sa_flags &SA_RESTORER ) { +if (__put_user (ksig->ka.sa.sa_restorer, &frame->pretcode)) +return -EFAULT ; }else {/* Set up the following code on the stack:
@@ -319,7 +313,7 @@ static int setup_rt_frame(int sig, strucif (__put_user ((__sigrestore_t )frame->retcode, &frame->pretcode) ||__put_user (0x8efc0000 |__NR_rt_sigreturn, &frame->retcode[0 ]) ||__put_user (0xc0700000 , &frame->retcode[1 ])) - goto give_sigsegv; +return -EFAULT ;flush_icache_range ((unsigned long ) frame->retcode, (unsigned long ) (frame->retcode +2 ));
@@ -328,14 +322,14 @@ static int setup_rt_frame(int sig, struc/* Set up registers for signal handler */ if (current->personality &FDPIC_FUNCPTRS ) {struct fdpic_func_descriptor __user *funcptr = - (struct fdpic_func_descriptor __user *) ka->sa.sa_handler; + (struct fdpic_func_descriptor __user *) ksig->ka.sa.sa_handler;struct fdpic_func_descriptor desc;if (copy_from_user (&desc, funcptr,sizeof (desc))) - goto give_sigsegv; +return -EFAULT ; __frame->pc = desc.text; __frame->gr15 = desc.GOT; }else { - __frame->pc = (unsigned long ) ka->sa.sa_handler; + __frame->pc = (unsigned long ) ksig->ka.sa.sa_handler; __frame->gr15 =0 ; }
@@ -349,21 +343,15 @@ static int setup_rt_frame(int sig, struc sig, current->comm, current->pid, frame, __frame->pc, frame->pretcode);#endif -return 0 ; -give_sigsegv: -force_sigsegv (sig, current); -return -EFAULT ; - }/* end setup_rt_frame() */ /*****************************************************************************/ /* * OK, we're invoking a handler */ -static void handle_signal (unsigned long sig,siginfo_t *info, -struct k_sigaction *ka) +static void handle_signal (struct ksignal *ksig) {sigset_t *oldset =sigmask_to_save ();int ret;
@@ -378,7 +366,7 @@ static void handle_signal(unsigned longbreak ;case -ERESTARTSYS : -if (!(ka->sa.sa_flags &SA_RESTART )) { +if (!(ksig->ka.sa.sa_flags &SA_RESTART )) { __frame->gr8 = -EINTR ;break ; }
@@ -392,16 +380,12 @@ static void handle_signal(unsigned long }/* Set up the stack frame */ -if (ka->sa.sa_flags &SA_SIGINFO ) - ret =setup_rt_frame (sig, ka, info, oldset); +if (ksig->ka.sa.sa_flags &SA_SIGINFO ) + ret =setup_rt_frame (ksig, oldset);else - ret =setup_frame (sig, ka, oldset); + ret =setup_frame (ksig, oldset); -if (ret) -return ; - -signal_delivered (sig, info, ka, __frame, -test_thread_flag (TIF_SINGLESTEP )); +signal_setup_done (ret, ksig,test_thread_flag (TIF_SINGLESTEP )); }/* end handle_signal() */ /*****************************************************************************/
@@ -412,13 +396,10 @@ static void handle_signal(unsigned long*/ static void do_signal (void ) { -struct k_sigaction ka; -siginfo_t info; -int signr; - - signr =get_signal_to_deliver (&info, &ka, __frame,NULL ); -if (signr >0 ) { -handle_signal (signr, &info, &ka); +struct ksignal ksig; + +if (get_signal (&ksig)) { +handle_signal (&ksig);return ; }
PATCH 114/202 hexagon: Use get_signal() signal_setup_done()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit ac443624490f7033aefd06713e7761aee5977de3 upstream.
Use the more generic functions get_signal() signal_setup_done() for signal delivery.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- arch/hexagon/kernel/signal.c | 45 +++++++++++++++--------------------- 1 file changed, 18 insertions(+), 27 deletions(-)
arch/hexagon/kernel/signal.c +18 -27
@@ -112,20 +112,20 @@ static int restore_sigcontext(struct pt_/* * Setup signal stack frame with siginfo structure */ -static int setup_rt_frame (int signr,struct k_sigaction *ka,siginfo_t *info, -sigset_t *set,struct pt_regs *regs) +static int setup_rt_frame (struct ksignal *ksig,sigset_t *set, +struct pt_regs *regs) {int err =0 ;struct rt_sigframe __user *frame;struct hexagon_vdso *vdso = current->mm->context.vdso; - frame =get_sigframe (ka, regs,sizeof (struct rt_sigframe )); + frame =get_sigframe (&ksig->ka, regs,sizeof (struct rt_sigframe ));if (!access_ok (VERIFY_WRITE , frame,sizeof (struct rt_sigframe ))) - goto sigsegv; +return -EFAULT ; -if (copy_siginfo_to_user (&frame->info, info)) - goto sigsegv; +if (copy_siginfo_to_user (&frame->info, &ksig->info)) +return -EFAULT ;/* The on-stack signal trampoline is no longer executed; * however, the libgcc signal frame unwinding code checks for
@@ -137,29 +137,26 @@ static int setup_rt_frame(int signr, str err |=__copy_to_user (&frame->uc.uc_sigmask, set,sizeof (*set)); err |=__save_altstack (&frame->uc.uc_stack,user_stack_pointer (regs));if (err) - goto sigsegv; +return -EFAULT ;/* Load r0/r1 pair with signumber/siginfo pointer... */ regs->r0100 = ((unsigned long long )((unsigned long )&frame->info) <<32 ) - | (unsigned long long )signr; + | (unsigned long long )ksig->sig; regs->r02 = (unsigned long ) &frame->uc; regs->r31 = (unsigned long ) vdso->rt_signal_trampoline;pt_psp (regs) = (unsigned long ) frame; -pt_set_elr (regs, (unsigned long )ka->sa.sa_handler); +pt_set_elr (regs, (unsigned long )ksig->ka.sa.sa_handler);return 0 ; - -sigsegv: -force_sigsegv (signr, current); -return -EFAULT ; }/* * Setup invocation of signal handler */ -static void handle_signal (int sig,siginfo_t *info,struct k_sigaction *ka, -struct pt_regs *regs) +static void handle_signal (struct ksignal *ksig,struct pt_regs *regs) { +int ret; +/* * If we're handling a signal that aborted a system call, * set up the error return value before adding the signal
@@ -173,7 +170,7 @@ static void handle_signal(int sig, sigin regs->r00 = -EINTR ;break ;case -ERESTARTSYS : -if (!(ka->sa.sa_flags &SA_RESTART )) { +if (!(ksig->ka.sa.sa_flags &SA_RESTART )) { regs->r00 = -EINTR ;break ; }
@@ -193,11 +190,9 @@ static void handle_signal(int sig, sigin* only set up the rt_frame flavor. */ /* If there was an error on setup, no signal was delivered. */ -if (setup_rt_frame (sig, ka, info,sigmask_to_save (), regs) <0 ) -return ; + ret =setup_rt_frame (ksig,sigmask_to_save (), regs); -signal_delivered (sig, info, ka, regs, -test_thread_flag (TIF_SINGLESTEP )); +signal_setup_done (ret, ksig,test_thread_flag (TIF_SINGLESTEP )); }/*
@@ -205,17 +200,13 @@ static void handle_signal(int sig, sigin*/ void do_signal (struct pt_regs *regs) { -struct k_sigaction sigact; -siginfo_t info; -int signo; +struct ksignal ksig;if (!user_mode (regs))return ; - signo =get_signal_to_deliver (&info, &sigact, regs,NULL ); - -if (signo >0 ) { -handle_signal (signo, &info, &sigact, regs); +if (get_signal (&ksig)) { +handle_signal (&ksig, regs);return ; }
PATCH 115/202 ia64: Use get_signal() signal_setup_done()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit 98c20309b97fc30001adf643cf876125f334fd8a upstream.
Use the more generic functions get_signal() signal_setup_done() for signal delivery.
This inverts also the return codes of force_sigsegv_info() and setup_frame() to follow the kernel convention.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- arch/ia64/kernel/signal.c | 46 ++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 25 deletions(-)
arch/ia64/kernel/signal.c +21 -25
@@ -309,12 +309,11 @@ force_sigsegv_info (int sig, void __user si.si_uid =from_kuid_munged (current_user_ns (),current_uid ()); si.si_addr = addr;force_sig_info (SIGSEGV , &si, current); -return 0 ; +return 1 ; }static long -setup_frame (int sig,struct k_sigaction *ka,siginfo_t *info,sigset_t *set, -struct sigscratch *scr) +setup_frame (struct ksignal *ksig,sigset_t *set,struct sigscratch *scr) {extern char __kernel_sigtramp[];unsigned long tramp_addr, new_rbs =0 , new_sp;
@@ -323,7 +322,7 @@ setup_frame (int sig, struct k_sigaction new_sp = scr->pt.r12; tramp_addr = (unsigned long ) __kernel_sigtramp; -if (ka->sa.sa_flags &SA_ONSTACK ) { +if (ksig->ka.sa.sa_flags &SA_ONSTACK ) {int onstack =sas_ss_flags (new_sp);if (onstack ==0 ) {
@@ -347,29 +346,29 @@ setup_frame (int sig, struct k_sigaction*/ check_sp = (new_sp -sizeof (*frame)) & -STACK_ALIGN ;if (!likely (on_sig_stack (check_sp))) -return force_sigsegv_info (sig, (void __user *) +return force_sigsegv_info (ksig->sig, (void __user *) check_sp); } } frame = (void __user *) ((new_sp -sizeof (*frame)) & -STACK_ALIGN );if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame))) -return force_sigsegv_info (sig, frame); +return force_sigsegv_info (ksig->sig, frame); - err =__put_user (sig, &frame->arg0); + err =__put_user (ksig->sig, &frame->arg0); err |=__put_user (&frame->info, &frame->arg1); err |=__put_user (&frame->sc, &frame->arg2); err |=__put_user (new_rbs, &frame->sc.sc_rbs_base); err |=__put_user (0 , &frame->sc.sc_loadrs);/* initialize to zero */ - err |=__put_user (ka->sa.sa_handler, &frame->handler); + err |=__put_user (ksig->ka.sa.sa_handler, &frame->handler); - err |=copy_siginfo_to_user (&frame->info, info); + err |=copy_siginfo_to_user (&frame->info, &ksig->info); err |=__save_altstack (&frame->sc.sc_stack, scr->pt.r12); err |=setup_sigcontext (&frame->sc, set, scr);if (unlikely (err)) -return force_sigsegv_info (sig, frame); +return force_sigsegv_info (ksig->sig, frame); scr->pt.r12 = (unsigned long ) frame -16 ;/* new stack pointer */ scr->pt.ar_fpsr =FPSR_DEFAULT ;/* reset fpsr for signal handler */
@@ -394,22 +393,20 @@ setup_frame (int sig, struct k_sigaction#if DEBUG_SIG printk ("SIG deliver (%s:%d): sig=%d sp=%lx ip=%lx handler=%p\n" , - current->comm, current->pid, sig, scr->pt.r12, frame->sc.sc_ip, frame->handler); + current->comm, current->pid, ksig->sig, scr->pt.r12, frame->sc.sc_ip, frame->handler);#endif -return 1 ; +return 0 ; }static long -handle_signal (unsigned long sig,struct k_sigaction *ka,siginfo_t *info, -struct sigscratch *scr) +handle_signal (struct ksignal *ksig,struct sigscratch *scr) { -if (!setup_frame (sig, ka, info,sigmask_to_save (), scr)) -return 0 ; +int ret =setup_frame (ksig,sigmask_to_save (), scr); -signal_delivered (sig, info, ka, &scr->pt, -test_thread_flag (TIF_SINGLESTEP )); +if (!ret) +signal_setup_done (ret, ksig,test_thread_flag (TIF_SINGLESTEP )); -return 1 ; +return ret; }/*
@@ -419,17 +416,16 @@ handle_signal (unsigned long sig, structvoid ia64_do_signal (struct sigscratch *scr,long in_syscall) { -struct k_sigaction ka; -siginfo_t info;long restart = in_syscall;long errno = scr->pt.r8; +struct ksignal ksig;/* * This only loops in the rare cases of handle_signal() failing, in which case we * need to push through a forced SIGSEGV. */ while (1 ) { -int signr =get_signal_to_deliver (&info, &ka, &scr->pt,NULL ); +get_signal (&ksig);/* * get_signal_to_deliver() may have run a debugger (via notify_parent())
@@ -446,7 +442,7 @@ ia64_do_signal (struct sigscratch *scr,*/ restart =0 ; -if (signr <=0 ) +if (ksig.sig <=0 )break ;if (unlikely (restart)) {
@@ -458,7 +454,7 @@ ia64_do_signal (struct sigscratch *scr,break ;case ERESTARTSYS : -if ((ka.sa.sa_flags &SA_RESTART ) ==0 ) { +if ((ksig.ka.sa.sa_flags &SA_RESTART ) ==0 ) { scr->pt.r8 =EINTR ;/* note: scr->pt.r10 is already -1 */ break ;
@@ -473,7 +469,7 @@ ia64_do_signal (struct sigscratch *scr,* Whee! Actually deliver the signal. If the delivery failed, we need to * continue to iterate in this loop so we can deliver the SIGSEGV... */ -if (handle_signal (signr, &ka, &info, scr)) +if (handle_signal (&ksig, scr))return ; }
PATCH 116/202 m32r: Use get_signal() signal_setup_done()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit 0f5bef660a7c3b030eb60ceb29e3b2d89f894f56 upstream.
Use the more generic functions get_signal() signal_setup_done() for signal delivery.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- arch/m32r/kernel/signal.c | 47 +++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 27 deletions(-)
arch/m32r/kernel/signal.c +20 -27
@@ -173,17 +173,17 @@ get_sigframe(struct k_sigaction *ka, unsreturn (void __user *)((sp - frame_size) &-8ul ); } -static int setup_rt_frame (int sig,struct k_sigaction *ka,siginfo_t *info, -sigset_t *set,struct pt_regs *regs) +static int setup_rt_frame (struct ksignal *ksig,sigset_t *set, +struct pt_regs *regs) {struct rt_sigframe __user *frame;int err =0 ; -int signal; +int signal, sig = ksig->sig; - frame =get_sigframe (ka, regs->spu,sizeof (*frame)); + frame =get_sigframe (&ksig->ka, regs->spu,sizeof (*frame));if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame))) - goto give_sigsegv; +return -EFAULT ; signal =current_thread_info ()->exec_domain &¤t_thread_info ()->exec_domain->signal_invmap
@@ -193,13 +193,13 @@ static int setup_rt_frame(int sig, struc err |=__put_user (signal, &frame->sig);if (err) - goto give_sigsegv; +return -EFAULT ; err |=__put_user (&frame->info, &frame->pinfo); err |=__put_user (&frame->uc, &frame->puc); - err |=copy_siginfo_to_user (&frame->info, info); + err |=copy_siginfo_to_user (&frame->info, &ksig->info);if (err) - goto give_sigsegv; +return -EFAULT ;/* Create the ucontext. */ err |=__put_user (0 , &frame->uc.uc_flags);
@@ -208,17 +208,17 @@ static int setup_rt_frame(int sig, struc err |=setup_sigcontext (&frame->uc.uc_mcontext, regs, set->sig[0 ]); err |=__copy_to_user (&frame->uc.uc_sigmask, set,sizeof (*set));if (err) - goto give_sigsegv; +return -EFAULT ;/* Set up to return from userspace. */ - regs->lr = (unsigned long )ka->sa.sa_restorer; + regs->lr = (unsigned long )ksig->ka.sa.sa_restorer;/* Set up registers for signal handler */ regs->spu = (unsigned long )frame; regs->r0 = signal;/* Arg for signal handler */ regs->r1 = (unsigned long )&frame->info; regs->r2 = (unsigned long )&frame->uc; - regs->bpc = (unsigned long )ka->sa.sa_handler; + regs->bpc = (unsigned long )ksig->ka.sa.sa_handler;set_fs (USER_DS );
@@ -228,10 +228,6 @@ static int setup_rt_frame(int sig, struc#endif return 0 ; - -give_sigsegv: -force_sigsegv (sig, current); -return -EFAULT ; }static int prev_insn (struct pt_regs *regs)
@@ -252,9 +248,10 @@ static int prev_insn(struct pt_regs *reg*/ static void -handle_signal (unsigned long sig,struct k_sigaction *ka,siginfo_t *info, -struct pt_regs *regs) +handle_signal (struct ksignal *ksig,struct pt_regs *regs) { +int ret; +/* Are we from a system call? */ if (regs->syscall_nr >=0 ) {/* If so, check system call restarting.. */
@@ -265,7 +262,7 @@ handle_signal(unsigned long sig, structbreak ;case -ERESTARTSYS : -if (!(ka->sa.sa_flags &SA_RESTART )) { +if (!(ksig->ka.sa.sa_flags &SA_RESTART )) { regs->r0 = -EINTR ;break ; }
@@ -278,10 +275,9 @@ handle_signal(unsigned long sig, struct }/* Set up the stack frame */ -if (setup_rt_frame (sig, ka, info,sigmask_to_save (), regs)) -return ; + ret =setup_rt_frame (ksig,sigmask_to_save (), regs); -signal_delivered (sig, info, ka, regs,0 ); +signal_setup_done (ret, ksig,0 ); }/*
@@ -291,9 +287,7 @@ handle_signal(unsigned long sig, struct*/ static void do_signal (struct pt_regs *regs) { -siginfo_t info; -int signr; -struct k_sigaction ka; +struct ksignal ksig;/* * We want the common case to go fast, which
@@ -304,8 +298,7 @@ static void do_signal(struct pt_regs *reif (!user_mode (regs))return ; - signr =get_signal_to_deliver (&info, &ka, regs,NULL ); -if (signr >0 ) { +if (get_signal (&ksig)) {/* Re-enable any watchpoints before delivering the * signal to user space. The processor register will * have been cleared if the watchpoint triggered
@@ -313,7 +306,7 @@ static void do_signal(struct pt_regs *re*/ /* Whee! Actually deliver the signal. */ -handle_signal (signr, &ka, &info, regs); +handle_signal (&ksig, regs);return ; }
PATCH 117/202 m68k: Use get_signal() signal_setup_done()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit 0d97500d393012690f3579056629bea0369e6554 upstream.
Use the more generic functions get_signal() signal_setup_done() for signal delivery.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- arch/m68k/kernel/signal.c | 63 +++++++++++++++------------------------ 1 file changed, 24 insertions(+), 39 deletions(-)
arch/m68k/kernel/signal.c +24 -39
@@ -850,23 +850,23 @@ get_sigframe(struct k_sigaction *ka, strreturn (void __user *)((usp - frame_size) &-8UL ); } -static int setup_frame (int sig,struct k_sigaction *ka, -sigset_t *set,struct pt_regs *regs) +static int setup_frame (struct ksignal *ksig,sigset_t *set, +struct pt_regs *regs) {struct sigframe __user *frame;int fsize =frame_extra_sizes (regs->format);struct sigcontext context; -int err =0 ; +int err =0 , sig = ksig->sig;if (fsize <0 ) {#ifdef DEBUG printk ("setup_frame: Unknown frame format %#x\n" , regs->format);#endif - goto give_sigsegv; +return -EFAULT ; } - frame =get_sigframe (ka, regs,sizeof (*frame) + fsize); + frame =get_sigframe (&ksig->ka, regs,sizeof (*frame) + fsize);if (fsize) err |=copy_to_user (frame +1 , regs +1 , fsize);
@@ -899,7 +899,7 @@ static int setup_frame (int sig, struct#endif if (err) - goto give_sigsegv; +return -EFAULT ;push_cache ((unsigned long ) &frame->retcode);
@@ -908,7 +908,7 @@ static int setup_frame (int sig, struct* to destroy is successfully copied to sigframe. */ wrusp ((unsigned long ) frame); - regs->pc = (unsigned long ) ka->sa.sa_handler; + regs->pc = (unsigned long ) ksig->ka.sa.sa_handler;adjustformat (regs);/*
@@ -934,28 +934,24 @@ static int setup_frame (int sig, struct tregs->sr = regs->sr; }return 0 ; - -give_sigsegv: -force_sigsegv (sig, current); -return err; } -static int setup_rt_frame (int sig,struct k_sigaction *ka,siginfo_t *info, -sigset_t *set,struct pt_regs *regs) +static int setup_rt_frame (struct ksignal *ksig,sigset_t *set, +struct pt_regs *regs) {struct rt_sigframe __user *frame;int fsize =frame_extra_sizes (regs->format); -int err =0 ; +int err =0 , sig = ksig->sig;if (fsize <0 ) {#ifdef DEBUG printk ("setup_frame: Unknown frame format %#x\n" , regs->format);#endif - goto give_sigsegv; +return -EFAULT ; } - frame =get_sigframe (ka, regs,sizeof (*frame)); + frame =get_sigframe (&ksig->ka, regs,sizeof (*frame));if (fsize) err |=copy_to_user (&frame->uc.uc_extra, regs +1 , fsize);
@@ -968,7 +964,7 @@ static int setup_rt_frame (int sig, stru &frame->sig); err |=__put_user (&frame->info, &frame->pinfo); err |=__put_user (&frame->uc, &frame->puc); - err |=copy_siginfo_to_user (&frame->info, info); + err |=copy_siginfo_to_user (&frame->info, &ksig->info);/* Create the ucontext. */ err |=__put_user (0 , &frame->uc.uc_flags);
@@ -996,7 +992,7 @@ static int setup_rt_frame (int sig, stru#endif /* CONFIG_MMU */ if (err) - goto give_sigsegv; +return -EFAULT ;push_cache ((unsigned long ) &frame->retcode);
@@ -1005,7 +1001,7 @@ static int setup_rt_frame (int sig, stru* to destroy is successfully copied to sigframe. */ wrusp ((unsigned long ) frame); - regs->pc = (unsigned long ) ka->sa.sa_handler; + regs->pc = (unsigned long ) ksig->ka.sa.sa_handler;adjustformat (regs);/*
@@ -1031,10 +1027,6 @@ static int setup_rt_frame (int sig, stru tregs->sr = regs->sr; }return 0 ; - -give_sigsegv: -force_sigsegv (sig, current); -return err; } static inline void
@@ -1074,26 +1066,22 @@ handle_restart(struct pt_regs *regs, str* OK, we're invoking a handler */ static void -handle_signal (int sig,struct k_sigaction *ka,siginfo_t *info, -struct pt_regs *regs) +handle_signal (struct ksignal *ksig,struct pt_regs *regs) {sigset_t *oldset =sigmask_to_save ();int err;/* are we from a system call? */ if (regs->orig_d0 >=0 )/* If so, check system call restarting.. */ -handle_restart (regs, ka,1 ); +handle_restart (regs, &ksig->ka,1 );/* set up the stack frame */ -if (ka->sa.sa_flags &SA_SIGINFO ) - err =setup_rt_frame (sig, ka, info, oldset, regs); +if (ksig->ka.sa.sa_flags &SA_SIGINFO ) + err =setup_rt_frame (ksig, oldset, regs);else - err =setup_frame (sig, ka, oldset, regs); - -if (err) -return ; + err =setup_frame (ksig, oldset, regs); -signal_delivered (sig, info, ka, regs,0 ); +signal_setup_done (err, ksig,0 );if (test_thread_flag (TIF_DELAYED_TRACE )) { regs->sr &= ~0x8000 ;
@@ -1108,16 +1096,13 @@ handle_signal(int sig, struct k_sigactio*/ static void do_signal (struct pt_regs *regs) { -siginfo_t info; -struct k_sigaction ka; -int signr; +struct ksignal ksig; current->thread.esp0 = (unsigned long ) regs; - signr =get_signal_to_deliver (&info, &ka, regs,NULL ); -if (signr >0 ) { +if (get_signal (&ksig)) {/* Whee! Actually deliver the signal. */ -handle_signal (signr, &ka, &info, regs); +handle_signal (&ksig, regs);return ; }
PATCH 118/202 microblaze: Use get_signal() signal_setup_done()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit 9c53c7ec14a5738ae3117d7d71b7abf630526c9f upstream.
Use the more generic functions get_signal() signal_setup_done() for signal delivery.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- arch/microblaze/kernel/signal.c | 48 ++++++++++++--------------------- 1 file changed, 17 insertions(+), 31 deletions(-)
arch/microblaze/kernel/signal.c +17 -31
@@ -156,11 +156,11 @@ get_sigframe(struct k_sigaction *ka, strreturn (void __user *)((sp - frame_size) &-8UL ); } -static int setup_rt_frame (int sig,struct k_sigaction *ka,siginfo_t *info, -sigset_t *set,struct pt_regs *regs) +static int setup_rt_frame (struct ksignal *ksig,sigset_t *set, +struct pt_regs *regs) {struct rt_sigframe __user *frame; -int err =0 ; +int err =0 , sig = ksig->sig;int signal;unsigned long address =0 ;#ifdef CONFIG_MMU
@@ -168,10 +168,10 @@ static int setup_rt_frame(int sig, strucpte_t *ptep;#endif - frame =get_sigframe (ka, regs,sizeof (*frame)); + frame =get_sigframe (&ksig->ka, regs,sizeof (*frame));if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame))) - goto give_sigsegv; +return -EFAULT ; signal =current_thread_info ()->exec_domain &¤t_thread_info ()->exec_domain->signal_invmap
@@ -179,8 +179,8 @@ static int setup_rt_frame(int sig, struc ?current_thread_info ()->exec_domain->signal_invmap[sig] : sig; -if (info) - err |=copy_siginfo_to_user (&frame->info, info); +if (ksig->ka.sa.sa_flags &SA_SIGINFO ) + err |=copy_siginfo_to_user (&frame->info, &ksig->info);/* Create the ucontext. */ err |=__put_user (0 , &frame->uc.uc_flags);
@@ -227,7 +227,7 @@ static int setup_rt_frame(int sig, strucflush_dcache_range (address, address +8 );#endif if (err) - goto give_sigsegv; +return -EFAULT ;/* Set up registers for signal handler */ regs->r1 = (unsigned long ) frame;
@@ -237,7 +237,7 @@ static int setup_rt_frame(int sig, struc regs->r6 = (unsigned long ) &frame->info;/* arg 1: siginfo */ regs->r7 = (unsigned long ) &frame->uc;/* arg2: ucontext */ /* Offset to handle microblaze rtid r14, 0 */ - regs->pc = (unsigned long )ka->sa.sa_handler; + regs->pc = (unsigned long )ksig->ka.sa.sa_handler;set_fs (USER_DS );
@@ -247,10 +247,6 @@ static int setup_rt_frame(int sig, struc#endif return 0 ; - -give_sigsegv: -force_sigsegv (sig, current); -return -EFAULT ; }/* Handle restarting system calls */
@@ -283,23 +279,15 @@ do_restart:*/ static void -handle_signal (unsigned long sig,struct k_sigaction *ka, -siginfo_t *info,struct pt_regs *regs) +handle_signal (struct ksignal *ksig,struct pt_regs *regs) {sigset_t *oldset =sigmask_to_save ();int ret;/* Set up the stack frame */ -if (ka->sa.sa_flags &SA_SIGINFO ) - ret =setup_rt_frame (sig, ka, info, oldset, regs); -else - ret =setup_rt_frame (sig, ka,NULL , oldset, regs); - -if (ret) -return ; + ret =setup_rt_frame (ksig, oldset, regs); -signal_delivered (sig, info, ka, regs, -test_thread_flag (TIF_SINGLESTEP )); +signal_setup_done (ret, ksig,test_thread_flag (TIF_SINGLESTEP )); }/*
@@ -313,21 +301,19 @@ handle_signal(unsigned long sig, struct*/ static void do_signal (struct pt_regs *regs,int in_syscall) { -siginfo_t info; -int signr; -struct k_sigaction ka; +struct ksignal ksig; +#ifdef DEBUG_SIG pr_info ("do signal: %p %d\n" , regs, in_syscall);pr_info ("do signal2: %lx %lx %ld [%lx]\n" , regs->pc, regs->r1, regs->r12,current_thread_info ()->flags);#endif - signr =get_signal_to_deliver (&info, &ka, regs,NULL ); -if (signr >0 ) { +if (get_signal (&ksig)) {/* Whee! Actually deliver the signal. */ if (in_syscall) -handle_restart (regs, &ka,1 ); -handle_signal (signr, &ka, &info, regs); +handle_restart (regs, &ksig.ka,1 ); +handle_signal (&ksig, regs);return ; }
PATCH 119/202 mips: Use get_signal() signal_setup_done()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit 81d103bf80678669c56658185e758fc3f9845d71 upstream.
Use the more generic functions get_signal() signal_setup_done() for signal delivery.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- arch/mips/include/asm/abi.h | 10 ++--- arch/mips/kernel/signal-common.h | 2 +- arch/mips/kernel/signal.c | 66 ++++++++++++-------------------- arch/mips/kernel/signal32.c | 39 ++++++++----------- arch/mips/kernel/signal_n32.c | 20 ++++------ 5 files changed, 53 insertions(+), 84 deletions(-)
arch/mips/include/asm/abi.h +4 -6
@@ -13,13 +13,11 @@#include <asm/siginfo.h> struct mips_abi { -int (*const setup_frame)(void *sig_return,struct k_sigaction *ka, -struct pt_regs *regs,int signr, -sigset_t *set); +int (*const setup_frame)(void *sig_return,struct ksignal *ksig, +struct pt_regs *regs,sigset_t *set);const unsigned long signal_return_offset; -int (*const setup_rt_frame)(void *sig_return,struct k_sigaction *ka, -struct pt_regs *regs,int signr, -sigset_t *set,siginfo_t *info); +int (*const setup_rt_frame)(void *sig_return,struct ksignal *ksig, +struct pt_regs *regs,sigset_t *set);const unsigned long rt_signal_return_offset;const unsigned long restart; };
arch/mips/kernel/signal-common.h +1 -1
@@ -22,7 +22,7 @@/* * Determine which stack to use.. */ -extern void __user *get_sigframe (struct k_sigaction *ka,struct pt_regs *regs, +extern void __user *get_sigframe (struct ksignal *ksig,struct pt_regs *regs,size_t frame_size);/* Check and clear pending FPU exceptions in saved CSR */ extern int fpcsr_pending (unsigned int __user *fpcsr);
arch/mips/kernel/signal.c +25 -41
155 lines not on this page · raw message
arch/mips/kernel/signal32.c +15 -24
@@ -488,21 +488,21 @@ badframe:force_sig (SIGSEGV , current); } -static int setup_frame_32 (void *sig_return,struct k_sigaction *ka, -struct pt_regs *regs,int signr,sigset_t *set) +static int setup_frame_32 (void *sig_return,struct ksignal *ksig, +struct pt_regs *regs,sigset_t *set) {struct sigframe32 __user *frame;int err =0 ; - frame =get_sigframe (ka, regs,sizeof (*frame)); + frame =get_sigframe (&ksig->ka, regs,sizeof (*frame));if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame))) - goto give_sigsegv; +return -EFAULT ; err |=setup_sigcontext32 (regs, &frame->sf_sc); err |=__copy_conv_sigset_to_user (&frame->sf_mask, set);if (err) - goto give_sigsegv; +return -EFAULT ;/* * Arguments to signal handler:
@@ -514,37 +514,32 @@ static int setup_frame_32(void *sig_retu* $25 and c0_epc point to the signal handler, $29 points to the * struct sigframe. */ - regs->regs[4 ] = signr; + regs->regs[4 ] = ksig->sig; regs->regs[5 ] =0 ; regs->regs[6 ] = (unsigned long ) &frame->sf_sc; regs->regs[29 ] = (unsigned long ) frame; regs->regs[31 ] = (unsigned long ) sig_return; - regs->cp0_epc = regs->regs[25 ] = (unsigned long ) ka->sa.sa_handler; + regs->cp0_epc = regs->regs[25 ] = (unsigned long ) ksig->ka.sa.sa_handler;DEBUGP ("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n" , current->comm, current->pid, frame, regs->cp0_epc, regs->regs[31 ]);return 0 ; - -give_sigsegv: -force_sigsegv (signr, current); -return -EFAULT ; } -static int setup_rt_frame_32 (void *sig_return,struct k_sigaction *ka, -struct pt_regs *regs,int signr,sigset_t *set, -siginfo_t *info) +static int setup_rt_frame_32 (void *sig_return,struct ksignal *ksig, +struct pt_regs *regs,sigset_t *set) {struct rt_sigframe32 __user *frame;int err =0 ; - frame =get_sigframe (ka, regs,sizeof (*frame)); + frame =get_sigframe (&ksig->ka, regs,sizeof (*frame));if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame))) - goto give_sigsegv; +return -EFAULT ;/* Convert (siginfo_t -> compat_siginfo_t) and copy to user. */ - err |=copy_siginfo_to_user32 (&frame->rs_info, info); + err |=copy_siginfo_to_user32 (&frame->rs_info, &ksig->info);/* Create the ucontext. */ err |=__put_user (0 , &frame->rs_uc.uc_flags);
@@ -554,7 +549,7 @@ static int setup_rt_frame_32(void *sig_r err |=__copy_conv_sigset_to_user (&frame->rs_uc.uc_sigmask, set);if (err) - goto give_sigsegv; +return -EFAULT ;/* * Arguments to signal handler:
@@ -566,22 +561,18 @@ static int setup_rt_frame_32(void *sig_r* $25 and c0_epc point to the signal handler, $29 points to * the struct rt_sigframe32. */ - regs->regs[4 ] = signr; + regs->regs[4 ] = ksig->sig; regs->regs[5 ] = (unsigned long ) &frame->rs_info; regs->regs[6 ] = (unsigned long ) &frame->rs_uc; regs->regs[29 ] = (unsigned long ) frame; regs->regs[31 ] = (unsigned long ) sig_return; - regs->cp0_epc = regs->regs[25 ] = (unsigned long ) ka->sa.sa_handler; + regs->cp0_epc = regs->regs[25 ] = (unsigned long ) ksig->ka.sa.sa_handler;DEBUGP ("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n" , current->comm, current->pid, frame, regs->cp0_epc, regs->regs[31 ]);return 0 ; - -give_sigsegv: -force_sigsegv (signr, current); -return -EFAULT ; }/*
arch/mips/kernel/signal_n32.c +8 -12
@@ -102,18 +102,18 @@ badframe:force_sig (SIGSEGV , current); } -static int setup_rt_frame_n32 (void *sig_return,struct k_sigaction *ka, -struct pt_regs *regs,int signr,sigset_t *set,siginfo_t *info) +static int setup_rt_frame_n32 (void *sig_return,struct ksignal *ksig, +struct pt_regs *regs,sigset_t *set) {struct rt_sigframe_n32 __user *frame;int err =0 ; - frame =get_sigframe (ka, regs,sizeof (*frame)); + frame =get_sigframe (&ksig->ka, regs,sizeof (*frame));if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame))) - goto give_sigsegv; +return -EFAULT ;/* Create siginfo. */ - err |=copy_siginfo_to_user32 (&frame->rs_info, info); + err |=copy_siginfo_to_user32 (&frame->rs_info, &ksig->info);/* Create the ucontext. */ err |=__put_user (0 , &frame->rs_uc.uc_flags);
@@ -123,7 +123,7 @@ static int setup_rt_frame_n32(void *sig_ err |=__copy_conv_sigset_to_user (&frame->rs_uc.uc_sigmask, set);if (err) - goto give_sigsegv; +return -EFAULT ;/* * Arguments to signal handler:
@@ -135,22 +135,18 @@ static int setup_rt_frame_n32(void *sig_* $25 and c0_epc point to the signal handler, $29 points to * the struct rt_sigframe. */ - regs->regs[4 ] = signr; + regs->regs[4 ] = ksig->sig; regs->regs[5 ] = (unsigned long ) &frame->rs_info; regs->regs[6 ] = (unsigned long ) &frame->rs_uc; regs->regs[29 ] = (unsigned long ) frame; regs->regs[31 ] = (unsigned long ) sig_return; - regs->cp0_epc = regs->regs[25 ] = (unsigned long ) ka->sa.sa_handler; + regs->cp0_epc = regs->regs[25 ] = (unsigned long ) ksig->ka.sa.sa_handler;DEBUGP ("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n" , current->comm, current->pid, frame, regs->cp0_epc, regs->regs[31 ]);return 0 ; - -give_sigsegv: -force_sigsegv (signr, current); -return -EFAULT ; }struct mips_abi mips_abi_n32 = {
PATCH 120/202 mips: Use sigsp()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit 7c4f563507c33ca97dcfbd62dba1e9232575d499 upstream.
Use sigsp() instead of the open coded variant.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- arch/mips/kernel/signal.c | 10 ++++------ arch/mips/kernel/signal32.c | 4 ++-- arch/mips/kernel/signal_n32.c | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-)
arch/mips/kernel/signal.c +4 -6
@@ -280,7 +280,7 @@ int restore_sigcontext(struct pt_regs *rreturn err; } -void __user *get_sigframe (struct k_sigaction *ka,struct pt_regs *regs, +void __user *get_sigframe (struct ksignal *ksig,struct pt_regs *regs,size_t frame_size) {unsigned long sp;
@@ -295,9 +295,7 @@ void __user *get_sigframe(struct k_sigac*/ sp -=32 ; -/* This is the X/Open sanctioned signal stack switching. */ -if ((ka->sa.sa_flags &SA_ONSTACK ) && (sas_ss_flags (sp) ==0 )) - sp = current->sas_ss_sp + current->sas_ss_size; + sp =sigsp (sp, ksig);return (void __user *)((sp - frame_size) & (ICACHE_REFILLS_WORKAROUND_WAR ? ~(cpu_icache_line_size ()-1 ) :ALMASK )); }
@@ -434,7 +432,7 @@ static int setup_frame(void *sig_return,struct sigframe __user *frame;int err =0 ; - frame =get_sigframe (&ksig->ka, regs,sizeof (*frame)); + frame =get_sigframe (ksig, regs,sizeof (*frame));if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame)))return -EFAULT ;
@@ -473,7 +471,7 @@ static int setup_rt_frame(void *sig_retustruct rt_sigframe __user *frame;int err =0 ; - frame =get_sigframe (&ksig->ka, regs,sizeof (*frame)); + frame =get_sigframe (ksig, regs,sizeof (*frame));if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame)))return -EFAULT ;
arch/mips/kernel/signal32.c +2 -2
@@ -494,7 +494,7 @@ static int setup_frame_32(void *sig_retustruct sigframe32 __user *frame;int err =0 ; - frame =get_sigframe (&ksig->ka, regs,sizeof (*frame)); + frame =get_sigframe (ksig, regs,sizeof (*frame));if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame)))return -EFAULT ;
@@ -534,7 +534,7 @@ static int setup_rt_frame_32(void *sig_rstruct rt_sigframe32 __user *frame;int err =0 ; - frame =get_sigframe (&ksig->ka, regs,sizeof (*frame)); + frame =get_sigframe (ksig, regs,sizeof (*frame));if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame)))return -EFAULT ;
arch/mips/kernel/signal_n32.c +1 -1
@@ -108,7 +108,7 @@ static int setup_rt_frame_n32(void *sig_struct rt_sigframe_n32 __user *frame;int err =0 ; - frame =get_sigframe (&ksig->ka, regs,sizeof (*frame)); + frame =get_sigframe (ksig, regs,sizeof (*frame));if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame)))return -EFAULT ;
PATCH 121/202 mn10300: Use get_signal() signal_setup_done()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit 8b166553a9aaf39774bc22f5e93c965584303929 upstream.
Use the more generic functions get_signal() signal_setup_done() for signal delivery.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- arch/mn10300/kernel/signal.c | 89 +++++++++++++++--------------------- 1 file changed, 36 insertions(+), 53 deletions(-)
arch/mn10300/kernel/signal.c +36 -53
@@ -207,16 +207,16 @@ static inline void __user *get_sigframe(/* * set up a normal signal frame */ -static int setup_frame (int sig,struct k_sigaction *ka,sigset_t *set, +static int setup_frame (struct ksignal *ksig,sigset_t *set,struct pt_regs *regs) {struct sigframe __user *frame; -int rsig; +int rsig, sig = ksig->sig; - frame =get_sigframe (ka, regs,sizeof (*frame)); + frame =get_sigframe (&ksig->ka, regs,sizeof (*frame));if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame))) - goto give_sigsegv; +return -EFAULT ; rsig = sig; if (sig < 32 &&
@@ -226,40 +226,40 @@ static int setup_frame(int sig, struct kif (__put_user (rsig, &frame->sig) <0 ||__put_user (&frame->sc, &frame->psc) <0 ) - goto give_sigsegv; +return -EFAULT ;if (setup_sigcontext (&frame->sc, &frame->fpuctx, regs, set->sig[0 ])) - goto give_sigsegv; +return -EFAULT ;if (_NSIG_WORDS >1 ) {if (__copy_to_user (frame->extramask, &set->sig[1 ],sizeof (frame->extramask))) - goto give_sigsegv; +return -EFAULT ; }/* set up to return from userspace. If provided, use a stub already in * userspace */ -if (ka->sa.sa_flags &SA_RESTORER ) { -if (__put_user (ka->sa.sa_restorer, &frame->pretcode)) - goto give_sigsegv; +if (ksig->ka.sa.sa_flags &SA_RESTORER ) { +if (__put_user (ksig->ka.sa.sa_restorer, &frame->pretcode)) +return -EFAULT ; }else {if (__put_user ((void (*)(void ))frame->retcode, &frame->pretcode)) - goto give_sigsegv; +return -EFAULT ;/* this is mov $,d0; syscall 0 */ if (__put_user (0x2c , (char *)(frame->retcode +0 )) ||__put_user (__NR_sigreturn, (char *)(frame->retcode +1 )) ||__put_user (0x00 , (char *)(frame->retcode +2 )) ||__put_user (0xf0 , (char *)(frame->retcode +3 )) ||__put_user (0xe0 , (char *)(frame->retcode +4 ))) - goto give_sigsegv; +return -EFAULT ;flush_icache_range ((unsigned long ) frame->retcode, (unsigned long ) frame->retcode +5 ); }/* set up registers for signal handler */ regs->sp = (unsigned long ) frame; - regs->pc = (unsigned long ) ka->sa.sa_handler; + regs->pc = (unsigned long ) ksig->ka.sa.sa_handler; regs->d0 = sig; regs->d1 = (unsigned long ) &frame->sc;
@@ -270,25 +270,21 @@ static int setup_frame(int sig, struct k#endif return 0 ; - -give_sigsegv: -force_sigsegv (sig, current); -return -EFAULT ; }/* * set up a realtime signal frame */ -static int setup_rt_frame (int sig,struct k_sigaction *ka,siginfo_t *info, -sigset_t *set,struct pt_regs *regs) +static int setup_rt_frame (struct ksignal *ksig,sigset_t *set, +struct pt_regs *regs) {struct rt_sigframe __user *frame; -int rsig; +int rsig, sig = ksig->sig; - frame =get_sigframe (ka, regs,sizeof (*frame)); + frame =get_sigframe (&ksig->ka, regs,sizeof (*frame));if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame))) - goto give_sigsegv; +return -EFAULT ; rsig = sig; if (sig < 32 &&
@@ -299,8 +295,8 @@ static int setup_rt_frame(int sig, strucif (__put_user (rsig, &frame->sig) ||__put_user (&frame->info, &frame->pinfo) ||__put_user (&frame->uc, &frame->puc) || -copy_siginfo_to_user (&frame->info, info)) - goto give_sigsegv; +copy_siginfo_to_user (&frame->info, &ksig->info)) +return -EFAULT ;/* create the ucontext. */ if (__put_user(0, &frame->uc.uc_flags) ||
@@ -309,13 +305,14 @@ static int setup_rt_frame(int sig, strucsetup_sigcontext (&frame->uc.uc_mcontext, &frame->fpuctx, regs, set->sig[0 ]) || __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set))) - goto give_sigsegv; + return -EFAULT;/* set up to return from userspace. If provided, use a stub already in * userspace */ -if (ka->sa.sa_flags &SA_RESTORER ) { -if (__put_user (ka->sa.sa_restorer, &frame->pretcode)) - goto give_sigsegv; +if (ksig->ka.sa.sa_flags &SA_RESTORER ) { +if (__put_user (ksig->ka.sa.sa_restorer, &frame->pretcode)) +return -EFAULT ; + }else { if (__put_user((void(*)(void))frame->retcode, &frame->pretcode) ||
@@ -326,7 +323,7 @@ static int setup_rt_frame(int sig, struc__put_user (0x00 , (char *)(frame->retcode +2 )) ||__put_user (0xf0 , (char *)(frame->retcode +3 )) || __put_user(0xe0, (char *)(frame->retcode + 4))) - goto give_sigsegv; + return -EFAULT;flush_icache_range ((u_long ) frame->retcode, (u_long ) frame->retcode +5 );
@@ -334,7 +331,7 @@ static int setup_rt_frame(int sig, struc/* Set up registers for signal handler */ regs->sp = (unsigned long ) frame; - regs->pc = (unsigned long ) ka->sa.sa_handler; + regs->pc = (unsigned long ) ksig->ka.sa.sa_handler; regs->d0 = sig; regs->d1 = (long ) &frame->info;
@@ -345,10 +342,6 @@ static int setup_rt_frame(int sig, struc#endif return 0 ; - -give_sigsegv: -force_sigsegv (sig, current); -return -EFAULT ; }static inline void stepback (struct pt_regs *regs)
@@ -360,9 +353,7 @@ static inline void stepback(struct pt_re/* * handle the actual delivery of a signal to userspace */ -static int handle_signal (int sig, -siginfo_t *info,struct k_sigaction *ka, -struct pt_regs *regs) +static int handle_signal (struct ksignal *ksig,struct pt_regs *regs) {sigset_t *oldset =sigmask_to_save ();int ret;
@@ -377,7 +368,7 @@ static int handle_signal(int sig,break ;case -ERESTARTSYS : -if (!(ka->sa.sa_flags &SA_RESTART )) { +if (!(ksig->ka.sa.sa_flags &SA_RESTART )) { regs->d0 = -EINTR ;break ; }
@@ -390,15 +381,12 @@ static int handle_signal(int sig, }/* Set up the stack frame */ -if (ka->sa.sa_flags &SA_SIGINFO ) - ret =setup_rt_frame (sig, ka, info, oldset, regs); +if (ksig->ka.sa.sa_flags &SA_SIGINFO ) + ret =setup_rt_frame (ksig, oldset, regs);else - ret =setup_frame (sig, ka, oldset, regs); -if (ret) -return ret; + ret =setup_frame (ksig, oldset, regs); -signal_delivered (sig, info, ka, regs, -test_thread_flag (TIF_SINGLESTEP )); +signal_setup_done (ret, ksig,test_thread_flag (TIF_SINGLESTEP ));return 0 ; }
@@ -407,15 +395,10 @@ static int handle_signal(int sig,*/ static void do_signal (struct pt_regs *regs) { -struct k_sigaction ka; -siginfo_t info; -int signr; - - signr =get_signal_to_deliver (&info, &ka, regs,NULL ); -if (signr >0 ) { -if (handle_signal (signr, &info, &ka, regs) ==0 ) { - } +struct ksignal ksig; +if (get_signal (&ksig)) { +handle_signal (&ksig, regs);return ; }
PATCH 122/202 parisc: Use get_signal() signal_setup_done()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit e4dc894b61776733629b24507031dd46f5ba5efc upstream.
Use the more generic functions get_signal() signal_setup_done() for signal delivery.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- arch/parisc/kernel/signal.c | 58 +++++++++++++++---------------------- 1 file changed, 24 insertions(+), 34 deletions(-)
arch/parisc/kernel/signal.c +24 -34
@@ -227,8 +227,8 @@ setup_sigcontext(struct sigcontext __use }static long -setup_rt_frame (int sig,struct k_sigaction *ka,siginfo_t *info, -sigset_t *set,struct pt_regs *regs,int in_syscall) +setup_rt_frame (struct ksignal *ksig,sigset_t *set,struct pt_regs *regs, +int in_syscall) {struct rt_sigframe __user *frame;unsigned long rp, usp;
@@ -241,10 +241,10 @@ setup_rt_frame(int sig, struct k_sigacti usp = (regs->gr[30 ] & ~(0x01UL ));/*FIXME: frame_size parameter is unused, remove it. */ - frame =get_sigframe (ka, usp,sizeof (*frame)); + frame =get_sigframe (&ksig->ka, usp,sizeof (*frame));DBG (1 ,"SETUP_RT_FRAME: START\n" ); -DBG (1 ,"setup_rt_frame: frame %p info %p\n" , frame, info); +DBG (1 ,"setup_rt_frame: frame %p info %p\n" , frame, ksig->info);#ifdef CONFIG_64BIT
@@ -253,7 +253,7 @@ setup_rt_frame(int sig, struct k_sigactiif (is_compat_task ()) {DBG (1 ,"setup_rt_frame: frame->info = 0x%p\n" , &compat_frame->info); - err |=copy_siginfo_to_user32 (&compat_frame->info, info); + err |=copy_siginfo_to_user32 (&compat_frame->info, &ksig->info); err |=__compat_save_altstack ( &compat_frame->uc.uc_stack, regs->gr[30 ]);DBG (1 ,"setup_rt_frame: frame->uc = 0x%p\n" , &compat_frame->uc);DBG (1 ,"setup_rt_frame: frame->uc.uc_mcontext = 0x%p\n" , &compat_frame->uc.uc_mcontext);
@@ -265,7 +265,7 @@ setup_rt_frame(int sig, struct k_sigacti#endif {DBG (1 ,"setup_rt_frame: frame->info = 0x%p\n" , &frame->info); - err |=copy_siginfo_to_user (&frame->info, info); + err |=copy_siginfo_to_user (&frame->info, &ksig->info); err |=__save_altstack (&frame->uc.uc_stack, regs->gr[30 ]);DBG (1 ,"setup_rt_frame: frame->uc = 0x%p\n" , &frame->uc);DBG (1 ,"setup_rt_frame: frame->uc.uc_mcontext = 0x%p\n" , &frame->uc.uc_mcontext);
@@ -275,7 +275,7 @@ setup_rt_frame(int sig, struct k_sigacti }if (err) - goto give_sigsegv; +return -EFAULT ;/* Set up to return from userspace. If provided, use a stub already in userspace. The first words of tramp are used to
@@ -312,9 +312,9 @@ setup_rt_frame(int sig, struct k_sigacti rp = (unsigned long ) &frame->tramp[SIGRESTARTBLOCK_TRAMP ];if (err) - goto give_sigsegv; +return -EFAULT ; - haddr =A (ka->sa.sa_handler); + haddr =A (ksig->ka.sa.sa_handler);/* The sa_handler may be a pointer to a function descriptor */ #ifdef CONFIG_64BIT if (is_compat_task ()) {
@@ -326,7 +326,7 @@ setup_rt_frame(int sig, struct k_sigacti err =__copy_from_user (&fdesc, ufdesc,sizeof (fdesc));if (err) - goto give_sigsegv; +return -EFAULT ; haddr = fdesc.addr; regs->gr[19 ] = fdesc.gp;
@@ -339,7 +339,7 @@ setup_rt_frame(int sig, struct k_sigacti err =__copy_from_user (&fdesc, ufdesc,sizeof (fdesc));if (err) - goto give_sigsegv; +return -EFAULT ; haddr = fdesc.addr; regs->gr[19 ] = fdesc.gp;
@@ -386,7 +386,7 @@ setup_rt_frame(int sig, struct k_sigacti } regs->gr[2 ] = rp;/* userland return pointer */ - regs->gr[26 ] = sig;/* signal number */ + regs->gr[26 ] = ksig->sig;/* signal number */ #ifdef CONFIG_64BIT if (is_compat_task ()) {
@@ -410,11 +410,6 @@ setup_rt_frame(int sig, struct k_sigacti current->comm, current->pid, frame, regs->gr[30 ], regs->iaoq[0], regs->iaoq[1], rp); -return 1 ; - -give_sigsegv: -DBG (1 ,"setup_rt_frame: sending SIGSEGV\n" ); -force_sigsegv (sig, current);return 0 ; }
@@ -423,20 +418,19 @@ give_sigsegv:*/ static void -handle_signal (unsigned long sig,siginfo_t *info,struct k_sigaction *ka, -struct pt_regs *regs,int in_syscall) +handle_signal (struct ksignal *ksig,struct pt_regs *regs,int in_syscall) { +int ret;sigset_t *oldset =sigmask_to_save (); +DBG (1 ,"handle_signal: sig=%ld, ka=%p, info=%p, oldset=%p, regs=%p\n" , - sig, ka, info, oldset, regs); + ksig->sig, ksig->ka, ksig->info, oldset, regs);/* Set up the stack frame */ -if (!setup_rt_frame (sig, ka, info, oldset, regs, in_syscall)) -return ; + ret =setup_rt_frame (ksig, oldset, regs, in_syscall); -signal_delivered (sig, info, ka, regs, -test_thread_flag (TIF_SINGLESTEP ) || -test_thread_flag (TIF_BLOCKSTEP )); +signal_setup_done (ret, ksig,test_thread_flag (TIF_SINGLESTEP ) || +test_thread_flag (TIF_BLOCKSTEP ));DBG (1 ,KERN_DEBUG "do_signal: Exit (success), regs->gr[28] = %ld\n" , regs->gr[28 ]);
@@ -584,22 +578,18 @@ insert_restart_trampoline(struct pt_regs asmlinkage voiddo_signal (struct pt_regs *regs,long in_syscall) { -siginfo_t info; -struct k_sigaction ka; -int signr; +struct ksignal ksig;DBG (1 ,"\ndo_signal: regs=0x%p, sr7 %#lx, in_syscall=%d\n" , regs, regs->sr[7 ], in_syscall); - signr =get_signal_to_deliver (&info, &ka, regs,NULL ); -DBG (3 ,"do_signal: signr = %d, regs->gr[28] = %ld\n" , signr, regs->gr[28 ]); - -if (signr >0 ) { +if (get_signal (&ksig)) { +DBG (3 ,"do_signal: signr = %d, regs->gr[28] = %ld\n" , signr, regs->gr[28 ]);/* Restart a system call if necessary. */ if (in_syscall) -syscall_restart (regs, &ka); +syscall_restart (regs, &ksig.ka); -handle_signal (signr, &info, &ka, regs, in_syscall); +handle_signal (&ksig, regs, in_syscall);return ; }
PATCH 123/202 powerpc: Use get_signal() signal_setup_done()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit 129b69df9c9074750245fca8aa92df5cc1a86ef4 upstream.
Use the more generic functions get_signal() signal_setup_done() for signal delivery.
This inverts also the return codes of setup_*frame() to follow the kernel convention.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- arch/powerpc/kernel/signal.c | 31 ++++++++++------------------ arch/powerpc/kernel/signal.h | 14 +++++-------- arch/powerpc/kernel/signal_32.c | 36 +++++++++++++++------------------ arch/powerpc/kernel/signal_64.c | 28 ++++++++++++------------- 4 files changed, 45 insertions(+), 64 deletions(-)
arch/powerpc/kernel/signal.c +11 -20
@@ -105,25 +105,23 @@ static void check_syscall_restart(struct } } -static int do_signal (struct pt_regs *regs) +static void do_signal (struct pt_regs *regs) {sigset_t *oldset =sigmask_to_save (); -siginfo_t info; -int signr; -struct k_sigaction ka; +struct ksignal ksig;int ret;int is32 =is_32bit_task (); - signr =get_signal_to_deliver (&info, &ka, regs,NULL ); +get_signal (&ksig);/* Is there any syscall restart business here ? */ -check_syscall_restart (regs, &ka, signr >0 ); +check_syscall_restart (regs, &ksig.ka, ksig.sig >0 ); -if (signr <=0 ) { +if (ksig.sig <=0 ) {/* No signal to deliver -- put the saved sigmask back */ restore_saved_sigmask (); regs->trap =0 ; -return 0 ;/* no signals delivered */ +return ;/* no signals delivered */ }#ifndef CONFIG_PPC_ADV_DEBUG_REGS
@@ -140,23 +138,16 @@ static int do_signal(struct pt_regs *regthread_change_pc (current, regs);if (is32) { -if (ka.sa.sa_flags &SA_SIGINFO ) - ret =handle_rt_signal32 (signr, &ka, &info, oldset, - regs); +if (ksig.ka.sa.sa_flags &SA_SIGINFO ) + ret =handle_rt_signal32 (&ksig, oldset, regs);else - ret =handle_signal32 (signr, &ka, &info, oldset, - regs); + ret =handle_signal32 (&ksig, oldset, regs); }else { - ret =handle_rt_signal64 (signr, &ka, &info, oldset, regs); + ret =handle_rt_signal64 (&ksig, oldset, regs); } regs->trap =0 ; -if (ret) { -signal_delivered (signr, &info, &ka, regs, -test_thread_flag (TIF_SINGLESTEP )); - } - -return ret; +signal_setup_done (ret, &ksig,test_thread_flag (TIF_SINGLESTEP )); }void do_notify_resume (struct pt_regs *regs,unsigned long thread_info_flags)
arch/powerpc/kernel/signal.h +5 -9
@@ -12,15 +12,13 @@extern void do_notify_resume (struct pt_regs *regs,unsigned long thread_info_flags); -extern void __user *get_sigframe (struct k_sigaction *ka,unsigned long sp, +extern void __user *get_sigframe (struct ksignal *ksig,unsigned long sp,size_t frame_size,int is_32); -extern int handle_signal32 (unsigned long sig,struct k_sigaction *ka, -siginfo_t *info,sigset_t *oldset, +extern int handle_signal32 (struct ksignal *ksig,sigset_t *oldset,struct pt_regs *regs); -extern int handle_rt_signal32 (unsigned long sig,struct k_sigaction *ka, -siginfo_t *info,sigset_t *oldset, +extern int handle_rt_signal32 (struct ksignal *ksig,sigset_t *oldset,struct pt_regs *regs); extern unsigned long copy_fpr_to_user(void __user *to,
@@ -44,14 +42,12 @@ extern unsigned long copy_transact_vsx_f#ifdef CONFIG_PPC64 -extern int handle_rt_signal64 (int signr,struct k_sigaction *ka, -siginfo_t *info,sigset_t *set, +extern int handle_rt_signal64 (struct ksignal *ksig,sigset_t *set,struct pt_regs *regs);#else /* CONFIG_PPC64 */ -static inline int handle_rt_signal64 (int signr,struct k_sigaction *ka, -siginfo_t *info,sigset_t *set, +static inline int handle_rt_signal64 (struct ksignal *ksig,sigset_t *set,struct pt_regs *regs) {return -EFAULT ;
arch/powerpc/kernel/signal_32.c +16 -20
@@ -1001,9 +1001,8 @@ int copy_siginfo_from_user32(siginfo_t ** Set up a signal frame for a "real-time" signal handler * (one which gets siginfo). */ -int handle_rt_signal32 (unsigned long sig,struct k_sigaction *ka, -siginfo_t *info,sigset_t *oldset, -struct pt_regs *regs) +int handle_rt_signal32 (struct ksignal *ksig,sigset_t *oldset, +struct pt_regs *regs) {struct rt_sigframe __user *rt_sf;struct mcontext __user *frame;
@@ -1015,13 +1014,13 @@ int handle_rt_signal32(unsigned long sig/* Set up Signal Frame */ /* Put a Real Time Context onto stack */ - rt_sf =get_sigframe (ka,get_tm_stackpointer (regs),sizeof (*rt_sf),1 ); + rt_sf =get_sigframe (&ksig->ka,get_tm_stackpointer (regs),sizeof (*rt_sf),1 ); addr = rt_sf;if (unlikely (rt_sf ==NULL )) goto badframe;/* Put the siginfo & fill in most of the ucontext */ -if (copy_siginfo_to_user (&rt_sf->info, info) +if (copy_siginfo_to_user (&rt_sf->info, &ksig->info) ||__put_user (0 , &rt_sf->uc.uc_flags) ||__save_altstack (&rt_sf->uc.uc_stack, regs->gpr[1 ]) || __put_user(to_user_ptr(&rt_sf->uc.uc_mcontext),
@@ -1071,15 +1070,15 @@ int handle_rt_signal32(unsigned long sig/* Fill registers for signal handler */ regs->gpr[1 ] = newsp; - regs->gpr[3 ] = sig; + regs->gpr[3 ] = ksig->sig; regs->gpr[4 ] = (unsigned long ) &rt_sf->info; regs->gpr[5 ] = (unsigned long ) &rt_sf->uc; regs->gpr[6 ] = (unsigned long ) rt_sf; - regs->nip = (unsigned long ) ka->sa.sa_handler; + regs->nip = (unsigned long ) ksig->ka.sa.sa_handler;/* enter the signal handler in native-endian mode */ regs->msr &= ~MSR_LE ; regs->msr |= (MSR_KERNEL &MSR_LE ); -return 1 ; +return 0 ; badframe:if (show_unhandled_signals)
@@ -1089,8 +1088,7 @@ badframe: current->comm, current->pid, addr, regs->nip, regs->link); -force_sigsegv (sig, current); -return 0 ; +return 1 ; }static int do_setcontext (struct ucontext __user *ucp,struct pt_regs *regs,int sig)
@@ -1437,8 +1435,7 @@ int sys_debug_setcontext(struct ucontext/* * OK, we're invoking a handler */ -int handle_signal32 (unsigned long sig,struct k_sigaction *ka, -siginfo_t *info,sigset_t *oldset,struct pt_regs *regs) +int handle_signal32 (struct ksignal *ksig,sigset_t *oldset,struct pt_regs *regs) {struct sigcontext __user *sc;struct sigframe __user *frame;
@@ -1448,7 +1445,7 @@ int handle_signal32(unsigned long sig, sunsigned long tramp;/* Set up Signal Frame */ - frame =get_sigframe (ka,get_tm_stackpointer (regs),sizeof (*frame),1 ); + frame =get_sigframe (&ksig->ka,get_tm_stackpointer (regs),sizeof (*frame),1 );if (unlikely (frame ==NULL )) goto badframe; sc = (struct sigcontext __user *) &frame->sctx;
@@ -1456,7 +1453,7 @@ int handle_signal32(unsigned long sig, s#if _NSIG !=64 #error "Please adjust handle_signal()"#endif -if (__put_user (to_user_ptr (ka->sa.sa_handler), &sc->handler) +if (__put_user (to_user_ptr (ksig->ka.sa.sa_handler), &sc->handler) ||__put_user (oldset->sig[0 ], &sc->oldmask) #ifdef CONFIG_PPC64 || __put_user((oldset->sig[0] >> 32), &sc->_unused[3])
@@ -1464,7 +1461,7 @@ int handle_signal32(unsigned long sig, s || __put_user(oldset->sig[1], &sc->_unused[3]) #endif || __put_user(to_user_ptr(&frame->mctx), &sc->regs) - || __put_user(sig, &sc->signal)) + || __put_user(ksig->sig, &sc->signal)) goto badframe;if (vdso32_sigtramp && current->mm->context.vdso_base) {
@@ -1499,12 +1496,12 @@ int handle_signal32(unsigned long sig, s goto badframe; regs->gpr[1 ] = newsp; - regs->gpr[3 ] = sig; + regs->gpr[3 ] = ksig->sig; regs->gpr[4 ] = (unsigned long ) sc; - regs->nip = (unsigned long ) ka->sa.sa_handler; + regs->nip = (unsigned long ) (unsigned long )ksig->ka.sa.sa_handler;/* enter the signal handler in big-endian mode */ regs->msr &= ~MSR_LE ; -return 1 ; +return 0 ; badframe:if (show_unhandled_signals)
@@ -1514,8 +1511,7 @@ badframe: current->comm, current->pid, frame, regs->nip, regs->link); -force_sigsegv (sig, current); -return 0 ; +return 1 ; }/*
arch/powerpc/kernel/signal_64.c +13 -15
@@ -743,20 +743,19 @@ badframe:return 0 ; } -int handle_rt_signal64 (int signr,struct k_sigaction *ka,siginfo_t *info, -sigset_t *set,struct pt_regs *regs) +int handle_rt_signal64 (struct ksignal *ksig,sigset_t *set,struct pt_regs *regs) {struct rt_sigframe __user *frame;unsigned long newsp =0 ;long err =0 ; - frame =get_sigframe (ka,get_tm_stackpointer (regs),sizeof (*frame),0 ); + frame =get_sigframe (&ksig->ka,get_tm_stackpointer (regs),sizeof (*frame),0 );if (unlikely (frame ==NULL )) goto badframe; err |=__put_user (&frame->info, &frame->pinfo); err |=__put_user (&frame->uc, &frame->puc); - err |=copy_siginfo_to_user (&frame->info, info); + err |=copy_siginfo_to_user (&frame->info, &ksig->info);if (err) goto badframe;
@@ -771,15 +770,15 @@ int handle_rt_signal64(int signr, struct err |=__put_user (&frame->uc_transact, &frame->uc.uc_link); err |=setup_tm_sigcontexts (&frame->uc.uc_mcontext, &frame->uc_transact.uc_mcontext, - regs, signr, + regs, ksig->sig,NULL , - (unsigned long )ka->sa.sa_handler); + (unsigned long )ksig->ka.sa.sa_handler); } else#endif { err |=__put_user (0 , &frame->uc.uc_link); - err |=setup_sigcontext (&frame->uc.uc_mcontext, regs, signr, -NULL , (unsigned long )ka->sa.sa_handler, + err |=setup_sigcontext (&frame->uc.uc_mcontext, regs, ksig->sig, +NULL , (unsigned long )ksig->ka.sa.sa_handler,1 ); } err |=__copy_to_user (&frame->uc.uc_sigmask, set,sizeof (*set));
@@ -805,7 +804,7 @@ int handle_rt_signal64(int signr, struct/* Set up "regs" so we "return" to the signal handler. */ if (is_elf2_task ()) { - regs->nip = (unsigned long ) ka->sa.sa_handler; + regs->nip = (unsigned long ) ksig->ka.sa.sa_handler; regs->gpr[12 ] = regs->nip; }else {/* Handler is *really* a pointer to the function descriptor for
@@ -814,7 +813,7 @@ int handle_rt_signal64(int signr, struct* entry is the TOC value we need to use. */ func_descr_t __user *funct_desc_ptr = - (func_descr_t __user *) ka->sa.sa_handler; + (func_descr_t __user *) ksig->ka.sa.sa_handler; err |=get_user (regs->nip, &funct_desc_ptr->entry); err |=get_user (regs->gpr[2 ], &funct_desc_ptr->toc);
@@ -824,9 +823,9 @@ int handle_rt_signal64(int signr, struct regs->msr &= ~MSR_LE ; regs->msr |= (MSR_KERNEL &MSR_LE ); regs->gpr[1 ] = newsp; - regs->gpr[3 ] = signr; + regs->gpr[3 ] = ksig->sig; regs->result =0 ; -if (ka->sa.sa_flags &SA_SIGINFO ) { +if (ksig->ka.sa.sa_flags &SA_SIGINFO ) { err |=get_user (regs->gpr[4 ], (unsigned long __user *)&frame->pinfo); err |=get_user (regs->gpr[5 ], (unsigned long __user *)&frame->puc); regs->gpr[6 ] = (unsigned long ) frame;
@@ -836,7 +835,7 @@ int handle_rt_signal64(int signr, structif (err) goto badframe; -return 1 ; +return 0 ; badframe:if (show_unhandled_signals)
@@ -844,6 +843,5 @@ badframe: current->comm, current->pid,"setup_rt_frame" , (long)frame, regs->nip, regs->link); -force_sigsegv (signr, current); -return 0 ; +return 1 ; }
PATCH 124/202 powerpc: Use sigsp()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit 059ade650ae57cfd371af690fdba887af04aded8 upstream.
Use sigsp() instead of the open coded variant.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- arch/powerpc/kernel/signal.c | 10 ++-------- arch/powerpc/kernel/signal_32.c | 4 ++-- arch/powerpc/kernel/signal_64.c | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-)
arch/powerpc/kernel/signal.c +2 -8
@@ -31,20 +31,14 @@ int show_unhandled_signals = 1;/* * Allocate space for the signal frame */ -void __user *get_sigframe (struct k_sigaction *ka,unsigned long sp, +void __user *get_sigframe (struct ksignal *ksig,unsigned long sp,size_t frame_size,int is_32) {unsigned long oldsp, newsp;/* Default to using normal stack */ oldsp =get_clean_sp (sp, is_32); - -/* Check for alt stack */ -if ((ka->sa.sa_flags &SA_ONSTACK ) && - current->sas_ss_size && !on_sig_stack (oldsp)) - oldsp = (current->sas_ss_sp + current->sas_ss_size); - -/* Get aligned frame */ + oldsp =sigsp (oldsp, ksig); newsp = (oldsp - frame_size) & ~0xFUL ;/* Check access */
arch/powerpc/kernel/signal_32.c +2 -2
@@ -1014,7 +1014,7 @@ int handle_rt_signal32(struct ksignal *k/* Set up Signal Frame */ /* Put a Real Time Context onto stack */ - rt_sf =get_sigframe (&ksig->ka,get_tm_stackpointer (regs),sizeof (*rt_sf),1 ); + rt_sf =get_sigframe (ksig,get_tm_stackpointer (regs),sizeof (*rt_sf),1 ); addr = rt_sf;if (unlikely (rt_sf ==NULL )) goto badframe;
@@ -1445,7 +1445,7 @@ int handle_signal32(struct ksignal *ksigunsigned long tramp;/* Set up Signal Frame */ - frame =get_sigframe (&ksig->ka,get_tm_stackpointer (regs),sizeof (*frame),1 ); + frame =get_sigframe (ksig,get_tm_stackpointer (regs),sizeof (*frame),1 );if (unlikely (frame ==NULL )) goto badframe; sc = (struct sigcontext __user *) &frame->sctx;
arch/powerpc/kernel/signal_64.c +1 -1
@@ -749,7 +749,7 @@ int handle_rt_signal64(struct ksignal *kunsigned long newsp =0 ;long err =0 ; - frame =get_sigframe (&ksig->ka,get_tm_stackpointer (regs),sizeof (*frame),0 ); + frame =get_sigframe (ksig,get_tm_stackpointer (regs),sizeof (*frame),0 );if (unlikely (frame ==NULL )) goto badframe;
PATCH 125/202 powerpc/signal: Properly handle return value from uprobe_deny_signal()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Naveen N. Rao" <[email protected]>
commit 46725b17f1c6c815a41429259b3f070c01e71bc1 upstream.
When a uprobe is installed on an instruction that we currently do not emulate, we copy the instruction into a xol buffer and single step that instruction. If that instruction generates a fault, we abort the single stepping before invoking the signal handler. Once the signal handler is done, the uprobe trap is hit again since the instruction is retried and the process repeats.
We use uprobe_deny_signal() to detect if the xol instruction triggered a signal. If so, we clear TIF_SIGPENDING and set TIF_UPROBE so that the signal is not handled until after the single stepping is aborted. In this case, uprobe_deny_signal() returns true and get_signal() ends up returning 0. However, in do_signal(), we are not looking at the return value, but depending on ksig.sig for further action, all with an uninitialized ksig that is not touched in this scenario. Fix the same by initializing ksig.sig to 0.
--- arch/powerpc/kernel/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/signal.c +1 -1
@@ -102,7 +102,7 @@ static void check_syscall_restart(structstatic void do_signal (struct pt_regs *regs) {sigset_t *oldset =sigmask_to_save (); -struct ksignal ksig; +struct ksignal ksig = { .sig =0 };int ret;int is32 =is_32bit_task ();
PATCH 126/202 s390: Use get_signal() signal_setup_done()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit 067bf2d4d3a7aedc5982f6a58716054e5004b801 upstream.
Use the more generic functions get_signal() signal_setup_done() for signal delivery.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- arch/s390/kernel/compat_signal.c | 79 ++++++++++++++------------------ arch/s390/kernel/entry.h | 4 +- arch/s390/kernel/signal.c | 78 +++++++++++++------------------ 3 files changed, 69 insertions(+), 92 deletions(-)
arch/s390/kernel/compat_signal.c +35 -44
@@ -320,38 +320,39 @@ static inline int map_signal(int sig)return sig; } -static int setup_frame32 (int sig,struct k_sigaction *ka, -sigset_t *set,struct pt_regs * regs) +static int setup_frame32 (struct ksignal *ksig,sigset_t *set, +struct pt_regs *regs) { -sigframe32 __user *frame =get_sigframe (ka, regs,sizeof (sigframe32)); +int sig = ksig->sig; +sigframe32 __user *frame =get_sigframe (&ksig->ka, regs,sizeof (sigframe32));if (frame == (void __user *)-1UL ) - goto give_sigsegv; +return -EFAULT ;if (__copy_to_user (&frame->sc.oldmask, &set->sig, _SIGMASK_COPY_SIZE32)) - goto give_sigsegv; +return -EFAULT ;if (save_sigregs32 (regs, &frame->sregs)) - goto give_sigsegv; +return -EFAULT ;if (save_sigregs_gprs_high (regs, frame->gprs_high)) - goto give_sigsegv; +return -EFAULT ;if (__put_user ((unsigned long ) &frame->sregs, &frame->sc.sregs)) - goto give_sigsegv; +return -EFAULT ;/* Set up to return from userspace. If provided, use a stub already in userspace. */ -if (ka->sa.sa_flags &SA_RESTORER ) { - regs->gprs[14 ] = (__u64 __force ) ka->sa.sa_restorer |PSW32_ADDR_AMODE ; +if (ksig->ka.sa.sa_flags &SA_RESTORER ) { + regs->gprs[14 ] = (__u64 __force ) ksig->ka.sa.sa_restorer |PSW32_ADDR_AMODE ; }else { regs->gprs[14 ] = (__u64 __force ) frame->retcode |PSW32_ADDR_AMODE ;if (__put_user (S390_SYSCALL_OPCODE | __NR_sigreturn, (u16 __force __user *)(frame->retcode))) - goto give_sigsegv; +return -EFAULT ; }/* Set up backchain. */ if (__put_user (regs->gprs[15 ], (unsigned int __user *) frame)) - goto give_sigsegv; +return -EFAULT ;/* Set up registers for signal handler */ regs->gprs[15 ] = (__force __u64 ) frame;
@@ -359,7 +360,7 @@ static int setup_frame32(int sig, struct regs->psw.mask =PSW_MASK_BA | (PSW_USER_BITS &PSW_MASK_ASC ) | (regs->psw.mask & ~PSW_MASK_ASC ); - regs->psw.addr = (__force __u64 ) ka->sa.sa_handler; + regs->psw.addr = (__force __u64 ) ksig->ka.sa.sa_handler; regs->gprs[2 ] =map_signal (sig); regs->gprs[3 ] = (__force __u64) &frame->sc;
@@ -376,25 +377,21 @@ static int setup_frame32(int sig, struct/* Place signal number on stack to allow backtrace from handler. */ if (__put_user (regs->gprs[2 ], (int __force __user *) &frame->signo)) - goto give_sigsegv; +return -EFAULT ;return 0 ; - -give_sigsegv: -force_sigsegv (sig, current); -return -EFAULT ; } -static int setup_rt_frame32 (int sig,struct k_sigaction *ka,siginfo_t *info, -sigset_t *set,struct pt_regs * regs) +static int setup_rt_frame32 (struct ksignal *ksig,sigset_t *set, +struct pt_regs *regs) {int err =0 ; -rt_sigframe32 __user *frame =get_sigframe (ka, regs,sizeof (rt_sigframe32)); +rt_sigframe32 __user *frame =get_sigframe (&ksig->ka, regs,sizeof (rt_sigframe32));if (frame == (void __user *)-1UL ) - goto give_sigsegv; +return -EFAULT ; -if (copy_siginfo_to_user32 (&frame->info, info)) - goto give_sigsegv; +if (copy_siginfo_to_user32 (&frame->info, &ksig->info)) +return -EFAULT ;/* Create the ucontext. */ err |=__put_user (UC_EXTENDED , &frame->uc.uc_flags);
@@ -404,22 +401,22 @@ static int setup_rt_frame32(int sig, str err |=save_sigregs_gprs_high (regs, frame->gprs_high); err |=__copy_to_user (&frame->uc.uc_sigmask, set,sizeof (*set));if (err) - goto give_sigsegv; +return -EFAULT ;/* Set up to return from userspace. If provided, use a stub already in userspace. */ -if (ka->sa.sa_flags &SA_RESTORER ) { - regs->gprs[14 ] = (__u64 __force ) ka->sa.sa_restorer |PSW32_ADDR_AMODE ; +if (ksig->ka.sa.sa_flags &SA_RESTORER ) { + regs->gprs[14 ] = (__u64 __force ) ksig->ka.sa.sa_restorer |PSW32_ADDR_AMODE ; }else { regs->gprs[14 ] = (__u64 __force ) frame->retcode |PSW32_ADDR_AMODE ;if (__put_user (S390_SYSCALL_OPCODE | __NR_rt_sigreturn, (u16 __force __user *)(frame->retcode))) - goto give_sigsegv; +return -EFAULT ; }/* Set up backchain. */ if (__put_user (regs->gprs[15 ], (unsigned int __force __user *) frame)) - goto give_sigsegv; +return -EFAULT ;/* Set up registers for signal handler */ regs->gprs[15 ] = (__force __u64 ) frame;
@@ -427,36 +424,30 @@ static int setup_rt_frame32(int sig, str regs->psw.mask =PSW_MASK_BA | (PSW_USER_BITS &PSW_MASK_ASC ) | (regs->psw.mask & ~PSW_MASK_ASC ); - regs->psw.addr = (__u64 __force ) ka->sa.sa_handler; + regs->psw.addr = (__u64 __force ) ksig->ka.sa.sa_handler; - regs->gprs[2 ] =map_signal (sig); + regs->gprs[2 ] =map_signal (ksig->sig); regs->gprs[3 ] = (__force __u64) &frame->info; regs->gprs[4 ] = (__force __u64) &frame->uc; regs->gprs[5 ] =task_thread_info (current)->last_break;return 0 ; - -give_sigsegv: -force_sigsegv (sig, current); -return -EFAULT ; }/* * OK, we're invoking a handler */ -void handle_signal32 (unsigned long sig,struct k_sigaction *ka, -siginfo_t *info,sigset_t *oldset,struct pt_regs *regs) +void handle_signal32 (struct ksignal *ksig,sigset_t *oldset, +struct pt_regs *regs) {int ret;/* Set up the stack frame */ -if (ka->sa.sa_flags &SA_SIGINFO ) - ret =setup_rt_frame32 (sig, ka, info, oldset, regs); +if (ksig->ka.sa.sa_flags &SA_SIGINFO ) + ret =setup_rt_frame32 (ksig, oldset, regs);else - ret =setup_frame32 (sig, ka, oldset, regs); -if (ret) -return ; -signal_delivered (sig, info, ka, regs, -test_thread_flag (TIF_SINGLE_STEP )); + ret =setup_frame32 (ksig, oldset, regs); + +signal_setup_done (ret, ksig,test_thread_flag (TIF_SINGLE_STEP )); }
arch/s390/kernel/entry.h +2 -2
@@ -48,8 +48,8 @@ void do_per_trap(struct pt_regs *regs);void syscall_trace (struct pt_regs *regs,int entryexit);void kernel_stack_overflow (struct pt_regs * regs);void do_signal (struct pt_regs *regs); -void handle_signal32 (unsigned long sig,struct k_sigaction *ka, -siginfo_t *info,sigset_t *oldset,struct pt_regs *regs); +void handle_signal32 (struct ksignal *ksig,sigset_t *oldset, +struct pt_regs *regs);void do_notify_resume (struct pt_regs *regs);void __init init_IRQ (void );
arch/s390/kernel/signal.c +32 -46
178 lines not on this page · raw message
PATCH 127/202 score: Use get_signal() signal_setup_done()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit 2bb12b773feb3e792145961e57ab356e6134d4a5 upstream.
Use the more generic functions get_signal() signal_setup_done() for signal delivery.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- arch/score/kernel/signal.c | 43 ++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 25 deletions(-)
arch/score/kernel/signal.c +18 -25
@@ -173,15 +173,15 @@ badframe:return 0 ; } -static int setup_rt_frame (struct k_sigaction *ka,struct pt_regs *regs, -int signr,sigset_t *set,siginfo_t *info) +static int setup_rt_frame (struct ksignal *ksig,struct pt_regs *regs, +sigset_t *set) {struct rt_sigframe __user *frame;int err =0 ; - frame =get_sigframe (ka, regs,sizeof (*frame)); + frame =get_sigframe (&ksig->ka, regs,sizeof (*frame));if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame))) - goto give_sigsegv; +return -EFAULT ;/* * Set up the return code ...
@@ -194,7 +194,7 @@ static int setup_rt_frame(struct k_sigac err |=__put_user (0x80008002 , frame->rs_code +1 );flush_cache_sigtramp ((unsigned long ) frame->rs_code); - err |=copy_siginfo_to_user (&frame->rs_info, info); + err |=copy_siginfo_to_user (&frame->rs_info, &ksig->info); err |=__put_user (0 , &frame->rs_uc.uc_flags); err |=__put_user (NULL , &frame->rs_uc.uc_link); err |=__save_altstack (&frame->rs_uc.uc_stack, regs->regs[0 ]);
@@ -202,26 +202,23 @@ static int setup_rt_frame(struct k_sigac err |=__copy_to_user (&frame->rs_uc.uc_sigmask, set,sizeof (*set));if (err) - goto give_sigsegv; +return -EFAULT ; regs->regs[0 ] = (unsigned long ) frame; regs->regs[3 ] = (unsigned long ) frame->rs_code; - regs->regs[4 ] = signr; + regs->regs[4 ] = ksig->sig; regs->regs[5 ] = (unsigned long ) &frame->rs_info; regs->regs[6 ] = (unsigned long ) &frame->rs_uc; - regs->regs[29 ] = (unsigned long ) ka->sa.sa_handler; - regs->cp0_epc = (unsigned long ) ka->sa.sa_handler; + regs->regs[29 ] = (unsigned long ) ksig->ka.sa.sa_handler; + regs->cp0_epc = (unsigned long ) ksig->ka.sa.sa_handler;return 0 ; - -give_sigsegv: -force_sigsegv (signr, current); -return -EFAULT ; } -static void handle_signal (unsigned long sig,siginfo_t *info, -struct k_sigaction *ka,struct pt_regs *regs) +static void handle_signal (struct ksignal *ksig,struct pt_regs *regs) { +int ret; +if (regs->is_syscall) {switch (regs->regs[4 ]) {case ERESTART_RESTARTBLOCK :
@@ -229,7 +226,7 @@ static void handle_signal(unsigned long regs->regs[4 ] =EINTR ;break ;case ERESTARTSYS : -if (!(ka->sa.sa_flags &SA_RESTART )) { +if (!(ksig->ka.sa.sa_flags &SA_RESTART )) { regs->regs[4 ] =EINTR ;break ; }
@@ -245,17 +242,14 @@ static void handle_signal(unsigned long/* * Set up the stack frame */ -if (setup_rt_frame (ka, regs, sig,sigmask_to_save (), info) <0 ) -return ; + ret =setup_rt_frame (ksig, regs,sigmask_to_save ()); -signal_delivered (sig, info, ka, regs,0 ); +signal_setup_done (ret, ksig,0 ); }static void do_signal (struct pt_regs *regs) { -struct k_sigaction ka; -siginfo_t info; -int signr; +struct ksignal ksig;/* * We want the common case to go fast, which is why we may in certain
@@ -265,10 +259,9 @@ static void do_signal(struct pt_regs *reif (!user_mode (regs))return ; - signr =get_signal_to_deliver (&info, &ka, regs,NULL ); -if (signr >0 ) { +if (get_signal (&ksig)) {/* Actually deliver the signal. */ -handle_signal (signr, &info, &ka, regs); +handle_signal (&ksig, regs);return ; }
PATCH 128/202 sh: Use get_signal() signal_setup_done()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit b46e848768acc458ba94feef162b8901592dbb9c upstream.
Use the more generic functions get_signal() signal_setup_done() for signal delivery.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- arch/sh/kernel/signal_32.c | 79 +++++++++++++++--------------------- arch/sh/kernel/signal_64.c | 82 +++++++++++++++----------------------- 2 files changed, 64 insertions(+), 97 deletions(-)
arch/sh/kernel/signal_32.c +32 -47
@@ -262,17 +262,17 @@ get_sigframe(struct k_sigaction *ka, unsextern void __kernel_sigreturn (void );extern void __kernel_rt_sigreturn (void ); -static int setup_frame (int sig,struct k_sigaction *ka, -sigset_t *set,struct pt_regs *regs) +static int setup_frame (struct ksignal *ksig,sigset_t *set, +struct pt_regs *regs) {struct sigframe __user *frame; -int err =0 ; +int err =0 , sig = ksig->sig;int signal; - frame =get_sigframe (ka, regs->regs[15 ],sizeof (*frame)); + frame =get_sigframe (&ksig->ka, regs->regs[15 ],sizeof (*frame));if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame))) - goto give_sigsegv; +return -EFAULT ; signal =current_thread_info ()->exec_domain &¤t_thread_info ()->exec_domain->signal_invmap
@@ -288,8 +288,8 @@ static int setup_frame(int sig, struct k/* Set up to return from userspace. If provided, use a stub already in userspace. */ -if (ka->sa.sa_flags &SA_RESTORER ) { - regs->pr = (unsigned long ) ka->sa.sa_restorer; +if (ksig->ka.sa.sa_flags &SA_RESTORER ) { + regs->pr = (unsigned long ) ksig->ka.sa.sa_restorer; #ifdef CONFIG_VSYSCALL }else if (likely (current->mm->context.vdso)) { regs->pr =VDSO_SYM (&__kernel_sigreturn);
@@ -309,7 +309,7 @@ static int setup_frame(int sig, struct k }if (err) - goto give_sigsegv; +return -EFAULT ;/* Set up registers for signal handler */ regs->regs[15 ] = (unsigned long ) frame;
@@ -319,15 +319,15 @@ static int setup_frame(int sig, struct kif (current->personality &FDPIC_FUNCPTRS ) {struct fdpic_func_descriptor __user *funcptr = - (struct fdpic_func_descriptor __user *)ka->sa.sa_handler; + (struct fdpic_func_descriptor __user *)ksig->ka.sa.sa_handler; err |=__get_user (regs->pc, &funcptr->text); err |=__get_user (regs->regs[12 ], &funcptr->GOT); }else - regs->pc = (unsigned long )ka->sa.sa_handler; + regs->pc = (unsigned long )ksig->ka.sa.sa_handler;if (err) - goto give_sigsegv; +return -EFAULT ;set_fs (USER_DS );
@@ -335,23 +335,19 @@ static int setup_frame(int sig, struct k current->comm, task_pid_nr(current), frame, regs->pc, regs->pr);return 0 ; - -give_sigsegv: -force_sigsegv (sig, current); -return -EFAULT ; } -static int setup_rt_frame (int sig,struct k_sigaction *ka,siginfo_t *info, -sigset_t *set,struct pt_regs *regs) +static int setup_rt_frame (struct ksignal *ksig,sigset_t *set, +struct pt_regs *regs) {struct rt_sigframe __user *frame; -int err =0 ; +int err =0 , sig = ksig->sig;int signal; - frame =get_sigframe (ka, regs->regs[15 ],sizeof (*frame)); + frame =get_sigframe (&ksig->ka, regs->regs[15 ],sizeof (*frame));if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame))) - goto give_sigsegv; +return -EFAULT ; signal =current_thread_info ()->exec_domain &¤t_thread_info ()->exec_domain->signal_invmap
@@ -359,7 +355,7 @@ static int setup_rt_frame(int sig, struc ?current_thread_info ()->exec_domain->signal_invmap[sig] : sig; - err |=copy_siginfo_to_user (&frame->info, info); + err |=copy_siginfo_to_user (&frame->info, &ksig->info);/* Create the ucontext. */ err |=__put_user (0 , &frame->uc.uc_flags);
@@ -371,8 +367,8 @@ static int setup_rt_frame(int sig, struc/* Set up to return from userspace. If provided, use a stub already in userspace. */ -if (ka->sa.sa_flags &SA_RESTORER ) { - regs->pr = (unsigned long ) ka->sa.sa_restorer; +if (ksig->ka.sa.sa_flags &SA_RESTORER ) { + regs->pr = (unsigned long ) ksig->ka.sa.sa_restorer; #ifdef CONFIG_VSYSCALL }else if (likely (current->mm->context.vdso)) { regs->pr =VDSO_SYM (&__kernel_rt_sigreturn);
@@ -392,7 +388,7 @@ static int setup_rt_frame(int sig, struc }if (err) - goto give_sigsegv; +return -EFAULT ;/* Set up registers for signal handler */ regs->regs[15 ] = (unsigned long ) frame;
@@ -402,15 +398,15 @@ static int setup_rt_frame(int sig, strucif (current->personality &FDPIC_FUNCPTRS ) {struct fdpic_func_descriptor __user *funcptr = - (struct fdpic_func_descriptor __user *)ka->sa.sa_handler; + (struct fdpic_func_descriptor __user *)ksig->ka.sa.sa_handler; err |=__get_user (regs->pc, &funcptr->text); err |=__get_user (regs->regs[12 ], &funcptr->GOT); }else - regs->pc = (unsigned long )ka->sa.sa_handler; + regs->pc = (unsigned long )ksig->ka.sa.sa_handler;if (err) - goto give_sigsegv; +return -EFAULT ;set_fs (USER_DS );
@@ -418,10 +414,6 @@ static int setup_rt_frame(int sig, struc current->comm, task_pid_nr(current), frame, regs->pc, regs->pr);return 0 ; - -give_sigsegv: -force_sigsegv (sig, current); -return -EFAULT ; } static inline void
@@ -455,22 +447,18 @@ handle_syscall_restart(unsigned long sav* OK, we're invoking a handler */ static void -handle_signal (unsigned long sig,struct k_sigaction *ka,siginfo_t *info, -struct pt_regs *regs,unsigned int save_r0) +handle_signal (struct ksignal *ksig,struct pt_regs *regs,unsigned int save_r0) {sigset_t *oldset =sigmask_to_save ();int ret;/* Set up the stack frame */ -if (ka->sa.sa_flags &SA_SIGINFO ) - ret =setup_rt_frame (sig, ka, info, oldset, regs); +if (ksig->ka.sa.sa_flags &SA_SIGINFO ) + ret =setup_rt_frame (ksig, oldset, regs);else - ret =setup_frame (sig, ka, oldset, regs); + ret =setup_frame (ksig, oldset, regs); -if (ret) -return ; -signal_delivered (sig, info, ka, regs, -test_thread_flag (TIF_SINGLESTEP )); +signal_setup_done (ret, ksig,test_thread_flag (TIF_SINGLESTEP )); }/*
@@ -484,9 +472,7 @@ handle_signal(unsigned long sig, struct*/ static void do_signal (struct pt_regs *regs,unsigned int save_r0) { -siginfo_t info; -int signr; -struct k_sigaction ka; +struct ksignal ksig;/* * We want the common case to go fast, which
@@ -497,12 +483,11 @@ static void do_signal(struct pt_regs *reif (!user_mode (regs))return ; - signr =get_signal_to_deliver (&info, &ka, regs,NULL ); -if (signr >0 ) { -handle_syscall_restart (save_r0, regs, &ka.sa); +if (get_signal (&ksig)) { +handle_syscall_restart (save_r0, regs, &ksig.ka.sa);/* Whee! Actually deliver the signal. */ -handle_signal (signr, &ka, &info, regs, save_r0); +handle_signal (&ksig, regs, save_r0);return ; }
arch/sh/kernel/signal_64.c +32 -50
212 lines not on this page · raw message
PATCH 129/202 tile: Use get_signal() signal_setup_done()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit b3707c7ed013d36752272ca2f9ed20dc8aed92e4 upstream.
Use the more generic functions get_signal() signal_setup_done() for signal delivery.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- arch/tile/include/asm/compat.h | 3 +- arch/tile/kernel/compat_signal.c | 29 ++++++++--------- arch/tile/kernel/signal.c | 54 ++++++++++++++------------------ 3 files changed, 40 insertions(+), 46 deletions(-)
arch/tile/include/asm/compat.h +1 -2
@@ -267,8 +267,7 @@ static inline int is_compat_task(void)return current_thread_info ()->status &TS_COMPAT ; } -extern int compat_setup_rt_frame (int sig,struct k_sigaction *ka, -siginfo_t *info,sigset_t *set, +extern int compat_setup_rt_frame (struct ksignal *ksig,sigset_t *set,struct pt_regs *regs);/* Compat syscalls. */
arch/tile/kernel/compat_signal.c +15 -14
@@ -190,18 +190,18 @@ static inline void __user *compat_get_sireturn (void __user *) sp; } -int compat_setup_rt_frame (int sig,struct k_sigaction *ka,siginfo_t *info, -sigset_t *set,struct pt_regs *regs) +int compat_setup_rt_frame (struct ksignal *ksig,sigset_t *set, +struct pt_regs *regs) {unsigned long restorer;struct compat_rt_sigframe __user *frame; -int err =0 ; +int err =0 , sig = ksig->sig;int usig; - frame =compat_get_sigframe (ka, regs,sizeof (*frame)); + frame =compat_get_sigframe (&ksig->ka, regs,sizeof (*frame));if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame))) - goto give_sigsegv; + goto err; usig =current_thread_info ()->exec_domain &¤t_thread_info ()->exec_domain->signal_invmap
@@ -210,12 +210,12 @@ int compat_setup_rt_frame(int sig, struc : sig;/* Always write at least the signal number for the stack backtracer. */ -if (ka->sa.sa_flags &SA_SIGINFO ) { +if (ksig->ka.sa.sa_flags &SA_SIGINFO ) {/* At sigreturn time, restore the callee-save registers too. */ - err |=copy_siginfo_to_user32 (&frame->info, info); + err |=copy_siginfo_to_user32 (&frame->info, &ksig->info); regs->flags |=PT_FLAGS_RESTORE_REGS ; }else { - err |=__put_user (info->si_signo, &frame->info.si_signo); + err |=__put_user (ksig->info.si_signo, &frame->info.si_signo); }/* Create the ucontext. */
@@ -226,11 +226,11 @@ int compat_setup_rt_frame(int sig, struc err |=setup_sigcontext (&frame->uc.uc_mcontext, regs); err |=__copy_to_user (&frame->uc.uc_sigmask, set,sizeof (*set));if (err) - goto give_sigsegv; + goto err; restorer =VDSO_SYM (&__vdso_rt_sigreturn); -if (ka->sa.sa_flags &SA_RESTORER ) - restorer =ptr_to_compat_reg (ka->sa.sa_restorer); +if (ksig->ka.sa.sa_flags &SA_RESTORER ) + restorer =ptr_to_compat_reg (ksig->ka.sa.sa_restorer);/* * Set up registers for signal handler.
@@ -239,7 +239,7 @@ int compat_setup_rt_frame(int sig, struc* We always pass siginfo and mcontext, regardless of SA_SIGINFO, * since some things rely on this (e.g. glibc's debug/segfault.c). */ - regs->pc =ptr_to_compat_reg (ka->sa.sa_handler); + regs->pc =ptr_to_compat_reg (ksig->ka.sa.sa_handler); regs->ex1 =PL_ICS_EX1 (USER_PL ,1 );/* set crit sec in handler */ regs->sp =ptr_to_compat_reg (frame); regs->lr = restorer;
@@ -249,7 +249,8 @@ int compat_setup_rt_frame(int sig, struc regs->flags |=PT_FLAGS_CALLER_SAVES ;return 0 ; -give_sigsegv: -signal_fault ("bad setup frame" , regs, frame, sig); +err: +trace_unhandled_signal ("bad sigreturn frame" , regs, + (unsigned long )frame,SIGSEGV );return -EFAULT ; }
arch/tile/kernel/signal.c +24 -30
129 lines not on this page · raw message
PATCH 130/202 um: Use get_signal() signal_setup_done()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit 307627eebbb0bc41b21e74d78b932362a6c1b38d upstream.
Use the more generic functions get_signal() signal_setup_done() for signal delivery.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- arch/um/include/shared/frame_kern.h | 12 +++----- arch/um/kernel/signal.c | 27 +++++++---------- arch/x86/um/signal.c | 45 ++++++++++++++--------------- 3 files changed, 36 insertions(+), 48 deletions(-)
arch/um/include/shared/frame_kern.h +4 -8
@@ -6,14 +6,10 @@#ifndef __FRAME_KERN_H_#define __FRAME_KERN_H_ -extern int setup_signal_stack_sc (unsigned long stack_top,int sig, -struct k_sigaction *ka, -struct pt_regs *regs, -sigset_t *mask); -extern int setup_signal_stack_si (unsigned long stack_top,int sig, -struct k_sigaction *ka, -struct pt_regs *regs,struct siginfo *info, -sigset_t *mask); +extern int setup_signal_stack_sc (unsigned long stack_top,struct ksignal *ksig, +struct pt_regs *regs,sigset_t *mask); +extern int setup_signal_stack_si (unsigned long stack_top,struct ksignal *ksig, +struct pt_regs *regs,sigset_t *mask);#endif
arch/um/kernel/signal.c +11 -16
@@ -18,8 +18,7 @@ EXPORT_SYMBOL(unblock_signals);/* * OK, we're invoking a handler */ -static void handle_signal (struct pt_regs *regs,unsigned long signr, -struct k_sigaction *ka,struct siginfo *info) +static void handle_signal (struct ksignal *ksig,struct pt_regs *regs) {sigset_t *oldset =sigmask_to_save ();int singlestep =0 ;
@@ -39,7 +38,7 @@ static void handle_signal(struct pt_regsbreak ;case -ERESTARTSYS : -if (!(ka->sa.sa_flags &SA_RESTART )) { +if (!(ksig->ka.sa.sa_flags &SA_RESTART )) {PT_REGS_SYSCALL_RET (regs) = -EINTR ;break ; }
@@ -52,32 +51,28 @@ static void handle_signal(struct pt_regs } sp =PT_REGS_SP (regs); -if ((ka->sa.sa_flags &SA_ONSTACK ) && (sas_ss_flags (sp) ==0 )) +if ((ksig->ka.sa.sa_flags &SA_ONSTACK ) && (sas_ss_flags (sp) ==0 )) sp = current->sas_ss_sp + current->sas_ss_size;#ifdef CONFIG_ARCH_HAS_SC_SIGNALS -if (!(ka->sa.sa_flags &SA_SIGINFO )) - err =setup_signal_stack_sc (sp, signr, ka, regs, oldset); +if (!(ksig->ka.sa.sa_flags &SA_SIGINFO )) + err =setup_signal_stack_sc (sp, ksig, regs, oldset); else#endif - err =setup_signal_stack_si (sp, signr, ka, regs, info, oldset); + err =setup_signal_stack_si (sp, ksig, regs, oldset); -if (err) -force_sigsegv (signr, current); -else -signal_delivered (signr, info, ka, regs, singlestep); +signal_setup_done (err, ksig, singlestep); }static int kern_do_signal (struct pt_regs *regs) { -struct k_sigaction ka_copy; -struct siginfo info; -int sig, handled_sig =0 ; +struct ksignal ksig; +int handled_sig =0 ; -while ((sig =get_signal_to_deliver (&info, &ka_copy, regs,NULL )) >0 ) { +while (get_signal (&ksig)) { handled_sig =1 ;/* Whee! Actually deliver the signal. */ -handle_signal (regs, sig, &ka_copy, &info); +handle_signal (&ksig, regs); }/* Did we come from a system call? */
arch/x86/um/signal.c +21 -24
118 lines not on this page · raw message
PATCH 131/202 unicore32: Use get_signal() signal_setup_done()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit 649671c90eaf3cbbd0cd03460b6a92c0b674a32e upstream.
Use the more generic functions get_signal() signal_setup_done() for signal delivery.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- arch/unicore32/kernel/signal.c | 48 ++++++++++++++-------------------- 1 file changed, 20 insertions(+), 28 deletions(-)
arch/unicore32/kernel/signal.c +20 -28
@@ -238,10 +238,10 @@ static int setup_return(struct pt_regs *regs, struct k_sigaction *ka,return 0 ; } -static int setup_frame (int usig,struct k_sigaction *ka, -sigset_t *set,struct pt_regs *regs) +static int setup_frame (struct ksignal *ksig,sigset_t *set, +struct pt_regs *regs) { -struct sigframe __user *frame =get_sigframe (ka, regs,sizeof (*frame)); +struct sigframe __user *frame =get_sigframe (&ksig->ka, regs,sizeof (*frame));int err =0 ;if (!frame)
@@ -254,29 +254,29 @@ static int setup_frame(int usig, struct k_sigaction *ka, err |=setup_sigframe (frame, regs, set);if (err ==0 ) - err |=setup_return (regs, ka, frame->retcode, frame, usig); + err |=setup_return (regs, &ksig->ka, frame->retcode, frame, usig);return err; } -static int setup_rt_frame (int usig,struct k_sigaction *ka,siginfo_t *info, -sigset_t *set,struct pt_regs *regs) +static int setup_rt_frame (struct ksignal *ksig,sigset_t *set, +struct pt_regs *regs) {struct rt_sigframe __user *frame = -get_sigframe (ka, regs,sizeof (*frame)); +get_sigframe (&ksig->ka, regs,sizeof (*frame));int err =0 ;if (!frame)return 1 ; - err |=copy_siginfo_to_user (&frame->info, info); + err |=copy_siginfo_to_user (&frame->info, &ksig->info); err |=__put_user (0 , &frame->sig.uc.uc_flags); err |=__put_user (NULL , &frame->sig.uc.uc_link); err |=__save_altstack (&frame->sig.uc.uc_stack, regs->UCreg_sp); err |=setup_sigframe (&frame->sig, regs, set);if (err ==0 ) - err |=setup_return (regs, ka, frame->sig.retcode, frame, usig); + err |=setup_return (regs, &ksig->ka, frame->sig.retcode, frame, usig);if (err ==0 ) {/*
@@ -299,13 +299,13 @@ static inline void setup_syscall_restart(struct pt_regs *regs)/* * OK, we're invoking a handler */ -static void handle_signal (unsigned long sig,struct k_sigaction *ka, -siginfo_t *info,struct pt_regs *regs,int syscall) +static void handle_signal (struct ksignal *ksig,struct pt_regs *regs, +int syscall) {struct thread_info *thread =current_thread_info ();struct task_struct *tsk = current;sigset_t *oldset =sigmask_to_save (); -int usig = sig; +int usig = ksig->sig;int ret;/*
@@ -318,7 +318,7 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka, regs->UCreg_00 = -EINTR ;break ;case -ERESTARTSYS : -if (!(ka->sa.sa_flags &SA_RESTART )) { +if (!(ksig->ka.sa.sa_flags &SA_RESTART )) { regs->UCreg_00 = -EINTR ;break ; }
@@ -338,22 +338,17 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka,/* * Set up the stack frame */ -if (ka->sa.sa_flags &SA_SIGINFO ) - ret =setup_rt_frame (usig, ka, info, oldset, regs); +if (ksig->ka.sa.sa_flags &SA_SIGINFO ) + ret =setup_rt_frame (ksig, oldset, regs);else - ret =setup_frame (usig, ka, oldset, regs); + ret =setup_frame (ksig, oldset, regs);/* * Check that the resulting registers are actually sane. */ ret |= !valid_user_regs (regs); -if (ret !=0 ) { -force_sigsegv (sig, tsk); -return ; - } - -signal_delivered (sig, info, ka, regs,0 ); +signal_setup_done (ret, ksig,0 ); }/*
@@ -367,9 +362,7 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka,*/ static void do_signal (struct pt_regs *regs,int syscall) { -struct k_sigaction ka; -siginfo_t info; -int signr; +struct ksignal ksig;/* * We want the common case to go fast, which
@@ -380,9 +373,8 @@ static void do_signal(struct pt_regs *regs, int syscall)if (!user_mode (regs))return ; - signr =get_signal_to_deliver (&info, &ka, regs,NULL ); -if (signr >0 ) { -handle_signal (signr, &ka, &info, regs, syscall); +if (get_signsl (&ksig)) { +handle_signal (&ksig, regs, syscall);return ; }
PATCH 132/202 unicore32: Fix build error
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
commit ca98565a6182a960cd857d7546267a0775154eb8 upstream.
unicore32 builds fail with
arch/unicore32/kernel/signal.c: In function ‘setup_frame’:
arch/unicore32/kernel/signal.c:257: error: ‘usig’ undeclared (first use in this function) arch/unicore32/kernel/signal.c:279: error: ‘usig’ undeclared (first use in this function) arch/unicore32/kernel/signal.c: In function ‘handle_signal’:
arch/unicore32/kernel/signal.c:306: warning: unused variable ‘tsk’ arch/unicore32/kernel/signal.c: In function ‘do_signal’:
arch/unicore32/kernel/signal.c:376: error: implicit declaration of function ‘get_signsl’ make[1]: *** [arch/unicore32/kernel/signal.o] Error 1
make: *** [arch/unicore32/kernel/signal.o] Error 2
Bisect points to commit 649671c90eaf ("unicore32: Use get_signal() signal_setup_done()").
This code never even compiled. Reverting the patch does not work, since previously used functions no longer exist, so try to fix it up. Compile tested only.
--- arch/unicore32/kernel/signal.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
arch/unicore32/kernel/signal.c +5 -4
@@ -254,7 +254,8 @@ static int setup_frame(struct ksignal *k err |=setup_sigframe (frame, regs, set);if (err ==0 ) - err |=setup_return (regs, &ksig->ka, frame->retcode, frame, usig); + err |=setup_return (regs, &ksig->ka, frame->retcode, frame, + ksig->sig);return err; }
@@ -276,7 +277,8 @@ static int setup_rt_frame(struct ksignal err |=__save_altstack (&frame->sig.uc.uc_stack, regs->UCreg_sp); err |=setup_sigframe (&frame->sig, regs, set);if (err ==0 ) - err |=setup_return (regs, &ksig->ka, frame->sig.retcode, frame, usig); + err |=setup_return (regs, &ksig->ka, frame->sig.retcode, frame, + ksig->sig);if (err ==0 ) {/*
@@ -303,7 +305,6 @@ static void handle_signal(struct ksignal int syscall) {struct thread_info *thread =current_thread_info (); -struct task_struct *tsk = current;sigset_t *oldset =sigmask_to_save ();int usig = ksig->sig;int ret;
@@ -373,7 +374,7 @@ static void do_signal(struct pt_regs *reif (!user_mode (regs))return ; -if (get_signsl (&ksig)) { +if (get_signal (&ksig)) {handle_signal (&ksig, regs, syscall);return ; }
PATCH 133/202 xtensa: Use get_signal() signal_setup_done()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit 5bdb7611eb7987102f3c0fef1220dd64b6fbd9fd upstream.
Use the more generic functions get_signal() signal_setup_done() for signal delivery.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- arch/xtensa/kernel/signal.c | 43 ++++++++++++++----------------------- 1 file changed, 16 insertions(+), 27 deletions(-)
arch/xtensa/kernel/signal.c +16 -27
@@ -331,17 +331,17 @@ gen_return_code(unsigned char *codemem) } -static int setup_frame (int sig,struct k_sigaction *ka,siginfo_t *info, -sigset_t *set,struct pt_regs *regs) +static int setup_frame (struct ksignal *ksig,sigset_t *set, +struct pt_regs *regs) {struct rt_sigframe *frame; -int err =0 ; +int err =0 , sig = ksig->sig;int signal;unsigned long sp, ra, tp; sp = regs->areg[1 ]; -if ((ka->sa.sa_flags &SA_ONSTACK ) !=0 &&sas_ss_flags (sp) ==0 ) { +if ((ksig->ka.sa.sa_flags &SA_ONSTACK ) !=0 &&sas_ss_flags (sp) ==0 ) { sp = current->sas_ss_sp + current->sas_ss_size; }
@@ -351,7 +351,7 @@ static int setup_frame(int sig, struct k_sigaction *ka, siginfo_t *info,panic ("Double exception sys_sigreturn\n" );if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame))) { - goto give_sigsegv; +return -EFAULT ; } signal =current_thread_info ()->exec_domain
@@ -360,8 +360,8 @@ static int setup_frame(int sig, struct k_sigaction *ka, siginfo_t *info, ?current_thread_info ()->exec_domain->signal_invmap[sig] : sig; -if (ka->sa.sa_flags &SA_SIGINFO ) { - err |=copy_siginfo_to_user (&frame->info, info); +if (ksig->ka.sa.sa_flags &SA_SIGINFO ) { + err |=copy_siginfo_to_user (&frame->info, &ksig->info); }/* Create the user context. */
@@ -372,8 +372,8 @@ static int setup_frame(int sig, struct k_sigaction *ka, siginfo_t *info, err |=setup_sigcontext (frame, regs); err |=__copy_to_user (&frame->uc.uc_sigmask, set,sizeof (*set)); -if (ka->sa.sa_flags &SA_RESTORER ) { - ra = (unsigned long )ka->sa.sa_restorer; +if (ksig->ka.sa.sa_flags &SA_RESTORER ) { + ra = (unsigned long )ksig->ka.sa.sa_restorer; }else {/* Create sys_rt_sigreturn syscall in stack frame */
@@ -381,7 +381,7 @@ static int setup_frame(int sig, struct k_sigaction *ka, siginfo_t *info, err |=gen_return_code (frame->retcode);if (err) { - goto give_sigsegv; +return -EFAULT ; } ra = (unsigned long ) frame->retcode; }
@@ -393,7 +393,7 @@ static int setup_frame(int sig, struct k_sigaction *ka, siginfo_t *info,/* Set up registers for signal handler; preserve the threadptr */ tp = regs->threadptr; -start_thread (regs, (unsigned long ) ka->sa.sa_handler, +start_thread (regs, (unsigned long ) ksig->ka.sa.sa_handler, (unsigned long ) frame);/* Set up a stack frame for a call4
@@ -416,10 +416,6 @@ static int setup_frame(int sig, struct k_sigaction *ka, siginfo_t *info,#endif return 0 ; - -give_sigsegv: -force_sigsegv (sig, current); -return -EFAULT ; }/*
@@ -433,15 +429,11 @@ static int setup_frame(int sig, struct k_sigaction *ka, siginfo_t *info,*/ static void do_signal (struct pt_regs *regs) { -siginfo_t info; -int signr; -struct k_sigaction ka; +struct ksignal ksig;task_pt_regs (current)->icountlevel =0 ; - signr =get_signal_to_deliver (&info, &ka, regs,NULL ); - -if (signr >0 ) { +if (get_signal (&ksig)) {int ret;/* Are we from a system call? */
@@ -457,7 +449,7 @@ static void do_signal(struct pt_regs *regs)break ;case -ERESTARTSYS : -if (!(ka.sa.sa_flags &SA_RESTART )) { +if (!(ksig.ka.sa.sa_flags &SA_RESTART )) { regs->areg[2 ] = -EINTR ;break ; }
@@ -476,11 +468,8 @@ static void do_signal(struct pt_regs *regs)/* Whee! Actually deliver the signal. */ /* Set up the stack frame */ - ret =setup_frame (signr, &ka, &info,sigmask_to_save (), regs); -if (ret) -return ; - -signal_delivered (signr, &info, &ka, regs,0 ); + ret =setup_frame (&ksig,sigmask_to_save (), regs); +signal_setup_done (ret, &ksig,0 );if (current->ptrace &PT_SINGLESTEP )task_pt_regs (current)->icountlevel =1 ;
PATCH 134/202 tracehook_signal_handler: Remove sig, info, ka and regs
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit df5601f9c3d831b4c478b004a1ed90a18643adbe upstream.
These parameters are nowhere used, so we can remove them.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- include/linux/tracehook.h | 8 +------- kernel/signal.c | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-)
include/linux/tracehook.h +1 -7
@@ -133,10 +133,6 @@ static inline void tracehook_report_sysc/** * tracehook_signal_handler - signal handler setup is complete -* @sig: number of signal being delivered -* @info: siginfo_t of signal being delivered -* @ka: sigaction setting that chose the handler -* @regs: user register state * @stepping: nonzero if debugger single-step or block-step in use * * Called by the arch code after a signal handler has been set up.
@@ -146,9 +142,7 @@ static inline void tracehook_report_sysc* Called without locks, shortly before returning to user mode * (or handling more signals). */ -static inline void tracehook_signal_handler (int sig,siginfo_t *info, -const struct k_sigaction *ka, -struct pt_regs *regs,int stepping) +static inline void tracehook_signal_handler (int stepping) {if (stepping)ptrace_notify (SIGTRAP );
kernel/signal.c +1 -1
@@ -2387,7 +2387,7 @@ void signal_delivered(int sig, siginfo_tif (!(ka->sa.sa_flags &SA_NODEFER ))sigaddset (&blocked, sig);set_current_blocked (&blocked); -tracehook_signal_handler (sig, info, ka, regs, stepping); +tracehook_signal_handler (stepping); }void signal_setup_done (int failed,struct ksignal *ksig,int stepping)
PATCH 135/202 Clean up signal_delivered()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit 10b1c7ac8bfed429cf3dcb0225482c8dc1485d8e upstream.
- Pass a ksignal struct to it
- Remove unused regs parameter
- Make it private as it's nowhere outside of kernel/signal.c is used
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- include/linux/signal.h | 1 - kernel/signal.c | 21 ++++++++------------- 2 files changed, 8 insertions(+), 14 deletions(-)
include/linux/signal.h +0 -1
@@ -281,7 +281,6 @@ struct ksignal {extern int get_signal_to_deliver (siginfo_t *info,struct k_sigaction *return_ka,struct pt_regs *regs,void *cookie);extern void signal_setup_done (int failed,struct ksignal *ksig,int stepping); -extern void signal_delivered (int sig,siginfo_t *info,struct k_sigaction *ka,struct pt_regs *regs,int stepping);extern void exit_signals (struct task_struct *tsk);extern void kernel_sigaction (int ,__sighandler_t );
kernel/signal.c +8 -13
@@ -2361,19 +2361,15 @@ relock:/** * signal_delivered - -* @sig: number of signal being delivered -* @info: siginfo_t of signal being delivered -* @ka: sigaction setting that chose the handler -* @regs: user register state +* @ksig: kernel signal struct * @stepping: nonzero if debugger single-step or block-step in use * * This function should be called when a signal has successfully been -* delivered. It updates the blocked signals accordingly (@ka->sa.sa_mask +* delivered. It updates the blocked signals accordingly (@ksig->ka.sa.sa_mask * is always blocked, and the signal itself is blocked unless %SA_NODEFER -* is set in @ka->sa.sa_flags. Tracing is notified. +* is set in @ksig->ka.sa.sa_flags. Tracing is notified. */ -void signal_delivered (int sig,siginfo_t *info,struct k_sigaction *ka, -struct pt_regs *regs,int stepping) +static void signal_delivered (struct ksignal *ksig,int stepping) {sigset_t blocked;
@@ -2383,9 +2379,9 @@ void signal_delivered(int sig, siginfo_tsimply clear the restore sigmask flag. */ clear_restore_sigmask (); -sigorsets (&blocked, ¤t->blocked, &ka->sa.sa_mask); -if (!(ka->sa.sa_flags &SA_NODEFER )) -sigaddset (&blocked, sig); +sigorsets (&blocked, ¤t->blocked, &ksig->ka.sa.sa_mask); +if (!(ksig->ka.sa.sa_flags &SA_NODEFER )) +sigaddset (&blocked, ksig->sig);set_current_blocked (&blocked);tracehook_signal_handler (stepping); }
@@ -2395,8 +2391,7 @@ void signal_setup_done(int failed, strucif (failed)force_sigsegv (ksig->sig, current);else -signal_delivered (ksig->sig, &ksig->info, &ksig->ka, -signal_pt_regs (), stepping); +signal_delivered (ksig, stepping); }/*
PATCH 136/202 Rip out get_signal_to_deliver()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit 828b1f65d23cf8a68795739f6dd08fc8abd9ee64 upstream.
Now we can turn get_signal() to the main function.
[bwh: Backported to 3.16 as dependency of commit 35634ffa1751
"signal: Always notice exiting tasks"]
--- include/linux/signal.h | 14 +------------- kernel/signal.c | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 24 deletions(-)
include/linux/signal.h +1 -13
@@ -279,7 +279,7 @@ struct ksignal {int sig; }; -extern int get_signal_to_deliver (siginfo_t *info,struct k_sigaction *return_ka,struct pt_regs *regs,void *cookie); +extern int get_signal (struct ksignal *ksig);extern void signal_setup_done (int failed,struct ksignal *ksig,int stepping);extern void exit_signals (struct task_struct *tsk);extern void kernel_sigaction (int ,__sighandler_t );
@@ -299,18 +299,6 @@ static inline void disallow_signal(int skernel_sigaction (sig,SIG_IGN ); } -/* -* Eventually that'll replace get_signal_to_deliver(); macro for now, -* to avoid nastiness with include order. -*/ -#define get_signal (ksig) \ -({ \ - struct ksignal *p = (ksig); \ - p->sig = get_signal_to_deliver(&p->info, &p->ka, \ - signal_pt_regs(), NULL);\ - p->sig > 0; \ -}) -extern struct kmem_cache *sighand_cachep;int unhandled_signal (struct task_struct *tsk,int sig);
kernel/signal.c +12 -11
@@ -2174,8 +2174,7 @@ static int ptrace_signal(int signr, sigireturn signr; } -int get_signal_to_deliver (siginfo_t *info,struct k_sigaction *return_ka, -struct pt_regs *regs,void *cookie) +int get_signal (struct ksignal *ksig) {struct sighand_struct *sighand = current->sighand;struct signal_struct *signal = current->signal;
@@ -2245,13 +2244,13 @@ relock: goto relock; } - signr =dequeue_signal (current, ¤t->blocked, info); + signr =dequeue_signal (current, ¤t->blocked, &ksig->info);if (!signr)break ;/* will return 0 */ if (unlikely (current->ptrace) && signr !=SIGKILL ) { - signr =ptrace_signal (signr, info); + signr =ptrace_signal (signr, &ksig->info);if (!signr)continue ; }
@@ -2259,13 +2258,13 @@ relock: ka = &sighand->action[signr-1 ];/* Trace actually delivered signals. */ -trace_signal_deliver (signr, info, ka); +trace_signal_deliver (signr, &ksig->info, ka);if (ka->sa.sa_handler ==SIG_IGN )/* Do nothing. */ continue ;if (ka->sa.sa_handler !=SIG_DFL ) {/* Run the handler. */ - *return_ka = *ka; + ksig->ka = *ka;if (ka->sa.sa_flags &SA_ONESHOT ) ka->sa.sa_handler =SIG_DFL ;
@@ -2315,7 +2314,7 @@ relock:spin_lock_irq (&sighand->siglock); } -if (likely (do_signal_stop (info->si_signo))) { +if (likely (do_signal_stop (ksig->info.si_signo))) {/* It released the siglock. */ goto relock; }
@@ -2336,7 +2335,7 @@ relock:if (sig_kernel_coredump (signr)) {if (print_fatal_signals) -print_fatal_signal (info->si_signo); +print_fatal_signal (ksig->info.si_signo);proc_coredump_connector (current);/* * If it was able to dump core, this kills all
@@ -2346,17 +2345,19 @@ relock:* first and our do_group_exit call below will use * that value and ignore the one we pass it. */ -do_coredump (info); +do_coredump (&ksig->info); }/* * Death signals, no core dump. */ -do_group_exit (info->si_signo); +do_group_exit (ksig->info.si_signo);/* NOTREACHED */ }spin_unlock_irq (&sighand->siglock); -return signr; + + ksig->sig = signr; +return ksig->sig >0 ; }/**
PATCH 137/202 signal: Always notice exiting tasks
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Eric W. Biederman" <[email protected]>
commit 35634ffa1751b6efd8cf75010b509dcb0263e29b upstream.
Recently syzkaller was able to create unkillablle processes by creating a timer that is delivered as a thread local signal on SIGHUP, and receiving SIGHUP SA_NODEFERER. Ultimately causing a loop failing to deliver SIGHUP but always trying.
Upon examination it turns out part of the problem is actually most of the solution. Since 2.5 signal delivery has found all fatal signals, marked the signal group for death, and queued SIGKILL in every threads thread queue relying on signal->group_exit_code to preserve the information of which was the actual fatal signal.
The conversion of all fatal signals to SIGKILL results in the synchronous signal heuristic in next_signal kicking in and preferring SIGHUP to SIGKILL. Which is especially problematic as all fatal signals have already been transformed into SIGKILL.
Instead of dequeueing signals and depending upon SIGKILL to be the first signal dequeued, first test if the signal group has already been marked for death. This guarantees that nothing in the signal queue can prevent a process that needs to exit from exiting.
Ref: ebf5ebe31d2c ("[PATCH] signal-fixes-2.5.59-A4")
History Tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
--- kernel/signal.c | 6 ++++++ 1 file changed, 6 insertions(+)
kernel/signal.c +6 -0
@@ -2231,6 +2231,11 @@ relock: goto relock; } +/* Has this task already been marked for death? */ + ksig->info.si_signo = signr =SIGKILL ; +if (signal_group_exit (signal)) + goto fatal; +for (;;) {struct k_sigaction *ka;
@@ -2326,6 +2331,7 @@ relock:continue ; } + fatal:spin_unlock_irq (&sighand->siglock);/*
PATCH 138/202 signal: Better detection of synchronous signals
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Eric W. Biederman" <[email protected]>
commit 7146db3317c67b517258cb5e1b08af387da0618b upstream.
Recently syzkaller was able to create unkillablle processes by creating a timer that is delivered as a thread local signal on SIGHUP, and receiving SIGHUP SA_NODEFERER. Ultimately causing a loop failing to deliver SIGHUP but always trying.
When the stack overflows delivery of SIGHUP fails and force_sigsegv is called. Unfortunately because SIGSEGV is numerically higher than SIGHUP next_signal tries again to deliver a SIGHUP.
=46roma quality of implementation standpoint attempting to deliver the timer SIGHUP signal is wrong. We should attempt to deliver the synchronous SIGSEGV signal we just forced.
We can make that happening in a fairly straight forward manner by instead of just looking at the signal number we also look at the si_code. In particular for exceptions (aka synchronous signals) the si_code is always greater than 0.
That still has the potential to pick up a number of asynchronous signals as in a few cases the same si_codes that are used for synchronous signals are also used for asynchronous signals, and SI_KERNEL is also included in the list of possible si_codes.
Still the heuristic is much better and timer signals are definitely excluded. Which is enough to prevent all known ways for someone sending a process signals fast enough to cause unexpected and arguably incorrect behavior.
--- kernel/signal.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-)
kernel/signal.c +51 -1
@@ -684,6 +684,48 @@ int dequeue_signal(struct task_struct *treturn signr; } +static int dequeue_synchronous_signal (siginfo_t *info) +{ +struct task_struct *tsk = current; +struct sigpending *pending = &tsk->pending; +struct sigqueue *q, *sync =NULL ; + +/* +* Might a synchronous signal be in the queue? +*/ +if (!((pending->signal.sig[0 ] & ~tsk->blocked.sig[0 ]) &SYNCHRONOUS_MASK )) +return 0 ; + +/* +* Return the first synchronous signal in the queue. +*/ +list_for_each_entry (q, &pending->list, list) { +/* Synchronous signals have a postive si_code */ +if ((q->info.si_code >SI_USER ) && + (sigmask (q->info.si_signo) &SYNCHRONOUS_MASK )) { + sync = q; + goto next; + } + } +return 0 ; +next: +/* +* Check if there is another siginfo for the same signal. +*/ +list_for_each_entry_continue (q, &pending->list, list) { +if (q->info.si_signo == sync->info.si_signo) + goto still_pending; + } + +sigdelset (&pending->signal, sync->info.si_signo); +recalc_sigpending (); +still_pending: +list_del_init (&sync->list); +copy_siginfo (info, &sync->info); +__sigqueue_free (sync); +return info->si_signo; +} +/* * Tell a process that it has a new active signal.. *
@@ -2249,7 +2291,15 @@ relock: goto relock; } - signr =dequeue_signal (current, ¤t->blocked, &ksig->info); +/* +* Signals generated by the execution of an instruction +* need to be delivered before any other pending signals +* so that the instruction pointer in the signal stack +* frame points to the faulting instruction. +*/ + signr =dequeue_synchronous_signal (&ksig->info); +if (!signr) + signr =dequeue_signal (current, ¤t->blocked, &ksig->info);if (!signr)break ;/* will return 0 */
PATCH 139/202 sit: check if IPv6 enabled before calling ip6_err_gen_icmpv6_unreach()
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hangbin Liu <[email protected]>
commit 173656accaf583698bac3f9e269884ba60d51ef4 upstream.
If we disabled IPv6 from the kernel command line (ipv6.disable=1), we should not call ip6_err_gen_icmpv6_unreach(). This:
ip link add sit1 type sit local 192.0.2.1 remote 192.0.2.2 ttl 1 ip link set sit1 up
ip addr add 198.51.100.1/24 dev sit1
ping 198.51.100.2
if IPv6 is disabled at boot time, will crash the kernel.
v2: there's no need to use in6_dev_get(), use __in6_dev_get() instead,
as we only need to check that idev exists and we are under rcu_read_lock() (from netif_receive_skb_internal()).
--- net/ipv6/sit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv6/sit.c +2 -1
@@ -576,7 +576,8 @@ static int ipip6_err(struct sk_buff *skb goto out; err =0 ; -if (!ipip6_err_gen_icmpv6_unreach (skb)) +if (__in6_dev_get (skb->dev) && + !ipip6_err_gen_icmpv6_unreach (skb)) goto out;if (t->parms.iph.ttl ==0 && type ==ICMP_TIME_EXCEEDED )
PATCH 140/202 ALSA: usb-audio: Fix implicit fb endpoint setup by quirk
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Manuel Reinhardt <[email protected]>
commit 2bc16b9f3223d049b57202ee702fcb5b9b507019 upstream.
The commit a60945fd08e4 ("ALSA: usb-audio: move implicit fb quirks to separate function") introduced an error in the handling of quirks for implicit feedback endpoints. This commit fixes this.
If a quirk successfully sets up an implicit feedback endpoint, usb-audio no longer tries to find the implicit fb endpoint itself.
--- sound/usb/pcm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
sound/usb/pcm.c +8 -1
@@ -313,6 +313,9 @@ static int search_roland_implicit_fb(strreturn 0 ; } +/* Setup an implicit feedback endpoint from a quirk. Returns 0 if no quirk +* applies. Returns 1 if a quirk was found. +*/ static int set_sync_ep_implicit_fb_quirk(struct snd_usb_substream *subs, struct usb_device *dev, struct usb_interface_descriptor *altsd,
@@ -381,7 +384,7 @@ add_sync_ep: subs->data_endpoint->sync_master = subs->sync_endpoint; -return 0 ; +return 1 ; } static int set_sync_endpoint(struct snd_usb_substream *subs,
@@ -406,6 +409,10 @@ static int set_sync_endpoint(struct snd_if (err <0 )return err; +/* endpoint set by quirk */ +if (err >0 ) +return 0 ; +if (altsd->bNumEndpoints <2 )return 0 ;
PATCH 141/202 Input: elantech - force needed quirks on Fujitsu H760
In reply to Ben Hutchings3.16.66-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Matti Kurkela <[email protected]>
commit f9a703a54d16ba2470391c4b12236ee56591d50c upstream.
Just like Fujitsu CELSIUS H730, the H760 also has an Elantech touchpad with the same quirks. Without this patch, the touchpad is useless out-of-the-box as the mouse pointer won't move.
This patch makes the driver aware of both the crc_enabled=1 requirement and the middle button, making the touchpad fully functional out-of-the-box.
--- drivers/input/mouse/elantech.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/input/mouse/elantech.c +14 -0
@@ -1076,6 +1076,13 @@ static const struct dmi_system_id elante DMI_MATCH(DMI_PRODUCT_NAME, "CELSIUS H730"), }, }, + { +/* Fujitsu H760 also has a middle button */ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"FUJITSU" ), + DMI_MATCH(DMI_PRODUCT_NAME, "CELSIUS H760"), + }, + }, #endif { } };
@@ -1420,6 +1427,13 @@ static const struct dmi_system_id elante }, }, { +/* Fujitsu H760 does not work with crc_enabled == 0 */ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"FUJITSU" ), + DMI_MATCH(DMI_PRODUCT_NAME, "CELSIUS H760"), + }, + }, + {/* Fujitsu LIFEBOOK E544 does not work with crc_enabled == 0 */ .matches = { DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),