3.2.78-rc1 review
Subsystems (3)
cover 3.2.78-rc1 review
This is the start of the stable review cycle for the 3.2.78 release. There are 67 patches in this series, which will be posted as responses to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri Feb 25 00:00:00 UTC 2016. Anything received after that time might be too late.
A combined patch relative to 3.2.77 will be posted as an additional response to this. A shortlog and diffstat can be found below.
Ben.
-------------
Alan Stern (1):
SCSI: fix crashes in sd and sr runtime PM
[13b4389143413a1f18127c07f72c74cad5b563e8]
Alexandra Yates (1):
ahci: Intel DNV device IDs SATA
[342decff2b846b46fa61eb5ee40986fab79a9a32]
Andrey Konovalov (1):
ALSA: usb-audio: avoid freeing umidi object twice
[07d86ca93db7e5cdf4743564d98292042ec21af7]
Ben Hutchings (1):
pipe: Fix buffer offset after partially failed read
[not upstream; fixes a regression specific to stable branches]
Dan Carpenter (1):
intel_scu_ipcutil: underflow in scu_reg_access()
[b1d353ad3d5835b16724653b33c05124e1b5acf1]
Daniele Palmas (1):
USB: serial: option: Adding support for Telit LE922
[ff4e2494dc17b173468e1713fdf6237fd8578bc7]
David Sterba (1):
btrfs: properly set the termination value of ctx->pos in readdir
[bc4ef7592f657ae81b017207a1098817126ad4cb]Eric Dumazet (1):
af_unix: fix struct pid memory leak
[fa0dc04df259ba2df3ce1920e9690c7842f8fa4b]
Greg Kroah-Hartman (1):
USB: serial: ftdi_sio: add support for Yaesu SCU-18 cable
[e03cdf22a2727c60307be6a729233edab3bfda9c]
Hannes Frederic Sowa (2):
pptp: fix illegal memory access caused by multiple bind()s
[9a368aff9cb370298fa02feeffa861f2db497c18]
unix: correctly track in-flight fds in sending process user_struct
[415e3d3e90ce9e18727e8843ae343eda5a58fad6]
Hannes Reinecke (1):
scsi_dh_rdac: always retry MODE SELECT on command lock violation
[d2d06d4fe0f2cc2df9b17fefec96e6e1a1271d91]
Hariprasad S (1):
iw_cxgb3: Fix incorrectly returning error on success
[67f1aee6f45059fd6b0f5b0ecb2c97ad0451f6b3]
Herbert Xu (2):
crypto: algif_skcipher - Do not dereference ctx without socket lock
[6454c2b83f719057069777132b13949e4c6b6350]
crypto: shash - Fix has_key setting
[00420a65fa2beb3206090ead86942484df2275f3]
James Bottomley (1):
klist: fix starting point removed bug in klist iterators
[00cd29b799e3449f0c68b1cc77cd4a5f95b42d17]
Johan Hovold (1):
USB: visor: fix null-deref at probe
[cac9b50b0d75a1d50d6c056ff65c005f3224c8e0]
Johannes Berg (1):
rfkill: fix rfkill_fop_read wait_event usage
[6736fde9672ff6717ac576e9bba2fd5f3dfec822]
Linus Walleij (2):
ARM: 8517/1: ICST: avoid arithmetic overflow in icst_hz()
[5070fb14a0154f075c8b418e5bc58a620ae85a45]
ARM: 8519/1: ICST: try other dividends than 1
[e972c37459c813190461dabfeaac228e00aae259]
Lu Baolu (2):
usb: cdc-acm: send zero packet for intel 7260 modem
[ffdb1e369a73b380fce95b05f8498d92c43842b4]
usb: xhci: apply XHCI_PME_STUCK_QUIRK to Intel Broxton-M platforms
[ccc04afb72cddbdf7c0e1c17e92886405a71b754]
Marcelo Ricardo Leitner (1):
sctp: allow setting SCTP_SACK_IMMEDIATELY by the application
[27f7ed2b11d42ab6d796e96533c2076ec220affc]
Markus Trippelsdorf (1):
perf annotate browser: Fix behaviour of Shift-Tab with nothing focussed
[d4913cbd05bab685e49c8174896e563b2487d054]
Mathias Krause (1):
crypto: user - lock crypto_alg_list on alg dump
[63e41ebc6630f39422d87f8a4bade1e793f37a01]
Mathias Nyman (2):
Revert "xhci: don't finish a TD if we get a short-transfer event mid TD"
[a6835090716a85f2297668ba593bd00e1051e662]
xhci: Fix list corruption in urb dequeue at host removal
[5c82171167adb8e4ac77b91a42cd49fb211a81a0]
Matt Fleming (1):
x86/mm/pat: Avoid truncation when converting cpa->numpages to address
[742563777e8da62197d6cb4b99f4027f59454735]Mauro Carvalho Chehab (2):
[media] saa7134-alsa: Only frees registered sound cards
[ac75fe5d8fe4a0bf063be18fb29684405279e79e]
[media] tda1004x: only update the frontend properties if locked
[e8beb02343e7582980c6705816cd957cf4f74c7a]
Michael S. Tsirkin (1):
virtio_pci: fix use after free on release
[2989be09a8a9d62a785137586ad941f916e08f83]
Mike Galbraith (1):
sched: fix __sched_setscheduler() vs load balancing race
[not upstream; minimal alternative to upstream patch series]
Oliver Neukum (1):
cdc-acm:exclude Samsung phone 04e8:685d
[e912e685f372ab62a2405a1acd923597f524e94a]
Paolo Bonzini (1):
KVM: vmx: fix MPX detection
[920c837785699bcc48f4a729ba9ee3492f620b95]
Peter Dedecker (1):
USB: cp210x: add ID for IAI USB to RS485 adaptor
[f487c54ddd544e1c9172cd510954f697b77b76e3]Peter Hurley (1):
tty: Fix unsafe ldisc reference via ioctl(TIOCGETD)
[5c17c861a357e9458001f021a7afa7aab9937439]
Rob Clark (1):
drm/vmwgfx: respect 'nomodeset'
[96c5d076f0a5e2023ecdb44d8261f87641ee71e0]
Rui Y Wang (1):
crypto: algif_hash - wait for crypto_ahash_init() to complete
[fe09786178f9df713a4b2dd6b93c0a722346bf5e]
Sebastian Andrzej Siewior (1):
PCI/AER: Flush workqueue on device remove to avoid use-after-free
[4ae2182b1e3407de369f8c5d799543b7db74221b]
Takashi Iwai (16):
ALSA: dummy: Disable switching timer backend via sysfs
[7ee96216c31aabe1eb42fb91ff50dae9fcd014b2]
ALSA: dummy: Implement timer backend switching more safely
[ddce57a6f0a2d8d1bfacfa77f06043bc760403c2]
ALSA: pcm: Fix potential deadlock in OSS emulation
[b248371628aad599a48540962f6b85a21a8a0c3f]
ALSA: rawmidi: Fix race at copying & updating the position
[81f577542af15640cbcb6ef68baa4caa610cbbfc]
ALSA: rawmidi: Make snd_rawmidi_transmit() race-free
[06ab30034ed9c200a570ab13c017bde248ddb2a6]
ALSA: rawmidi: Remove kernel WARNING for NULL user-space buffer check
[cc85f7a634cfaf9f0713c6aa06d08817424db37a]
ALSA: seq: Degrade the error message for too many opens
[da10816e3d923565b470fec78a674baba794ed33]
ALSA: seq: Fix incorrect sanity check at snd_seq_oss_synth_cleanup()
[599151336638d57b98d92338aa59c048e3a3e97d]
ALSA: seq: Fix lockdep warnings due to double mutex locks
[7f0973e973cd74aa40747c9d38844560cd184ee8]
ALSA: seq: Fix race at closing in virmidi driver
[2d1b5c08366acd46c35a2e9aba5d650cb5bf5c19]
ALSA: seq: Fix yet another races among ALSA timer accesses
[2cdc7b636d55cbcf42e1e6c8accd85e62d3e9ae8]
ALSA: timer: Fix leftover link at closing
[094fd3be87b0f102589e2d5c3fa5d06b7e20496d]
ALSA: timer: Fix link corruption due to double start or stop
[f784beb75ce82f4136f8a0960d3ee872f7109e09]
ALSA: timer: Fix race at concurrent reads
[4dff5c7b7093b19c19d3a100f8a3ad87cb7cd9e7]
ALSA: timer: Fix race between stop and interrupt
[ed8b1d6d2c741ab26d60d499d7fbb7ac801f0f51]
ALSA: timer: Fix wrong instance passed to slave callbacks
[117159f0b9d392fb433a7871426fad50317f06f7]
Tejun Heo (2):
libata: disable forced PORTS_IMPL for >= AHCI 1.3
[566d1827df2ef0cbe921d3d6946ac3007b1a6938]
libata: fix sff host state machine locking while polling
[8eee1d3ed5b6fc8e14389567c9a6f53f82bb7224]
Tetsuo Handa (1):
mm, vmstat: fix wrong WQ sleep when memory reclaim doesn't make any progress
[564e81a57f9788b1475127012e0fd44e9049e342]
Thomas Gleixner (4):
hrtimer: Handle remaining time proper for TIME_LOW_RES
[203cbf77de59fc8f13502dcfd11350c6d4a5c95f]
itimers: Handle relative timers with CONFIG_TIME_LOW_RES proper
[51cbb5242a41700a3f250ecfb48dcfb7e4375ea4]
posix-timers: Handle relative timers with CONFIG_TIME_LOW_RES proper
[572c39172684c3711e4a03c9a7380067e2b0661c]
timerfd: Handle relative timers with CONFIG_TIME_LOW_RES proper
[b62526ed11a1fe3861ab98d40b7fdab8981d788a]
Vladis Dronov (1):
USB: serial: visor: fix crash on detecting device without write_urbs
[cb3232138e37129e88240a98a1d2aba2187ff57c]
Willy Tarreau (2):
pipe: limit the per-user amount of pages allocated in pipes
[759c01142a5d0f364a462346168a56de28a80f52]
unix: properly account for FDs passed over unix sockets
[712f4aad406bb1ed67f3f98d04c044191f0ff593]
Xin Long (1):
sctp: translate network order to host order when users get a hmacid
[7a84bd46647ff181eb2659fdc99590e6f16e501d]
Xuejiufei (1):
ocfs2/dlm: clear refmap bit of recovery lock while doing local recovery cleanup
[c95a51807b730e4681e2ecbdfd669ca52601959e]
Documentation/sysctl/fs.txt | 23 +++ Makefile | 4 +- arch/arm/common/icst.c | 9 +- arch/x86/kvm/x86.c | 3 +- arch/x86/mm/pageattr.c | 4 +- crypto/algif_hash.c | 4 +- crypto/algif_skcipher.c | 5 +- crypto/crypto_user.c | 6 +- crypto/shash.c | 7 +- drivers/ata/ahci.c | 20 +++ drivers/ata/libahci.c | 4 +- drivers/ata/libata-sff.c | 32 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 7 + drivers/infiniband/hw/cxgb3/iwch_cm.c | 4 +- drivers/media/dvb/frontends/tda1004x.c | 9 ++ drivers/media/video/saa7134/saa7134-alsa.c | 5 +- drivers/net/ppp/pptp.c | 34 +++-- drivers/pci/pcie/aer/aerdrv.c | 4 +- drivers/pci/pcie/aer/aerdrv.h | 1 - drivers/pci/pcie/aer/aerdrv_core.c | 2 - drivers/platform/x86/intel_scu_ipcutil.c | 2 +- drivers/scsi/device_handler/scsi_dh_rdac.c | 4 +- drivers/scsi/sd.c | 7 +- drivers/tty/tty_io.c | 24 ++- drivers/usb/class/cdc-acm.c | 11 ++ drivers/usb/class/cdc-acm.h | 1 + drivers/usb/host/xhci-pci.c | 4 +- drivers/usb/host/xhci-ring.c | 10 -- drivers/usb/host/xhci.c | 4 +- drivers/usb/serial/cp210x.c | 1 + drivers/usb/serial/ftdi_sio.c | 1 + drivers/usb/serial/ftdi_sio_ids.h | 1 + drivers/usb/serial/option.c | 16 ++ drivers/usb/serial/visor.c | 11 +- drivers/virtio/virtio_pci.c | 2 + fs/btrfs/delayed-inode.c | 3 +- fs/btrfs/delayed-inode.h | 2 +- fs/btrfs/inode.c | 14 +- fs/ocfs2/dlm/dlmrecovery.c | 2 + fs/pipe.c | 52 ++++++- fs/timerfd.c | 2 +- include/linux/hrtimer.h | 34 ++++- include/linux/pipe_fs_i.h | 4 + include/linux/sched.h | 2 + include/net/af_unix.h | 4 +- include/net/scm.h | 1 + include/sound/rawmidi.h | 4 + kernel/hrtimer.c | 56 ++++--- kernel/itimer.c | 2 +- kernel/posix-timers.c | 2 +- kernel/sched_fair.c | 9 ++ kernel/sysctl.c | 14 ++ kernel/time/timer_list.c | 2 +- lib/klist.c | 6 +- mm/backing-dev.c | 2 +- net/core/scm.c | 7 + net/rfkill/core.c | 16 +- net/sctp/socket.c | 10 +- net/unix/af_unix.c | 27 +++- net/unix/garbage.c | 18 ++- sound/core/oss/pcm_oss.c | 21 ++- sound/core/rawmidi.c | 134 ++++++++++++----- sound/core/seq/oss/seq_oss_init.c | 2 +- sound/core/seq/oss/seq_oss_synth.c | 2 +- sound/core/seq/seq_clientmgr.c | 3 + sound/core/seq/seq_ports.c | 233 ++++++++++++++++------------- sound/core/seq/seq_timer.c | 87 ++++++++--- sound/core/seq/seq_virmidi.c | 23 ++- sound/core/timer.c | 72 ++++++--- sound/drivers/dummy.c | 35 ++--- sound/usb/midi.c | 1 - tools/perf/util/ui/browsers/annotate.c | 4 +- 72 files changed, 844 insertions(+), 354 deletions(-)
Signature · 2 lines
Ben Hutchings Any smoothly functioning technology is indistinguishable from a rigged demo.
PATCH 1/67 KVM: vmx: fix MPX detection
3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Bonzini <[email protected]>
commit 920c837785699bcc48f4a729ba9ee3492f620b95 upstream.
kvm_x86_ops is still NULL at this point. Since kvm_init_msr_list cannot fail, it is safe to initialize it before the call.
[bwh: Dependency of "KVM: x86: expose MSR_TSC_AUX to userspace",
applied in 3.2.77]
--- arch/x86/kvm/x86.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kvm/x86.c +2 -1
@@ -5257,9 +5257,10 @@ int kvm_arch_init(void *opaque) goto out;kvm_set_mmio_spte_mask (); -kvm_init_msr_list (); kvm_x86_ops = ops; +kvm_init_msr_list (); +kvm_mmu_set_mask_ptes (PT_USER_MASK ,PT_ACCESSED_MASK ,PT_DIRTY_MASK ,PT64_NX_MASK ,0 );
PATCH 2/67 hrtimer: Handle remaining time proper for TIME_LOW_RES
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 203cbf77de59fc8f13502dcfd11350c6d4a5c95f upstream.
If CONFIG_TIME_LOW_RES is enabled we add a jiffie to the relative timeout to prevent short sleeps, but we do not account for that in interfaces which retrieve the remaining time.
Helge observed that timerfd can return a remaining time larger than the relative timeout. That's not expected and breaks userland test programs.
Store the information that the timer was armed relative and provide functions to adjust the remaining time. To avoid bloating the hrtimer struct make state a u8, which as a bonus results in better code on x86 at least.
[bwh: Backported to 3.2:
- Use #ifdef instead of IS_ENABLED() as that doesn't work for config symbols that don't exist on the current architecture
- Use KTIME_LOW_RES directly instead of hrtimer_resolution
- Use ktime_sub() instead of modifying ktime::tv64 directly
- Adjust filename, context]
--- include/linux/hrtimer.h | 34 +++++++++++++++++++++++++++--- kernel/hrtimer.c | 55 ++++++++++++++++++++++++++++++++---------------- kernel/time/timer_list.c | 2 +- 3 files changed, 69 insertions(+), 22 deletions(-)
include/linux/hrtimer.h +32 -2
@@ -96,6 +96,7 @@ enum hrtimer_restart {* @function: timer expiry callback function * @base: pointer to the timer base (per cpu and per clock) * @state: state information (See bit values above) +* @is_rel: Set if the timer was armed relative * @start_site: timer statistics field to store the site where the timer * was started * @start_comm: timer statistics field to store the name of the process which
@@ -110,7 +111,8 @@ struct hrtimer {ktime_t _softexpires;enum hrtimer_restart (*function)(struct hrtimer *);struct hrtimer_clock_base *base; -unsigned long state; +u8 state; +u8 is_rel;#ifdef CONFIG_TIMER_STATS int start_pid;void *start_site;
@@ -315,6 +317,29 @@ static inline void clock_was_set_delayed#endif +static inline ktime_t +__hrtimer_expires_remaining_adjusted (const struct hrtimer *timer,ktime_t now) +{ +ktime_t rem =ktime_sub (timer->node.expires, now); + +/* +* Adjust relative timers for the extra we added in +* hrtimer_start_range_ns() to prevent short timeouts. +*/ +#ifdef CONFIG_TIME_LOW_RES +if (timer->is_rel) + rem =ktime_sub (rem,KTIME_LOW_RES ); +#endif +return rem; +} + +static inline ktime_t +hrtimer_expires_remaining_adjusted (const struct hrtimer *timer) +{ +return __hrtimer_expires_remaining_adjusted (timer, + timer->base->get_time ()); +} +extern void clock_was_set (void );#ifdef CONFIG_TIMERFD extern void timerfd_clock_was_set (void );
@@ -383,7 +408,12 @@ static inline int hrtimer_restart(struct }/* Query timers: */ -extern ktime_t hrtimer_get_remaining (const struct hrtimer *timer); +extern ktime_t __hrtimer_get_remaining (const struct hrtimer *timer,bool adjust); + +static inline ktime_t hrtimer_get_remaining (const struct hrtimer *timer) +{ +return __hrtimer_get_remaining (timer, false); +}extern int hrtimer_get_res (const clockid_t which_clock,struct timespec *tp);extern ktime_t hrtimer_get_next_event (void );
kernel/hrtimer.c +39 -17
103 lines not on this page · raw message
kernel/time/timer_list.c +1 -1
@@ -57,7 +57,7 @@ print_timer(struct seq_file *m, struct hprint_name_offset (m, taddr);SEQ_printf (m,", " );print_name_offset (m, timer->function); -SEQ_printf (m,", S:%02lx" , timer->state); +SEQ_printf (m,", S:%02x" , timer->state);#ifdef CONFIG_TIMER_STATS SEQ_printf (m,", " );print_name_offset (m, timer->start_site);
PATCH 2/67 hrtimer: Handle remaining time proper for TIME_LOW_RES
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 203cbf77de59fc8f13502dcfd11350c6d4a5c95f upstream.
If CONFIG_TIME_LOW_RES is enabled we add a jiffie to the relative timeout to prevent short sleeps, but we do not account for that in interfaces which retrieve the remaining time.
Helge observed that timerfd can return a remaining time larger than the relative timeout. That's not expected and breaks userland test programs.
Store the information that the timer was armed relative and provide functions to adjust the remaining time. To avoid bloating the hrtimer struct make state a u8, which as a bonus results in better code on x86 at least.
[bwh: Backported to 3.2:
- Use #ifdef instead of IS_ENABLED() as that doesn't work for config symbols that don't exist on the current architecture
- Use KTIME_LOW_RES directly instead of hrtimer_resolution
- Use ktime_sub() instead of modifying ktime::tv64 directly
- Adjust filename, context]
--- include/linux/hrtimer.h | 34 +++++++++++++++++++++++++++--- kernel/hrtimer.c | 55 ++++++++++++++++++++++++++++++++---------------- kernel/time/timer_list.c | 2 +- 3 files changed, 69 insertions(+), 22 deletions(-)
include/linux/hrtimer.h +32 -2
@@ -96,6 +96,7 @@ enum hrtimer_restart {* @function: timer expiry callback function * @base: pointer to the timer base (per cpu and per clock) * @state: state information (See bit values above) +* @is_rel: Set if the timer was armed relative * @start_site: timer statistics field to store the site where the timer * was started * @start_comm: timer statistics field to store the name of the process which
@@ -110,7 +111,8 @@ struct hrtimer {ktime_t _softexpires;enum hrtimer_restart (*function)(struct hrtimer *);struct hrtimer_clock_base *base; -unsigned long state; +u8 state; +u8 is_rel;#ifdef CONFIG_TIMER_STATS int start_pid;void *start_site;
@@ -315,6 +317,29 @@ static inline void clock_was_set_delayed#endif +static inline ktime_t +__hrtimer_expires_remaining_adjusted (const struct hrtimer *timer,ktime_t now) +{ +ktime_t rem =ktime_sub (timer->node.expires, now); + +/* +* Adjust relative timers for the extra we added in +* hrtimer_start_range_ns() to prevent short timeouts. +*/ +#ifdef CONFIG_TIME_LOW_RES +if (timer->is_rel) + rem =ktime_sub (rem,KTIME_LOW_RES ); +#endif +return rem; +} + +static inline ktime_t +hrtimer_expires_remaining_adjusted (const struct hrtimer *timer) +{ +return __hrtimer_expires_remaining_adjusted (timer, + timer->base->get_time ()); +} +extern void clock_was_set (void );#ifdef CONFIG_TIMERFD extern void timerfd_clock_was_set (void );
@@ -383,7 +408,12 @@ static inline int hrtimer_restart(struct }/* Query timers: */ -extern ktime_t hrtimer_get_remaining (const struct hrtimer *timer); +extern ktime_t __hrtimer_get_remaining (const struct hrtimer *timer,bool adjust); + +static inline ktime_t hrtimer_get_remaining (const struct hrtimer *timer) +{ +return __hrtimer_get_remaining (timer, false); +}extern int hrtimer_get_res (const clockid_t which_clock,struct timespec *tp);extern ktime_t hrtimer_get_next_event (void );
kernel/hrtimer.c +39 -17
103 lines not on this page · raw message
kernel/time/timer_list.c +1 -1
@@ -57,7 +57,7 @@ print_timer(struct seq_file *m, struct hprint_name_offset (m, taddr);SEQ_printf (m,", " );print_name_offset (m, timer->function); -SEQ_printf (m,", S:%02lx" , timer->state); +SEQ_printf (m,", S:%02x" , timer->state);#ifdef CONFIG_TIMER_STATS SEQ_printf (m,", " );print_name_offset (m, timer->start_site);
PATCH 3/67 timerfd: Handle relative timers with CONFIG_TIME_LOW_RES proper
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit b62526ed11a1fe3861ab98d40b7fdab8981d788a upstream.
Helge reported that a relative timer can return a remaining time larger than the programmed relative time on parisc and other architectures which have CONFIG_TIME_LOW_RES set. This happens because we add a jiffie to the resulting expiry time to prevent short timeouts.
Use the new function hrtimer_expires_remaining_adjusted() to calculate the remaining time. It takes that extra added time into account for relative timers.
--- fs/timerfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/timerfd.c +1 -1
@@ -123,7 +123,7 @@ static ktime_t timerfd_get_remaining(str {ktime_t remaining; - remaining =hrtimer_expires_remaining (&ctx->tmr); + remaining =hrtimer_expires_remaining_adjusted (&ctx->tmr);return remaining.tv64 <0 ?ktime_set (0 ,0 ): remaining; }
PATCH 3/67 timerfd: Handle relative timers with CONFIG_TIME_LOW_RES proper
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit b62526ed11a1fe3861ab98d40b7fdab8981d788a upstream.
Helge reported that a relative timer can return a remaining time larger than the programmed relative time on parisc and other architectures which have CONFIG_TIME_LOW_RES set. This happens because we add a jiffie to the resulting expiry time to prevent short timeouts.
Use the new function hrtimer_expires_remaining_adjusted() to calculate the remaining time. It takes that extra added time into account for relative timers.
--- fs/timerfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/timerfd.c +1 -1
@@ -123,7 +123,7 @@ static ktime_t timerfd_get_remaining(str {ktime_t remaining; - remaining =hrtimer_expires_remaining (&ctx->tmr); + remaining =hrtimer_expires_remaining_adjusted (&ctx->tmr);return remaining.tv64 <0 ?ktime_set (0 ,0 ): remaining; }
PATCH 4/67 posix-timers: Handle relative timers with CONFIG_TIME_LOW_RES proper
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 572c39172684c3711e4a03c9a7380067e2b0661c upstream.
As Helge reported for timerfd we have the same issue in posix timers. We return remaining time larger than the programmed relative time to user space in case of CONFIG_TIME_LOW_RES=y. Use the proper function to adjust the extra time added in hrtimer_start_range_ns().
--- kernel/posix-timers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/posix-timers.c +1 -1
@@ -706,7 +706,7 @@ common_timer_get(struct k_itimer *timr, (timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE)) timr->it_overrun += (unsigned int) hrtimer_forward(timer, now, iv); - remaining =ktime_sub (hrtimer_get_expires (timer), now); + remaining =__hrtimer_expires_remaining_adjusted (timer, now);/* Return 0 only, when the timer is expired and not pending */ if (remaining.tv64 <=0 ) {/*
PATCH 4/67 posix-timers: Handle relative timers with CONFIG_TIME_LOW_RES proper
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 572c39172684c3711e4a03c9a7380067e2b0661c upstream.
As Helge reported for timerfd we have the same issue in posix timers. We return remaining time larger than the programmed relative time to user space in case of CONFIG_TIME_LOW_RES=y. Use the proper function to adjust the extra time added in hrtimer_start_range_ns().
--- kernel/posix-timers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/posix-timers.c +1 -1
@@ -706,7 +706,7 @@ common_timer_get(struct k_itimer *timr, (timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE)) timr->it_overrun += (unsigned int) hrtimer_forward(timer, now, iv); - remaining =ktime_sub (hrtimer_get_expires (timer), now); + remaining =__hrtimer_expires_remaining_adjusted (timer, now);/* Return 0 only, when the timer is expired and not pending */ if (remaining.tv64 <=0 ) {/*
PATCH 5/67 itimers: Handle relative timers with CONFIG_TIME_LOW_RES proper
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 51cbb5242a41700a3f250ecfb48dcfb7e4375ea4 upstream.
As Helge reported for timerfd we have the same issue in itimers. We return remaining time larger than the programmed relative time to user space in case of CONFIG_TIME_LOW_RES=y. Use the proper function to adjust the extra time added in hrtimer_start_range_ns().
--- kernel/itimer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/itimer.c +1 -1
@@ -26,7 +26,7 @@*/ static struct timeval itimer_get_remtime (struct hrtimer *timer) { -ktime_t rem =hrtimer_get_remaining (timer); +ktime_t rem =__hrtimer_get_remaining (timer, true);/* * Racy but safe: if the itimer expires after the above
PATCH 5/67 itimers: Handle relative timers with CONFIG_TIME_LOW_RES proper
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 51cbb5242a41700a3f250ecfb48dcfb7e4375ea4 upstream.
As Helge reported for timerfd we have the same issue in itimers. We return remaining time larger than the programmed relative time to user space in case of CONFIG_TIME_LOW_RES=y. Use the proper function to adjust the extra time added in hrtimer_start_range_ns().
--- kernel/itimer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/itimer.c +1 -1
@@ -26,7 +26,7 @@*/ static struct timeval itimer_get_remtime (struct hrtimer *timer) { -ktime_t rem =hrtimer_get_remaining (timer); +ktime_t rem =__hrtimer_get_remaining (timer, true);/* * Racy but safe: if the itimer expires after the above
PATCH 7/67 cdc-acm:exclude Samsung phone 04e8:685d
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit e912e685f372ab62a2405a1acd923597f524e94a upstream.
This phone needs to be handled by a specialised firmware tool and is reported to crash irrevocably if cdc-acm takes it.
--- drivers/usb/class/cdc-acm.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/class/cdc-acm.c +5 -0
@@ -1668,6 +1668,11 @@ static const struct usb_device_id acm_id .driver_info = NO_DATA_INTERFACE, }, +/*Samsung phone in firmware update mode */ + { USB_DEVICE(0x04e8, 0x685d), + .driver_info =IGNORE_DEVICE , + }, + /* Exclude Infineon Flash Loader utility */ { USB_DEVICE(0x058b, 0x0041), .driver_info = IGNORE_DEVICE,
PATCH 8/67 af_unix: fix struct pid memory leak
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit fa0dc04df259ba2df3ce1920e9690c7842f8fa4b upstream.
Dmitry reported a struct pid leak detected by a syzkaller program.
Bug happens in unix_stream_recvmsg() when we break the loop when a signal is pending, without properly releasing scm.
--- net/unix/af_unix.c | 1 + 1 file changed, 1 insertion(+)
net/unix/af_unix.c +1 -0
@@ -2100,6 +2100,7 @@ static int unix_stream_recvmsg(struct kiif (signal_pending (current)) { err =sock_intr_errno (timeo); +scm_destroy (siocb->scm); goto out; }
PATCH 10/67 sctp: allow setting SCTP_SACK_IMMEDIATELY by the application
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Marcelo Ricardo Leitner <[email protected]>
commit 27f7ed2b11d42ab6d796e96533c2076ec220affc upstream.
This patch extends commit b93d6471748d ("sctp: implement the sender side for SACK-IMMEDIATELY extension") as it didn't white list SCTP_SACK_IMMEDIATELY on sctp_msghdr_parse(), causing it to be understood as an invalid flag and returning -EINVAL to the application.
Note that the actual handling of the flag is already there in sctp_datamsg_from_user().
https://tools.ietf.org/html/rfc7053#section-7
[bwh: Backported to 3.2: drop the second hunk as we don't have SCTP_SNDINFO
cmsg support]
--- net/sctp/socket.c | 2 ++ 1 file changed, 2 insertions(+)
net/sctp/socket.c +1 -0
@@ -6241,6 +6241,7 @@ SCTP_STATIC int sctp_msghdr_parse(const/* Minimally, validate the sinfo_flags. */ if (cmsgs->info->sinfo_flags & ~(SCTP_UNORDERED |SCTP_ADDR_OVER | +SCTP_SACK_IMMEDIATELY |SCTP_ABORT |SCTP_EOF ))return -EINVAL ;break ;
PATCH 11/67 USB: cp210x: add ID for IAI USB to RS485 adaptor
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Peter Dedecker <[email protected]>
commit f487c54ddd544e1c9172cd510954f697b77b76e3 upstream.
Added the USB serial console device ID for IAI Corp. RCB-CV-USB USB to RS485 adaptor.
--- drivers/usb/serial/cp210x.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/serial/cp210x.c +1 -0
@@ -104,6 +104,7 @@ static const struct usb_device_id id_tab { USB_DEVICE(0x10C4, 0x81AC) }, /* MSD Dash Hawk */ { USB_DEVICE(0x10C4, 0x81AD) }, /* INSYS USB Modem */ { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */ + { USB_DEVICE(0x10C4, 0x81D7) }, /* IAI Corp. RCB-CV-USB USB to RS485 Adaptor */ { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */ { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */ { USB_DEVICE(0x10C4, 0x81E8) }, /* Zephyr Bioharness */
PATCH 14/67 USB: serial: option: Adding support for Telit LE922
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Daniele Palmas <[email protected]>
commit ff4e2494dc17b173468e1713fdf6237fd8578bc7 upstream.
This patch adds support for two PIDs of LE922.
--- drivers/usb/serial/option.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/usb/serial/option.c +16 -0
@@ -269,6 +269,8 @@ static void option_instat_callback(struc#define TELIT_PRODUCT_CC864_SINGLE 0x1006#define TELIT_PRODUCT_DE910_DUAL 0x1010#define TELIT_PRODUCT_UE910_V2 0x1012 +#define TELIT_PRODUCT_LE922_USBCFG0 0x1042 +#define TELIT_PRODUCT_LE922_USBCFG3 0x1043#define TELIT_PRODUCT_LE920 0x1200#define TELIT_PRODUCT_LE910 0x1201
@@ -621,6 +623,16 @@ static const struct option_blacklist_inf .reserved = BIT(1) | BIT(5), }; +static const struct option_blacklist_info telit_le922_blacklist_usbcfg0 = { + .sendsetup =BIT (2 ), + .reserved =BIT (0 ) |BIT (1 ) |BIT (3 ), +}; + +static const struct option_blacklist_info telit_le922_blacklist_usbcfg3 = { + .sendsetup =BIT (0 ), + .reserved =BIT (1 ) |BIT (2 ) |BIT (3 ), +}; +static const struct usb_device_id option_ids[] = { {USB_DEVICE (OPTION_VENDOR_ID ,OPTION_PRODUCT_COLT ) }, {USB_DEVICE (OPTION_VENDOR_ID ,OPTION_PRODUCT_RICOLA ) },
@@ -1166,6 +1178,10 @@ static const struct usb_device_id option { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_CC864_SINGLE) }, { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_DE910_DUAL) }, { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UE910_V2) }, + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG0), + .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg0 }, + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG3), + .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg3 }, { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910), .driver_info = (kernel_ulong_t)&telit_le910_blacklist }, { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920),
PATCH 16/67 ALSA: seq: Degrade the error message for too many opens
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit da10816e3d923565b470fec78a674baba794ed33 upstream.
ALSA OSS sequencer spews a kernel error message ("ALSA: seq_oss: too many applications") when user-space tries to open more than the limit. This means that it can easily fill the log buffer.
Since it's merely a normal error, it's safe to suppress it via pr_debug() instead.
--- sound/core/seq/oss/seq_oss_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/seq/oss/seq_oss_init.c +1 -1
@@ -196,7 +196,7 @@ snd_seq_oss_open(struct file *file, int dp->index = i;if (i >=SNDRV_SEQ_OSS_MAX_CLIENTS ) { -snd_printk (KERN_ERR "too many applications\n" ); +pr_debug ("ALSA: seq_oss: too many applications\n" ); rc = -ENOMEM ; goto _error; }
PATCH 17/67 USB: serial: ftdi_sio: add support for Yaesu SCU-18 cable
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit e03cdf22a2727c60307be6a729233edab3bfda9c upstream.
Harald Linden reports that the ftdi_sio driver works properly for the Yaesu SCU-18 cable if the device ids are added to the driver. So let's add them.
--- drivers/usb/serial/ftdi_sio.c | 1 + drivers/usb/serial/ftdi_sio_ids.h | 1 + 2 files changed, 2 insertions(+)
drivers/usb/serial/ftdi_sio.c +1 -0
@@ -848,6 +848,7 @@ static struct usb_device_id id_table_com { USB_DEVICE(FTDI_VID, FTDI_TURTELIZER_PID), .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) }, + { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_SCU18) }, { USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) },/* Papouch devices based on FTDI chip */
drivers/usb/serial/ftdi_sio_ids.h +1 -0
@@ -615,6 +615,7 @@*/ #define RATOC_VENDOR_ID 0x0584#define RATOC_PRODUCT_ID_USB60F 0xb020 +#define RATOC_PRODUCT_ID_SCU18 0xb03a/* * Acton Research Corp.
PATCH 18/67 PCI/AER: Flush workqueue on device remove to avoid use-after-free
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
commit 4ae2182b1e3407de369f8c5d799543b7db74221b upstream.
A Root Port's AER structure (rpc) contains a queue of events. aer_irq() enqueues AER status information and schedules aer_isr() to dequeue and process it. When we remove a device, aer_remove() waits for the queue to be empty, then frees the rpc struct.
But aer_isr() references the rpc struct after dequeueing and possibly emptying the queue, which can cause a use-after-free error as in the following scenario with two threads, aer_isr() on the left and a concurrent aer_remove() on the right:
Thread A Thread B
-------- --------
aer_irq():
rpc->prod_idx++
aer_remove():
wait_event(rpc->prod_idx == rpc->cons_idx)
# now blocked until queue becomes empty
aer_isr(): # ...
rpc->cons_idx++ # unblocked because queue is now empty
... kfree(rpc)
mutex_unlock(&rpc->rpc_mutex)To prevent this problem, use flush_work() to wait until the last scheduled instance of aer_isr() has completed before freeing the rpc struct in aer_remove().
I reproduced this use-after-free by flashing a device FPGA and re-enumerating the bus to find the new device. With SLUB debug, this crashes with 0x6b bytes (POISON_FREE, the use-after-free magic number) in GPR25:
pcieport 0000:00:00.0: AER: Multiple Corrected error received: id=0000
Unable to handle kernel paging request for data at address 0x27ef9e3e Workqueue: events aer_isr GPR24: dd6aa000 6b6b6b6b 605f8378 605f8360 d99b12c0 604fc674 606b1704 d99b12c0 NIP [602f5328] pci_walk_bus+0xd4/0x104
--- drivers/pci/pcie/aer/aerdrv.c | 4 +--- drivers/pci/pcie/aer/aerdrv.h | 1 - drivers/pci/pcie/aer/aerdrv_core.c | 2 -- 3 files changed, 1 insertion(+), 6 deletions(-)
drivers/pci/pcie/aer/aerdrv.c +1 -3
@@ -263,7 +263,6 @@ static struct aer_rpc *aer_alloc_rpc(str rpc->rpd = dev;INIT_WORK (&rpc->dpc_handler, aer_isr);mutex_init (&rpc->rpc_mutex); -init_waitqueue_head (&rpc->wait_release);/* Use PCIe bus function to store rpc into PCIe device */ set_service_data (dev, rpc);
@@ -286,8 +285,7 @@ static void aer_remove(struct pcie_devicif (rpc->isr)free_irq (dev->irq, dev); -wait_event (rpc->wait_release, rpc->prod_idx == rpc->cons_idx); - +flush_work (&rpc->dpc_handler);aer_disable_rootport (rpc);kfree (rpc);set_service_data (dev,NULL );
drivers/pci/pcie/aer/aerdrv.h +0 -1
@@ -76,7 +76,6 @@ struct aer_rpc {* recovery on the same * root port hierarchy */ -wait_queue_head_t wait_release; };struct aer_broadcast_data {
drivers/pci/pcie/aer/aerdrv_core.c +0 -2
@@ -823,8 +823,6 @@ void aer_isr(struct work_struct *work)while (get_e_source (rpc, &e_src))aer_isr_one_error (p_device, &e_src);mutex_unlock (&rpc->rpc_mutex); - -wake_up (&rpc->wait_release); }/**
PATCH 20/67 virtio_pci: fix use after free on release
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Michael S. Tsirkin" <[email protected]>
commit 2989be09a8a9d62a785137586ad941f916e08f83 upstream.
KASan detected a use-after-free error in virtio-pci remove code. In virtio_pci_remove(), vp_dev is still used after being freed in unregister_virtio_device() (in virtio_pci_release_dev() more precisely).
To fix, keep a reference until cleanup is done.
--- drivers/virtio/virtio_pci.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/virtio/virtio_pci.c +2 -0
@@ -698,6 +698,7 @@ out: static void __devexit virtio_pci_remove(struct pci_dev *pci_dev) {struct virtio_pci_device *vp_dev =pci_get_drvdata (pci_dev); +struct device *dev =get_device (&vp_dev->vdev.dev);unregister_virtio_device (&vp_dev->vdev);
@@ -706,6 +707,7 @@ static void __devexit virtio_pci_remove(pci_iounmap (pci_dev, vp_dev->ioaddr);pci_release_regions (pci_dev);pci_disable_device (pci_dev); +put_device (dev); }#ifdef CONFIG_PM
PATCH 21/67 rfkill: fix rfkill_fop_read wait_event usage
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit 6736fde9672ff6717ac576e9bba2fd5f3dfec822 upstream.
The code within wait_event_interruptible() is called with !TASK_RUNNING, so mustn't call any functions that can sleep, like mutex_lock().
Since we re-check the list_empty() in a loop after the wait, it's safe to simply use list_empty() without locking.
This bug has existed forever, but was only discovered now because all userspace implementations, including the default 'rfkill' tool, use poll() or select() to get a readable fd before attempting to read.
--- net/rfkill/core.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
net/rfkill/core.c +4 -12
@@ -1065,17 +1065,6 @@ static unsigned int rfkill_fop_poll(strureturn res; } -static bool rfkill_readable (struct rfkill_data *data) -{ -bool r; - -mutex_lock (&data->mtx); - r = !list_empty (&data->events); -mutex_unlock (&data->mtx); - -return r; -} -static ssize_t rfkill_fop_read (struct file *file,char __user *buf,size_t count,loff_t *pos) {
@@ -1092,8 +1081,11 @@ static ssize_t rfkill_fop_read(struct fi goto out; }mutex_unlock (&data->mtx); +/* since we re-check and it just compares pointers, +* using !list_empty() without locking isn't a problem +*/ ret =wait_event_interruptible (data->read_wait, -rfkill_readable (data)); + !list_empty (&data->events));mutex_lock (&data->mtx);if (ret)
PATCH 24/67 tty: Fix unsafe ldisc reference via ioctl(TIOCGETD)
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Peter Hurley <[email protected]>
commit 5c17c861a357e9458001f021a7afa7aab9937439 upstream.
ioctl(TIOCGETD) retrieves the line discipline id directly from the ldisc because the line discipline id (c_line) in termios is untrustworthy; userspace may have set termios via ioctl(TCSETS*) without actually changing the line discipline via ioctl(TIOCSETD).
However, directly accessing the current ldisc via tty->ldisc is unsafe; the ldisc ptr dereferenced may be stale if the line discipline is changing via ioctl(TIOCSETD) or hangup.
Wait for the line discipline reference (just like read() or write()) to retrieve the "current" line discipline id.
--- drivers/tty/tty_io.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
drivers/tty/tty_io.c +23 -1
@@ -2475,6 +2475,28 @@ static int tiocsetd(struct tty_struct *t }/** +* tiocgetd - get line discipline +* @tty: tty device +* @p: pointer to user data +* +* Retrieves the line discipline id directly from the ldisc. +* +* Locking: waits for ldisc reference (in case the line discipline +* is changing or the tty is being hungup) +*/ + +static int tiocgetd (struct tty_struct *tty,int __user *p) +{ +struct tty_ldisc *ld; +int ret; + + ld =tty_ldisc_ref_wait (tty); + ret =put_user (ld->ops->num, p); +tty_ldisc_deref (ld); +return ret; +} + +/** * send_break - performed time break * @tty: device to break on * @duration: timeout in mS
@@ -2684,7 +2706,7 @@ long tty_ioctl(struct file *file, unsigncase TIOCGSID :return tiocgsid (tty, real_tty, p);case TIOCGETD : -return put_user (tty->ldisc->ops->num, (int __user *)p); +return tiocgetd (tty, p);case TIOCSETD :return tiocsetd (tty, p);case TIOCVHANGUP :
PATCH 25/67 crypto: shash - Fix has_key setting
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
commit 00420a65fa2beb3206090ead86942484df2275f3 upstream.
The has_key logic is wrong for shash algorithms as they always have a setkey function. So we should instead be testing against shash_no_setkey.
--- crypto/shash.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
crypto/shash.c +3 -4
@@ -353,11 +353,10 @@ int crypto_init_shash_ops_async(struct c crt->final = shash_async_final; crt->finup = shash_async_finup; crt->digest = shash_async_digest; + crt->setkey = shash_async_setkey; + + crt->has_setkey = alg->setkey != shash_no_setkey; -if (alg->setkey) { - crt->setkey = shash_async_setkey; - crt->has_setkey = true; - }if (alg->export) crt->export = shash_async_export;if (alg->import)
PATCH 28/67 x86/mm/pat: Avoid truncation when converting cpa->numpages to address
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Matt Fleming <[email protected]>
commit 742563777e8da62197d6cb4b99f4027f59454735 upstream.
There are a couple of nasty truncation bugs lurking in the pageattr code that can be triggered when mapping EFI regions, e.g. when we pass a cpa->pgd pointer. Because cpa->numpages is a 32-bit value, shifting left by PAGE_SHIFT will truncate the resultant address to 32-bits.
Viorel-Cătălin managed to trigger this bug on his Dell machine that provides a ~5GB EFI region which requires 1236992 pages to be mapped. When calling populate_pud() the end of the region gets calculated incorrectly in the following buggy expression,
end = start + (cpa->numpages << PAGE_SHIFT);
And only 188416 pages are mapped. Next, populate_pud() gets invoked for a second time because of the loop in __change_page_attr_set_clr(), only this time no pages get mapped because shifting the remaining number of pages (1048576) by PAGE_SHIFT is zero. At which point the loop in __change_page_attr_set_clr() spins forever because we fail to map progress.
Hitting this bug depends very much on the virtual address we pick to map the large region at and how many pages we map on the initial run through the loop. This explains why this issue was only recently hit with the introduction of commit
a5caa209ba9c ("x86/efi: Fix boot crash by mapping EFI memmap
entries bottom-up at runtime, instead of top-down")
It's interesting to note that safe uses of cpa->numpages do exist in the pageattr code. If instead of shifting ->numpages we multiply by PAGE_SIZE, no truncation occurs because PAGE_SIZE is a UL value, and so the result is unsigned long.
To avoid surprises when users try to convert very large cpa->numpages values to addresses, change the data type from 'int' to 'unsigned long', thereby making it suitable for shifting by PAGE_SHIFT without any type casting.
The alternative would be to make liberal use of casting, but that is far more likely to cause problems in the future when someone adds more code and fails to cast properly; this bug was difficult enough to track down in the first place.
--- arch/x86/mm/pageattr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/mm/pageattr.c +2 -2
@@ -32,7 +32,7 @@ struct cpa_data {unsigned long *vaddr;pgprot_t mask_set;pgprot_t mask_clr; -int numpages; +unsigned long numpages;int flags;unsigned long pfn; unsigned force_split : 1;
@@ -820,7 +820,7 @@ static int __change_page_attr_set_clr(st* CPA operation. Either a large page has been * preserved or a single page update happened. */ -BUG_ON (cpa->numpages > numpages); +BUG_ON (cpa->numpages > numpages || !cpa->numpages); numpages -= cpa->numpages;if (cpa->flags & (CPA_PAGES_ARRAY |CPA_ARRAY )) cpa->curpage++;
PATCH 29/67 crypto: algif_hash - wait for crypto_ahash_init() to complete
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Wang, Rui Y" <[email protected]>
commit fe09786178f9df713a4b2dd6b93c0a722346bf5e upstream.
hash_sendmsg/sendpage() need to wait for the completion of crypto_ahash_init() otherwise it can cause panic.
--- crypto/algif_hash.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
crypto/algif_hash.c +3 -1
@@ -56,7 +56,8 @@ static int hash_sendmsg(struct kiocb *unlock_sock (sk);if (!ctx->more) { - err =crypto_ahash_init (&ctx->req); + err =af_alg_wait_for_completion (crypto_ahash_init (&ctx->req), + &ctx->completion);if (err) goto unlock; }
@@ -136,6 +137,7 @@ static ssize_t hash_sendpage(struct sock }else {if (!ctx->more) { err =crypto_ahash_init (&ctx->req); + err =af_alg_wait_for_completion (err, &ctx->completion);if (err) goto unlock; }
PATCH 30/67 intel_scu_ipcutil: underflow in scu_reg_access()
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit b1d353ad3d5835b16724653b33c05124e1b5acf1 upstream.
"count" is controlled by the user and it can be negative. Let's prevent that by making it unsigned. You have to have CAP_SYS_RAWIO to call this function so the bug is not as serious as it could be.
--- drivers/platform/x86/intel_scu_ipcutil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/intel_scu_ipcutil.c +1 -1
@@ -52,7 +52,7 @@ struct scu_ipc_data {static int scu_reg_access (u32 cmd,struct scu_ipc_data *data) { -int count = data->count; +unsigned int count = data->count;if (count ==0 || count ==3 || count >4 )return -EINVAL ;
PATCH 32/67 ALSA: rawmidi: Remove kernel WARNING for NULL user-space buffer check
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit cc85f7a634cfaf9f0713c6aa06d08817424db37a upstream.
NULL user-space buffer can be passed even in a normal path, thus it's not good to spew a kernel warning with stack trace at each time. Just drop snd_BUG_ON() macro usage there.
--- sound/core/rawmidi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/rawmidi.c +1 -1
@@ -1162,7 +1162,7 @@ static long snd_rawmidi_kernel_write1(stlong count1, result;struct snd_rawmidi_runtime *runtime = substream->runtime; -if (snd_BUG_ON (!kernelbuf && !userbuf)) +if (!kernelbuf && !userbuf)return -EINVAL ;if (snd_BUG_ON (!runtime->buffer))return -EINVAL ;
PATCH 33/67 ALSA: pcm: Fix potential deadlock in OSS emulation
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit b248371628aad599a48540962f6b85a21a8a0c3f upstream.
There are potential deadlocks in PCM OSS emulation code while accessing read/write and mmap concurrently. This comes from the infamous mmap_sem usage in copy_from/to_user(). Namely,
snd_pcm_oss_write() ->
&runtime->oss.params_lock ->
copy_to_user() ->
&mm->mmap_sem
mmap() ->
&mm->mmap_sem ->
snd_pcm_oss_mmap() ->
&runtime->oss.params_lockSince we can't avoid taking params_lock from mmap code path, use trylock variant and aborts with -EAGAIN as a workaround of this AB/BA deadlock.
--- sound/core/oss/pcm_oss.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
sound/core/oss/pcm_oss.c +15 -6
@@ -834,7 +834,8 @@ static int choose_rate(struct snd_pcm_sureturn snd_pcm_hw_param_near (substream, params,SNDRV_PCM_HW_PARAM_RATE , best_rate,NULL ); } -static int snd_pcm_oss_change_params (struct snd_pcm_substream *substream) +static int snd_pcm_oss_change_params (struct snd_pcm_substream *substream, +bool trylock) {struct snd_pcm_runtime *runtime = substream->runtime;struct snd_pcm_hw_params *params, *sparams;
@@ -848,7 +849,10 @@ static int snd_pcm_oss_change_params(strstruct snd_mask sformat_mask;struct snd_mask mask; -if (mutex_lock_interruptible (&runtime->oss.params_lock)) +if (trylock) { +if (!(mutex_trylock (&runtime->oss.params_lock))) +return -EAGAIN ; + }else if (mutex_lock_interruptible (&runtime->oss.params_lock))return -EINTR ; sw_params =kmalloc (sizeof (*sw_params),GFP_KERNEL ); params =kmalloc (sizeof (*params),GFP_KERNEL );
@@ -1091,7 +1095,7 @@ static int snd_pcm_oss_get_active_substrif (asubstream ==NULL ) asubstream = substream;if (substream->runtime->oss.params) { - err =snd_pcm_oss_change_params (substream); + err =snd_pcm_oss_change_params (substream, false);if (err <0 )return err; }
@@ -1130,7 +1134,7 @@ static int snd_pcm_oss_make_ready(structreturn 0 ; runtime = substream->runtime;if (runtime->oss.params) { - err =snd_pcm_oss_change_params (substream); + err =snd_pcm_oss_change_params (substream, false);if (err <0 )return err; }
@@ -2168,7 +2172,7 @@ static int snd_pcm_oss_get_space(struct runtime = substream->runtime;if (runtime->oss.params && - (err =snd_pcm_oss_change_params (substream)) <0 ) + (err =snd_pcm_oss_change_params (substream, false)) <0 )return err; info.fragsize = runtime->oss.period_bytes;
@@ -2804,7 +2808,12 @@ static int snd_pcm_oss_mmap(struct filereturn -EIO ;if (runtime->oss.params) { -if ((err =snd_pcm_oss_change_params (substream)) <0 ) +/* use mutex_trylock() for params_lock for avoiding a deadlock +* between mmap_sem and params_lock taken by +* copy_from/to_user() in snd_pcm_oss_write/read() +*/ + err =snd_pcm_oss_change_params (substream, true); +if (err <0 )return err; }#ifdef CONFIG_SND_PCM_OSS_PLUGINS
PATCH 34/67 ALSA: seq: Fix yet another races among ALSA timer accesses
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 2cdc7b636d55cbcf42e1e6c8accd85e62d3e9ae8 upstream.
ALSA sequencer may open/close and control ALSA timer instance dynamically either via sequencer events or direct ioctls. These are done mostly asynchronously, and it may call still some timer action like snd_timer_start() while another is calling snd_timer_close(). Since the instance gets removed by snd_timer_close(), it may lead to a use-after-free.
This patch tries to address such a race by protecting each snd_timer_*() call via the existing spinlock and also by avoiding the access to timer during close call.
--- sound/core/seq/seq_timer.c | 87 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 67 insertions(+), 20 deletions(-)
sound/core/seq/seq_timer.c +67 -20
@@ -92,6 +92,9 @@ void snd_seq_timer_delete(struct snd_seqvoid snd_seq_timer_defaults (struct snd_seq_timer * tmr) { +unsigned long flags; + +spin_lock_irqsave (&tmr->lock, flags);/* setup defaults */ tmr->ppq =96 ;/* 96 PPQ */ tmr->tempo =500000 ;/* 120 BPM */
@@ -107,21 +110,25 @@ void snd_seq_timer_defaults(struct snd_s tmr->preferred_resolution = seq_default_timer_resolution; tmr->skew = tmr->skew_base =SKEW_BASE ; +spin_unlock_irqrestore (&tmr->lock, flags); } -void snd_seq_timer_reset (struct snd_seq_timer * tmr) +static void seq_timer_reset (struct snd_seq_timer *tmr) { -unsigned long flags; - -spin_lock_irqsave (&tmr->lock, flags); -/* reset time & songposition */ tmr->cur_time.tv_sec =0 ; tmr->cur_time.tv_nsec =0 ; tmr->tick.cur_tick =0 ; tmr->tick.fraction =0 ; +} + +void snd_seq_timer_reset (struct snd_seq_timer *tmr) +{ +unsigned long flags; +spin_lock_irqsave (&tmr->lock, flags); +seq_timer_reset (tmr);spin_unlock_irqrestore (&tmr->lock, flags); }
@@ -140,8 +147,11 @@ static void snd_seq_timer_interrupt(stru tmr = q->timer;if (tmr ==NULL )return ; -if (!tmr->running) +spin_lock_irqsave (&tmr->lock, flags); +if (!tmr->running) { +spin_unlock_irqrestore (&tmr->lock, flags);return ; + } resolution *= ticks;if (tmr->skew != tmr->skew_base) {
@@ -150,8 +160,6 @@ static void snd_seq_timer_interrupt(stru (((resolution &0xffff ) * tmr->skew) >>16 ); } -spin_lock_irqsave (&tmr->lock, flags); -/* update timer */ snd_seq_inc_time_nsec (&tmr->cur_time, resolution);
@@ -298,26 +306,30 @@ int snd_seq_timer_open(struct snd_seq_qu t->callback = snd_seq_timer_interrupt; t->callback_data = q; t->flags |=SNDRV_TIMER_IFLG_AUTO ; +spin_lock_irq (&tmr->lock); tmr->timeri = t; +spin_unlock_irq (&tmr->lock);return 0 ; }int snd_seq_timer_close (struct snd_seq_queue *q) {struct snd_seq_timer *tmr; +struct snd_timer_instance *t; tmr = q->timer;if (snd_BUG_ON (!tmr))return -EINVAL ; -if (tmr->timeri) { -snd_timer_stop (tmr->timeri); -snd_timer_close (tmr->timeri); - tmr->timeri =NULL ; - } +spin_lock_irq (&tmr->lock); + t = tmr->timeri; + tmr->timeri =NULL ; +spin_unlock_irq (&tmr->lock); +if (t) +snd_timer_close (t);return 0 ; } -int snd_seq_timer_stop (struct snd_seq_timer * tmr) +static int seq_timer_stop (struct snd_seq_timer *tmr) {if (! tmr->timeri)return -EINVAL ;
@@ -328,6 +340,17 @@ int snd_seq_timer_stop(struct snd_seq_tireturn 0 ; } +int snd_seq_timer_stop (struct snd_seq_timer *tmr) +{ +unsigned long flags; +int err; + +spin_lock_irqsave (&tmr->lock, flags); + err =seq_timer_stop (tmr); +spin_unlock_irqrestore (&tmr->lock, flags); +return err; +} +static int initialize_timer (struct snd_seq_timer *tmr) {struct snd_timer *t;
@@ -360,13 +383,13 @@ static int initialize_timer(struct snd_sreturn 0 ; } -int snd_seq_timer_start (struct snd_seq_timer * tmr) +static int seq_timer_start (struct snd_seq_timer *tmr) {if (! tmr->timeri)return -EINVAL ;if (tmr->running) -snd_seq_timer_stop (tmr); -snd_seq_timer_reset (tmr); +seq_timer_stop (tmr); +seq_timer_reset (tmr);if (initialize_timer (tmr) <0 )return -EINVAL ;snd_timer_start (tmr->timeri, tmr->ticks);
@@ -375,14 +398,25 @@ int snd_seq_timer_start(struct snd_seq_treturn 0 ; } -int snd_seq_timer_continue (struct snd_seq_timer * tmr) +int snd_seq_timer_start (struct snd_seq_timer *tmr) +{ +unsigned long flags; +int err; + +spin_lock_irqsave (&tmr->lock, flags); + err =seq_timer_start (tmr); +spin_unlock_irqrestore (&tmr->lock, flags); +return err; +} + +static int seq_timer_continue (struct snd_seq_timer *tmr) {if (! tmr->timeri)return -EINVAL ;if (tmr->running)return -EBUSY ;if (! tmr->initialized) { -snd_seq_timer_reset (tmr); +seq_timer_reset (tmr);if (initialize_timer (tmr) <0 )return -EINVAL ; }
@@ -392,11 +426,24 @@ int snd_seq_timer_continue(struct snd_sereturn 0 ; } +int snd_seq_timer_continue (struct snd_seq_timer *tmr) +{ +unsigned long flags; +int err; + +spin_lock_irqsave (&tmr->lock, flags); + err =seq_timer_continue (tmr); +spin_unlock_irqrestore (&tmr->lock, flags); +return err; +} +/* return current 'real' time. use timeofday() to get better granularity. */ snd_seq_real_time_t snd_seq_timer_get_cur_time (struct snd_seq_timer *tmr) {snd_seq_real_time_t cur_time; +unsigned long flags; +spin_lock_irqsave (&tmr->lock, flags); cur_time = tmr->cur_time;if (tmr->running) {struct timeval tm;
@@ -412,7 +459,7 @@ snd_seq_real_time_t snd_seq_timer_get_cu }snd_seq_sanity_real_time (&cur_time); } - +spin_unlock_irqrestore (&tmr->lock, flags);return cur_time; }
PATCH 35/67 ALSA: timer: Fix link corruption due to double start or stop
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit f784beb75ce82f4136f8a0960d3ee872f7109e09 upstream.
Although ALSA timer code got hardening for races, it still causes use-after-free error. This is however rather a corrupted linked list, not actually the concurrent accesses. Namely, when timer start is triggered twice, list_add_tail() is called twice, too. This ends up with the link corruption and triggers KASAN error.
The simplest fix would be replacing list_add_tail() with list_move_tail(), but fundamentally it's the problem that we don't check the double start/stop correctly. So, the right fix here is to add the proper checks to snd_timer_start() and snd_timer_stop() (and their variants).
--- sound/core/timer.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)
sound/core/timer.c +28 -2
@@ -443,6 +443,10 @@ static int snd_timer_start_slave(structunsigned long flags;spin_lock_irqsave (&slave_active_lock, flags); +if (timeri->flags &SNDRV_TIMER_IFLG_RUNNING ) { +spin_unlock_irqrestore (&slave_active_lock, flags); +return -EBUSY ; + } timeri->flags |=SNDRV_TIMER_IFLG_RUNNING ;if (timeri->master && timeri->timer) {spin_lock (&timeri->timer->lock);
@@ -467,18 +471,26 @@ int snd_timer_start(struct snd_timer_insreturn -EINVAL ;if (timeri->flags &SNDRV_TIMER_IFLG_SLAVE ) { result =snd_timer_start_slave (timeri); -snd_timer_notify1 (timeri,SNDRV_TIMER_EVENT_START ); +if (result >=0 ) +snd_timer_notify1 (timeri,SNDRV_TIMER_EVENT_START );return result; } timer = timeri->timer;if (timer ==NULL )return -EINVAL ;spin_lock_irqsave (&timer->lock, flags); +if (timeri->flags & (SNDRV_TIMER_IFLG_RUNNING | +SNDRV_TIMER_IFLG_START )) { + result = -EBUSY ; + goto unlock; + } timeri->ticks = timeri->cticks = ticks; timeri->pticks =0 ; result =snd_timer_start1 (timer, timeri, ticks); + unlock:spin_unlock_irqrestore (&timer->lock, flags); -snd_timer_notify1 (timeri,SNDRV_TIMER_EVENT_START ); +if (result >=0 ) +snd_timer_notify1 (timeri,SNDRV_TIMER_EVENT_START );return result; }
@@ -494,6 +506,10 @@ static int _snd_timer_stop(struct snd_tiif (timeri->flags &SNDRV_TIMER_IFLG_SLAVE ) {if (!keep_flag) {spin_lock_irqsave (&slave_active_lock, flags); +if (!(timeri->flags &SNDRV_TIMER_IFLG_RUNNING )) { +spin_unlock_irqrestore (&slave_active_lock, flags); +return -EBUSY ; + } timeri->flags &= ~SNDRV_TIMER_IFLG_RUNNING ;list_del_init (&timeri->ack_list);list_del_init (&timeri->active_list);
@@ -505,6 +521,11 @@ static int _snd_timer_stop(struct snd_tiif (!timer)return -EINVAL ;spin_lock_irqsave (&timer->lock, flags); +if (!(timeri->flags & (SNDRV_TIMER_IFLG_RUNNING | +SNDRV_TIMER_IFLG_START ))) { +spin_unlock_irqrestore (&timer->lock, flags); +return -EBUSY ; + }list_del_init (&timeri->ack_list);list_del_init (&timeri->active_list); if ((timeri->flags & SNDRV_TIMER_IFLG_RUNNING) &&
@@ -570,10 +591,15 @@ int snd_timer_continue(struct snd_timer_if (! timer)return -EINVAL ;spin_lock_irqsave (&timer->lock, flags); +if (timeri->flags &SNDRV_TIMER_IFLG_RUNNING ) { + result = -EBUSY ; + goto unlock; + }if (!timeri->cticks) timeri->cticks =1 ; timeri->pticks =0 ; result =snd_timer_start1 (timer, timeri, timer->sticks); + unlock:spin_unlock_irqrestore (&timer->lock, flags);snd_timer_notify1 (timeri,SNDRV_TIMER_EVENT_CONTINUE );return result;
PATCH 36/67 libata: fix sff host state machine locking while polling
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
commit 8eee1d3ed5b6fc8e14389567c9a6f53f82bb7224 upstream.
The bulk of ATA host state machine is implemented by ata_sff_hsm_move(). The function is called from either the interrupt handler or, if polling, a work item. Unlike from the interrupt path, the polling path calls the function without holding the host lock and ata_sff_hsm_move() selectively grabs the lock.
This is completely broken. If an IRQ triggers while polling is in progress, the two can easily race and end up accessing the hardware and updating state machine state at the same time. This can put the state machine in an illegal state and lead to a crash like the following.
kernel BUG at drivers/ata/libata-sff.c:1302! invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN
Modules linked in: CPU: 1 PID: 10679 Comm: syz-executor Not tainted 4.5.0-rc1+ #300 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 task: ffff88002bd00000 ti: ffff88002e048000 task.ti: ffff88002e048000 RIP: 0010:[<ffffffff83a83409>] [<ffffffff83a83409>] ata_sff_hsm_move+0x619/0x1c60 ... Call Trace: <IRQ> [<ffffffff83a84c31>] __ata_sff_port_intr+0x1e1/0x3a0 drivers/ata/libata-sff.c:1584 [<ffffffff83a85611>] ata_bmdma_port_intr+0x71/0x400 drivers/ata/libata-sff.c:2877 [< inline >] __ata_sff_interrupt drivers/ata/libata-sff.c:1629 [<ffffffff83a85bf3>] ata_bmdma_interrupt+0x253/0x580 drivers/ata/libata-sff.c:2902 [<ffffffff81479f98>] handle_irq_event_percpu+0x108/0x7e0 kernel/irq/handle.c:157 [<ffffffff8147a717>] handle_irq_event+0xa7/0x140 kernel/irq/handle.c:205 [<ffffffff81484573>] handle_edge_irq+0x1e3/0x8d0 kernel/irq/chip.c:623 [< inline >] generic_handle_irq_desc include/linux/irqdesc.h:146 [<ffffffff811a92bc>] handle_irq+0x10c/0x2a0 arch/x86/kernel/irq_64.c:78 [<ffffffff811a7e4d>] do_IRQ+0x7d/0x1a0 arch/x86/kernel/irq.c:240 [<ffffffff86653d4c>] common_interrupt+0x8c/0x8c arch/x86/entry/entry_64.S:520 <EOI> [< inline >] rcu_lock_acquire include/linux/rcupdate.h:490 [< inline >] rcu_read_lock include/linux/rcupdate.h:874 [<ffffffff8164b4a1>] filemap_map_pages+0x131/0xba0 mm/filemap.c:2145 [< inline >] do_fault_around mm/memory.c:2943 [< inline >] do_read_fault mm/memory.c:2962 [< inline >] do_fault mm/memory.c:3133 [< inline >] handle_pte_fault mm/memory.c:3308 [< inline >] __handle_mm_fault mm/memory.c:3418 [<ffffffff816efb16>] handle_mm_fault+0x2516/0x49a0 mm/memory.c:3447 [<ffffffff8127dc16>] __do_page_fault+0x376/0x960 arch/x86/mm/fault.c:1238 [<ffffffff8127e358>] trace_do_page_fault+0xe8/0x420 arch/x86/mm/fault.c:1331 [<ffffffff8126f514>] do_async_page_fault+0x14/0xd0 arch/x86/kernel/kvm.c:264 [<ffffffff86655578>] async_page_fault+0x28/0x30 arch/x86/entry/entry_64.S:986
Fix it by ensuring that the polling path is holding the host lock before entering ata_sff_hsm_move() so that all hardware accesses and state updates are performed under the host lock.
--- drivers/ata/libata-sff.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-)
drivers/ata/libata-sff.c +11 -21
@@ -997,12 +997,9 @@ static inline int ata_hsm_ok_in_wq(strucstatic void ata_hsm_qc_complete (struct ata_queued_cmd *qc,int in_wq) {struct ata_port *ap = qc->ap; -unsigned long flags;if (ap->ops->error_handler) {if (in_wq) { -spin_lock_irqsave (ap->lock, flags); -/* EH might have kicked in while host lock is * released. */
@@ -1014,8 +1011,6 @@ static void ata_hsm_qc_complete(struct a }else ata_port_freeze (ap); } - -spin_unlock_irqrestore (ap->lock, flags); }else {if (likely (!(qc->err_mask &AC_ERR_HSM )))ata_qc_complete (qc);
@@ -1024,10 +1019,8 @@ static void ata_hsm_qc_complete(struct a } }else {if (in_wq) { -spin_lock_irqsave (ap->lock, flags);ata_sff_irq_on (ap);ata_qc_complete (qc); -spin_unlock_irqrestore (ap->lock, flags); }else ata_qc_complete (qc); }
@@ -1048,9 +1041,10 @@ int ata_sff_hsm_move(struct ata_port *ap {struct ata_link *link = qc->dev->link;struct ata_eh_info *ehi = &link->eh_info; -unsigned long flags =0 ;int poll_next; +lockdep_assert_held (ap->lock); +WARN_ON_ONCE ((qc->flags &ATA_QCFLAG_ACTIVE ) ==0 );/* Make sure ata_sff_qc_issue() does not throw things
@@ -1112,14 +1106,6 @@ fsm_start: } } -/* Send the CDB (atapi) or the first data block (ata pio out). -* During the state transition, interrupt handler shouldn't -* be invoked before the data transfer is complete and -* hsm_task_state is changed. Hence, the following locking. -*/ -if (in_wq) -spin_lock_irqsave (ap->lock, flags); -if (qc->tf.protocol ==ATA_PROT_PIO ) {/* PIO data out protocol. * send first data block.
@@ -1135,9 +1121,6 @@ fsm_start:/* send CDB */ atapi_send_cdb (ap, qc); -if (in_wq) -spin_unlock_irqrestore (ap->lock, flags); -/* if polling, ata_sff_pio_task() handles the rest. * otherwise, interrupt handler takes over from here. */
@@ -1361,12 +1344,14 @@ static void ata_sff_pio_task(struct worku8 status;int poll_next; +spin_lock_irq (ap->lock); +BUG_ON (ap->sff_pio_task_link ==NULL );/* qc can be NULL if timeout occurred */ qc =ata_qc_from_tag (ap, link->active_tag);if (!qc) { ap->sff_pio_task_link =NULL ; -return ; + goto out_unlock; } fsm_start:
@@ -1381,11 +1366,14 @@ fsm_start:*/ status =ata_sff_busy_wait (ap,ATA_BUSY ,5 );if (status &ATA_BUSY ) { +spin_unlock_irq (ap->lock);ata_msleep (ap,2 ); +spin_lock_irq (ap->lock); + status =ata_sff_busy_wait (ap,ATA_BUSY ,10 );if (status &ATA_BUSY ) {ata_sff_queue_pio_task (link,ATA_SHORT_PAUSE ); -return ; + goto out_unlock; } }
@@ -1402,6 +1390,8 @@ fsm_start:*/ if (poll_next) goto fsm_start; +out_unlock: +spin_unlock_irq (ap->lock); }/**
PATCH 39/67 ALSA: seq: Fix lockdep warnings due to double mutex locks
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 7f0973e973cd74aa40747c9d38844560cd184ee8 upstream.
The port subscription code uses double mutex locks for source and destination ports, and this may become racy once when wrongly set up. It leads to lockdep warning splat, typically triggered by fuzzer like syzkaller, although the actual deadlock hasn't been seen, so far.
This patch simplifies the handling by reducing to two single locks, so that no lockdep warning will be trigger any longer.
By splitting to two actions, a still-in-progress element shall be added in one list while handling another. For ignoring this element, a new check is added in deliver_to_subscribers().
Along with it, the code to add/remove the subscribers list element was cleaned up and refactored.
--- sound/core/seq/seq_clientmgr.c | 3 + sound/core/seq/seq_ports.c | 233 +++++++++++++++++++++++------------------ 2 files changed, 133 insertions(+), 103 deletions(-)
sound/core/seq/seq_clientmgr.c +3 -0
@@ -678,6 +678,9 @@ static int deliver_to_subscribers(structelse down_read (&grp->list_mutex);list_for_each_entry (subs, &grp->list_head, src_list) { +/* both ports ready? */ +if (atomic_read (&subs->ref_count) !=2 ) +continue ; event->dest = subs->info.dest;if (subs->info.flags &SNDRV_SEQ_PORT_SUBS_TIMESTAMP )/* convert time according to flag with subscription */
sound/core/seq/seq_ports.c +131 -104
320 lines not on this page · raw message
PATCH 40/67 Revert "xhci: don't finish a TD if we get a short-transfer event mid TD"
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit a6835090716a85f2297668ba593bd00e1051e662 upstream.
This reverts commit e210c422b6fd ("xhci: don't finish a TD if we get a short transfer event mid TD")
Turns out that most host controllers do not follow the xHCI specs and never send the second event for the last TRB in the TD if there was a short event mid-TD.
Returning the URB directly after the first short-transfer event is far better than never returning the URB. (class drivers usually timeout after 30sec). For the hosts that do send the second event we will go back to treating it as misplaced event and print an error message for it.
The origial patch was sent to stable kernels and needs to be reverted from there as well
--- drivers/usb/host/xhci-ring.c | 10 ---------- 1 file changed, 10 deletions(-)
drivers/usb/host/xhci-ring.c +0 -10
@@ -2187,10 +2187,6 @@ EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)));/* Fast path - was this the last TRB in the TD for this URB? */ if (event_trb == td->last_trb) { -if (td->urb_length_set && trb_comp_code ==COMP_SHORT_TX ) -return finish_td (xhci, td, event_trb, event, ep, - status, false); -if (EVENT_TRB_LEN (le32_to_cpu (event->transfer_len)) !=0 ) { td->urb->actual_length = td->urb->transfer_buffer_length -
@@ -2242,12 +2238,6 @@ td->urb->actual_length +=TRB_LEN (le32_to_cpu (cur_trb->generic.field[2 ])) -EVENT_TRB_LEN (le32_to_cpu (event->transfer_len)); - -if (trb_comp_code ==COMP_SHORT_TX ) { -xhci_dbg (xhci,"mid bulk/intr SP, wait for last TRB event\n" ); - td->urb_length_set = true; -return 0 ; - } }return finish_td (xhci, td, event_trb, event, ep, status, false);
PATCH 41/67 usb: xhci: apply XHCI_PME_STUCK_QUIRK to Intel Broxton-M platforms
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Lu Baolu <[email protected]>
commit ccc04afb72cddbdf7c0e1c17e92886405a71b754 upstream.
Intel Broxton M was verifed to require XHCI_PME_STUCK_QUIRK quirk as well.
--- drivers/usb/host/xhci-pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/host/xhci-pci.c +3 -1
@@ -39,6 +39,7 @@#define PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI 0x22b5#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI 0xa12f#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI 0x9d2f +#define PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI 0x0aa8static const char hcd_name[] ="xhci_hcd" ;
@@ -132,7 +133,8 @@ static void xhci_pci_quirks(struct devicif (pdev->vendor ==PCI_VENDOR_ID_INTEL && (pdev->device ==PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI || pdev->device ==PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI || - pdev->device ==PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI )) { + pdev->device ==PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI || + pdev->device ==PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI )) { xhci->quirks |=XHCI_PME_STUCK_QUIRK ; } if (pdev->vendor == PCI_VENDOR_ID_ETRON &&
PATCH 42/67 xhci: Fix list corruption in urb dequeue at host removal
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit 5c82171167adb8e4ac77b91a42cd49fb211a81a0 upstream.
xhci driver frees data for all devices, both usb2 and and usb3 the first time usb_remove_hcd() is called, including td_list and and xhci_ring structures.
When usb_remove_hcd() is called a second time for the second xhci bus it will try to dequeue all pending urbs, and touches td_list which is already freed for that endpoint.
--- drivers/usb/host/xhci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/host/xhci.c +3 -1
@@ -1533,7 +1533,9 @@ int xhci_urb_dequeue(struct usb_hcd *hcdif (temp ==0xffffffff || (xhci->xhc_state &XHCI_STATE_HALTED )) {xhci_dbg (xhci,"HW died, freeing TD.\n" ); urb_priv = urb->hcpriv; -for (i = urb_priv->td_cnt; i < urb_priv->length; i++) { +for (i = urb_priv->td_cnt; + i < urb_priv->length && xhci->devs[urb->dev->slot_id]; + i++) { td = urb_priv->td[i];if (!list_empty (&td->td_list))list_del_init (&td->td_list);
PATCH 43/67 tda1004x: only update the frontend properties if locked
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mauro Carvalho Chehab <[email protected]>
commit e8beb02343e7582980c6705816cd957cf4f74c7a upstream.
The tda1004x was updating the properties cache before locking. If the device is not locked, the data at the registers are just random values with no real meaning.
This caused the driver to fail with libdvbv5, as such library calls GET_PROPERTY from time to time, in order to return the DVB stats.
Tested with a saa7134 card 78:
ASUSTeK P7131 Dual, vendor PCI ID: 1043:4862
--- drivers/media/dvb/frontends/tda1004x.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/media/dvb/frontends/tda1004x.c +9 -0
@@ -898,9 +898,18 @@ static int tda1004x_set_fe(struct dvb_frstatic int tda1004x_get_fe (struct dvb_frontend * fe,struct dvb_frontend_parameters *fe_params) {struct tda1004x_state * state = fe->demodulator_priv; +int status;dprintk ("%s\n" , __func__); + status =tda1004x_read_byte (state,TDA1004X_STATUS_CD ); +if (status ==-1 ) +return -EIO ; + +/* Only update the properties cache if device is locked */ +if (!(status &8 )) +return 0 ; +// inversion status fe_params->inversion =INVERSION_OFF ;if (tda1004x_read_byte (state,TDA1004X_CONFC1 ) &0x20 )
PATCH 44/67 ALSA: timer: Fix leftover link at closing
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 094fd3be87b0f102589e2d5c3fa5d06b7e20496d upstream.
In ALSA timer core, the active timer instance is managed in active_list linked list. Each element is added / removed dynamically at timer start, stop and in timer interrupt. The problem is that snd_timer_interrupt() has a thinko and leaves the element in active_list when it's the last opened element. This eventually leads to list corruption or use-after-free error.
This hasn't been revealed because we used to delete the list forcibly in snd_timer_stop() in the past. However, the recent fix avoids the double-stop behavior (in commit [f784beb75ce8: ALSA: timer: Fix link corruption due to double start or stop]), and this leak hits reality.
This patch fixes the link management in snd_timer_interrupt(). Now it simply unlinks no matter which stream is.
--- sound/core/timer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/core/timer.c +2 -2
@@ -727,8 +727,8 @@ void snd_timer_interrupt(struct snd_time ti->cticks = ti->ticks; }else { ti->flags &= ~SNDRV_TIMER_IFLG_RUNNING ; -if (--timer->running) -list_del_init (&ti->active_list); + --timer->running; +list_del_init (&ti->active_list); }if ((timer->hw.flags &SNDRV_TIMER_HW_TASKLET ) || (ti->flags &SNDRV_TIMER_IFLG_FAST ))
PATCH 46/67 scsi_dh_rdac: always retry MODE SELECT on command lock violation
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hannes Reinecke <[email protected]>
commit d2d06d4fe0f2cc2df9b17fefec96e6e1a1271d91 upstream.
If MODE SELECT returns with sense '05/91/36' (command lock violation) it should always be retried without counting the number of retries. During an HBA upgrade or similar circumstances one might see a flood of MODE SELECT command from various HBAs, which will easily trigger the sense code and exceed the retry count.
--- drivers/scsi/device_handler/scsi_dh_rdac.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/device_handler/scsi_dh_rdac.c +3 -1
@@ -573,7 +573,7 @@ static int mode_select_handle_sense(stru/* * Command Lock contention */ - err =SCSI_DH_RETRY ; + err =SCSI_DH_IMM_RETRY ;break ;default :break ;
@@ -623,6 +623,8 @@ retry: err =mode_select_handle_sense (sdev, h->sense);if (err ==SCSI_DH_RETRY && retry_cnt--) goto retry; +if (err ==SCSI_DH_IMM_RETRY ) + goto retry; }if (err ==SCSI_DH_OK ) { h->state =RDAC_STATE_ACTIVE ;
PATCH 47/67 mm, vmstat: fix wrong WQ sleep when memory reclaim doesn't make any progress
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Tetsuo Handa <[email protected]>
commit 564e81a57f9788b1475127012e0fd44e9049e342 upstream.
Jan Stancek has reported that system occasionally hanging after "oom01" testcase from LTP triggers OOM. Guessing from a result that there is a kworker thread doing memory allocation and the values between "Node 0 Normal free:" and "Node 0 Normal:" differs when hanging, vmstat is not up-to-date for some reason.
According to commit 373ccbe59270 ("mm, vmstat: allow WQ concurrency to discover memory reclaim doesn't make any progress"), it meant to force the kworker thread to take a short sleep, but it by error used schedule_timeout(1). We missed that schedule_timeout() in state TASK_RUNNING doesn't do anything.
Fix it by using schedule_timeout_uninterruptible(1) which forces the kworker thread to take a short sleep in order to make sure that vmstat is up-to-date.
--- mm/backing-dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/backing-dev.c +1 -1
@@ -879,7 +879,7 @@ long wait_iff_congested(struct zone *zon* here rather than calling cond_resched(). */ if (current->flags &PF_WQ_WORKER ) -schedule_timeout (1 ); +schedule_timeout_uninterruptible (1 );else cond_resched ();
PATCH 49/67 crypto: user - lock crypto_alg_list on alg dump
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Krause <[email protected]>
commit 63e41ebc6630f39422d87f8a4bade1e793f37a01 upstream.
We miss to take the crypto_alg_sem semaphore when traversing the crypto_alg_list for CRYPTO_MSG_GETALG dumps. This allows a race with crypto_unregister_alg() removing algorithms from the list while we're still traversing it, thereby leading to a use-after-free as show below:
[ 3482.071639] general protection fault: 0000 [#1] SMP [ 3482.075639] Modules linked in: aes_x86_64 glue_helper lrw ablk_helper cryptd gf128mul ipv6 pcspkr serio_raw virtio_net microcode virtio_pci virtio_ring virtio sr_mod cdrom [last unloaded: aesni_intel] [ 3482.075639] CPU: 1 PID: 11065 Comm: crconf Not tainted 4.3.4-grsec+ #126 [ 3482.075639] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.7.5-20140531_083030-gandalf 04/01/2014 [ 3482.075639] task: ffff88001cd41a40 ti: ffff88001cd422c8 task.ti: ffff88001cd422c8 [ 3482.075639] RIP: 0010:[<ffffffff93722bd3>] [<ffffffff93722bd3>] strncpy+0x13/0x30 [ 3482.075639] RSP: 0018:ffff88001f713b60 EFLAGS: 00010202 [ 3482.075639] RAX: ffff88001f6c4430 RBX: ffff88001f6c43a0 RCX: ffff88001f6c4430 [ 3482.075639] RDX: 0000000000000040 RSI: fefefefefefeff16 RDI: ffff88001f6c4430 [ 3482.075639] RBP: ffff88001f713b60 R08: ffff88001f6c4470 R09: ffff88001f6c4480 [ 3482.075639] R10: 0000000000000002 R11: 0000000000000246 R12: ffff88001ce2aa28 [ 3482.075639] R13: ffff880000093700 R14: ffff88001f5e4bf8 R15: 0000000000003b20 [ 3482.075639] FS: 0000033826fa2700(0000) GS:ffff88001e900000(0000) knlGS:0000000000000000 [ 3482.075639] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 3482.075639] CR2: ffffffffff600400 CR3: 00000000139ec000 CR4: 00000000001606f0 [ 3482.075639] Stack: [ 3482.075639] ffff88001f713bd8 ffffffff936ccd00 ffff88001e5c4200 ffff880000093700 [ 3482.075639] ffff88001f713bd0 ffffffff938ef4bf 0000000000000000 0000000000003b20 [ 3482.075639] ffff88001f5e4bf8 ffff88001f5e4848 0000000000000000 0000000000003b20 [ 3482.075639] Call Trace: [ 3482.075639] [<ffffffff936ccd00>] crypto_report_alg+0xc0/0x3e0 [ 3482.075639] [<ffffffff938ef4bf>] ? __alloc_skb+0x16f/0x300 [ 3482.075639] [<ffffffff936cd08a>] crypto_dump_report+0x6a/0x90 [ 3482.075639] [<ffffffff93935707>] netlink_dump+0x147/0x2e0 [ 3482.075639] [<ffffffff93935f99>] __netlink_dump_start+0x159/0x190 [ 3482.075639] [<ffffffff936ccb13>] crypto_user_rcv_msg+0xc3/0x130 [ 3482.075639] [<ffffffff936cd020>] ? crypto_report_alg+0x3e0/0x3e0 [ 3482.075639] [<ffffffff936cc4b0>] ? alg_test_crc32c+0x120/0x120 [ 3482.075639] [<ffffffff93933145>] ? __netlink_lookup+0xd5/0x120 [ 3482.075639] [<ffffffff936cca50>] ? crypto_add_alg+0x1d0/0x1d0 [ 3482.075639] [<ffffffff93938141>] netlink_rcv_skb+0xe1/0x130 [ 3482.075639] [<ffffffff936cc4f8>] crypto_netlink_rcv+0x28/0x40 [ 3482.075639] [<ffffffff939375a8>] netlink_unicast+0x108/0x180 [ 3482.075639] [<ffffffff93937c21>] netlink_sendmsg+0x541/0x770 [ 3482.075639] [<ffffffff938e31e1>] sock_sendmsg+0x21/0x40 [ 3482.075639] [<ffffffff938e4763>] SyS_sendto+0xf3/0x130 [ 3482.075639] [<ffffffff93444203>] ? bad_area_nosemaphore+0x13/0x20 [ 3482.075639] [<ffffffff93444470>] ? __do_page_fault+0x80/0x3a0 [ 3482.075639] [<ffffffff939d80cb>] entry_SYSCALL_64_fastpath+0x12/0x6e [ 3482.075639] Code: 88 4a ff 75 ed 5d 48 0f ba 2c 24 3f c3 66 66 2e 0f 1f 84 00 00 00 00 00 55 48 85 d2 48 89 f8 48 89 f9 4c 8d 04 17 48 89 e5 74 15 <0f> b6 16 80 fa 01 88 11 48 83 de ff 48 83 c1 01 4c 39 c1 75 eb [ 3482.075639] RIP [<ffffffff93722bd3>] strncpy+0x13/0x30
To trigger the race run the following loops simultaneously for a while:
$ while : ; do modprobe aesni-intel; rmmod aesni-intel; done $ while : ; do crconf show all > /dev/null; done
Fix the race by taking the crypto_alg_sem read lock, thereby preventing crypto_unregister_alg() from modifying the algorithm list during the dump.
This bug has been detected by the PaX memory sanitize feature.
--- crypto/crypto_user.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
crypto/crypto_user.c +5 -1
@@ -390,8 +390,12 @@ static int crypto_user_rcv_msg(struct skif (link->dump ==NULL )return -EINVAL ; -return netlink_dump_start (crypto_nlsk, skb, nlh, +down_read (&crypto_alg_sem); + err =netlink_dump_start (crypto_nlsk, skb, nlh, link->dump, link->done,0 ); +up_read (&crypto_alg_sem); + +return err; } err = nlmsg_parse(nlh, crypto_msg_min[type], attrs, CRYPTOCFGA_MAX,
PATCH 50/67 crypto: algif_skcipher - Do not dereference ctx without socket lock
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
commit 6454c2b83f719057069777132b13949e4c6b6350 upstream.
Any access to non-constant bits of the private context must be done under the socket lock, in particular, this includes ctx->req.
This patch moves such accesses under the lock, and fetches the tfm from the parent socket which is guaranteed to be constant, rather than from ctx->req.
[bwh: Backported to 3.2:
- Drop changes to skcipher_recvmsg_async
- s/skcipher/ablkcipher/ in many places
- s/skc->skcipher/skc->base/]
--- crypto/algif_skcipher.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
crypto/algif_skcipher.c +4 -1
@@ -249,8 +249,11 @@ static int skcipher_sendmsg(struct kiocb {struct sock *sk = sock->sk;struct alg_sock *ask =alg_sk (sk); +struct sock *psk = ask->parent; +struct alg_sock *pask =alg_sk (psk);struct skcipher_ctx *ctx = ask->private; -struct crypto_ablkcipher *tfm =crypto_ablkcipher_reqtfm (&ctx->req); +struct ablkcipher_tfm *skc = pask->private; +struct crypto_ablkcipher *tfm = skc->base;unsigned ivsize =crypto_ablkcipher_ivsize (tfm);struct skcipher_sg_list *sgl;struct af_alg_control con = {};
PATCH 51/67 klist: fix starting point removed bug in klist iterators
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Bottomley <[email protected]>
commit 00cd29b799e3449f0c68b1cc77cd4a5f95b42d17 upstream.
The starting node for a klist iteration is often passed in from somewhere way above the klist infrastructure, meaning there's no guarantee the node is still on the list. We've seen this in SCSI where we use bus_find_device() to iterate through a list of devices. In the face of heavy hotplug activity, the last device returned by bus_find_device() can be removed before the next call. This leads to
Dec 3 13:22:02 localhost kernel: WARNING: CPU: 2 PID: 28073 at include/linux/kref.h:47 klist_iter_init_node+0x3d/0x50() Dec 3 13:22:02 localhost kernel: Modules linked in: scsi_debug x86_pkg_temp_thermal kvm_intel kvm irqbypass crc32c_intel joydev iTCO_wdt dcdbas ipmi_devintf acpi_power_meter iTCO_vendor_support ipmi_si imsghandler pcspkr wmi acpi_cpufreq tpm_tis tpm shpchp lpc_ich mfd_core nfsd nfs_acl lockd grace sunrpc tg3 ptp pps_core Dec 3 13:22:02 localhost kernel: CPU: 2 PID: 28073 Comm: cat Not tainted 4.4.0-rc1+ #2 Dec 3 13:22:02 localhost kernel: Hardware name: Dell Inc. PowerEdge R320/08VT7V, BIOS 2.0.22 11/19/2013 Dec 3 13:22:02 localhost kernel: ffffffff81a20e77 ffff880613acfd18 ffffffff81321eef 0000000000000000 Dec 3 13:22:02 localhost kernel: ffff880613acfd50 ffffffff8107ca52 ffff88061176b198 0000000000000000 Dec 3 13:22:02 localhost kernel: ffffffff814542b0 ffff880610cfb100 ffff88061176b198 ffff880613acfd60 Dec 3 13:22:02 localhost kernel: Call Trace: Dec 3 13:22:02 localhost kernel: [<ffffffff81321eef>] dump_stack+0x44/0x55 Dec 3 13:22:02 localhost kernel: [<ffffffff8107ca52>] warn_slowpath_common+0x82/0xc0 Dec 3 13:22:02 localhost kernel: [<ffffffff814542b0>] ? proc_scsi_show+0x20/0x20 Dec 3 13:22:02 localhost kernel: [<ffffffff8107cb4a>] warn_slowpath_null+0x1a/0x20 Dec 3 13:22:02 localhost kernel: [<ffffffff8167225d>] klist_iter_init_node+0x3d/0x50 Dec 3 13:22:02 localhost kernel: [<ffffffff81421d41>] bus_find_device+0x51/0xb0 Dec 3 13:22:02 localhost kernel: [<ffffffff814545ad>] scsi_seq_next+0x2d/0x40
[...]
And an eventual crash. It can actually occur in any hotplug system which has a device finder and a starting device.
We can fix this globally by making sure the starting node for klist_iter_init_node() is actually a member of the list before using it (and by starting from the beginning if it isn't).
--- lib/klist.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/klist.c +3 -3
@@ -282,9 +282,9 @@ void klist_iter_init_node(struct klist * struct klist_node *n) { i->i_klist = k; - i->i_cur = n; -if (n) -kref_get (&n->n_ref); + i->i_cur =NULL ; +if (n &&kref_get_unless_zero (&n->n_ref)) + i->i_cur = n; }EXPORT_SYMBOL_GPL (klist_iter_init_node);
PATCH 52/67 ALSA: dummy: Implement timer backend switching more safely
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit ddce57a6f0a2d8d1bfacfa77f06043bc760403c2 upstream.
Currently the selected timer backend is referred at any moment from the running PCM callbacks. When the backend is switched, it's possible to lead to inconsistency from the running backend. This was pointed by syzkaller fuzzer, and the commit [7ee96216c31a: ALSA:
dummy: Disable switching timer backend via sysfs] disabled the dynamic switching for avoiding the crash.
This patch improves the handling of timer backend switching. It keeps the reference to the selected backend during the whole operation of an opened stream so that it won't be changed by other streams.
Together with this change, the hrtimer parameter is reenabled as writable now.
NOTE: this patch also turned out to fix the still remaining race. Namely, ops was still replaced dynamically at dummy_pcm_open:
static int dummy_pcm_open(struct snd_pcm_substream *substream)
{
....
dummy->timer_ops = &dummy_systimer_ops;
if (hrtimer)
dummy->timer_ops = &dummy_hrtimer_ops;Since dummy->timer_ops is common among all streams, and when the replacement happens during accesses of other streams, it may lead to a crash. This was actually triggered by syzkaller fuzzer and KASAN.
This patch rewrites the code not to use the ops shared by all streams any longer, too.
--- sound/drivers/dummy.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-)
sound/drivers/dummy.c +19 -18
@@ -87,7 +87,7 @@ MODULE_PARM_DESC(pcm_substreams, "PCM sumodule_param (fake_buffer, bool,0444 );MODULE_PARM_DESC (fake_buffer,"Fake buffer allocations." );#ifdef CONFIG_HIGH_RES_TIMERS -module_param (hrtimer, bool,0444 ); +module_param (hrtimer, bool,0644 );MODULE_PARM_DESC (hrtimer,"Use hrtimer as the timer source." );#endif
@@ -109,6 +109,9 @@ struct dummy_timer_ops {snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *); }; +#define get_dummy_ops (substream) \ + (*(const struct dummy_timer_ops **)(substream)->runtime->private_data) +struct dummy_model {const char *name;int (*playback_constraints)(struct snd_pcm_runtime *runtime);
@@ -134,7 +137,6 @@ struct snd_dummy {spinlock_t mixer_lock;int mixer_volume[MIXER_ADDR_LAST +1 ][2 ];int capture_source[MIXER_ADDR_LAST +1 ][2 ]; -const struct dummy_timer_ops *timer_ops; };/*
@@ -228,6 +230,8 @@ struct dummy_model *dummy_models[] = {*/ struct dummy_systimer_pcm { +/* ops must be the first item */ +const struct dummy_timer_ops *timer_ops;spinlock_t lock;struct timer_list timer;unsigned long base_time;
@@ -365,6 +369,8 @@ static struct dummy_timer_ops dummy_syst*/ struct dummy_hrtimer_pcm { +/* ops must be the first item */ +const struct dummy_timer_ops *timer_ops;ktime_t base_time;ktime_t period_time;atomic_t running;
@@ -491,31 +497,25 @@ static struct dummy_timer_ops dummy_hrtistatic int dummy_pcm_trigger (struct snd_pcm_substream *substream,int cmd) { -struct snd_dummy *dummy =snd_pcm_substream_chip (substream); -switch (cmd) {case SNDRV_PCM_TRIGGER_START :case SNDRV_PCM_TRIGGER_RESUME : -return dummy->timer_ops->start (substream); +return get_dummy_ops (substream)->start (substream);case SNDRV_PCM_TRIGGER_STOP :case SNDRV_PCM_TRIGGER_SUSPEND : -return dummy->timer_ops->stop (substream); +return get_dummy_ops (substream)->stop (substream); }return -EINVAL ; }static int dummy_pcm_prepare (struct snd_pcm_substream *substream) { -struct snd_dummy *dummy =snd_pcm_substream_chip (substream); - -return dummy->timer_ops->prepare (substream); +return get_dummy_ops (substream)->prepare (substream); }static snd_pcm_uframes_t dummy_pcm_pointer (struct snd_pcm_substream *substream) { -struct snd_dummy *dummy =snd_pcm_substream_chip (substream); - -return dummy->timer_ops->pointer (substream); +return get_dummy_ops (substream)->pointer (substream); }static struct snd_pcm_hardware dummy_pcm_hardware = {
@@ -561,17 +561,19 @@ static int dummy_pcm_open(struct snd_pcmstruct snd_dummy *dummy =snd_pcm_substream_chip (substream);struct dummy_model *model = dummy->model;struct snd_pcm_runtime *runtime = substream->runtime; +const struct dummy_timer_ops *ops;int err; - dummy->timer_ops = &dummy_systimer_ops; + ops = &dummy_systimer_ops;#ifdef CONFIG_HIGH_RES_TIMERS if (hrtimer) - dummy->timer_ops = &dummy_hrtimer_ops; + ops = &dummy_hrtimer_ops;#endif - err = dummy->timer_ops->create (substream); + err = ops->create (substream);if (err <0 )return err; +get_dummy_ops (substream) = ops; runtime->hw = dummy->pcm_hw;if (substream->pcm->device &1 ) {
@@ -593,7 +595,7 @@ static int dummy_pcm_open(struct snd_pcm err = model->capture_constraints (substream->runtime); }if (err <0 ) { - dummy->timer_ops->free (substream); +get_dummy_ops (substream)->free (substream);return err; }return 0 ;
@@ -601,8 +603,7 @@ static int dummy_pcm_open(struct snd_pcmstatic int dummy_pcm_close (struct snd_pcm_substream *substream) { -struct snd_dummy *dummy =snd_pcm_substream_chip (substream); - dummy->timer_ops->free (substream); +get_dummy_ops (substream)->free (substream);return 0 ; }
PATCH 54/67 ARM: 8517/1: ICST: avoid arithmetic overflow in icst_hz()
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
commit 5070fb14a0154f075c8b418e5bc58a620ae85a45 upstream.
When trying to set the ICST 307 clock to 25174000 Hz I ran into this arithmetic error: the icst_hz_to_vco() correctly figure out DIVIDE=2, RDW=100 and VDW=99 yielding a frequency of 25174000 Hz out of the VCO. (I replicated the icst_hz() function in a spreadsheet to verify this.)
However, when I called icst_hz() on these VCO settings it would instead return 4122709 Hz. This causes an error in the common clock driver for ICST as the common clock framework will call .round_rate() on the clock which will utilize icst_hz_to_vco() followed by icst_hz() suggesting the erroneous frequency, and then the clock gets set to this.
The error did not manifest in the old clock framework since this high frequency was only used by the CLCD, which calls clk_set_rate() without first calling clk_round_rate() and since the old clock framework would not call clk_round_rate() before setting the frequency, the correct values propagated into the VCO.
After some experimenting I figured out that it was due to a simple arithmetic overflow: the divisor for 24Mhz reference frequency as reference becomes 24000000*2*(99+8)=0x132212400 and the "1" in bit 32 overflows and is lost.
But introducing an explicit 64-by-32 bit do_div() and casting the divisor into (u64) we get the right frequency back, and the right frequency gets set.
Tested on the ARM Versatile.
--- arch/arm/common/icst.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/arm/common/icst.c +6 -2
@@ -16,7 +16,7 @@*/ #include <linux/module.h> #include <linux/kernel.h> - +#include <asm/div64.h> #include <asm/hardware/icst.h> /*
@@ -29,7 +29,11 @@ EXPORT_SYMBOL(icst525_s2div);unsigned long icst_hz (const struct icst_params *p,struct icst_vco vco) { -return p->ref *2 * (vco.v +8 ) / ((vco.r +2 ) * p->s2div[vco.s]); +u64 dividend = p->ref *2 * (u64)(vco.v +8 ); +u32 divisor = (vco.r +2 ) * p->s2div[vco.s]; + +do_div (dividend, divisor); +return (unsigned long )dividend; }EXPORT_SYMBOL (icst_hz);
PATCH 55/67 sctp: translate network order to host order when users get a hmacid
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
commit 7a84bd46647ff181eb2659fdc99590e6f16e501d upstream.
Commit ed5a377d87dc ("sctp: translate host order to network order when setting a hmacid") corrected the hmacid byte-order when setting a hmacid. but the same issue also exists on getting a hmacid.
We fix it by changing hmacids to host order when users get them with getsockopt.
--- net/sctp/socket.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
net/sctp/socket.c +7 -2
@@ -5309,6 +5309,7 @@ static int sctp_getsockopt_hmac_ident(ststruct sctp_hmac_algo_param *hmacs;__u16 data_len =0 ;u32 num_idents; +int i;if (!sctp_auth_enable)return -EACCES ;
@@ -5326,8 +5327,12 @@ static int sctp_getsockopt_hmac_ident(streturn -EFAULT ;if (put_user (num_idents, &p->shmac_num_idents))return -EFAULT ; -if (copy_to_user (p->shmac_idents, hmacs->hmac_ids, data_len)) -return -EFAULT ; +for (i =0 ; i < num_idents; i++) { +__u16 hmacid =ntohs (hmacs->hmac_ids[i]); + +if (copy_to_user (&p->shmac_idents[i], &hmacid,sizeof (__u16))) +return -EFAULT ; + }return 0 ; }
PATCH 57/67 ALSA: timer: Fix race at concurrent reads
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 4dff5c7b7093b19c19d3a100f8a3ad87cb7cd9e7 upstream.
snd_timer_user_read() has a potential race among parallel reads, as qhead and qused are updated outside the critical section due to copy_to_user() calls. Move them into the critical section, and also sanitize the relevant code a bit.
---
sound/core/timer.c +14 -18
@@ -1890,6 +1890,7 @@ static ssize_t snd_timer_user_read(struc {struct snd_timer_user *tu;long result =0 , unit; +int qhead;int err =0 ; tu = file->private_data;
@@ -1901,7 +1902,7 @@ static ssize_t snd_timer_user_read(strucif ((file->f_flags &O_NONBLOCK ) !=0 || result >0 ) { err = -EAGAIN ; -break ; + goto _error; }set_current_state (TASK_INTERRUPTIBLE );
@@ -1916,38 +1917,33 @@ static ssize_t snd_timer_user_read(strucif (signal_pending (current)) { err = -ERESTARTSYS ; -break ; + goto _error; } } + qhead = tu->qhead++; + tu->qhead %= tu->queue_size;spin_unlock_irq (&tu->qlock); -if (err <0 ) - goto _error;if (tu->tread) { -if (copy_to_user (buffer, &tu->tqueue[tu->qhead++], -sizeof (struct snd_timer_tread ))) { +if (copy_to_user (buffer, &tu->tqueue[qhead], +sizeof (struct snd_timer_tread ))) err = -EFAULT ; - goto _error; - } }else { -if (copy_to_user (buffer, &tu->queue[tu->qhead++], -sizeof (struct snd_timer_read ))) { +if (copy_to_user (buffer, &tu->queue[qhead], +sizeof (struct snd_timer_read ))) err = -EFAULT ; - goto _error; - } } - tu->qhead %= tu->queue_size; - - result += unit; - buffer += unit; -spin_lock_irq (&tu->qlock); tu->qused--; +if (err <0 ) + goto _error; + result += unit; + buffer += unit; } -spin_unlock_irq (&tu->qlock); _error: +spin_unlock_irq (&tu->qlock);return result >0 ? result : err; }
PATCH 58/67 ahci: Intel DNV device IDs SATA
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alexandra Yates <[email protected]>
commit 342decff2b846b46fa61eb5ee40986fab79a9a32 upstream.
Adding Intel codename DNV platform device IDs for SATA.
--- drivers/ata/ahci.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/ata/ahci.c +20 -0
@@ -274,6 +274,26 @@ static const struct pci_device_id ahci_p { PCI_VDEVICE(INTEL, 0x3b2b), board_ahci }, /* PCH RAID */ { PCI_VDEVICE(INTEL, 0x3b2c), board_ahci }, /* PCH RAID */ { PCI_VDEVICE(INTEL, 0x3b2f), board_ahci }, /* PCH AHCI */ + { PCI_VDEVICE(INTEL, 0x19b0), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19b1), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19b2), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19b3), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19b4), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19b5), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19b6), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19b7), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19bE), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19bF), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19c0), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19c1), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19c2), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19c3), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19c4), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19c5), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19c6), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19c7), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19cE), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19cF), board_ahci }, /* DNV AHCI */ { PCI_VDEVICE(INTEL, 0x1c02), board_ahci }, /* CPT AHCI */ { PCI_VDEVICE(INTEL, 0x1c03), board_ahci }, /* CPT AHCI */ { PCI_VDEVICE(INTEL, 0x1c04), board_ahci }, /* CPT RAID */
PATCH 59/67 ARM: 8519/1: ICST: try other dividends than 1
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
commit e972c37459c813190461dabfeaac228e00aae259 upstream.
Since the dawn of time the ICST code has only supported divide by one or hang in an eternal loop. Luckily we were always dividing by one because the reference frequency for the systems using the ICSTs is 24MHz and the [min,max] values for the PLL input if [10,320] MHz for ICST307 and [6,200] for ICST525, so the loop will always terminate immediately without assigning any divisor for the reference frequency.
But for the code to make sense, let's insert the missing i++
--- arch/arm/common/icst.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/common/icst.c +1 -0
@@ -62,6 +62,7 @@ icst_hz_to_vco(const struct icst_paramsif (f > p->vco_min && f <= p->vco_max)break ; + i++; }while (i <8 );if (i >=8 )
PATCH 60/67 btrfs: properly set the termination value of ctx->pos in readdir
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: David Sterba <[email protected]>
commit bc4ef7592f657ae81b017207a1098817126ad4cb upstream.
The value of ctx->pos in the last readdir call is supposed to be set to INT_MAX due to 32bit compatibility, unless 'pos' is intentially set to a larger value, then it's LLONG_MAX.
There's a report from PaX SIZE_OVERFLOW plugin that "ctx->pos++" overflows (https://forums.grsecurity.net/viewtopic.php?f=1&t=4284), on a 64bit arch, where the value is 0x7fffffffffffffff ie. LLONG_MAX before the increment.
We can get to that situation like that:
* emit all regular readdir entries
* still in the same call to readdir, bump the last pos to INT_MAX
* next call to readdir will not emit any entries, but will reach the bump code again, finds pos to be INT_MAX and sets it to LLONG_MAX
Normally this is not a problem, but if we call readdir again, we'll find 'pos' set to LLONG_MAX and the unconditional increment will overflow.
The report from Victor at
(http://thread.gmane.org/gmane.comp.file-systems.btrfs/49500) with debugging print shows that pattern:
Overflow: e
Overflow: 7fffffff
Overflow: 7fffffffffffffff
PAX: size overflow detected in function btrfs_real_readdir
fs/btrfs/inode.c:5760 cicus.935_282 max, count: 9, decl: pos; num: 0;
context: dir_context;
CPU: 0 PID: 2630 Comm: polkitd Not tainted 4.2.3-grsec #1 Hardware name: Gigabyte Technology Co., Ltd. H81ND2H/H81ND2H, BIOS F3 08/11/2015 ffffffff81901608 0000000000000000 ffffffff819015e6 ffffc90004973d48 ffffffff81742f0f 0000000000000007 ffffffff81901608 ffffc90004973d78 ffffffff811cb706 0000000000000000 ffff8800d47359e0 ffffc90004973ed8 Call Trace: [<ffffffff81742f0f>] dump_stack+0x4c/0x7f [<ffffffff811cb706>] report_size_overflow+0x36/0x40 [<ffffffff812ef0bc>] btrfs_real_readdir+0x69c/0x6d0 [<ffffffff811dafc8>] iterate_dir+0xa8/0x150 [<ffffffff811e6d8d>] ? __fget_light+0x2d/0x70 [<ffffffff811dba3a>] SyS_getdents+0xba/0x1c0 Overflow: 1a [<ffffffff811db070>] ? iterate_dir+0x150/0x150 [<ffffffff81749b69>] entry_SYSCALL_64_fastpath+0x12/0x83
The jump from 7fffffff to 7fffffffffffffff happens when new dir entries are not yet synced and are processed from the delayed list. Then the code could go to the bump section again even though it might not emit any new dir entries from the delayed list.
The fix avoids entering the "bump" section again once we've finished emitting the entries, both for synced and delayed entries.
References: https://forums.grsecurity.net/viewtopic.php?f=1&t=4284
[bwh: Backported to 3.2:
- s/ctx->pos/filp->f_pos/
- Adjust context]
--- fs/btrfs/delayed-inode.c | 3 ++- fs/btrfs/delayed-inode.h | 2 +- fs/btrfs/inode.c | 14 +++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-)
fs/btrfs/delayed-inode.c +2 -1
@@ -1593,7 +1593,7 @@ int btrfs_should_delete_dir_index(struct*/ int btrfs_readdir_delayed_dir_index (struct file *filp,void *dirent,filldir_t filldir, -struct list_head *ins_list) +struct list_head *ins_list,bool *emitted) {struct btrfs_dir_item *di;struct btrfs_delayed_item *curr, *next;
@@ -1637,6 +1637,7 @@ int btrfs_readdir_delayed_dir_index(struif (over)return 1 ; + *emitted = true; }return 0 ; }
fs/btrfs/delayed-inode.h +1 -1
@@ -133,7 +133,7 @@ int btrfs_should_delete_dir_index(struct u64 index);int btrfs_readdir_delayed_dir_index (struct file *filp,void *dirent,filldir_t filldir, -struct list_head *ins_list); +struct list_head *ins_list,bool *emitted);/* for init */ int __init btrfs_delayed_inode_init (void );
fs/btrfs/inode.c +13 -1
@@ -4111,6 +4111,7 @@ static int btrfs_real_readdir(struct filchar *name_ptr;int name_len;int is_curr =0 ;/* filp->f_pos points to the current index? */ +bool emitted;/* FIXME, use a real flag for deciding about the key type */ if (root->fs_info->tree_root == root)
@@ -4153,6 +4154,7 @@ static int btrfs_real_readdir(struct filif (ret <0 ) goto err; + emitted = false;while (1 ) { leaf = path->nodes[0 ]; slot = path->slots[0 ];
@@ -4254,6 +4256,7 @@ skip:if (over) goto nopos; + emitted = true; di_len =btrfs_dir_name_len (leaf, di) +btrfs_dir_data_len (leaf, di) +sizeof (*di); di_cur += di_len;
@@ -4267,11 +4270,20 @@ next:if (is_curr) filp->f_pos++; ret =btrfs_readdir_delayed_dir_index (filp, dirent, filldir, - &ins_list); + &ins_list, &emitted);if (ret) goto nopos; } +/* +* If we haven't emitted any dir entry, we must not touch filp->f_pos as +* it was was set to the termination value in previous call. We assume +* that "." and ".." were emitted if we reach this point and set the +* termination value as well for an empty directory. +*/ +if (filp->f_pos >2 && !emitted) + goto nopos; +/* Reached end of directory/root. Bump pos past the last item. */ if (key_type ==BTRFS_DIR_INDEX_KEY )/*
PATCH 61/67 ALSA: usb-audio: avoid freeing umidi object twice
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Konovalov <[email protected]>
commit 07d86ca93db7e5cdf4743564d98292042ec21af7 upstream.
The 'umidi' object will be free'd on the error path by snd_usbmidi_free() when tearing down the rawmidi interface. So we shouldn't try to free it in snd_usbmidi_create() after having registered the rawmidi interface.
Found by KASAN.
--- sound/usb/midi.c | 1 - 1 file changed, 1 deletion(-)
sound/usb/midi.c +0 -1
@@ -2289,7 +2289,6 @@ int snd_usbmidi_create(struct snd_card *else err =snd_usbmidi_create_endpoints (umidi, endpoints);if (err <0 ) { -snd_usbmidi_free (umidi);return err; }
PATCH 62/67 unix: properly account for FDs passed over unix sockets
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: willy tarreau <[email protected]>
commit 712f4aad406bb1ed67f3f98d04c044191f0ff593 upstream.
It is possible for a process to allocate and accumulate far more FDs than the process' limit by sending them over a unix socket then closing them to keep the process' fd count low.
This change addresses this problem by keeping track of the number of FDs in flight per user and preventing non-privileged processes from having more FDs in flight than their configured FD limit.
Mitigates: CVE-2013-4312 (Linux 2.0+)
--- include/linux/sched.h | 1 + net/unix/af_unix.c | 24 ++++++++++++++++++++---- net/unix/garbage.c | 13 ++++++++----- 3 files changed, 29 insertions(+), 9 deletions(-)
include/linux/sched.h +1 -0
@@ -709,6 +709,7 @@ struct user_struct {unsigned long mq_bytes;/* How many bytes can be allocated to mqueue? */ #endif unsigned long locked_shm;/* How many pages of mlocked shm ? */ +unsigned long unix_inflight;/* How many files in flight in unix sockets */ #ifdef CONFIG_KEYS struct key *uid_keyring;/* UID specific keyring */
net/unix/af_unix.c +20 -4
@@ -1472,6 +1472,21 @@ static void unix_destruct_scm(struct sk_sock_wfree (skb); } +/* +* The "user->unix_inflight" variable is protected by the garbage +* collection lock, and we just read it locklessly here. If you go +* over the limit, there might be a tiny race in actually noticing +* it across threads. Tough. +*/ +static inline bool too_many_unix_fds (struct task_struct *p) +{ +struct user_struct *user =current_user (); + +if (unlikely (user->unix_inflight >task_rlimit (p,RLIMIT_NOFILE ))) +return !capable (CAP_SYS_RESOURCE ) && !capable (CAP_SYS_ADMIN ); +return false; +} +#define MAX_RECURSION_LEVEL 4static int unix_attach_fds (struct scm_cookie *scm,struct sk_buff *skb)
@@ -1480,6 +1495,9 @@ static int unix_attach_fds(struct scm_counsigned char max_level =0 ;int unix_sock_count =0 ; +if (too_many_unix_fds (current)) +return -ETOOMANYREFS ; +for (i = scm->fp->count -1 ; i >=0 ; i--) {struct sock *sk =unix_get_socket (scm->fp->fp[i]);
@@ -1501,10 +1519,8 @@ static int unix_attach_fds(struct scm_coif (!UNIXCB (skb).fp)return -ENOMEM ; -if (unix_sock_count) { -for (i = scm->fp->count -1 ; i >=0 ; i--) -unix_inflight (scm->fp->fp[i]); - } +for (i = scm->fp->count -1 ; i >=0 ; i--) +unix_inflight (scm->fp->fp[i]);return max_level; }
net/unix/garbage.c +10 -4
@@ -125,9 +125,11 @@ struct sock *unix_get_socket(struct filevoid unix_inflight (struct file *fp) {struct sock *s =unix_get_socket (fp); + +spin_lock (&unix_gc_lock); +if (s) {struct unix_sock *u =unix_sk (s); -spin_lock (&unix_gc_lock);if (atomic_long_inc_return (&u->inflight) ==1 ) {BUG_ON (!list_empty (&u->link));list_add_tail (&u->link, &gc_inflight_list);
@@ -135,22 +137,26 @@ void unix_inflight(struct file *fp)BUG_ON (list_empty (&u->link)); } unix_tot_inflight++; -spin_unlock (&unix_gc_lock); } + fp->f_cred->user->unix_inflight++; +spin_unlock (&unix_gc_lock); }void unix_notinflight (struct file *fp) {struct sock *s =unix_get_socket (fp); + +spin_lock (&unix_gc_lock); +if (s) {struct unix_sock *u =unix_sk (s); -spin_lock (&unix_gc_lock);BUG_ON (list_empty (&u->link));if (atomic_long_dec_and_test (&u->inflight))list_del_init (&u->link); unix_tot_inflight--; -spin_unlock (&unix_gc_lock); } + fp->f_cred->user->unix_inflight--; +spin_unlock (&unix_gc_lock); } static void scan_inflight(struct sock *x, void (*func)(struct unix_sock *),
PATCH 63/67 unix: correctly track in-flight fds in sending process user_struct
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hannes Frederic Sowa <[email protected]>
commit 415e3d3e90ce9e18727e8843ae343eda5a58fad6 upstream.
The commit referenced in the Fixes tag incorrectly accounted the number of in-flight fds over a unix domain socket to the original opener of the file-descriptor. This allows another process to arbitrary deplete the original file-openers resource limit for the maximum of open files. Instead the sending processes and its struct cred should be credited.
To do so, we add a reference counted struct user_struct pointer to the scm_fp_list and use it to account for the number of inflight unix fds.
--- include/net/af_unix.h | 4 ++-- include/net/scm.h | 1 + net/core/scm.c | 7 +++++++ net/unix/af_unix.c | 4 ++-- net/unix/garbage.c | 8 ++++---- 5 files changed, 16 insertions(+), 8 deletions(-)
include/net/af_unix.h +2 -2
@@ -6,8 +6,8 @@#include <linux/mutex.h> #include <net/sock.h> -extern void unix_inflight (struct file *fp); -extern void unix_notinflight (struct file *fp); +extern void unix_inflight (struct user_struct *user,struct file *fp); +extern void unix_notinflight (struct user_struct *user,struct file *fp);extern void unix_gc (void );extern void wait_for_unix_gc (void );extern struct sock *unix_get_socket (struct file *filp);
include/net/scm.h +1 -0
@@ -16,6 +16,7 @@ struct scm_fp_list {struct list_head list;short count;short max; +struct user_struct *user;struct file *fp[SCM_MAX_FD ]; };
net/core/scm.c +7 -0
@@ -80,6 +80,7 @@ static int scm_fp_copy(struct cmsghdr *c *fplp = fpl; fpl->count =0 ; fpl->max =SCM_MAX_FD ; + fpl->user =NULL ; } fpp = &fpl->fp[fpl->count];
@@ -100,6 +101,10 @@ static int scm_fp_copy(struct cmsghdr *c *fpp++ = file; fpl->count++; } + +if (!fpl->user) + fpl->user =get_uid (current_user ()); +return num; }
@@ -124,6 +129,7 @@ void __scm_destroy(struct scm_cookie *sclist_del (&fpl->list);for (i=fpl->count-1 ; i>=0 ; i--)fput (fpl->fp[i]); +free_uid (fpl->user);kfree (fpl); }
@@ -342,6 +348,7 @@ struct scm_fp_list *scm_fp_dup(struct scfor (i =0 ; i < fpl->count; i++)get_file (fpl->fp[i]); new_fpl->max = new_fpl->count; + new_fpl->user =get_uid (fpl->user); }return new_fpl; }
net/unix/af_unix.c +2 -2
@@ -1454,7 +1454,7 @@ static void unix_detach_fds(struct scm_cUNIXCB (skb).fp =NULL ;for (i = scm->fp->count-1 ; i >=0 ; i--) -unix_notinflight (scm->fp->fp[i]); +unix_notinflight (scm->fp->user, scm->fp->fp[i]); }static void unix_destruct_scm (struct sk_buff *skb)
@@ -1520,7 +1520,7 @@ static int unix_attach_fds(struct scm_coreturn -ENOMEM ;for (i = scm->fp->count -1 ; i >=0 ; i--) -unix_inflight (scm->fp->fp[i]); +unix_inflight (scm->fp->user, scm->fp->fp[i]);return max_level; }
net/unix/garbage.c +4 -4
@@ -122,7 +122,7 @@ struct sock *unix_get_socket(struct file* descriptor if it is for an AF_UNIX socket. */ -void unix_inflight (struct file *fp) +void unix_inflight (struct user_struct *user,struct file *fp) {struct sock *s =unix_get_socket (fp);
@@ -138,11 +138,11 @@ void unix_inflight(struct file *fp) } unix_tot_inflight++; } - fp->f_cred->user->unix_inflight++; + user->unix_inflight++;spin_unlock (&unix_gc_lock); } -void unix_notinflight (struct file *fp) +void unix_notinflight (struct user_struct *user,struct file *fp) {struct sock *s =unix_get_socket (fp);
@@ -155,7 +155,7 @@ void unix_notinflight(struct file *fp)list_del_init (&u->link); unix_tot_inflight--; } - fp->f_cred->user->unix_inflight--; + user->unix_inflight--;spin_unlock (&unix_gc_lock); }
PATCH 65/67 iw_cxgb3: Fix incorrectly returning error on success
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hariprasad S <[email protected]>
commit 67f1aee6f45059fd6b0f5b0ecb2c97ad0451f6b3 upstream.
The cxgb3_*_send() functions return NET_XMIT_ values, which are positive integers values. So don't treat positive return values as an error.
--- drivers/infiniband/hw/cxgb3/iwch_cm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/cxgb3/iwch_cm.c +2 -2
@@ -150,7 +150,7 @@ static int iwch_l2t_send(struct t3cdev * error =l2t_send (tdev, skb, l2e);if (error <0 )kfree_skb (skb); -return error; +return error <0 ? error :0 ; }int iwch_cxgb3_ofld_send (struct t3cdev *tdev,struct sk_buff *skb)
@@ -166,7 +166,7 @@ int iwch_cxgb3_ofld_send(struct t3cdev * error =cxgb3_ofld_send (tdev, skb);if (error <0 )kfree_skb (skb); -return error; +return error <0 ? error :0 ; }static void release_tid (struct t3cdev *tdev,u32 hwtid,struct sk_buff *skb)
PATCH 66/67 pipe: Fix buffer offset after partially failed read
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ben Hutchings <[email protected]>
Quoting the RHEL advisory:
Quoted 5 lines
It was found that the fix for CVE-2015-1805 incorrectly kept buffer offset and buffer length in sync on a failed atomic read, potentially resulting in a pipe buffer state corruption. A local, unprivileged user could use this flaw to crash the system or leak kernel memory to user space. (CVE-2016-0774, Moderate)
The same flawed fix was applied to stable branches from 2.6.32.y to 3.14.y inclusive, and I was able to reproduce the issue on 3.2.y. We need to give pipe_iov_copy_to_user() a separate offset variable and only update the buffer offset if it succeeds.
References: https://rhn.redhat.com/errata/RHSA-2016-0103.html
---
fs/pipe.c +4 -1
@@ -395,6 +395,7 @@ pipe_read(struct kiocb *iocb, const struvoid *addr;size_t chars = buf->len, remaining;int error, atomic; +int offset;if (chars > total_len) chars = total_len;
@@ -408,9 +409,10 @@ pipe_read(struct kiocb *iocb, const stru atomic = !iov_fault_in_pages_write (iov, chars); remaining = chars; + offset = buf->offset; redo: addr = ops->map (pipe, buf, atomic); - error =pipe_iov_copy_to_user (iov, addr, &buf->offset, + error =pipe_iov_copy_to_user (iov, addr, &offset, &remaining, atomic); ops->unmap (pipe, buf, addr);if (unlikely (error)) {
@@ -426,6 +428,7 @@ redo:break ; } ret += chars; + buf->offset += chars; buf->len -= chars;/* Was it a packet buffer? Clean up and exit */
PATCH 67/67 sched: fix __sched_setscheduler() vs load balancing race
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mike Galbraith <[email protected]>
__sched_setscheduler() may release rq->lock in pull_rt_task() as a task is being changed rt -> fair class. load balancing may sneak in, move the task behind __sched_setscheduler()'s back, which explodes in switched_to_fair() when the passed but no longer valid rq is used. Tell can_migrate_task() to say no if ->pi_lock is held.
@stable: Kernels that predate SCHED_DEADLINE can use this simple (and tested) check in lieu of backport of the full 18 patch mainline treatment.
[bwh: Backported to 3.2:
- Adjust numbering in the comment
- Adjust filename]
--- kernel/sched/fair.c | 9 +++++++++ 1 file changed, 9 insertions(+)
kernel/sched_fair.c +9 -0
@@ -2791,6 +2791,7 @@ int can_migrate_task(struct task_struct* 1) running (obviously), or * 2) cannot be migrated to this CPU due to cpus_allowed, or * 3) are cache-hot on their current CPU. +* 4) p->pi_lock is held. */ if (!cpumask_test_cpu (this_cpu,tsk_cpus_allowed (p))) {schedstat_inc (p, se.statistics.nr_failed_migrations_affine);
@@ -2804,6 +2805,14 @@ int can_migrate_task(struct task_struct }/* +* rt -> fair class change may be in progress. If we sneak in should +* double_lock_balance() release rq->lock, and move the task, we will +* cause switched_to_fair() to meet a passed but no longer valid rq. +*/ +if (raw_spin_is_locked (&p->pi_lock)) +return 0 ; + +/* * Aggressive migration if: * 1) task is cache cold, or * 2) too many balance attempts have failed.
PATCH 6/67 usb: cdc-acm: send zero packet for intel 7260 modem
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Lu Baolu <[email protected]>
commit ffdb1e369a73b380fce95b05f8498d92c43842b4 upstream.
For Intel 7260 modem, it is needed for host side to send zero packet if the BULK OUT size is equal to USB endpoint max packet length. Otherwise, modem side may still wait for more data and cannot give response to host side.
--- drivers/usb/class/cdc-acm.c | 6 ++++++ drivers/usb/class/cdc-acm.h | 1 + 2 files changed, 7 insertions(+)
drivers/usb/class/cdc-acm.c +6 -0
@@ -1237,6 +1237,8 @@ made_compressed_probe:usb_sndbulkpipe (usb_dev, epwrite->bEndpointAddress), NULL, acm->writesize, acm_write_bulk, snd); snd->urb->transfer_flags |=URB_NO_TRANSFER_DMA_MAP ; +if (quirks &SEND_ZERO_PACKET ) + snd->urb->transfer_flags |=URB_ZERO_PACKET ; snd->instance = acm; }
@@ -1689,6 +1691,10 @@ static const struct usb_device_id acm_id { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, USB_CDC_ACM_PROTO_AT_CDMA) }, + { USB_DEVICE(0x1519, 0x0452), /* Intel 7260 modem */ + .driver_info = SEND_ZERO_PACKET, + }, + { } };
drivers/usb/class/cdc-acm.h +1 -0
@@ -129,3 +129,4 @@ struct acm {#define NO_DATA_INTERFACE 16#define IGNORE_DEVICE 32#define CLEAR_HALT_CONDITIONS BIT(7) +#define SEND_ZERO_PACKET BIT(8)
PATCH 12/67 USB: visor: fix null-deref at probe
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit cac9b50b0d75a1d50d6c056ff65c005f3224c8e0 upstream.
Fix null-pointer dereference at probe should a (malicious) Treo device lack the expected endpoints.
Specifically, the Treo port-setup hack was dereferencing the bulk-in and interrupt-in urbs without first making sure they had been allocated by core.
--- drivers/usb/serial/visor.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/serial/visor.c +5 -0
@@ -587,6 +587,11 @@ static int treo_attach(struct usb_serialdbg ("%s" , __func__); +if (serial->num_bulk_in <2 || serial->num_interrupt_in <2 ) { +dev_err (&serial->interface->dev,"missing endpoints\n" ); +return -ENODEV ; + } +/* * It appears that Treos and Kyoceras want to use the * 1st bulk in endpoint to communicate with the 2nd bulk out endpoint,
PATCH 45/67 saa7134-alsa: Only frees registered sound cards
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mauro Carvalho Chehab <[email protected]>
commit ac75fe5d8fe4a0bf063be18fb29684405279e79e upstream.
That prevents this bug:
[ 2382.269496] BUG: unable to handle kernel NULL pointer dereference at 0000000000000540 [ 2382.270013] IP: [<ffffffffa01fe616>] snd_card_free+0x36/0x70 [snd] [ 2382.270013] PGD 0 [ 2382.270013] Oops: 0002 [#1] SMP [ 2382.270013] Modules linked in: saa7134_alsa(-) tda1004x saa7134_dvb videobuf2_dvb dvb_core tda827x tda8290 tuner saa7134 tveeprom videobuf2_dma_sg videobuf2_memops videobuf2_v4l2 videobuf2_core v4l2_common videodev media auth_rpcgss nfsv4 dns_resolver nfs lockd grace sunrpc tun bridge stp llc ebtables ip6table_filter ip6_tables nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack it87 hwmon_vid snd_hda_codec_idt snd_hda_codec_generic iTCO_wdt iTCO_vendor_support snd_hda_intel snd_hda_codec snd_hwdep snd_hda_core snd_seq pcspkr i2c_i801 snd_seq_device snd_pcm snd_timer lpc_ich snd mfd_core soundcore binfmt_misc i915 video i2c_algo_bit drm_kms_helper drm r8169 ata_generic serio_raw pata_acpi mii i2c_core [last unloaded: videobuf2_memops] [ 2382.270013] CPU: 0 PID: 4899 Comm: rmmod Not tainted 4.5.0-rc1+ #4 [ 2382.270013] Hardware name: PCCHIPS P17G/P17G, BIOS 080012 05/14/2008 [ 2382.270013] task: ffff880039c38000 ti: ffff88003c764000 task.ti: ffff88003c764000 [ 2382.270013] RIP: 0010:[<ffffffffa01fe616>] [<ffffffffa01fe616>] snd_card_free+0x36/0x70 [snd] [ 2382.270013] RSP: 0018:ffff88003c767ea0 EFLAGS: 00010286 [ 2382.270013] RAX: ffff88003c767eb8 RBX: 0000000000000000 RCX: 0000000000006260 [ 2382.270013] RDX: ffffffffa020a060 RSI: ffffffffa0206de1 RDI: ffff88003c767eb0 [ 2382.270013] RBP: ffff88003c767ed8 R08: 0000000000019960 R09: ffffffff811a5412 [ 2382.270013] R10: ffffea0000d7c200 R11: 0000000000000000 R12: ffff88003c767ea8 [ 2382.270013] R13: 00007ffe760617f7 R14: 0000000000000000 R15: 0000557625d7f1e0 [ 2382.270013] FS: 00007f80bb1c0700(0000) GS:ffff88003f400000(0000) knlGS:0000000000000000 [ 2382.270013] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b [ 2382.270013] CR2: 0000000000000540 CR3: 000000003c00f000 CR4: 00000000000006f0 [ 2382.270013] Stack: [ 2382.270013] 000000003c767ed8 ffffffff00000000 ffff880000000000 ffff88003c767eb8 [ 2382.270013] ffff88003c767eb8 ffffffffa049a890 00007ffe76060060 ffff88003c767ef0 [ 2382.270013] ffffffffa049889d ffffffffa049a500 ffff88003c767f48 ffffffff8111079c [ 2382.270013] Call Trace: [ 2382.270013] [<ffffffffa049889d>] saa7134_alsa_exit+0x1d/0x780 [saa7134_alsa] [ 2382.270013] [<ffffffff8111079c>] SyS_delete_module+0x19c/0x1f0 [ 2382.270013] [<ffffffff8170fc2e>] entry_SYSCALL_64_fastpath+0x12/0x71 [ 2382.270013] Code: 20 a0 48 c7 c6 e1 6d 20 a0 48 89 e5 41 54 53 4c 8d 65 d0 48 89 fb 48 83 ec 28 c7 45 d0 00 00 00 00 49 8d 7c 24 08 e8 7a 55 ed e0 <4c> 89 a3 40 05 00 00 48 89 df e8 eb fd ff ff 85 c0 75 1a 48 8d [ 2382.270013] RIP [<ffffffffa01fe616>] snd_card_free+0x36/0x70 [snd] [ 2382.270013] RSP <ffff88003c767ea0> [ 2382.270013] CR2: 0000000000000540
--- drivers/media/video/saa7134/saa7134-alsa.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/video/saa7134/saa7134-alsa.c +4 -1
@@ -1145,6 +1145,8 @@ static int alsa_device_init(struct saa71static int alsa_device_exit (struct saa7134_dev *dev) { +if (!snd_saa7134_cards[dev->nr]) +return 1 ;snd_card_free (snd_saa7134_cards[dev->nr]); snd_saa7134_cards[dev->nr] =NULL ;
@@ -1194,7 +1196,8 @@ static void saa7134_alsa_exit(void)int idx;for (idx =0 ; idx <SNDRV_CARDS ; idx++) { -snd_card_free (snd_saa7134_cards[idx]); +if (snd_saa7134_cards[idx]) +snd_card_free (snd_saa7134_cards[idx]); } saa7134_dmasound_init =NULL ;
PATCH 38/67 ALSA: rawmidi: Fix race at copying & updating the position
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 81f577542af15640cbcb6ef68baa4caa610cbbfc upstream.
The rawmidi read and write functions manage runtime stream status such as runtime->appl_ptr and runtime->avail. These point where to copy the new data and how many bytes have been copied (or to be read). The problem is that rawmidi read/write call copy_from_user() or copy_to_user(), and the runtime spinlock is temporarily unlocked and relocked while copying user-space. Since the current code advances and updates the runtime status after the spin unlock/relock, the copy and the update may be asynchronous, and eventually runtime->avail might go to a negative value when many concurrent accesses are done. This may lead to memory corruption in the end.
For fixing this race, in this patch, the status update code is performed in the same lock before the temporary unlock. Also, the spinlock is now taken more widely in snd_rawmidi_kernel_read1() for protecting more properly during the whole operation.
--- sound/core/rawmidi.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-)
sound/core/rawmidi.c +22 -12
@@ -934,31 +934,36 @@ static long snd_rawmidi_kernel_read1(strunsigned long flags;long result =0 , count1;struct snd_rawmidi_runtime *runtime = substream->runtime; +unsigned long appl_ptr; +spin_lock_irqsave (&runtime->lock, flags);while (count >0 && runtime->avail) { count1 = runtime->buffer_size - runtime->appl_ptr;if (count1 > count) count1 = count; -spin_lock_irqsave (&runtime->lock, flags);if (count1 > (int )runtime->avail) count1 = runtime->avail; + +/* update runtime->appl_ptr before unlocking for userbuf */ + appl_ptr = runtime->appl_ptr; + runtime->appl_ptr += count1; + runtime->appl_ptr %= runtime->buffer_size; + runtime->avail -= count1; +if (kernelbuf) -memcpy (kernelbuf + result, runtime->buffer + runtime->appl_ptr, count1); +memcpy (kernelbuf + result, runtime->buffer + appl_ptr, count1);if (userbuf) {spin_unlock_irqrestore (&runtime->lock, flags);if (copy_to_user (userbuf + result, - runtime->buffer + runtime->appl_ptr, count1)) { + runtime->buffer + appl_ptr, count1)) {return result >0 ? result : -EFAULT ; }spin_lock_irqsave (&runtime->lock, flags); } - runtime->appl_ptr += count1; - runtime->appl_ptr %= runtime->buffer_size; - runtime->avail -= count1; -spin_unlock_irqrestore (&runtime->lock, flags); result += count1; count -= count1; } +spin_unlock_irqrestore (&runtime->lock, flags);return result; }
@@ -1207,6 +1212,7 @@ static long snd_rawmidi_kernel_write1(stunsigned long flags;long count1, result;struct snd_rawmidi_runtime *runtime = substream->runtime; +unsigned long appl_ptr;if (!kernelbuf && !userbuf)return -EINVAL ;
@@ -1227,12 +1233,19 @@ static long snd_rawmidi_kernel_write1(st count1 = count;if (count1 > (long )runtime->avail) count1 = runtime->avail; + +/* update runtime->appl_ptr before unlocking for userbuf */ + appl_ptr = runtime->appl_ptr; + runtime->appl_ptr += count1; + runtime->appl_ptr %= runtime->buffer_size; + runtime->avail -= count1; +if (kernelbuf) -memcpy (runtime->buffer + runtime->appl_ptr, +memcpy (runtime->buffer + appl_ptr, kernelbuf + result, count1);else if (userbuf) {spin_unlock_irqrestore (&runtime->lock, flags); -if (copy_from_user (runtime->buffer + runtime->appl_ptr, +if (copy_from_user (runtime->buffer + appl_ptr, userbuf + result, count1)) {spin_lock_irqsave (&runtime->lock, flags); result = result >0 ? result : -EFAULT ;
@@ -1240,9 +1253,6 @@ static long snd_rawmidi_kernel_write1(st }spin_lock_irqsave (&runtime->lock, flags); } - runtime->appl_ptr += count1; - runtime->appl_ptr %= runtime->buffer_size; - runtime->avail -= count1; result += count1; count -= count1; }
PATCH 37/67 ALSA: rawmidi: Make snd_rawmidi_transmit() race-free
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 06ab30034ed9c200a570ab13c017bde248ddb2a6 upstream.
A kernel WARNING in snd_rawmidi_transmit_ack() is triggered by syzkaller fuzzer:
WARNING: CPU: 1 PID: 20739 at sound/core/rawmidi.c:1136 Call Trace: [< inline >] __dump_stack lib/dump_stack.c:15 [<ffffffff82999e2d>] dump_stack+0x6f/0xa2 lib/dump_stack.c:50 [<ffffffff81352089>] warn_slowpath_common+0xd9/0x140 kernel/panic.c:482 [<ffffffff813522b9>] warn_slowpath_null+0x29/0x30 kernel/panic.c:515 [<ffffffff84f80bd5>] snd_rawmidi_transmit_ack+0x275/0x400 sound/core/rawmidi.c:1136 [<ffffffff84fdb3c1>] snd_virmidi_output_trigger+0x4b1/0x5a0 sound/core/seq/seq_virmidi.c:163 [< inline >] snd_rawmidi_output_trigger sound/core/rawmidi.c:150 [<ffffffff84f87ed9>] snd_rawmidi_kernel_write1+0x549/0x780 sound/core/rawmidi.c:1223 [<ffffffff84f89fd3>] snd_rawmidi_write+0x543/0xb30 sound/core/rawmidi.c:1273 [<ffffffff817b0323>] __vfs_write+0x113/0x480 fs/read_write.c:528 [<ffffffff817b1db7>] vfs_write+0x167/0x4a0 fs/read_write.c:577 [< inline >] SYSC_write fs/read_write.c:624 [<ffffffff817b50a1>] SyS_write+0x111/0x220 fs/read_write.c:616 [<ffffffff86336c36>] entry_SYSCALL_64_fastpath+0x16/0x7a arch/x86/entry/entry_64.S:185
Also a similar warning is found but in another path:
Call Trace: [< inline >] __dump_stack lib/dump_stack.c:15 [<ffffffff82be2c0d>] dump_stack+0x6f/0xa2 lib/dump_stack.c:50 [<ffffffff81355139>] warn_slowpath_common+0xd9/0x140 kernel/panic.c:482 [<ffffffff81355369>] warn_slowpath_null+0x29/0x30 kernel/panic.c:515 [<ffffffff8527e69a>] rawmidi_transmit_ack+0x24a/0x3b0 sound/core/rawmidi.c:1133 [<ffffffff8527e851>] snd_rawmidi_transmit_ack+0x51/0x80 sound/core/rawmidi.c:1163 [<ffffffff852d9046>] snd_virmidi_output_trigger+0x2b6/0x570 sound/core/seq/seq_virmidi.c:185 [< inline >] snd_rawmidi_output_trigger sound/core/rawmidi.c:150 [<ffffffff85285a0b>] snd_rawmidi_kernel_write1+0x4bb/0x760 sound/core/rawmidi.c:1252 [<ffffffff85287b73>] snd_rawmidi_write+0x543/0xb30 sound/core/rawmidi.c:1302 [<ffffffff817ba5f3>] __vfs_write+0x113/0x480 fs/read_write.c:528 [<ffffffff817bc087>] vfs_write+0x167/0x4a0 fs/read_write.c:577 [< inline >] SYSC_write fs/read_write.c:624 [<ffffffff817bf371>] SyS_write+0x111/0x220 fs/read_write.c:616 [<ffffffff86660276>] entry_SYSCALL_64_fastpath+0x16/0x7a arch/x86/entry/entry_64.S:185
In the former case, the reason is that virmidi has an open code calling snd_rawmidi_transmit_ack() with the value calculated outside
the spinlock. We may use snd_rawmidi_transmit() in a loop just for
consuming the input data, but even there, there is a race between snd_rawmidi_transmit_peek() and snd_rawmidi_tranmit_ack().
Similarly in the latter case, it calls snd_rawmidi_transmit_peek() and snd_rawmidi_tranmit_ack() separately without protection, so they are racy as well.
The patch tries to address these issues by the following ways:
- Introduce the unlocked versions of snd_rawmidi_transmit_peek() and snd_rawmidi_transmit_ack() to be called inside the explicit lock.
- Rewrite snd_rawmidi_transmit() to be race-free (the former case).
- Make the split calls (the latter case) protected in the rawmidi spin lock.
--- include/sound/rawmidi.h | 4 ++ sound/core/rawmidi.c | 98 ++++++++++++++++++++++++++++++++------------ sound/core/seq/seq_virmidi.c | 17 +++++--- 3 files changed, 88 insertions(+), 31 deletions(-)
include/sound/rawmidi.h +4 -0
@@ -167,6 +167,10 @@ int snd_rawmidi_transmit_peek(struct sndint snd_rawmidi_transmit_ack (struct snd_rawmidi_substream *substream,int count);int snd_rawmidi_transmit (struct snd_rawmidi_substream *substream,unsigned char *buffer,int count); +int __snd_rawmidi_transmit_peek (struct snd_rawmidi_substream *substream, +unsigned char *buffer,int count); +int __snd_rawmidi_transmit_ack (struct snd_rawmidi_substream *substream, +int count);/* main midi functions */
sound/core/rawmidi.c +72 -26
154 lines not on this page · raw message
sound/core/seq/seq_virmidi.c +12 -5
@@ -155,21 +155,26 @@ static void snd_virmidi_output_trigger(sstruct snd_virmidi *vmidi = substream->runtime->private_data;int count, res;unsigned char buf[32 ], *pbuf; +unsigned long flags;if (up) { vmidi->trigger =1 ;if (vmidi->seq_mode ==SNDRV_VIRMIDI_SEQ_DISPATCH && !(vmidi->rdev->flags &SNDRV_VIRMIDI_SUBSCRIBE )) { -snd_rawmidi_transmit_ack (substream, substream->runtime->buffer_size - substream->runtime->avail); -return ;/* ignored */ +while (snd_rawmidi_transmit (substream, buf, +sizeof (buf)) >0 ) { +/* ignored */ + } +return ; }if (vmidi->event.type !=SNDRV_SEQ_EVENT_NONE ) {if (snd_seq_kernel_client_dispatch (vmidi->client, &vmidi->event,in_atomic (),0 ) <0 )return ; vmidi->event.type =SNDRV_SEQ_EVENT_NONE ; } +spin_lock_irqsave (&substream->runtime->lock, flags);while (1 ) { - count =snd_rawmidi_transmit_peek (substream, buf,sizeof (buf)); + count =__snd_rawmidi_transmit_peek (substream, buf,sizeof (buf));if (count <=0 )break ; pbuf = buf;
@@ -179,16 +184,18 @@ static void snd_virmidi_output_trigger(ssnd_midi_event_reset_encode (vmidi->parser);continue ; } -snd_rawmidi_transmit_ack (substream, res); +__snd_rawmidi_transmit_ack (substream, res); pbuf += res; count -= res;if (vmidi->event.type !=SNDRV_SEQ_EVENT_NONE ) {if (snd_seq_kernel_client_dispatch (vmidi->client, &vmidi->event,in_atomic (),0 ) <0 ) -return ; + goto out; vmidi->event.type =SNDRV_SEQ_EVENT_NONE ; } } } + out: +spin_unlock_irqrestore (&substream->runtime->lock, flags); }else { vmidi->trigger =0 ; }
PATCH 56/67 ALSA: timer: Fix race between stop and interrupt
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit ed8b1d6d2c741ab26d60d499d7fbb7ac801f0f51 upstream.
A slave timer element also unlinks at snd_timer_stop() but it takes only slave_active_lock. When a slave is assigned to a master, however, this may become a race against the master's interrupt handling, eventually resulting in a list corruption. The actual bug could be seen with a syzkaller fuzzer test case in BugLink below.
As a fix, we need to take timeri->timer->lock when timer isn't NULL, i.e. assigned to a master, while the assignment to a master itself is protected by slave_active_lock.
--- sound/core/timer.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/core/timer.c +4 -0
@@ -510,9 +510,13 @@ static int _snd_timer_stop(struct snd_tispin_unlock_irqrestore (&slave_active_lock, flags);return -EBUSY ; } +if (timeri->timer) +spin_lock (&timeri->timer->lock); timeri->flags &= ~SNDRV_TIMER_IFLG_RUNNING ;list_del_init (&timeri->ack_list);list_del_init (&timeri->active_list); +if (timeri->timer) +spin_unlock (&timeri->timer->lock);spin_unlock_irqrestore (&slave_active_lock, flags); } goto __end;
PATCH 48/67 ocfs2/dlm: clear refmap bit of recovery lock while doing local recovery cleanup
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: xuejiufei <[email protected]>
commit c95a51807b730e4681e2ecbdfd669ca52601959e upstream.
When recovery master down, dlm_do_local_recovery_cleanup() only remove the $RECOVERY lock owned by dead node, but do not clear the refmap bit. Which will make umount thread falling in dead loop migrating $RECOVERY to the dead node.
--- fs/ocfs2/dlm/dlmrecovery.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ocfs2/dlm/dlmrecovery.c +2 -0
@@ -2333,6 +2333,8 @@ static void dlm_do_local_recovery_cleanubreak ; } } +dlm_lockres_clear_refmap_bit (dlm, res, + dead_node);spin_unlock (&res->spinlock);continue ; }
PATCH 53/67 ALSA: timer: Fix wrong instance passed to slave callbacks
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 117159f0b9d392fb433a7871426fad50317f06f7 upstream.
In snd_timer_notify1(), the wrong timer instance was passed for slave ccallback function. This leads to the access to the wrong data when an incompatible master is handled (e.g. the master is the sequencer timer and the slave is a user timer), as spotted by syzkaller fuzzer.
This patch fixes that wrong assignment.
--- sound/core/timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/timer.c +1 -1
@@ -414,7 +414,7 @@ static void snd_timer_notify1(struct sndspin_lock_irqsave (&timer->lock, flags);list_for_each_entry (ts, &ti->slave_active_head, active_list)if (ts->ccallback) - ts->ccallback (ti, event +100 , &tstamp, resolution); + ts->ccallback (ts, event +100 , &tstamp, resolution);spin_unlock_irqrestore (&timer->lock, flags); }
PATCH 31/67 ALSA: seq: Fix race at closing in virmidi driver
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 2d1b5c08366acd46c35a2e9aba5d650cb5bf5c19 upstream.
The virmidi driver has an open race at closing its assigned rawmidi device, and this may lead to use-after-free in snd_seq_deliver_single_event().
Plug the hole by properly protecting the linked list deletion and calling in the right order in snd_virmidi_input_close().
--- sound/core/seq/seq_virmidi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
sound/core/seq/seq_virmidi.c +5 -1
@@ -254,9 +254,13 @@ static int snd_virmidi_output_open(struc*/ static int snd_virmidi_input_close (struct snd_rawmidi_substream *substream) { +struct snd_virmidi_dev *rdev = substream->rmidi->private_data;struct snd_virmidi *vmidi = substream->runtime->private_data; -snd_midi_event_free (vmidi->parser); + +write_lock_irq (&rdev->filelist_lock);list_del (&vmidi->list); +write_unlock_irq (&rdev->filelist_lock); +snd_midi_event_free (vmidi->parser); substream->runtime->private_data =NULL ;kfree (vmidi);return 0 ;
PATCH 26/67 ALSA: dummy: Disable switching timer backend via sysfs
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 7ee96216c31aabe1eb42fb91ff50dae9fcd014b2 upstream.
ALSA dummy driver can switch the timer backend between system timer and hrtimer via its hrtimer module option. This can be also switched dynamically via sysfs, but it may lead to a memory corruption when switching is done while a PCM stream is running; the stream instance for the newly switched timer method tries to access the memory that was allocated by another timer method although the sizes differ.
As the simplest fix, this patch just disables the switch via sysfs by dropping the writable bit.
--- sound/drivers/dummy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/drivers/dummy.c +1 -1
@@ -87,7 +87,7 @@ MODULE_PARM_DESC(pcm_substreams, "PCM sumodule_param (fake_buffer, bool,0444 );MODULE_PARM_DESC (fake_buffer,"Fake buffer allocations." );#ifdef CONFIG_HIGH_RES_TIMERS -module_param (hrtimer, bool,0644 ); +module_param (hrtimer, bool,0444 );MODULE_PARM_DESC (hrtimer,"Use hrtimer as the timer source." );#endif
PATCH 19/67 libata: disable forced PORTS_IMPL for >= AHCI 1.3
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
commit 566d1827df2ef0cbe921d3d6946ac3007b1a6938 upstream.
Some early controllers incorrectly reported zero ports in PORTS_IMPL register and the ahci driver fabricates PORTS_IMPL from the number of ports in those cases. This hasn't mattered but with the new nvme controllers there are cases where zero PORTS_IMPL is valid and should be honored.
Disable the workaround for >= AHCI 1.3.
--- drivers/ata/libahci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ata/libahci.c +2 -2
@@ -480,8 +480,8 @@ void ahci_save_initial_config(struct dev } } -/* fabricate port_map from cap.nr_ports */ -if (!port_map) { +/* fabricate port_map from cap.nr_ports for < AHCI 1.3 */ +if (!port_map && vers <0x10300 ) { port_map = (1 <<ahci_nr_ports (cap)) -1 ;dev_warn (dev,"forcing PORTS_IMPL to 0x%x\n" , port_map);
PATCH 23/67 SCSI: fix crashes in sd and sr runtime PM
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 13b4389143413a1f18127c07f72c74cad5b563e8 upstream.
Runtime suspend during driver probe and removal can cause problems. The driver's runtime_suspend or runtime_resume callbacks may invoked before the driver has finished binding to the device or after the driver has unbound from the device.
This problem shows up with the sd and sr drivers, and can cause disk or CD/DVD drives to become unusable as a result. The fix is simple. The drivers store a pointer to the scsi_disk or scsi_cd structure as their private device data when probing is finished, so we simply have to be sure to clear the private data during removal and test it during runtime suspend/resume.
This fixes <https://bugs.debian.org/801925>.
---
drivers/scsi/sd.c +5 -2
@@ -2767,8 +2767,8 @@ static int sd_suspend(struct device *devstruct scsi_disk *sdkp =scsi_disk_get_from_dev (dev);int ret =0 ; -if (!sdkp) -return 0 ;/* this can happen */ +if (!sdkp)/* E.g.: runtime suspend following sd_remove() */ +return 0 ;if (sdkp->WCE) {sd_printk (KERN_NOTICE , sdkp,"Synchronizing SCSI cache\n" );
@@ -2792,6 +2792,9 @@ static int sd_resume(struct device *dev)struct scsi_disk *sdkp =scsi_disk_get_from_dev (dev);int ret =0 ; +if (!sdkp)/* E.g.: runtime resume at the start of sd_probe() */ +return 0 ; +if (!sdkp->device->manage_start_stop) goto done;
PATCH 15/67 ALSA: seq: Fix incorrect sanity check at snd_seq_oss_synth_cleanup()
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 599151336638d57b98d92338aa59c048e3a3e97d upstream.
ALSA sequencer OSS emulation code has a sanity check for currently opened devices, but there is a thinko there, eventually it spews warnings and skips the operation wrongly like:
WARNING: CPU: 1 PID: 7573 at sound/core/seq/oss/seq_oss_synth.c:311
Fix this off-by-one error.
--- sound/core/seq/oss/seq_oss_synth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/seq/oss/seq_oss_synth.c +1 -1
@@ -310,7 +310,7 @@ snd_seq_oss_synth_cleanup(struct seq_ossstruct seq_oss_synth *rec;struct seq_oss_synthinfo *info; -if (snd_BUG_ON (dp->max_synthdev >=SNDRV_SEQ_OSS_MAX_SYNTH_DEVS )) +if (snd_BUG_ON (dp->max_synthdev >SNDRV_SEQ_OSS_MAX_SYNTH_DEVS ))return ;for (i =0 ; i < dp->max_synthdev; i++) { info = &dp->synths[i];
PATCH 22/67 perf annotate browser: Fix behaviour of Shift-Tab with nothing focussed
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Markus Trippelsdorf <[email protected]>
commit d4913cbd05bab685e49c8174896e563b2487d054 upstream.
The issue was pointed out by gcc-6's -Wmisleading-indentation.
--- tools/perf/util/ui/browsers/annotate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/ui/browsers/annotate.c +2 -2
@@ -276,11 +276,11 @@ static int annotate_browser__run(struct nd = self->curr_hot;break ;case K_UNTAB : -if (nd !=NULL ) +if (nd !=NULL ) { nd =rb_next (nd);if (nd ==NULL ) nd =rb_first (&self->entries); -else + }else nd = self->curr_hot;break ;case 'H' :
PATCH 27/67 drm/vmwgfx: respect 'nomodeset'
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Rob Clark <[email protected]>
commit 96c5d076f0a5e2023ecdb44d8261f87641ee71e0 upstream.
--- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +7 -0
@@ -25,6 +25,7 @@* **************************************************************************/ #include <linux/module.h> +#include <linux/console.h> #include "drmP.h" #include "vmwgfx_drv.h"
@@ -1142,6 +1143,12 @@ static int vmw_probe(struct pci_dev *pdestatic int __init vmwgfx_init (void ) {int ret; + +#ifdef CONFIG_VGA_CONSOLE +if (vgacon_text_force ()) +return -EINVAL ; +#endif + ret =drm_pci_init (&driver, &vmw_pci_driver);if (ret)DRM_ERROR ("Failed initializing DRM.\n" );
PATCH 9/67 pptp: fix illegal memory access caused by multiple bind()s
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hannes Frederic Sowa <[email protected]>
commit 9a368aff9cb370298fa02feeffa861f2db497c18 upstream.
Several times already this has been reported as kasan reports caused by syzkaller and trinity and people always looked at RCU races, but it is much more simple. :)
In case we bind a pptp socket multiple times, we simply add it to the callid_sock list but don't remove the old binding. Thus the old socket stays in the bucket with unused call_id indexes and doesn't get cleaned up. This causes various forms of kasan reports which were hard to pinpoint.
Simply don't allow multiple binds and correct error handling in pptp_bind. Also keep sk_state bits in place in pptp_connect.
--- drivers/net/ppp/pptp.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-)
drivers/net/ppp/pptp.c +24 -10
@@ -131,24 +131,27 @@ static int lookup_chan_dst(u16 call_id,return i <MAX_CALLID ; } -static int add_chan (struct pppox_sock *sock) +static int add_chan (struct pppox_sock *sock, +struct pptp_addr *sa) {static int call_id;spin_lock (&chan_lock); -if (!sock->proto.pptp.src_addr.call_id) { +if (!sa->call_id) { call_id =find_next_zero_bit (callid_bitmap,MAX_CALLID , call_id +1 );if (call_id ==MAX_CALLID ) { call_id =find_next_zero_bit (callid_bitmap,MAX_CALLID ,1 );if (call_id ==MAX_CALLID ) goto out_err; } - sock->proto.pptp.src_addr.call_id = call_id; - }else if (test_bit (sock->proto.pptp.src_addr.call_id, callid_bitmap)) + sa->call_id = call_id; + }else if (test_bit (sa->call_id, callid_bitmap)) { goto out_err; + } -set_bit (sock->proto.pptp.src_addr.call_id, callid_bitmap); -rcu_assign_pointer (callid_sock[sock->proto.pptp.src_addr.call_id], sock); + sock->proto.pptp.src_addr = *sa; +set_bit (sa->call_id, callid_bitmap); +rcu_assign_pointer (callid_sock[sa->call_id], sock);spin_unlock (&chan_lock);return 0 ;
@@ -417,7 +420,6 @@ static int pptp_bind(struct socket *sockstruct sock *sk = sock->sk;struct sockaddr_pppox *sp = (struct sockaddr_pppox *) uservaddr;struct pppox_sock *po =pppox_sk (sk); -struct pptp_opt *opt = &po->proto.pptp;int error =0 ;if (sockaddr_len <sizeof (struct sockaddr_pppox ))
@@ -425,10 +427,22 @@ static int pptp_bind(struct socket *socklock_sock (sk); - opt->src_addr = sp->sa_addr.pptp; -if (add_chan (po)) +if (sk->sk_state &PPPOX_DEAD ) { + error = -EALREADY ; + goto out; + } + +if (sk->sk_state &PPPOX_BOUND ) { error = -EBUSY ; + goto out; + } + +if (add_chan (po, &sp->sa_addr.pptp)) + error = -EBUSY ; +else + sk->sk_state |=PPPOX_BOUND ; +out:release_sock (sk);return error; }
@@ -499,7 +513,7 @@ static int pptp_connect(struct socket *s } opt->dst_addr = sp->sa_addr.pptp; - sk->sk_state =PPPOX_CONNECTED ; + sk->sk_state |=PPPOX_CONNECTED ; end:release_sock (sk);
PATCH 13/67 USB: serial: visor: fix crash on detecting device without write_urbs
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Vladis Dronov <[email protected]>
commit cb3232138e37129e88240a98a1d2aba2187ff57c upstream.
The visor driver crashes in clie_5_attach() when a specially crafted USB device without bulk-out endpoint is detected. This fix adds a check that the device has proper configuration expected by the driver.
--- drivers/usb/serial/visor.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/usb/serial/visor.c +4 -2
@@ -640,8 +640,10 @@ static int clie_5_attach(struct usb_seri*/ /* some sanity check */ -if (serial->num_ports <2 ) -return -1 ; +if (serial->num_bulk_out <2 ) { +dev_err (&serial->interface->dev,"missing bulk out endpoints\n" ); +return -ENODEV ; + }/* port 0 now uses the modified endpoint Address */ port = serial->port[0 ];
PATCH 64/67 pipe: limit the per-user amount of pages allocated in pipes
In reply to Ben Hutchings3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Willy Tarreau <[email protected]>
commit 759c01142a5d0f364a462346168a56de28a80f52 upstream.
On no-so-small systems, it is possible for a single process to cause an OOM condition by filling large pipes with data that are never read. A typical process filling 4000 pipes with 1 MB of data will use 4 GB of memory. On small systems it may be tricky to set the pipe max size to prevent this from happening.
This patch makes it possible to enforce a per-user soft limit above which new pipes will be limited to a single page, effectively limiting them to 4 kB each, as well as a hard limit above which no new pipes may be created for this user. This has the effect of protecting the system against memory abuse without hurting other users, and still allowing pipes to work correctly though with less data at once.
The limit are controlled by two new sysctls : pipe-user-pages-soft, and pipe-user-pages-hard. Both may be disabled by setting them to zero. The default soft limit allows the default number of FDs per process (1024) to create pipes of the default size (64kB), thus reaching a limit of 64MB before starting to create only smaller pipes. With 256 processes limited to 1024 FDs each, this results in 1024*64kB + (256*1024 - 1024) * 4kB = 1084 MB of memory allocated for a user. The hard limit is disabled by default to avoid breaking existing applications that make intensive use of pipes (eg: for splicing).
Mitigates: CVE-2013-4312 (Linux 2.0+)
--- Documentation/sysctl/fs.txt | 23 ++++++++++++++++++++++ fs/pipe.c | 47 +++++++++++++++++++++++++++++++++++++++++++-- include/linux/pipe_fs_i.h | 4 ++++ include/linux/sched.h | 1 + kernel/sysctl.c | 14 ++++++++++++++ 5 files changed, 87 insertions(+), 2 deletions(-)
Documentation/sysctl/fs.txt +23 -0
@@ -32,6 +32,8 @@ Currently, these files are in /proc/sys/ - nr_open - overflowuid - overflowgid +- pipe-user-pages-hard +- pipe-user-pages-soft - suid_dumpable - super-max - super-nr
@@ -157,6 +159,27 @@ The default is 65534. ============================================================== +pipe-user-pages-hard: + +Maximum total number of pages a non-privileged user may allocate for pipes. +Once this limit is reached, no new pipes may be allocated until usage goes +below the limit again. When set to 0, no limit is applied, which is the default +setting. + +============================================================== + +pipe-user-pages-soft: + +Maximum total number of pages a non-privileged user may allocate for pipes +before the pipe size gets limited to a single page. Once this limit is reached, +new pipes will be limited to a single page in size for this user in order to +limit total memory usage, and trying to increase them using fcntl() will be +denied until usage goes below the limit again. The default value allows to +allocate up to 1024 pipes at their default size. When set to 0, no limit is +applied. + +============================================================== + suid_dumpable: This value can be used to query and set the core dump mode for setuid
fs/pipe.c +45 -2
89 lines not on this page · raw message
include/linux/pipe_fs_i.h +4 -0
@@ -43,6 +43,7 @@ struct pipe_buffer {* @fasync_writers: writer side fasync * @inode: inode this pipe is attached to * @bufs: the circular array of pipe buffers +* @user: the user who created this pipe **/ struct pipe_inode_info {wait_queue_head_t wait;
@@ -57,6 +58,7 @@ struct pipe_inode_info {struct fasync_struct *fasync_writers;struct inode *inode;struct pipe_buffer *bufs; +struct user_struct *user; };/*
@@ -142,6 +144,8 @@ void pipe_unlock(struct pipe_inode_infovoid pipe_double_lock (struct pipe_inode_info *,struct pipe_inode_info *);extern unsigned int pipe_max_size, pipe_min_size; +extern unsigned long pipe_user_pages_hard; +extern unsigned long pipe_user_pages_soft;int pipe_proc_fn (struct ctl_table *,int ,void __user *,size_t *,loff_t *);
include/linux/sched.h +1 -0
@@ -710,6 +710,7 @@ struct user_struct {#endif unsigned long locked_shm;/* How many pages of mlocked shm ? */ unsigned long unix_inflight;/* How many files in flight in unix sockets */ +atomic_long_t pipe_bufs;/* how many pages are allocated in pipe buffers */ #ifdef CONFIG_KEYS struct key *uid_keyring;/* UID specific keyring */
kernel/sysctl.c +14 -0
@@ -1518,6 +1518,20 @@ static struct ctl_table fs_table[] = { .proc_handler = &pipe_proc_fn, .extra1 = &pipe_min_size, }, + { + .procname = "pipe-user-pages-hard", + .data = &pipe_user_pages_hard, + .maxlen = sizeof(pipe_user_pages_hard), + .mode = 0644, + .proc_handler = proc_doulongvec_minmax, + }, + { + .procname = "pipe-user-pages-soft", + .data = &pipe_user_pages_soft, + .maxlen = sizeof(pipe_user_pages_soft), + .mode = 0644, + .proc_handler = proc_doulongvec_minmax, + }, { } };
Re: [PATCH 3.2 08/67] af_unix: fix struct pid memory leak
In reply to Ben HutchingsQuoted 7 lines · Ben Hutchings
3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit
fa0dc04df259ba2df3ce1920e9690c7842f8fa4bupstream.
[...]
Quoted 1 line
Fixes b3ca9b02b007 ("net: fix multithreaded signal handling in unix recv routines")
[...]
net/unix/af_unix.c static int unix_stream_recvmsg(struct ki · line 2105
Quoted 12 lines
net/unix/af_unix.c | 1 + 1 file changed, 1 insertion(+)net/unix/af_unix.c +1
-0@@ -2100,6 +2100,7 @@ static int unix_stream_recvmsg(struct kiif (signal_pending (current)) { err =sock_intr_errno (timeo); +scm_destroy (siocb->scm); goto out; }
JFTR: The commit mentioned in the fixes is (just the relevant part)
@@ -1895,11 +1903,12 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
timeo = unix_stream_data_wait(sk, timeo);
- if (signal_pending(current)) {
+ if (signal_pending(current)
+ || mutex_lock_interruptible(&u->readlock)) {
err = sock_intr_errno(timeo);
goto out;
}
- mutex_lock(&u->readlock);
+
continue;
unlock:
unix_state_unlock(sk);This not only didn't add the block triggering the error but this change isn't even part of the (version of) the function which was fixed anymore.
This is the combined diff for 3.2.78-rc1 relative to 3.2.77.
Ben.
Signature · 2 lines
Ben Hutchings Beware of programmers who carry screwdrivers. - Leonard Brandwein
Documentation/sysctl/fs.txt +23 -0
@@ -32,6 +32,8 @@ Currently, these files are in /proc/sys/fs: - nr_open - overflowuid - overflowgid +- pipe-user-pages-hard +- pipe-user-pages-soft - suid_dumpable - super-max - super-nr
@@ -157,6 +159,27 @@ The default is 65534. ============================================================== +pipe-user-pages-hard: + +Maximum total number of pages a non-privileged user may allocate for pipes. +Once this limit is reached, no new pipes may be allocated until usage goes +below the limit again. When set to 0, no limit is applied, which is the default +setting. + +============================================================== + +pipe-user-pages-soft: + +Maximum total number of pages a non-privileged user may allocate for pipes +before the pipe size gets limited to a single page. Once this limit is reached, +new pipes will be limited to a single page in size for this user in order to +limit total memory usage, and trying to increase them using fcntl() will be +denied until usage goes below the limit again. The default value allows to +allocate up to 1024 pipes at their default size. When set to 0, no limit is +applied. + +============================================================== + suid_dumpable: This value can be used to query and set the core dump mode for setuid
Makefile +2 -2
@@ -1,7 +1,7 @@ VERSION = 3 PATCHLEVEL = 2 -SUBLEVEL = 77 -EXTRAVERSION = +SUBLEVEL = 78 +EXTRAVERSION = -rc1 NAME = Saber-toothed Squirrel # *DOCUMENTATION*
arch/arm/common/icst.c +7 -2
@@ -16,7 +16,7 @@*/ #include <linux/module.h> #include <linux/kernel.h> - +#include <asm/div64.h> #include <asm/hardware/icst.h> /*
@@ -29,7 +29,11 @@ EXPORT_SYMBOL(icst525_s2div);unsigned long icst_hz (const struct icst_params *p,struct icst_vco vco) { -return p->ref *2 * (vco.v +8 ) / ((vco.r +2 ) * p->s2div[vco.s]); +u64 dividend = p->ref *2 * (u64)(vco.v +8 ); +u32 divisor = (vco.r +2 ) * p->s2div[vco.s]; + +do_div (dividend, divisor); +return (unsigned long )dividend; }EXPORT_SYMBOL (icst_hz);
@@ -58,6 +62,7 @@ icst_hz_to_vco(const struct icst_params *p, unsigned long freq)if (f > p->vco_min && f <= p->vco_max)break ; + i++; }while (i <8 );if (i >=8 )
arch/x86/kvm/x86.c +2 -1
@@ -5257,9 +5257,10 @@ int kvm_arch_init(void *opaque) goto out;kvm_set_mmio_spte_mask (); -kvm_init_msr_list (); kvm_x86_ops = ops; +kvm_init_msr_list (); +kvm_mmu_set_mask_ptes (PT_USER_MASK ,PT_ACCESSED_MASK ,PT_DIRTY_MASK ,PT64_NX_MASK ,0 );
arch/x86/mm/pageattr.c +2 -2
@@ -32,7 +32,7 @@ struct cpa_data {unsigned long *vaddr;pgprot_t mask_set;pgprot_t mask_clr; -int numpages; +unsigned long numpages;int flags;unsigned long pfn; unsigned force_split : 1;
@@ -820,7 +820,7 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias)* CPA operation. Either a large page has been * preserved or a single page update happened. */ -BUG_ON (cpa->numpages > numpages); +BUG_ON (cpa->numpages > numpages || !cpa->numpages); numpages -= cpa->numpages;if (cpa->flags & (CPA_PAGES_ARRAY |CPA_ARRAY )) cpa->curpage++;
crypto/algif_hash.c +3 -1
@@ -56,7 +56,8 @@ static int hash_sendmsg(struct kiocb *unused, struct socket *sock,lock_sock (sk);if (!ctx->more) { - err =crypto_ahash_init (&ctx->req); + err =af_alg_wait_for_completion (crypto_ahash_init (&ctx->req), + &ctx->completion);if (err) goto unlock; }
@@ -136,6 +137,7 @@ static ssize_t hash_sendpage(struct socket *sock, struct page *page, }else {if (!ctx->more) { err =crypto_ahash_init (&ctx->req); + err =af_alg_wait_for_completion (err, &ctx->completion);if (err) goto unlock; }
crypto/algif_skcipher.c +4 -1
@@ -249,8 +249,11 @@ static int skcipher_sendmsg(struct kiocb *unused, struct socket *sock, {struct sock *sk = sock->sk;struct alg_sock *ask =alg_sk (sk); +struct sock *psk = ask->parent; +struct alg_sock *pask =alg_sk (psk);struct skcipher_ctx *ctx = ask->private; -struct crypto_ablkcipher *tfm =crypto_ablkcipher_reqtfm (&ctx->req); +struct ablkcipher_tfm *skc = pask->private; +struct crypto_ablkcipher *tfm = skc->base;unsigned ivsize =crypto_ablkcipher_ivsize (tfm);struct skcipher_sg_list *sgl;struct af_alg_control con = {};
crypto/crypto_user.c +5 -1
@@ -390,8 +390,12 @@ static int crypto_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)if (link->dump ==NULL )return -EINVAL ; -return netlink_dump_start (crypto_nlsk, skb, nlh, +down_read (&crypto_alg_sem); + err =netlink_dump_start (crypto_nlsk, skb, nlh, link->dump, link->done,0 ); +up_read (&crypto_alg_sem); + +return err; } err = nlmsg_parse(nlh, crypto_msg_min[type], attrs, CRYPTOCFGA_MAX,
crypto/shash.c +3 -4
@@ -353,11 +353,10 @@ int crypto_init_shash_ops_async(struct crypto_tfm *tfm) crt->final = shash_async_final; crt->finup = shash_async_finup; crt->digest = shash_async_digest; + crt->setkey = shash_async_setkey; + + crt->has_setkey = alg->setkey != shash_no_setkey; -if (alg->setkey) { - crt->setkey = shash_async_setkey; - crt->has_setkey = true; - }if (alg->export) crt->export = shash_async_export;if (alg->import)
drivers/ata/ahci.c +20 -0
@@ -274,6 +274,26 @@ static const struct pci_device_id ahci_pci_tbl[] = { { PCI_VDEVICE(INTEL, 0x3b2b), board_ahci }, /* PCH RAID */ { PCI_VDEVICE(INTEL, 0x3b2c), board_ahci }, /* PCH RAID */ { PCI_VDEVICE(INTEL, 0x3b2f), board_ahci }, /* PCH AHCI */ + { PCI_VDEVICE(INTEL, 0x19b0), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19b1), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19b2), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19b3), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19b4), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19b5), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19b6), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19b7), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19bE), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19bF), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19c0), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19c1), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19c2), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19c3), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19c4), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19c5), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19c6), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19c7), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19cE), board_ahci }, /* DNV AHCI */ + { PCI_VDEVICE(INTEL, 0x19cF), board_ahci }, /* DNV AHCI */ { PCI_VDEVICE(INTEL, 0x1c02), board_ahci }, /* CPT AHCI */ { PCI_VDEVICE(INTEL, 0x1c03), board_ahci }, /* CPT AHCI */ { PCI_VDEVICE(INTEL, 0x1c04), board_ahci }, /* CPT RAID */
drivers/ata/libahci.c +2 -2
@@ -480,8 +480,8 @@ void ahci_save_initial_config(struct device *dev, } } -/* fabricate port_map from cap.nr_ports */ -if (!port_map) { +/* fabricate port_map from cap.nr_ports for < AHCI 1.3 */ +if (!port_map && vers <0x10300 ) { port_map = (1 <<ahci_nr_ports (cap)) -1 ;dev_warn (dev,"forcing PORTS_IMPL to 0x%x\n" , port_map);
drivers/ata/libata-sff.c +11 -21
@@ -997,12 +997,9 @@ static inline int ata_hsm_ok_in_wq(struct ata_port *ap,static void ata_hsm_qc_complete (struct ata_queued_cmd *qc,int in_wq) {struct ata_port *ap = qc->ap; -unsigned long flags;if (ap->ops->error_handler) {if (in_wq) { -spin_lock_irqsave (ap->lock, flags); -/* EH might have kicked in while host lock is * released. */
@@ -1014,8 +1011,6 @@ static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq) }else ata_port_freeze (ap); } - -spin_unlock_irqrestore (ap->lock, flags); }else {if (likely (!(qc->err_mask &AC_ERR_HSM )))ata_qc_complete (qc);
@@ -1024,10 +1019,8 @@ static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq) } }else {if (in_wq) { -spin_lock_irqsave (ap->lock, flags);ata_sff_irq_on (ap);ata_qc_complete (qc); -spin_unlock_irqrestore (ap->lock, flags); }else ata_qc_complete (qc); }
@@ -1048,9 +1041,10 @@ int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc, {struct ata_link *link = qc->dev->link;struct ata_eh_info *ehi = &link->eh_info; -unsigned long flags =0 ;int poll_next; +lockdep_assert_held (ap->lock); +WARN_ON_ONCE ((qc->flags &ATA_QCFLAG_ACTIVE ) ==0 );/* Make sure ata_sff_qc_issue() does not throw things
@@ -1112,14 +1106,6 @@ fsm_start: } } -/* Send the CDB (atapi) or the first data block (ata pio out). -* During the state transition, interrupt handler shouldn't -* be invoked before the data transfer is complete and -* hsm_task_state is changed. Hence, the following locking. -*/ -if (in_wq) -spin_lock_irqsave (ap->lock, flags); -if (qc->tf.protocol ==ATA_PROT_PIO ) {/* PIO data out protocol. * send first data block.
@@ -1135,9 +1121,6 @@ fsm_start:/* send CDB */ atapi_send_cdb (ap, qc); -if (in_wq) -spin_unlock_irqrestore (ap->lock, flags); -/* if polling, ata_sff_pio_task() handles the rest. * otherwise, interrupt handler takes over from here. */
@@ -1361,12 +1344,14 @@ static void ata_sff_pio_task(struct work_struct *work)u8 status;int poll_next; +spin_lock_irq (ap->lock); +BUG_ON (ap->sff_pio_task_link ==NULL );/* qc can be NULL if timeout occurred */ qc =ata_qc_from_tag (ap, link->active_tag);if (!qc) { ap->sff_pio_task_link =NULL ; -return ; + goto out_unlock; } fsm_start:
@@ -1381,11 +1366,14 @@ fsm_start:*/ status =ata_sff_busy_wait (ap,ATA_BUSY ,5 );if (status &ATA_BUSY ) { +spin_unlock_irq (ap->lock);ata_msleep (ap,2 ); +spin_lock_irq (ap->lock); + status =ata_sff_busy_wait (ap,ATA_BUSY ,10 );if (status &ATA_BUSY ) {ata_sff_queue_pio_task (link,ATA_SHORT_PAUSE ); -return ; + goto out_unlock; } }
@@ -1402,6 +1390,8 @@ fsm_start:*/ if (poll_next) goto fsm_start; +out_unlock: +spin_unlock_irq (ap->lock); }/**
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +7 -0
@@ -25,6 +25,7 @@* **************************************************************************/ #include <linux/module.h> +#include <linux/console.h> #include "drmP.h" #include "vmwgfx_drv.h"
@@ -1142,6 +1143,12 @@ static int vmw_probe(struct pci_dev *pdev, const struct pci_device_id *ent)static int __init vmwgfx_init (void ) {int ret; + +#ifdef CONFIG_VGA_CONSOLE +if (vgacon_text_force ()) +return -EINVAL ; +#endif + ret =drm_pci_init (&driver, &vmw_pci_driver);if (ret)DRM_ERROR ("Failed initializing DRM.\n" );
drivers/infiniband/hw/cxgb3/iwch_cm.c +2 -2
@@ -150,7 +150,7 @@ static int iwch_l2t_send(struct t3cdev *tdev, struct sk_buff *skb, struct l2t_en error =l2t_send (tdev, skb, l2e);if (error <0 )kfree_skb (skb); -return error; +return error <0 ? error :0 ; }int iwch_cxgb3_ofld_send (struct t3cdev *tdev,struct sk_buff *skb)
@@ -166,7 +166,7 @@ int iwch_cxgb3_ofld_send(struct t3cdev *tdev, struct sk_buff *skb) error =cxgb3_ofld_send (tdev, skb);if (error <0 )kfree_skb (skb); -return error; +return error <0 ? error :0 ; }static void release_tid (struct t3cdev *tdev,u32 hwtid,struct sk_buff *skb)
drivers/media/dvb/frontends/tda1004x.c +9 -0
@@ -898,9 +898,18 @@ static int tda1004x_set_fe(struct dvb_frontend* fe,static int tda1004x_get_fe (struct dvb_frontend * fe,struct dvb_frontend_parameters *fe_params) {struct tda1004x_state * state = fe->demodulator_priv; +int status;dprintk ("%s\n" , __func__); + status =tda1004x_read_byte (state,TDA1004X_STATUS_CD ); +if (status ==-1 ) +return -EIO ; + +/* Only update the properties cache if device is locked */ +if (!(status &8 )) +return 0 ; +// inversion status fe_params->inversion =INVERSION_OFF ;if (tda1004x_read_byte (state,TDA1004X_CONFC1 ) &0x20 )
drivers/media/video/saa7134/saa7134-alsa.c +4 -1
@@ -1145,6 +1145,8 @@ static int alsa_device_init(struct saa7134_dev *dev)static int alsa_device_exit (struct saa7134_dev *dev) { +if (!snd_saa7134_cards[dev->nr]) +return 1 ;snd_card_free (snd_saa7134_cards[dev->nr]); snd_saa7134_cards[dev->nr] =NULL ;
@@ -1194,7 +1196,8 @@ static void saa7134_alsa_exit(void)int idx;for (idx =0 ; idx <SNDRV_CARDS ; idx++) { -snd_card_free (snd_saa7134_cards[idx]); +if (snd_saa7134_cards[idx]) +snd_card_free (snd_saa7134_cards[idx]); } saa7134_dmasound_init =NULL ;
drivers/net/ppp/pptp.c +24 -10
@@ -131,24 +131,27 @@ static int lookup_chan_dst(u16 call_id, __be32 d_addr)return i <MAX_CALLID ; } -static int add_chan (struct pppox_sock *sock) +static int add_chan (struct pppox_sock *sock, +struct pptp_addr *sa) {static int call_id;spin_lock (&chan_lock); -if (!sock->proto.pptp.src_addr.call_id) { +if (!sa->call_id) { call_id =find_next_zero_bit (callid_bitmap,MAX_CALLID , call_id +1 );if (call_id ==MAX_CALLID ) { call_id =find_next_zero_bit (callid_bitmap,MAX_CALLID ,1 );if (call_id ==MAX_CALLID ) goto out_err; } - sock->proto.pptp.src_addr.call_id = call_id; - }else if (test_bit (sock->proto.pptp.src_addr.call_id, callid_bitmap)) + sa->call_id = call_id; + }else if (test_bit (sa->call_id, callid_bitmap)) { goto out_err; + } -set_bit (sock->proto.pptp.src_addr.call_id, callid_bitmap); -rcu_assign_pointer (callid_sock[sock->proto.pptp.src_addr.call_id], sock); + sock->proto.pptp.src_addr = *sa; +set_bit (sa->call_id, callid_bitmap); +rcu_assign_pointer (callid_sock[sa->call_id], sock);spin_unlock (&chan_lock);return 0 ;
@@ -417,7 +420,6 @@ static int pptp_bind(struct socket *sock, struct sockaddr *uservaddr,struct sock *sk = sock->sk;struct sockaddr_pppox *sp = (struct sockaddr_pppox *) uservaddr;struct pppox_sock *po =pppox_sk (sk); -struct pptp_opt *opt = &po->proto.pptp;int error =0 ;if (sockaddr_len <sizeof (struct sockaddr_pppox ))
@@ -425,10 +427,22 @@ static int pptp_bind(struct socket *sock, struct sockaddr *uservaddr,lock_sock (sk); - opt->src_addr = sp->sa_addr.pptp; -if (add_chan (po)) +if (sk->sk_state &PPPOX_DEAD ) { + error = -EALREADY ; + goto out; + } + +if (sk->sk_state &PPPOX_BOUND ) { error = -EBUSY ; + goto out; + } + +if (add_chan (po, &sp->sa_addr.pptp)) + error = -EBUSY ; +else + sk->sk_state |=PPPOX_BOUND ; +out:release_sock (sk);return error; }
@@ -499,7 +513,7 @@ static int pptp_connect(struct socket *sock, struct sockaddr *uservaddr, } opt->dst_addr = sp->sa_addr.pptp; - sk->sk_state =PPPOX_CONNECTED ; + sk->sk_state |=PPPOX_CONNECTED ; end:release_sock (sk);
drivers/pci/pcie/aer/aerdrv.c +1 -3
@@ -263,7 +263,6 @@ static struct aer_rpc *aer_alloc_rpc(struct pcie_device *dev) rpc->rpd = dev;INIT_WORK (&rpc->dpc_handler, aer_isr);mutex_init (&rpc->rpc_mutex); -init_waitqueue_head (&rpc->wait_release);/* Use PCIe bus function to store rpc into PCIe device */ set_service_data (dev, rpc);
@@ -286,8 +285,7 @@ static void aer_remove(struct pcie_device *dev)if (rpc->isr)free_irq (dev->irq, dev); -wait_event (rpc->wait_release, rpc->prod_idx == rpc->cons_idx); - +flush_work (&rpc->dpc_handler);aer_disable_rootport (rpc);kfree (rpc);set_service_data (dev,NULL );
drivers/pci/pcie/aer/aerdrv.h +0 -1
@@ -76,7 +76,6 @@ struct aer_rpc {* recovery on the same * root port hierarchy */ -wait_queue_head_t wait_release; };struct aer_broadcast_data {
drivers/pci/pcie/aer/aerdrv_core.c +0 -2
@@ -823,8 +823,6 @@ void aer_isr(struct work_struct *work)while (get_e_source (rpc, &e_src))aer_isr_one_error (p_device, &e_src);mutex_unlock (&rpc->rpc_mutex); - -wake_up (&rpc->wait_release); }/**
drivers/platform/x86/intel_scu_ipcutil.c +1 -1
@@ -52,7 +52,7 @@ struct scu_ipc_data {static int scu_reg_access (u32 cmd,struct scu_ipc_data *data) { -int count = data->count; +unsigned int count = data->count;if (count ==0 || count ==3 || count >4 )return -EINVAL ;
drivers/scsi/device_handler/scsi_dh_rdac.c +3 -1
@@ -573,7 +573,7 @@ static int mode_select_handle_sense(struct scsi_device *sdev,/* * Command Lock contention */ - err =SCSI_DH_RETRY ; + err =SCSI_DH_IMM_RETRY ;break ;default :break ;
@@ -623,6 +623,8 @@ retry: err =mode_select_handle_sense (sdev, h->sense);if (err ==SCSI_DH_RETRY && retry_cnt--) goto retry; +if (err ==SCSI_DH_IMM_RETRY ) + goto retry; }if (err ==SCSI_DH_OK ) { h->state =RDAC_STATE_ACTIVE ;
drivers/scsi/sd.c +5 -2
@@ -2767,8 +2767,8 @@ static int sd_suspend(struct device *dev, pm_message_t mesg)struct scsi_disk *sdkp =scsi_disk_get_from_dev (dev);int ret =0 ; -if (!sdkp) -return 0 ;/* this can happen */ +if (!sdkp)/* E.g.: runtime suspend following sd_remove() */ +return 0 ;if (sdkp->WCE) {sd_printk (KERN_NOTICE , sdkp,"Synchronizing SCSI cache\n" );
@@ -2792,6 +2792,9 @@ static int sd_resume(struct device *dev)struct scsi_disk *sdkp =scsi_disk_get_from_dev (dev);int ret =0 ; +if (!sdkp)/* E.g.: runtime resume at the start of sd_probe() */ +return 0 ; +if (!sdkp->device->manage_start_stop) goto done;
drivers/tty/tty_io.c +23 -1
@@ -2475,6 +2475,28 @@ static int tiocsetd(struct tty_struct *tty, int __user *p) }/** +* tiocgetd - get line discipline +* @tty: tty device +* @p: pointer to user data +* +* Retrieves the line discipline id directly from the ldisc. +* +* Locking: waits for ldisc reference (in case the line discipline +* is changing or the tty is being hungup) +*/ + +static int tiocgetd (struct tty_struct *tty,int __user *p) +{ +struct tty_ldisc *ld; +int ret; + + ld =tty_ldisc_ref_wait (tty); + ret =put_user (ld->ops->num, p); +tty_ldisc_deref (ld); +return ret; +} + +/** * send_break - performed time break * @tty: device to break on * @duration: timeout in mS
@@ -2684,7 +2706,7 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)case TIOCGSID :return tiocgsid (tty, real_tty, p);case TIOCGETD : -return put_user (tty->ldisc->ops->num, (int __user *)p); +return tiocgetd (tty, p);case TIOCSETD :return tiocsetd (tty, p);case TIOCVHANGUP :
drivers/usb/class/cdc-acm.c +11 -0
@@ -1237,6 +1237,8 @@ made_compressed_probe:usb_sndbulkpipe (usb_dev, epwrite->bEndpointAddress), NULL, acm->writesize, acm_write_bulk, snd); snd->urb->transfer_flags |=URB_NO_TRANSFER_DMA_MAP ; +if (quirks &SEND_ZERO_PACKET ) + snd->urb->transfer_flags |=URB_ZERO_PACKET ; snd->instance = acm; }
@@ -1666,6 +1668,11 @@ static const struct usb_device_id acm_ids[] = { .driver_info = NO_DATA_INTERFACE, }, +/*Samsung phone in firmware update mode */ + { USB_DEVICE(0x04e8, 0x685d), + .driver_info =IGNORE_DEVICE , + }, + /* Exclude Infineon Flash Loader utility */ { USB_DEVICE(0x058b, 0x0041), .driver_info = IGNORE_DEVICE,
@@ -1689,6 +1696,10 @@ static const struct usb_device_id acm_ids[] = { { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, USB_CDC_ACM_PROTO_AT_CDMA) }, + { USB_DEVICE(0x1519, 0x0452), /* Intel 7260 modem */ + .driver_info = SEND_ZERO_PACKET, + }, + { } };
drivers/usb/class/cdc-acm.h +1 -0
@@ -129,3 +129,4 @@ struct acm {#define NO_DATA_INTERFACE 16#define IGNORE_DEVICE 32#define CLEAR_HALT_CONDITIONS BIT(7) +#define SEND_ZERO_PACKET BIT(8)
drivers/usb/host/xhci-pci.c +3 -1
@@ -39,6 +39,7 @@#define PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI 0x22b5#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI 0xa12f#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI 0x9d2f +#define PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI 0x0aa8static const char hcd_name[] ="xhci_hcd" ;
@@ -132,7 +133,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)if (pdev->vendor ==PCI_VENDOR_ID_INTEL && (pdev->device ==PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI || pdev->device ==PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI || - pdev->device ==PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI )) { + pdev->device ==PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI || + pdev->device ==PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI )) { xhci->quirks |=XHCI_PME_STUCK_QUIRK ; } if (pdev->vendor == PCI_VENDOR_ID_ETRON &&
drivers/usb/host/xhci-ring.c +0 -10
@@ -2187,10 +2187,6 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)));/* Fast path - was this the last TRB in the TD for this URB? */ if (event_trb == td->last_trb) { -if (td->urb_length_set && trb_comp_code ==COMP_SHORT_TX ) -return finish_td (xhci, td, event_trb, event, ep, - status, false); -if (EVENT_TRB_LEN (le32_to_cpu (event->transfer_len)) !=0 ) { td->urb->actual_length = td->urb->transfer_buffer_length -
@@ -2242,12 +2238,6 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, td->urb->actual_length +=TRB_LEN (le32_to_cpu (cur_trb->generic.field[2 ])) -EVENT_TRB_LEN (le32_to_cpu (event->transfer_len)); - -if (trb_comp_code ==COMP_SHORT_TX ) { -xhci_dbg (xhci,"mid bulk/intr SP, wait for last TRB event\n" ); - td->urb_length_set = true; -return 0 ; - } }return finish_td (xhci, td, event_trb, event, ep, status, false);
drivers/usb/host/xhci.c +3 -1
@@ -1533,7 +1533,9 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)if (temp ==0xffffffff || (xhci->xhc_state &XHCI_STATE_HALTED )) {xhci_dbg (xhci,"HW died, freeing TD.\n" ); urb_priv = urb->hcpriv; -for (i = urb_priv->td_cnt; i < urb_priv->length; i++) { +for (i = urb_priv->td_cnt; + i < urb_priv->length && xhci->devs[urb->dev->slot_id]; + i++) { td = urb_priv->td[i];if (!list_empty (&td->td_list))list_del_init (&td->td_list);
drivers/usb/serial/cp210x.c +1 -0
@@ -104,6 +104,7 @@ static const struct usb_device_id id_table[] = { { USB_DEVICE(0x10C4, 0x81AC) }, /* MSD Dash Hawk */ { USB_DEVICE(0x10C4, 0x81AD) }, /* INSYS USB Modem */ { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */ + { USB_DEVICE(0x10C4, 0x81D7) }, /* IAI Corp. RCB-CV-USB USB to RS485 Adaptor */ { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */ { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */ { USB_DEVICE(0x10C4, 0x81E8) }, /* Zephyr Bioharness */
drivers/usb/serial/ftdi_sio.c +1 -0
@@ -848,6 +848,7 @@ static struct usb_device_id id_table_combined [] = { { USB_DEVICE(FTDI_VID, FTDI_TURTELIZER_PID), .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) }, + { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_SCU18) }, { USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) },/* Papouch devices based on FTDI chip */
drivers/usb/serial/ftdi_sio_ids.h +1 -0
@@ -615,6 +615,7 @@*/ #define RATOC_VENDOR_ID 0x0584#define RATOC_PRODUCT_ID_USB60F 0xb020 +#define RATOC_PRODUCT_ID_SCU18 0xb03a/* * Acton Research Corp.
drivers/usb/serial/option.c +16 -0
@@ -269,6 +269,8 @@ static void option_instat_callback(struct urb *urb);#define TELIT_PRODUCT_CC864_SINGLE 0x1006#define TELIT_PRODUCT_DE910_DUAL 0x1010#define TELIT_PRODUCT_UE910_V2 0x1012 +#define TELIT_PRODUCT_LE922_USBCFG0 0x1042 +#define TELIT_PRODUCT_LE922_USBCFG3 0x1043#define TELIT_PRODUCT_LE920 0x1200#define TELIT_PRODUCT_LE910 0x1201
@@ -621,6 +623,16 @@ static const struct option_blacklist_info telit_le920_blacklist = { .reserved = BIT(1) | BIT(5), }; +static const struct option_blacklist_info telit_le922_blacklist_usbcfg0 = { + .sendsetup =BIT (2 ), + .reserved =BIT (0 ) |BIT (1 ) |BIT (3 ), +}; + +static const struct option_blacklist_info telit_le922_blacklist_usbcfg3 = { + .sendsetup =BIT (0 ), + .reserved =BIT (1 ) |BIT (2 ) |BIT (3 ), +}; +static const struct usb_device_id option_ids[] = { {USB_DEVICE (OPTION_VENDOR_ID ,OPTION_PRODUCT_COLT ) }, {USB_DEVICE (OPTION_VENDOR_ID ,OPTION_PRODUCT_RICOLA ) },
@@ -1166,6 +1178,10 @@ static const struct usb_device_id option_ids[] = { { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_CC864_SINGLE) }, { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_DE910_DUAL) }, { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UE910_V2) }, + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG0), + .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg0 }, + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG3), + .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg3 }, { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910), .driver_info = (kernel_ulong_t)&telit_le910_blacklist }, { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920),
drivers/usb/serial/visor.c +9 -2
@@ -587,6 +587,11 @@ static int treo_attach(struct usb_serial *serial)dbg ("%s" , __func__); +if (serial->num_bulk_in <2 || serial->num_interrupt_in <2 ) { +dev_err (&serial->interface->dev,"missing endpoints\n" ); +return -ENODEV ; + } +/* * It appears that Treos and Kyoceras want to use the * 1st bulk in endpoint to communicate with the 2nd bulk out endpoint,
@@ -635,8 +640,10 @@ static int clie_5_attach(struct usb_serial *serial)*/ /* some sanity check */ -if (serial->num_ports <2 ) -return -1 ; +if (serial->num_bulk_out <2 ) { +dev_err (&serial->interface->dev,"missing bulk out endpoints\n" ); +return -ENODEV ; + }/* port 0 now uses the modified endpoint Address */ port = serial->port[0 ];
drivers/virtio/virtio_pci.c +2 -0
@@ -698,6 +698,7 @@ out: static void __devexit virtio_pci_remove(struct pci_dev *pci_dev) {struct virtio_pci_device *vp_dev =pci_get_drvdata (pci_dev); +struct device *dev =get_device (&vp_dev->vdev.dev);unregister_virtio_device (&vp_dev->vdev);
@@ -706,6 +707,7 @@ static void __devexit virtio_pci_remove(struct pci_dev *pci_dev)pci_iounmap (pci_dev, vp_dev->ioaddr);pci_release_regions (pci_dev);pci_disable_device (pci_dev); +put_device (dev); }#ifdef CONFIG_PM
fs/btrfs/delayed-inode.c +2 -1
@@ -1593,7 +1593,7 @@ int btrfs_should_delete_dir_index(struct list_head *del_list,*/ int btrfs_readdir_delayed_dir_index (struct file *filp,void *dirent,filldir_t filldir, -struct list_head *ins_list) +struct list_head *ins_list,bool *emitted) {struct btrfs_dir_item *di;struct btrfs_delayed_item *curr, *next;
@@ -1637,6 +1637,7 @@ int btrfs_readdir_delayed_dir_index(struct file *filp, void *dirent,if (over)return 1 ; + *emitted = true; }return 0 ; }
fs/btrfs/delayed-inode.h +1 -1
@@ -133,7 +133,7 @@ int btrfs_should_delete_dir_index(struct list_head *del_list, u64 index);int btrfs_readdir_delayed_dir_index (struct file *filp,void *dirent,filldir_t filldir, -struct list_head *ins_list); +struct list_head *ins_list,bool *emitted);/* for init */ int __init btrfs_delayed_inode_init (void );
fs/btrfs/inode.c +13 -1
@@ -4111,6 +4111,7 @@ static int btrfs_real_readdir(struct file *filp, void *dirent,char *name_ptr;int name_len;int is_curr =0 ;/* filp->f_pos points to the current index? */ +bool emitted;/* FIXME, use a real flag for deciding about the key type */ if (root->fs_info->tree_root == root)
@@ -4153,6 +4154,7 @@ static int btrfs_real_readdir(struct file *filp, void *dirent,if (ret <0 ) goto err; + emitted = false;while (1 ) { leaf = path->nodes[0 ]; slot = path->slots[0 ];
@@ -4254,6 +4256,7 @@ skip:if (over) goto nopos; + emitted = true; di_len =btrfs_dir_name_len (leaf, di) +btrfs_dir_data_len (leaf, di) +sizeof (*di); di_cur += di_len;
@@ -4267,11 +4270,20 @@ next:if (is_curr) filp->f_pos++; ret =btrfs_readdir_delayed_dir_index (filp, dirent, filldir, - &ins_list); + &ins_list, &emitted);if (ret) goto nopos; } +/* +* If we haven't emitted any dir entry, we must not touch filp->f_pos as +* it was was set to the termination value in previous call. We assume +* that "." and ".." were emitted if we reach this point and set the +* termination value as well for an empty directory. +*/ +if (filp->f_pos >2 && !emitted) + goto nopos; +/* Reached end of directory/root. Bump pos past the last item. */ if (key_type ==BTRFS_DIR_INDEX_KEY )/*
fs/ocfs2/dlm/dlmrecovery.c +2 -0
@@ -2333,6 +2333,8 @@ static void dlm_do_local_recovery_cleanup(struct dlm_ctxt *dlm, u8 dead_node)break ; } } +dlm_lockres_clear_refmap_bit (dlm, res, + dead_node);spin_unlock (&res->spinlock);continue ; }
fs/pipe.c +49 -3
114 lines not on this page · raw message
fs/timerfd.c +1 -1
@@ -123,7 +123,7 @@ static ktime_t timerfd_get_remaining(struct timerfd_ctx *ctx) {ktime_t remaining; - remaining =hrtimer_expires_remaining (&ctx->tmr); + remaining =hrtimer_expires_remaining_adjusted (&ctx->tmr);return remaining.tv64 <0 ?ktime_set (0 ,0 ): remaining; }
include/linux/hrtimer.h +32 -2
@@ -96,6 +96,7 @@ enum hrtimer_restart {* @function: timer expiry callback function * @base: pointer to the timer base (per cpu and per clock) * @state: state information (See bit values above) +* @is_rel: Set if the timer was armed relative * @start_site: timer statistics field to store the site where the timer * was started * @start_comm: timer statistics field to store the name of the process which
@@ -110,7 +111,8 @@ struct hrtimer {ktime_t _softexpires;enum hrtimer_restart (*function)(struct hrtimer *);struct hrtimer_clock_base *base; -unsigned long state; +u8 state; +u8 is_rel;#ifdef CONFIG_TIMER_STATS int start_pid;void *start_site;
@@ -315,6 +317,29 @@ static inline void clock_was_set_delayed(void) { }#endif +static inline ktime_t +__hrtimer_expires_remaining_adjusted (const struct hrtimer *timer,ktime_t now) +{ +ktime_t rem =ktime_sub (timer->node.expires, now); + +/* +* Adjust relative timers for the extra we added in +* hrtimer_start_range_ns() to prevent short timeouts. +*/ +#ifdef CONFIG_TIME_LOW_RES +if (timer->is_rel) + rem =ktime_sub (rem,KTIME_LOW_RES ); +#endif +return rem; +} + +static inline ktime_t +hrtimer_expires_remaining_adjusted (const struct hrtimer *timer) +{ +return __hrtimer_expires_remaining_adjusted (timer, + timer->base->get_time ()); +} +extern void clock_was_set (void );#ifdef CONFIG_TIMERFD extern void timerfd_clock_was_set (void );
@@ -383,7 +408,12 @@ static inline int hrtimer_restart(struct hrtimer *timer) }/* Query timers: */ -extern ktime_t hrtimer_get_remaining (const struct hrtimer *timer); +extern ktime_t __hrtimer_get_remaining (const struct hrtimer *timer,bool adjust); + +static inline ktime_t hrtimer_get_remaining (const struct hrtimer *timer) +{ +return __hrtimer_get_remaining (timer, false); +}extern int hrtimer_get_res (const clockid_t which_clock,struct timespec *tp);extern ktime_t hrtimer_get_next_event (void );
include/linux/pipe_fs_i.h +4 -0
@@ -43,6 +43,7 @@ struct pipe_buffer {* @fasync_writers: writer side fasync * @inode: inode this pipe is attached to * @bufs: the circular array of pipe buffers +* @user: the user who created this pipe **/ struct pipe_inode_info {wait_queue_head_t wait;
@@ -57,6 +58,7 @@ struct pipe_inode_info {struct fasync_struct *fasync_writers;struct inode *inode;struct pipe_buffer *bufs; +struct user_struct *user; };/*
@@ -142,6 +144,8 @@ void pipe_unlock(struct pipe_inode_info *);void pipe_double_lock (struct pipe_inode_info *,struct pipe_inode_info *);extern unsigned int pipe_max_size, pipe_min_size; +extern unsigned long pipe_user_pages_hard; +extern unsigned long pipe_user_pages_soft;int pipe_proc_fn (struct ctl_table *,int ,void __user *,size_t *,loff_t *);
include/linux/sched.h +2 -0
@@ -709,6 +709,8 @@ struct user_struct {unsigned long mq_bytes;/* How many bytes can be allocated to mqueue? */ #endif unsigned long locked_shm;/* How many pages of mlocked shm ? */ +unsigned long unix_inflight;/* How many files in flight in unix sockets */ +atomic_long_t pipe_bufs;/* how many pages are allocated in pipe buffers */ #ifdef CONFIG_KEYS struct key *uid_keyring;/* UID specific keyring */
include/net/af_unix.h +2 -2
@@ -6,8 +6,8 @@#include <linux/mutex.h> #include <net/sock.h> -extern void unix_inflight (struct file *fp); -extern void unix_notinflight (struct file *fp); +extern void unix_inflight (struct user_struct *user,struct file *fp); +extern void unix_notinflight (struct user_struct *user,struct file *fp);extern void unix_gc (void );extern void wait_for_unix_gc (void );extern struct sock *unix_get_socket (struct file *filp);
include/net/scm.h +1 -0
@@ -16,6 +16,7 @@ struct scm_fp_list {struct list_head list;short count;short max; +struct user_struct *user;struct file *fp[SCM_MAX_FD ]; };
include/sound/rawmidi.h +4 -0
@@ -167,6 +167,10 @@ int snd_rawmidi_transmit_peek(struct snd_rawmidi_substream *substream,int snd_rawmidi_transmit_ack (struct snd_rawmidi_substream *substream,int count);int snd_rawmidi_transmit (struct snd_rawmidi_substream *substream,unsigned char *buffer,int count); +int __snd_rawmidi_transmit_peek (struct snd_rawmidi_substream *substream, +unsigned char *buffer,int count); +int __snd_rawmidi_transmit_ack (struct snd_rawmidi_substream *substream, +int count);/* main midi functions */
kernel/hrtimer.c +39 -17
103 lines not on this page · raw message
kernel/itimer.c +1 -1
@@ -26,7 +26,7 @@*/ static struct timeval itimer_get_remtime (struct hrtimer *timer) { -ktime_t rem =hrtimer_get_remaining (timer); +ktime_t rem =__hrtimer_get_remaining (timer, true);/* * Racy but safe: if the itimer expires after the above
kernel/posix-timers.c +1 -1
@@ -706,7 +706,7 @@ common_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting) (timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE)) timr->it_overrun += (unsigned int) hrtimer_forward(timer, now, iv); - remaining =ktime_sub (hrtimer_get_expires (timer), now); + remaining =__hrtimer_expires_remaining_adjusted (timer, now);/* Return 0 only, when the timer is expired and not pending */ if (remaining.tv64 <=0 ) {/*
kernel/sched_fair.c +9 -0
@@ -2791,6 +2791,7 @@ int can_migrate_task(struct task_struct *p, struct rq *rq, int this_cpu,* 1) running (obviously), or * 2) cannot be migrated to this CPU due to cpus_allowed, or * 3) are cache-hot on their current CPU. +* 4) p->pi_lock is held. */ if (!cpumask_test_cpu (this_cpu,tsk_cpus_allowed (p))) {schedstat_inc (p, se.statistics.nr_failed_migrations_affine);
@@ -2804,6 +2805,14 @@ int can_migrate_task(struct task_struct *p, struct rq *rq, int this_cpu, }/* +* rt -> fair class change may be in progress. If we sneak in should +* double_lock_balance() release rq->lock, and move the task, we will +* cause switched_to_fair() to meet a passed but no longer valid rq. +*/ +if (raw_spin_is_locked (&p->pi_lock)) +return 0 ; + +/* * Aggressive migration if: * 1) task is cache cold, or * 2) too many balance attempts have failed.
kernel/sysctl.c +14 -0
@@ -1518,6 +1518,20 @@ static struct ctl_table fs_table[] = { .proc_handler = &pipe_proc_fn, .extra1 = &pipe_min_size, }, + { + .procname = "pipe-user-pages-hard", + .data = &pipe_user_pages_hard, + .maxlen = sizeof(pipe_user_pages_hard), + .mode = 0644, + .proc_handler = proc_doulongvec_minmax, + }, + { + .procname = "pipe-user-pages-soft", + .data = &pipe_user_pages_soft, + .maxlen = sizeof(pipe_user_pages_soft), + .mode = 0644, + .proc_handler = proc_doulongvec_minmax, + }, { } };
kernel/time/timer_list.c +1 -1
@@ -57,7 +57,7 @@ print_timer(struct seq_file *m, struct hrtimer *taddr, struct hrtimer *timer,print_name_offset (m, taddr);SEQ_printf (m,", " );print_name_offset (m, timer->function); -SEQ_printf (m,", S:%02lx" , timer->state); +SEQ_printf (m,", S:%02x" , timer->state);#ifdef CONFIG_TIMER_STATS SEQ_printf (m,", " );print_name_offset (m, timer->start_site);
lib/klist.c +3 -3
@@ -282,9 +282,9 @@ void klist_iter_init_node(struct klist *k, struct klist_iter *i, struct klist_node *n) { i->i_klist = k; - i->i_cur = n; -if (n) -kref_get (&n->n_ref); + i->i_cur =NULL ; +if (n &&kref_get_unless_zero (&n->n_ref)) + i->i_cur = n; }EXPORT_SYMBOL_GPL (klist_iter_init_node);
mm/backing-dev.c +1 -1
@@ -879,7 +879,7 @@ long wait_iff_congested(struct zone *zone, int sync, long timeout)* here rather than calling cond_resched(). */ if (current->flags &PF_WQ_WORKER ) -schedule_timeout (1 ); +schedule_timeout_uninterruptible (1 );else cond_resched ();
net/core/scm.c +7 -0
@@ -80,6 +80,7 @@ static int scm_fp_copy(struct cmsghdr *cmsg, struct scm_fp_list **fplp) *fplp = fpl; fpl->count =0 ; fpl->max =SCM_MAX_FD ; + fpl->user =NULL ; } fpp = &fpl->fp[fpl->count];
@@ -100,6 +101,10 @@ static int scm_fp_copy(struct cmsghdr *cmsg, struct scm_fp_list **fplp) *fpp++ = file; fpl->count++; } + +if (!fpl->user) + fpl->user =get_uid (current_user ()); +return num; }
@@ -124,6 +129,7 @@ void __scm_destroy(struct scm_cookie *scm)list_del (&fpl->list);for (i=fpl->count-1 ; i>=0 ; i--)fput (fpl->fp[i]); +free_uid (fpl->user);kfree (fpl); }
@@ -342,6 +348,7 @@ struct scm_fp_list *scm_fp_dup(struct scm_fp_list *fpl)for (i =0 ; i < fpl->count; i++)get_file (fpl->fp[i]); new_fpl->max = new_fpl->count; + new_fpl->user =get_uid (fpl->user); }return new_fpl; }
net/rfkill/core.c +4 -12
@@ -1065,17 +1065,6 @@ static unsigned int rfkill_fop_poll(struct file *file, poll_table *wait)return res; } -static bool rfkill_readable (struct rfkill_data *data) -{ -bool r; - -mutex_lock (&data->mtx); - r = !list_empty (&data->events); -mutex_unlock (&data->mtx); - -return r; -} -static ssize_t rfkill_fop_read (struct file *file,char __user *buf,size_t count,loff_t *pos) {
@@ -1092,8 +1081,11 @@ static ssize_t rfkill_fop_read(struct file *file, char __user *buf, goto out; }mutex_unlock (&data->mtx); +/* since we re-check and it just compares pointers, +* using !list_empty() without locking isn't a problem +*/ ret =wait_event_interruptible (data->read_wait, -rfkill_readable (data)); + !list_empty (&data->events));mutex_lock (&data->mtx);if (ret)
net/sctp/socket.c +8 -2
@@ -5309,6 +5309,7 @@ static int sctp_getsockopt_hmac_ident(struct sock *sk, int len,struct sctp_hmac_algo_param *hmacs;__u16 data_len =0 ;u32 num_idents; +int i;if (!sctp_auth_enable)return -EACCES ;
@@ -5326,8 +5327,12 @@ static int sctp_getsockopt_hmac_ident(struct sock *sk, int len,return -EFAULT ;if (put_user (num_idents, &p->shmac_num_idents))return -EFAULT ; -if (copy_to_user (p->shmac_idents, hmacs->hmac_ids, data_len)) -return -EFAULT ; +for (i =0 ; i < num_idents; i++) { +__u16 hmacid =ntohs (hmacs->hmac_ids[i]); + +if (copy_to_user (&p->shmac_idents[i], &hmacid,sizeof (__u16))) +return -EFAULT ; + }return 0 ; }
@@ -6241,6 +6246,7 @@ SCTP_STATIC int sctp_msghdr_parse(const struct msghdr *msg,/* Minimally, validate the sinfo_flags. */ if (cmsgs->info->sinfo_flags & ~(SCTP_UNORDERED |SCTP_ADDR_OVER | +SCTP_SACK_IMMEDIATELY |SCTP_ABORT |SCTP_EOF ))return -EINVAL ;break ;
net/unix/af_unix.c +22 -5
@@ -1454,7 +1454,7 @@ static void unix_detach_fds(struct scm_cookie *scm, struct sk_buff *skb)UNIXCB (skb).fp =NULL ;for (i = scm->fp->count-1 ; i >=0 ; i--) -unix_notinflight (scm->fp->fp[i]); +unix_notinflight (scm->fp->user, scm->fp->fp[i]); }static void unix_destruct_scm (struct sk_buff *skb)
@@ -1472,6 +1472,21 @@ static void unix_destruct_scm(struct sk_buff *skb)sock_wfree (skb); } +/* +* The "user->unix_inflight" variable is protected by the garbage +* collection lock, and we just read it locklessly here. If you go +* over the limit, there might be a tiny race in actually noticing +* it across threads. Tough. +*/ +static inline bool too_many_unix_fds (struct task_struct *p) +{ +struct user_struct *user =current_user (); + +if (unlikely (user->unix_inflight >task_rlimit (p,RLIMIT_NOFILE ))) +return !capable (CAP_SYS_RESOURCE ) && !capable (CAP_SYS_ADMIN ); +return false; +} +#define MAX_RECURSION_LEVEL 4static int unix_attach_fds (struct scm_cookie *scm,struct sk_buff *skb)
@@ -1480,6 +1495,9 @@ static int unix_attach_fds(struct scm_cookie *scm, struct sk_buff *skb)unsigned char max_level =0 ;int unix_sock_count =0 ; +if (too_many_unix_fds (current)) +return -ETOOMANYREFS ; +for (i = scm->fp->count -1 ; i >=0 ; i--) {struct sock *sk =unix_get_socket (scm->fp->fp[i]);
@@ -1501,10 +1519,8 @@ static int unix_attach_fds(struct scm_cookie *scm, struct sk_buff *skb)if (!UNIXCB (skb).fp)return -ENOMEM ; -if (unix_sock_count) { -for (i = scm->fp->count -1 ; i >=0 ; i--) -unix_inflight (scm->fp->fp[i]); - } +for (i = scm->fp->count -1 ; i >=0 ; i--) +unix_inflight (scm->fp->user, scm->fp->fp[i]);return max_level; }
@@ -2100,6 +2116,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,if (signal_pending (current)) { err =sock_intr_errno (timeo); +scm_destroy (siocb->scm); goto out; }
net/unix/garbage.c +12 -6
@@ -122,12 +122,14 @@ struct sock *unix_get_socket(struct file *filp)* descriptor if it is for an AF_UNIX socket. */ -void unix_inflight (struct file *fp) +void unix_inflight (struct user_struct *user,struct file *fp) {struct sock *s =unix_get_socket (fp); + +spin_lock (&unix_gc_lock); +if (s) {struct unix_sock *u =unix_sk (s); -spin_lock (&unix_gc_lock);if (atomic_long_inc_return (&u->inflight) ==1 ) {BUG_ON (!list_empty (&u->link));list_add_tail (&u->link, &gc_inflight_list);
@@ -135,22 +137,26 @@ void unix_inflight(struct file *fp)BUG_ON (list_empty (&u->link)); } unix_tot_inflight++; -spin_unlock (&unix_gc_lock); } + user->unix_inflight++; +spin_unlock (&unix_gc_lock); } -void unix_notinflight (struct file *fp) +void unix_notinflight (struct user_struct *user,struct file *fp) {struct sock *s =unix_get_socket (fp); + +spin_lock (&unix_gc_lock); +if (s) {struct unix_sock *u =unix_sk (s); -spin_lock (&unix_gc_lock);BUG_ON (list_empty (&u->link));if (atomic_long_dec_and_test (&u->inflight))list_del_init (&u->link); unix_tot_inflight--; -spin_unlock (&unix_gc_lock); } + user->unix_inflight--; +spin_unlock (&unix_gc_lock); } static void scan_inflight(struct sock *x, void (*func)(struct unix_sock *),
sound/core/oss/pcm_oss.c +15 -6
@@ -834,7 +834,8 @@ static int choose_rate(struct snd_pcm_substream *substream,return snd_pcm_hw_param_near (substream, params,SNDRV_PCM_HW_PARAM_RATE , best_rate,NULL ); } -static int snd_pcm_oss_change_params (struct snd_pcm_substream *substream) +static int snd_pcm_oss_change_params (struct snd_pcm_substream *substream, +bool trylock) {struct snd_pcm_runtime *runtime = substream->runtime;struct snd_pcm_hw_params *params, *sparams;
@@ -848,7 +849,10 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)struct snd_mask sformat_mask;struct snd_mask mask; -if (mutex_lock_interruptible (&runtime->oss.params_lock)) +if (trylock) { +if (!(mutex_trylock (&runtime->oss.params_lock))) +return -EAGAIN ; + }else if (mutex_lock_interruptible (&runtime->oss.params_lock))return -EINTR ; sw_params =kmalloc (sizeof (*sw_params),GFP_KERNEL ); params =kmalloc (sizeof (*params),GFP_KERNEL );
@@ -1091,7 +1095,7 @@ static int snd_pcm_oss_get_active_substream(struct snd_pcm_oss_file *pcm_oss_filif (asubstream ==NULL ) asubstream = substream;if (substream->runtime->oss.params) { - err =snd_pcm_oss_change_params (substream); + err =snd_pcm_oss_change_params (substream, false);if (err <0 )return err; }
@@ -1130,7 +1134,7 @@ static int snd_pcm_oss_make_ready(struct snd_pcm_substream *substream)return 0 ; runtime = substream->runtime;if (runtime->oss.params) { - err =snd_pcm_oss_change_params (substream); + err =snd_pcm_oss_change_params (substream, false);if (err <0 )return err; }
@@ -2168,7 +2172,7 @@ static int snd_pcm_oss_get_space(struct snd_pcm_oss_file *pcm_oss_file, int stre runtime = substream->runtime;if (runtime->oss.params && - (err =snd_pcm_oss_change_params (substream)) <0 ) + (err =snd_pcm_oss_change_params (substream, false)) <0 )return err; info.fragsize = runtime->oss.period_bytes;
@@ -2804,7 +2808,12 @@ static int snd_pcm_oss_mmap(struct file *file, struct vm_area_struct *area)return -EIO ;if (runtime->oss.params) { -if ((err =snd_pcm_oss_change_params (substream)) <0 ) +/* use mutex_trylock() for params_lock for avoiding a deadlock +* between mmap_sem and params_lock taken by +* copy_from/to_user() in snd_pcm_oss_write/read() +*/ + err =snd_pcm_oss_change_params (substream, true); +if (err <0 )return err; }#ifdef CONFIG_SND_PCM_OSS_PLUGINS
sound/core/rawmidi.c +95 -39
237 lines not on this page · raw message
sound/core/seq/oss/seq_oss_init.c +1 -1
@@ -196,7 +196,7 @@ snd_seq_oss_open(struct file *file, int level) dp->index = i;if (i >=SNDRV_SEQ_OSS_MAX_CLIENTS ) { -snd_printk (KERN_ERR "too many applications\n" ); +pr_debug ("ALSA: seq_oss: too many applications\n" ); rc = -ENOMEM ; goto _error; }
sound/core/seq/oss/seq_oss_synth.c +1 -1
@@ -310,7 +310,7 @@ snd_seq_oss_synth_cleanup(struct seq_oss_devinfo *dp)struct seq_oss_synth *rec;struct seq_oss_synthinfo *info; -if (snd_BUG_ON (dp->max_synthdev >=SNDRV_SEQ_OSS_MAX_SYNTH_DEVS )) +if (snd_BUG_ON (dp->max_synthdev >SNDRV_SEQ_OSS_MAX_SYNTH_DEVS ))return ;for (i =0 ; i < dp->max_synthdev; i++) { info = &dp->synths[i];
sound/core/seq/seq_clientmgr.c +3 -0
@@ -678,6 +678,9 @@ static int deliver_to_subscribers(struct snd_seq_client *client,else down_read (&grp->list_mutex);list_for_each_entry (subs, &grp->list_head, src_list) { +/* both ports ready? */ +if (atomic_read (&subs->ref_count) !=2 ) +continue ; event->dest = subs->info.dest;if (subs->info.flags &SNDRV_SEQ_PORT_SUBS_TIMESTAMP )/* convert time according to flag with subscription */
sound/core/seq/seq_ports.c +130 -103
319 lines not on this page · raw message
sound/core/seq/seq_timer.c +67 -20
187 lines not on this page · raw message
sound/core/seq/seq_virmidi.c +17 -6
@@ -155,21 +155,26 @@ static void snd_virmidi_output_trigger(struct snd_rawmidi_substream *substream,struct snd_virmidi *vmidi = substream->runtime->private_data;int count, res;unsigned char buf[32 ], *pbuf; +unsigned long flags;if (up) { vmidi->trigger =1 ;if (vmidi->seq_mode ==SNDRV_VIRMIDI_SEQ_DISPATCH && !(vmidi->rdev->flags &SNDRV_VIRMIDI_SUBSCRIBE )) { -snd_rawmidi_transmit_ack (substream, substream->runtime->buffer_size - substream->runtime->avail); -return ;/* ignored */ +while (snd_rawmidi_transmit (substream, buf, +sizeof (buf)) >0 ) { +/* ignored */ + } +return ; }if (vmidi->event.type !=SNDRV_SEQ_EVENT_NONE ) {if (snd_seq_kernel_client_dispatch (vmidi->client, &vmidi->event,in_atomic (),0 ) <0 )return ; vmidi->event.type =SNDRV_SEQ_EVENT_NONE ; } +spin_lock_irqsave (&substream->runtime->lock, flags);while (1 ) { - count =snd_rawmidi_transmit_peek (substream, buf,sizeof (buf)); + count =__snd_rawmidi_transmit_peek (substream, buf,sizeof (buf));if (count <=0 )break ; pbuf = buf;
@@ -179,16 +184,18 @@ static void snd_virmidi_output_trigger(struct snd_rawmidi_substream *substream,snd_midi_event_reset_encode (vmidi->parser);continue ; } -snd_rawmidi_transmit_ack (substream, res); +__snd_rawmidi_transmit_ack (substream, res); pbuf += res; count -= res;if (vmidi->event.type !=SNDRV_SEQ_EVENT_NONE ) {if (snd_seq_kernel_client_dispatch (vmidi->client, &vmidi->event,in_atomic (),0 ) <0 ) -return ; + goto out; vmidi->event.type =SNDRV_SEQ_EVENT_NONE ; } } } + out: +spin_unlock_irqrestore (&substream->runtime->lock, flags); }else { vmidi->trigger =0 ; }
@@ -254,9 +261,13 @@ static int snd_virmidi_output_open(struct snd_rawmidi_substream *substream)*/ static int snd_virmidi_input_close (struct snd_rawmidi_substream *substream) { +struct snd_virmidi_dev *rdev = substream->rmidi->private_data;struct snd_virmidi *vmidi = substream->runtime->private_data; -snd_midi_event_free (vmidi->parser); + +write_lock_irq (&rdev->filelist_lock);list_del (&vmidi->list); +write_unlock_irq (&rdev->filelist_lock); +snd_midi_event_free (vmidi->parser); substream->runtime->private_data =NULL ;kfree (vmidi);return 0 ;
sound/core/timer.c +49 -23
164 lines not on this page · raw message
sound/drivers/dummy.c +18 -17
@@ -109,6 +109,9 @@ struct dummy_timer_ops {snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *); }; +#define get_dummy_ops (substream) \ + (*(const struct dummy_timer_ops **)(substream)->runtime->private_data) +struct dummy_model {const char *name;int (*playback_constraints)(struct snd_pcm_runtime *runtime);
@@ -134,7 +137,6 @@ struct snd_dummy {spinlock_t mixer_lock;int mixer_volume[MIXER_ADDR_LAST +1 ][2 ];int capture_source[MIXER_ADDR_LAST +1 ][2 ]; -const struct dummy_timer_ops *timer_ops; };/*
@@ -228,6 +230,8 @@ struct dummy_model *dummy_models[] = {*/ struct dummy_systimer_pcm { +/* ops must be the first item */ +const struct dummy_timer_ops *timer_ops;spinlock_t lock;struct timer_list timer;unsigned long base_time;
@@ -365,6 +369,8 @@ static struct dummy_timer_ops dummy_systimer_ops = {*/ struct dummy_hrtimer_pcm { +/* ops must be the first item */ +const struct dummy_timer_ops *timer_ops;ktime_t base_time;ktime_t period_time;atomic_t running;
@@ -491,31 +497,25 @@ static struct dummy_timer_ops dummy_hrtimer_ops = {static int dummy_pcm_trigger (struct snd_pcm_substream *substream,int cmd) { -struct snd_dummy *dummy =snd_pcm_substream_chip (substream); -switch (cmd) {case SNDRV_PCM_TRIGGER_START :case SNDRV_PCM_TRIGGER_RESUME : -return dummy->timer_ops->start (substream); +return get_dummy_ops (substream)->start (substream);case SNDRV_PCM_TRIGGER_STOP :case SNDRV_PCM_TRIGGER_SUSPEND : -return dummy->timer_ops->stop (substream); +return get_dummy_ops (substream)->stop (substream); }return -EINVAL ; }static int dummy_pcm_prepare (struct snd_pcm_substream *substream) { -struct snd_dummy *dummy =snd_pcm_substream_chip (substream); - -return dummy->timer_ops->prepare (substream); +return get_dummy_ops (substream)->prepare (substream); }static snd_pcm_uframes_t dummy_pcm_pointer (struct snd_pcm_substream *substream) { -struct snd_dummy *dummy =snd_pcm_substream_chip (substream); - -return dummy->timer_ops->pointer (substream); +return get_dummy_ops (substream)->pointer (substream); }static struct snd_pcm_hardware dummy_pcm_hardware = {
@@ -561,17 +561,19 @@ static int dummy_pcm_open(struct snd_pcm_substream *substream)struct snd_dummy *dummy =snd_pcm_substream_chip (substream);struct dummy_model *model = dummy->model;struct snd_pcm_runtime *runtime = substream->runtime; +const struct dummy_timer_ops *ops;int err; - dummy->timer_ops = &dummy_systimer_ops; + ops = &dummy_systimer_ops;#ifdef CONFIG_HIGH_RES_TIMERS if (hrtimer) - dummy->timer_ops = &dummy_hrtimer_ops; + ops = &dummy_hrtimer_ops;#endif - err = dummy->timer_ops->create (substream); + err = ops->create (substream);if (err <0 )return err; +get_dummy_ops (substream) = ops; runtime->hw = dummy->pcm_hw;if (substream->pcm->device &1 ) {
@@ -593,7 +595,7 @@ static int dummy_pcm_open(struct snd_pcm_substream *substream) err = model->capture_constraints (substream->runtime); }if (err <0 ) { - dummy->timer_ops->free (substream); +get_dummy_ops (substream)->free (substream);return err; }return 0 ;
@@ -601,8 +603,7 @@ static int dummy_pcm_open(struct snd_pcm_substream *substream)static int dummy_pcm_close (struct snd_pcm_substream *substream) { -struct snd_dummy *dummy =snd_pcm_substream_chip (substream); - dummy->timer_ops->free (substream); +get_dummy_ops (substream)->free (substream);return 0 ; }
sound/usb/midi.c +0 -1
@@ -2289,7 +2289,6 @@ int snd_usbmidi_create(struct snd_card *card,else err =snd_usbmidi_create_endpoints (umidi, endpoints);if (err <0 ) { -snd_usbmidi_free (umidi);return err; }
tools/perf/util/ui/browsers/annotate.c +2 -2
@@ -276,11 +276,11 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx, nd = self->curr_hot;break ;case K_UNTAB : -if (nd !=NULL ) +if (nd !=NULL ) { nd =rb_next (nd);if (nd ==NULL ) nd =rb_first (&self->entries); -else + }else nd = self->curr_hot;break ;case 'H' :
Quoted 8 lines · Ben Hutchings
This is the start of the stable review cycle for the 3.2.78 release. There are 67 patches in this series, which will be posted as responses to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri Feb 25 00:00:00 UTC 2016. Anything received after that time might be too late.
Build results:
total: 93 pass: 93 fail: 0 Qemu test results: total: 58 pass: 58 fail: 0
Details are available at http://kerneltests.org/builders.
Guenter
Quoted 12 lines · Guenter Roeck
Quoted 11 lines · Ben Hutchings
This is the start of the stable review cycle for the 3.2.78 release.
There are 67 patches in this series, which will be posted as responses
to this one. If anyone has any issues with these being applied, please
let me know.Responses should be made by Fri Feb 25 00:00:00 UTC 2016. Anything received after that time might be too late.
Quoted 6 lines
Build results:
total: 93 pass: 93 fail: 0 Qemu test results: total: 58 pass: 58 fail: 0Details are available at http://kerneltests.org/builders.
Thanks for checking.
Ben.
Signature · 2 lines
Ben Hutchings Beware of programmers who carry screwdrivers. - Leonard Brandwein
Re: [PATCH 3.2 08/67] af_unix: fix struct pid memory leak
In reply to Rainer WeikusatQuoted 29 lines · Rainer Weikusat
Quoted 7 lines · Ben Hutchings
3.2.78-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit
fa0dc04df259ba2df3ce1920e9690c7842f8fa4bupstream.[...]
Quoted 1 line
Fixes b3ca9b02b007 ("net: fix multithreaded signal handling in unix recv routines")[...]
Quoted 10 lines
net/unix/af_unix.c | 1 +
1 file changed, 1 insertion(+)net/unix/af_unix.c +0
-0@@ -2100,6 +2100,7 @@ static int unix_stream_recvmsg(struct ki
if (signal_pending(current)) { err =sock_intr_errno(timeo);net/unix/af_unix.c +1
-0+scm_destroy (siocb->scm);Quoted 2 lines
goto out;
}JFTR: The commit mentioned in the fixes is (just the relevant part)
[...]
Quoted 3 lines
This not only didn't add the block triggering the error but this change isn't even part of the (version of) the function which was fixed anymore.
Yes, it looks like the bug was really introduced way back in 2.5.65 by "[NET]: Simplify scm handling and sendmsg/recvmsg invocation, consolidate net compat syscalls."
So I think this is also needed for 2.6.32.
Ben.
Signature · 2 lines
Ben Hutchings Beware of programmers who carry screwdrivers. - Leonard Brandwein
Re: [PATCH 3.2 08/67] af_unix: fix struct pid memory leak
On Wed, Feb 24, 2016 at 09:24:39PM +0000, Ben Hutchings wrote:
(...)
Quoted 5 lines
Yes, it looks like the bug was really introduced way back in 2.5.65 by "[NET]: Simplify scm handling and sendmsg/recvmsg invocation, consolidate net compat syscalls."
So I think this is also needed for 2.6.32.
Thanks for letting me know, Ben!
Willy