4.9.250-rc1 review
Greg Kroah-Hartman
maintainercover 4.9.250-rc1 review
This is the start of the stable review cycle for the 4.9.250 release. There are 32 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 09 Jan 2021 14:08:13 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.250-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.9.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 4.9.250-rc1
Jonathan Cameron <[email protected]>
iio:magnetometer:mag3110: Fix alignment and data leak issues.
Jonathan Cameron <[email protected]>
iio:imu:bmi160: Fix alignment and data leak issues
Jonathan Cameron <[email protected]>
iio:imu:bmi160: Fix too large a buffer.
sayli karnik <[email protected]>
iio: bmi160_core: Fix sparse warning due to incorrect type in assignment
SeongJae Park <[email protected]>
xenbus/xenbus_backend: Disallow pending watch messages
SeongJae Park <[email protected]>
xen/xenbus: Count pending messages for each watch
SeongJae Park <[email protected]>
xen/xenbus/xen_bus_type: Support will_handle watch callback
SeongJae Park <[email protected]>
xen/xenbus: Add 'will_handle' callback support in xenbus_watch_path()
SeongJae Park <[email protected]>
xen/xenbus: Allow watches discard events before queueing
Josh Poimboeuf <[email protected]>
kdev_t: always inline major/minor helper functions
Jessica Yu <[email protected]>
module: delay kobject uevent until after module init call
Qinglang Miao <[email protected]>
powerpc: sysdev: add missing iounmap() on error in mpic_msgr_probe()
Jan Kara <[email protected]>
quota: Don't overflow quota file offsets
Miroslav Benes <[email protected]>
module: set MODULE_STATE_GOING state when a module fails to load
Takashi Iwai <[email protected]>
ALSA: seq: Use bool for snd_seq_queue internal flags
Mauro Carvalho Chehab <[email protected]>
media: gp8psk: initialize stats at power control logic
Anant Thazhemadam <[email protected]>
misc: vmw_vmci: fix kernel info-leak by initializing dbells in vmci_ctx_get_chkpt_doorbells()
Rustam Kovhaev <[email protected]>
reiserfs: add check for an invalid ih_entry_count
Johan Hovold <[email protected]>
of: fix linker-section match-table corruption
Petr Vorel <[email protected]>
uapi: move constants from <linux/kernel.h> to <linux/const.h>
Paolo Abeni <[email protected]>
l2tp: fix races with ipv4-mapped ipv6 addresses
Paolo Abeni <[email protected]>
net: ipv6: keep sk status consistent after datagram connect failure
Johan Hovold <[email protected]>
USB: serial: digi_acceleport: fix write-wakeup deadlocks
Stefan Haberland <[email protected]>
s390/dasd: fix hanging device offline processing
Eric Auger <[email protected]>
vfio/pci: Move dummy_resources_list init in vfio_pci_probe()
Kailang Yang <[email protected]>
ALSA: hda/realtek - Dell headphone has noise on unmute for ALC236
Hui Wang <[email protected]>
ALSA: hda - Fix a wrong FIXUP for alc289 on Dell machines
Kailang Yang <[email protected]>
ALSA: hda/realtek - Support Dell headset mode for ALC3271
Johan Hovold <[email protected]>
ALSA: usb-audio: fix sync-ep altsetting sanity check
Alberto Aguirre <[email protected]>
ALSA: usb-audio: simplify set_sync_ep_implicit_fb_quirk
Takashi Iwai <[email protected]>
ALSA: hda/ca0132 - Fix work handling in delayed HP detection
Jan Beulich <[email protected]>
x86/entry/64: Add instruction suffix
-------------
Diffstat:
Makefile | 4 +-- arch/powerpc/sysdev/mpic_msgr.c | 2 +- arch/x86/entry/entry_64.S | 2 +- drivers/block/xen-blkback/xenbus.c | 3 +- drivers/iio/imu/bmi160/bmi160_core.c | 12 +++++-- drivers/iio/magnetometer/mag3110.c | 13 +++++--- drivers/media/usb/dvb-usb/gp8psk.c | 2 +- drivers/misc/vmw_vmci/vmci_context.c | 2 +- drivers/net/xen-netback/xenbus.c | 4 ++- drivers/s390/block/dasd_alias.c | 10 +++++- drivers/usb/serial/digi_acceleport.c | 45 ++++++++------------------ drivers/vfio/pci/vfio_pci.c | 4 +-- drivers/xen/xen-pciback/xenbus.c | 2 +- drivers/xen/xenbus/xenbus_client.c | 8 ++++- drivers/xen/xenbus/xenbus_probe.c | 1 + drivers/xen/xenbus/xenbus_probe.h | 2 ++ drivers/xen/xenbus/xenbus_probe_backend.c | 7 +++++ drivers/xen/xenbus/xenbus_xs.c | 38 ++++++++++++++-------- fs/quota/quota_tree.c | 8 ++--- fs/reiserfs/stree.c | 6 ++++ include/linux/kdev_t.h | 22 ++++++------- include/linux/of.h | 1 + include/uapi/linux/const.h | 5 +++ include/uapi/linux/ethtool.h | 2 +- include/uapi/linux/kernel.h | 9 +----- include/uapi/linux/lightnvm.h | 2 +- include/uapi/linux/mroute6.h | 2 +- include/uapi/linux/netfilter/x_tables.h | 2 +- include/uapi/linux/netlink.h | 2 +- include/uapi/linux/sysctl.h | 2 +- include/xen/xenbus.h | 15 ++++++++- kernel/module.c | 6 ++-- net/ipv6/datagram.c | 21 ++++++++++--- net/l2tp/l2tp_core.c | 38 +++++++++++----------- net/l2tp/l2tp_core.h | 3 -- sound/core/seq/seq_queue.h | 8 ++--- sound/pci/hda/patch_ca0132.c | 16 ++++++++-- sound/pci/hda/patch_realtek.c | 25 +++++++++++++-- sound/usb/pcm.c | 52 ++++++++++++------------------- 39 files changed, 242 insertions(+), 166 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/32 x86/entry/64: Add instruction suffix
From: Jan Beulich <[email protected]>
commit a368d7fd2a3c6babb852fe974018dd97916bcd3b upstream.
Omitting suffixes from instructions in AT&T mode is bad practice when operand size cannot be determined by the assembler from register operands, and is likely going to be warned about by upstream gas in the future (mine does already). Add the single missing suffix here.
--- arch/x86/entry/entry_64.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/entry/entry_64.S +1 -1
@@ -58,7 +58,7 @@ ENDPROC(native_usergs_sysret64) .macro TRACE_IRQS_IRETQ #ifdef CONFIG_TRACE_IRQFLAGS - bt $9, EFLAGS(%rsp) /* interrupts off? */ + btl $9, EFLAGS(%rsp) /* interrupts off? */ jnc 1f TRACE_IRQS_ON 1:
Greg Kroah-Hartman
maintainerPATCH 2/32 ALSA: hda/ca0132 - Fix work handling in delayed HP detection
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 42fb6b1d41eb5905d77c06cad2e87b70289bdb76 upstream
CA0132 has the delayed HP jack detection code that is invoked from the unsol handler, but it does a few weird things: it contains the cancel of a work inside the work handler, and yet it misses the cancel-sync call at (runtime-)suspend. This patch addresses those issues.
--- sound/pci/hda/patch_ca0132.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
sound/pci/hda/patch_ca0132.c +14 -2
@@ -4443,11 +4443,10 @@ static void hp_callback(struct hda_codec/* Delay enabling the HP amp, to let the mic-detection * state machine run. */ -cancel_delayed_work (&spec->unsol_hp_work); -schedule_delayed_work (&spec->unsol_hp_work,msecs_to_jiffies (500 )); tbl =snd_hda_jack_tbl_get (codec, cb->nid);if (tbl) tbl->block_report =1 ; +schedule_delayed_work (&spec->unsol_hp_work,msecs_to_jiffies (500 )); }static void amic_callback (struct hda_codec *codec,struct hda_jack_callback *cb)
@@ -4625,12 +4624,25 @@ static void ca0132_free(struct hda_codeckfree (codec->spec); } +#ifdef CONFIG_PM +static int ca0132_suspend (struct hda_codec *codec) +{ +struct ca0132_spec *spec = codec->spec; + +cancel_delayed_work_sync (&spec->unsol_hp_work); +return 0 ; +} +#endif +static const struct hda_codec_ops ca0132_patch_ops = { .build_controls = ca0132_build_controls, .build_pcms = ca0132_build_pcms, .init = ca0132_init, .free = ca0132_free, .unsol_event = snd_hda_jack_unsol_event, +#ifdef CONFIG_PM + .suspend = ca0132_suspend, +#endif };static void ca0132_config (struct hda_codec *codec)
Greg Kroah-Hartman
maintainerPATCH 3/32 ALSA: usb-audio: simplify set_sync_ep_implicit_fb_quirk
In reply to Greg Kroah-HartmanFrom: Alberto Aguirre <[email protected]>
commit 103e9625647ad74d201e26fb74afcd8479142a37 upstream
--- sound/usb/pcm.c | 52 ++++++++++++++++++++-------------------------------- 1 file changed, 20 insertions(+), 32 deletions(-)
sound/usb/pcm.c +20 -32
@@ -324,6 +324,7 @@ static int set_sync_ep_implicit_fb_quirkstruct usb_host_interface *alts;struct usb_interface *iface;unsigned int ep; +unsigned int ifnum;/* Implicit feedback sync EPs consumers are always playback EPs */ if (subs->direction !=SNDRV_PCM_STREAM_PLAYBACK )
@@ -334,44 +335,23 @@ static int set_sync_ep_implicit_fb_quirkcase USB_ID (0x0763 ,0x2031 ):/* M-Audio Fast Track C600 */ case USB_ID (0x22f0 ,0x0006 ):/* Allen&Heath Qu-16 */ ep =0x81 ; - iface =usb_ifnum_to_if (dev,3 ); - -if (!iface || iface->num_altsetting ==0 ) -return -EINVAL ; - - alts = &iface->altsetting[1 ]; - goto add_sync_ep; -break ; + ifnum =3 ; + goto add_sync_ep_from_ifnum;case USB_ID (0x0763 ,0x2080 ):/* M-Audio FastTrack Ultra */ case USB_ID (0x0763 ,0x2081 ): ep =0x81 ; - iface =usb_ifnum_to_if (dev,2 ); - -if (!iface || iface->num_altsetting ==0 ) -return -EINVAL ; - - alts = &iface->altsetting[1 ]; - goto add_sync_ep; -case USB_ID (0x2466 ,0x8003 ): + ifnum =2 ; + goto add_sync_ep_from_ifnum; +case USB_ID (0x2466 ,0x8003 ):/* Fractal Audio Axe-Fx II */ ep =0x86 ; - iface =usb_ifnum_to_if (dev,2 ); - -if (!iface || iface->num_altsetting ==0 ) -return -EINVAL ; - - alts = &iface->altsetting[1 ]; - goto add_sync_ep; -case USB_ID (0x1397 ,0x0002 ): + ifnum =2 ; + goto add_sync_ep_from_ifnum; +case USB_ID (0x1397 ,0x0002 ):/* Behringer UFX1204 */ ep =0x81 ; - iface =usb_ifnum_to_if (dev,1 ); - -if (!iface || iface->num_altsetting ==0 ) -return -EINVAL ; - - alts = &iface->altsetting[1 ]; - goto add_sync_ep; - + ifnum =1 ; + goto add_sync_ep_from_ifnum; } + if (attr == USB_ENDPOINT_SYNC_ASYNC && altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC && altsd->bInterfaceProtocol == 2 &&
@@ -386,6 +366,14 @@ static int set_sync_ep_implicit_fb_quirk/* No quirk */ return 0 ; +add_sync_ep_from_ifnum: + iface =usb_ifnum_to_if (dev, ifnum); + +if (!iface || iface->num_altsetting ==0 ) +return -EINVAL ; + + alts = &iface->altsetting[1 ]; + add_sync_ep: subs->sync_endpoint = snd_usb_add_endpoint(subs->stream->chip, alts, ep, !subs->direction,
Greg Kroah-Hartman
maintainerPATCH 4/32 ALSA: usb-audio: fix sync-ep altsetting sanity check
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 5d1b71226dc4d44b4b65766fa9d74492f9d4587b upstream
The altsetting sanity check in set_sync_ep_implicit_fb_quirk() was checking for there to be at least one altsetting but then went on to access the second one, which may not exist.
This could lead to random slab data being used to initialise the sync endpoint in snd_usb_add_endpoint().
--- sound/usb/pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/usb/pcm.c +1 -1
@@ -369,7 +369,7 @@ static int set_sync_ep_implicit_fb_quirk add_sync_ep_from_ifnum: iface =usb_ifnum_to_if (dev, ifnum); -if (!iface || iface->num_altsetting ==0 ) +if (!iface || iface->num_altsetting <2 )return -EINVAL ; alts = &iface->altsetting[1 ];
Greg Kroah-Hartman
maintainerPATCH 5/32 ALSA: hda/realtek - Support Dell headset mode for ALC3271
In reply to Greg Kroah-HartmanFrom: Kailang Yang <[email protected]>
commit fcc6c877a01f83cbce1cca885ea62df6a10d33c3 upstream
Add DELL4_MIC_NO_PRESENCE model.
Add the pin configuration value of this machine into the pin_quirk table to make DELL4_MIC_NO_PRESENCE apply to this machine.
--- sound/pci/hda/patch_realtek.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
sound/pci/hda/patch_realtek.c +16 -0
@@ -4896,6 +4896,7 @@ enum {ALC269_FIXUP_DELL1_MIC_NO_PRESENCE ,ALC269_FIXUP_DELL2_MIC_NO_PRESENCE ,ALC269_FIXUP_DELL3_MIC_NO_PRESENCE , +ALC269_FIXUP_DELL4_MIC_NO_PRESENCE ,ALC269_FIXUP_HEADSET_MODE ,ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC , ALC269_FIXUP_ASPIRE_HEADSET_MIC,
@@ -5199,6 +5200,16 @@ static const struct hda_fixup alc269_fix .chained = true, .chain_id =ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC }, + [ALC269_FIXUP_DELL4_MIC_NO_PRESENCE] = { + .type = HDA_FIXUP_PINS, + .v.pins = (const struct hda_pintbl []) { + {0x19 ,0x01a1913c },/* use as headset mic, without its own jack detect */ + {0x1b ,0x01a1913d },/* use as headphone mic, without its own jack detect */ + { } + }, + .chained = true, + .chain_id =ALC269_FIXUP_HEADSET_MODE + }, [ALC269_FIXUP_HEADSET_MODE] = { .type = HDA_FIXUP_FUNC, .v.func = alc_fixup_headset_mode,
@@ -6267,6 +6278,11 @@ static const struct snd_hda_pin_quirk al {0x17, 0x90170110}, {0x1a, 0x03011020}, {0x21, 0x03211030}), +SND_HDA_PIN_QUIRK (0x10ec0299 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL4_MIC_NO_PRESENCE , +ALC225_STANDARD_PINS , + {0x12, 0xb7a60130}, + {0x13, 0xb8a60140}, + {0x17, 0x90170110}), {} };
Greg Kroah-Hartman
maintainerPATCH 6/32 ALSA: hda - Fix a wrong FIXUP for alc289 on Dell machines
In reply to Greg Kroah-HartmanFrom: Hui Wang <[email protected]>
commit d5078193e56bb24f4593f00102a3b5e07bb84ee0 upstream
With the alc289, the Pin 0x1b is Headphone-Mic, so we should assign ALC269_FIXUP_DELL4_MIC_NO_PRESENCE rather than ALC225_FIXUP_DELL1_MIC_NO_PRESENCE to it. And this change is suggested by Kailang of Realtek and is verified on the machine.
--- sound/pci/hda/patch_realtek.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/hda/patch_realtek.c +1 -1
@@ -6194,7 +6194,7 @@ static const struct snd_hda_pin_quirk al {0x12, 0x90a60120}, {0x14, 0x90170110}, {0x21, 0x0321101f}), -SND_HDA_PIN_QUIRK (0x10ec0289 ,0x1028 ,"Dell" ,ALC225_FIXUP_DELL1_MIC_NO_PRESENCE , +SND_HDA_PIN_QUIRK (0x10ec0289 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL4_MIC_NO_PRESENCE , {0x12, 0xb7a60130}, {0x14, 0x90170110}, {0x21, 0x04211020}),
Greg Kroah-Hartman
maintainerPATCH 7/32 ALSA: hda/realtek - Dell headphone has noise on unmute for ALC236
In reply to Greg Kroah-HartmanFrom: Kailang Yang <[email protected]>
commit e1e8c1fdce8b00fce08784d9d738c60ebf598ebc upstream
headphone have noise even the volume is very small. Let it fill up pcbeep hidden register to default value. The issue was gone.
--- sound/pci/hda/patch_realtek.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
sound/pci/hda/patch_realtek.c +5 -2
@@ -330,9 +330,7 @@ static void alc_fill_eapd_coef(struct hdcase 0x10ec0225 :case 0x10ec0233 :case 0x10ec0235 : -case 0x10ec0236 :case 0x10ec0255 : -case 0x10ec0256 :case 0x10ec0257 :case 0x10ec0282 :case 0x10ec0283 :
@@ -343,6 +341,11 @@ static void alc_fill_eapd_coef(struct hdcase 0x10ec0299 :alc_update_coef_idx (codec,0x10 ,1 <<9 ,0 );break ; +case 0x10ec0236 : +case 0x10ec0256 : +alc_write_coef_idx (codec,0x36 ,0x5757 ); +alc_update_coef_idx (codec,0x10 ,1 <<9 ,0 ); +break ;case 0x10ec0285 :case 0x10ec0293 :alc_update_coef_idx (codec,0xa ,1 <<13 ,0 );
Greg Kroah-Hartman
maintainerPATCH 8/32 vfio/pci: Move dummy_resources_list init in vfio_pci_probe()
In reply to Greg Kroah-HartmanFrom: Eric Auger <[email protected]>
[ Upstream commit 16b8fe4caf499ae8e12d2ab1b1324497e36a7b83 ]
In case an error occurs in vfio_pci_enable() before the call to vfio_pci_probe_mmaps(), vfio_pci_disable() will try to iterate on an uninitialized list and cause a kernel panic.
Lets move to the initialization to vfio_pci_probe() to fix the issue.
--- drivers/vfio/pci/vfio_pci.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/vfio/pci/vfio_pci.c +1 -3
@@ -118,8 +118,6 @@ static void vfio_pci_probe_mmaps(struct vfio_pci_device *vdev)int bar;struct vfio_pci_dummy_resource *dummy_res; -INIT_LIST_HEAD (&vdev->dummy_resources_list); -for (bar =PCI_STD_RESOURCES ; bar <=PCI_STD_RESOURCE_END ; bar++) { res = vdev->pdev->resource + bar;
@@ -1547,7 +1545,7 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) vdev->irq_type =VFIO_PCI_NUM_IRQS ;mutex_init (&vdev->igate);spin_lock_init (&vdev->irqlock); - +INIT_LIST_HEAD (&vdev->dummy_resources_list);mutex_init (&vdev->vma_lock);INIT_LIST_HEAD (&vdev->vma_list);init_rwsem (&vdev->memory_lock);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 9/32 s390/dasd: fix hanging device offline processing
In reply to Greg Kroah-HartmanFrom: Stefan Haberland <[email protected]>
[ Upstream commit 658a337a606f48b7ebe451591f7681d383fa115e ]
For an LCU update a read unit address configuration IO is required. This is started using sleep_on(), which has early exit paths in case the device is not usable for IO. For example when it is in offline processing.
In those cases the LCU update should fail and not be retried. Therefore lcu_update_work checks if EOPNOTSUPP is returned or not.
Commit 41995342b40c ("s390/dasd: fix endless loop after read unit address configuration") accidentally removed the EOPNOTSUPP return code from read_unit_address_configuration(), which in turn might lead to an endless loop of the LCU update in offline processing.
Fix by returning EOPNOTSUPP again if the device is not able to perform the request.
--- drivers/s390/block/dasd_alias.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/s390/block/dasd_alias.c +9 -1
@@ -461,11 +461,19 @@ static int read_unit_address_configuration(struct dasd_device *device,spin_unlock_irqrestore (&lcu->lock, flags); rc =dasd_sleep_on (cqr); -if (rc && !suborder_not_supported (cqr)) { +if (!rc) + goto out; + +if (suborder_not_supported (cqr)) { +/* suborder not supported or device unusable for IO */ + rc = -EOPNOTSUPP ; + }else { +/* IO failed but should be retried */ spin_lock_irqsave (&lcu->lock, flags); lcu->flags |=NEED_UAC_UPDATE ;spin_unlock_irqrestore (&lcu->lock, flags); } +out:dasd_kfree_request (cqr, cqr->memdev);return rc; }
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 10/32 USB: serial: digi_acceleport: fix write-wakeup deadlocks
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit 5098e77962e7c8947f87bd8c5869c83e000a522a ]
The driver must not call tty_wakeup() while holding its private lock as line disciplines are allowed to call back into write() from write_wakeup(), leading to a deadlock.
Also remove the unneeded work struct that was used to defer wakeup in order to work around a possible race in ancient times (see comment about n_tty write_chan() in commit 14b54e39b412 ("USB: serial: remove changelogs and old todo entries")).
--- drivers/usb/serial/digi_acceleport.c | 45 ++++++++++------------------------- 1 file changed, 13 insertions(+), 32 deletions(-)
drivers/usb/serial/digi_acceleport.c +13 -32
@@ -23,7 +23,6 @@#include <linux/tty_flip.h> #include <linux/module.h> #include <linux/spinlock.h> -#include <linux/workqueue.h> #include <linux/uaccess.h> #include <linux/usb.h> #include <linux/wait.h>
@@ -201,14 +200,12 @@ struct digi_port {int dp_throttle_restart;wait_queue_head_t dp_flush_wait;wait_queue_head_t dp_close_wait;/* wait queue for close */ -struct work_struct dp_wakeup_work;struct usb_serial_port *dp_port; };/* Local Function Declarations */ -static void digi_wakeup_write_lock (struct work_struct *work);static int digi_write_oob_command (struct usb_serial_port *port,unsigned char *buf,int count,int interruptible); static int digi_write_inb_command(struct usb_serial_port *port,
@@ -355,26 +352,6 @@ __releases(lock)return timeout; } - -/* -* Digi Wakeup Write -* -* Wake up port, line discipline, and tty processes sleeping -* on writes. -*/ - -static void digi_wakeup_write_lock (struct work_struct *work) -{ -struct digi_port *priv = - container_of(work, struct digi_port, dp_wakeup_work); -struct usb_serial_port *port = priv->dp_port; -unsigned long flags; - -spin_lock_irqsave (&priv->dp_port_lock, flags); -tty_port_tty_wakeup (&port->port); -spin_unlock_irqrestore (&priv->dp_port_lock, flags); -} -/* * Digi Write OOB Command *
@@ -985,6 +962,7 @@ static void digi_write_bulk_callback(strstruct digi_serial *serial_priv;int ret =0 ;int status = urb->status; +bool wakeup;/* port and serial sanity check */ if (port ==NULL || (priv =usb_get_serial_port_data (port)) ==NULL ) {
@@ -1011,6 +989,7 @@ static void digi_write_bulk_callback(str }/* try to send any buffered data on this port */ + wakeup = true;spin_lock (&priv->dp_port_lock); priv->dp_write_urb_in_use =0 ;if (priv->dp_out_buf_len >0 ) {
@@ -1026,19 +1005,18 @@ static void digi_write_bulk_callback(strif (ret ==0 ) { priv->dp_write_urb_in_use =1 ; priv->dp_out_buf_len =0 ; + wakeup = false; } } -/* wake up processes sleeping on writes immediately */ -tty_port_tty_wakeup (&port->port); -/* also queue up a wakeup at scheduler time, in case we */ -/* lost the race in write_chan(). */ -schedule_work (&priv->dp_wakeup_work); -spin_unlock (&priv->dp_port_lock); +if (ret && ret != -EPERM )dev_err_console (port,"%s: usb_submit_urb failed, ret=%d, port=%d\n" , __func__, ret, priv->dp_port_num); + +if (wakeup) +tty_port_tty_wakeup (&port->port); }static int digi_write_room (struct tty_struct *tty)
@@ -1238,7 +1216,6 @@ static int digi_port_init(struct usb_serinit_waitqueue_head (&priv->dp_transmit_idle_wait);init_waitqueue_head (&priv->dp_flush_wait);init_waitqueue_head (&priv->dp_close_wait); -INIT_WORK (&priv->dp_wakeup_work, digi_wakeup_write_lock); priv->dp_port = port;init_waitqueue_head (&port->write_wait);
@@ -1524,13 +1501,14 @@ static int digi_read_oob_callback(struct rts =C_CRTSCTS (tty);if (tty && opcode ==DIGI_CMD_READ_INPUT_SIGNALS ) { +bool wakeup = false; +spin_lock (&priv->dp_port_lock);/* convert from digi flags to termiox flags */ if (val &DIGI_READ_INPUT_SIGNALS_CTS ) { priv->dp_modem_signals |=TIOCM_CTS ; -/* port must be open to use tty struct */ if (rts) -tty_port_tty_wakeup (&port->port); + wakeup = true; }else { priv->dp_modem_signals &= ~TIOCM_CTS ;/* port must be open to use tty struct */
@@ -1549,6 +1527,9 @@ static int digi_read_oob_callback(struct priv->dp_modem_signals &= ~TIOCM_CD ;spin_unlock (&priv->dp_port_lock); + +if (wakeup) +tty_port_tty_wakeup (&port->port); }else if (opcode ==DIGI_CMD_TRANSMIT_IDLE ) {spin_lock (&priv->dp_port_lock); priv->dp_transmit_idle =1 ;
Greg Kroah-Hartman
maintainerPATCH 11/32 net: ipv6: keep sk status consistent after datagram connect failure
In reply to Greg Kroah-HartmanFrom: Paolo Abeni <[email protected]>
commit 2f987a76a97773beafbc615b9c4d8fe79129a7f4 upstream.
On unsuccesful ip6_datagram_connect(), if the failure is caused by ip6_datagram_dst_update(), the sk peer information are cleared, but the sk->sk_state is preserved.
If the socket was already in an established status, the overall sk status is inconsistent and fouls later checks in datagram code.
Fix this saving the old peer information and restoring them in case of failure. This also aligns ipv6 datagram connect() behavior with ipv4.
v1 -> v2:
- added missing Fixes tag
--- net/ipv6/datagram.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
net/ipv6/datagram.c +17 -4
@@ -145,10 +145,12 @@ int __ip6_datagram_connect(struct sock *struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr;struct inet_sock *inet =inet_sk (sk);struct ipv6_pinfo *np =inet6_sk (sk); -struct in6_addr *daddr; +struct in6_addr *daddr, old_daddr; +__be32 fl6_flowlabel =0 ; +__be32 old_fl6_flowlabel; +__be32 old_dport;int addr_type;int err; -__be32 fl6_flowlabel =0 ;if (usin->sin6_family ==AF_INET ) {if (__ipv6_only_sock (sk))
@@ -238,9 +240,13 @@ ipv4_connected: } } +/* save the current peer information before updating it */ + old_daddr = sk->sk_v6_daddr; + old_fl6_flowlabel = np->flow_label; + old_dport = inet->inet_dport; + sk->sk_v6_daddr = *daddr; np->flow_label = fl6_flowlabel; - inet->inet_dport = usin->sin6_port;/*
@@ -249,8 +255,15 @@ ipv4_connected:*/ err =ip6_datagram_dst_update (sk, true); -if (err) +if (err) { +/* Restore the socket peer info, to keep it consistent with +* the old socket state +*/ + sk->sk_v6_daddr = old_daddr; + np->flow_label = old_fl6_flowlabel; + inet->inet_dport = old_dport; goto out; + } sk->sk_state =TCP_ESTABLISHED ;sk_set_txhash (sk);
Greg Kroah-Hartman
maintainerPATCH 12/32 l2tp: fix races with ipv4-mapped ipv6 addresses
In reply to Greg Kroah-HartmanFrom: Paolo Abeni <[email protected]>
commit b954f94023dcc61388c8384f0f14eb8e42c863c5 upstream.
The l2tp_tunnel_create() function checks for v4mapped ipv6 sockets and cache that flag, so that l2tp core code can reusing it at xmit time.
If the socket is provided by the userspace, the connection status of the tunnel sockets can change between the tunnel creation and the xmit call, so that syzbot is able to trigger the following splat:
BUG: KASAN: use-after-free in ip6_dst_idev include/net/ip6_fib.h:192 [inline] BUG: KASAN: use-after-free in ip6_xmit+0x1f76/0x2260 net/ipv6/ip6_output.c:264 Read of size 8 at addr ffff8801bd949318 by task syz-executor4/23448 CPU: 0 PID: 23448 Comm: syz-executor4 Not tainted 4.16.0-rc4+ #65 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:17 [inline] dump_stack+0x194/0x24d lib/dump_stack.c:53 print_address_description+0x73/0x250 mm/kasan/report.c:256 kasan_report_error mm/kasan/report.c:354 [inline] kasan_report+0x23c/0x360 mm/kasan/report.c:412 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433 ip6_dst_idev include/net/ip6_fib.h:192 [inline] ip6_xmit+0x1f76/0x2260 net/ipv6/ip6_output.c:264 inet6_csk_xmit+0x2fc/0x580 net/ipv6/inet6_connection_sock.c:139 l2tp_xmit_core net/l2tp/l2tp_core.c:1053 [inline] l2tp_xmit_skb+0x105f/0x1410 net/l2tp/l2tp_core.c:1148 pppol2tp_sendmsg+0x470/0x670 net/l2tp/l2tp_ppp.c:341 sock_sendmsg_nosec net/socket.c:630 [inline] sock_sendmsg+0xca/0x110 net/socket.c:640 ___sys_sendmsg+0x767/0x8b0 net/socket.c:2046 __sys_sendmsg+0xe5/0x210 net/socket.c:2080 SYSC_sendmsg net/socket.c:2091 [inline] SyS_sendmsg+0x2d/0x50 net/socket.c:2087 do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287 entry_SYSCALL_64_after_hwframe+0x42/0xb7 RIP: 0033:0x453e69 RSP: 002b:00007f819593cc68 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007f819593d6d4 RCX: 0000000000453e69 RDX: 0000000000000081 RSI: 000000002037ffc8 RDI: 0000000000000004 RBP: 000000000072bea0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff R13: 00000000000004c3 R14: 00000000006f72e8 R15: 0000000000000000
This change addresses the issues:
* explicitly checking for TCP_ESTABLISHED for user space provided sockets
* dropping the v4mapped flag usage - it can become outdated - and explicitly invoking ipv6_addr_v4mapped() instead
The issue is apparently there since ancient times.
v1 -> v2: (many thanks to Guillaume)
- with csum issue introduced in v1
- replace pr_err with pr_debug
- fix build issue with IPV6 disabled
- move l2tp_sk_is_v4mapped in l2tp_core.c
v2 -> v3:
- don't update inet_daddr for v4mapped address, unneeded
- drop rendundant check at creation time
--- net/l2tp/l2tp_core.c | 38 ++++++++++++++++++-------------------- net/l2tp/l2tp_core.h | 3 --- 2 files changed, 18 insertions(+), 23 deletions(-)
net/l2tp/l2tp_core.c +18 -20
@@ -112,6 +112,13 @@ struct l2tp_net {spinlock_t l2tp_session_hlist_lock; }; +#if IS_ENABLED (CONFIG_IPV6 ) +static bool l2tp_sk_is_v6 (struct sock *sk) +{ +return sk->sk_family ==PF_INET6 && + !ipv6_addr_v4mapped (&sk->sk_v6_daddr); +} +#endif static inline struct l2tp_tunnel *l2tp_tunnel (struct sock *sk) {
@@ -1136,7 +1143,7 @@ static int l2tp_xmit_core(struct l2tp_se skb->ignore_df =1 ;skb_dst_drop (skb);#if IS_ENABLED (CONFIG_IPV6 ) -if (tunnel->sock->sk_family ==PF_INET6 && !tunnel->v4mapped) +if (l2tp_sk_is_v6 (tunnel->sock)) error =inet6_csk_xmit (tunnel->sock, skb,NULL ); else#endif
@@ -1199,6 +1206,15 @@ int l2tp_xmit_skb(struct l2tp_session *s goto out_unlock; } +/* The user-space may change the connection status for the user-space +* provided socket at run time: we must check it under the socket lock +*/ +if (tunnel->fd >=0 && sk->sk_state !=TCP_ESTABLISHED ) { +kfree_skb (skb); + ret =NET_XMIT_DROP ; + goto out_unlock; + } + inet =inet_sk (sk); fl = &inet->cork.fl;switch (tunnel->encap) {
@@ -1214,7 +1230,7 @@ int l2tp_xmit_skb(struct l2tp_session *s/* Calculate UDP checksum if configured to do so */ #if IS_ENABLED (CONFIG_IPV6 ) -if (sk->sk_family ==PF_INET6 && !tunnel->v4mapped) +if (l2tp_sk_is_v6 (sk))udp6_set_csum (udp_get_no_check6_tx (sk), skb, &inet6_sk (sk)->saddr, &sk->sk_v6_daddr, udp_len);
@@ -1620,24 +1636,6 @@ int l2tp_tunnel_create(struct net *net,if (cfg !=NULL ) tunnel->debug = cfg->debug; -#if IS_ENABLED (CONFIG_IPV6 ) -if (sk->sk_family ==PF_INET6 ) { -struct ipv6_pinfo *np =inet6_sk (sk); - -if (ipv6_addr_v4mapped (&np->saddr) && -ipv6_addr_v4mapped (&sk->sk_v6_daddr)) { -struct inet_sock *inet =inet_sk (sk); - - tunnel->v4mapped = true; - inet->inet_saddr = np->saddr.s6_addr32[3 ]; - inet->inet_rcv_saddr = sk->sk_v6_rcv_saddr.s6_addr32[3 ]; - inet->inet_daddr = sk->sk_v6_daddr.s6_addr32[3 ]; - }else { - tunnel->v4mapped = false; - } - } -#endif -/* Mark socket as an encapsulation socket. See net/ipv4/udp.c */ tunnel->encap = encap;if (encap ==L2TP_ENCAPTYPE_UDP ) {
net/l2tp/l2tp_core.h +0 -3
@@ -191,9 +191,6 @@ struct l2tp_tunnel {struct sock *sock;/* Parent socket */ int fd;/* Parent fd, if tunnel socket * was created by userspace */ -#if IS_ENABLED (CONFIG_IPV6 ) -bool v4mapped; -#endif struct work_struct del_work;
Greg Kroah-Hartman
maintainerPATCH 13/32 uapi: move constants from <linux/kernel.h> to <linux/const.h>
In reply to Greg Kroah-HartmanFrom: Petr Vorel <[email protected]>
commit a85cbe6159ffc973e5702f70a3bd5185f8f3c38d upstream.
and include <linux/const.h> in UAPI headers instead of <linux/kernel.h>.
The reason is to avoid indirect <linux/sysinfo.h> include when using some network headers: <linux/netlink.h> or others -> <linux/kernel.h> -> <linux/sysinfo.h>.
This indirect include causes on MUSL redefinition of struct sysinfo when included both <sys/sysinfo.h> and some of UAPI headers:
In file included from x86_64-buildroot-linux-musl/sysroot/usr/include/linux/kernel.h:5,
from x86_64-buildroot-linux-musl/sysroot/usr/include/linux/netlink.h:5,
from ../include/tst_netlink.h:14,
from tst_crypto.c:13:
x86_64-buildroot-linux-musl/sysroot/usr/include/linux/sysinfo.h:8:8: error: redefinition of `struct sysinfo'
struct sysinfo {
^~~~~~~
In file included from ../include/tst_safe_macros.h:15,
from ../include/tst_test.h:93,
from tst_crypto.c:11:
x86_64-buildroot-linux-musl/sysroot/usr/include/sys/sysinfo.h:10:8: note: originally defined here--- include/uapi/linux/const.h | 5 +++++ include/uapi/linux/ethtool.h | 2 +- include/uapi/linux/kernel.h | 9 +-------- include/uapi/linux/lightnvm.h | 2 +- include/uapi/linux/mroute6.h | 2 +- include/uapi/linux/netfilter/x_tables.h | 2 +- include/uapi/linux/netlink.h | 2 +- include/uapi/linux/sysctl.h | 2 +- 8 files changed, 12 insertions(+), 14 deletions(-)
include/uapi/linux/const.h +5 -0
@@ -24,4 +24,9 @@#define _BITUL (x) (_AC(1,UL) << (x))#define _BITULL (x) (_AC(1,ULL) << (x)) +#define __ALIGN_KERNEL (x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1) +#define __ALIGN_KERNEL_MASK (x, mask) (((x) + (mask)) & ~(mask)) + +#define __KERNEL_DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) +#endif /* !(_LINUX_CONST_H) */
include/uapi/linux/ethtool.h +1 -1
@@ -13,7 +13,7 @@#ifndef _UAPI_LINUX_ETHTOOL_H#define _UAPI_LINUX_ETHTOOL_H -#include <linux/kernel.h> +#include <linux/const.h> #include <linux/types.h> #include <linux/if_ether.h>
include/uapi/linux/kernel.h +1 -8
@@ -2,13 +2,6 @@#define _UAPI_LINUX_KERNEL_H#include <linux/sysinfo.h> - -/* -* 'kernel.h' contains some often-used function prototypes etc -*/ -#define __ALIGN_KERNEL (x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1) -#define __ALIGN_KERNEL_MASK (x, mask) (((x) + (mask)) & ~(mask)) - -#define __KERNEL_DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) +#include <linux/const.h> #endif /* _UAPI_LINUX_KERNEL_H */
include/uapi/linux/lightnvm.h +1 -1
@@ -20,7 +20,7 @@#define _UAPI_LINUX_LIGHTNVM_H#ifdef __KERNEL__ -#include <linux/kernel.h> +#include <linux/const.h> #include <linux/ioctl.h> #else /* __KERNEL__ */ #include <stdio.h>
include/uapi/linux/mroute6.h +1 -1
@@ -1,7 +1,7 @@#ifndef _UAPI__LINUX_MROUTE6_H#define _UAPI__LINUX_MROUTE6_H -#include <linux/kernel.h> +#include <linux/const.h> #include <linux/types.h> #include <linux/sockios.h> #include <linux/in6.h> /* For struct sockaddr_in6. */
include/uapi/linux/netfilter/x_tables.h +1 -1
@@ -1,6 +1,6 @@#ifndef _UAPI_X_TABLES_H#define _UAPI_X_TABLES_H -#include <linux/kernel.h> +#include <linux/const.h> #include <linux/types.h> #define XT_FUNCTION_MAXNAMELEN 30
include/uapi/linux/netlink.h +1 -1
@@ -1,7 +1,7 @@#ifndef _UAPI__LINUX_NETLINK_H#define _UAPI__LINUX_NETLINK_H -#include <linux/kernel.h> +#include <linux/const.h> #include <linux/socket.h> /* for __kernel_sa_family_t */ #include <linux/types.h>
include/uapi/linux/sysctl.h +1 -1
@@ -22,7 +22,7 @@#ifndef _UAPI_LINUX_SYSCTL_H#define _UAPI_LINUX_SYSCTL_H -#include <linux/kernel.h> +#include <linux/const.h> #include <linux/types.h> #include <linux/compiler.h>
Greg Kroah-Hartman
maintainerPATCH 14/32 of: fix linker-section match-table corruption
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 5812b32e01c6d86ba7a84110702b46d8a8531fe9 upstream.
Specify type alignment when declaring linker-section match-table entries to prevent gcc from increasing alignment and corrupting the various tables with padding (e.g. timers, irqchips, clocks, reserved memory).
This is specifically needed on x86 where gcc (typically) aligns larger objects like struct of_device_id with static extent on 32-byte boundaries which at best prevents matching on anything but the first entry. Specifying alignment when declaring variables suppresses this optimisation.
Here's a 64-bit example where all entries are corrupt as 16 bytes of padding has been inserted before the first entry:
ffffffff8266b4b0 D __clk_of_table ffffffff8266b4c0 d __of_table_fixed_factor_clk ffffffff8266b5a0 d __of_table_fixed_clk ffffffff8266b680 d __clk_of_table_sentinel
And here's a 32-bit example where the 8-byte-aligned table happens to be placed on a 32-byte boundary so that all but the first entry are corrupt due to the 28 bytes of padding inserted between entries:
812b3ec0 D __irqchip_of_table 812b3ec0 d __of_table_irqchip1 812b3fa0 d __of_table_irqchip2 812b4080 d __of_table_irqchip3 812b4160 d irqchip_of_match_end
Verified on x86 using gcc-9.3 and gcc-4.9 (which uses 64-byte alignment), and on arm using gcc-7.2.
Note that there are no in-tree users of these tables on x86 currently (even if they are included in the image).
--- include/linux/of.h | 1 + 1 file changed, 1 insertion(+)
include/linux/of.h +1 -0
@@ -1132,6 +1132,7 @@ static inline int of_get_available_child#define _OF_DECLARE (table, name, compat, fn, fn_type) \ static const struct of_device_id __of_table_##name \ __used __section(__##table##_of_table) \ + __aligned(__alignof__(struct of_device_id)) \ = { .compatible = compat, \ .data = (fn == (fn_type)NULL) ? fn : fn }#else
Greg Kroah-Hartman
maintainerPATCH 15/32 reiserfs: add check for an invalid ih_entry_count
In reply to Greg Kroah-HartmanFrom: Rustam Kovhaev <[email protected]>
commit d24396c5290ba8ab04ba505176874c4e04a2d53c upstream.
when directory item has an invalid value set for ih_entry_count it might trigger use-after-free or out-of-bounds read in bin_search_in_dir_item()
ih_entry_count * IH_SIZE for directory item should not be larger than ih_item_len
--- fs/reiserfs/stree.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/reiserfs/stree.c +6 -0
@@ -453,6 +453,12 @@ static int is_leaf(char *buf, int blocks "(second one): %h", ih);return 0 ; } +if (is_direntry_le_ih (ih) && (ih_item_len (ih) < (ih_entry_count (ih) *IH_SIZE ))) { +reiserfs_warning (NULL ,"reiserfs-5093" , +"item entry count seems wrong %h" , + ih); +return 0 ; + } prev_location =ih_location (ih); }
Greg Kroah-Hartman
maintainerPATCH 16/32 misc: vmw_vmci: fix kernel info-leak by initializing dbells in vmci_ctx_get_chkpt_doorbells()
In reply to Greg Kroah-HartmanFrom: Anant Thazhemadam <[email protected]>
commit 31dcb6c30a26d32650ce134820f27de3c675a45a upstream.
A kernel-infoleak was reported by syzbot, which was caused because dbells was left uninitialized.
Using kzalloc() instead of kmalloc() fixes this issue.
--- drivers/misc/vmw_vmci/vmci_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/vmw_vmci/vmci_context.c +1 -1
@@ -750,7 +750,7 @@ static int vmci_ctx_get_chkpt_doorbells(return VMCI_ERROR_MORE_DATA ; } - dbells =kmalloc (data_size,GFP_ATOMIC ); + dbells =kzalloc (data_size,GFP_ATOMIC );if (!dbells)return VMCI_ERROR_NO_MEM ;
Greg Kroah-Hartman
maintainerPATCH 17/32 media: gp8psk: initialize stats at power control logic
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
commit d0ac1a26ed5943127cb0156148735f5f52a07075 upstream.
As reported on:
https://lore.kernel.org/linux-media/[email protected]/
if gp8psk_usb_in_op() returns an error, the status var is not initialized. Yet, this var is used later on, in order to identify:
- if the device was already started;
- if firmware has loaded;
- if the LNBf was powered on.
Using status = 0 seems to ensure that everything will be properly powered up.
So, instead of the proposed solution, let's just set status = 0.
--- drivers/media/usb/dvb-usb/gp8psk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/dvb-usb/gp8psk.c +1 -1
@@ -186,7 +186,7 @@ out_rel_fw:static int gp8psk_power_ctrl (struct dvb_usb_device *d,int onoff) { -u8 status, buf; +u8 status =0 , buf;int gp_product_id =le16_to_cpu (d->udev->descriptor.idProduct);if (onoff) {
Greg Kroah-Hartman
maintainerPATCH 18/32 ALSA: seq: Use bool for snd_seq_queue internal flags
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 4ebd47037027c4beae99680bff3b20fdee5d7c1e upstream.
The snd_seq_queue struct contains various flags in the bit fields. Those are categorized to two different use cases, both of which are protected by different spinlocks. That implies that there are still potential risks of the bad operations for bit fields by concurrent accesses.
For addressing the problem, this patch rearranges those flags to be a standard bool instead of a bit field.
--- sound/core/seq/seq_queue.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/core/seq/seq_queue.h +4 -4
@@ -40,10 +40,10 @@ struct snd_seq_queue {struct snd_seq_timer *timer;/* time keeper for this queue */ int owner;/* client that 'owns' the timer */ - unsigned int locked:1, /* timer is only accesibble by owner if set */ - klocked:1, /* kernel lock (after START) */ - check_again:1, - check_blocked:1; +bool locked;/* timer is only accesibble by owner if set */ +bool klocked;/* kernel lock (after START) */ +bool check_again;/* concurrent access happened during check */ +bool check_blocked;/* queue being checked */ unsigned int flags;/* status flags */ unsigned int info_flags;/* info for sync */
Greg Kroah-Hartman
maintainerPATCH 19/32 module: set MODULE_STATE_GOING state when a module fails to load
In reply to Greg Kroah-HartmanFrom: Miroslav Benes <[email protected]>
[ Upstream commit 5e8ed280dab9eeabc1ba0b2db5dbe9fe6debb6b5 ]
If a module fails to load due to an error in prepare_coming_module(), the following error handling in load_module() runs with MODULE_STATE_COMING in module's state. Fix it by correctly setting MODULE_STATE_GOING under "bug_cleanup" label.
--- kernel/module.c | 1 + 1 file changed, 1 insertion(+)
kernel/module.c +1 -0
@@ -3738,6 +3738,7 @@ static int load_module(struct load_info *info, const char __user *uargs, MODULE_STATE_GOING, mod);klp_module_going (mod); bug_cleanup: + mod->state =MODULE_STATE_GOING ;/* module_bug_cleanup needs module_mutex protection */ mutex_lock (&module_mutex);module_bug_cleanup (mod);
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 20/32 quota: Dont overflow quota file offsets
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
[ Upstream commit 10f04d40a9fa29785206c619f80d8beedb778837 ]
The on-disk quota format supports quota files with upto 2^32 blocks. Be careful when computing quota file offsets in the quota files from block numbers as they can overflow 32-bit types. Since quota files larger than 4GB would require ~26 millions of quota users, this is mostly a theoretical concern now but better be careful, fuzzers would find the problem sooner or later anyway...
--- fs/quota/quota_tree.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/quota/quota_tree.c +4 -4
@@ -61,7 +61,7 @@ static ssize_t read_blk(struct qtree_mem_dqinfo *info, uint blk, char *buf)memset (buf,0 , info->dqi_usable_bs);return sb->s_op->quota_read (sb, info->dqi_type, buf, - info->dqi_usable_bs, blk << info->dqi_blocksize_bits); + info->dqi_usable_bs, (loff_t )blk << info->dqi_blocksize_bits); }static ssize_t write_blk (struct qtree_mem_dqinfo *info,uint blk,char *buf)
@@ -70,7 +70,7 @@ static ssize_t write_blk(struct qtree_mem_dqinfo *info, uint blk, char *buf)ssize_t ret; ret = sb->s_op->quota_write (sb, info->dqi_type, buf, - info->dqi_usable_bs, blk << info->dqi_blocksize_bits); + info->dqi_usable_bs, (loff_t )blk << info->dqi_blocksize_bits);if (ret != info->dqi_usable_bs) {quota_error (sb,"dquota write failed" );if (ret >=0 )
@@ -283,7 +283,7 @@ static uint find_free_dqentry(struct qtree_mem_dqinfo *info, blk); goto out_buf; } - dquot->dq_off = (blk << info->dqi_blocksize_bits) + + dquot->dq_off = ((loff_t )blk << info->dqi_blocksize_bits) +sizeof (struct qt_disk_dqdbheader ) + i * info->dqi_entry_size;kfree (buf);
@@ -558,7 +558,7 @@ static loff_t find_block_dqentry(struct qtree_mem_dqinfo *info, ret = -EIO ; goto out_buf; }else { - ret = (blk << info->dqi_blocksize_bits) +sizeof (struct + ret = ((loff_t )blk << info->dqi_blocksize_bits) +sizeof (struct qt_disk_dqdbheader ) + i * info->dqi_entry_size; } out_buf:
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 21/32 powerpc: sysdev: add missing iounmap() on error in mpic_msgr_probe()
In reply to Greg Kroah-HartmanFrom: Qinglang Miao <[email protected]>
[ Upstream commit ffa1797040c5da391859a9556be7b735acbe1242 ]
I noticed that iounmap() of msgr_block_addr before return from mpic_msgr_probe() in the error handling case is missing. So use devm_ioremap() instead of just ioremap() when remapping the message register block, so the mapping will be automatically released on probe failure.
--- arch/powerpc/sysdev/mpic_msgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/sysdev/mpic_msgr.c +1 -1
@@ -196,7 +196,7 @@ static int mpic_msgr_probe(struct platform_device *dev)/* IO map the message register block. */ of_address_to_resource (np,0 , &rsrc); - msgr_block_addr =ioremap (rsrc.start,resource_size (&rsrc)); + msgr_block_addr =devm_ioremap (&dev->dev, rsrc.start,resource_size (&rsrc));if (!msgr_block_addr) {dev_err (&dev->dev,"Failed to iomap MPIC message registers" );return -EFAULT ;
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 22/32 module: delay kobject uevent until after module init call
In reply to Greg Kroah-HartmanFrom: Jessica Yu <[email protected]>
[ Upstream commit 38dc717e97153e46375ee21797aa54777e5498f3 ]
Apparently there has been a longstanding race between udev/systemd and the module loader. Currently, the module loader sends a uevent right after sysfs initialization, but before the module calls its init function. However, some udev rules expect that the module has initialized already upon receiving the uevent.
This race has been triggered recently (see link in references) in some systemd mount unit files. For instance, the configfs module creates the /sys/kernel/config mount point in its init function, however the module loader issues the uevent before this happens. sys-kernel-config.mount expects to be able to mount /sys/kernel/config upon receipt of the module loading uevent, but if the configfs module has not called its init function yet, then this directory will not exist and the mount unit fails. A similar situation exists for sys-fs-fuse-connections.mount, as the fuse sysfs mount point is created during the fuse module's init function. If udev is faster than module initialization then the mount unit would fail in a similar fashion.
To fix this race, delay the module KOBJ_ADD uevent until after the module has finished calling its init routine.
--- kernel/module.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/module.c +3 -2
@@ -1762,7 +1762,6 @@ static int mod_sysfs_init(struct module *mod)if (err)mod_kobject_put (mod); -/* delay uevent until full sysfs population */ out:return err; }
@@ -1796,7 +1795,6 @@ static int mod_sysfs_setup(struct module *mod,add_sect_attrs (mod, info);add_notes_attrs (mod, info); -kobject_uevent (&mod->mkobj.kobj,KOBJ_ADD );return 0 ; out_unreg_param:
@@ -3427,6 +3425,9 @@ static noinline int do_init_module(struct module *mod)blocking_notifier_call_chain (&module_notify_list,MODULE_STATE_LIVE , mod); +/* Delay uevent until module has finished its init routine */ +kobject_uevent (&mod->mkobj.kobj,KOBJ_ADD ); +/* * We need to finish all async code before the module init sequence * is done. This has potential to deadlock. For example, a newly
Signature · 1 line
2.27.0
Greg Kroah-Hartman
maintainerPATCH 23/32 kdev_t: always inline major/minor helper functions
In reply to Greg Kroah-HartmanFrom: Josh Poimboeuf <[email protected]>
commit aa8c7db494d0a83ecae583aa193f1134ef25d506 upstream.
Silly GCC doesn't always inline these trivial functions.
Fixes the following warning:
arch/x86/kernel/sys_ia32.o: warning: objtool: cp_stat64()+0xd8: call to new_encode_dev() with UACCESS enabled
--- include/linux/kdev_t.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
include/linux/kdev_t.h +11 -11
@@ -20,61 +20,61 @@ })/* acceptable for old filesystems */ -static inline bool old_valid_dev (dev_t dev) +static __always_inline bool old_valid_dev(dev_t dev) {return MAJOR (dev) <256 &&MINOR (dev) <256 ; } -static inline u16 old_encode_dev (dev_t dev) +static __always_inline u16 old_encode_dev(dev_t dev) {return (MAJOR (dev) <<8 ) |MINOR (dev); } -static inline dev_t old_decode_dev (u16 val) +static __always_inline dev_t old_decode_dev(u16 val) {return MKDEV ((val >>8 ) &255 , val &255 ); } -static inline u32 new_encode_dev (dev_t dev) +static __always_inline u32 new_encode_dev(dev_t dev) {unsigned major =MAJOR (dev);unsigned minor =MINOR (dev);return (minor &0xff ) | (major <<8 ) | ((minor & ~0xff ) <<12 ); } -static inline dev_t new_decode_dev (u32 dev) +static __always_inline dev_t new_decode_dev(u32 dev) {unsigned major = (dev &0xfff00 ) >>8 ;unsigned minor = (dev &0xff ) | ((dev >>12 ) &0xfff00 );return MKDEV (major, minor); } -static inline u64 huge_encode_dev (dev_t dev) +static __always_inline u64 huge_encode_dev(dev_t dev) {return new_encode_dev (dev); } -static inline dev_t huge_decode_dev (u64 dev) +static __always_inline dev_t huge_decode_dev(u64 dev) {return new_decode_dev (dev); } -static inline int sysv_valid_dev (dev_t dev) +static __always_inline int sysv_valid_dev(dev_t dev) {return MAJOR (dev) < (1 <<14 ) &&MINOR (dev) < (1 <<18 ); } -static inline u32 sysv_encode_dev (dev_t dev) +static __always_inline u32 sysv_encode_dev(dev_t dev) {return MINOR (dev) | (MAJOR (dev) <<18 ); } -static inline unsigned sysv_major (u32 dev) +static __always_inline unsigned sysv_major (u32 dev) {return (dev >>18 ) &0x3fff ; } -static inline unsigned sysv_minor (u32 dev) +static __always_inline unsigned sysv_minor (u32 dev) {return dev &0x3ffff ; }
Greg Kroah-Hartman
maintainerPATCH 24/32 xen/xenbus: Allow watches discard events before queueing
In reply to Greg Kroah-HartmanFrom: SeongJae Park <[email protected]>
commit fed1755b118147721f2c87b37b9d66e62c39b668 upstream.
If handling logics of watch events are slower than the events enqueue logic and the events can be created from the guests, the guests could trigger memory pressure by intensively inducing the events, because it will create a huge number of pending events that exhausting the memory.
Fortunately, some watch events could be ignored, depending on its handler callback. For example, if the callback has interest in only one single path, the watch wouldn't want multiple pending events. Or, some watches could ignore events to same path.
To let such watches to volutarily help avoiding the memory pressure situation, this commit introduces new watch callback, 'will_handle'. If it is not NULL, it will be called for each new event just before enqueuing it. Then, if the callback returns false, the event will be discarded. No watch is using the callback for now, though.
This is part of XSA-349
--- drivers/net/xen-netback/xenbus.c | 2 ++ drivers/xen/xenbus/xenbus_client.c | 1 + drivers/xen/xenbus/xenbus_xs.c | 7 ++++++- include/xen/xenbus.h | 7 +++++++ 4 files changed, 16 insertions(+), 1 deletion(-)
drivers/net/xen-netback/xenbus.c +2 -0
@@ -770,12 +770,14 @@ static int xen_register_credit_watch(strreturn -ENOMEM ;snprintf (node, maxlen,"%s/rate" , dev->nodename); vif->credit_watch.node = node; + vif->credit_watch.will_handle =NULL ; vif->credit_watch.callback = xen_net_rate_changed; err =register_xenbus_watch (&vif->credit_watch);if (err) {pr_err ("Failed to set watcher %s\n" , vif->credit_watch.node);kfree (node); vif->credit_watch.node =NULL ; + vif->credit_watch.will_handle =NULL ; vif->credit_watch.callback =NULL ; }return err;
drivers/xen/xenbus/xenbus_client.c +1 -0
@@ -120,6 +120,7 @@ int xenbus_watch_path(struct xenbus_deviint err; watch->node = path; + watch->will_handle =NULL ; watch->callback = callback; err =register_xenbus_watch (watch);
drivers/xen/xenbus/xenbus_xs.c +6 -1
@@ -901,7 +901,12 @@ static int process_msg(void)spin_lock (&watches_lock); msg->u.watch.handle =find_watch ( msg->u.watch.vec[XS_WATCH_TOKEN ]); -if (msg->u.watch.handle !=NULL ) { +if (msg->u.watch.handle !=NULL && + (!msg->u.watch.handle->will_handle || + msg->u.watch.handle->will_handle ( + msg->u.watch.handle, + (const char **)msg->u.watch.vec, + msg->u.watch.vec_size))) {spin_lock (&watch_events_lock);list_add_tail (&msg->list, &watch_events);wake_up (&watch_events_waitq);
include/xen/xenbus.h +7 -0
@@ -58,6 +58,13 @@ struct xenbus_watch/* Path being watched. */ const char *node; +/* +* Called just before enqueing new event while a spinlock is held. +* The event will be discarded if this callback returns false. +*/ +bool (*will_handle)(struct xenbus_watch *, +const char **vec,unsigned int len); +/* Callback (executed in a process context with no locks held). */ void (*callback)(struct xenbus_watch *,const char **vec,unsigned int len);
Greg Kroah-Hartman
maintainerPATCH 25/32 xen/xenbus: Add will_handle callback support in xenbus_watch_path()
In reply to Greg Kroah-HartmanFrom: SeongJae Park <[email protected]>
commit 2e85d32b1c865bec703ce0c962221a5e955c52c2 upstream.
Some code does not directly make 'xenbus_watch' object and call 'register_xenbus_watch()' but use 'xenbus_watch_path()' instead. This commit adds support of 'will_handle' callback in the 'xenbus_watch_path()' and it's wrapper, 'xenbus_watch_pathfmt()'.
This is part of XSA-349
--- drivers/block/xen-blkback/xenbus.c | 3 ++- drivers/net/xen-netback/xenbus.c | 2 +- drivers/xen/xen-pciback/xenbus.c | 2 +- drivers/xen/xenbus/xenbus_client.c | 9 +++++++-- drivers/xen/xenbus/xenbus_probe.c | 2 +- include/xen/xenbus.h | 6 +++++- 6 files changed, 17 insertions(+), 7 deletions(-)
drivers/block/xen-blkback/xenbus.c +2 -1
@@ -646,7 +646,8 @@ static int xen_blkbk_probe(struct xenbus/* setup back pointer */ be->blkif->be = be; - err =xenbus_watch_pathfmt (dev, &be->backend_watch, backend_changed, + err =xenbus_watch_pathfmt (dev, &be->backend_watch,NULL , + backend_changed,"%s/%s" , dev->nodename,"physical-device" );if (err) goto fail;
drivers/net/xen-netback/xenbus.c +1 -1
@@ -1040,7 +1040,7 @@ static void connect(struct backend_infoxenvif_carrier_on (be->vif);unregister_hotplug_status_watch (be); - err =xenbus_watch_pathfmt (dev, &be->hotplug_status_watch, + err =xenbus_watch_pathfmt (dev, &be->hotplug_status_watch,NULL , hotplug_status_changed,"%s/%s" , dev->nodename,"hotplug-status" );if (!err)
drivers/xen/xen-pciback/xenbus.c +1 -1
@@ -689,7 +689,7 @@ static int xen_pcibk_xenbus_probe(struct/* watch the backend node for backend configuration information */ err =xenbus_watch_path (dev, dev->nodename, &pdev->be_watch, - xen_pcibk_be_watch); +NULL , xen_pcibk_be_watch);if (err) goto out;
drivers/xen/xenbus/xenbus_client.c +7 -2
@@ -114,19 +114,22 @@ EXPORT_SYMBOL_GPL(xenbus_strstate);*/ int xenbus_watch_path (struct xenbus_device *dev,const char *path,struct xenbus_watch *watch, +bool (*will_handle)(struct xenbus_watch *, +const char **,unsigned int ),void (*callback)(struct xenbus_watch *,const char **,unsigned int )) {int err; watch->node = path; - watch->will_handle =NULL ; + watch->will_handle = will_handle; watch->callback = callback; err =register_xenbus_watch (watch);if (err) { watch->node =NULL ; + watch->will_handle =NULL ; watch->callback =NULL ;xenbus_dev_fatal (dev, err,"adding watch on %s" , path); }
@@ -153,6 +156,8 @@ EXPORT_SYMBOL_GPL(xenbus_watch_path);*/ int xenbus_watch_pathfmt (struct xenbus_device *dev,struct xenbus_watch *watch, +bool (*will_handle)(struct xenbus_watch *, +const char **,unsigned int ),void (*callback)(struct xenbus_watch *,const char **,unsigned int ),const char *pathfmt, ...)
@@ -169,7 +174,7 @@ int xenbus_watch_pathfmt(struct xenbus_dxenbus_dev_fatal (dev, -ENOMEM ,"allocating path for watch" );return -ENOMEM ; } - err =xenbus_watch_path (dev, path, watch, callback); + err =xenbus_watch_path (dev, path, watch, will_handle, callback);if (err)kfree (path);
drivers/xen/xenbus/xenbus_probe.c +1 -1
@@ -137,7 +137,7 @@ static int watch_otherend(struct xenbus_ container_of(dev->dev.bus, struct xen_bus_type, bus);return xenbus_watch_pathfmt (dev, &dev->otherend_watch, - bus->otherend_changed, +NULL , bus->otherend_changed,"%s/%s" , dev->otherend,"state" ); }
include/xen/xenbus.h +5 -1
@@ -201,10 +201,14 @@ void xenbus_suspend_cancel(void);int xenbus_watch_path (struct xenbus_device *dev,const char *path,struct xenbus_watch *watch, +bool (*will_handle)(struct xenbus_watch *, +const char **,unsigned int ),void (*callback)(struct xenbus_watch *,const char **,unsigned int )); -__printf(4, 5) +__printf(5, 6)int xenbus_watch_pathfmt (struct xenbus_device *dev,struct xenbus_watch *watch, +bool (*will_handle)(struct xenbus_watch *, +const char **,unsigned int ),void (*callback)(struct xenbus_watch *,const char **,unsigned int ),const char *pathfmt, ...);
Greg Kroah-Hartman
maintainerPATCH 26/32 xen/xenbus/xen_bus_type: Support will_handle watch callback
In reply to Greg Kroah-HartmanFrom: SeongJae Park <[email protected]>
commit be987200fbaceaef340872841d4f7af2c5ee8dc3 upstream.
This commit adds support of the 'will_handle' watch callback for 'xen_bus_type' users.
This is part of XSA-349
--- drivers/xen/xenbus/xenbus_probe.c | 3 ++- drivers/xen/xenbus/xenbus_probe.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/xen/xenbus/xenbus_probe.c +2 -1
@@ -137,7 +137,8 @@ static int watch_otherend(struct xenbus_ container_of(dev->dev.bus, struct xen_bus_type, bus);return xenbus_watch_pathfmt (dev, &dev->otherend_watch, -NULL , bus->otherend_changed, + bus->otherend_will_handle, + bus->otherend_changed,"%s/%s" , dev->otherend,"state" ); }
drivers/xen/xenbus/xenbus_probe.h +2 -0
@@ -42,6 +42,8 @@ struct xen_bus_type {int (*get_bus_id)(char bus_id[XEN_BUS_ID_SIZE ],const char *nodename);int (*probe)(struct xen_bus_type *bus,const char *type,const char *dir); +bool (*otherend_will_handle)(struct xenbus_watch *watch, +const char **vec,unsigned int len);void (*otherend_changed)(struct xenbus_watch *watch,const char **vec,unsigned int len);struct bus_type bus;
Greg Kroah-Hartman
maintainerPATCH 27/32 xen/xenbus: Count pending messages for each watch
In reply to Greg Kroah-HartmanFrom: SeongJae Park <[email protected]>
commit 3dc86ca6b4c8cfcba9da7996189d1b5a358a94fc upstream.
This commit adds a counter of pending messages for each watch in the struct. It is used to skip unnecessary pending messages lookup in 'unregister_xenbus_watch()'. It could also be used in 'will_handle' callback.
This is part of XSA-349
--- drivers/xen/xenbus/xenbus_xs.c | 31 +++++++++++++++++++------------ include/xen/xenbus.h | 2 ++ 2 files changed, 21 insertions(+), 12 deletions(-)
drivers/xen/xenbus/xenbus_xs.c +19 -12
@@ -699,6 +699,8 @@ int register_xenbus_watch(struct xenbus_sprintf (token,"%lX" , (long )watch); + watch->nr_pending =0 ; +down_read (&xs_state.watch_mutex);spin_lock (&watches_lock);
@@ -748,12 +750,15 @@ void unregister_xenbus_watch(struct xenb/* Cancel pending watch events. */ spin_lock (&watch_events_lock); -list_for_each_entry_safe (msg, tmp, &watch_events, list) { -if (msg->u.watch.handle != watch) -continue ; -list_del (&msg->list); -kfree (msg->u.watch.vec); -kfree (msg); +if (watch->nr_pending) { +list_for_each_entry_safe (msg, tmp, &watch_events, list) { +if (msg->u.watch.handle != watch) +continue ; +list_del (&msg->list); +kfree (msg->u.watch.vec); +kfree (msg); + } + watch->nr_pending =0 ; }spin_unlock (&watch_events_lock);
@@ -800,7 +805,6 @@ void xs_suspend_cancel(void)static int xenwatch_thread (void *unused) { -struct list_head *ent;struct xs_stored_msg *msg;for (;;) {
@@ -813,13 +817,15 @@ static int xenwatch_thread(void *unused)mutex_lock (&xenwatch_mutex);spin_lock (&watch_events_lock); - ent = watch_events.next; -if (ent != &watch_events) -list_del (ent); + msg =list_first_entry_or_null (&watch_events, + struct xs_stored_msg, list); +if (msg) { +list_del (&msg->list); + msg->u.watch.handle->nr_pending--; + }spin_unlock (&watch_events_lock); -if (ent != &watch_events) { - msg = list_entry(ent, struct xs_stored_msg, list); +if (msg) { msg->u.watch.handle->callback( msg->u.watch.handle, (const char **)msg->u.watch.vec,
@@ -909,6 +915,7 @@ static int process_msg(void) msg->u.watch.vec_size))) { spin_lock(&watch_events_lock); list_add_tail(&msg->list, &watch_events); + msg->u.watch.handle->nr_pending++; wake_up(&watch_events_waitq); spin_unlock(&watch_events_lock); } else {
include/xen/xenbus.h +2 -0
@@ -58,6 +58,8 @@ struct xenbus_watch/* Path being watched. */ const char *node; +unsigned int nr_pending; +/* * Called just before enqueing new event while a spinlock is held. * The event will be discarded if this callback returns false.
Greg Kroah-Hartman
maintainerPATCH 28/32 xenbus/xenbus_backend: Disallow pending watch messages
In reply to Greg Kroah-HartmanFrom: SeongJae Park <[email protected]>
commit 9996bd494794a2fe393e97e7a982388c6249aa76 upstream.
'xenbus_backend' watches 'state' of devices, which is writable by guests. Hence, if guests intensively updates it, dom0 will have lots of pending events that exhausting memory of dom0. In other words, guests can trigger dom0 memory pressure. This is known as XSA-349. However, the watch callback of it, 'frontend_changed()', reads only 'state', so doesn't need to have the pending events.
To avoid the problem, this commit disallows pending watch messages for 'xenbus_backend' using the 'will_handle()' watch callback.
This is part of XSA-349
--- drivers/xen/xenbus/xenbus_probe_backend.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/xen/xenbus/xenbus_probe_backend.c +7 -0
@@ -181,6 +181,12 @@ static int xenbus_probe_backend(struct xreturn err; } +static bool frontend_will_handle (struct xenbus_watch *watch, +const char **vec,unsigned int len) +{ +return watch->nr_pending ==0 ; +} +static void frontend_changed (struct xenbus_watch *watch,const char **vec,unsigned int len) {
@@ -192,6 +198,7 @@ static struct xen_bus_type xenbus_backen .levels = 3, /* backend/type/<frontend>/<id> */ .get_bus_id = backend_bus_id, .probe = xenbus_probe_backend, + .otherend_will_handle = frontend_will_handle, .otherend_changed = frontend_changed, .bus = { .name = "xen-backend",
Greg Kroah-Hartman
maintainerPATCH 29/32 iio: bmi160_core: Fix sparse warning due to incorrect type in assignment
In reply to Greg Kroah-HartmanFrom: sayli karnik <[email protected]>
commit dd4ba3fb22233e69f06399ee0aa7ecb11d2b595c upstream
There is a type mismatch between the buffer which is of type s16 and the samples stored, which are declared as __le16.
Fix the following sparse warning:drivers/iio/imu/bmi160/bmi160_core.c:411:26: warning: incorrect type in assignment (different base types)
drivers/iio/imu/bmi160/bmi160_core.c:411:26: expected signed short [signed] [short] [explicitly-signed] <noident> drivers/iio/imu/bmi160/bmi160_core.c:411:26: got restricted __le16 [addressable] [usertype] sample
This is a cosmetic-type patch since it does not alter code behaviour. The le16 is going into a 16bit buf element, and is labelled as IIO_LE in the channel buffer definition.
--- drivers/iio/imu/bmi160/bmi160_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/imu/bmi160/bmi160_core.c +2 -1
@@ -385,7 +385,8 @@ static irqreturn_t bmi160_trigger_handlestruct iio_poll_func *pf = p;struct iio_dev *indio_dev = pf->indio_dev;struct bmi160_data *data =iio_priv (indio_dev); -s16 buf[16 ];/* 3 sens x 3 axis x s16 + 3 x s16 pad + 4 x s16 tstamp */ +__le16 buf[16 ]; +/* 3 sens x 3 axis x __le16 + 3 x __le16 pad + 4 x __le16 tstamp */ int i, ret, j =0 , base =BMI160_REG_DATA_MAGN_XOUT_L ;__le16 sample;
Greg Kroah-Hartman
maintainerPATCH 30/32 iio:imu:bmi160: Fix too large a buffer.
In reply to Greg Kroah-HartmanFrom: Jonathan Cameron <[email protected]>
commit dc7de42d6b50a07b37feeba4c6b5136290fcee81 upstream.
The comment implies this device has 3 sensor types, but it only has an accelerometer and a gyroscope (both 3D). As such the buffer does not need to be as long as stated.
Note I've separated this from the following patch which fixes the alignment for passing to iio_push_to_buffers_with_timestamp() as they are different issues even if they affect the same line of code.
--- drivers/iio/imu/bmi160/bmi160_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/imu/bmi160/bmi160_core.c +2 -2
@@ -385,8 +385,8 @@ static irqreturn_t bmi160_trigger_handlestruct iio_poll_func *pf = p;struct iio_dev *indio_dev = pf->indio_dev;struct bmi160_data *data =iio_priv (indio_dev); -__le16 buf[16 ]; -/* 3 sens x 3 axis x __le16 + 3 x __le16 pad + 4 x __le16 tstamp */ +__le16 buf[12 ]; +/* 2 sens x 3 axis x __le16 + 2 x __le16 pad + 4 x __le16 tstamp */ int i, ret, j =0 , base =BMI160_REG_DATA_MAGN_XOUT_L ;__le16 sample;
Greg Kroah-Hartman
maintainerPATCH 31/32 iio:imu:bmi160: Fix alignment and data leak issues
In reply to Greg Kroah-HartmanFrom: Jonathan Cameron <[email protected]>
commit 7b6b51234df6cd8b04fe736b0b89c25612d896b8 upstream
One of a class of bugs pointed out by Lars in a recent review. iio_push_to_buffers_with_timestamp assumes the buffer used is aligned to the size of the timestamp (8 bytes). This is not guaranteed in this driver which uses an array of smaller elements on the stack. As Lars also noted this anti pattern can involve a leak of data to userspace and that indeed can happen here. We close both issues by moving to a suitable array in the iio_priv() data with alignment explicitly requested. This data is allocated with kzalloc() so no data can leak apart from previous readings.
In this driver, depending on which channels are enabled, the timestamp can be in a number of locations. Hence we cannot use a structure to specify the data layout without it being misleading.
--- drivers/iio/imu/bmi160/bmi160_core.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/iio/imu/bmi160/bmi160_core.c +9 -4
@@ -110,6 +110,13 @@ enum bmi160_sensor_type {struct bmi160_data {struct regmap *regmap; +/* +* Ensure natural alignment for timestamp if present. +* Max length needed: 2 * 3 channels + 4 bytes padding + 8 byte ts. +* If fewer channels are enabled, less space may be needed, as +* long as the timestamp is still aligned to 8 bytes. +*/ +__le16 buf[12 ]__aligned(8) ; };const struct regmap_config bmi160_regmap_config = {
@@ -385,8 +392,6 @@ static irqreturn_t bmi160_trigger_handlestruct iio_poll_func *pf = p;struct iio_dev *indio_dev = pf->indio_dev;struct bmi160_data *data =iio_priv (indio_dev); -__le16 buf[12 ]; -/* 2 sens x 3 axis x __le16 + 2 x __le16 pad + 4 x __le16 tstamp */ int i, ret, j =0 , base =BMI160_REG_DATA_MAGN_XOUT_L ;__le16 sample;
@@ -396,10 +401,10 @@ static irqreturn_t bmi160_trigger_handle &sample, sizeof(__le16));if (ret <0 ) goto done; - buf[j++] = sample; + data->buf[j++] = sample; } -iio_push_to_buffers_with_timestamp (indio_dev, buf, +iio_push_to_buffers_with_timestamp (indio_dev, data->buf,iio_get_time_ns (indio_dev)); done:iio_trigger_notify_done (indio_dev->trig);
Greg Kroah-Hartman
maintainerPATCH 32/32 iio:magnetometer:mag3110: Fix alignment and data leak issues.
In reply to Greg Kroah-HartmanFrom: Jonathan Cameron <[email protected]>
commit 89deb1334252ea4a8491d47654811e28b0790364 upstream
One of a class of bugs pointed out by Lars in a recent review. iio_push_to_buffers_with_timestamp() assumes the buffer used is aligned to the size of the timestamp (8 bytes). This is not guaranteed in this driver which uses an array of smaller elements on the stack. As Lars also noted this anti pattern can involve a leak of data to userspace and that indeed can happen here. We close both issues by moving to a suitable structure in the iio_priv() data.
This data is allocated with kzalloc() so no data can leak apart from previous readings.
The explicit alignment of ts is not necessary in this case but does make the code slightly less fragile so I have included it.
--- drivers/iio/magnetometer/mag3110.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/iio/magnetometer/mag3110.c +9 -4
@@ -52,6 +52,12 @@ struct mag3110_data {struct i2c_client *client;struct mutex lock;u8 ctrl_reg1; +/* Ensure natural alignment of timestamp */ +struct { +__be16 channels[3 ]; +u8 temperature; +s64 ts__aligned(8) ; + } scan; };static int mag3110_request (struct mag3110_data *data)
@@ -262,10 +268,9 @@ static irqreturn_t mag3110_trigger_handlstruct iio_poll_func *pf = p;struct iio_dev *indio_dev = pf->indio_dev;struct mag3110_data *data =iio_priv (indio_dev); -u8 buffer[16 ];/* 3 16-bit channels + 1 byte temp + padding + ts */ int ret; - ret =mag3110_read (data, (__be16 *) buffer); + ret =mag3110_read (data, data->scan.channels);if (ret <0 ) goto done;
@@ -274,10 +279,10 @@ static irqreturn_t mag3110_trigger_handl MAG3110_DIE_TEMP);if (ret <0 ) goto done; - buffer[6 ] = ret; + data->scan.temperature = ret; } -iio_push_to_buffers_with_timestamp (indio_dev, buffer, +iio_push_to_buffers_with_timestamp (indio_dev, &data->scan,iio_get_time_ns (indio_dev)); done: