drm/amdgpu: remove set but not used variable 'mc_shared_chmap' from 'gfx_v6_0.c' and 'gfx_v7_0.c'
Subsystems (65)
Sasha Levin
maintainerPATCH 436/542 driver core: platform: fix u32 greater or equal to zero comparison
In reply to Sasha LevinFrom: Colin Ian King <[email protected]>
[ Upstream commit 0707cfa5c3ef58effb143db9db6d6e20503f9dec ]
Currently the check that a u32 variable i is >= 0 is always true because the unsigned variable will never be negative, causing the loop to run forever. Fix this by changing the pre-decrement check to a zero check on i followed by a decrement of i.
Addresses-Coverity: ("Unsigned compared against 0")
--- drivers/base/platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/platform.c +1 -1
@@ -571,7 +571,7 @@ int platform_device_add(struct platform_device *pdev) pdev->id =PLATFORM_DEVID_AUTO ; } -while (--i >=0 ) { +while (i--) {struct resource *r = &pdev->resource[i];if (r->parent)release_resource (r);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 437/542 platform/x86: intel_mid_powerbtn: Take a copy of ddata
In reply to Sasha LevinFrom: Mika Westerberg <[email protected]>
[ Upstream commit 5e0c94d3aeeecc68c573033f08d9678fecf253bd ]
The driver gets driver_data from memory that is marked as const (which is probably put to read-only memory) and it then modifies it. This likely causes some sort of fault to happen.
Fix this by taking a copy of the structure.
--- drivers/platform/x86/intel_mid_powerbtn.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/platform/x86/intel_mid_powerbtn.c +3 -2
@@ -146,9 +146,10 @@ static int mid_pb_probe(struct platform_device *pdev)input_set_capability (input,EV_KEY ,KEY_POWER ); - ddata = (struct mid_pb_ddata *)id->driver_data; + ddata =devm_kmemdup (&pdev->dev, (void *)id->driver_data, +sizeof (*ddata),GFP_KERNEL );if (!ddata) -return -ENODATA ; +return -ENOMEM ; ddata->dev = &pdev->dev; ddata->irq = irq;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 438/542 bpf, btf: Always output invariant hit in pahole DWARF to BTF transform
In reply to Sasha LevinFrom: Chris Down <[email protected]>
[ Upstream commit 2a67a6ccb01f21b854715d86ff6432a18b97adb3 ]
When trying to compile with CONFIG_DEBUG_INFO_BTF enabled, I got this error:
% make -s
Failed to generate BTF for vmlinux
Try to disable CONFIG_DEBUG_INFO_BTF
make[3]: *** [vmlinux] Error 1
Compiling again without -s shows the true error (that pahole is missing), but since this is fatal, we should show the error unconditionally on stderr as well, not silence it using the info function. With this patch:
% make -s
BTF: .tmp_vmlinux.btf: pahole (pahole) is not available Failed to generate BTF for vmlinux
Try to disable CONFIG_DEBUG_INFO_BTF
make[3]: *** [vmlinux] Error 1
--- scripts/link-vmlinux.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/link-vmlinux.sh +2 -2
@@ -108,13 +108,13 @@ gen_btf() local bin_arch if ! [ -x "$(command -v ${PAHOLE})" ]; then - info "BTF" "${1}: pahole (${PAHOLE}) is not available" + echo >&2 "BTF: ${1}: pahole (${PAHOLE}) is not available" return 1 fi pahole_ver=$(${PAHOLE} --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/') if [ "${pahole_ver}" -lt "113" ]; then - info "BTF" "${1}: pahole version $(${PAHOLE} --version) is too old, need at least v1.13" + echo >&2 "BTF: ${1}: pahole version $(${PAHOLE} --version) is too old, need at least v1.13" return 1 fi
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 439/542 ALSA: hda - Add docking station support for Lenovo Thinkpad T420s
In reply to Sasha LevinFrom: Peter Große <[email protected]>
[ Upstream commit ef7d84caa5928b40b1c93a26dbe5a3f12737c6ab ]
Lenovo Thinkpad T420s uses the same codec as T420, so apply the same quirk to enable audio output on a docking station.
--- sound/pci/hda/patch_conexant.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_conexant.c +1 -0
@@ -922,6 +922,7 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {SND_PCI_QUIRK (0x17aa ,0x215f ,"Lenovo T510" ,CXT_PINCFG_LENOVO_TP410 ),SND_PCI_QUIRK (0x17aa ,0x21ce ,"Lenovo T420" ,CXT_PINCFG_LENOVO_TP410 ),SND_PCI_QUIRK (0x17aa ,0x21cf ,"Lenovo T520" ,CXT_PINCFG_LENOVO_TP410 ), +SND_PCI_QUIRK (0x17aa ,0x21d2 ,"Lenovo T420s" ,CXT_PINCFG_LENOVO_TP410 ),SND_PCI_QUIRK (0x17aa ,0x21da ,"Lenovo X220" ,CXT_PINCFG_LENOVO_TP410 ),SND_PCI_QUIRK (0x17aa ,0x21db ,"Lenovo X220-tablet" ,CXT_PINCFG_LENOVO_TP410 ), SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo IdeaPad Z560", CXT_FIXUP_MUTE_LED_EAPD),
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 440/542 sunrpc: Fix potential leaks in sunrpc_cache_unhash()
In reply to Sasha LevinFrom: Trond Myklebust <[email protected]>
[ Upstream commit 1d82163714c16ebe09c7a8c9cd3cef7abcc16208 ]
When we unhash the cache entry, we need to handle any pending upcalls by calling cache_fresh_unlocked().
--- net/sunrpc/cache.c | 2 ++ 1 file changed, 2 insertions(+)
net/sunrpc/cache.c +2 -0
@@ -1888,7 +1888,9 @@ void sunrpc_cache_unhash(struct cache_detail *cd, struct cache_head *h)if (!hlist_unhashed (&h->cache_list)){hlist_del_init_rcu (&h->cache_list); cd->entries--; +set_bit (CACHE_CLEANED , &h->flags);spin_unlock (&cd->hash_lock); +cache_fresh_unlocked (h, cd);cache_put (h, cd); }else spin_unlock (&cd->hash_lock);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 441/542 drm/nouveau/mmu: fix comptag memory leak
In reply to Sasha LevinFrom: Ben Skeggs <[email protected]>
[ Upstream commit 35e4909b6a2b4005ced3c4238da60d926b78fdea ]
--- drivers/gpu/drm/nouveau/nvkm/core/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nvkm/core/memory.c +1 -1
@@ -91,8 +91,8 @@ nvkm_memory_tags_get(struct nvkm_memory *memory, struct nvkm_device *device, }refcount_set (&tags->refcount,1 ); + *ptags = memory->tags = tags;mutex_unlock (&fb->subdev.mutex); - *ptags = tags;return 0 ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 442/542 drm/nouveau/kms/nv50: remove set but not unused variable 'nv_connector'
In reply to Sasha LevinFrom: YueHaibing <[email protected]>
[ Upstream commit 39496368ba96b40b1dca07315418e473998eef15 ]
drivers/gpu/drm/nouveau/dispnv50/disp.c: In function nv50_pior_enable:drivers/gpu/drm/nouveau/dispnv50/disp.c:1672:28: warning:
variable nv_connector set but not used [-Wunused-but-set-variable]
commit ac2d9275f371 ("drm/nouveau/kms/nv50-: Store the bpc we're using in nv50_head_atom") left behind this.
--- drivers/gpu/drm/nouveau/dispnv50/disp.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/nouveau/dispnv50/disp.c +0 -2
@@ -1673,7 +1673,6 @@ nv50_pior_enable(struct drm_encoder *encoder) {struct nouveau_encoder *nv_encoder =nouveau_encoder (encoder);struct nouveau_crtc *nv_crtc =nouveau_crtc (encoder->crtc); -struct nouveau_connector *nv_connector;struct nv50_head_atom *asyh =nv50_head_atom (nv_crtc->base.state);struct nv50_core *core =nv50_disp (encoder->dev)->core;u8 owner =1 << nv_crtc->index;
@@ -1681,7 +1680,6 @@ nv50_pior_enable(struct drm_encoder *encoder)nv50_outp_acquire (nv_encoder); - nv_connector =nouveau_encoder_connector_get (nv_encoder);switch (asyh->or.bpc) {case 10 : asyh->or.depth =0x6 ;break ;case 8 : asyh->or.depth =0x5 ;break ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 443/542 net/mlx5e: Fix printk format warning
In reply to Sasha LevinFrom: Olof Johansson <[email protected]>
[ Upstream commit ca9c74ae9be5e78541c2058db9a754947a7d4a9b ]
Use "%zu" for size_t. Seen on ARM allmodconfig:
drivers/net/ethernet/mellanox/mlx5/core/wq.c: In function 'mlx5_wq_cyc_wqe_dump':include/linux/kern_levels.h:5:18: warning: format '%ld' expects argument of type 'long int', but argument 5 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
--- drivers/net/ethernet/mellanox/mlx5/core/wq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/wq.c +1 -1
@@ -89,7 +89,7 @@ void mlx5_wq_cyc_wqe_dump(struct mlx5_wq_cyc *wq, u16 ix, u8 nstrides) len = nstrides << wq->fbc.log_stride; wqe =mlx5_wq_cyc_get_wqe (wq, ix); -pr_info ("WQE DUMP: WQ size %d WQ cur size %d, WQE index 0x%x, len: %ld\n" , +pr_info ("WQE DUMP: WQ size %d WQ cur size %d, WQE index 0x%x, len: %zu\n" ,mlx5_wq_cyc_get_size (wq), wq->cur_sz, ix, len);print_hex_dump (KERN_WARNING ,"" ,DUMP_PREFIX_OFFSET ,16 ,1 , wqe, len, false); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 444/542 powerpc/ptdump: Fix W+X verification call in mark_rodata_ro()
In reply to Sasha LevinFrom: Christophe Leroy <[email protected]>
[ Upstream commit e26ad936dd89d79f66c2b567f700e0c2a7103070 ]
ptdump_check_wx() also have to be called when pages are mapped by blocks.
--- arch/powerpc/mm/pgtable_32.c | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/mm/pgtable_32.c +1 -0
@@ -218,6 +218,7 @@ void mark_rodata_ro(void)if (v_block_mapped ((unsigned long )_sinittext)) {mmu_mark_rodata_ro (); +ptdump_check_wx ();return ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 445/542 powerpc/ptdump: Only enable PPC_CHECK_WX with STRICT_KERNEL_RWX
In reply to Sasha LevinFrom: Christophe Leroy <[email protected]>
[ Upstream commit f509247b08f2dcf7754d9ed85ad69a7972aa132b ]
ptdump_check_wx() is called from mark_rodata_ro() which only exists when CONFIG_STRICT_KERNEL_RWX is selected.
--- arch/powerpc/Kconfig.debug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/Kconfig.debug +1 -1
@@ -371,7 +371,7 @@ config PPC_PTDUMP config PPC_DEBUG_WX bool "Warn on W+X mappings at boot" - depends on PPC_PTDUMP + depends on PPC_PTDUMP && STRICT_KERNEL_RWX help Generate a warning if any W+X mappings are found at boot.
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 446/542 powerpc/sriov: Remove VF eeh_dev state when disabling SR-IOV
In reply to Sasha LevinFrom: Oliver O'Halloran <[email protected]>
[ Upstream commit 1fb4124ca9d456656a324f1ee29b7bf942f59ac8 ]
When disabling virtual functions on an SR-IOV adapter we currently do not correctly remove the EEH state for the now-dead virtual functions. When removing the pci_dn that was created for the VF when SR-IOV was enabled we free the corresponding eeh_dev without removing it from the child device list of the eeh_pe that contained it. This can result in crashes due to the use-after-free.
--- arch/powerpc/kernel/pci_dn.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
arch/powerpc/kernel/pci_dn.c +14 -1
@@ -244,9 +244,22 @@ void remove_dev_pci_data(struct pci_dev *pdev)continue ;#ifdef CONFIG_EEH -/* Release EEH device for the VF */ +/* +* Release EEH state for this VF. The PCI core +* has already torn down the pci_dev for this VF, but +* we're responsible to removing the eeh_dev since it +* has the same lifetime as the pci_dn that spawned it. +*/ edev =pdn_to_eeh_dev (pdn);if (edev) { +/* +* We allocate pci_dn's for the totalvfs count, +* but only only the vfs that were activated +* have a configured PE. +*/ +if (edev->pe) +eeh_rmv_from_parent_pe (edev); + pdn->edev =NULL ;kfree (edev); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 447/542 media: uvcvideo: Add a quirk to force GEO GC6500 Camera bits-per-pixel value
In reply to Sasha LevinFrom: Sergey Zakharchenko <[email protected]>
[ Upstream commit 1dd2e8f942574e2be18374ebb81751082d8d467c ]
This device does not function correctly in raw mode in kernel versions validating buffer sizes in bulk mode. It erroneously announces 16 bits per pixel instead of 12 for NV12 format, so it needs this quirk to fix computed frame size and avoid legitimate frames getting discarded.
[Move info and div variables to local scope]
--- drivers/media/usb/uvc/uvc_driver.c | 25 +++++++++++++++++++++++++ drivers/media/usb/uvc/uvcvideo.h | 1 + 2 files changed, 26 insertions(+)
drivers/media/usb/uvc/uvc_driver.c +25 -0
@@ -497,6 +497,22 @@ static int uvc_parse_format(struct uvc_device *dev, } } +/* Some devices report bpp that doesn't match the format. */ +if (dev->quirks &UVC_QUIRK_FORCE_BPP ) { +const struct v4l2_format_info *info = +v4l2_format_info (format->fcc); + +if (info) { +unsigned int div = info->hdiv * info->vdiv; + + n = info->bpp[0 ] * div; +for (i =1 ; i < info->comp_planes; i++) + n += info->bpp[i]; + + format->bpp =DIV_ROUND_UP (8 * n, div); + } + } +if (buffer[2 ] ==UVC_VS_FORMAT_UNCOMPRESSED ) { ftype =UVC_VS_FRAME_UNCOMPRESSED ; }else {
@@ -2874,6 +2890,15 @@ static const struct usb_device_id uvc_ids[] = { .bInterfaceSubClass = 1, .bInterfaceProtocol = 0, .driver_info = (kernel_ulong_t)&uvc_quirk_force_y8 }, +/* GEO Semiconductor GC6500 */ + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE + | USB_DEVICE_ID_MATCH_INT_INFO, + .idVendor = 0x29fe, + .idProduct = 0x4d53, + .bInterfaceClass = USB_CLASS_VIDEO, + .bInterfaceSubClass = 1, + .bInterfaceProtocol = 0, + .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_FORCE_BPP) }, /* Intel RealSense D4M */ { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
drivers/media/usb/uvc/uvcvideo.h +1 -0
@@ -198,6 +198,7 @@#define UVC_QUIRK_RESTRICT_FRAME_RATE 0x00000200#define UVC_QUIRK_RESTORE_CTRLS_ON_INIT 0x00000400#define UVC_QUIRK_FORCE_Y8 0x00000800 +#define UVC_QUIRK_FORCE_BPP 0x00001000/* Format flags */ #define UVC_FMT_FLAG_COMPRESSED 0x00000001
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 448/542 btrfs: separate definition of assertion failure handlers
In reply to Sasha LevinFrom: David Sterba <[email protected]>
[ Upstream commit 68c467cbb2f389b6c933e235bce0d1756fc8cc34 ]
There's a report where objtool detects unreachable instructions, eg.:
fs/btrfs/ctree.o: warning: objtool: btrfs_search_slot()+0x2d4: unreachable instruction
This seems to be a false positive due to compiler version. The cause is in the ASSERT macro implementation that does the conditional check as IS_DEFINED(CONFIG_BTRFS_ASSERT) and not an #ifdef.
To avoid that, use the ifdefs directly.
There are still 2 reports that aren't fixed:
fs/btrfs/extent_io.o: warning: objtool: __set_extent_bit()+0x71f: unreachable instruction fs/btrfs/relocation.o: warning: objtool: find_data_references()+0x4e0: unreachable instruction
--- fs/btrfs/ctree.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
fs/btrfs/ctree.h +12 -8
@@ -3108,17 +3108,21 @@ do { \rcu_read_unlock (); \ } while (0) -__cold -static inline void assfail(const char *expr, const char *file, int line) +#ifdef CONFIG_BTRFS_ASSERT +__cold __noreturn +static inline void assertfail (const char *expr,const char *file,int line) { -if (IS_ENABLED (CONFIG_BTRFS_ASSERT )) { -pr_err ("assertion failed: %s, in %s:%d\n" , expr, file, line); -BUG (); - } +pr_err ("assertion failed: %s, in %s:%d\n" , expr, file, line); +BUG (); } -#define ASSERT (expr) \ - (likely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__)) +#define ASSERT (expr) \ + (likely(expr) ? (void)0 : assertfail(#expr, __FILE__, __LINE__)) + +#else +static inline void assertfail (const char *expr,const char * file,int line) { } +#define ASSERT (expr) (void)(expr) +#endif /* * Use that for functions that are conditionally exported for sanity tests but
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 449/542 btrfs: Fix split-brain handling when changing FSID to metadata uuid
In reply to Sasha LevinFrom: Nikolay Borisov <[email protected]>
[ Upstream commit 1362089d2ad7e20d16371b39d3c11990d4ec23e4 ]
Current code doesn't correctly handle the situation which arises when a file system that has METADATA_UUID_INCOMPAT flag set and has its FSID changed to the one in metadata uuid. This causes the incompat flag to disappear.
In case of a power failure we could end up in a situation where part of the disks in a multi-disk filesystem are correctly reverted to METADATA_UUID_INCOMPAT flag unset state, while others have METADATA_UUID_INCOMPAT set and CHANGING_FSID_V2_IN_PROGRESS.
This patch corrects the behavior required to handle the case where a disk of the second type is scanned first, creating the necessary btrfs_fs_devices. Subsequently, when a disk which has already completed the transition is scanned it should overwrite the data in btrfs_fs_devices.
--- fs/btrfs/volumes.c | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-)
fs/btrfs/volumes.c +38 -4
@@ -723,6 +723,32 @@ static struct btrfs_fs_devices *find_fsid_changed(return NULL ; } + +static struct btrfs_fs_devices *find_fsid_reverted_metadata ( +struct btrfs_super_block *disk_super) +{ +struct btrfs_fs_devices *fs_devices; + +/* +* Handle the case where the scanned device is part of an fs whose last +* metadata UUID change reverted it to the original FSID. At the same +* time * fs_devices was first created by another constitutent device +* which didn't fully observe the operation. This results in an +* btrfs_fs_devices created with metadata/fsid different AND +* btrfs_fs_devices::fsid_change set AND the metadata_uuid of the +* fs_devices equal to the FSID of the disk. +*/ +list_for_each_entry (fs_devices, &fs_uuids, fs_list) { +if (memcmp (fs_devices->fsid, fs_devices->metadata_uuid, +BTRFS_FSID_SIZE ) !=0 && +memcmp (fs_devices->metadata_uuid, disk_super->fsid, +BTRFS_FSID_SIZE ) ==0 && + fs_devices->fsid_change) +return fs_devices; + } + +return NULL ; +}/* * Add new device to list of registered devices *
@@ -762,7 +788,9 @@ static noinline struct btrfs_device *device_list_add(const char *path, fs_devices =find_fsid (disk_super->fsid, disk_super->metadata_uuid); }else { - fs_devices =find_fsid (disk_super->fsid,NULL ); + fs_devices =find_fsid_reverted_metadata (disk_super); +if (!fs_devices) + fs_devices =find_fsid (disk_super->fsid,NULL ); }
@@ -792,12 +820,18 @@ static noinline struct btrfs_device *device_list_add(const char *path,* a device which had the CHANGING_FSID_V2 flag then replace the * metadata_uuid/fsid values of the fs_devices. */ -if (has_metadata_uuid && fs_devices->fsid_change && +if (fs_devices->fsid_change && found_transid > fs_devices->latest_generation) {memcpy (fs_devices->fsid, disk_super->fsid,BTRFS_FSID_SIZE ); -memcpy (fs_devices->metadata_uuid, - disk_super->metadata_uuid,BTRFS_FSID_SIZE ); + +if (has_metadata_uuid) +memcpy (fs_devices->metadata_uuid, + disk_super->metadata_uuid, +BTRFS_FSID_SIZE ); +else +memcpy (fs_devices->metadata_uuid, + disk_super->fsid,BTRFS_FSID_SIZE ); fs_devices->fsid_change = false; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 450/542 ARM: dts: am43xx: add support for clkout1 clock
In reply to Sasha LevinFrom: Tero Kristo <[email protected]>
[ Upstream commit 01053dadb79d63b65f7b353e68b4b6ccf4effedb ]
clkout1 clock node and its generation tree was missing. Add this based on the data on TRM and PRCM functional spec.
commit 664ae1ab2536 ("ARM: dts: am43xx: add clkctrl nodes") effectively reverted this commit 8010f13a40d3 ("ARM: dts: am43xx: add support for clkout1 clock") which is needed for the ov2659 camera sensor clock definition hence it is being re-applied here.
Note that because of the current dts node name dependency for mapping to clock domain, we must still use "clkout1-*ck" naming instead of generic "clock@" naming for the node. And because of this, it's probably best to apply the dts node addition together along with the other clock changes.
--- arch/arm/boot/dts/am43xx-clocks.dtsi | 54 ++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+)
arch/arm/boot/dts/am43xx-clocks.dtsi +54 -0
@@ -704,6 +704,60 @@ ti,bit-shift = <8>; reg = <0x2a48>; }; + + clkout1_osc_div_ck: clkout1-osc-div-ck { + #clock-cells = <0>; + compatible = "ti,divider-clock"; + clocks = <&sys_clkin_ck>; + ti,bit-shift = <20>; + ti,max-div = <4>; + reg = <0x4100>; + }; + + clkout1_src2_mux_ck: clkout1-src2-mux-ck { + #clock-cells = <0>; + compatible = "ti,mux-clock"; + clocks = <&clk_rc32k_ck>, <&sysclk_div>, <&dpll_ddr_m2_ck>, + <&dpll_per_m2_ck>, <&dpll_disp_m2_ck>, + <&dpll_mpu_m2_ck>; + reg = <0x4100>; + }; + + clkout1_src2_pre_div_ck: clkout1-src2-pre-div-ck { + #clock-cells = <0>; + compatible = "ti,divider-clock"; + clocks = <&clkout1_src2_mux_ck>; + ti,bit-shift = <4>; + ti,max-div = <8>; + reg = <0x4100>; + }; + + clkout1_src2_post_div_ck: clkout1-src2-post-div-ck { + #clock-cells = <0>; + compatible = "ti,divider-clock"; + clocks = <&clkout1_src2_pre_div_ck>; + ti,bit-shift = <8>; + ti,max-div = <32>; + ti,index-power-of-two; + reg = <0x4100>; + }; + + clkout1_mux_ck: clkout1-mux-ck { + #clock-cells = <0>; + compatible = "ti,mux-clock"; + clocks = <&clkout1_osc_div_ck>, <&clk_rc32k_ck>, + <&clkout1_src2_post_div_ck>, <&dpll_extdev_m2_ck>; + ti,bit-shift = <16>; + reg = <0x4100>; + }; + + clkout1_ck: clkout1-ck { + #clock-cells = <0>; + compatible = "ti,gate-clock"; + clocks = <&clkout1_mux_ck>; + ti,bit-shift = <23>; + reg = <0x4100>; + }; }; &prcm {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 451/542 tty: n_hdlc: Use flexible-array member and struct_size() helper
In reply to Sasha LevinFrom: "Gustavo A. R. Silva" <[email protected]>
[ Upstream commit 85f4c95172d606dd66f7ee1fa50c45a245535ffd ]
Old code in the kernel uses 1-byte and 0-byte arrays to indicate the presence of a "variable length array":
struct something {
int length;
u8 data[1];
};struct something *instance;
instance = kmalloc(sizeof(*instance) + size, GFP_KERNEL); instance->length = size;memcpy(instance->data, source, size);
There is also 0-byte arrays. Both cases pose confusion for things like sizeof(), CONFIG_FORTIFY_SOURCE, etc.[1] Instead, the preferred mechanism to declare variable-length types such as the one above is a flexible array member[2] which need to be the last member of a structure and empty-sized:
struct something {
int stuff;
u8 data[];
};Also, by making use of the mechanism above, we will get a compiler warning in case the flexible array does not occur last in the structure, which will help us prevent some kind of undefined behavior bugs from being inadvertenly introduced[3] to the codebase from now on.
Lastly, make use of the struct_size() helper to safely calculate the allocation size for instances of struct n_hdlc_buf and avoid any potential type mistakes[4][5].
[1] https://github.com/KSPP/linux/issues/21
[2] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")
[4] https://lore.kernel.org/lkml/[email protected]/
[5] commit 553d66cb1e86 ("iommu/vt-d: Use struct_size() helper")
--- drivers/tty/n_hdlc.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/tty/n_hdlc.c +5 -6
@@ -115,11 +115,9 @@struct n_hdlc_buf {struct list_head list_item;int count; -char buf[1 ]; +char buf[]; }; -#define N_HDLC_BUF_SIZE (sizeof(struct n_hdlc_buf) + maxframe) -struct n_hdlc_buf_list {struct list_head list;int count;
@@ -524,7 +522,8 @@ static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data,/* no buffers in free list, attempt to allocate another rx buffer */ /* unless the maximum count has been reached */ if (n_hdlc->rx_buf_list.count <MAX_RX_BUF_COUNT ) - buf =kmalloc (N_HDLC_BUF_SIZE ,GFP_ATOMIC ); + buf =kmalloc (struct_size (buf, buf, maxframe), +GFP_ATOMIC ); }if (!buf) {
@@ -853,7 +852,7 @@ static struct n_hdlc *n_hdlc_alloc(void)/* allocate free rx buffer list */ for (i=0 ;i<DEFAULT_RX_BUF_COUNT ;i++) { - buf =kmalloc (N_HDLC_BUF_SIZE ,GFP_KERNEL ); + buf =kmalloc (struct_size (buf, buf, maxframe),GFP_KERNEL );if (buf)n_hdlc_buf_put (&n_hdlc->rx_free_buf_list,buf);else if (debuglevel >=DEBUG_LEVEL_INFO )
@@ -862,7 +861,7 @@ static struct n_hdlc *n_hdlc_alloc(void)/* allocate free tx buffer list */ for (i=0 ;i<DEFAULT_TX_BUF_COUNT ;i++) { - buf =kmalloc (N_HDLC_BUF_SIZE ,GFP_KERNEL ); + buf =kmalloc (struct_size (buf, buf, maxframe),GFP_KERNEL );if (buf)n_hdlc_buf_put (&n_hdlc->tx_free_buf_list,buf);else if (debuglevel >=DEBUG_LEVEL_INFO )
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerRe: [PATCH AUTOSEL 5.5 451/542] tty: n_hdlc: Use flexible-array member and struct_size() helper
Quoted 100 lines · Sasha Levin
From: "Gustavo A. R. Silva" <[email protected]>
[ Upstream commit
85f4c95172d606dd66f7ee1fa50c45a245535ffd]Old code in the kernel uses 1-byte and 0-byte arrays to indicate the presence of a "variable length array":
struct something { int length; u8 data[1]; };struct something *instance;
instance =
kmalloc(sizeof(*instance) + size, GFP_KERNEL);instance->length= size;memcpy(instance->data, source, size);There is also 0-byte arrays. Both cases pose confusion for things like
sizeof(),CONFIG_FORTIFY_SOURCE, etc.[1] Instead, the preferred mechanism to declare variable-length types such as the one above is a flexible array member[2] which need to be the last member of a structure and empty-sized:struct something { int stuff; u8 data[]; };Also, by making use of the mechanism above, we will get a compiler warning in case the flexible array does not occur last in the structure, which will help us prevent some kind of undefined behavior bugs from being inadvertenly introduced[3] to the codebase from now on.
Lastly, make use of the
struct_size()helper to safely calculate the allocation size for instances of structn_hdlc_bufand avoid any potential type mistakes[4][5].[1] https://github.com/KSPP/linux/issues/21
[2] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[3] commit76497732932f("cxgb3/l2t: Fix undefined behaviour")
[4] https://lore.kernel.org/lkml/[email protected]/
[5] commit553d66cb1e86("iommu/vt-d: Usestruct_size()helper")Signed-off-by Gustavo A. R. Silva <[email protected]>Reviewed-by Jiri Slaby <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/tty/n_hdlc.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)drivers/tty/n_hdlc.c +5
-6@@ -115,11 +115,9 @@struct n_hdlc_buf {struct list_head list_item;int count; -char buf[1 ]; +char buf[]; }; -#define N_HDLC_BUF_SIZE (sizeof(struct n_hdlc_buf) + maxframe) -struct n_hdlc_buf_list {struct list_head list;int count;@@ -524,7 +522,8 @@ static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data,/* no buffers in free list, attempt to allocate another rx buffer */ /* unless the maximum count has been reached */ if (n_hdlc->rx_buf_list.count <MAX_RX_BUF_COUNT ) - buf =kmalloc (N_HDLC_BUF_SIZE ,GFP_ATOMIC ); + buf =kmalloc (struct_size (buf, buf, maxframe), +GFP_ATOMIC ); }if (!buf) {@@ -853,7 +852,7 @@ static struct n_hdlc *n_hdlc_alloc(void)/* allocate free rx buffer list */ for (i=0 ;i<DEFAULT_RX_BUF_COUNT ;i++) { - buf =kmalloc (N_HDLC_BUF_SIZE ,GFP_KERNEL ); + buf =kmalloc (struct_size (buf, buf, maxframe),GFP_KERNEL );if (buf)n_hdlc_buf_put (&n_hdlc->rx_free_buf_list,buf);else if (debuglevel >=DEBUG_LEVEL_INFO )@@ -862,7 +861,7 @@ static struct n_hdlc *n_hdlc_alloc(void)/* allocate free tx buffer list */ for (i=0 ;i<DEFAULT_TX_BUF_COUNT ;i++) { - buf =kmalloc (N_HDLC_BUF_SIZE ,GFP_KERNEL ); + buf =kmalloc (struct_size (buf, buf, maxframe),GFP_KERNEL );if (buf)n_hdlc_buf_put (&n_hdlc->tx_free_buf_list,buf);else if (debuglevel >=DEBUG_LEVEL_INFO )Signature · 1 line
2.20.1
There's no need for any of these variable length array patches to be backported anywhere.
thanks,
greg k-h
Sasha Levin
maintainerPATCH 452/542 bcache: cached_dev_free needs to put the sb page
In reply to Sasha LevinFrom: Liang Chen <[email protected]>
[ Upstream commit e8547d42095e58bee658f00fef8e33d2a185c927 ]
Same as cache device, the buffer page needs to be put while freeing cached_dev. Otherwise a page would be leaked every time a cached_dev is stopped.
--- drivers/md/bcache/super.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/md/bcache/super.c +3 -0
@@ -1275,6 +1275,9 @@ static void cached_dev_free(struct closure *cl)mutex_unlock (&bch_register_lock); +if (dc->sb_bio.bi_inline_vecs[0 ].bv_page) +put_page (bio_first_page_all (&dc->sb_bio)); +if (!IS_ERR_OR_NULL (dc->bdev))blkdev_put (dc->bdev,FMODE_READ |FMODE_WRITE |FMODE_EXCL );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 453/542 bcache: rework error unwinding in register_bcache
In reply to Sasha LevinFrom: Christoph Hellwig <[email protected]>
[ Upstream commit 50246693f81fe887f4db78bf7089051d7f1894cc ]
Split the successful and error return path, and use one goto label for each resource to unwind. This also fixes some small errors like leaking the module reference count in the reboot case (which seems entirely harmless) or printing the wrong warning messages for early failures.
--- drivers/md/bcache/super.c | 75 +++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 30 deletions(-)
drivers/md/bcache/super.c +45 -30
@@ -2375,29 +2375,33 @@ static bool bch_is_open(struct block_device *bdev)static ssize_t register_bcache (struct kobject *k,struct kobj_attribute *attr,const char *buffer,size_t size) { -ssize_t ret = -EINVAL ; -const char *err ="cannot allocate memory" ; -char *path =NULL ; -struct cache_sb *sb =NULL ; +const char *err; +char *path; +struct cache_sb *sb;struct block_device *bdev =NULL ; -struct page *sb_page =NULL ; +struct page *sb_page; +ssize_t ret; + ret = -EBUSY ;if (!try_module_get (THIS_MODULE )) -return -EBUSY ; + goto out;/* For latest state of bcache_is_reboot */ smp_mb ();if (bcache_is_reboot) -return -EBUSY ; + goto out_module_put; + ret = -ENOMEM ; + err ="cannot allocate memory" ; path =kstrndup (buffer, size,GFP_KERNEL );if (!path) - goto err; + goto out_module_put; sb =kmalloc (sizeof (struct cache_sb ),GFP_KERNEL );if (!sb) - goto err; + goto out_free_path; + ret = -EINVAL ; err ="failed to open device" ; bdev = blkdev_get_by_path(strim(path), FMODE_READ|FMODE_WRITE|FMODE_EXCL,
@@ -2414,57 +2418,68 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,if (!IS_ERR (bdev))bdput (bdev);if (attr == &ksysfs_register_quiet) - goto quiet_out; + goto done; } - goto err; + goto out_free_sb; } err ="failed to set blocksize" ;if (set_blocksize (bdev,4096 )) - goto err_close; + goto out_blkdev_put; err =read_super (sb, bdev, &sb_page);if (err) - goto err_close; + goto out_blkdev_put; err ="failed to register device" ;if (SB_IS_BDEV (sb)) {struct cached_dev *dc =kzalloc (sizeof (*dc),GFP_KERNEL );if (!dc) - goto err_close; + goto out_put_sb_page;mutex_lock (&bch_register_lock); ret =register_bdev (sb, sb_page, bdev, dc);mutex_unlock (&bch_register_lock);/* blkdev_put() will be called in cached_dev_free() */ -if (ret <0 ) - goto err; +if (ret <0 ) { + bdev =NULL ; + goto out_put_sb_page; + } }else {struct cache *ca =kzalloc (sizeof (*ca),GFP_KERNEL );if (!ca) - goto err_close; + goto out_put_sb_page;/* blkdev_put() will be called in bch_cache_release() */ -if (register_cache (sb, sb_page, bdev, ca) !=0 ) - goto err; +if (register_cache (sb, sb_page, bdev, ca) !=0 ) { + bdev =NULL ; + goto out_put_sb_page; + } } -quiet_out: - ret = size; -out: -if (sb_page) -put_page (sb_page); + +put_page (sb_page); +done:kfree (sb);kfree (path);module_put (THIS_MODULE ); -return ret; - -err_close: -blkdev_put (bdev,FMODE_READ |FMODE_WRITE |FMODE_EXCL ); -err: +return size; + +out_put_sb_page: +put_page (sb_page); +out_blkdev_put: +if (bdev) +blkdev_put (bdev,FMODE_READ |FMODE_WRITE |FMODE_EXCL ); +out_free_sb: +kfree (sb); +out_free_path: +kfree (path); +out_module_put: +module_put (THIS_MODULE ); +out:pr_info ("error %s: %s" , path, err); - goto out; +return ret; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 454/542 bcache: fix use-after-free in register_bcache()
In reply to Sasha LevinFrom: Coly Li <[email protected]>
[ Upstream commit ae3cd299919af6eb670d5af0bc9d7ba14086bd8e ]
The patch "bcache: rework error unwinding in register_bcache" introduces a use-after-free regression in register_bcache(). Here are current code,
2510 out_free_path:
2511 kfree(path);
2512 out_module_put:
2513 module_put(THIS_MODULE);
2514 out:
2515 pr_info("error %s: %s", path, err);
2516 return ret;If some error happens and the above code path is executed, at line 2511 path is released, but referenced at line 2515. Then KASAN reports a use- after-free error message.
This patch changes line 2515 in the following way to fix the problem,
2515 pr_info("error %s: %s", path?path:"", err);--- drivers/md/bcache/super.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/bcache/super.c +2 -1
@@ -2475,10 +2475,11 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,kfree (sb); out_free_path:kfree (path); + path =NULL ; out_module_put:module_put (THIS_MODULE ); out: -pr_info ("error %s: %s" , path, err); +pr_info ("error %s: %s" , path?path:"" , err);return ret; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 455/542 bcache: avoid unnecessary btree nodes flushing in btree_flush_write()
In reply to Sasha LevinFrom: Coly Li <[email protected]>
[ Upstream commit 2aa8c529387c25606fdc1484154b92f8bfbc5746 ]
the commit 91be66e1318f ("bcache: performance improvement for btree_flush_write()") was an effort to flushing btree node with oldest btree node faster in following methods,
- Only iterate dirty btree nodes in c->btree_cache, avoid scanning a lot of clean btree nodes.
- Take c->btree_cache as a LRU-like list, aggressively flushing all dirty nodes from tail of c->btree_cache util the btree node with oldest journal entry is flushed. This is to reduce the time of holding c->bucket_lock.
Guoju Fang and Shuang Li reported that they observe unexptected extra write I/Os on cache device after applying the above patch. Guoju Fang provideed more detailed diagnose information that the aggressive btree nodes flushing may cause 10x more btree nodes to flush in his workload. He points out when system memory is large enough to hold all btree nodes in memory, c->btree_cache is not a LRU-like list any more. Then the btree node with oldest journal entry is very probably not- close to the tail of c->btree_cache list. In such situation much more dirty btree nodes will be aggressively flushed before the target node is flushed. When slow SATA SSD is used as cache device, such over- aggressive flushing behavior will cause performance regression.
After spending a lot of time on debug and diagnose, I find the real condition is more complicated, aggressive flushing dirty btree nodes from tail of c->btree_cache list is not a good solution.
- When all btree nodes are cached in memory, c->btree_cache is not a LRU-like list, the btree nodes with oldest journal entry won't be close to the tail of the list.
- There can be hundreds dirty btree nodes reference the oldest journal entry, before flushing all the nodes the oldest journal entry cannot be reclaimed.
When the above two conditions mixed together, a simply flushing from tail of c->btree_cache list is really NOT a good idea.
Fortunately there is still chance to make btree_flush_write() work better. Here is how this patch avoids unnecessary btree nodes flushing,
- Only acquire c->journal.lock when getting oldest journal entry of fifo c->journal.pin. In rested locations check the journal entries locklessly, so their values can be changed on other cores in parallel.
- In loop list_for_each_entry_safe_reverse(), checking latest front point of fifo c->journal.pin. If it is different from the original point which we get with locking c->journal.lock, it means the oldest journal entry is reclaim on other cores. At this moment, all selected dirty nodes recorded in array btree_nodes[] are all flushed and clean on other CPU cores, it is unncessary to iterate c->btree_cache any longer. Just quit the list_for_each_entry_safe_reverse() loop and the following for-loop will skip all the selected clean nodes.
- Find a proper time to quit the list_for_each_entry_safe_reverse() loop. Check the refcount value of orignial fifo front point, if the value is larger than selected node number of btree_nodes[], it means more matching btree nodes should be scanned. Otherwise it means no more matching btee nodes in rest of c->btree_cache list, the loop can be quit. If the original oldest journal entry is reclaimed and fifo front point is updated, the refcount of original fifo front point will be 0, then the loop will be quit too.
- Not hold c->bucket_lock too long time. c->bucket_lock is also required for space allocation for cached data, hold it for too long time will block regular I/O requests. When iterating list c->btree_cache, even there are a lot of maching btree nodes, in order to not holding c->bucket_lock for too long time, only BTREE_FLUSH_NR nodes are selected and to flush in following for-loop.
With this patch, only btree nodes referencing oldest journal entry are flushed to cache device, no aggressive flushing for unnecessary btree node any more. And in order to avoid blocking regluar I/O requests, each time when btree_flush_write() called, at most only BTREE_FLUSH_NR btree nodes are selected to flush, even there are more maching btree nodes in list c->btree_cache.
At last, one more thing to explain: Why it is safe to read front point of c->journal.pin without holding c->journal.lock inside the list_for_each_entry_safe_reverse() loop ?
Here is my answer: When reading the front point of fifo c->journal.pin, we don't need to know the exact value of front point, we just want to check whether the value is different from the original front point (which is accurate value because we get it while c->jouranl.lock is held). For such purpose, it works as expected without holding c->journal.lock. Even the front point is changed on other CPU core and not updated to local core, and current iterating btree node has identical journal entry local as original fetched fifo front point, it is still safe. Because after holding mutex b->write_lock (with memory barrier) this btree node can be found as clean and skipped, the loop will quite latter when iterate on next node of list c->btree_cache.
--- drivers/md/bcache/journal.c | 80 ++++++++++++++++++++++++++++++++++--- 1 file changed, 75 insertions(+), 5 deletions(-)
drivers/md/bcache/journal.c +75 -5
@@ -417,10 +417,14 @@ int bch_journal_replay(struct cache_set *s, struct list_head *list)/* Journalling */ +#define nr_to_fifo_front (p, front_p, mask) (((p) - (front_p)) & (mask)) +static void btree_flush_write (struct cache_set *c) {struct btree *b, *t, *btree_nodes[BTREE_FLUSH_NR ]; -unsigned int i, n; +unsigned int i, nr, ref_nr; +atomic_t *fifo_front_p, *now_fifo_front_p; +size_t mask;if (c->journal.btree_flushing)return ;
@@ -433,12 +437,50 @@ static void btree_flush_write(struct cache_set *c) c->journal.btree_flushing = true;spin_unlock (&c->journal.flush_write_lock); +/* get the oldest journal entry and check its refcount */ +spin_lock (&c->journal.lock); + fifo_front_p = &fifo_front (&c->journal.pin); + ref_nr =atomic_read (fifo_front_p); +if (ref_nr <=0 ) { +/* +* do nothing if no btree node references +* the oldest journal entry +*/ +spin_unlock (&c->journal.lock); + goto out; + } +spin_unlock (&c->journal.lock); + + mask = c->journal.pin.mask; + nr =0 ;atomic_long_inc (&c->flush_write);memset (btree_nodes,0 ,sizeof (btree_nodes)); - n =0 ;mutex_lock (&c->bucket_lock);list_for_each_entry_safe_reverse (b, t, &c->btree_cache, list) { +/* +* It is safe to get now_fifo_front_p without holding +* c->journal.lock here, because we don't need to know +* the exactly accurate value, just check whether the +* front pointer of c->journal.pin is changed. +*/ + now_fifo_front_p = &fifo_front (&c->journal.pin); +/* +* If the oldest journal entry is reclaimed and front +* pointer of c->journal.pin changes, it is unnecessary +* to scan c->btree_cache anymore, just quit the loop and +* flush out what we have already. +*/ +if (now_fifo_front_p != fifo_front_p) +break ; +/* +* quit this loop if all matching btree nodes are +* scanned and record in btree_nodes[] already. +*/ + ref_nr =atomic_read (fifo_front_p); +if (nr >= ref_nr) +break ; +if (btree_node_journal_flush (b))pr_err ("BUG: flush_write bit should not be set here!" );
@@ -454,17 +496,44 @@ static void btree_flush_write(struct cache_set *c)continue ; } +/* +* Only select the btree node which exactly references +* the oldest journal entry. +* +* If the journal entry pointed by fifo_front_p is +* reclaimed in parallel, don't worry: +* - the list_for_each_xxx loop will quit when checking +* next now_fifo_front_p. +* - If there are matched nodes recorded in btree_nodes[], +* they are clean now (this is why and how the oldest +* journal entry can be reclaimed). These selected nodes +* will be ignored and skipped in the folowing for-loop. +*/ +if (nr_to_fifo_front (btree_current_write (b)->journal, + fifo_front_p, + mask) !=0 ) { +mutex_unlock (&b->write_lock); +continue ; + } +set_btree_node_journal_flush (b);mutex_unlock (&b->write_lock); - btree_nodes[n++] = b; -if (n ==BTREE_FLUSH_NR ) + btree_nodes[nr++] = b; +/* +* To avoid holding c->bucket_lock too long time, +* only scan for BTREE_FLUSH_NR matched btree nodes +* at most. If there are more btree nodes reference +* the oldest journal entry, try to flush them next +* time when btree_flush_write() is called. +*/ +if (nr ==BTREE_FLUSH_NR )break ; }mutex_unlock (&c->bucket_lock); -for (i =0 ; i < n; i++) { +for (i =0 ; i < nr; i++) { b = btree_nodes[i];if (!b) {pr_err ("BUG: btree_nodes[%d] is NULL" , i);
@@ -497,6 +566,7 @@ static void btree_flush_write(struct cache_set *c)mutex_unlock (&b->write_lock); } +out:spin_lock (&c->journal.flush_write_lock); c->journal.btree_flushing = false;spin_unlock (&c->journal.flush_write_lock);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 456/542 char: hpet: Use flexible-array member
In reply to Sasha LevinFrom: "Gustavo A. R. Silva" <[email protected]>
[ Upstream commit 987f028b8637cfa7658aa456ae73f8f21a7a7f6f ]
Old code in the kernel uses 1-byte and 0-byte arrays to indicate the presence of a "variable length array":
struct something {
int length;
u8 data[1];
};struct something *instance;
instance = kmalloc(sizeof(*instance) + size, GFP_KERNEL); instance->length = size;memcpy(instance->data, source, size);
There is also 0-byte arrays. Both cases pose confusion for things like sizeof(), CONFIG_FORTIFY_SOURCE, etc.[1] Instead, the preferred mechanism to declare variable-length types such as the one above is a flexible array member[2] which need to be the last member of a structure and empty-sized:
struct something {
int stuff;
u8 data[];
};Also, by making use of the mechanism above, we will get a compiler warning in case the flexible array does not occur last in the structure, which will help us prevent some kind of undefined behavior bugs from being unadvertenly introduced[3] to the codebase from now on.
[1] https://github.com/KSPP/linux/issues/21
[2] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")
--- drivers/char/hpet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/hpet.c +1 -1
@@ -110,7 +110,7 @@ struct hpets {unsigned long hp_delta;unsigned int hp_ntimer;unsigned int hp_which; -struct hpet_dev hp_dev[1 ]; +struct hpet_dev hp_dev[]; };static struct hpets *hpets;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerRe: [PATCH AUTOSEL 5.5 456/542] char: hpet: Use flexible-array member
Quoted 61 lines · Sasha Levin
From: "Gustavo A. R. Silva" <[email protected]>
[ Upstream commit
987f028b8637cfa7658aa456ae73f8f21a7a7f6f]Old code in the kernel uses 1-byte and 0-byte arrays to indicate the presence of a "variable length array":
struct something { int length; u8 data[1]; };struct something *instance;
instance =
kmalloc(sizeof(*instance) + size, GFP_KERNEL);instance->length= size;memcpy(instance->data, source, size);There is also 0-byte arrays. Both cases pose confusion for things like
sizeof(),CONFIG_FORTIFY_SOURCE, etc.[1] Instead, the preferred mechanism to declare variable-length types such as the one above is a flexible array member[2] which need to be the last member of a structure and empty-sized:struct something { int stuff; u8 data[]; };Also, by making use of the mechanism above, we will get a compiler warning in case the flexible array does not occur last in the structure, which will help us prevent some kind of undefined behavior bugs from being unadvertenly introduced[3] to the codebase from now on.
[1] https://github.com/KSPP/linux/issues/21
[2] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[3] commit76497732932f("cxgb3/l2t: Fix undefined behaviour")Signed-off-by Gustavo A. R. Silva <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/char/hpet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/char/hpet.c +1
-1@@ -110,7 +110,7 @@ struct hpets {unsigned long hp_delta;unsigned int hp_ntimer;unsigned int hp_which; -struct hpet_dev hp_dev[1 ]; +struct hpet_dev hp_dev[]; };static struct hpets *hpets;Signature · 1 line
2.20.1
Not needed, please drop from all trees. Along with the other hpet patch that fixes the bug this one introduced :)
thanks,
greg k-h
Sasha Levin
maintainerPATCH 457/542 PCI/AER: Initialize aer_fifo
In reply to Sasha LevinFrom: Dongdong Liu <[email protected]>
[ Upstream commit d95f20c4f07020ebc605f3b46af4b6db9eb5fc99 ]
Previously we did not call INIT_KFIFO() for aer_fifo. This leads to kfifo_put() sometimes returning 0 (queue full) when in fact it is not.
It is easy to reproduce the problem by using aer-inject:
$ aer-inject -s :82:00.0 multiple-corr-nonfatal
The content of the multiple-corr-nonfatal file is as below:
AER
COR RCVR
HL 0 1 2 3
AER
UNCOR POISON_TLP
HL 4 5 6 7
--- drivers/pci/pcie/aer.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/pcie/aer.c +1 -0
@@ -1445,6 +1445,7 @@ static int aer_probe(struct pcie_device *dev)return -ENOMEM ; rpc->rpd = port; +INIT_KFIFO (rpc->aer_fifo);set_service_data (dev, rpc); status = devm_request_threaded_irq(device, dev->irq, aer_irq, aer_isr,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 458/542 iommu/vt-d: Mark firmware tainted if RMRR fails sanity check
In reply to Sasha LevinFrom: Barret Rhoden <[email protected]>
[ Upstream commit f5a68bb0752e0cf77c06f53f72258e7beb41381b ]
RMRR entries describe memory regions that are DMA targets for devices outside the kernel's control.
RMRR entries that fail the sanity check are pointing to regions of memory that the firmware did not tell the kernel are reserved or otherwise should not be used.
Instead of aborting DMAR processing, this commit marks the firmware as tainted. These RMRRs will still be identity mapped, otherwise, some devices, e.x. graphic devices, will not work during boot.
--- drivers/iommu/intel-iommu.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/iommu/intel-iommu.c +8 -4
@@ -4320,12 +4320,16 @@ int __init dmar_parse_one_rmrr(struct acpi_dmar_header *header, void *arg) {struct acpi_dmar_reserved_memory *rmrr;struct dmar_rmrr_unit *rmrru; -int ret; rmrr = (struct acpi_dmar_reserved_memory *)header; - ret =arch_rmrr_sanity_check (rmrr); -if (ret) -return ret; +if (arch_rmrr_sanity_check (rmrr)) +WARN_TAINT (1 ,TAINT_FIRMWARE_WORKAROUND , +"Your BIOS is broken; bad RMRR [%#018Lx-%#018Lx]\n" +"BIOS vendor: %s; Ver: %s; Product Version: %s\n" , + rmrr->base_address, rmrr->end_address, +dmi_get_system_info (DMI_BIOS_VENDOR ), +dmi_get_system_info (DMI_BIOS_VERSION ), +dmi_get_system_info (DMI_PRODUCT_VERSION )); rmrru =kzalloc (sizeof (*rmrru),GFP_KERNEL );if (!rmrru)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 459/542 iommu/vt-d: Remove unnecessary WARN_ON_ONCE()
In reply to Sasha LevinFrom: Lu Baolu <[email protected]>
[ Upstream commit 857f081426e5aa38313426c13373730f1345fe95 ]
Address field in device TLB invalidation descriptor is qualified by the S field. If S field is zero, a single page at page address specified by address [63:12] is requested to be invalidated. If S field is set, the least significant bit in the address field with value 0b (say bit N) indicates the invalidation address range. The spec doesn't require the address [N - 1, 0] to be cleared, hence remove the unnecessary WARN_ON_ONCE().
Otherwise, the caller might set "mask = MAX_AGAW_PFN_WIDTH" in order to invalidating all the cached mappings on an endpoint, and below overflow error will be triggered.
[...]
UBSAN: Undefined behaviour in drivers/iommu/dmar.c:1354:3
shift exponent 64 is too large for 64-bit type 'long long unsigned int' [...]
--- drivers/iommu/dmar.c | 1 - 1 file changed, 1 deletion(-)
drivers/iommu/dmar.c +0 -1
@@ -1354,7 +1354,6 @@ void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 pfsid,struct qi_desc desc;if (mask) { -WARN_ON_ONCE (addr & ((1ULL << (VTD_PAGE_SHIFT + mask)) -1 )); addr |= (1ULL << (VTD_PAGE_SHIFT + mask -1 )) -1 ; desc.qw1 =QI_DEV_IOTLB_ADDR (addr) |QI_DEV_IOTLB_SIZE ; }else
Signature · 6 lines
2.20.1 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Sasha Levin
maintainerPATCH 460/542 alarmtimer: Make alarmtimer platform device child of RTC device
In reply to Sasha LevinFrom: Stephen Boyd <[email protected]>
[ Upstream commit c79108bd19a8490315847e0c95ac6526fcd8e770 ]
The alarmtimer_suspend() function will fail if an RTC device is on a bus such as SPI or i2c and that RTC device registers and probes after alarmtimer_init() registers and probes the 'alarmtimer' platform device.
This is because system wide suspend suspends devices in the reverse order of their probe. When alarmtimer_suspend() attempts to program the RTC for a wakeup it will try to program an RTC device on a bus that has already been suspended.
Move the alarmtimer device registration to happen when the RTC which is used for wakeup is registered. Register the 'alarmtimer' platform device as a child of the RTC device too, so that it can be guaranteed that the RTC device won't be suspended when alarmtimer_suspend() is called.
--- kernel/time/alarmtimer.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
kernel/time/alarmtimer.c +9 -11
@@ -88,6 +88,7 @@ static int alarmtimer_rtc_add_device(struct device *dev,unsigned long flags;struct rtc_device *rtc =to_rtc_device (dev);struct wakeup_source *__ws; +struct platform_device *pdev;int ret =0 ;if (rtcdev)
@@ -99,9 +100,11 @@ static int alarmtimer_rtc_add_device(struct device *dev,return -1 ; __ws =wakeup_source_register (dev,"alarmtimer" ); + pdev =platform_device_register_data (dev,"alarmtimer" , +PLATFORM_DEVID_AUTO ,NULL ,0 );spin_lock_irqsave (&rtcdev_lock, flags); -if (!rtcdev) { +if (__ws && !IS_ERR (pdev) && !rtcdev) {if (!try_module_get (rtc->owner)) { ret =-1 ; goto unlock;
@@ -112,10 +115,14 @@ static int alarmtimer_rtc_add_device(struct device *dev,get_device (dev); ws = __ws; __ws =NULL ; + pdev =NULL ; + }else { + ret =-1 ; } unlock:spin_unlock_irqrestore (&rtcdev_lock, flags); +platform_device_unregister (pdev);wakeup_source_unregister (__ws);return ret;
@@ -876,8 +883,7 @@ static struct platform_driver alarmtimer_driver = {*/ static int __init alarmtimer_init (void ) { -struct platform_device *pdev; -int error =0 ; +int error;int i;alarmtimer_rtc_timer_init ();
@@ -900,15 +906,7 @@ static int __init alarmtimer_init(void)if (error) goto out_if; - pdev =platform_device_register_simple ("alarmtimer" ,-1 ,NULL ,0 ); -if (IS_ERR (pdev)) { - error =PTR_ERR (pdev); - goto out_drv; - }return 0 ; - -out_drv: -platform_driver_unregister (&alarmtimer_driver); out_if:alarmtimer_rtc_interface_remove ();return error;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 461/542 selftests: bpf: Reset global state between reuseport test runs
In reply to Sasha LevinFrom: Lorenz Bauer <[email protected]>
[ Upstream commit 51bad0f05616c43d6d34b0a19bcc9bdab8e8fb39 ]
Currently, there is a lot of false positives if a single reuseport test fails. This is because expected_results and the result map are not cleared.
Zero both after individual test runs, which fixes the mentioned false positives.
--- .../selftests/bpf/test_select_reuseport.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/test_select_reuseport.c +14 -2
@@ -30,7 +30,7 @@#define REUSEPORT_ARRAY_SIZE 32static int result_map, tmp_index_ovr_map, linum_map, data_check_map; -static enum result expected_results[NR_RESULTS ]; +static __u32 expected_results[NR_RESULTS ];static int sk_fds[REUSEPORT_ARRAY_SIZE ];static int reuseport_array, outer_map;static int select_by_skb_data_prog;
@@ -662,7 +662,19 @@ static void setup_per_test(int type, unsigned short family, bool inany)static void cleanup_per_test (void ) { -int i, err; +int i, err, zero =0 ; + +memset (expected_results,0 ,sizeof (expected_results)); + +for (i =0 ; i <NR_RESULTS ; i++) { + err =bpf_map_update_elem (result_map, &i, &zero,BPF_ANY ); +RET_IF (err,"reset elem in result_map" , +"i:%u err:%d errno:%d\n" , i, err, errno); + } + + err =bpf_map_update_elem (linum_map, &zero, &zero,BPF_ANY ); +RET_IF (err,"reset line number in linum_map" ,"err:%d errno:%d\n" , + err, errno);for (i =0 ; i <REUSEPORT_ARRAY_SIZE ; i++)close (sk_fds[i]);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 462/542 jbd2: switch to use jbd2_journal_abort() when failed to submit the commit record
In reply to Sasha LevinFrom: "zhangyi (F)" <[email protected]>
[ Upstream commit d0a186e0d3e7ac05cc77da7c157dae5aa59f95d9 ]
We invoke jbd2_journal_abort() to abort the journal and record errno in the jbd2 superblock when committing journal transaction besides the failure on submitting the commit record. But there is no need for the case and we can also invoke jbd2_journal_abort() instead of __jbd2_journal_abort_hard().
--- fs/jbd2/commit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/jbd2/commit.c +2 -2
@@ -782,7 +782,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) err =journal_submit_commit_record (journal, commit_transaction, &cbh, crc32_sum);if (err) -__jbd2_journal_abort_hard (journal); +jbd2_journal_abort (journal, err); }blk_finish_plug (&plug);
@@ -875,7 +875,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) err =journal_submit_commit_record (journal, commit_transaction, &cbh, crc32_sum);if (err) -__jbd2_journal_abort_hard (journal); +jbd2_journal_abort (journal, err); }if (cbh) err =journal_wait_on_commit_record (journal, cbh);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 463/542 jbd2: make sure ESHUTDOWN to be recorded in the journal superblock
In reply to Sasha LevinFrom: "zhangyi (F)" <[email protected]>
[ Upstream commit 0e98c084a21177ef136149c6a293b3d1eb33ff92 ]
Commit fb7c02445c49 ("ext4: pass -ESHUTDOWN code to jbd2 layer") want to allow jbd2 layer to distinguish shutdown journal abort from other error cases. So the ESHUTDOWN should be taken precedence over any other errno which has already been recoded after EXT4_FLAGS_SHUTDOWN is set, but it only update errno in the journal suoerblock now if the old errno is 0.
--- fs/jbd2/journal.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/jbd2/journal.c +1 -2
@@ -2147,8 +2147,7 @@ static void __journal_abort_soft (journal_t *journal, int errno)if (journal->j_flags &JBD2_ABORT ) {write_unlock (&journal->j_state_lock); -if (!old_errno && old_errno != -ESHUTDOWN && - errno == -ESHUTDOWN ) +if (old_errno != -ESHUTDOWN && errno == -ESHUTDOWN )jbd2_journal_update_sb_errno (journal);return ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 464/542 powerpc/pseries/lparcfg: Fix display of Maximum Memory
In reply to Sasha LevinFrom: Michael Bringmann <[email protected]>
[ Upstream commit f1dbc1c5c70d0d4c60b5d467ba941fba167c12f6 ]
Correct overflow problem in calculation and display of Maximum Memory value to syscfg.
--- arch/powerpc/platforms/pseries/lparcfg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/platforms/pseries/lparcfg.c +2 -2
@@ -435,10 +435,10 @@ static void maxmem_data(struct seq_file *m) {unsigned long maxmem =0 ; - maxmem += drmem_info->n_lmbs * drmem_info->lmb_size; + maxmem += (unsigned long )drmem_info->n_lmbs * drmem_info->lmb_size; maxmem +=hugetlb_total_pages () *PAGE_SIZE ; -seq_printf (m,"MaxMem=%ld\n" , maxmem); +seq_printf (m,"MaxMem=%lu\n" , maxmem); }static int pseries_lparcfg_data (struct seq_file *m,void *v)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 465/542 selftests/eeh: Bump EEH wait time to 60s
In reply to Sasha LevinFrom: Oliver O'Halloran <[email protected]>
[ Upstream commit 414f50434aa2463202a5b35e844f4125dd1a7101 ]
Some newer cards supported by aacraid can take up to 40s to recover after an EEH event. This causes spurious failures in the basic EEH self-test since the current maximim timeout is only 30s.
Fix the immediate issue by bumping the timeout to a default of 60s, and allow the wait time to be specified via an environmental variable (EEH_MAX_WAIT).
--- tools/testing/selftests/powerpc/eeh/eeh-functions.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
tools/testing/selftests/powerpc/eeh/eeh-functions.sh +7 -3
@@ -53,9 +53,13 @@ eeh_one_dev() { # is a no-op. echo $dev >/sys/kernel/debug/powerpc/eeh_dev_check - # Enforce a 30s timeout for recovery. Even the IPR, which is infamously - # slow to reset, should recover within 30s. - max_wait=30 + # Default to a 60s timeout when waiting for a device to recover. This + # is an arbitrary default which can be overridden by setting the + # EEH_MAX_WAIT environmental variable when required. + + # The current record holder for longest recovery time is: + # "Adaptec Series 8 12G SAS/PCIe 3" at 39 seconds + max_wait=${EEH_MAX_WAIT:=60} for i in `seq 0 ${max_wait}` ; do if pe_ok $dev ; then
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 466/542 ARM: 8941/1: decompressor: enable CP15 barrier instructions in v7 cache setup code
In reply to Sasha LevinFrom: Ard Biesheuvel <[email protected]>
[ Upstream commit 8239fc7755fd3d410920006615abd0c7d653560f ]
Commit e17b1af96b2afc38e684aa2f1033387e2ed10029
"ARM: 8857/1: efi: enable CP15 DMB instructions before cleaning the cache"
added some explicit handling of the CP15BEN bit in the SCTLR system register, to ensure that CP15 barrier instructions are enabled, even if we enter the decompressor via the EFI stub.
However, as it turns out, there are other ways in which we may end up using CP15 barrier instructions without them being enabled. I.e., when the decompressor startup code skips the cache_on() initially, we end up calling cache_clean_flush() with the caches and MMU off, in which case the CP15BEN bit in SCTLR may not be programmed either. And in fact, cache_on() itself issues CP15 barrier instructions before actually enabling them by programming the new SCTLR value (and issuing an ISB)
Since these routines are shared between v7 CPUs and older ones that implement the CPUID extension as well, using the ordinary v7 barrier instructions in this code is not possible, and so we should enable the CP15 ones explicitly before issuing them. Note that a v7 ISB is still required between programming the SCTLR register and using the CP15 barrier instructions, and we should take care to branch over it if the CP15BEN bit is already set, given that in that case, the CPU may not support it.
--- arch/arm/boot/compressed/head.S | 13 +++++++++++++ 1 file changed, 13 insertions(+)
arch/arm/boot/compressed/head.S +13 -0
@@ -140,6 +140,17 @@ #endif .endm + .macro enable_cp15_barriers, reg + mrc p15, 0, \reg, c1, c0, 0 @ read SCTLR + tst \reg, #(1 << 5) @ CP15BEN bit set? + bne .L_\@ + orr \reg, \reg, #(1 << 5) @ CP15 barrier instructions + mcr p15, 0, \reg, c1, c0, 0 @ write SCTLR + ARM( .inst 0xf57ff06f @ v7+ isb ) + THUMB( isb ) +.L_\@: + .endm + .section ".start", "ax" /* * sort out different calling conventions
@@ -820,6 +831,7 @@ __armv4_mmu_cache_on: mov pc, r12 __armv7_mmu_cache_on: + enable_cp15_barriers r11 mov r12, lr #ifdef CONFIG_MMU mrc p15, 0, r11, c0, c1, 4 @ read ID_MMFR0
@@ -1209,6 +1221,7 @@ __armv6_mmu_cache_flush: mov pc, lr __armv7_mmu_cache_flush: + enable_cp15_barriers r10 tst r4, #1 bne iflush mrc p15, 0, r10, c0, c1, 5 @ read ID_MMFR1
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 467/542 ARM: 8949/1: mm: mark free_memmap as __init
In reply to Sasha LevinFrom: Olof Johansson <[email protected]>
[ Upstream commit 31f3010e60522ede237fb145a63b4af5a41718c2 ]
As of commit ac7c3e4ff401 ("compiler: enable CONFIG_OPTIMIZE_INLINING forcibly"), free_memmap() might not always be inlined, and thus is triggering a section warning:
WARNING: vmlinux.o(.text.unlikely+0x904): Section mismatch in reference from the function free_memmap() to the function .meminit.text:memblock_free()
Mark it as __init, since the faller (free_unused_memmap) already is.
--- arch/arm/mm/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mm/init.c +1 -1
@@ -324,7 +324,7 @@ static inline void poison_init_mem(void *s, size_t count) *p++ =0xe7fddef0 ; } -static inline void +static inline void __init free_memmap (unsigned long start_pfn,unsigned long end_pfn) {struct page *start_pg, *end_pg;
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 468/542 ARM: 8951/1: Fix Kexec compilation issue.
In reply to Sasha LevinFrom: Vincenzo Frascino <[email protected]>
[ Upstream commit 76950f7162cad51d2200ebd22c620c14af38f718 ]
To perform the reserve_crashkernel() operation kexec uses SECTION_SIZE to find a memblock in a range.SECTION_SIZE is not defined for nommu systems. Trying to compile kexec in these conditions results in a build error:
linux/arch/arm/kernel/setup.c: In function ‘reserve_crashkernel’:
linux/arch/arm/kernel/setup.c:1016:25: error: ‘SECTION_SIZE’ undeclared
(first use in this function); did you mean ‘SECTIONS_WIDTH’?
crash_size, SECTION_SIZE);
^~~~~~~~~~~~
SECTIONS_WIDTH linux/arch/arm/kernel/setup.c:1016:25: note: each undeclared identifier
is reported only once for each function it appears in
linux/scripts/Makefile.build:265: recipe for target 'arch/arm/kernel/setup.o'
failed
Make KEXEC depend on MMU to fix the compilation issue.
--- arch/arm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/Kconfig +1 -1
@@ -1905,7 +1905,7 @@ config XIP_DEFLATED_DATA config KEXEC bool "Kexec system call (EXPERIMENTAL)" depends on (!SMP || PM_SLEEP_SMP) - depends on !CPU_V7M + depends on MMU select KEXEC_CORE help kexec is a system call that implements the ability to shutdown your
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 469/542 RDMA/core: Ensure that rdma_user_mmap_entry_remove() is a fence
In reply to Sasha LevinFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit 6b3712c0246ca7b2b8fa05eab2362cf267410f7e ]
The set of entry->driver_removed is missing locking, protect it with xa_lock() which is held by the only reader.
Otherwise readers may continue to see driver_removed = false after rdma_user_mmap_entry_remove() returns and may continue to try and establish new mmaps.
--- drivers/infiniband/core/ib_core_uverbs.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/core/ib_core_uverbs.c +2 -0
@@ -232,7 +232,9 @@ void rdma_user_mmap_entry_remove(struct rdma_user_mmap_entry *entry)if (!entry)return ; +xa_lock (&entry->ucontext->mmap_xa); entry->driver_removed = true; +xa_unlock (&entry->ucontext->mmap_xa);kref_put (&entry->ref, rdma_user_mmap_entry_free); }EXPORT_SYMBOL (rdma_user_mmap_entry_remove);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 470/542 ALSA: usb-audio: add quirks for Line6 Helix devices fw>=2.82
In reply to Sasha LevinFrom: Nicola Lunghi <[email protected]>
[ Upstream commit b81cbf7abfc94878a3c6f0789f2185ee55b1cc21 ]
With firmware 2.82 Line6 changed the usb id of some of the Helix devices but the quirks is still needed.
Add it to the quirk list for line6 helix family of devices.
Thanks to Jens for pointing out the missing ids.
--- sound/usb/format.c | 3 +++ 1 file changed, 3 insertions(+)
sound/usb/format.c +3 -0
@@ -296,6 +296,9 @@ static int line6_parse_audio_format_rates_quirk(struct snd_usb_audio *chip,case USB_ID (0x0E41 ,0x4242 ):/* Line6 Helix Rack */ case USB_ID (0x0E41 ,0x4244 ):/* Line6 Helix LT */ case USB_ID (0x0E41 ,0x4246 ):/* Line6 HX-Stomp */ +case USB_ID (0x0E41 ,0x4248 ):/* Line6 Helix >= fw 2.82 */ +case USB_ID (0x0E41 ,0x4249 ):/* Line6 Helix Rack >= fw 2.82 */ +case USB_ID (0x0E41 ,0x424a ):/* Line6 Helix LT >= fw 2.82 */ /* supported rates: 48Khz */ kfree (fp->rate_table); fp->rate_table =kmalloc (sizeof (int ),GFP_KERNEL );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 471/542 ath10k: pci: Only dump ATH10K_MEM_REGION_TYPE_IOREG when safe
In reply to Sasha LevinFrom: Bryan O'Donoghue <[email protected]>
[ Upstream commit d239380196c4e27a26fa4bea73d2bf994c14ec2d ]
ath10k_pci_dump_memory_reg() will try to access memory of type ATH10K_MEM_REGION_TYPE_IOREG however, if a hardware restart is in progress this can crash a system.
Individual ioread32() time has been observed to jump from 15-20 ticks to > 80k ticks followed by a secure-watchdog bite and a system reset.
Work around this corner case by only issuing the read transaction when the driver state is ATH10K_STATE_ON.
Tested-on: QCA9988 PCI 10.4-3.9.0.2-00044
--- drivers/net/wireless/ath/ath10k/pci.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath10k/pci.c +17 -2
@@ -1604,11 +1604,22 @@ static int ath10k_pci_dump_memory_reg(struct ath10k *ar, {struct ath10k_pci *ar_pci =ath10k_pci_priv (ar);u32 i; +int ret; + +mutex_lock (&ar->conf_mutex); +if (ar->state !=ATH10K_STATE_ON ) { +ath10k_warn (ar,"Skipping pci_dump_memory_reg invalid state\n" ); + ret = -EIO ; + goto done; + }for (i =0 ; i < region->len; i +=4 ) *(u32 *)(buf + i) =ioread32 (ar_pci->mem + region->start + i); -return region->len; + ret = region->len; +done: +mutex_unlock (&ar->conf_mutex); +return ret; }/* if an error happened returns < 0, otherwise the length */
@@ -1704,7 +1715,11 @@ static void ath10k_pci_dump_memory(struct ath10k *ar, count =ath10k_pci_dump_memory_sram (ar, current_region, buf);break ;case ATH10K_MEM_REGION_TYPE_IOREG : - count =ath10k_pci_dump_memory_reg (ar, current_region, buf); + ret =ath10k_pci_dump_memory_reg (ar, current_region, buf); +if (ret <0 ) +break ; + + count = ret;break ;default : ret =ath10k_pci_dump_memory_generic (ar, current_region, buf);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 472/542 hostap: Adjust indentation in prism2_hostapd_add_sta
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit b61156fba74f659d0bc2de8f2dbf5bad9f4b8faf ]
Clang warns:
../drivers/net/wireless/intersil/hostap/hostap_ap.c:2511:3: warning:
misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
if (sta->tx_supp_rates & WLAN_RATE_5M5)
^
../drivers/net/wireless/intersil/hostap/hostap_ap.c:2509:2: note:
previous statement is here
if (sta->tx_supp_rates & WLAN_RATE_2M)
^1 warning generated.
This warning occurs because there is a space before the tab on this line. Remove it so that the indentation is consistent with the Linux kernel coding style and clang no longer warns.
--- drivers/net/wireless/intersil/hostap/hostap_ap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intersil/hostap/hostap_ap.c +1 -1
@@ -2508,7 +2508,7 @@ static int prism2_hostapd_add_sta(struct ap_data *ap, sta->supported_rates[0 ] =2 ;if (sta->tx_supp_rates &WLAN_RATE_2M ) sta->supported_rates[1 ] =4 ; -if (sta->tx_supp_rates &WLAN_RATE_5M5 ) +if (sta->tx_supp_rates &WLAN_RATE_5M5 ) sta->supported_rates[2 ] =11 ;if (sta->tx_supp_rates &WLAN_RATE_11M ) sta->supported_rates[3 ] =22 ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 473/542 rtw88: fix potential NULL skb access in TX ISR
In reply to Sasha LevinFrom: Yan-Hsuan Chuang <[email protected]>
[ Upstream commit f4f84ff8377d4cedf18317747bc407b2cf657d0f ]
Sometimes the TX queue may be empty and we could possible dequeue a NULL pointer, crash the kernel. If the skb is NULL then there is nothing to do, just leave the ISR.
And the TX queue should not be empty here, so print an error to see if there is anything wrong for DMA ring.
--- drivers/net/wireless/realtek/rtw88/pci.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/wireless/realtek/rtw88/pci.c +5 -0
@@ -832,6 +832,11 @@ static void rtw_pci_tx_isr(struct rtw_dev *rtwdev, struct rtw_pci *rtwpci,while (count--) { skb =skb_dequeue (&ring->queue); +if (!skb) { +rtw_err (rtwdev,"failed to dequeue %d skb TX queue %d, BD=0x%08x, rp %d -> %d\n" , + count, hw_queue, bd_idx, ring->r.rp, cur_rp); +break ; + } tx_data =rtw_pci_get_tx_data (skb);pci_unmap_single (rtwpci->pdev, tx_data->dma, skb->len,PCI_DMA_TODEVICE );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 474/542 rtlwifi: rtl8821ae: remove unused variables
In reply to Sasha LevinFrom: YueHaibing <[email protected]>
[ Upstream commit cc071a6f26aae3321cf193dc2e8c35090709b8ab ]
drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c:142:17:
warning: cckswing_table_ch1ch13 defined but not used [-Wunused-const-variable=]drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c:178:17:
warning: cckswing_table_ch14 defined but not used [-Wunused-const-variable=]drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c:96:18:
warning: ofdmswing_table defined but not used [-Wunused-const-variable=]
These variable is never used, so remove them.
--- .../wireless/realtek/rtlwifi/rtl8821ae/dm.c | 118 ------------------ 1 file changed, 118 deletions(-)
drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c +0 -118
@@ -93,124 +93,6 @@ static const u32 rtl8821ae_txscaling_table[TXSCALE_TABLE_SIZE] = {0x3FE /* 36, +6.0dB */ }; -static const u32 ofdmswing_table[] = { -0x0b40002d ,/* 0, -15.0dB */ -0x0c000030 ,/* 1, -14.5dB */ -0x0cc00033 ,/* 2, -14.0dB */ -0x0d800036 ,/* 3, -13.5dB */ -0x0e400039 ,/* 4, -13.0dB */ -0x0f00003c ,/* 5, -12.5dB */ -0x10000040 ,/* 6, -12.0dB */ -0x11000044 ,/* 7, -11.5dB */ -0x12000048 ,/* 8, -11.0dB */ -0x1300004c ,/* 9, -10.5dB */ -0x14400051 ,/* 10, -10.0dB */ -0x15800056 ,/* 11, -9.5dB */ -0x16c0005b ,/* 12, -9.0dB */ -0x18000060 ,/* 13, -8.5dB */ -0x19800066 ,/* 14, -8.0dB */ -0x1b00006c ,/* 15, -7.5dB */ -0x1c800072 ,/* 16, -7.0dB */ -0x1e400079 ,/* 17, -6.5dB */ -0x20000080 ,/* 18, -6.0dB */ -0x22000088 ,/* 19, -5.5dB */ -0x24000090 ,/* 20, -5.0dB */ -0x26000098 ,/* 21, -4.5dB */ -0x288000a2 ,/* 22, -4.0dB */ -0x2ac000ab ,/* 23, -3.5dB */ -0x2d4000b5 ,/* 24, -3.0dB */ -0x300000c0 ,/* 25, -2.5dB */ -0x32c000cb ,/* 26, -2.0dB */ -0x35c000d7 ,/* 27, -1.5dB */ -0x390000e4 ,/* 28, -1.0dB */ -0x3c8000f2 ,/* 29, -0.5dB */ -0x40000100 ,/* 30, +0dB */ -0x43c0010f ,/* 31, +0.5dB */ -0x47c0011f ,/* 32, +1.0dB */ -0x4c000130 ,/* 33, +1.5dB */ -0x50800142 ,/* 34, +2.0dB */ -0x55400155 ,/* 35, +2.5dB */ -0x5a400169 ,/* 36, +3.0dB */ -0x5fc0017f ,/* 37, +3.5dB */ -0x65400195 ,/* 38, +4.0dB */ -0x6b8001ae ,/* 39, +4.5dB */ -0x71c001c7 ,/* 40, +5.0dB */ -0x788001e2 ,/* 41, +5.5dB */ -0x7f8001fe /* 42, +6.0dB */ -}; - -static const u8 cckswing_table_ch1ch13[CCK_TABLE_SIZE ][8 ] = { - {0x09 ,0x08 ,0x07 ,0x06 ,0x04 ,0x03 ,0x01 ,0x01 },/* 0, -16.0dB */ - {0x09 ,0x09 ,0x08 ,0x06 ,0x05 ,0x03 ,0x01 ,0x01 },/* 1, -15.5dB */ - {0x0a ,0x09 ,0x08 ,0x07 ,0x05 ,0x03 ,0x02 ,0x01 },/* 2, -15.0dB */ - {0x0a ,0x0a ,0x09 ,0x07 ,0x05 ,0x03 ,0x02 ,0x01 },/* 3, -14.5dB */ - {0x0b ,0x0a ,0x09 ,0x08 ,0x06 ,0x04 ,0x02 ,0x01 },/* 4, -14.0dB */ - {0x0b ,0x0b ,0x0a ,0x08 ,0x06 ,0x04 ,0x02 ,0x01 },/* 5, -13.5dB */ - {0x0c ,0x0c ,0x0a ,0x09 ,0x06 ,0x04 ,0x02 ,0x01 },/* 6, -13.0dB */ - {0x0d ,0x0c ,0x0b ,0x09 ,0x07 ,0x04 ,0x02 ,0x01 },/* 7, -12.5dB */ - {0x0d ,0x0d ,0x0c ,0x0a ,0x07 ,0x05 ,0x02 ,0x01 },/* 8, -12.0dB */ - {0x0e ,0x0e ,0x0c ,0x0a ,0x08 ,0x05 ,0x02 ,0x01 },/* 9, -11.5dB */ - {0x0f ,0x0f ,0x0d ,0x0b ,0x08 ,0x05 ,0x03 ,0x01 },/* 10, -11.0dB */ - {0x10 ,0x10 ,0x0e ,0x0b ,0x08 ,0x05 ,0x03 ,0x01 },/* 11, -10.5dB */ - {0x11 ,0x11 ,0x0f ,0x0c ,0x09 ,0x06 ,0x03 ,0x01 },/* 12, -10.0dB */ - {0x12 ,0x12 ,0x0f ,0x0c ,0x09 ,0x06 ,0x03 ,0x01 },/* 13, -9.5dB */ - {0x13 ,0x13 ,0x10 ,0x0d ,0x0a ,0x06 ,0x03 ,0x01 },/* 14, -9.0dB */ - {0x14 ,0x14 ,0x11 ,0x0e ,0x0b ,0x07 ,0x03 ,0x02 },/* 15, -8.5dB */ - {0x16 ,0x15 ,0x12 ,0x0f ,0x0b ,0x07 ,0x04 ,0x01 },/* 16, -8.0dB */ - {0x17 ,0x16 ,0x13 ,0x10 ,0x0c ,0x08 ,0x04 ,0x02 },/* 17, -7.5dB */ - {0x18 ,0x17 ,0x15 ,0x11 ,0x0c ,0x08 ,0x04 ,0x02 },/* 18, -7.0dB */ - {0x1a ,0x19 ,0x16 ,0x12 ,0x0d ,0x09 ,0x04 ,0x02 },/* 19, -6.5dB */ - {0x1b ,0x1a ,0x17 ,0x13 ,0x0e ,0x09 ,0x04 ,0x02 },/* 20, -6.0dB */ - {0x1d ,0x1c ,0x18 ,0x14 ,0x0f ,0x0a ,0x05 ,0x02 },/* 21, -5.5dB */ - {0x1f ,0x1e ,0x1a ,0x15 ,0x10 ,0x0a ,0x05 ,0x02 },/* 22, -5.0dB */ - {0x20 ,0x20 ,0x1b ,0x16 ,0x11 ,0x08 ,0x05 ,0x02 },/* 23, -4.5dB */ - {0x22 ,0x21 ,0x1d ,0x18 ,0x11 ,0x0b ,0x06 ,0x02 },/* 24, -4.0dB */ - {0x24 ,0x23 ,0x1f ,0x19 ,0x13 ,0x0c ,0x06 ,0x03 },/* 25, -3.5dB */ - {0x26 ,0x25 ,0x21 ,0x1b ,0x14 ,0x0d ,0x06 ,0x03 },/* 26, -3.0dB */ - {0x28 ,0x28 ,0x22 ,0x1c ,0x15 ,0x0d ,0x07 ,0x03 },/* 27, -2.5dB */ - {0x2b ,0x2a ,0x25 ,0x1e ,0x16 ,0x0e ,0x07 ,0x03 },/* 28, -2.0dB */ - {0x2d ,0x2d ,0x27 ,0x1f ,0x18 ,0x0f ,0x08 ,0x03 },/* 29, -1.5dB */ - {0x30 ,0x2f ,0x29 ,0x21 ,0x19 ,0x10 ,0x08 ,0x03 },/* 30, -1.0dB */ - {0x33 ,0x32 ,0x2b ,0x23 ,0x1a ,0x11 ,0x08 ,0x04 },/* 31, -0.5dB */ - {0x36 ,0x35 ,0x2e ,0x25 ,0x1c ,0x12 ,0x09 ,0x04 }/* 32, +0dB */ -}; - -static const u8 cckswing_table_ch14[CCK_TABLE_SIZE ][8 ] = { - {0x09 ,0x08 ,0x07 ,0x04 ,0x00 ,0x00 ,0x00 ,0x00 },/* 0, -16.0dB */ - {0x09 ,0x09 ,0x08 ,0x05 ,0x00 ,0x00 ,0x00 ,0x00 },/* 1, -15.5dB */ - {0x0a ,0x09 ,0x08 ,0x05 ,0x00 ,0x00 ,0x00 ,0x00 },/* 2, -15.0dB */ - {0x0a ,0x0a ,0x09 ,0x05 ,0x00 ,0x00 ,0x00 ,0x00 },/* 3, -14.5dB */ - {0x0b ,0x0a ,0x09 ,0x05 ,0x00 ,0x00 ,0x00 ,0x00 },/* 4, -14.0dB */ - {0x0b ,0x0b ,0x0a ,0x06 ,0x00 ,0x00 ,0x00 ,0x00 },/* 5, -13.5dB */ - {0x0c ,0x0c ,0x0a ,0x06 ,0x00 ,0x00 ,0x00 ,0x00 },/* 6, -13.0dB */ - {0x0d ,0x0c ,0x0b ,0x06 ,0x00 ,0x00 ,0x00 ,0x00 },/* 7, -12.5dB */ - {0x0d ,0x0d ,0x0c ,0x07 ,0x00 ,0x00 ,0x00 ,0x00 },/* 8, -12.0dB */ - {0x0e ,0x0e ,0x0c ,0x07 ,0x00 ,0x00 ,0x00 ,0x00 },/* 9, -11.5dB */ - {0x0f ,0x0f ,0x0d ,0x08 ,0x00 ,0x00 ,0x00 ,0x00 },/* 10, -11.0dB */ - {0x10 ,0x10 ,0x0e ,0x08 ,0x00 ,0x00 ,0x00 ,0x00 },/* 11, -10.5dB */ - {0x11 ,0x11 ,0x0f ,0x09 ,0x00 ,0x00 ,0x00 ,0x00 },/* 12, -10.0dB */ - {0x12 ,0x12 ,0x0f ,0x09 ,0x00 ,0x00 ,0x00 ,0x00 },/* 13, -9.5dB */ - {0x13 ,0x13 ,0x10 ,0x0a ,0x00 ,0x00 ,0x00 ,0x00 },/* 14, -9.0dB */ - {0x14 ,0x14 ,0x11 ,0x0a ,0x00 ,0x00 ,0x00 ,0x00 },/* 15, -8.5dB */ - {0x16 ,0x15 ,0x12 ,0x0b ,0x00 ,0x00 ,0x00 ,0x00 },/* 16, -8.0dB */ - {0x17 ,0x16 ,0x13 ,0x0b ,0x00 ,0x00 ,0x00 ,0x00 },/* 17, -7.5dB */ - {0x18 ,0x17 ,0x15 ,0x0c ,0x00 ,0x00 ,0x00 ,0x00 },/* 18, -7.0dB */ - {0x1a ,0x19 ,0x16 ,0x0d ,0x00 ,0x00 ,0x00 ,0x00 },/* 19, -6.5dB */ - {0x1b ,0x1a ,0x17 ,0x0e ,0x00 ,0x00 ,0x00 ,0x00 },/* 20, -6.0dB */ - {0x1d ,0x1c ,0x18 ,0x0e ,0x00 ,0x00 ,0x00 ,0x00 },/* 21, -5.5dB */ - {0x1f ,0x1e ,0x1a ,0x0f ,0x00 ,0x00 ,0x00 ,0x00 },/* 22, -5.0dB */ - {0x20 ,0x20 ,0x1b ,0x10 ,0x00 ,0x00 ,0x00 ,0x00 },/* 23, -4.5dB */ - {0x22 ,0x21 ,0x1d ,0x11 ,0x00 ,0x00 ,0x00 ,0x00 },/* 24, -4.0dB */ - {0x24 ,0x23 ,0x1f ,0x12 ,0x00 ,0x00 ,0x00 ,0x00 },/* 25, -3.5dB */ - {0x26 ,0x25 ,0x21 ,0x13 ,0x00 ,0x00 ,0x00 ,0x00 },/* 26, -3.0dB */ - {0x28 ,0x28 ,0x24 ,0x14 ,0x00 ,0x00 ,0x00 ,0x00 },/* 27, -2.5dB */ - {0x2b ,0x2a ,0x25 ,0x15 ,0x00 ,0x00 ,0x00 ,0x00 },/* 28, -2.0dB */ - {0x2d ,0x2d ,0x17 ,0x17 ,0x00 ,0x00 ,0x00 ,0x00 },/* 29, -1.5dB */ - {0x30 ,0x2f ,0x29 ,0x18 ,0x00 ,0x00 ,0x00 ,0x00 },/* 30, -1.0dB */ - {0x33 ,0x32 ,0x2b ,0x19 ,0x00 ,0x00 ,0x00 ,0x00 },/* 31, -0.5dB */ - {0x36 ,0x35 ,0x2e ,0x1b ,0x00 ,0x00 ,0x00 ,0x00 }/* 32, +0dB */ -}; -static const u32 edca_setting_dl[PEER_MAX ] = {0xa44f ,/* 0 UNKNOWN */ 0x5ea44f ,/* 1 REALTEK_90 */
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 475/542 rtlwifi: rtl8192ee: remove unused variables
In reply to Sasha LevinFrom: YueHaibing <[email protected]>
[ Upstream commit 253e5aba937973fd29bd5c559d21e35d0642242e ]
drivers/net/wireless/realtek/rtlwifi/rtl8192ee/dm.c:15:18:
warning: ofdmswing_table defined but not used [-Wunused-const-variable=]drivers/net/wireless/realtek/rtlwifi/rtl8192ee/dm.c:61:17:
warning: cckswing_table_ch1ch13 defined but not used [-Wunused-const-variable=]drivers/net/wireless/realtek/rtlwifi/rtl8192ee/dm.c:97:17:
warning: cckswing_table_ch14 defined but not used [-Wunused-const-variable=]
These variable is never used, so remove them.
--- .../wireless/realtek/rtlwifi/rtl8192ee/dm.c | 118 ------------------ 1 file changed, 118 deletions(-)
drivers/net/wireless/realtek/rtlwifi/rtl8192ee/dm.c +0 -118
@@ -12,124 +12,6 @@#include "fw.h" #include "trx.h" -static const u32 ofdmswing_table[OFDM_TABLE_SIZE ] = { -0x7f8001fe ,/* 0, +6.0dB */ -0x788001e2 ,/* 1, +5.5dB */ -0x71c001c7 ,/* 2, +5.0dB */ -0x6b8001ae ,/* 3, +4.5dB */ -0x65400195 ,/* 4, +4.0dB */ -0x5fc0017f ,/* 5, +3.5dB */ -0x5a400169 ,/* 6, +3.0dB */ -0x55400155 ,/* 7, +2.5dB */ -0x50800142 ,/* 8, +2.0dB */ -0x4c000130 ,/* 9, +1.5dB */ -0x47c0011f ,/* 10, +1.0dB */ -0x43c0010f ,/* 11, +0.5dB */ -0x40000100 ,/* 12, +0dB */ -0x3c8000f2 ,/* 13, -0.5dB */ -0x390000e4 ,/* 14, -1.0dB */ -0x35c000d7 ,/* 15, -1.5dB */ -0x32c000cb ,/* 16, -2.0dB */ -0x300000c0 ,/* 17, -2.5dB */ -0x2d4000b5 ,/* 18, -3.0dB */ -0x2ac000ab ,/* 19, -3.5dB */ -0x288000a2 ,/* 20, -4.0dB */ -0x26000098 ,/* 21, -4.5dB */ -0x24000090 ,/* 22, -5.0dB */ -0x22000088 ,/* 23, -5.5dB */ -0x20000080 ,/* 24, -6.0dB */ -0x1e400079 ,/* 25, -6.5dB */ -0x1c800072 ,/* 26, -7.0dB */ -0x1b00006c ,/* 27. -7.5dB */ -0x19800066 ,/* 28, -8.0dB */ -0x18000060 ,/* 29, -8.5dB */ -0x16c0005b ,/* 30, -9.0dB */ -0x15800056 ,/* 31, -9.5dB */ -0x14400051 ,/* 32, -10.0dB */ -0x1300004c ,/* 33, -10.5dB */ -0x12000048 ,/* 34, -11.0dB */ -0x11000044 ,/* 35, -11.5dB */ -0x10000040 ,/* 36, -12.0dB */ -0x0f00003c ,/* 37, -12.5dB */ -0x0e400039 ,/* 38, -13.0dB */ -0x0d800036 ,/* 39, -13.5dB */ -0x0cc00033 ,/* 40, -14.0dB */ -0x0c000030 ,/* 41, -14.5dB */ -0x0b40002d ,/* 42, -15.0dB */ -}; - -static const u8 cckswing_table_ch1ch13[CCK_TABLE_SIZE ][8 ] = { - {0x36 ,0x35 ,0x2e ,0x25 ,0x1c ,0x12 ,0x09 ,0x04 },/* 0, +0dB */ - {0x33 ,0x32 ,0x2b ,0x23 ,0x1a ,0x11 ,0x08 ,0x04 },/* 1, -0.5dB */ - {0x30 ,0x2f ,0x29 ,0x21 ,0x19 ,0x10 ,0x08 ,0x03 },/* 2, -1.0dB */ - {0x2d ,0x2d ,0x27 ,0x1f ,0x18 ,0x0f ,0x08 ,0x03 },/* 3, -1.5dB */ - {0x2b ,0x2a ,0x25 ,0x1e ,0x16 ,0x0e ,0x07 ,0x03 },/* 4, -2.0dB */ - {0x28 ,0x28 ,0x22 ,0x1c ,0x15 ,0x0d ,0x07 ,0x03 },/* 5, -2.5dB */ - {0x26 ,0x25 ,0x21 ,0x1b ,0x14 ,0x0d ,0x06 ,0x03 },/* 6, -3.0dB */ - {0x24 ,0x23 ,0x1f ,0x19 ,0x13 ,0x0c ,0x06 ,0x03 },/* 7, -3.5dB */ - {0x22 ,0x21 ,0x1d ,0x18 ,0x11 ,0x0b ,0x06 ,0x02 },/* 8, -4.0dB */ - {0x20 ,0x20 ,0x1b ,0x16 ,0x11 ,0x08 ,0x05 ,0x02 },/* 9, -4.5dB */ - {0x1f ,0x1e ,0x1a ,0x15 ,0x10 ,0x0a ,0x05 ,0x02 },/* 10, -5.0dB */ - {0x1d ,0x1c ,0x18 ,0x14 ,0x0f ,0x0a ,0x05 ,0x02 },/* 11, -5.5dB */ - {0x1b ,0x1a ,0x17 ,0x13 ,0x0e ,0x09 ,0x04 ,0x02 },/* 12, -6.0dB */ - {0x1a ,0x19 ,0x16 ,0x12 ,0x0d ,0x09 ,0x04 ,0x02 },/* 13, -6.5dB */ - {0x18 ,0x17 ,0x15 ,0x11 ,0x0c ,0x08 ,0x04 ,0x02 },/* 14, -7.0dB */ - {0x17 ,0x16 ,0x13 ,0x10 ,0x0c ,0x08 ,0x04 ,0x02 },/* 15, -7.5dB */ - {0x16 ,0x15 ,0x12 ,0x0f ,0x0b ,0x07 ,0x04 ,0x01 },/* 16, -8.0dB */ - {0x14 ,0x14 ,0x11 ,0x0e ,0x0b ,0x07 ,0x03 ,0x02 },/* 17, -8.5dB */ - {0x13 ,0x13 ,0x10 ,0x0d ,0x0a ,0x06 ,0x03 ,0x01 },/* 18, -9.0dB */ - {0x12 ,0x12 ,0x0f ,0x0c ,0x09 ,0x06 ,0x03 ,0x01 },/* 19, -9.5dB */ - {0x11 ,0x11 ,0x0f ,0x0c ,0x09 ,0x06 ,0x03 ,0x01 },/* 20, -10.0dB */ - {0x10 ,0x10 ,0x0e ,0x0b ,0x08 ,0x05 ,0x03 ,0x01 },/* 21, -10.5dB */ - {0x0f ,0x0f ,0x0d ,0x0b ,0x08 ,0x05 ,0x03 ,0x01 },/* 22, -11.0dB */ - {0x0e ,0x0e ,0x0c ,0x0a ,0x08 ,0x05 ,0x02 ,0x01 },/* 23, -11.5dB */ - {0x0d ,0x0d ,0x0c ,0x0a ,0x07 ,0x05 ,0x02 ,0x01 },/* 24, -12.0dB */ - {0x0d ,0x0c ,0x0b ,0x09 ,0x07 ,0x04 ,0x02 ,0x01 },/* 25, -12.5dB */ - {0x0c ,0x0c ,0x0a ,0x09 ,0x06 ,0x04 ,0x02 ,0x01 },/* 26, -13.0dB */ - {0x0b ,0x0b ,0x0a ,0x08 ,0x06 ,0x04 ,0x02 ,0x01 },/* 27, -13.5dB */ - {0x0b ,0x0a ,0x09 ,0x08 ,0x06 ,0x04 ,0x02 ,0x01 },/* 28, -14.0dB */ - {0x0a ,0x0a ,0x09 ,0x07 ,0x05 ,0x03 ,0x02 ,0x01 },/* 29, -14.5dB */ - {0x0a ,0x09 ,0x08 ,0x07 ,0x05 ,0x03 ,0x02 ,0x01 },/* 30, -15.0dB */ - {0x09 ,0x09 ,0x08 ,0x06 ,0x05 ,0x03 ,0x01 ,0x01 },/* 31, -15.5dB */ - {0x09 ,0x08 ,0x07 ,0x06 ,0x04 ,0x03 ,0x01 ,0x01 }/* 32, -16.0dB */ -}; - -static const u8 cckswing_table_ch14[CCK_TABLE_SIZE ][8 ] = { - {0x36 ,0x35 ,0x2e ,0x1b ,0x00 ,0x00 ,0x00 ,0x00 },/* 0, +0dB */ - {0x33 ,0x32 ,0x2b ,0x19 ,0x00 ,0x00 ,0x00 ,0x00 },/* 1, -0.5dB */ - {0x30 ,0x2f ,0x29 ,0x18 ,0x00 ,0x00 ,0x00 ,0x00 },/* 2, -1.0dB */ - {0x2d ,0x2d ,0x17 ,0x17 ,0x00 ,0x00 ,0x00 ,0x00 },/* 3, -1.5dB */ - {0x2b ,0x2a ,0x25 ,0x15 ,0x00 ,0x00 ,0x00 ,0x00 },/* 4, -2.0dB */ - {0x28 ,0x28 ,0x24 ,0x14 ,0x00 ,0x00 ,0x00 ,0x00 },/* 5, -2.5dB */ - {0x26 ,0x25 ,0x21 ,0x13 ,0x00 ,0x00 ,0x00 ,0x00 },/* 6, -3.0dB */ - {0x24 ,0x23 ,0x1f ,0x12 ,0x00 ,0x00 ,0x00 ,0x00 },/* 7, -3.5dB */ - {0x22 ,0x21 ,0x1d ,0x11 ,0x00 ,0x00 ,0x00 ,0x00 },/* 8, -4.0dB */ - {0x20 ,0x20 ,0x1b ,0x10 ,0x00 ,0x00 ,0x00 ,0x00 },/* 9, -4.5dB */ - {0x1f ,0x1e ,0x1a ,0x0f ,0x00 ,0x00 ,0x00 ,0x00 },/* 10, -5.0dB */ - {0x1d ,0x1c ,0x18 ,0x0e ,0x00 ,0x00 ,0x00 ,0x00 },/* 11, -5.5dB */ - {0x1b ,0x1a ,0x17 ,0x0e ,0x00 ,0x00 ,0x00 ,0x00 },/* 12, -6.0dB */ - {0x1a ,0x19 ,0x16 ,0x0d ,0x00 ,0x00 ,0x00 ,0x00 },/* 13, -6.5dB */ - {0x18 ,0x17 ,0x15 ,0x0c ,0x00 ,0x00 ,0x00 ,0x00 },/* 14, -7.0dB */ - {0x17 ,0x16 ,0x13 ,0x0b ,0x00 ,0x00 ,0x00 ,0x00 },/* 15, -7.5dB */ - {0x16 ,0x15 ,0x12 ,0x0b ,0x00 ,0x00 ,0x00 ,0x00 },/* 16, -8.0dB */ - {0x14 ,0x14 ,0x11 ,0x0a ,0x00 ,0x00 ,0x00 ,0x00 },/* 17, -8.5dB */ - {0x13 ,0x13 ,0x10 ,0x0a ,0x00 ,0x00 ,0x00 ,0x00 },/* 18, -9.0dB */ - {0x12 ,0x12 ,0x0f ,0x09 ,0x00 ,0x00 ,0x00 ,0x00 },/* 19, -9.5dB */ - {0x11 ,0x11 ,0x0f ,0x09 ,0x00 ,0x00 ,0x00 ,0x00 },/* 20, -10.0dB */ - {0x10 ,0x10 ,0x0e ,0x08 ,0x00 ,0x00 ,0x00 ,0x00 },/* 21, -10.5dB */ - {0x0f ,0x0f ,0x0d ,0x08 ,0x00 ,0x00 ,0x00 ,0x00 },/* 22, -11.0dB */ - {0x0e ,0x0e ,0x0c ,0x07 ,0x00 ,0x00 ,0x00 ,0x00 },/* 23, -11.5dB */ - {0x0d ,0x0d ,0x0c ,0x07 ,0x00 ,0x00 ,0x00 ,0x00 },/* 24, -12.0dB */ - {0x0d ,0x0c ,0x0b ,0x06 ,0x00 ,0x00 ,0x00 ,0x00 },/* 25, -12.5dB */ - {0x0c ,0x0c ,0x0a ,0x06 ,0x00 ,0x00 ,0x00 ,0x00 },/* 26, -13.0dB */ - {0x0b ,0x0b ,0x0a ,0x06 ,0x00 ,0x00 ,0x00 ,0x00 },/* 27, -13.5dB */ - {0x0b ,0x0a ,0x09 ,0x05 ,0x00 ,0x00 ,0x00 ,0x00 },/* 28, -14.0dB */ - {0x0a ,0x0a ,0x09 ,0x05 ,0x00 ,0x00 ,0x00 ,0x00 },/* 29, -14.5dB */ - {0x0a ,0x09 ,0x08 ,0x05 ,0x00 ,0x00 ,0x00 ,0x00 },/* 30, -15.0dB */ - {0x09 ,0x09 ,0x08 ,0x05 ,0x00 ,0x00 ,0x00 ,0x00 },/* 31, -15.5dB */ - {0x09 ,0x08 ,0x07 ,0x04 ,0x00 ,0x00 ,0x00 ,0x00 }/* 32, -16.0dB */ -}; -static void rtl92ee_dm_false_alarm_counter_statistics (struct ieee80211_hw *hw) {u32 ret_value;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 476/542 rtlwifi: rtl8723ae: remove unused variables
In reply to Sasha LevinFrom: YueHaibing <[email protected]>
[ Upstream commit c5f9852411098474ab21f5d7b1b84e5cdd59ca5a ]
drivers/net/wireless/realtek/rtlwifi/rtl8723ae/dm.c:16:18:
warning: ofdmswing_table defined but not used [-Wunused-const-variable=]drivers/net/wireless/realtek/rtlwifi/rtl8723ae/dm.c:56:17:
warning: cckswing_table_ch1ch13 defined but not used [-Wunused-const-variable=]drivers/net/wireless/realtek/rtlwifi/rtl8723ae/dm.c:92:17:
warning: cckswing_table_ch14 defined but not used [-Wunused-const-variable=]
These variable is never used, so remove them.
--- .../wireless/realtek/rtlwifi/rtl8723ae/dm.c | 112 ------------------ 1 file changed, 112 deletions(-)
drivers/net/wireless/realtek/rtlwifi/rtl8723ae/dm.c +0 -112
@@ -13,118 +13,6 @@#include "fw.h" #include "hal_btc.h" -static const u32 ofdmswing_table[OFDM_TABLE_SIZE ] = { -0x7f8001fe , -0x788001e2 , -0x71c001c7 , -0x6b8001ae , -0x65400195 , -0x5fc0017f , -0x5a400169 , -0x55400155 , -0x50800142 , -0x4c000130 , -0x47c0011f , -0x43c0010f , -0x40000100 , -0x3c8000f2 , -0x390000e4 , -0x35c000d7 , -0x32c000cb , -0x300000c0 , -0x2d4000b5 , -0x2ac000ab , -0x288000a2 , -0x26000098 , -0x24000090 , -0x22000088 , -0x20000080 , -0x1e400079 , -0x1c800072 , -0x1b00006c , -0x19800066 , -0x18000060 , -0x16c0005b , -0x15800056 , -0x14400051 , -0x1300004c , -0x12000048 , -0x11000044 , -0x10000040 , -}; - -static const u8 cckswing_table_ch1ch13[CCK_TABLE_SIZE ][8 ] = { - {0x36 ,0x35 ,0x2e ,0x25 ,0x1c ,0x12 ,0x09 ,0x04 }, - {0x33 ,0x32 ,0x2b ,0x23 ,0x1a ,0x11 ,0x08 ,0x04 }, - {0x30 ,0x2f ,0x29 ,0x21 ,0x19 ,0x10 ,0x08 ,0x03 }, - {0x2d ,0x2d ,0x27 ,0x1f ,0x18 ,0x0f ,0x08 ,0x03 }, - {0x2b ,0x2a ,0x25 ,0x1e ,0x16 ,0x0e ,0x07 ,0x03 }, - {0x28 ,0x28 ,0x22 ,0x1c ,0x15 ,0x0d ,0x07 ,0x03 }, - {0x26 ,0x25 ,0x21 ,0x1b ,0x14 ,0x0d ,0x06 ,0x03 }, - {0x24 ,0x23 ,0x1f ,0x19 ,0x13 ,0x0c ,0x06 ,0x03 }, - {0x22 ,0x21 ,0x1d ,0x18 ,0x11 ,0x0b ,0x06 ,0x02 }, - {0x20 ,0x20 ,0x1b ,0x16 ,0x11 ,0x08 ,0x05 ,0x02 }, - {0x1f ,0x1e ,0x1a ,0x15 ,0x10 ,0x0a ,0x05 ,0x02 }, - {0x1d ,0x1c ,0x18 ,0x14 ,0x0f ,0x0a ,0x05 ,0x02 }, - {0x1b ,0x1a ,0x17 ,0x13 ,0x0e ,0x09 ,0x04 ,0x02 }, - {0x1a ,0x19 ,0x16 ,0x12 ,0x0d ,0x09 ,0x04 ,0x02 }, - {0x18 ,0x17 ,0x15 ,0x11 ,0x0c ,0x08 ,0x04 ,0x02 }, - {0x17 ,0x16 ,0x13 ,0x10 ,0x0c ,0x08 ,0x04 ,0x02 }, - {0x16 ,0x15 ,0x12 ,0x0f ,0x0b ,0x07 ,0x04 ,0x01 }, - {0x14 ,0x14 ,0x11 ,0x0e ,0x0b ,0x07 ,0x03 ,0x02 }, - {0x13 ,0x13 ,0x10 ,0x0d ,0x0a ,0x06 ,0x03 ,0x01 }, - {0x12 ,0x12 ,0x0f ,0x0c ,0x09 ,0x06 ,0x03 ,0x01 }, - {0x11 ,0x11 ,0x0f ,0x0c ,0x09 ,0x06 ,0x03 ,0x01 }, - {0x10 ,0x10 ,0x0e ,0x0b ,0x08 ,0x05 ,0x03 ,0x01 }, - {0x0f ,0x0f ,0x0d ,0x0b ,0x08 ,0x05 ,0x03 ,0x01 }, - {0x0e ,0x0e ,0x0c ,0x0a ,0x08 ,0x05 ,0x02 ,0x01 }, - {0x0d ,0x0d ,0x0c ,0x0a ,0x07 ,0x05 ,0x02 ,0x01 }, - {0x0d ,0x0c ,0x0b ,0x09 ,0x07 ,0x04 ,0x02 ,0x01 }, - {0x0c ,0x0c ,0x0a ,0x09 ,0x06 ,0x04 ,0x02 ,0x01 }, - {0x0b ,0x0b ,0x0a ,0x08 ,0x06 ,0x04 ,0x02 ,0x01 }, - {0x0b ,0x0a ,0x09 ,0x08 ,0x06 ,0x04 ,0x02 ,0x01 }, - {0x0a ,0x0a ,0x09 ,0x07 ,0x05 ,0x03 ,0x02 ,0x01 }, - {0x0a ,0x09 ,0x08 ,0x07 ,0x05 ,0x03 ,0x02 ,0x01 }, - {0x09 ,0x09 ,0x08 ,0x06 ,0x05 ,0x03 ,0x01 ,0x01 }, - {0x09 ,0x08 ,0x07 ,0x06 ,0x04 ,0x03 ,0x01 ,0x01 } -}; - -static const u8 cckswing_table_ch14[CCK_TABLE_SIZE ][8 ] = { - {0x36 ,0x35 ,0x2e ,0x1b ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x33 ,0x32 ,0x2b ,0x19 ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x30 ,0x2f ,0x29 ,0x18 ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x2d ,0x2d ,0x17 ,0x17 ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x2b ,0x2a ,0x25 ,0x15 ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x28 ,0x28 ,0x24 ,0x14 ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x26 ,0x25 ,0x21 ,0x13 ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x24 ,0x23 ,0x1f ,0x12 ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x22 ,0x21 ,0x1d ,0x11 ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x20 ,0x20 ,0x1b ,0x10 ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x1f ,0x1e ,0x1a ,0x0f ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x1d ,0x1c ,0x18 ,0x0e ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x1b ,0x1a ,0x17 ,0x0e ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x1a ,0x19 ,0x16 ,0x0d ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x18 ,0x17 ,0x15 ,0x0c ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x17 ,0x16 ,0x13 ,0x0b ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x16 ,0x15 ,0x12 ,0x0b ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x14 ,0x14 ,0x11 ,0x0a ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x13 ,0x13 ,0x10 ,0x0a ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x12 ,0x12 ,0x0f ,0x09 ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x11 ,0x11 ,0x0f ,0x09 ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x10 ,0x10 ,0x0e ,0x08 ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x0f ,0x0f ,0x0d ,0x08 ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x0e ,0x0e ,0x0c ,0x07 ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x0d ,0x0d ,0x0c ,0x07 ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x0d ,0x0c ,0x0b ,0x06 ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x0c ,0x0c ,0x0a ,0x06 ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x0b ,0x0b ,0x0a ,0x06 ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x0b ,0x0a ,0x09 ,0x05 ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x0a ,0x0a ,0x09 ,0x05 ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x0a ,0x09 ,0x08 ,0x05 ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x09 ,0x09 ,0x08 ,0x05 ,0x00 ,0x00 ,0x00 ,0x00 }, - {0x09 ,0x08 ,0x07 ,0x04 ,0x00 ,0x00 ,0x00 ,0x00 } -}; -static u8 rtl8723e_dm_initial_gain_min_pwdb (struct ieee80211_hw *hw) {struct rtl_priv *rtlpriv =rtl_priv (hw);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 477/542 iwlegacy: ensure loop counter addr does not wrap and cause an infinite loop
In reply to Sasha LevinFrom: Colin Ian King <[email protected]>
[ Upstream commit c2f9a4e4a5abfc84c01b738496b3fd2d471e0b18 ]
The loop counter addr is a u16 where as the upper limit of the loop is an int. In the unlikely event that the il->cfg->eeprom_size is greater than 64K then we end up with an infinite loop since addr will wrap around an never reach upper loop limit. Fix this by making addr an int.
Addresses-Coverity: ("Infinite loop")
--- drivers/net/wireless/intel/iwlegacy/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlegacy/common.c +1 -1
@@ -699,7 +699,7 @@ il_eeprom_init(struct il_priv *il)u32 gp =_il_rd (il,CSR_EEPROM_GP );int sz;int ret; -u16 addr; +int addr;/* allocate eeprom */ sz = il->cfg->eeprom_size;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 478/542 cifs: fix unitialized variable poential problem with network I/O cache lock patch
In reply to Sasha LevinFrom: Steve French <[email protected]>
[ Upstream commit 463a7b457c02250a84faa1d23c52da9e3364aed2 ]
static analysis with Coverity detected an issue with the following commit:
Author: Paulo Alcantara (SUSE) <[email protected]>
Date: Wed Dec 4 17:38:03 2019 -0300
cifs: Avoid doing network I/O while holding cache lock
Addresses-Coverity: ("Uninitialized pointer read")
--- fs/cifs/dfs_cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/dfs_cache.c +1 -1
@@ -1319,7 +1319,7 @@ static struct cifs_ses *find_root_ses(struct dfs_cache_vol_info *vi,char *mdata =NULL , *devname =NULL ;struct TCP_Server_Info *server;struct cifs_ses *ses; -struct smb_vol vol; +struct smb_vol vol = {NULL }; rpath =get_dfs_root (path);if (IS_ERR (rpath))
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 479/542 cifs: Fix mount options set in automount
In reply to Sasha LevinFrom: "Paulo Alcantara (SUSE)" <[email protected]>
[ Upstream commit 5739375ee4230980166807d347cc21c305532bbc ]
Starting from 4a367dc04435, we must set the mount options based on the DFS full path rather than the resolved target, that is, cifs_mount() will be responsible for resolving the DFS link (cached) as well as performing failover to any other targets in the referral.
--- fs/cifs/cifs_dfs_ref.c | 97 +++++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 54 deletions(-)
fs/cifs/cifs_dfs_ref.c +43 -54
@@ -120,17 +120,17 @@ cifs_build_devname(char *nodename, const char *prepath)/** -* cifs_compose_mount_options - creates mount options for refferral +* cifs_compose_mount_options - creates mount options for referral * @sb_mountdata: parent/root DFS mount options (template) * @fullpath: full path in UNC format -* @ref: server's referral +* @ref: optional server's referral * @devname: optional pointer for saving device name * * creates mount options for submount based on template options sb_mountdata * and replacing unc,ip,prefixpath options with ones we've got form ref_unc. * * Returns: pointer to new mount options or ERR_PTR. -* Caller is responcible for freeing retunrned value if it is not error. +* Caller is responsible for freeing returned value if it is not error. */ char *cifs_compose_mount_options(const char *sb_mountdata, const char *fullpath,
@@ -150,18 +150,27 @@ char *cifs_compose_mount_options(const char *sb_mountdata,if (sb_mountdata ==NULL )return ERR_PTR (-EINVAL ); -if (strlen (fullpath) - ref->path_consumed) { - prepath = fullpath + ref->path_consumed; -/* skip initial delimiter */ -if (*prepath =='/' || *prepath =='\\' ) - prepath++; - } +if (ref) { +if (strlen (fullpath) - ref->path_consumed) { + prepath = fullpath + ref->path_consumed; +/* skip initial delimiter */ +if (*prepath =='/' || *prepath =='\\' ) + prepath++; + } - name =cifs_build_devname (ref->node_name, prepath); -if (IS_ERR (name)) { - rc =PTR_ERR (name); - name =NULL ; - goto compose_mount_options_err; + name =cifs_build_devname (ref->node_name, prepath); +if (IS_ERR (name)) { + rc =PTR_ERR (name); + name =NULL ; + goto compose_mount_options_err; + } + }else { + name =cifs_build_devname ((char *)fullpath,NULL ); +if (IS_ERR (name)) { + rc =PTR_ERR (name); + name =NULL ; + goto compose_mount_options_err; + } } rc =dns_resolve_server_name_to_ip (name, &srvIP);
@@ -225,6 +234,8 @@ char *cifs_compose_mount_options(const char *sb_mountdata,if (devname) *devname = name; +else +kfree (name);/*cifs_dbg(FYI, "%s: parent mountdata: %s\n", __func__, sb_mountdata);*/ /*cifs_dbg(FYI, "%s: submount mountdata: %s\n", __func__, mountdata );*/
@@ -241,23 +252,23 @@ char *cifs_compose_mount_options(const char *sb_mountdata, }/** -* cifs_dfs_do_refmount - mounts specified path using provided refferal +* cifs_dfs_do_mount - mounts specified path using DFS full path +* +* Always pass down @fullpath to smb3_do_mount() so we can use the root server +* to perform failover in case we failed to connect to the first target in the +* referral. +* * @cifs_sb: parent/root superblock * @fullpath: full path in UNC format -* @ref: server's referral */ -static struct vfsmount *cifs_dfs_do_refmount (struct dentry *mntpt, -struct cifs_sb_info *cifs_sb, -const char *fullpath,const struct dfs_info3_param *ref) +static struct vfsmount *cifs_dfs_do_mount (struct dentry *mntpt, +struct cifs_sb_info *cifs_sb, +const char *fullpath) {struct vfsmount *mnt;char *mountdata;char *devname; -/* -* Always pass down the DFS full path to smb3_do_mount() so we -* can use it later for failover. -*/ devname =kstrndup (fullpath,strlen (fullpath),GFP_KERNEL );if (!devname)return ERR_PTR (-ENOMEM );
@@ -266,7 +277,7 @@ static struct vfsmount *cifs_dfs_do_refmount(struct dentry *mntpt,/* strip first '\' from fullpath */ mountdata =cifs_compose_mount_options (cifs_sb->mountdata, - fullpath +1 , ref,NULL ); + fullpath +1 ,NULL ,NULL );if (IS_ERR (mountdata)) {kfree (devname);return (struct vfsmount *)mountdata;
@@ -278,28 +289,16 @@ static struct vfsmount *cifs_dfs_do_refmount(struct dentry *mntpt,return mnt; } -static void dump_referral (const struct dfs_info3_param *ref) -{ -cifs_dbg (FYI ,"DFS: ref path: %s\n" , ref->path_name); -cifs_dbg (FYI ,"DFS: node path: %s\n" , ref->node_name); -cifs_dbg (FYI ,"DFS: fl: %d, srv_type: %d\n" , - ref->flags, ref->server_type); -cifs_dbg (FYI ,"DFS: ref_flags: %d, path_consumed: %d\n" , - ref->ref_flag, ref->path_consumed); -} -/* * Create a vfsmount that we can automount */ static struct vfsmount *cifs_dfs_do_automount (struct dentry *mntpt) { -struct dfs_info3_param referral = {0 };struct cifs_sb_info *cifs_sb;struct cifs_ses *ses;struct cifs_tcon *tcon;char *full_path, *root_path;unsigned int xid; -int len;int rc;struct vfsmount *mnt;
@@ -357,7 +356,7 @@ static struct vfsmount *cifs_dfs_do_automount(struct dentry *mntpt)if (!rc) { rc =dfs_cache_find (xid, ses, cifs_sb->local_nls,cifs_remap (cifs_sb), full_path +1 , - &referral,NULL ); +NULL ,NULL ); }free_xid (xid);
@@ -366,26 +365,16 @@ static struct vfsmount *cifs_dfs_do_automount(struct dentry *mntpt) mnt =ERR_PTR (rc); goto free_root_path; } - -dump_referral (&referral); - - len =strlen (referral.node_name); -if (len <2 ) { -cifs_dbg (VFS ,"%s: Net Address path too short: %s\n" , - __func__, referral.node_name); - mnt =ERR_PTR (-EINVAL ); - goto free_dfs_ref; - }/* -* cifs_mount() will retry every available node server in case -* of failures. +* OK - we were able to get and cache a referral for @full_path. +* +* Now, pass it down to cifs_mount() and it will retry every available +* node server in case of failures - no need to do it here. */ - mnt =cifs_dfs_do_refmount (mntpt, cifs_sb, full_path, &referral); -cifs_dbg (FYI ,"%s: cifs_dfs_do_refmount:%s , mnt:%p\n" , __func__, - referral.node_name, mnt); + mnt =cifs_dfs_do_mount (mntpt, cifs_sb, full_path); +cifs_dbg (FYI ,"%s: cifs_dfs_do_mount:%s , mnt:%p\n" , __func__, + full_path +1 , mnt); -free_dfs_ref: -free_dfs_info_param (&referral); free_root_path:kfree (root_path); free_full_path:
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 480/542 cifs: fix NULL dereference in match_prepath
In reply to Sasha LevinFrom: Ronnie Sahlberg <[email protected]>
[ Upstream commit fe1292686333d1dadaf84091f585ee903b9ddb84 ]
RHBZ: 1760879
Fix an oops in match_prepath() by making sure that the prepath string is not NULL before we pass it into strcmp().
This is similar to other checks we make for example in cifs_root_iget()
--- fs/cifs/connect.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/cifs/connect.c +4 -2
@@ -3709,8 +3709,10 @@ match_prepath(struct super_block *sb, struct cifs_mnt_data *mnt_data) {struct cifs_sb_info *old =CIFS_SB (sb);struct cifs_sb_info *new = mnt_data->cifs_sb; -bool old_set = old->mnt_cifs_flags &CIFS_MOUNT_USE_PREFIX_PATH ; -bool new_set = new->mnt_cifs_flags &CIFS_MOUNT_USE_PREFIX_PATH ; +bool old_set = (old->mnt_cifs_flags &CIFS_MOUNT_USE_PREFIX_PATH ) && + old->prepath; +bool new_set = (new->mnt_cifs_flags &CIFS_MOUNT_USE_PREFIX_PATH ) && + new->prepath;if (old_set && new_set && !strcmp (new->prepath, old->prepath))return 1 ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 481/542 video: hyperv: hyperv_fb: Use physical memory for fb on HyperV Gen 1 VMs.
In reply to Sasha LevinFrom: Wei Hu <[email protected]>
[ Upstream commit 3a6fb6c4255c3893ab61e2bd4e9ae01ca6bbcd94 ]
On Hyper-V, Generation 1 VMs can directly use VM's physical memory for their framebuffers. This can improve the efficiency of framebuffer and overall performence for VM. The physical memory assigned to framebuffer must be contiguous. We use CMA allocator to get contiguouse physicial memory when the framebuffer size is greater than 4MB. For size under 4MB, we use alloc_pages to achieve this.
To enable framebuffer memory allocation from CMA, supply a kernel parameter to give enough space to CMA allocator at boot time. For example:
cma0m
This gives 130MB memory to CAM allocator that can be allocated to framebuffer. If this fails, we fall back to the old way of using mmio for framebuffer.
--- drivers/video/fbdev/Kconfig | 1 + drivers/video/fbdev/hyperv_fb.c | 182 +++++++++++++++++++++++++------- 2 files changed, 144 insertions(+), 39 deletions(-)
drivers/video/fbdev/Kconfig +1 -0
@@ -2215,6 +2215,7 @@ config FB_HYPERV select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT select FB_DEFERRED_IO + select DMA_CMA if HAVE_DMA_CONTIGUOUS && CMA help This framebuffer driver supports Microsoft Hyper-V Synthetic Video.
drivers/video/fbdev/hyperv_fb.c +142 -38
291 lines not on this page · raw message
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 482/542 bpf: map_seq_next should always increase position index
In reply to Sasha LevinFrom: Vasily Averin <[email protected]>
[ Upstream commit 90435a7891a2259b0f74c5a1bc5600d0d64cba8f ]
If seq_file .next fuction does not change position index, read after some lseek can generate an unexpected output.
See also: https://bugzilla.kernel.org/show_bug.cgi?id=206283
v1 -> v2: removed missed increment in end of function
--- kernel/bpf/inode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/bpf/inode.c +1 -2
@@ -196,6 +196,7 @@ static void *map_seq_next(struct seq_file *m, void *v, loff_t *pos)void *key =map_iter (m)->key;void *prev_key; + (*pos)++;if (map_iter (m)->done)return NULL ;
@@ -208,8 +209,6 @@ static void *map_seq_next(struct seq_file *m, void *v, loff_t *pos)map_iter (m)->done = true;return NULL ; } - - ++(*pos);return key; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 483/542 powerpc/mm: Don't log user reads to 0xffffffff
In reply to Sasha LevinFrom: Christophe Leroy <[email protected]>
[ Upstream commit 0f9aee0cb9da7db7d96f63cfa2dc5e4f1bffeb87 ]
Running vdsotest leaves many times the following log:
[ 79.629901] vdsotest[396]: User access of kernel address (ffffffff) - exploit attempt? (uid: 0)
A pointer set to (-1) is likely a programming error similar to a NULL pointer and is not worth logging as an exploit attempt.
Don't log user accesses to 0xffffffff.
--- arch/powerpc/mm/fault.c | 3 +++ 1 file changed, 3 insertions(+)
arch/powerpc/mm/fault.c +3 -0
@@ -354,6 +354,9 @@ static void sanity_check_fault(bool is_write, bool is_user,* Userspace trying to access kernel address, we get PROTFAULT for that. */ if (is_user && address >=TASK_SIZE ) { +if ((long )address ==-1 ) +return ; +pr_crit_ratelimited ("%s[%d]: User access of kernel address (%lx) - exploit attempt? (uid: %d)\n" , current->comm, current->pid, address,from_kuid (&init_user_ns,current_uid ()));
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 484/542 mwifiex: Fix possible buffer overflows in mwifiex_ret_wmm_get_status()
In reply to Sasha LevinFrom: Qing Xu <[email protected]>
[ Upstream commit 3a9b153c5591548612c3955c9600a98150c81875 ]
mwifiex_ret_wmm_get_status() calls memcpy() without checking the destination size.Since the source is given from remote AP which contains illegal wmm elements , this may trigger a heap buffer overflow.
Fix it by putting the length check before calling memcpy().
--- drivers/net/wireless/marvell/mwifiex/wmm.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/marvell/mwifiex/wmm.c +4 -0
@@ -970,6 +970,10 @@ int mwifiex_ret_wmm_get_status(struct mwifiex_private *priv,"WMM Parameter Set Count: %d\n" , wmm_param_ie->qos_info_bitmap & mask); +if (wmm_param_ie->vend_hdr.len +2 > +sizeof (struct ieee_types_wmm_parameter )) +break ; +memcpy ((u8 *) &priv->curr_bss_params.bss_descriptor. wmm_ie, wmm_param_ie, wmm_param_ie->vend_hdr.len +2 );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 485/542 mwifiex: Fix possible buffer overflows in mwifiex_cmd_append_vsie_tlv()
In reply to Sasha LevinFrom: Qing Xu <[email protected]>
[ Upstream commit b70261a288ea4d2f4ac7cd04be08a9f0f2de4f4d ]
mwifiex_cmd_append_vsie_tlv() calls memcpy() without checking the destination size may trigger a buffer overflower, which a local user could use to cause denial of service or the execution of arbitrary code.
Fix it by putting the length check before calling memcpy().
--- drivers/net/wireless/marvell/mwifiex/scan.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/wireless/marvell/mwifiex/scan.c +7 -0
@@ -2884,6 +2884,13 @@ mwifiex_cmd_append_vsie_tlv(struct mwifiex_private *priv, vs_param_set->header.len =cpu_to_le16 ((((u16 ) priv->vs_ie[id].ie[1 ]) &0x00FF ) +2 ); +if (le16_to_cpu (vs_param_set->header.len) > +MWIFIEX_MAX_VSIE_LEN ) { +mwifiex_dbg (priv->adapter,ERROR , +"Invalid param length!\n" ); +break ; + } +memcpy (vs_param_set->ie, priv->vs_ie[id].ie,le16_to_cpu (vs_param_set->header.len)); *buffer += le16_to_cpu(vs_param_set->header.len) +
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 486/542 ceph: check availability of mds cluster on mount after wait timeout
In reply to Sasha LevinFrom: Xiubo Li <[email protected]>
[ Upstream commit 97820058fb2831a4b203981fa2566ceaaa396103 ]
If all the MDS daemons are down for some reason, then the first mount attempt will fail with EIO after the mount request times out. A mount attempt will also fail with EIO if all of the MDS's are laggy.
This patch changes the code to return -EHOSTUNREACH in these situations and adds a pr_info error message to help the admin determine the cause.
URL: https://tracker.ceph.com/issues/4386
--- fs/ceph/mds_client.c | 3 +-- fs/ceph/super.c | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-)
fs/ceph/mds_client.c +1 -2
@@ -2558,8 +2558,7 @@ static void __do_request(struct ceph_mds_client *mdsc,if (!(mdsc->fsc->mount_options->flags &CEPH_MOUNT_OPT_MOUNTWAIT ) && !ceph_mdsmap_is_cluster_available (mdsc->mdsmap)) { - err = -ENOENT ; -pr_info ("probably no mds server is up\n" ); + err = -EHOSTUNREACH ; goto finish; } }
fs/ceph/super.c +5 -0
@@ -1070,6 +1070,11 @@ static int ceph_get_tree(struct fs_context *fc)return 0 ; out_splat: +if (!ceph_mdsmap_is_cluster_available (fsc->mdsc->mdsmap)) { +pr_info ("No mds server is up or the cluster is laggy\n" ); + err = -EHOSTUNREACH ; + } +ceph_mdsc_close_sessions (fsc->mdsc);deactivate_locked_super (sb); goto out_final;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 487/542 ceph: remove the extra slashes in the server path
In reply to Sasha LevinFrom: Xiubo Li <[email protected]>
[ Upstream commit 4fbc0c711b2464ee1551850b85002faae0b775d5 ]
It's possible to pass the mount helper a server path that has more than one contiguous slash character. For example:
$ mount -t ceph 192.168.195.165:40176:/// /mnt/cephfs/
In the MDS server side the extra slashes of the server path will be treated as snap dir, and then we can get the following debug logs:
ceph: mount opening path // ceph: open_root_inode opening '//' ceph: fill_trace 0000000059b8a3bc is_dentry 0 is_target 1 ceph: alloc_inode 00000000dc4ca00b ceph: get_inode created new inode 00000000dc4ca00b 1.ffffffffffffffff ino 1 ceph: get_inode on 1=1.ffffffffffffffff got 00000000dc4ca00b
And then when creating any new file or directory under the mount point, we can hit the following BUG_ON in ceph_fill_trace():
BUG_ON(ceph_snap(dir) != dvino.snap);
Have the client ignore the extra slashes in the server path when mounting. This will also canonicalize the path, so that identical mounts can be consilidated.
1) "//mydir1///mydir//"
2) "/mydir1/mydir"
3) "/mydir1/mydir/"
Regardless of the internal treatment of these paths, the kernel still stores the original string including the leading '/' for presentation to userland.
URL: https://tracker.ceph.com/issues/42771
--- fs/ceph/super.c | 122 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 102 insertions(+), 20 deletions(-)
fs/ceph/super.c +102 -20
@@ -107,7 +107,6 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)return 0 ; } -static int ceph_sync_fs (struct super_block *sb,int wait) {struct ceph_fs_client *fsc =ceph_sb_to_client (sb);
@@ -211,7 +210,6 @@ struct ceph_parse_opts_ctx {/* * Parse the source parameter. Distinguish the server list from the path. -* Internally we do not include the leading '/' in the path. * * The source will look like: * <server_spec>[,<server_spec>...]:[<path>]
@@ -232,12 +230,15 @@ static int ceph_parse_source(struct fs_parameter *param, struct fs_context *fc) dev_name_end =strchr (dev_name,'/' );if (dev_name_end) { -if (strlen (dev_name_end) >1 ) { -kfree (fsopt->server_path); - fsopt->server_path =kstrdup (dev_name_end,GFP_KERNEL ); -if (!fsopt->server_path) -return -ENOMEM ; - } +kfree (fsopt->server_path); + +/* +* The server_path will include the whole chars from userland +* including the leading '/'. +*/ + fsopt->server_path =kstrdup (dev_name_end,GFP_KERNEL ); +if (!fsopt->server_path) +return -ENOMEM ; }else { dev_name_end = dev_name +strlen (dev_name); }
@@ -461,6 +462,73 @@ static int strcmp_null(const char *s1, const char *s2)return strcmp (s1, s2); } +/** +* path_remove_extra_slash - Remove the extra slashes in the server path +* @server_path: the server path and could be NULL +* +* Return NULL if the path is NULL or only consists of "/", or a string +* without any extra slashes including the leading slash(es) and the +* slash(es) at the end of the server path, such as: +* "//dir1////dir2///" --> "dir1/dir2" +*/ +static char *path_remove_extra_slash (const char *server_path) +{ +const char *path = server_path; +const char *cur, *end; +char *buf, *p; +int len; + +/* if the server path is omitted */ +if (!path) +return NULL ; + +/* remove all the leading slashes */ +while (*path =='/' ) + path++; + +/* if the server path only consists of slashes */ +if (*path =='\0' ) +return NULL ; + + len =strlen (path); + + buf =kmalloc (len +1 ,GFP_KERNEL ); +if (!buf) +return ERR_PTR (-ENOMEM ); + + end = path + len; + p = buf; +do { + cur =strchr (path,'/' ); +if (!cur) + cur = end; + + len = cur - path; + +/* including one '/' */ +if (cur != end) + len +=1 ; + +memcpy (p, path, len); + p += len; + +while (cur <= end && *cur =='/' ) + cur++; + path = cur; + }while (path < end); + + *p ='\0' ; + +/* +* remove the last slash if there has and just to make sure that +* we will get something like "dir1/dir2" +*/ +if (*(--p) =='/' ) + *p ='\0' ; + +return buf; +} +static int compare_mount_options (struct ceph_mount_options *new_fsopt,struct ceph_options *new_opt,struct ceph_fs_client *fsc)
@@ -468,6 +536,7 @@ static int compare_mount_options(struct ceph_mount_options *new_fsopt,struct ceph_mount_options *fsopt1 = new_fsopt;struct ceph_mount_options *fsopt2 = fsc->mount_options;int ofs = offsetof(struct ceph_mount_options , snapdir_name); +char *p1, *p2;int ret; ret =memcmp (fsopt1, fsopt2, ofs);
@@ -480,9 +549,21 @@ static int compare_mount_options(struct ceph_mount_options *new_fsopt, ret =strcmp_null (fsopt1->mds_namespace, fsopt2->mds_namespace);if (ret)return ret; - ret =strcmp_null (fsopt1->server_path, fsopt2->server_path); + + p1 =path_remove_extra_slash (fsopt1->server_path); +if (IS_ERR (p1)) +return PTR_ERR (p1); + p2 =path_remove_extra_slash (fsopt2->server_path); +if (IS_ERR (p2)) { +kfree (p1); +return PTR_ERR (p2); + } + ret =strcmp_null (p1, p2); +kfree (p1); +kfree (p2);if (ret)return ret; + ret =strcmp_null (fsopt1->fscache_uniq, fsopt2->fscache_uniq);if (ret)return ret;
@@ -788,7 +869,6 @@ static void destroy_caches(void)ceph_fscache_unregister (); } -/* * ceph_umount_begin - initiate forced umount. Tear down down the * mount, skipping steps that may hang while waiting for server(s).
@@ -868,9 +948,6 @@ static struct dentry *open_root_dentry(struct ceph_fs_client *fsc,return root; } - - -/* * mount: join the ceph cluster, and open root directory. */
@@ -885,7 +962,7 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc,mutex_lock (&fsc->client->mount_mutex);if (!fsc->sb->s_root) { -const char *path; +const char *path, *p; err =__ceph_open_session (fsc->client, started);if (err <0 ) goto out;
@@ -897,17 +974,22 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc, goto out; } -if (!fsc->mount_options->server_path) { - path ="" ; -dout ("mount opening path \\t\n" ); - }else { - path = fsc->mount_options->server_path +1 ; -dout ("mount opening path %s\n" , path); + p =path_remove_extra_slash (fsc->mount_options->server_path); +if (IS_ERR (p)) { + err =PTR_ERR (p); + goto out; } +/* if the server path is omitted or just consists of '/' */ +if (!p) + path ="" ; +else + path = p; +dout ("mount opening path '%s'\n" , path);ceph_fs_debugfs_init (fsc); root =open_root_dentry (fsc, path, started); +kfree (p);if (IS_ERR (root)) { err =PTR_ERR (root); goto out;
Signature · 1 line
2.20.1
Re: [PATCH AUTOSEL 5.5 487/542] ceph: remove the extra slashes in the server path
Quoted 239 lines · Sasha Levin
From: Xiubo Li <[email protected]>
[ Upstream commit
4fbc0c711b2464ee1551850b85002faae0b775d5]It's possible to pass the mount helper a server path that has more than one contiguous slash character. For example:
$ mount -t ceph 192.168.195.165:40176:/// /mnt/cephfs/In the MDS server side the extra slashes of the server path will be treated as snap dir, and then we can get the following debug logs:
ceph: mount opening path // ceph: open_root_inode opening '//' ceph: fill_trace 0000000059b8a3bc is_dentry 0 is_target 1 ceph: alloc_inode 00000000dc4ca00b ceph: get_inode created new inode 00000000dc4ca00b 1.ffffffffffffffff ino 1 ceph: get_inode on 1=1.ffffffffffffffff got 00000000dc4ca00bAnd then when creating any new file or directory under the mount point, we can hit the following
BUG_ONinceph_fill_trace():BUG_ON(ceph_snap(dir) != dvino.snap);Have the client ignore the extra slashes in the server path when mounting. This will also canonicalize the path, so that identical mounts can be consilidated.
1) "//mydir1///mydir//"
2) "/mydir1/mydir"
3) "/mydir1/mydir/"Regardless of the internal treatment of these paths, the kernel still stores the original string including the leading '/' for presentation to userland.
URL: https://tracker.ceph.com/issues/42771
Signed-off-by Xiubo Li <[email protected]>Reviewed-by Jeff Layton <[email protected]>Signed-off-by Ilya Dryomov <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- fs/ceph/super.c | 122 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 102 insertions(+), 20 deletions(-)fs/ceph/super.c +99
-20@@ -107,7 +107,6 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)return 0 ; } -static int ceph_sync_fs (struct super_block *sb,int wait) {struct ceph_fs_client *fsc =ceph_sb_to_client (sb);@@ -211,7 +210,6 @@ struct ceph_parse_opts_ctx {/* * Parse the source parameter. Distinguish the server list from the path. -* Internally we do not include the leading '/' in the path. * * The source will look like: * <server_spec>[,<server_spec>...]:[<path>] @@ -232,12 +230,15 @@ static int ceph_parse_source(struct fs_parameter *param, struct fs_context *fc) dev_name_end =strchr (dev_name,'/' );if (dev_name_end) { -if (strlen (dev_name_end) >1 ) { -kfree (fsopt->server_path); - fsopt->server_path =kstrdup (dev_name_end,GFP_KERNEL ); -if (!fsopt->server_path) -return -ENOMEM ; - } +kfree (fsopt->server_path); + +/* +* The server_path will include the whole chars from userland +* including the leading '/'. +*/ + fsopt->server_path =kstrdup (dev_name_end,GFP_KERNEL ); +if (!fsopt->server_path) +return -ENOMEM ; }else { dev_name_end = dev_name +strlen (dev_name); }@@ -461,6 +462,73 @@ static int strcmp_null(const char *s1, const char *s2)return strcmp (s1, s2); } +/** +* path_remove_extra_slash - Remove the extra slashes in the server path +* @server_path: the server path and could be NULL +* +* Return NULL if the path is NULL or only consists of "/", or a string +* without any extra slashes including the leading slash(es) and the +* slash(es) at the end of the server path, such as: +* "//dir1////dir2///" --> "dir1/dir2" +*/ +static char *path_remove_extra_slash (const char *server_path) +{ +const char *path = server_path; +const char *cur, *end; +char *buf, *p; +int len; + +/* if the server path is omitted */ +if (!path) +return NULL ; + +/* remove all the leading slashes */ +while (*path =='/' ) + path++; + +/* if the server path only consists of slashes */ +if (*path =='\0' ) +return NULL ; + + len =strlen (path); + + buf =kmalloc (len +1 ,GFP_KERNEL ); +if (!buf) +return ERR_PTR (-ENOMEM ); + + end = path + len; + p = buf; +do { + cur =strchr (path,'/' ); +if (!cur) + cur = end; + + len = cur - path; + +/* including one '/' */ +if (cur != end) + len +=1 ; + +memcpy (p, path, len); + p += len; + +while (cur <= end && *cur =='/' ) + cur++; + path = cur; + }while (path < end); + + *p ='\0' ; + +/* +* remove the last slash if there has and just to make sure that +* we will get something like "dir1/dir2" +*/ +if (*(--p) =='/' ) + *p ='\0' ; + +return buf; +} +static int compare_mount_options (struct ceph_mount_options *new_fsopt,struct ceph_options *new_opt,struct ceph_fs_client *fsc)@@ -468,6 +536,7 @@ static int compare_mount_options(struct ceph_mount_options *new_fsopt,struct ceph_mount_options *fsopt1 = new_fsopt;struct ceph_mount_options *fsopt2 = fsc->mount_options;int ofs = offsetof(struct ceph_mount_options , snapdir_name); +char *p1, *p2;int ret; ret =memcmp (fsopt1, fsopt2, ofs);@@ -480,9 +549,21 @@ static int compare_mount_options(struct ceph_mount_options *new_fsopt, ret =strcmp_null (fsopt1->mds_namespace, fsopt2->mds_namespace);if (ret)return ret; - ret =strcmp_null (fsopt1->server_path, fsopt2->server_path); + + p1 =path_remove_extra_slash (fsopt1->server_path); +if (IS_ERR (p1)) +return PTR_ERR (p1); + p2 =path_remove_extra_slash (fsopt2->server_path); +if (IS_ERR (p2)) { +kfree (p1); +return PTR_ERR (p2); + } + ret =strcmp_null (p1, p2); +kfree (p1); +kfree (p2);if (ret)return ret; + ret =strcmp_null (fsopt1->fscache_uniq, fsopt2->fscache_uniq);if (ret)return ret;@@ -788,7 +869,6 @@ static void destroy_caches(void)ceph_fscache_unregister (); } -/* * ceph_umount_begin - initiate forced umount. Tear down down the * mount, skipping steps that may hang while waiting for server(s). @@ -868,9 +948,6 @@ static struct dentry *open_root_dentry(struct ceph_fs_client *fsc,return root; } - - -/* * mount: join the ceph cluster, and open root directory. */ @@ -885,7 +962,7 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc,mutex_lock (&fsc->client->mount_mutex);if (!fsc->sb->s_root) { -const char *path; +const char *path, *p; err =__ceph_open_session (fsc->client, started);if (err <0 ) goto out;@@ -897,17 +974,22 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc, goto out; } -if (!fsc->mount_options->server_path) { - path ="" ; -dout ("mount opening path \\t\n" ); - }else { - path = fsc->mount_options->server_path +1 ; -dout ("mount opening path %s\n" , path); + p =path_remove_extra_slash (fsc->mount_options->server_path); +if (IS_ERR (p)) { + err =PTR_ERR (p); + goto out; } +/* if the server path is omitted or just consists of '/' */ +if (!p) + path ="" ; +else
fs/ceph/super.c static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc, · line 995
Quoted 10 lines
fs/ceph/super.c +3
-0+ path = p; +dout ("mount opening path '%s'\n" , path);ceph_fs_debugfs_init (fsc); root =open_root_dentry (fsc, path, started); +kfree (p);if (IS_ERR (root)) { err =PTR_ERR (root); goto out;
Hi Sasha,
This commit is buggy, the fix should land in 5.6-rc2. Please drop it for now -- it would need to be taken together with "ceph: canonicalize server path in place" or not backported at all.
Thanks,
Ilya
Sasha Levin
maintainerRe: [PATCH AUTOSEL 5.5 487/542] ceph: remove the extra slashes in the server path
Quoted 253 lines · Ilya Dryomov
Quoted 239 lines · Sasha Levin
From: Xiubo Li <[email protected]>
[ Upstream commit
4fbc0c711b2464ee1551850b85002faae0b775d5]It's possible to pass the mount helper a server path that has more than one contiguous slash character. For example:
$ mount -t ceph 192.168.195.165:40176:/// /mnt/cephfs/In the MDS server side the extra slashes of the server path will be treated as snap dir, and then we can get the following debug logs:
ceph: mount opening path // ceph: open_root_inode opening '//' ceph: fill_trace 0000000059b8a3bc is_dentry 0 is_target 1 ceph: alloc_inode 00000000dc4ca00b ceph: get_inode created new inode 00000000dc4ca00b 1.ffffffffffffffff ino 1 ceph: get_inode on 1=1.ffffffffffffffff got 00000000dc4ca00bAnd then when creating any new file or directory under the mount point, we can hit the following
BUG_ONinceph_fill_trace():BUG_ON(ceph_snap(dir) != dvino.snap);Have the client ignore the extra slashes in the server path when mounting. This will also canonicalize the path, so that identical mounts can be consilidated.
1) "//mydir1///mydir//"
2) "/mydir1/mydir"
3) "/mydir1/mydir/"Regardless of the internal treatment of these paths, the kernel still stores the original string including the leading '/' for presentation to userland.
URL: https://tracker.ceph.com/issues/42771
Signed-off-by Xiubo Li <[email protected]>Reviewed-by Jeff Layton <[email protected]>Signed-off-by Ilya Dryomov <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- fs/ceph/super.c | 122 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 102 insertions(+), 20 deletions(-)fs/ceph/super.c +99
-20@@ -107,7 +107,6 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)return 0 ; } -static int ceph_sync_fs (struct super_block *sb,int wait) {struct ceph_fs_client *fsc =ceph_sb_to_client (sb);@@ -211,7 +210,6 @@ struct ceph_parse_opts_ctx {/* * Parse the source parameter. Distinguish the server list from the path. -* Internally we do not include the leading '/' in the path. * * The source will look like: * <server_spec>[,<server_spec>...]:[<path>] @@ -232,12 +230,15 @@ static int ceph_parse_source(struct fs_parameter *param, struct fs_context *fc) dev_name_end =strchr (dev_name,'/' );if (dev_name_end) { -if (strlen (dev_name_end) >1 ) { -kfree (fsopt->server_path); - fsopt->server_path =kstrdup (dev_name_end,GFP_KERNEL ); -if (!fsopt->server_path) -return -ENOMEM ; - } +kfree (fsopt->server_path); + +/* +* The server_path will include the whole chars from userland +* including the leading '/'. +*/ + fsopt->server_path =kstrdup (dev_name_end,GFP_KERNEL ); +if (!fsopt->server_path) +return -ENOMEM ; }else { dev_name_end = dev_name +strlen (dev_name); }@@ -461,6 +462,73 @@ static int strcmp_null(const char *s1, const char *s2)return strcmp (s1, s2); } +/** +* path_remove_extra_slash - Remove the extra slashes in the server path +* @server_path: the server path and could be NULL +* +* Return NULL if the path is NULL or only consists of "/", or a string +* without any extra slashes including the leading slash(es) and the +* slash(es) at the end of the server path, such as: +* "//dir1////dir2///" --> "dir1/dir2" +*/ +static char *path_remove_extra_slash (const char *server_path) +{ +const char *path = server_path; +const char *cur, *end; +char *buf, *p; +int len; + +/* if the server path is omitted */ +if (!path) +return NULL ; + +/* remove all the leading slashes */ +while (*path =='/' ) + path++; + +/* if the server path only consists of slashes */ +if (*path =='\0' ) +return NULL ; + + len =strlen (path); + + buf =kmalloc (len +1 ,GFP_KERNEL ); +if (!buf) +return ERR_PTR (-ENOMEM ); + + end = path + len; + p = buf; +do { + cur =strchr (path,'/' ); +if (!cur) + cur = end; + + len = cur - path; + +/* including one '/' */ +if (cur != end) + len +=1 ; + +memcpy (p, path, len); + p += len; + +while (cur <= end && *cur =='/' ) + cur++; + path = cur; + }while (path < end); + + *p ='\0' ; + +/* +* remove the last slash if there has and just to make sure that +* we will get something like "dir1/dir2" +*/ +if (*(--p) =='/' ) + *p ='\0' ; + +return buf; +} +static int compare_mount_options (struct ceph_mount_options *new_fsopt,struct ceph_options *new_opt,struct ceph_fs_client *fsc)@@ -468,6 +536,7 @@ static int compare_mount_options(struct ceph_mount_options *new_fsopt,struct ceph_mount_options *fsopt1 = new_fsopt;struct ceph_mount_options *fsopt2 = fsc->mount_options;int ofs = offsetof(struct ceph_mount_options , snapdir_name); +char *p1, *p2;int ret; ret =memcmp (fsopt1, fsopt2, ofs);@@ -480,9 +549,21 @@ static int compare_mount_options(struct ceph_mount_options *new_fsopt, ret =strcmp_null (fsopt1->mds_namespace, fsopt2->mds_namespace);if (ret)return ret; - ret =strcmp_null (fsopt1->server_path, fsopt2->server_path); + + p1 =path_remove_extra_slash (fsopt1->server_path); +if (IS_ERR (p1)) +return PTR_ERR (p1); + p2 =path_remove_extra_slash (fsopt2->server_path); +if (IS_ERR (p2)) { +kfree (p1); +return PTR_ERR (p2); + } + ret =strcmp_null (p1, p2); +kfree (p1); +kfree (p2);if (ret)return ret; + ret =strcmp_null (fsopt1->fscache_uniq, fsopt2->fscache_uniq);if (ret)return ret;@@ -788,7 +869,6 @@ static void destroy_caches(void)ceph_fscache_unregister (); } -/* * ceph_umount_begin - initiate forced umount. Tear down down the * mount, skipping steps that may hang while waiting for server(s). @@ -868,9 +948,6 @@ static struct dentry *open_root_dentry(struct ceph_fs_client *fsc,return root; } - - -/* * mount: join the ceph cluster, and open root directory. */ @@ -885,7 +962,7 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc,mutex_lock (&fsc->client->mount_mutex);if (!fsc->sb->s_root) { -const char *path; +const char *path, *p; err =__ceph_open_session (fsc->client, started);if (err <0 ) goto out;@@ -897,17 +974,22 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc, goto out; } -if (!fsc->mount_options->server_path) { - path ="" ; -dout ("mount opening path \\t\n" ); - }else { - path = fsc->mount_options->server_path +1 ; -dout ("mount opening path %s\n" , path); + p =path_remove_extra_slash (fsc->mount_options->server_path); +if (IS_ERR (p)) { + err =PTR_ERR (p); + goto out; } +/* if the server path is omitted or just consists of '/' */ +if (!p) + path ="" ; +else fs/ceph/super.c static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc, · line 995
Quoted 10 lines
fs/ceph/super.c +3
-0+ path = p; +dout ("mount opening path '%s'\n" , path);ceph_fs_debugfs_init (fsc); root =open_root_dentry (fsc, path, started); +kfree (p);if (IS_ERR (root)) { err =PTR_ERR (root); goto out;Hi Sasha,
Quoted 3 lines
This commit is buggy, the fix should land in 5.6-rc2. Please drop it for now -- it would need to be taken together with "ceph: canonicalize server path in place" or not backported at all.
I'll try and queue up the fix when it's upstream. This series will probably be queued closer to -rc3 anyways.
Signature · 2 lines
Thanks, Sasha
Sasha Levin
maintainerPATCH 488/542 rbd: work around -Wuninitialized warning
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
[ Upstream commit a55e601b2f02df5db7070e9a37bd655c9c576a52 ]
gcc -O3 warns about a dummy variable that is passed down into rbd_img_fill_nodata without being initialized:
drivers/block/rbd.c: In function 'rbd_img_fill_nodata':drivers/block/rbd.c:2573:13: error: 'dummy' is used uninitialized in this function [-Werror=uninitialized]
fctx->iter = *fctx->pos;
Since this is a dummy, I assume the warning is harmless, but it's better to initialize it anyway and avoid the warning.
--- drivers/block/rbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/rbd.c +1 -1
@@ -2662,7 +2662,7 @@ static int rbd_img_fill_nodata(struct rbd_img_request *img_req, u64 off, u64 len) {struct ceph_file_extent ex = { off, len }; -union rbd_img_fill_iter dummy; +union rbd_img_fill_iter dummy = {};struct rbd_img_fill_ctx fctx = { .pos_type =OBJ_REQUEST_NODATA , .pos = &dummy,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 489/542 ASoC: Intel: consistent HDMI codec probing code
In reply to Sasha LevinFrom: Guennadi Liakhovetski <[email protected]>
[ Upstream commit 98ff5c262f27aafee077a4c096f71a8566e9e948 ]
Multiple Intel ASoC machine drivers repeat the same pattern in their .late_probe() methods: they first check whether the common HDMI codec driver is used, if not, they proceed by linking the legacy HDMI driver to each HDMI port. While doing that they use some inconsistent code:
1. after the loop they check, whether the list contained at least one element and if not, they return an error. However, the earlier code to use the common HDMI driver uses the first element of the same list without checking. To fix this we move the check to the top of the function.
2. some of those .late_probe() implementations execute code, only needed for the common HDMI driver, before checking, whether the driver is used. Move the code to after the check.
3. Some of those functions also perform a redundant initialisation of the "err" variable.
This patch fixes those issues.
--- sound/soc/intel/boards/bxt_da7219_max98357a.c | 14 +++++++------- sound/soc/intel/boards/bxt_rt298.c | 14 +++++++------- sound/soc/intel/boards/cml_rt1011_rt5682.c | 13 +++++++------ sound/soc/intel/boards/glk_rt5682_max98357a.c | 16 ++++++++-------- sound/soc/intel/boards/sof_rt5682.c | 15 ++++++++------- 5 files changed, 37 insertions(+), 35 deletions(-)
sound/soc/intel/boards/bxt_da7219_max98357a.c +7 -7
@@ -617,12 +617,15 @@ static int bxt_card_late_probe(struct snd_soc_card *card)snd_soc_dapm_add_routes (&card->dapm, broxton_map,ARRAY_SIZE (broxton_map)); - pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm, - head); - component = pcm->codec_dai->component; +if (list_empty (&ctx->hdmi_pcm_list)) +return -EINVAL ; -if (ctx->common_hdmi_codec_drv) +if (ctx->common_hdmi_codec_drv) { + pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm, + head); + component = pcm->codec_dai->component;return hda_dsp_hdmi_build_controls (card, component); + }list_for_each_entry (pcm, &ctx->hdmi_pcm_list, head) { component = pcm->codec_dai->component;
@@ -643,9 +646,6 @@ static int bxt_card_late_probe(struct snd_soc_card *card) i++; } -if (!component) -return -EINVAL ; -return hdac_hdmi_jack_port_init (component, &card->dapm); }
sound/soc/intel/boards/bxt_rt298.c +7 -7
@@ -529,12 +529,15 @@ static int bxt_card_late_probe(struct snd_soc_card *card)int err, i =0 ;char jack_name[NAME_SIZE ]; - pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm, - head); - component = pcm->codec_dai->component; +if (list_empty (&ctx->hdmi_pcm_list)) +return -EINVAL ; -if (ctx->common_hdmi_codec_drv) +if (ctx->common_hdmi_codec_drv) { + pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm, + head); + component = pcm->codec_dai->component;return hda_dsp_hdmi_build_controls (card, component); + }list_for_each_entry (pcm, &ctx->hdmi_pcm_list, head) { component = pcm->codec_dai->component;
@@ -555,9 +558,6 @@ static int bxt_card_late_probe(struct snd_soc_card *card) i++; } -if (!component) -return -EINVAL ; -return hdac_hdmi_jack_port_init (component, &card->dapm); }
sound/soc/intel/boards/cml_rt1011_rt5682.c +7 -6
@@ -241,12 +241,15 @@ static int sof_card_late_probe(struct snd_soc_card *card)struct hdmi_pcm *pcm;int ret, i =0 ; - pcm = list_first_entry(&ctx->hdmi_pcm_list, struct hdmi_pcm, - head); - component = pcm->codec_dai->component; +if (list_empty (&ctx->hdmi_pcm_list)) +return -EINVAL ; -if (ctx->common_hdmi_codec_drv) +if (ctx->common_hdmi_codec_drv) { + pcm = list_first_entry(&ctx->hdmi_pcm_list, struct hdmi_pcm, + head); + component = pcm->codec_dai->component;return hda_dsp_hdmi_build_controls (card, component); + }list_for_each_entry (pcm, &ctx->hdmi_pcm_list, head) { component = pcm->codec_dai->component;
@@ -265,8 +268,6 @@ static int sof_card_late_probe(struct snd_soc_card *card) i++; } -if (!component) -return -EINVAL ;return hdac_hdmi_jack_port_init (component, &card->dapm); }
sound/soc/intel/boards/glk_rt5682_max98357a.c +8 -8
@@ -544,15 +544,18 @@ static int glk_card_late_probe(struct snd_soc_card *card)struct snd_soc_component *component =NULL ;char jack_name[NAME_SIZE ];struct glk_hdmi_pcm *pcm; -int err =0 ; +int err;int i =0 ; - pcm = list_first_entry(&ctx->hdmi_pcm_list, struct glk_hdmi_pcm, - head); - component = pcm->codec_dai->component; +if (list_empty (&ctx->hdmi_pcm_list)) +return -EINVAL ; -if (ctx->common_hdmi_codec_drv) +if (ctx->common_hdmi_codec_drv) { + pcm = list_first_entry(&ctx->hdmi_pcm_list, struct glk_hdmi_pcm, + head); + component = pcm->codec_dai->component;return hda_dsp_hdmi_build_controls (card, component); + }list_for_each_entry (pcm, &ctx->hdmi_pcm_list, head) { component = pcm->codec_dai->component;
@@ -573,9 +576,6 @@ static int glk_card_late_probe(struct snd_soc_card *card) i++; } -if (!component) -return -EINVAL ; -return hdac_hdmi_jack_port_init (component, &card->dapm); }
sound/soc/intel/boards/sof_rt5682.c +8 -7
@@ -273,19 +273,22 @@ static int sof_card_late_probe(struct snd_soc_card *card)struct snd_soc_component *component =NULL ;char jack_name[NAME_SIZE ];struct sof_hdmi_pcm *pcm; -int err =0 ; +int err;int i =0 ;/* HDMI is not supported by SOF on Baytrail/CherryTrail */ if (is_legacy_cpu)return 0 ; - pcm = list_first_entry(&ctx->hdmi_pcm_list, struct sof_hdmi_pcm, - head); - component = pcm->codec_dai->component; +if (list_empty (&ctx->hdmi_pcm_list)) +return -EINVAL ; -if (ctx->common_hdmi_codec_drv) +if (ctx->common_hdmi_codec_drv) { + pcm = list_first_entry(&ctx->hdmi_pcm_list, struct sof_hdmi_pcm, + head); + component = pcm->codec_dai->component;return hda_dsp_hdmi_build_controls (card, component); + }list_for_each_entry (pcm, &ctx->hdmi_pcm_list, head) { component = pcm->codec_dai->component;
@@ -305,8 +308,6 @@ static int sof_card_late_probe(struct snd_soc_card *card) i++; } -if (!component) -return -EINVAL ;return hdac_hdmi_jack_port_init (component, &card->dapm); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 490/542 IB/mlx4: Fix leak in id_map_find_del
In reply to Sasha LevinFrom: Håkon Bugge <[email protected]>
[ Upstream commit ea660ad7c1c476fd6e5e3b17780d47159db71dea ]
Using CX-3 virtual functions, either from a bare-metal machine or pass-through from a VM, MAD packets are proxied through the PF driver.
Since the VF drivers have separate name spaces for MAD Transaction Ids (TIDs), the PF driver has to re-map the TIDs and keep the book keeping in a cache.
Following the RDMA Connection Manager (CM) protocol, it is clear when an entry has to evicted from the cache. When a DREP is sent from mlx4_ib_multiplex_cm_handler(), id_map_find_del() is called. Similar when a REJ is received by the mlx4_ib_demux_cm_handler(), id_map_find_del() is called.
This function wipes out the TID in use from the IDR or XArray and removes the id_map_entry from the table.
In short, it does everything except the topping of the cake, which is to remove the entry from the list and free it. In other words, for the REJ case enumerated above, one id_map_entry will be leaked.
For the other case above, a DREQ has been received first. The reception of the DREQ will trigger queuing of a delayed work to delete the id_map_entry, for the case where the VM doesn't send back a DREP.
In the normal case, the VM _will_ send back a DREP, and id_map_find_del() will be called.
But this scenario introduces a secondary leak. First, when the DREQ is received, a delayed work is queued. The VM will then return a DREP, which will call id_map_find_del(). As stated above, this will free the TID used from the XArray or IDR. Now, there is window where that particular TID can be re-allocated, lets say by an outgoing REQ. This TID will later be wiped out by the delayed work, when the function id_map_ent_timeout() is called. But the id_map_entry allocated by the outgoing REQ will not be de-allocated, and we have a leak.
Both leaks are fixed by removing the id_map_find_del() function and only using schedule_delayed(). Of course, a check in schedule_delayed() to see if the work already has been queued, has been added.
Another benefit of always using the delayed version for deleting entries, is that we do get a TimeWait effect; a TID no longer in use, will occupy the XArray or IDR for CM_CLEANUP_CACHE_TIMEOUT time, without any ability of being re-used for that time period.
--- drivers/infiniband/hw/mlx4/cm.c | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-)
drivers/infiniband/hw/mlx4/cm.c +3 -26
@@ -186,23 +186,6 @@ static void id_map_ent_timeout(struct work_struct *work)kfree (ent); } -static void id_map_find_del (struct ib_device *ibdev,int pv_cm_id) -{ -struct mlx4_ib_sriov *sriov = &to_mdev (ibdev)->sriov; -struct rb_root *sl_id_map = &sriov->sl_id_map; -struct id_map_entry *ent, *found_ent; - -spin_lock (&sriov->id_map_lock); - ent =xa_erase (&sriov->pv_id_table, pv_cm_id); -if (!ent) - goto out; - found_ent =id_map_find_by_sl_id (ibdev, ent->slave_id, ent->sl_cm_id); -if (found_ent && found_ent == ent) -rb_erase (&found_ent->node, sl_id_map); -out: -spin_unlock (&sriov->id_map_lock); -} -static void sl_id_map_add (struct ib_device *ibdev,struct id_map_entry *new) {struct rb_root *sl_id_map = &to_mdev (ibdev)->sriov.sl_id_map;
@@ -294,7 +277,7 @@ static void schedule_delayed(struct ib_device *ibdev, struct id_map_entry *id)spin_lock (&sriov->id_map_lock);spin_lock_irqsave (&sriov->going_down_lock, flags);/*make sure that there is no schedule inside the scheduled work.*/ -if (!sriov->is_going_down) { +if (!sriov->is_going_down && !id->scheduled_delete) { id->scheduled_delete =1 ;schedule_delayed_work (&id->timeout,CM_CLEANUP_CACHE_TIMEOUT ); }
@@ -341,9 +324,6 @@ int mlx4_ib_multiplex_cm_handler(struct ib_device *ibdev, int port, int slave_idif (mad->mad_hdr.attr_id ==CM_DREQ_ATTR_ID )schedule_delayed (ibdev, id); -else if (mad->mad_hdr.attr_id ==CM_DREP_ATTR_ID ) -id_map_find_del (ibdev, pv_cm_id); -return 0 ; }
@@ -382,12 +362,9 @@ int mlx4_ib_demux_cm_handler(struct ib_device *ibdev, int port, int *slave, *slave = id->slave_id;set_remote_comm_id (mad, id->sl_cm_id); -if (mad->mad_hdr.attr_id ==CM_DREQ_ATTR_ID ) +if (mad->mad_hdr.attr_id ==CM_DREQ_ATTR_ID || + mad->mad_hdr.attr_id ==CM_REJ_ATTR_ID )schedule_delayed (ibdev, id); -else if (mad->mad_hdr.attr_id ==CM_REJ_ATTR_ID || - mad->mad_hdr.attr_id ==CM_DREP_ATTR_ID ) { -id_map_find_del (ibdev, (int ) pv_cm_id); - }return 0 ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 491/542 drm/amd/display: do not allocate display_mode_lib unnecessarily
In reply to Sasha LevinFrom: Dor Askayo <[email protected]>
[ Upstream commit bb67bfd2e7101bf2ac5327b0b7a847cd9fb9723f ]
This allocation isn't required and can fail when resuming from suspend.
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +9 -8
@@ -2396,12 +2396,7 @@ void dc_set_power_state( enum dc_acpi_cm_power_state power_state) {struct kref refcount; -struct display_mode_lib *dml =kzalloc (sizeof (struct display_mode_lib ), -GFP_KERNEL ); - -ASSERT (dml); -if (!dml) -return ; +struct display_mode_lib *dml;switch (power_state) {case DC_ACPI_CM_POWER_STATE_D0 :
@@ -2423,6 +2418,12 @@ void dc_set_power_state(* clean state, and dc hw programming optimizations will not * cause any trouble. */ + dml =kzalloc (sizeof (struct display_mode_lib ), +GFP_KERNEL ); + +ASSERT (dml); +if (!dml) +return ;/* Preserve refcount */ refcount = dc->current_state->refcount;
@@ -2436,10 +2437,10 @@ void dc_set_power_state( dc->current_state->refcount = refcount; dc->current_state->bw_ctx.dml = *dml; +kfree (dml); +break ; } - -kfree (dml); }void dc_resume (struct dc *dc)
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 492/542 irqchip/gic-v3: Only provision redistributors that are enabled in ACPI
In reply to Sasha LevinFrom: Marc Zyngier <[email protected]>
[ Upstream commit 926b5dfa6b8dc666ff398044af6906b156e1d949 ]
We currently allocate redistributor region structures for individual redistributors when ACPI doesn't present us with compact MMIO regions covering multiple redistributors.
It turns out that we allocate these structures even when the redistributor is flagged as disabled by ACPI. It works fine until someone actually tries to tarse one of these structures, and access the corresponding MMIO region.
Instead, track the number of enabled redistributors, and only allocate what is required. This makes sure that there is no invalid data to misuse.
--- drivers/irqchip/irq-gic-v3.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/irqchip/irq-gic-v3.c +7 -2
@@ -1821,6 +1821,7 @@ static structstruct redist_region *redist_regs;u32 nr_redist_regions;bool single_redist; +int enabled_rdists;u32 maint_irq;int maint_irq_mode;phys_addr_t vcpu_base;
@@ -1915,8 +1916,10 @@ static int __init gic_acpi_match_gicc(union acpi_subtable_headers *header,* If GICC is enabled and has valid gicr base address, then it means * GICR base is presented via GICC */ -if ((gicc->flags &ACPI_MADT_ENABLED ) && gicc->gicr_base_address) +if ((gicc->flags &ACPI_MADT_ENABLED ) && gicc->gicr_base_address) { + acpi_data.enabled_rdists++;return 0 ; + }/* * It's perfectly valid firmware can pass disabled GICC entry, driver
@@ -1946,8 +1949,10 @@ static int __init gic_acpi_count_gicr_regions(void) count =acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_INTERRUPT , gic_acpi_match_gicc,0 ); -if (count >0 ) +if (count >0 ) { acpi_data.single_redist = true; + count = acpi_data.enabled_rdists; + }return count; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 493/542 KVM: PPC: Book3S HV: Release lock on page-out failure path
In reply to Sasha LevinFrom: Bharata B Rao <[email protected]>
[ Upstream commit e032e3b55b6f487e48c163c5dca74086f147a169 ]
When migrate_vma_setup() fails in kvmppc_svm_page_out(), release kvm->arch.uvmem_lock before returning.
--- arch/powerpc/kvm/book3s_hv_uvmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kvm/book3s_hv_uvmem.c +1 -1
@@ -543,7 +543,7 @@ kvmppc_svm_page_out(struct vm_area_struct *vma, unsigned long start, ret =migrate_vma_setup (&mig);if (ret) -return ret; + goto out; spage =migrate_pfn_to_page (*mig.src);if (!spage || !(*mig.src &MIGRATE_PFN_MIGRATE ))
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 494/542 drm/nouveau/disp/nv50-: prevent oops when no channel method map provided
In reply to Sasha LevinFrom: Ben Skeggs <[email protected]>
[ Upstream commit 0e6176c6d286316e9431b4f695940cfac4ffe6c2 ]
The implementations for most channel types contains a map of methods to priv registers in order to provide debugging info when a disp exception has been raised.
This info is missing from the implementation of PIO channels as they're rather simplistic already, however, if an exception is raised by one of them, we'd end up triggering a NULL-pointer deref. Not ideal...
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=206299
--- drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c +2 -0
@@ -74,6 +74,8 @@ nv50_disp_chan_mthd(struct nv50_disp_chan *chan, int debug)if (debug > subdev->debug)return ; +if (!mthd) +return ;for (i =0 ; (list = mthd->data[i].mthd) !=NULL ; i++) {u32 base = chan->head * mthd->addr;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 495/542 docs: i2c: writing-clients: properly name the stop condition
In reply to Sasha LevinFrom: Luca Ceresoli <[email protected]>
[ Upstream commit 4fcb445ec688a62da9c864ab05a4bd39b0307cdc ]
In I2C there is no such thing as a "stop bit". Use the proper naming: "stop condition".
--- Documentation/i2c/writing-clients.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Documentation/i2c/writing-clients.rst +3 -3
@@ -357,9 +357,9 @@ read/written. This sends a series of messages. Each message can be a read or write, and they can be mixed in any way. The transactions are combined: no -stop bit is sent between transaction. The i2c_msg structure contains -for each message the client address, the number of bytes of the message -and the message data itself. +stop condition is issued between transaction. The i2c_msg structure +contains for each message the client address, the number of bytes of the +message and the message data itself. You can read the file ``i2c-protocol`` for more information about the actual I2C protocol.
Signature · 1 line
2.20.1
Re: [PATCH AUTOSEL 5.5 495/542] docs: i2c: writing-clients: properly name the stop condition
Quoted 23 lines · Sasha Levin
From: Luca Ceresoli <[email protected]>
[ Upstream commit
4fcb445ec688a62da9c864ab05a4bd39b0307cdc]In I2C there is no such thing as a "stop bit". Use the proper naming: "stop condition".
Signed-off-by Luca Ceresoli <[email protected]>Reported-by Jean Delvare <[email protected]>Reviewed-by Jean Delvare <[email protected]>Signed-off-by Wolfram Sang <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- Documentation/i2c/writing-clients.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)Documentation/i2c/writing-clients.rst +0
-0@@ -357,9 +357,9 @@ read/written. This sends a series of messages. Each message can be a read or write,
Documentation/i2c/writing-clients.rst read/written. · line 365
Quoted 10 lines
Documentation/i2c/writing-clients.rst +3
-3and they can be mixed in any way. The transactions are combined: no -stop bit is sent between transaction. The i2c_msg structure contains -for each message the client address, the number of bytes of the message -and the message data itself. +stop condition is issued between transaction. The i2c_msg structure +contains for each message the client address, the number of bytes of the +message and the message data itself. You can read the file ``i2c-protocol`` for more information about the actual I2C protocol.
I wouldn't bother backporting this documentation patch to stable and longterm trees. That's a minor vocabulary thing really, it does not qualify.
Signature · 2 lines
Jean Delvare SUSE L3 Support
Re: [PATCH AUTOSEL 5.5 495/542] docs: i2c: writing-clients: properly name the stop condition
Hi,
Quoted 32 lines · Jean Delvare
Quoted 31 lines · Sasha Levin
From: Luca Ceresoli <[email protected]>
[ Upstream commit
4fcb445ec688a62da9c864ab05a4bd39b0307cdc]In I2C there is no such thing as a "stop bit". Use the proper naming: "stop condition".
Signed-off-by Luca Ceresoli <[email protected]>Reported-by Jean Delvare <[email protected]>Reviewed-by Jean Delvare <[email protected]>Signed-off-by Wolfram Sang <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- Documentation/i2c/writing-clients.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)Documentation/i2c/writing-clients.rst +3
-3@@ -357,9 +357,9 @@ read/written. This sends a series of messages. Each message can be a read or write, and they can be mixed in any way. The transactions are combined: no -stop bit is sent between transaction. The i2c_msg structure contains -for each message the client address, the number of bytes of the message -and the message data itself. +stop condition is issued between transaction. The i2c_msg structure +contains for each message the client address, the number of bytes of the +message and the message data itself.
Quoted 6 lines
Documentation/i2c/writing-clients.rst read/written. · line 365
Quoted 2 lines
Documentation/i2c/writing-clients.rst +0
-0You can read the file ``i2c-protocol`` for more information about the actual I2C protocol.I wouldn't bother backporting this documentation patch to stable and longterm trees. That's a minor vocabulary thing really, it does not qualify.
I also feel no need to have it in stable branches. Hovever it would not hurt, so whatever is fine for who's maintaining that branch will be fine for me as well.
Signature · 1 line
Luca
Sasha Levin
maintainerRe: [PATCH AUTOSEL 5.5 495/542] docs: i2c: writing-clients: properly name the stop condition
Quoted 42 lines · Luca Ceresoli
Hi,
Quoted 32 lines · Jean Delvare
Quoted 31 lines · Sasha Levin
From: Luca Ceresoli <[email protected]>
[ Upstream commit
4fcb445ec688a62da9c864ab05a4bd39b0307cdc]In I2C there is no such thing as a "stop bit". Use the proper naming: "stop condition".
Signed-off-by Luca Ceresoli <[email protected]>Reported-by Jean Delvare <[email protected]>Reviewed-by Jean Delvare <[email protected]>Signed-off-by Wolfram Sang <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- Documentation/i2c/writing-clients.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)Documentation/i2c/writing-clients.rst +3
-3@@ -357,9 +357,9 @@ read/written. This sends a series of messages. Each message can be a read or write, and they can be mixed in any way. The transactions are combined: no -stop bit is sent between transaction. The i2c_msg structure contains -for each message the client address, the number of bytes of the message -and the message data itself. +stop condition is issued between transaction. The i2c_msg structure +contains for each message the client address, the number of bytes of the +message and the message data itself.Quoted 6 lines
Documentation/i2c/writing-clients.rst read/written. · line 365
Quoted 2 lines
Documentation/i2c/writing-clients.rst +0
-0You can read the file ``i2c-protocol`` for more information about the actual I2C protocol.I wouldn't bother backporting this documentation patch to stable and longterm trees. That's a minor vocabulary thing really, it does not qualify.
Quoted 3 lines
I also feel no need to have it in stable branches. Hovever it would not hurt, so whatever is fine for who's maintaining that branch will be fine for me as well.
No, you're right, this isn't stable material - I've missed it during review and I'll drop it now. Thanks for pointing it out.
Signature · 2 lines
Thanks, Sasha
Sasha Levin
maintainerPATCH 496/542 char: hpet: Fix out-of-bounds read bug
In reply to Sasha LevinFrom: "Gustavo A. R. Silva" <[email protected]>
[ Upstream commit 98c49f1746ac44ccc164e914b9a44183fad09f51 ]
Currently, there is an out-of-bounds read on array hpetp->hp_dev in the following for loop:
870 for (i = 0; i < hdp->hd_nirqs; i++)
871 hpetp->hp_dev[i].hd_hdwirq = hdp->hd_irq[i];
This is due to the recent change from one-element array to flexible-array member in struct hpets:
104 struct hpets {
...113 struct hpet_dev hp_dev[];
114 };
This change affected the total size of the dynamic memory allocation, decreasing it by one time the size of struct hpet_dev.
Fix this by adjusting the allocation size when calling struct_size().
--- drivers/char/hpet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/hpet.c +1 -1
@@ -855,7 +855,7 @@ int hpet_alloc(struct hpet_data *hdp)return 0 ; } - hpetp =kzalloc (struct_size (hpetp, hp_dev, hdp->hd_nirqs -1 ), + hpetp =kzalloc (struct_size (hpetp, hp_dev, hdp->hd_nirqs),GFP_KERNEL );if (!hpetp)
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerRe: [PATCH AUTOSEL 5.5 496/542] char: hpet: Fix out-of-bounds read bug
Quoted 51 lines · Sasha Levin
From: "Gustavo A. R. Silva" <[email protected]>
[ Upstream commit
98c49f1746ac44ccc164e914b9a44183fad09f51]Currently, there is an out-of-bounds read on array
hpetp->hp_devin the following for loop:870 for (i = 0; i <
hdp->hd_nirqs; i++)
871 hpetp->hp_dev[i].hd_hdwirq = hdp->hd_irq[i];This is due to the recent change from one-element array to flexible-array member in struct hpets:
104 struct hpets { ...113 struct
hpet_devhp_dev[];
114 };This change affected the total size of the dynamic memory allocation, decreasing it by one time the size of struct
hpet_dev.Fix this by adjusting the allocation size when calling
struct_size().Fixes 987f028b8637c ("char: hpet: Use flexible-array member")Signed-off-by Gustavo A. R. Silva <[email protected]>Signed-off-by Tetsuo Handa <[email protected]>Acked-by Eric Biggers <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/char/hpet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/char/hpet.c +1
-1@@ -855,7 +855,7 @@ int hpet_alloc(struct hpet_data *hdp)return 0 ; } - hpetp =kzalloc (struct_size (hpetp, hp_dev, hdp->hd_nirqs -1 ), + hpetp =kzalloc (struct_size (hpetp, hp_dev, hdp->hd_nirqs),GFP_KERNEL );if (!hpetp)Signature · 1 line
2.20.1
Not needed unless you have the other patch that I asked you to drop added :)
Sasha Levin
maintainerPATCH 497/542 ftrace: fpid_next() should increase position index
In reply to Sasha LevinFrom: Vasily Averin <[email protected]>
[ Upstream commit e4075e8bdffd93a9b6d6e1d52fabedceeca5a91b ]
if seq_file .next fuction does not change position index, read after some lseek can generate unexpected output.
Without patch:
# dd bs=4 skip=1 if=/sys/kernel/tracing/set_ftrace_pid dd: /sys/kernel/tracing/set_ftrace_pid: cannot skip to specified offset id no pid 2+1 records in 2+1 records out 10 bytes copied, 0.000213285 s, 46.9 kB/s
Notice the "id" followed by "no pid".
With the patch:
# dd bs=4 skip=1 if=/sys/kernel/tracing/set_ftrace_pid dd: /sys/kernel/tracing/set_ftrace_pid: cannot skip to specified offset id 0+1 records in 0+1 records out 3 bytes copied, 0.000202112 s, 14.8 kB/s
Notice that it only prints "id" and not the "no pid" afterward.
https://bugzilla.kernel.org/show_bug.cgi?id=206283
--- kernel/trace/ftrace.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/trace/ftrace.c +3 -2
@@ -7038,9 +7038,10 @@ static void *fpid_next(struct seq_file *m, void *v, loff_t *pos)struct trace_array *tr = m->private;struct trace_pid_list *pid_list =rcu_dereference_sched (tr->function_pids); -if (v ==FTRACE_NO_PIDS ) +if (v ==FTRACE_NO_PIDS ) { + (*pos)++;return NULL ; - + }return trace_pid_next (pid_list, v, pos); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 498/542 trigger_next should increase position index
In reply to Sasha LevinFrom: Vasily Averin <[email protected]>
[ Upstream commit 6722b23e7a2ace078344064a9735fb73e554e9ef ]
if seq_file .next fuction does not change position index, read after some lseek can generate unexpected output.
Without patch:
# dd bs=30 skip=1 if=/sys/kernel/tracing/events/sched/sched_switch/trigger dd: /sys/kernel/tracing/events/sched/sched_switch/trigger: cannot skip to specified offset n traceoff snapshot stacktrace enable_event disable_event enable_hist disable_hist hist # Available triggers: # traceon traceoff snapshot stacktrace enable_event disable_event enable_hist disable_hist hist 6+1 records in 6+1 records out 206 bytes copied, 0.00027916 s, 738 kB/s
Notice the printing of "# Available triggers:..." after the line.
With the patch:
# dd bs=30 skip=1 if=/sys/kernel/tracing/events/sched/sched_switch/trigger dd: /sys/kernel/tracing/events/sched/sched_switch/trigger: cannot skip to specified offset n traceoff snapshot stacktrace enable_event disable_event enable_hist disable_hist hist 2+1 records in 2+1 records out 88 bytes copied, 0.000526867 s, 167 kB/s
It only prints the end of the file, and does not restart.
https://bugzilla.kernel.org/show_bug.cgi?id=206283
--- kernel/trace/trace_events_trigger.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/trace/trace_events_trigger.c +3 -2
@@ -116,9 +116,10 @@ static void *trigger_next(struct seq_file *m, void *t, loff_t *pos) {struct trace_event_file *event_file =event_file_data (m->private); -if (t ==SHOW_AVAILABLE_TRIGGERS ) +if (t ==SHOW_AVAILABLE_TRIGGERS ) { + (*pos)++;return NULL ; - + }return seq_list_next (t, &event_file->triggers, pos); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 499/542 radeon: insert 10ms sleep in dce5_crtc_load_lut
In reply to Sasha LevinFrom: Daniel Vetter <[email protected]>
[ Upstream commit ec3d65082d7dabad6fa8f66a8ef166f2d522d6b2 ]
Per at least one tester this is enough magic to recover the regression introduced for some people (but not all) in
commit b8e2b0199cc377617dc238f5106352c06dcd3fa2
Author: Peter Rosin <[email protected]> Date: Tue Jul 4 12:36:57 2017 +0200
drm/fb-helper: factor out pseudo-palette
which for radeon had the side-effect of refactoring out a seemingly redudant writing of the color palette.
10ms in a fairly slow modeset path feels like an acceptable form of duct-tape, so maybe worth a shot and see what sticks.
Cc: Alex Deucher <[email protected]>
Cc: Michel Dänzer <[email protected]>
References: https://bugzilla.kernel.org/show_bug.cgi?id=198123
--- drivers/gpu/drm/radeon/radeon_display.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/radeon/radeon_display.c +2 -0
@@ -127,6 +127,8 @@ static void dce5_crtc_load_lut(struct drm_crtc *crtc)DRM_DEBUG_KMS ("%d\n" , radeon_crtc->crtc_id); +msleep (10 ); +WREG32 (NI_INPUT_CSC_CONTROL + radeon_crtc->crtc_offset, (NI_INPUT_CSC_GRPH_MODE (NI_INPUT_CSC_BYPASS ) |NI_INPUT_CSC_OVL_MODE (NI_INPUT_CSC_BYPASS )));
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 500/542 i2c: cros-ec-tunnel: Fix slave device enumeration
In reply to Sasha LevinFrom: Akshu Agrawal <[email protected]>
[ Upstream commit 8ff2d7ca4a55dfabf12e876369835bd024eb4621 ]
During adding of the adapter the slave device registration use to fail as the acpi companion field was not populated.
--- drivers/i2c/busses/i2c-cros-ec-tunnel.c | 1 + 1 file changed, 1 insertion(+)
drivers/i2c/busses/i2c-cros-ec-tunnel.c +1 -0
@@ -273,6 +273,7 @@ static int ec_i2c_probe(struct platform_device *pdev) bus->adap.dev.parent = &pdev->dev; bus->adap.dev.of_node = pdev->dev.of_node; bus->adap.retries =I2C_MAX_RETRIES ; +ACPI_COMPANION_SET (&bus->adap.dev,ACPI_COMPANION (&pdev->dev)); err =i2c_add_adapter (&bus->adap);if (err)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 501/542 i2c: cros-ec-tunnel: Fix ACPI identifier
In reply to Sasha LevinFrom: Raul E Rangel <[email protected]>
[ Upstream commit b49f8e0e7bd17b968129790e40f9e2566f4f95ec ]
The initial patch was using the incorrect identifier.
--- drivers/i2c/busses/i2c-cros-ec-tunnel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-cros-ec-tunnel.c +1 -1
@@ -299,7 +299,7 @@ static const struct of_device_id cros_ec_i2c_of_match[] = {MODULE_DEVICE_TABLE (of, cros_ec_i2c_of_match);static const struct acpi_device_id cros_ec_i2c_tunnel_acpi_id[] = { - {"GOOG001A" ,0 }, + {"GOOG0012" ,0 }, { } };MODULE_DEVICE_TABLE (acpi, cros_ec_i2c_tunnel_acpi_id);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 502/542 powerpc: Do not consider weak unresolved symbol relocations as bad
In reply to Sasha LevinFrom: Alexandre Ghiti <[email protected]>
[ Upstream commit 43e76cd368fbb67e767da5363ffeaa3989993c8c ]
Commit 8580ac9404f6 ("bpf: Process in-kernel BTF") introduced two weak symbols that may be unresolved at link time which result in an absolute relocation to 0. relocs_check.sh emits the following warning:
"WARNING: 2 bad relocationsc000000001a41478 R_PPC64_ADDR64 _binary__btf_vmlinux_bin_startc000000001a41480 R_PPC64_ADDR64 _binary__btf_vmlinux_bin_end"
whereas those relocations are legitimate even for a relocatable kernel compiled with -pie option.
relocs_check.sh already excluded some weak unresolved symbols explicitly:
remove those hardcoded symbols and add some logic that parses the symbols using nm, retrieves all the weak unresolved symbols and excludes those from the list of the potential bad relocations.
--- arch/powerpc/Makefile.postlink | 4 ++-- arch/powerpc/tools/relocs_check.sh | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-)
arch/powerpc/Makefile.postlink +2 -2
@@ -17,11 +17,11 @@ quiet_cmd_head_check = CHKHEAD $@ quiet_cmd_relocs_check = CHKREL $@ ifdef CONFIG_PPC_BOOK3S_64 cmd_relocs_check = \ - $(CONFIG_SHELL) $(srctree)/arch/powerpc/tools/relocs_check.sh "$(OBJDUMP)" "$@" ; \ + $(CONFIG_SHELL) $(srctree)/arch/powerpc/tools/relocs_check.sh "$(OBJDUMP)" "$(NM)" "$@" ; \ $(BASH) $(srctree)/arch/powerpc/tools/unrel_branch_check.sh "$(OBJDUMP)" "$@" else cmd_relocs_check = \ - $(CONFIG_SHELL) $(srctree)/arch/powerpc/tools/relocs_check.sh "$(OBJDUMP)" "$@" + $(CONFIG_SHELL) $(srctree)/arch/powerpc/tools/relocs_check.sh "$(OBJDUMP)" "$(NM)" "$@" endif # `@true` prevents complaint when there is nothing to be done
arch/powerpc/tools/relocs_check.sh +12 -8
@@ -10,14 +10,21 @@ # based on relocs_check.pl # Copyright © 2009 IBM Corporation -if [ $# -lt 2 ]; then - echo "$0 [path to objdump] [path to vmlinux]" 1>&2 +if [ $# -lt 3 ]; then + echo "$0 [path to objdump] [path to nm] [path to vmlinux]" 1>&2 exit 1 fi -# Have Kbuild supply the path to objdump so we handle cross compilation. +# Have Kbuild supply the path to objdump and nm so we handle cross compilation. objdump="$1" -vmlinux="$2" +nm="$2" +vmlinux="$3" + +# Remove from the bad relocations those that match an undefined weak symbol +# which will result in an absolute relocation to 0. +# Weak unresolved symbols are of that form in nm output: +# " w _binary__btf_vmlinux_bin_end" +undef_weak_symbols=$($nm "$vmlinux" | awk '$1 ~ /w/ { print $2 }') bad_relocs=$( $objdump -R "$vmlinux" |
@@ -26,8 +33,6 @@ $objdump -R "$vmlinux" | # These relocations are okay # On PPC64: # R_PPC64_RELATIVE, R_PPC64_NONE - # R_PPC64_ADDR64 mach_<name> - # R_PPC64_ADDR64 __crc_<name> # On PPC: # R_PPC_RELATIVE, R_PPC_ADDR16_HI, # R_PPC_ADDR16_HA,R_PPC_ADDR16_LO,
@@ -39,8 +44,7 @@ R_PPC_ADDR16_HI R_PPC_ADDR16_HA R_PPC_RELATIVE R_PPC_NONE' | - grep -E -v '\<R_PPC64_ADDR64[[:space:]]+mach_' | - grep -E -v '\<R_PPC64_ADDR64[[:space:]]+__crc_' + ([ "$undef_weak_symbols" ] && grep -F -w -v "$undef_weak_symbols" || cat) ) if [ -z "$bad_relocs" ]; then
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 503/542 btrfs: do not do delalloc reservation under page lock
In reply to Sasha LevinFrom: Josef Bacik <[email protected]>
[ Upstream commit f4b1363cae43fef7c86c993b7ca7fe7d546b3c68 ]
We ran into a deadlock in production with the fixup worker. The stack traces were as follows:
Thread responsible for the writeout, waiting on the page lock
[<0>] io_schedule+0x12/0x40 [<0>] __lock_page+0x109/0x1e0 [<0>] extent_write_cache_pages+0x206/0x360 [<0>] extent_writepages+0x40/0x60 [<0>] do_writepages+0x31/0xb0 [<0>] __writeback_single_inode+0x3d/0x350 [<0>] writeback_sb_inodes+0x19d/0x3c0 [<0>] __writeback_inodes_wb+0x5d/0xb0 [<0>] wb_writeback+0x231/0x2c0 [<0>] wb_workfn+0x308/0x3c0 [<0>] process_one_work+0x1e0/0x390 [<0>] worker_thread+0x2b/0x3c0 [<0>] kthread+0x113/0x130 [<0>] ret_from_fork+0x35/0x40 [<0>] 0xffffffffffffffff
Thread of the fixup worker who is holding the page lock
[<0>] start_delalloc_inodes+0x241/0x2d0 [<0>] btrfs_start_delalloc_roots+0x179/0x230 [<0>] btrfs_alloc_data_chunk_ondemand+0x11b/0x2e0 [<0>] btrfs_check_data_free_space+0x53/0xa0 [<0>] btrfs_delalloc_reserve_space+0x20/0x70 [<0>] btrfs_writepage_fixup_worker+0x1fc/0x2a0 [<0>] normal_work_helper+0x11c/0x360 [<0>] process_one_work+0x1e0/0x390 [<0>] worker_thread+0x2b/0x3c0 [<0>] kthread+0x113/0x130 [<0>] ret_from_fork+0x35/0x40 [<0>] 0xffffffffffffffff
Thankfully the stars have to align just right to hit this. First you have to end up in the fixup worker, which is tricky by itself (my reproducer does DIO reads into a MMAP'ed region, so not a common operation). Then you have to have less than a page size of free data space and 0 unallocated space so you go down the "commit the transaction to free up pinned space" path. This was accomplished by a random balance that was running on the host. Then you get this deadlock.
I'm still in the process of trying to force the deadlock to happen on demand, but I've hit other issues. I can still trigger the fixup worker path itself so this patch has been tested in that regard, so the normal case is fine.
--- fs/btrfs/inode.c | 76 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 16 deletions(-)
fs/btrfs/inode.c +60 -16
@@ -2191,6 +2191,7 @@ int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end,/* see btrfs_writepage_start_hook for details on why this is required */ struct btrfs_writepage_fixup {struct page *page; +struct inode *inode;struct btrfs_work work; };
@@ -2205,9 +2206,20 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work)u64 page_start;u64 page_end;int ret =0 ; +bool free_delalloc_space = true; fixup = container_of(work, struct btrfs_writepage_fixup, work); page = fixup->page; + inode = fixup->inode; + page_start =page_offset (page); + page_end =page_offset (page) +PAGE_SIZE -1 ; + +/* +* This is similar to page_mkwrite, we need to reserve the space before +* we take the page lock. +*/ + ret =btrfs_delalloc_reserve_space (inode, &data_reserved, page_start, +PAGE_SIZE ); again:lock_page (page);
@@ -2216,25 +2228,48 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work)* page->mapping may go NULL, but it shouldn't be moved to a different * address space. */ -if (!page->mapping || !PageDirty (page) || !PageChecked (page)) +if (!page->mapping || !PageDirty (page) || !PageChecked (page)) { +/* +* Unfortunately this is a little tricky, either +* +* 1) We got here and our page had already been dealt with and +* we reserved our space, thus ret == 0, so we need to just +* drop our space reservation and bail. This can happen the +* first time we come into the fixup worker, or could happen +* while waiting for the ordered extent. +* 2) Our page was already dealt with, but we happened to get an +* ENOSPC above from the btrfs_delalloc_reserve_space. In +* this case we obviously don't have anything to release, but +* because the page was already dealt with we don't want to +* mark the page with an error, so make sure we're resetting +* ret to 0. This is why we have this check _before_ the ret +* check, because we do not want to have a surprise ENOSPC +* when the page was already properly dealt with. +*/ +if (!ret) { +btrfs_delalloc_release_extents (BTRFS_I (inode), +PAGE_SIZE ); +btrfs_delalloc_release_space (inode, data_reserved, + page_start,PAGE_SIZE , + true); + } + ret =0 ; goto out_page; + }/* -* We keep the PageChecked() bit set until we're done with the -* btrfs_start_ordered_extent() dance that we do below. That drops and -* retakes the page lock, so we don't want new fixup workers queued for -* this page during the churn. +* We can't mess with the page state unless it is locked, so now that +* it is locked bail if we failed to make our space reservation. */ - inode = page->mapping->host; - page_start =page_offset (page); - page_end =page_offset (page) +PAGE_SIZE -1 ; +if (ret) + goto out_page;lock_extent_bits (&BTRFS_I (inode)->io_tree, page_start, page_end, &cached_state);/* already ordered? We're done */ if (PagePrivate2 (page)) - goto out; + goto out_reserved; ordered =btrfs_lookup_ordered_range (BTRFS_I (inode), page_start,PAGE_SIZE );
@@ -2247,11 +2282,6 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work) goto again; } - ret =btrfs_delalloc_reserve_space (inode, &data_reserved, page_start, -PAGE_SIZE ); -if (ret) - goto out; - ret =btrfs_set_extent_delalloc (inode, page_start, page_end,0 , &cached_state);if (ret)
@@ -2265,12 +2295,12 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work)* The page was dirty when we started, nothing should have cleaned it. */ BUG_ON (!PageDirty (page)); + free_delalloc_space = false; out_reserved:btrfs_delalloc_release_extents (BTRFS_I (inode),PAGE_SIZE ); -if (ret) +if (free_delalloc_space)btrfs_delalloc_release_space (inode, data_reserved, page_start,PAGE_SIZE , true); -out:unlock_extent_cached (&BTRFS_I (inode)->io_tree, page_start, page_end, &cached_state); out_page:
@@ -2289,6 +2319,12 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work)put_page (page);kfree (fixup);extent_changeset_free (data_reserved); +/* +* As a precaution, do a delayed iput in case it would be the last iput +* that could need flushing space. Recursing back to fixup worker would +* deadlock. +*/ +btrfs_add_delayed_iput (inode); }/*
@@ -2326,10 +2362,18 @@ int btrfs_writepage_cow_fixup(struct page *page, u64 start, u64 end)if (!fixup)return -EAGAIN ; +/* +* We are already holding a reference to this inode from +* write_cache_pages. We need to hold it because the space reservation +* takes place outside of the page lock, and we can't trust +* page->mapping outside of the page lock. +*/ +ihold (inode);SetPageChecked (page);get_page (page);btrfs_init_work (&fixup->work, btrfs_writepage_fixup_worker,NULL ,NULL ); fixup->page = page; + fixup->inode = inode;btrfs_queue_work (fs_info->fixup_workers, &fixup->work);return -EAGAIN ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 504/542 tracing: Fix now invalid var_ref_vals assumption in trace action
In reply to Sasha LevinFrom: Tom Zanussi <[email protected]>
[ Upstream commit d380dcde9a07ca5de4805dee11f58a98ec0ad6ff ]
The patch 'tracing: Fix histogram code when expression has same var as value' added code to return an existing variable reference when creating a new variable reference, which resulted in var_ref_vals slots being reused instead of being duplicated.
The implementation of the trace action assumes that the end of the var_ref_vals array starting at action_data.var_ref_idx corresponds to the values that will be assigned to the trace params. The patch mentioned above invalidates that assumption, which means that each param needs to explicitly specify its index into var_ref_vals.
This fix changes action_data.var_ref_idx to an array of var ref indexes to account for that.
--- kernel/trace/trace_events_hist.c | 53 +++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 15 deletions(-)
kernel/trace/trace_events_hist.c +38 -15
@@ -470,11 +470,12 @@ struct action_data {* When a histogram trigger is hit, the values of any * references to variables, including variables being passed * as parameters to synthetic events, are collected into a -* var_ref_vals array. This var_ref_idx is the index of the -* first param in the array to be passed to the synthetic -* event invocation. +* var_ref_vals array. This var_ref_idx array is an array of +* indices into the var_ref_vals array, one for each synthetic +* event param, and is passed to the synthetic event +* invocation. */ -unsigned int var_ref_idx; +unsigned int var_ref_idx[TRACING_MAP_VARS_MAX ];struct synth_event *synth_event;bool use_trace_keyword;char *synth_event_name;
@@ -875,14 +876,14 @@ static struct trace_event_functions synth_event_funcs = { static notrace void trace_event_raw_event_synth(void *__data,u64 *var_ref_vals, -unsigned int var_ref_idx) +unsigned int *var_ref_idx) {struct trace_event_file *trace_file = __data;struct synth_trace_event *entry;struct trace_event_buffer fbuffer;struct ring_buffer *buffer;struct synth_event *event; -unsigned int i, n_u64; +unsigned int i, n_u64, val_idx;int fields_size =0 ; event = trace_file->event_call->data;
@@ -905,15 +906,16 @@ static notrace void trace_event_raw_event_synth(void *__data, goto out;for (i =0 , n_u64 =0 ; i < event->n_fields; i++) { + val_idx = var_ref_idx[i];if (event->fields[i]->is_string) { -char *str_val = (char *)(long )var_ref_vals[var_ref_idx + i]; +char *str_val = (char *)(long )var_ref_vals[val_idx];char *str_field = (char *)&entry->fields[n_u64];strscpy (str_field, str_val,STR_VAR_LEN_MAX ); n_u64 +=STR_VAR_LEN_MAX /sizeof (u64); }else {struct synth_field *field = event->fields[i]; -u64 val = var_ref_vals[var_ref_idx + i]; +u64 val = var_ref_vals[val_idx];switch (field->size) {case 1 :
@@ -1113,10 +1115,10 @@ static struct tracepoint *alloc_synth_tracepoint(char *name) }typedef void (*synth_probe_func_t ) (void *__data,u64 *var_ref_vals, -unsigned int var_ref_idx); +unsigned int *var_ref_idx);static inline void trace_synth (struct synth_event *event,u64 *var_ref_vals, -unsigned int var_ref_idx) +unsigned int *var_ref_idx) {struct tracepoint *tp = event->tp;
@@ -2651,6 +2653,22 @@ static int init_var_ref(struct hist_field *ref_field, goto out; } +static int find_var_ref_idx (struct hist_trigger_data *hist_data, +struct hist_field *var_field) +{ +struct hist_field *ref_field; +int i; + +for (i =0 ; i < hist_data->n_var_refs; i++) { + ref_field = hist_data->var_refs[i]; +if (ref_field->var.idx == var_field->var.idx && + ref_field->var.hist_data == var_field->hist_data) +return i; + } + +return -ENOENT ; +} +/** * create_var_ref - Create a variable reference and attach it to trigger * @hist_data: The trigger that will be referencing the variable
@@ -4224,11 +4242,11 @@ static int trace_action_create(struct hist_trigger_data *hist_data,struct trace_array *tr = hist_data->event_file->tr;char *event_name, *param, *system =NULL ;struct hist_field *hist_field, *var_ref; -unsigned int i, var_ref_idx; +unsigned int i;unsigned int field_pos =0 ;struct synth_event *event;char *synth_event_name; -int ret =0 ; +int var_ref_idx, ret =0 ;lockdep_assert_held (&event_mutex);
@@ -4245,8 +4263,6 @@ static int trace_action_create(struct hist_trigger_data *hist_data, event->ref++; - var_ref_idx = hist_data->n_var_refs; -for (i =0 ; i < data->n_params; i++) {char *p;
@@ -4295,6 +4311,14 @@ static int trace_action_create(struct hist_trigger_data *hist_data, goto err; } + var_ref_idx =find_var_ref_idx (hist_data, var_ref); +if (WARN_ON (var_ref_idx <0 )) { + ret = var_ref_idx; + goto err; + } + + data->var_ref_idx[i] = var_ref_idx; + field_pos++;kfree (p);continue ;
@@ -4313,7 +4337,6 @@ static int trace_action_create(struct hist_trigger_data *hist_data, } data->synth_event = event; - data->var_ref_idx = var_ref_idx; out:return ret; err:
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 505/542 ocfs2: make local header paths relative to C files
In reply to Sasha LevinFrom: Masahiro Yamada <[email protected]>
[ Upstream commit ca322fb6030956c2337fbf1c1beeb08c5dd5c943 ]
Gang He reports the failure of building fs/ocfs2/ as an external module of the kernel installed on the system:
$ cd fs/ocfs2 $ make -C /lib/modules/`uname -r`/build M=`pwd` modules
If you want to make it work reliably, I'd recommend to remove ccflags-y from the Makefiles, and to make header paths relative to the C files. I think this is the correct usage of the #include "..." directive.
--- fs/ocfs2/dlm/Makefile | 2 -- fs/ocfs2/dlm/dlmast.c | 8 ++++---- fs/ocfs2/dlm/dlmconvert.c | 8 ++++---- fs/ocfs2/dlm/dlmdebug.c | 8 ++++---- fs/ocfs2/dlm/dlmdomain.c | 8 ++++---- fs/ocfs2/dlm/dlmlock.c | 8 ++++---- fs/ocfs2/dlm/dlmmaster.c | 8 ++++---- fs/ocfs2/dlm/dlmrecovery.c | 8 ++++---- fs/ocfs2/dlm/dlmthread.c | 8 ++++---- fs/ocfs2/dlm/dlmunlock.c | 8 ++++---- fs/ocfs2/dlmfs/Makefile | 2 -- fs/ocfs2/dlmfs/dlmfs.c | 4 ++-- fs/ocfs2/dlmfs/userdlm.c | 6 +++--- 13 files changed, 41 insertions(+), 45 deletions(-)
fs/ocfs2/dlm/Makefile +0 -2
@@ -1,6 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only -ccflags-y := -I $(srctree)/$(src)/.. - obj-$(CONFIG_OCFS2_FS_O2CB) += ocfs2_dlm.o ocfs2_dlm-objs := dlmdomain.o dlmdebug.o dlmthread.o dlmrecovery.o \
fs/ocfs2/dlm/dlmast.c +4 -4
@@ -23,15 +23,15 @@#include <linux/spinlock.h> -#include "cluster/heartbeat.h" -#include "cluster/nodemanager.h" -#include "cluster/tcp.h" +#include "../cluster/heartbeat.h" +#include "../cluster/nodemanager.h" +#include "../cluster/tcp.h" #include "dlmapi.h" #include "dlmcommon.h" #define MLOG_MASK_PREFIX ML_DLM -#include "cluster/masklog.h" +#include "../cluster/masklog.h" static void dlm_update_lvb (struct dlm_ctxt *dlm,struct dlm_lock_resource *res,struct dlm_lock *lock);
fs/ocfs2/dlm/dlmconvert.c +4 -4
@@ -23,9 +23,9 @@#include <linux/spinlock.h> -#include "cluster/heartbeat.h" -#include "cluster/nodemanager.h" -#include "cluster/tcp.h" +#include "../cluster/heartbeat.h" +#include "../cluster/nodemanager.h" +#include "../cluster/tcp.h" #include "dlmapi.h" #include "dlmcommon.h"
@@ -33,7 +33,7 @@#include "dlmconvert.h" #define MLOG_MASK_PREFIX ML_DLM -#include "cluster/masklog.h" +#include "../cluster/masklog.h" /* NOTE: __dlmconvert_master is the only function in here that * needs a spinlock held on entry (res->spinlock) and it is the
fs/ocfs2/dlm/dlmdebug.c +4 -4
@@ -17,9 +17,9 @@#include <linux/debugfs.h> #include <linux/export.h> -#include "cluster/heartbeat.h" -#include "cluster/nodemanager.h" -#include "cluster/tcp.h" +#include "../cluster/heartbeat.h" +#include "../cluster/nodemanager.h" +#include "../cluster/tcp.h" #include "dlmapi.h" #include "dlmcommon.h"
@@ -27,7 +27,7 @@#include "dlmdebug.h" #define MLOG_MASK_PREFIX ML_DLM -#include "cluster/masklog.h" +#include "../cluster/masklog.h" static int stringify_lockname (const char *lockname,int locklen,char *buf,int len);
fs/ocfs2/dlm/dlmdomain.c +4 -4
@@ -20,9 +20,9 @@#include <linux/debugfs.h> #include <linux/sched/signal.h> -#include "cluster/heartbeat.h" -#include "cluster/nodemanager.h" -#include "cluster/tcp.h" +#include "../cluster/heartbeat.h" +#include "../cluster/nodemanager.h" +#include "../cluster/tcp.h" #include "dlmapi.h" #include "dlmcommon.h"
@@ -30,7 +30,7 @@#include "dlmdebug.h" #define MLOG_MASK_PREFIX (ML_DLM|ML_DLM_DOMAIN) -#include "cluster/masklog.h" +#include "../cluster/masklog.h" /* * ocfs2 node maps are array of long int, which limits to send them freely
fs/ocfs2/dlm/dlmlock.c +4 -4
@@ -25,9 +25,9 @@#include <linux/delay.h> -#include "cluster/heartbeat.h" -#include "cluster/nodemanager.h" -#include "cluster/tcp.h" +#include "../cluster/heartbeat.h" +#include "../cluster/nodemanager.h" +#include "../cluster/tcp.h" #include "dlmapi.h" #include "dlmcommon.h"
@@ -35,7 +35,7 @@#include "dlmconvert.h" #define MLOG_MASK_PREFIX ML_DLM -#include "cluster/masklog.h" +#include "../cluster/masklog.h" static struct kmem_cache *dlm_lock_cache;
fs/ocfs2/dlm/dlmmaster.c +4 -4
@@ -25,9 +25,9 @@#include <linux/delay.h> -#include "cluster/heartbeat.h" -#include "cluster/nodemanager.h" -#include "cluster/tcp.h" +#include "../cluster/heartbeat.h" +#include "../cluster/nodemanager.h" +#include "../cluster/tcp.h" #include "dlmapi.h" #include "dlmcommon.h"
@@ -35,7 +35,7 @@#include "dlmdebug.h" #define MLOG_MASK_PREFIX (ML_DLM|ML_DLM_MASTER) -#include "cluster/masklog.h" +#include "../cluster/masklog.h" static void dlm_mle_node_down(struct dlm_ctxt *dlm, struct dlm_master_list_entry *mle,
fs/ocfs2/dlm/dlmrecovery.c +4 -4
@@ -26,16 +26,16 @@#include <linux/delay.h> -#include "cluster/heartbeat.h" -#include "cluster/nodemanager.h" -#include "cluster/tcp.h" +#include "../cluster/heartbeat.h" +#include "../cluster/nodemanager.h" +#include "../cluster/tcp.h" #include "dlmapi.h" #include "dlmcommon.h" #include "dlmdomain.h" #define MLOG_MASK_PREFIX (ML_DLM|ML_DLM_RECOVERY) -#include "cluster/masklog.h" +#include "../cluster/masklog.h" static void dlm_do_local_recovery_cleanup (struct dlm_ctxt *dlm,u8 dead_node);
fs/ocfs2/dlm/dlmthread.c +4 -4
@@ -25,16 +25,16 @@#include <linux/delay.h> -#include "cluster/heartbeat.h" -#include "cluster/nodemanager.h" -#include "cluster/tcp.h" +#include "../cluster/heartbeat.h" +#include "../cluster/nodemanager.h" +#include "../cluster/tcp.h" #include "dlmapi.h" #include "dlmcommon.h" #include "dlmdomain.h" #define MLOG_MASK_PREFIX (ML_DLM|ML_DLM_THREAD) -#include "cluster/masklog.h" +#include "../cluster/masklog.h" static int dlm_thread (void *data);static void dlm_flush_asts (struct dlm_ctxt *dlm);
fs/ocfs2/dlm/dlmunlock.c +4 -4
@@ -23,15 +23,15 @@#include <linux/spinlock.h> #include <linux/delay.h> -#include "cluster/heartbeat.h" -#include "cluster/nodemanager.h" -#include "cluster/tcp.h" +#include "../cluster/heartbeat.h" +#include "../cluster/nodemanager.h" +#include "../cluster/tcp.h" #include "dlmapi.h" #include "dlmcommon.h" #define MLOG_MASK_PREFIX ML_DLM -#include "cluster/masklog.h" +#include "../cluster/masklog.h" #define DLM_UNLOCK_FREE_LOCK 0x00000001#define DLM_UNLOCK_CALL_AST 0x00000002
fs/ocfs2/dlmfs/Makefile +0 -2
@@ -1,6 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only -ccflags-y := -I $(srctree)/$(src)/.. - obj-$(CONFIG_OCFS2_FS) += ocfs2_dlmfs.o ocfs2_dlmfs-objs := userdlm.o dlmfs.o
fs/ocfs2/dlmfs/dlmfs.c +2 -2
@@ -33,11 +33,11 @@#include <linux/uaccess.h> -#include "stackglue.h" +#include "../stackglue.h" #include "userdlm.h" #define MLOG_MASK_PREFIX ML_DLMFS -#include "cluster/masklog.h" +#include "../cluster/masklog.h" static const struct super_operations dlmfs_ops;
fs/ocfs2/dlmfs/userdlm.c +3 -3
@@ -21,12 +21,12 @@#include <linux/types.h> #include <linux/crc32.h> -#include "ocfs2_lockingver.h" -#include "stackglue.h" +#include "../ocfs2_lockingver.h" +#include "../stackglue.h" #include "userdlm.h" #define MLOG_MASK_PREFIX ML_DLMFS -#include "cluster/masklog.h" +#include "../cluster/masklog.h" static inline struct user_lock_res *user_lksb_to_lock_res (struct ocfs2_dlm_lksb *lksb)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 506/542 ocfs2: fix a NULL pointer dereference when call ocfs2_update_inode_fsync_trans()
In reply to Sasha LevinFrom: wangyan <[email protected]>
[ Upstream commit 9f16ca48fc818a17de8be1f75d08e7f4addc4497 ]
I found a NULL pointer dereference in ocfs2_update_inode_fsync_trans(), handle->h_transaction may be NULL in this situation:
ocfs2_file_write_iter
->__generic_file_write_iter
->generic_perform_write
->ocfs2_write_begin
->ocfs2_write_begin_nolock
->ocfs2_write_cluster_by_desc
->ocfs2_write_cluster
->ocfs2_mark_extent_written
->ocfs2_change_extent_flag
->ocfs2_split_extent
->ocfs2_try_to_merge_extent
->ocfs2_extend_rotate_transaction
->ocfs2_extend_trans
->jbd2_journal_restart
->jbd2__journal_restart
// handle->h_transaction is NULL here
->handle->h_transaction = NULL;
->start_this_handle
/* journal aborted due to storage
network disconnection, return error */
->return -EROFS;
/* line 3806 in ocfs2_try_to_merge_extent (),
it will ignore ret error. */
->ret = 0;
->...
->ocfs2_write_end
->ocfs2_write_end_nolock
->ocfs2_update_inode_fsync_trans
// NULL pointer dereference
->oi->i_sync_tid = handle->h_transaction->t_tid;The information of NULL pointer dereference as follows:
JBD2: Detected IO errors while flushing file data on dm-11-45
Aborting journal on device dm-11-45.
JBD2: Error -5 detected when updating journal superblock for dm-11-45.
(dd,22081,3):ocfs2_extend_trans:474 ERROR: status = -30
(dd,22081,3):ocfs2_try_to_merge_extent:3877 ERROR: status = -30
Unable to handle kernel NULL pointer dereference at
virtual address 0000000000000008
Mem abort info:
ESR = 0x96000004
Exception class = DABT (current EL), IL = 32 bits
SET = 0, FnV = 0
EA = 0, S1PTW = 0
Data abort info:
ISV = 0, ISS = 0x00000004
CM = 0, WnR = 0
user pgtable: 4k pages, 48-bit VAs, pgdp = 00000000e74e1338
[0000000000000008] pgd=0000000000000000
Internal error: Oops: 96000004 [#1] SMP
Process dd (pid: 22081, stack limit = 0x00000000584f35a9)
CPU: 3 PID: 22081 Comm: dd Kdump: loaded
Hardware name: Huawei TaiShan 2280 V2/BC82AMDD, BIOS 0.98 08/25/2019
pstate: 60400009 (nZCv daif +PAN -UAO)
pc : ocfs2_write_end_nolock+0x2b8/0x550 [ocfs2]
lr : ocfs2_write_end_nolock+0x2a0/0x550 [ocfs2]
sp : ffff0000459fba70
x29: ffff0000459fba70 x28: 0000000000000000
x27: ffff807ccf7f1000 x26: 0000000000000001
x25: ffff807bdff57970 x24: ffff807caf1d4000
x23: ffff807cc79e9000 x22: 0000000000001000
x21: 000000006c6cd000 x20: ffff0000091d9000
x19: ffff807ccb239db0 x18: ffffffffffffffff
x17: 000000000000000e x16: 0000000000000007
x15: ffff807c5e15bd78 x14: 0000000000000000
x13: 0000000000000000 x12: 0000000000000000
x11: 0000000000000000 x10: 0000000000000001
x9 : 0000000000000228 x8 : 000000000000000c
x7 : 0000000000000fff x6 : ffff807a308ed6b0
x5 : ffff7e01f10967c0 x4 : 0000000000000018
x3 : d0bc661572445600 x2 : 0000000000000000
x1 : 000000001b2e0200 x0 : 0000000000000000
Call trace:
ocfs2_write_end_nolock+0x2b8/0x550 [ocfs2]
ocfs2_write_end+0x4c/0x80 [ocfs2]
generic_perform_write+0x108/0x1a8
__generic_file_write_iter+0x158/0x1c8
ocfs2_file_write_iter+0x668/0x950 [ocfs2]
__vfs_write+0x11c/0x190
vfs_write+0xac/0x1c0
ksys_write+0x6c/0xd8
__arm64_sys_write+0x24/0x30
el0_svc_common+0x78/0x130
el0_svc_handler+0x38/0x78
el0_svc+0x8/0xcTo prevent NULL pointer dereference in this situation, we use is_handle_aborted() before using handle->h_transaction->t_tid.
--- fs/ocfs2/journal.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/ocfs2/journal.h +5 -3
@@ -597,9 +597,11 @@ static inline void ocfs2_update_inode_fsync_trans(handle_t *handle, {struct ocfs2_inode_info *oi =OCFS2_I (inode); - oi->i_sync_tid = handle->h_transaction->t_tid; -if (datasync) - oi->i_datasync_tid = handle->h_transaction->t_tid; +if (!is_handle_aborted (handle)) { + oi->i_sync_tid = handle->h_transaction->t_tid; +if (datasync) + oi->i_datasync_tid = handle->h_transaction->t_tid; + } }#endif /* OCFS2_JOURNAL_H */
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 507/542 lib/scatterlist.c: adjust indentation in __sg_alloc_table
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 4e456fee215677584cafa7f67298a76917e89c64 ]
Clang warns:
../lib/scatterlist.c:314:5: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
return -ENOMEM;
^
../lib/scatterlist.c:311:4: note: previous statement is here
if (prv)
^1 warning generated.
This warning occurs because there is a space before the tab on this line. Remove it so that the indentation is consistent with the Linux kernel coding style and clang no longer warns.
--- lib/scatterlist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/scatterlist.c +1 -1
@@ -311,7 +311,7 @@ int __sg_alloc_table(struct sg_table *table, unsigned int nents,if (prv) table->nents = ++table->orig_nents; -return -ENOMEM ; +return -ENOMEM ; }sg_init_table (sg, alloc_size);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 508/542 reiserfs: prevent NULL pointer dereference in reiserfs_insert_item()
In reply to Sasha LevinFrom: Yunfeng Ye <[email protected]>
[ Upstream commit aacee5446a2a1aa35d0a49dab289552578657fb4 ]
The variable inode may be NULL in reiserfs_insert_item(), but there is no check before accessing the member of inode.
Fix this by adding NULL pointer check before calling reiserfs_debug().
--- fs/reiserfs/stree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/reiserfs/stree.c +2 -1
@@ -2246,7 +2246,8 @@ int reiserfs_insert_item(struct reiserfs_transaction_handle *th,/* also releases the path */ unfix_nodes (&s_ins_balance);#ifdef REISERQUOTA_DEBUG -reiserfs_debug (th->t_super,REISERFS_DEBUG_CODE , +if (inode) +reiserfs_debug (th->t_super,REISERFS_DEBUG_CODE ,"reiserquota insert_item(): freeing %u id=%u type=%c" , quota_bytes, inode->i_uid,head2type (ih));#endif
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 510/542 bcache: explicity type cast in bset_bkey_last()
In reply to Sasha LevinFrom: Coly Li <[email protected]>
[ Upstream commit 7c02b0055f774ed9afb6e1c7724f33bf148ffdc0 ]
In bset.h, macro bset_bkey_last() is defined as,
bkey_idx((struct bkey *) (i)->d, (i)->keys)
Parameter i can be variable type of data structure, the macro always works once the type of struct i has member 'd' and 'keys'.
bset_bkey_last() is also used in macro csum_set() to calculate the checksum of a on-disk data structure. When csum_set() is used to calculate checksum of on-disk bcache super block, the parameter 'i' data type is struct cache_sb_disk. Inside struct cache_sb_disk (also in struct cache_sb) the member keys is __u16 type. But bkey_idx() expects unsigned int (a 32bit width), so there is problem when sending parameters via stack to call bkey_idx().
Sparse tool from Intel 0day kbuild system reports this incompatible problem. bkey_idx() is part of user space API, so the simplest fix is to cast the (i)->keys to unsigned int type in macro bset_bkey_last().
--- drivers/md/bcache/bset.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/bcache/bset.h +2 -1
@@ -397,7 +397,8 @@ void bch_btree_keys_stats(struct btree_keys *b, struct bset_stats *state);/* Bkey utility code */ -#define bset_bkey_last (i) bkey_idx((struct bkey *) (i)->d, (i)->keys) +#define bset_bkey_last (i) bkey_idx((struct bkey *) (i)->d, \ + (unsigned int)(i)->keys)static inline struct bkey *bset_bkey_idx (struct bset *i,unsigned int idx) {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 511/542 bcache: fix incorrect data type usage in btree_flush_write()
In reply to Sasha LevinFrom: Coly Li <[email protected]>
[ Upstream commit d1c3cc34f5a78b38d2b809b289d912c3560545df ]
Dan Carpenter points out that from commit 2aa8c529387c ("bcache: avoid unnecessary btree nodes flushing in btree_flush_write()"), there is a incorrect data type usage which leads to the following static checker warning:
drivers/md/bcache/journal.c:444 btree_flush_write()
warn: 'ref_nr' unsigned <= 0
drivers/md/bcache/journal.c
422 static void btree_flush_write(struct cache_set *c) 423 {
424 struct btree *b, *t, *btree_nodes[BTREE_FLUSH_NR];
425 unsigned int i, nr, ref_nr;
^^^^^^ 426 atomic_t *fifo_front_p, *now_fifo_front_p;
427 size_t mask;
428
429 if (c->journal.btree_flushing)
430 return;
431
432 spin_lock(&c->journal.flush_write_lock);
433 if (c->journal.btree_flushing) {
434 spin_unlock(&c->journal.flush_write_lock);
435 return;
436 }
437 c->journal.btree_flushing = true;
438 spin_unlock(&c->journal.flush_write_lock);
439
440 /* get the oldest journal entry and check its refcount */
441 spin_lock(&c->journal.lock);
442 fifo_front_p = &fifo_front(&c->journal.pin);
443 ref_nr = atomic_read(fifo_front_p);
444 if (ref_nr <= 0) {
^^^^^^^^^^^Unsigned can't be less than zero.
445 /* 446 * do nothing if no btree node references 447 * the oldest journal entry 448 */ 449 spin_unlock(&c->journal.lock); 450 goto out; 451 } 452 spin_unlock(&c->journal.lock);
As the warning information indicates, local varaible ref_nr in unsigned int type is wrong, which does not matche atomic_read() and the "<= 0" checking.
This patch fixes the above error by defining local variable ref_nr as int type.
--- drivers/md/bcache/journal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/bcache/journal.c +2 -1
@@ -422,7 +422,8 @@ int bch_journal_replay(struct cache_set *s, struct list_head *list)static void btree_flush_write (struct cache_set *c) {struct btree *b, *t, *btree_nodes[BTREE_FLUSH_NR ]; -unsigned int i, nr, ref_nr; +unsigned int i, nr; +int ref_nr;atomic_t *fifo_front_p, *now_fifo_front_p;size_t mask;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 512/542 irqchip/gic-v3-its: Reference to its_invall_cmd descriptor when building INVALL
In reply to Sasha LevinFrom: Zenghui Yu <[email protected]>
[ Upstream commit 107945227ac5d4c37911c7841b27c64b489ce9a9 ]
It looks like an obvious mistake to use its_mapc_cmd descriptor when building the INVALL command block. It so far worked by luck because both its_mapc_cmd.col and its_invall_cmd.col sit at the same offset of the ITS command descriptor, but we should not rely on it.
--- drivers/irqchip/irq-gic-v3-its.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3-its.c +1 -1
@@ -598,7 +598,7 @@ static struct its_collection *its_build_invall_cmd(struct its_node *its, struct its_cmd_desc *desc) {its_encode_cmd (cmd,GITS_CMD_INVALL ); -its_encode_collection (cmd, desc->its_mapc_cmd.col->col_id); +its_encode_collection (cmd, desc->its_invall_cmd.col->col_id);its_fixup_cmd (cmd);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 513/542 nvmet: Pass lockdep expression to RCU lists
In reply to Sasha LevinFrom: Amol Grover <[email protected]>
[ Upstream commit 4ac76436a6d07dec1c3c766f234aa787a16e8f65 ]
ctrl->subsys->namespaces and subsys->namespaces are traversed with list_for_each_entry_rcu outside an RCU read-side critical section but under the protection of ctrl->subsys->lock and subsys->lock respectively.
Hence, add the corresponding lockdep expression to the list traversal primitive to silence false-positive lockdep warnings, and harden RCU lists.
--- drivers/nvme/target/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/nvme/target/core.c +4 -2
@@ -555,7 +555,8 @@ int nvmet_ns_enable(struct nvmet_ns *ns) }else {struct nvmet_ns *old; -list_for_each_entry_rcu (old, &subsys->namespaces, dev_link) { +list_for_each_entry_rcu (old, &subsys->namespaces, dev_link, +lockdep_is_held (&subsys->lock)) {BUG_ON (ns->nsid == old->nsid);if (ns->nsid < old->nsid)break ;
@@ -1172,7 +1173,8 @@ static void nvmet_setup_p2p_ns_map(struct nvmet_ctrl *ctrl, ctrl->p2p_client =get_device (req->p2p_client); -list_for_each_entry_rcu (ns, &ctrl->subsys->namespaces, dev_link) +list_for_each_entry_rcu (ns, &ctrl->subsys->namespaces, dev_link, +lockdep_is_held (&ctrl->subsys->lock))nvmet_p2pmem_ns_add_p2p (ctrl, ns); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 514/542 nvmet: fix dsm failure when payload does not match sgl descriptor
In reply to Sasha LevinFrom: Sagi Grimberg <[email protected]>
[ Upstream commit b716e6889c95f64ba32af492461f6cc9341f3f05 ]
The host is allowed to pass the controller an sgl describing a buffer that is larger than the dsm payload itself, allow it when executing dsm.
--- drivers/nvme/target/core.c | 11 +++++++++++ drivers/nvme/target/io-cmd-bdev.c | 2 +- drivers/nvme/target/io-cmd-file.c | 2 +- drivers/nvme/target/nvmet.h | 1 + 4 files changed, 14 insertions(+), 2 deletions(-)
drivers/nvme/target/core.c +11 -0
@@ -939,6 +939,17 @@ bool nvmet_check_data_len(struct nvmet_req *req, size_t data_len) }EXPORT_SYMBOL_GPL (nvmet_check_data_len); +bool nvmet_check_data_len_lte (struct nvmet_req *req,size_t data_len) +{ +if (unlikely (data_len > req->transfer_len)) { + req->error_loc = offsetof(struct nvme_common_command , dptr); +nvmet_req_complete (req,NVME_SC_SGL_INVALID_DATA |NVME_SC_DNR ); +return false; + } + +return true; +} +int nvmet_req_alloc_sgl (struct nvmet_req *req) {struct pci_dev *p2p_dev =NULL ;
drivers/nvme/target/io-cmd-bdev.c +1 -1
@@ -280,7 +280,7 @@ static void nvmet_bdev_execute_discard(struct nvmet_req *req)static void nvmet_bdev_execute_dsm (struct nvmet_req *req) { -if (!nvmet_check_data_len (req,nvmet_dsm_len (req))) +if (!nvmet_check_data_len_lte (req,nvmet_dsm_len (req)))return ;switch (le32_to_cpu (req->cmd->dsm.attributes)) {
drivers/nvme/target/io-cmd-file.c +1 -1
@@ -336,7 +336,7 @@ static void nvmet_file_dsm_work(struct work_struct *w)static void nvmet_file_execute_dsm (struct nvmet_req *req) { -if (!nvmet_check_data_len (req,nvmet_dsm_len (req))) +if (!nvmet_check_data_len_lte (req,nvmet_dsm_len (req)))return ;INIT_WORK (&req->f.work, nvmet_file_dsm_work);schedule_work (&req->f.work);
drivers/nvme/target/nvmet.h +1 -0
@@ -374,6 +374,7 @@ bool nvmet_req_init(struct nvmet_req *req, struct nvmet_cq *cq, struct nvmet_sq *sq, const struct nvmet_fabrics_ops *ops);void nvmet_req_uninit (struct nvmet_req *req);bool nvmet_check_data_len (struct nvmet_req *req,size_t data_len); +bool nvmet_check_data_len_lte (struct nvmet_req *req,size_t data_len);void nvmet_req_complete (struct nvmet_req *req,u16 status);int nvmet_req_alloc_sgl (struct nvmet_req *req);void nvmet_req_free_sgl (struct nvmet_req *req);
Signature · 7 lines
2.20.1 _______________________________________________ linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Sasha Levin
maintainerPATCH 515/542 nvme-pci: remove nvmeq->tags
In reply to Sasha LevinFrom: Christoph Hellwig <[email protected]>
[ Upstream commit cfa27356f835dc7755192e7b941d4f4851acbcc7 ]
There is no real need to have a pointer to the tagset in struct nvme_queue, as we only need it in a single place, and that place can derive the used tagset from the device and qid trivially. This fixes a problem with stale pointer exposure when tagsets are reset, and also shrinks the nvme_queue structure. It also matches what most other transports have done since day 1.
--- drivers/nvme/host/pci.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-)
drivers/nvme/host/pci.c +8 -15
@@ -167,7 +167,6 @@ struct nvme_queue {/* only used for poll queues: */ spinlock_t cq_poll_lock____cacheline_aligned_in_smp ;volatile struct nvme_completion *cqes; -struct blk_mq_tags **tags;dma_addr_t sq_dma_addr;dma_addr_t cq_dma_addr;u32 __iomem *q_db;
@@ -376,29 +375,17 @@ static int nvme_admin_init_hctx(struct blk_mq_hw_ctx *hctx, void *data,WARN_ON (hctx_idx !=0 );WARN_ON (dev->admin_tagset.tags[0 ] != hctx->tags); -WARN_ON (nvmeq->tags); hctx->driver_data = nvmeq; - nvmeq->tags = &dev->admin_tagset.tags[0 ];return 0 ; } -static void nvme_admin_exit_hctx (struct blk_mq_hw_ctx *hctx,unsigned int hctx_idx) -{ -struct nvme_queue *nvmeq = hctx->driver_data; - - nvmeq->tags =NULL ; -} -static int nvme_init_hctx (struct blk_mq_hw_ctx *hctx,void *data,unsigned int hctx_idx) {struct nvme_dev *dev = data;struct nvme_queue *nvmeq = &dev->queues[hctx_idx +1 ]; -if (!nvmeq->tags) - nvmeq->tags = &dev->tagset.tags[hctx_idx]; -WARN_ON (dev->tagset.tags[hctx_idx] != hctx->tags); hctx->driver_data = nvmeq;return 0 ;
@@ -948,6 +935,13 @@ static inline void nvme_ring_cq_doorbell(struct nvme_queue *nvmeq)writel (head, nvmeq->q_db + nvmeq->dev->db_stride); } +static inline struct blk_mq_tags *nvme_queue_tagset (struct nvme_queue *nvmeq) +{ +if (!nvmeq->qid) +return nvmeq->dev->admin_tagset.tags[0 ]; +return nvmeq->dev->tagset.tags[nvmeq->qid -1 ]; +} +static inline void nvme_handle_cqe (struct nvme_queue *nvmeq,u16 idx) {volatile struct nvme_completion *cqe = &nvmeq->cqes[idx];
@@ -972,7 +966,7 @@ static inline void nvme_handle_cqe(struct nvme_queue *nvmeq, u16 idx)return ; } - req =blk_mq_tag_to_rq (*nvmeq->tags, cqe->command_id); + req =blk_mq_tag_to_rq (nvme_queue_tagset (nvmeq), cqe->command_id);trace_nvme_sq (req, cqe->sq_head, nvmeq->sq_tail);nvme_end_request (req, cqe->status, cqe->result); }
@@ -1572,7 +1566,6 @@ static const struct blk_mq_ops nvme_mq_admin_ops = { .queue_rq = nvme_queue_rq, .complete = nvme_pci_complete_rq, .init_hctx = nvme_admin_init_hctx, - .exit_hctx = nvme_admin_exit_hctx, .init_request = nvme_init_request, .timeout = nvme_timeout, };
Signature · 7 lines
2.20.1 _______________________________________________ linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Sasha Levin
maintainerPATCH 516/542 iwlwifi: mvm: Fix thermal zone registration
In reply to Sasha LevinFrom: Andrei Otcheretianski <[email protected]>
[ Upstream commit baa6cf8450b72dcab11f37c47efce7c5b9b8ad0f ]
Use a unique name when registering a thermal zone. Otherwise, with multiple NICS, we hit the following warning during the unregistration.
WARNING: CPU: 2 PID: 3525 at fs/sysfs/group.c:255 RIP: 0010:sysfs_remove_group+0x80/0x90 Call Trace: dpm_sysfs_remove+0x57/0x60 device_del+0x5a/0x350 ? sscanf+0x4e/0x70 device_unregister+0x1a/0x60 hwmon_device_unregister+0x4a/0xa0 thermal_remove_hwmon_sysfs+0x175/0x1d0 thermal_zone_device_unregister+0x188/0x1e0 iwl_mvm_thermal_exit+0xe7/0x100 [iwlmvm] iwl_op_mode_mvm_stop+0x27/0x180 [iwlmvm] _iwl_op_mode_stop.isra.3+0x2b/0x50 [iwlwifi] iwl_opmode_deregister+0x90/0xa0 [iwlwifi] __exit_compat+0x10/0x2c7 [iwlmvm] __x64_sys_delete_module+0x13f/0x270 do_syscall_64+0x5a/0x110 entry_SYSCALL_64_after_hwframe+0x44/0xa9
--- drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/tt.c +3 -1
@@ -734,7 +734,8 @@ static struct thermal_zone_device_ops tzone_ops = {static void iwl_mvm_thermal_zone_register (struct iwl_mvm *mvm) {int i; -char name[] ="iwlwifi" ; +char name[16 ]; +static atomic_t counter =ATOMIC_INIT (0 );if (!iwl_mvm_is_tt_in_fw (mvm)) { mvm->tz_device.tzone =NULL ;
@@ -744,6 +745,7 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)BUILD_BUG_ON (ARRAY_SIZE (name) >=THERMAL_NAME_LENGTH ); +sprintf (name,"iwlwifi_%u" ,atomic_inc_return (&counter) &0xFF ); mvm->tz_device.tzone = thermal_zone_device_register(name, IWL_MAX_DTS_TRIPS, IWL_WRITABLE_TRIPS_MSK,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 517/542 iwlwifi: mvm: avoid use after free for pmsr request
In reply to Sasha LevinFrom: Avraham Stern <[email protected]>
[ Upstream commit cc4255eff523f25187bb95561642941de0e57497 ]
When a FTM request is aborted, the driver sends the abort command to the fw and waits for a response. When the response arrives, the driver calls cfg80211_pmsr_complete() for that request.
However, cfg80211 frees the requested data immediately after sending the abort command, so this may lead to use after free.
Fix it by clearing the request data in the driver when the abort command arrives and ignoring the fw notification that will come afterwards.
--- drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c +4 -1
@@ -8,6 +8,7 @@* Copyright(c) 2015 - 2017 Intel Deutschland GmbH * Copyright (C) 2018 Intel Corporation * Copyright (C) 2019 Intel Corporation +* Copyright (C) 2020 Intel Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as
@@ -30,6 +31,7 @@* Copyright(c) 2015 - 2017 Intel Deutschland GmbH * Copyright (C) 2018 Intel Corporation * Copyright (C) 2019 Intel Corporation +* Copyright (C) 2020 Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -389,6 +391,8 @@ void iwl_mvm_ftm_abort(struct iwl_mvm *mvm, struct cfg80211_pmsr_request *req)if (req != mvm->ftm_initiator.req)return ; +iwl_mvm_ftm_reset (mvm); +if (iwl_mvm_send_cmd_pdu (mvm,iwl_cmd_id (TOF_RANGE_ABORT_CMD ,LOCATION_GROUP ,0 ),0 ,sizeof (cmd), &cmd))
@@ -502,7 +506,6 @@ void iwl_mvm_ftm_range_resp(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)lockdep_assert_held (&mvm->mutex);if (!mvm->ftm_initiator.req) { -IWL_ERR (mvm,"Got FTM response but have no request?\n" );return ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 518/542 iwlwifi: mvm: Check the sta is not NULL in iwl_mvm_cfg_he_sta()
In reply to Sasha LevinFrom: Andrei Otcheretianski <[email protected]>
[ Upstream commit 12d47f0ea5e0aa63f19ba618da55a7c67850ca10 ]
Fix a kernel panic by checking that the sta is not NULL. This could happen during a reconfig flow, as mac80211 moves the sta between all the states without really checking if the previous state was successfully set. So, if for some reason we failed to add back the station, subsequent calls to sta_state() callback will be done when the station is NULL. This would result in a following panic:
BUG: unable to handle kernel NULL pointer dereference at 0000000000000040 IP: iwl_mvm_cfg_he_sta+0xfc/0x690 [iwlmvm] [..] Call Trace: iwl_mvm_mac_sta_state+0x629/0x6f0 [iwlmvm] drv_sta_state+0xf4/0x950 [mac80211] ieee80211_reconfig+0xa12/0x2180 [mac80211] ieee80211_restart_work+0xbb/0xe0 [mac80211] process_one_work+0x1e2/0x610 worker_thread+0x4d/0x3e0
[..]
--- drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +3 -5
@@ -5,10 +5,9 @@* * GPL LICENSE SUMMARY * -* Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH * Copyright(c) 2016 - 2017 Intel Deutschland GmbH -* Copyright(c) 2018 - 2019 Intel Corporation +* Copyright(c) 2012 - 2014, 2018 - 2020 Intel Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as
@@ -28,10 +27,9 @@* * BSD LICENSE * -* Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH * Copyright(c) 2016 - 2017 Intel Deutschland GmbH -* Copyright(c) 2018 - 2019 Intel Corporation +* Copyright(c) 2012 - 2014, 2018 - 2020 Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -2037,7 +2035,7 @@ static void iwl_mvm_cfg_he_sta(struct iwl_mvm *mvm,rcu_read_lock (); sta =rcu_dereference (mvm->fw_id_to_mac_id[sta_ctxt_cmd.sta_id]); -if (IS_ERR (sta)) { +if (IS_ERR_OR_NULL (sta)) {rcu_read_unlock ();WARN (1 ,"Can't find STA to configure HE\n" );return ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 519/542 iwlwifi: mvm: fix TDLS discovery with the new firmware API
In reply to Sasha LevinFrom: Emmanuel Grumbach <[email protected]>
[ Upstream commit b5b878e36c1836c0195575132cc7c199e5a34a7b ]
I changed the API for asking for a session protection but I omitted the TDLS flows. Fix that now.
Note that for the TDLS flow, we need to block until the session protection actually starts, so add this option to iwl_mvm_schedule_session_protection.
This patch fixes a firmware assert in the TDLS flow since the old TIME_EVENT_CMD is not supported anymore by newer firwmare versions.
--- .../net/wireless/intel/iwlwifi/mvm/mac80211.c | 2 +- drivers/net/wireless/intel/iwlwifi/mvm/tdls.c | 10 ++- .../wireless/intel/iwlwifi/mvm/time-event.c | 71 ++++++++++++++++--- .../wireless/intel/iwlwifi/mvm/time-event.h | 4 +- 4 files changed, 72 insertions(+), 15 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +1 -1
@@ -3291,7 +3291,7 @@ static void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw *hw,if (fw_has_capa (&mvm->fw->ucode_capa,IWL_UCODE_TLV_CAPA_SESSION_PROT_CMD ))iwl_mvm_schedule_session_protection (mvm, vif,900 , - min_duration); + min_duration, false);else iwl_mvm_protect_session (mvm, vif, duration, min_duration,500 , false);
drivers/net/wireless/intel/iwlwifi/mvm/tdls.c +8 -2
@@ -205,9 +205,15 @@ void iwl_mvm_mac_mgd_protect_tdls_discover(struct ieee80211_hw *hw,struct iwl_mvm *mvm =IWL_MAC80211_GET_MVM (hw);u32 duration =2 * vif->bss_conf.dtim_period * vif->bss_conf.beacon_int; -mutex_lock (&mvm->mutex);/* Protect the session to hear the TDLS setup response on the channel */ -iwl_mvm_protect_session (mvm, vif, duration, duration,100 , true); +mutex_lock (&mvm->mutex); +if (fw_has_capa (&mvm->fw->ucode_capa, +IWL_UCODE_TLV_CAPA_SESSION_PROT_CMD )) +iwl_mvm_schedule_session_protection (mvm, vif, duration, + duration, true); +else +iwl_mvm_protect_session (mvm, vif, duration, + duration,100 , true);mutex_unlock (&mvm->mutex); }
drivers/net/wireless/intel/iwlwifi/mvm/time-event.c +60 -11
94 lines not on this page · raw message
drivers/net/wireless/intel/iwlwifi/mvm/time-event.h +3 -1
@@ -250,10 +250,12 @@ iwl_mvm_te_scheduled(struct iwl_mvm_time_event_data *te_data)* @mvm: the mvm component * @vif: the virtual interface for which the protection issued * @duration: the duration of the protection +* @wait_for_notif: if true, will block until the start of the protection */ void iwl_mvm_schedule_session_protection (struct iwl_mvm *mvm,struct ieee80211_vif *vif, -u32 duration,u32 min_duration); +u32 duration,u32 min_duration, +bool wait_for_notif);/** * iwl_mvm_rx_session_protect_notif - handles %SESSION_PROTECTION_NOTIF
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 520/542 NFSv4: pnfs_roc() must use cred_fscmp() to compare creds
In reply to Sasha LevinFrom: Trond Myklebust <[email protected]>
[ Upstream commit 387122478775be5d9816c34aa29de53d0b926835 ]
When comparing two 'struct cred' for equality w.r.t. behaviour under filesystem access, we need to use cred_fscmp().
--- fs/nfs/pnfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/pnfs.c +1 -1
@@ -1425,7 +1425,7 @@ bool pnfs_roc(struct inode *ino,/* lo ref dropped in pnfs_roc_release() */ layoutreturn =pnfs_prepare_layoutreturn (lo, &stateid, &iomode);/* If the creds don't match, we can't compound the layoutreturn */ -if (!layoutreturn || cred != lo->plh_lc_cred) +if (!layoutreturn ||cred_fscmp (cred, lo->plh_lc_cred) !=0 ) goto out_noroc; roc = layoutreturn;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 521/542 netdevsim: fix using uninitialized resources
In reply to Sasha LevinFrom: Taehee Yoo <[email protected]>
[ Upstream commit f5cd21605ecd249e5fc715411df22cc1bc877b32 ]
When module is being initialized, __init() calls bus_register() and driver_register().
These functions internally create various resources and sysfs files. The sysfs files are used for basic operations(add/del device). /sys/bus/netdevsim/new_device /sys/bus/netdevsim/del_device
These sysfs files use netdevsim resources, they are mostly allocated and initialized in ->probe() function, which is nsim_dev_probe(). But, sysfs files could be executed before ->probe() is finished. So, accessing uninitialized data would occur.
Another problem is very similar. /sys/bus/netdevsim/new_device internally creates sysfs files. /sys/devices/netdevsim<id>/new_port /sys/devices/netdevsim<id>/del_port
These sysfs files also use netdevsim resources, they are mostly allocated and initialized in creating device routine, which is nsim_bus_dev_new(). But they also could be executed before nsim_bus_dev_new() is finished. So, accessing uninitialized data would occur.
To fix these problems, this patch adds flags, which means whether the operation is finished or not.
The flag variable 'nsim_bus_enable' means whether netdevsim bus was initialized or not.
This is protected by nsim_bus_dev_list_lock.
The flag variable 'nsim_bus_dev->init' means whether nsim_bus_dev was initialized or not.
This could be used in {new/del}_port_store() with no lock.
Test commands:
#SHELL1
modprobe netdevsim
while :
do
echo "1 1" > /sys/bus/netdevsim/new_device echo "1 1" > /sys/bus/netdevsim/del_device
done
#SHELL2
while :
do
echo 1 > /sys/devices/netdevsim1/new_port
echo 1 > /sys/devices/netdevsim1/del_port
done
Splat looks like:
[ 47.508954][ T1008] general protection fault, probably for non-canonical address 0xdffffc0000000021: 0000 I [ 47.510793][ T1008] KASAN: null-ptr-deref in range [0x0000000000000108-0x000000000000010f] [ 47.511963][ T1008] CPU: 2 PID: 1008 Comm: bash Not tainted 5.5.0+ #322 [ 47.512823][ T1008] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 [ 47.514041][ T1008] RIP: 0010:__mutex_lock+0x10a/0x14b0 [ 47.514699][ T1008] Code: 08 84 d2 0f 85 7f 12 00 00 44 8b 0d 10 23 65 02 45 85 c9 75 29 49 8d 7f 68 48 b8 00 00 00 0f [ 47.517163][ T1008] RSP: 0018:ffff888059b4fbb0 EFLAGS: 00010206 [ 47.517802][ T1008] RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000000000 [ 47.518941][ T1008] RDX: 0000000000000021 RSI: ffffffff85926440 RDI: 0000000000000108 [ 47.519732][ T1008] RBP: ffff888059b4fd30 R08: ffffffffc073fad0 R09: 0000000000000000 [ 47.520729][ T1008] R10: ffff888059b4fd50 R11: ffff88804bb38040 R12: 0000000000000000 [ 47.521702][ T1008] R13: dffffc0000000000 R14: ffffffff871976c0 R15: 00000000000000a0 [ 47.522760][ T1008] FS: 00007fd4be05a740(0000) GS:ffff88806c800000(0000) knlGS:0000000000000000 [ 47.523877][ T1008] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 47.524627][ T1008] CR2: 0000561c82b69cf0 CR3: 0000000065dd6004 CR4: 00000000000606e0 [ 47.527662][ T1008] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 47.528604][ T1008] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 47.529531][ T1008] Call Trace: [ 47.529874][ T1008] ? nsim_dev_port_add+0x50/0x150 [netdevsim] [ 47.530470][ T1008] ? mutex_lock_io_nested+0x1380/0x1380 [ 47.531018][ T1008] ? _kstrtoull+0x76/0x160 [ 47.531449][ T1008] ? _parse_integer+0xf0/0xf0 [ 47.531874][ T1008] ? kernfs_fop_write+0x1cf/0x410 [ 47.532330][ T1008] ? sysfs_file_ops+0x160/0x160 [ 47.532773][ T1008] ? kstrtouint+0x86/0x110 [ 47.533168][ T1008] ? nsim_dev_port_add+0x50/0x150 [netdevsim] [ 47.533721][ T1008] nsim_dev_port_add+0x50/0x150 [netdevsim] [ 47.534336][ T1008] ? sysfs_file_ops+0x160/0x160 [ 47.534858][ T1008] new_port_store+0x99/0xb0 [netdevsim] [ 47.535439][ T1008] ? del_port_store+0xb0/0xb0 [netdevsim] [ 47.536035][ T1008] ? sysfs_file_ops+0x112/0x160 [ 47.536544][ T1008] ? sysfs_kf_write+0x3b/0x180 [ 47.537029][ T1008] kernfs_fop_write+0x276/0x410 [ 47.537548][ T1008] ? __sb_start_write+0x215/0x2e0 [ 47.538110][ T1008] vfs_write+0x197/0x4a0
[ ... ]
--- drivers/net/netdevsim/bus.c | 43 ++++++++++++++++++++++++++++--- drivers/net/netdevsim/netdevsim.h | 1 + 2 files changed, 41 insertions(+), 3 deletions(-)
drivers/net/netdevsim/bus.c +40 -3
@@ -17,6 +17,7 @@static DEFINE_IDA (nsim_bus_dev_ids);static LIST_HEAD (nsim_bus_dev_list);static DEFINE_MUTEX (nsim_bus_dev_list_lock); +static bool nsim_bus_enable;static struct nsim_bus_dev *to_nsim_bus_dev (struct device *dev) {
@@ -99,6 +100,9 @@ new_port_store(struct device *dev, struct device_attribute *attr,unsigned int port_index;int ret; +/* Prevent to use nsim_bus_dev before initialization. */ +if (!smp_load_acquire (&nsim_bus_dev->init)) +return -EBUSY ; ret =kstrtouint (buf,0 , &port_index);if (ret)return ret;
@@ -116,6 +120,9 @@ del_port_store(struct device *dev, struct device_attribute *attr,unsigned int port_index;int ret; +/* Prevent to use nsim_bus_dev before initialization. */ +if (!smp_load_acquire (&nsim_bus_dev->init)) +return -EBUSY ; ret =kstrtouint (buf,0 , &port_index);if (ret)return ret;
@@ -179,15 +186,30 @@ new_device_store(struct bus_type *bus, const char *buf, size_t count)pr_err ("Format for adding new device is \"id port_count\" (uint uint).\n" );return -EINVAL ; } - nsim_bus_dev =nsim_bus_dev_new (id, port_count); -if (IS_ERR (nsim_bus_dev)) -return PTR_ERR (nsim_bus_dev);mutex_lock (&nsim_bus_dev_list_lock); +/* Prevent to use resource before initialization. */ +if (!smp_load_acquire (&nsim_bus_enable)) { + err = -EBUSY ; + goto err; + } + + nsim_bus_dev =nsim_bus_dev_new (id, port_count); +if (IS_ERR (nsim_bus_dev)) { + err =PTR_ERR (nsim_bus_dev); + goto err; + } + +/* Allow using nsim_bus_dev */ +smp_store_release (&nsim_bus_dev->init, true); +list_add_tail (&nsim_bus_dev->list, &nsim_bus_dev_list);mutex_unlock (&nsim_bus_dev_list_lock);return count; +err: +mutex_unlock (&nsim_bus_dev_list_lock); +return err; }static BUS_ATTR_WO (new_device);
@@ -215,6 +237,11 @@ del_device_store(struct bus_type *bus, const char *buf, size_t count) err = -ENOENT ;mutex_lock (&nsim_bus_dev_list_lock); +/* Prevent to use resource before initialization. */ +if (!smp_load_acquire (&nsim_bus_enable)) { +mutex_unlock (&nsim_bus_dev_list_lock); +return -EBUSY ; + }list_for_each_entry_safe (nsim_bus_dev, tmp, &nsim_bus_dev_list, list) {if (nsim_bus_dev->dev.id != id)continue ;
@@ -284,6 +311,8 @@ nsim_bus_dev_new(unsigned int id, unsigned int port_count) nsim_bus_dev->dev.type = &nsim_bus_dev_type; nsim_bus_dev->port_count = port_count; nsim_bus_dev->initial_net = current->nsproxy->net_ns; +/* Disallow using nsim_bus_dev */ +smp_store_release (&nsim_bus_dev->init, false); err =device_register (&nsim_bus_dev->dev);if (err)
@@ -299,6 +328,8 @@ nsim_bus_dev_new(unsigned int id, unsigned int port_count)static void nsim_bus_dev_del (struct nsim_bus_dev *nsim_bus_dev) { +/* Disallow using nsim_bus_dev */ +smp_store_release (&nsim_bus_dev->init, false);device_unregister (&nsim_bus_dev->dev);ida_free (&nsim_bus_dev_ids, nsim_bus_dev->dev.id);kfree (nsim_bus_dev);
@@ -320,6 +351,8 @@ int nsim_bus_init(void) err =driver_register (&nsim_driver);if (err) goto err_bus_unregister; +/* Allow using resources */ +smp_store_release (&nsim_bus_enable, true);return 0 ; err_bus_unregister:
@@ -331,12 +364,16 @@ void nsim_bus_exit(void) {struct nsim_bus_dev *nsim_bus_dev, *tmp; +/* Disallow using resources */ +smp_store_release (&nsim_bus_enable, false); +mutex_lock (&nsim_bus_dev_list_lock);list_for_each_entry_safe (nsim_bus_dev, tmp, &nsim_bus_dev_list, list) {list_del (&nsim_bus_dev->list);nsim_bus_dev_del (nsim_bus_dev); }mutex_unlock (&nsim_bus_dev_list_lock); +driver_unregister (&nsim_driver);bus_unregister (&nsim_bus); }
drivers/net/netdevsim/netdevsim.h +1 -0
@@ -240,6 +240,7 @@ struct nsim_bus_dev {*/ unsigned int num_vfs;struct nsim_vf_config *vfconfigs; +bool init; };int nsim_bus_init (void );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 522/542 netdevsim: disable devlink reload when resources are being used
In reply to Sasha LevinFrom: Taehee Yoo <[email protected]>
[ Upstream commit 6ab63366e1ec4ec1900f253aa64727b4b5f4ee73 ]
devlink reload destroys resources and allocates resources again. So, when devices and ports resources are being used, devlink reload function should not be executed. In order to avoid this race, a new lock is added and new_port() and del_port() call devlink_reload_disable() and devlink_reload_enable().
Thread0 Thread1
{new/del}_port() {new/del}_port()devlink_reload_disable()
devlink_reload_disable()devlink_reload_enable()
//here
devlink_reload_enable()Before Thread1's devlink_reload_enable(), the devlink is already allowed to execute reload because Thread0 allows it. devlink reload disable/enable variable type is bool. So the above case would exist.
So, disable/enable should be executed atomically.
In order to do that, a new lock is used.
Test commands:
modprobe netdevsim
echo 1 > /sys/bus/netdevsim/new_device while :
do
echo 1 > /sys/devices/netdevsim1/new_port & echo 1 > /sys/devices/netdevsim1/del_port & devlink dev reload netdevsim/netdevsim1 &
done
Splat looks like:
[ 23.342145][ T932] DEBUG_LOCKS_WARN_ON(mutex_is_locked(lock)) [ 23.342159][ T932] WARNING: CPU: 0 PID: 932 at kernel/locking/mutex-debug.c:103 mutex_destroy+0xc7/0xf0 [ 23.344182][ T932] Modules linked in: netdevsim openvswitch nsh nf_conncount nf_nat nf_conntrack nf_defrag_ipv6 nf_dx [ 23.346485][ T932] CPU: 0 PID: 932 Comm: devlink Not tainted 5.5.0+ #322 [ 23.347696][ T932] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 [ 23.348893][ T932] RIP: 0010:mutex_destroy+0xc7/0xf0 [ 23.349505][ T932] Code: e0 07 83 c0 03 38 d0 7c 04 84 d2 75 2e 8b 05 00 ac b0 02 85 c0 75 8b 48 c7 c6 00 5e 07 96 40 [ 23.351887][ T932] RSP: 0018:ffff88806208f810 EFLAGS: 00010286 [ 23.353963][ T932] RAX: dffffc0000000008 RBX: ffff888067f6f2c0 RCX: ffffffff942c4bd4 [ 23.355222][ T932] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffffff96dac5b4 [ 23.356169][ T932] RBP: ffff888067f6f000 R08: fffffbfff2d235a5 R09: fffffbfff2d235a5 [ 23.357160][ T932] R10: 0000000000000001 R11: fffffbfff2d235a4 R12: ffff888067f6f208 [ 23.358288][ T932] R13: ffff88806208fa70 R14: ffff888067f6f000 R15: ffff888069ce3800 [ 23.359307][ T932] FS: 00007fe2a3876740(0000) GS:ffff88806c000000(0000) knlGS:0000000000000000 [ 23.360473][ T932] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 23.361319][ T932] CR2: 00005561357aa000 CR3: 000000005227a006 CR4: 00000000000606f0 [ 23.362323][ T932] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 23.363417][ T932] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 23.364414][ T932] Call Trace: [ 23.364828][ T932] nsim_dev_reload_destroy+0x77/0xb0 [netdevsim] [ 23.365655][ T932] nsim_dev_reload_down+0x84/0xb0 [netdevsim] [ 23.366433][ T932] devlink_reload+0xb1/0x350 [ 23.367010][ T932] genl_rcv_msg+0x580/0xe90
[ ...]
[ 23.531729][ T1305] kernel BUG at lib/list_debug.c:53! [ 23.532523][ T1305] invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN PTI [ 23.533467][ T1305] CPU: 2 PID: 1305 Comm: bash Tainted: G W 5.5.0+ #322 [ 23.534962][ T1305] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 [ 23.536503][ T1305] RIP: 0010:__list_del_entry_valid+0xe6/0x150 [ 23.538346][ T1305] Code: 89 ea 48 c7 c7 00 73 1e 96 e8 df f7 4c ff 0f 0b 48 c7 c7 60 73 1e 96 e8 d1 f7 4c ff 0f 0b 44 [ 23.541068][ T1305] RSP: 0018:ffff888047c27b58 EFLAGS: 00010282 [ 23.542001][ T1305] RAX: 0000000000000054 RBX: ffff888067f6f318 RCX: 0000000000000000 [ 23.543051][ T1305] RDX: 0000000000000054 RSI: 0000000000000008 RDI: ffffed1008f84f61 [ 23.544072][ T1305] RBP: ffff88804aa0fca0 R08: ffffed100d940539 R09: ffffed100d940539 [ 23.545085][ T1305] R10: 0000000000000001 R11: ffffed100d940538 R12: ffff888047c27cb0 [ 23.546422][ T1305] R13: ffff88806208b840 R14: ffffffff981976c0 R15: ffff888067f6f2c0 [ 23.547406][ T1305] FS: 00007f76c0431740(0000) GS:ffff88806c800000(0000) knlGS:0000000000000000 [ 23.548527][ T1305] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 23.549389][ T1305] CR2: 00007f5048f1a2f8 CR3: 000000004b310006 CR4: 00000000000606e0 [ 23.550636][ T1305] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 23.551578][ T1305] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 23.552597][ T1305] Call Trace: [ 23.553004][ T1305] mutex_remove_waiter+0x101/0x520 [ 23.553646][ T1305] __mutex_lock+0xac7/0x14b0 [ 23.554218][ T1305] ? nsim_dev_port_del+0x4e/0x140 [netdevsim] [ 23.554908][ T1305] ? mutex_lock_io_nested+0x1380/0x1380 [ 23.555570][ T1305] ? _parse_integer+0xf0/0xf0 [ 23.556043][ T1305] ? kstrtouint+0x86/0x110 [ 23.556504][ T1305] ? nsim_dev_port_del+0x4e/0x140 [netdevsim] [ 23.557133][ T1305] nsim_dev_port_del+0x4e/0x140 [netdevsim] [ 23.558024][ T1305] del_port_store+0xcc/0xf0 [netdevsim]
[ ... ]
--- drivers/net/netdevsim/bus.c | 19 +++++++++++++++++++ drivers/net/netdevsim/netdevsim.h | 2 ++ 2 files changed, 21 insertions(+)
drivers/net/netdevsim/bus.c +19 -0
@@ -97,6 +97,8 @@ new_port_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) {struct nsim_bus_dev *nsim_bus_dev =to_nsim_bus_dev (dev); +struct nsim_dev *nsim_dev =dev_get_drvdata (dev); +struct devlink *devlink;unsigned int port_index;int ret;
@@ -106,7 +108,14 @@ new_port_store(struct device *dev, struct device_attribute *attr, ret =kstrtouint (buf,0 , &port_index);if (ret)return ret; + + devlink =priv_to_devlink (nsim_dev); + +mutex_lock (&nsim_bus_dev->nsim_bus_reload_lock); +devlink_reload_disable (devlink); ret =nsim_dev_port_add (nsim_bus_dev, port_index); +devlink_reload_enable (devlink); +mutex_unlock (&nsim_bus_dev->nsim_bus_reload_lock);return ret ? ret : count; }
@@ -117,6 +126,8 @@ del_port_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) {struct nsim_bus_dev *nsim_bus_dev =to_nsim_bus_dev (dev); +struct nsim_dev *nsim_dev =dev_get_drvdata (dev); +struct devlink *devlink;unsigned int port_index;int ret;
@@ -126,7 +137,14 @@ del_port_store(struct device *dev, struct device_attribute *attr, ret =kstrtouint (buf,0 , &port_index);if (ret)return ret; + + devlink =priv_to_devlink (nsim_dev); + +mutex_lock (&nsim_bus_dev->nsim_bus_reload_lock); +devlink_reload_disable (devlink); ret =nsim_dev_port_del (nsim_bus_dev, port_index); +devlink_reload_enable (devlink); +mutex_unlock (&nsim_bus_dev->nsim_bus_reload_lock);return ret ? ret : count; }
@@ -311,6 +329,7 @@ nsim_bus_dev_new(unsigned int id, unsigned int port_count) nsim_bus_dev->dev.type = &nsim_bus_dev_type; nsim_bus_dev->port_count = port_count; nsim_bus_dev->initial_net = current->nsproxy->net_ns; +mutex_init (&nsim_bus_dev->nsim_bus_reload_lock);/* Disallow using nsim_bus_dev */ smp_store_release (&nsim_bus_dev->init, false);
drivers/net/netdevsim/netdevsim.h +2 -0
@@ -240,6 +240,8 @@ struct nsim_bus_dev {*/ unsigned int num_vfs;struct nsim_vf_config *vfconfigs; +/* Lock for devlink->reload_enabled in netdevsim module */ +struct mutex nsim_bus_reload_lock;bool init; };
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 523/542 netdevsim: fix panic in nsim_dev_take_snapshot_write()
In reply to Sasha LevinFrom: Taehee Yoo <[email protected]>
[ Upstream commit 8526ad9646b17c59b6d430d8baa8f152a14fe177 ]
nsim_dev_take_snapshot_write() uses nsim_dev and nsim_dev->dummy_region. So, during this function, these data shouldn't be removed. But there is no protecting stuff in this function.
There are two similar cases.
1. reload case
reload could be called during nsim_dev_take_snapshot_write(). When reload is being executed, nsim_dev_reload_down() is called and it calls nsim_dev_reload_destroy(). nsim_dev_reload_destroy() calls devlink_region_destroy() to destroy nsim_dev->dummy_region. So, during nsim_dev_take_snapshot_write(), nsim_dev->dummy_region() would be removed.
At this point, snapshot_write() would access freed pointer. In order to fix this case, take_snapshot file will be removed before devlink_region_destroy().
The take_snapshot file will be re-created by ->reload_up().
2. del_device_store casedel_device_store() also could call nsim_dev_reload_destroy() during nsim_dev_take_snapshot_write(). If so, panic would occur. This problem is actually the same problem with the first case. So, this problem will be fixed by the first case's solution.
Test commands:
modprobe netdevsim
while :
do
echo 1 > /sys/bus/netdevsim/new_device &
echo 1 > /sys/bus/netdevsim/del_device &
devlink dev reload netdevsim/netdevsim1 &
echo 1 > /sys/kernel/debug/netdevsim/netdevsim1/take_snapshot &
done
Splat looks like:
[ 45.564513][ T975] general protection fault, probably for non-canonical address 0xdffffc000000003a: 0000 [#1] SMP DEI [ 45.566131][ T975] KASAN: null-ptr-deref in range [0x00000000000001d0-0x00000000000001d7] [ 45.566135][ T975] CPU: 1 PID: 975 Comm: bash Not tainted 5.5.0+ #322 [ 45.569020][ T975] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 [ 45.569026][ T975] RIP: 0010:__mutex_lock+0x10a/0x14b0 [ 45.570518][ T975] Code: 08 84 d2 0f 85 7f 12 00 00 44 8b 0d 10 23 65 02 45 85 c9 75 29 49 8d 7f 68 48 b8 00 00 00 0f [ 45.570522][ T975] RSP: 0018:ffff888046ccfbf0 EFLAGS: 00010206 [ 45.572305][ T975] RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000000000 [ 45.572308][ T975] RDX: 000000000000003a RSI: ffffffffac926440 RDI: 00000000000001d0 [ 45.576843][ T975] RBP: ffff888046ccfd70 R08: ffffffffab610645 R09: 0000000000000000 [ 45.576847][ T975] R10: ffff888046ccfd90 R11: ffffed100d6360ad R12: 0000000000000000 [ 45.578471][ T975] R13: dffffc0000000000 R14: ffffffffae1976c0 R15: 0000000000000168 [ 45.578475][ T975] FS: 00007f614d6e7740(0000) GS:ffff88806c400000(0000) knlGS:0000000000000000 [ 45.581492][ T975] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 45.582942][ T975] CR2: 00005618677d1cf0 CR3: 000000005fb9c002 CR4: 00000000000606e0 [ 45.584543][ T975] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 45.586633][ T975] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 45.589889][ T975] Call Trace: [ 45.591445][ T975] ? devlink_region_snapshot_create+0x55/0x4a0 [ 45.601250][ T975] ? mutex_lock_io_nested+0x1380/0x1380 [ 45.602817][ T975] ? mutex_lock_io_nested+0x1380/0x1380 [ 45.603875][ T975] ? mark_held_locks+0xa5/0xe0 [ 45.604769][ T975] ? _raw_spin_unlock_irqrestore+0x2d/0x50 [ 45.606147][ T975] ? __mutex_unlock_slowpath+0xd0/0x670 [ 45.607723][ T975] ? crng_backtrack_protect+0x80/0x80 [ 45.613530][ T975] ? wait_for_completion+0x390/0x390 [ 45.615152][ T975] ? devlink_region_snapshot_create+0x55/0x4a0 [ 45.616834][ T975] devlink_region_snapshot_create+0x55/0x4a0
[ ... ]
--- drivers/net/netdevsim/dev.c | 13 +++++++++++-- drivers/net/netdevsim/netdevsim.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-)
drivers/net/netdevsim/dev.c +11 -2
@@ -88,8 +88,11 @@ static int nsim_dev_debugfs_init(struct nsim_dev *nsim_dev) &nsim_dev->max_macs);debugfs_create_bool ("test1" ,0600 , nsim_dev->ddir, &nsim_dev->test1); -debugfs_create_file ("take_snapshot" ,0200 , nsim_dev->ddir, nsim_dev, - &nsim_dev_take_snapshot_fops); + nsim_dev->take_snapshot =debugfs_create_file ("take_snapshot" , +0200 , + nsim_dev->ddir, + nsim_dev, + &nsim_dev_take_snapshot_fops);debugfs_create_bool ("dont_allow_reload" ,0600 , nsim_dev->ddir, &nsim_dev->dont_allow_reload); debugfs_create_bool("fail_reload", 0600, nsim_dev->ddir,
@@ -740,6 +743,11 @@ static int nsim_dev_reload_create(struct nsim_dev *nsim_dev,if (err) goto err_health_exit; + nsim_dev->take_snapshot =debugfs_create_file ("take_snapshot" , +0200 , + nsim_dev->ddir, + nsim_dev, + &nsim_dev_take_snapshot_fops);return 0 ; err_health_exit:
@@ -853,6 +861,7 @@ static void nsim_dev_reload_destroy(struct nsim_dev *nsim_dev)if (devlink_is_reload_failed (devlink))return ; +debugfs_remove (nsim_dev->take_snapshot);nsim_dev_port_del_all (nsim_dev);nsim_dev_health_exit (nsim_dev);nsim_dev_traps_exit (devlink);
drivers/net/netdevsim/netdevsim.h +1 -0
@@ -160,6 +160,7 @@ struct nsim_dev {struct nsim_trap_data *trap_data;struct dentry *ddir;struct dentry *ports_ddir; +struct dentry *take_snapshot;struct bpf_offload_dev *bpf_dev;bool bpf_bind_accept;u32 bpf_bind_verifier_delay;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 524/542 netdevsim: use __GFP_NOWARN to avoid memalloc warning
In reply to Sasha LevinFrom: Taehee Yoo <[email protected]>
[ Upstream commit 83cf4213bafc4e3c747f0a25ad22cfbf55af7e84 ]
vfnum buffer size and binary_len buffer size is received by user-space. So, this buffer size could be too large. If so, kmalloc will internally print a warning message.
This warning message is actually not necessary for the netdevsim module. So, this patch adds __GFP_NOWARN.
Test commands:
modprobe netdevsim
echo 1 > /sys/bus/netdevsim/new_device
echo 1000000000 > /sys/devices/netdevsim1/sriov_numvfs
Splat looks like:
[ 357.847266][ T1000] WARNING: CPU: 0 PID: 1000 at mm/page_alloc.c:4738 __alloc_pages_nodemask+0x2f3/0x740 [ 357.850273][ T1000] Modules linked in: netdevsim veth openvswitch nsh nf_conncount nf_nat nf_conntrack nf_defrx [ 357.852989][ T1000] CPU: 0 PID: 1000 Comm: bash Tainted: G B 5.5.0-rc5+ #270 [ 357.854334][ T1000] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 [ 357.855703][ T1000] RIP: 0010:__alloc_pages_nodemask+0x2f3/0x740 [ 357.856669][ T1000] Code: 64 fe ff ff 65 48 8b 04 25 c0 0f 02 00 48 05 f0 12 00 00 41 be 01 00 00 00 49 89 47 0 [ 357.860272][ T1000] RSP: 0018:ffff8880b7f47bd8 EFLAGS: 00010246 [ 357.861009][ T1000] RAX: ffffed1016fe8f80 RBX: 1ffff11016fe8fae RCX: 0000000000000000 [ 357.861843][ T1000] RDX: 0000000000000000 RSI: 0000000000000017 RDI: 0000000000000000 [ 357.862661][ T1000] RBP: 0000000000040dc0 R08: 1ffff11016fe8f67 R09: dffffc0000000000 [ 357.863509][ T1000] R10: ffff8880b7f47d68 R11: fffffbfff2798180 R12: 1ffff11016fe8f80 [ 357.864355][ T1000] R13: 0000000000000017 R14: 0000000000000017 R15: ffff8880c2038d68 [ 357.865178][ T1000] FS: 00007fd9a5b8c740(0000) GS:ffff8880d9c00000(0000) knlGS:0000000000000000 [ 357.866248][ T1000] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 357.867531][ T1000] CR2: 000055ce01ba8100 CR3: 00000000b7dbe005 CR4: 00000000000606f0 [ 357.868972][ T1000] Call Trace: [ 357.869423][ T1000] ? lock_contended+0xcd0/0xcd0 [ 357.870001][ T1000] ? __alloc_pages_slowpath+0x21d0/0x21d0 [ 357.870673][ T1000] ? _kstrtoull+0x76/0x160 [ 357.871148][ T1000] ? alloc_pages_current+0xc1/0x1a0 [ 357.871704][ T1000] kmalloc_order+0x22/0x80 [ 357.872184][ T1000] kmalloc_order_trace+0x1d/0x140 [ 357.872733][ T1000] __kmalloc+0x302/0x3a0 [ 357.873204][ T1000] nsim_bus_dev_numvfs_store+0x1ab/0x260 [netdevsim] [ 357.873919][ T1000] ? kernfs_get_active+0x12c/0x180 [ 357.874459][ T1000] ? new_device_store+0x450/0x450 [netdevsim] [ 357.875111][ T1000] ? kernfs_get_parent+0x70/0x70 [ 357.875632][ T1000] ? sysfs_file_ops+0x160/0x160 [ 357.876152][ T1000] kernfs_fop_write+0x276/0x410 [ 357.876680][ T1000] ? __sb_start_write+0x1ba/0x2e0 [ 357.877225][ T1000] vfs_write+0x197/0x4a0 [ 357.877671][ T1000] ksys_write+0x141/0x1d0
[ ... ]
--- drivers/net/netdevsim/bus.c | 2 +- drivers/net/netdevsim/health.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/netdevsim/bus.c +1 -1
@@ -29,7 +29,7 @@ static int nsim_bus_dev_vfs_enable(struct nsim_bus_dev *nsim_bus_dev, { nsim_bus_dev->vfconfigs =kcalloc (num_vfs,sizeof (struct nsim_vf_config ), -GFP_KERNEL ); +GFP_KERNEL | __GFP_NOWARN);if (!nsim_bus_dev->vfconfigs)return -ENOMEM ; nsim_bus_dev->num_vfs = num_vfs;
drivers/net/netdevsim/health.c +1 -1
@@ -82,7 +82,7 @@ static int nsim_dev_dummy_fmsg_put(struct devlink_fmsg *fmsg, u32 binary_len)if (err)return err; - binary =kmalloc (binary_len,GFP_KERNEL ); + binary =kmalloc (binary_len,GFP_KERNEL | __GFP_NOWARN);if (!binary)return -ENOMEM ;get_random_bytes (binary, binary_len);
Signature · 1 line
2.20.1
Jakub Kicinski
maintainerRe: [PATCH AUTOSEL 5.5 524/542] netdevsim: use __GFP_NOWARN to avoid memalloc warning
Quoted 7 lines · On Fri, 14 Feb 2020 10:48:36 -0500 Sasha Levin wrote:
From: Taehee Yoo <[email protected]>
[ Upstream commit
83cf4213bafc4e3c747f0a25ad22cfbf55af7e84]vfnum buffer size and
binary_lenbuffer size is received by user-space. So, this buffer size could be too large. If so, kmalloc will internally print a warning message.
Curious to see, I'm pretty sure Greg queued this yesterday.
Sasha Levin
maintainerPATCH 525/542 asm-generic/tlb: add missing CONFIG symbol
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 27796d03c9c4b2b937ed4cc2b10f21559ad5a8c9 ]
Without this the symbol will not actually end up in .config files.
--- arch/Kconfig | 3 +++ 1 file changed, 3 insertions(+)
arch/Kconfig +3 -0
@@ -399,6 +399,9 @@ config HAVE_RCU_TABLE_FREE config HAVE_MMU_GATHER_PAGE_SIZE bool +config MMU_GATHER_NO_RANGE + bool + config HAVE_MMU_GATHER_NO_GATHER bool
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 526/542 tc-testing: add missing 'nsPlugin' to basic.json
In reply to Sasha LevinFrom: Davide Caratti <[email protected]>
[ Upstream commit e9ed4fa7b4400d7b2cf03108842a30e6c9bd0eb2 ]
since tdc tests for cls_basic need $DEV1, use 'nsPlugin' so that the following command can be run without errors:
[root@f31 tc-testing]# ./tdc.py -c basic
--- .../tc-testing/tc-tests/filters/basic.json | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+)
tools/testing/selftests/tc-testing/tc-tests/filters/basic.json +51 -0
@@ -6,6 +6,9 @@ "filter", "basic" ], + "plugins": { + "requires": "nsPlugin" + }, "setup": [ "$TC qdisc add dev $DEV1 ingress" ],
@@ -25,6 +28,9 @@ "filter", "basic" ], + "plugins": { + "requires": "nsPlugin" + }, "setup": [ "$TC qdisc add dev $DEV1 ingress" ],
@@ -44,6 +50,9 @@ "filter", "basic" ], + "plugins": { + "requires": "nsPlugin" + }, "setup": [ "$TC qdisc add dev $DEV1 ingress" ],
@@ -63,6 +72,9 @@ "filter", "basic" ], + "plugins": { + "requires": "nsPlugin" + }, "setup": [ "$TC qdisc add dev $DEV1 ingress" ],
@@ -82,6 +94,9 @@ "filter", "basic" ], + "plugins": { + "requires": "nsPlugin" + }, "setup": [ "$TC qdisc add dev $DEV1 ingress" ],
@@ -101,6 +116,9 @@ "filter", "basic" ], + "plugins": { + "requires": "nsPlugin" + }, "setup": [ "$TC qdisc add dev $DEV1 ingress" ],
@@ -120,6 +138,9 @@ "filter", "basic" ], + "plugins": { + "requires": "nsPlugin" + }, "setup": [ "$TC qdisc add dev $DEV1 ingress" ],
@@ -139,6 +160,9 @@ "filter", "basic" ], + "plugins": { + "requires": "nsPlugin" + }, "setup": [ "$TC qdisc add dev $DEV1 ingress" ],
@@ -158,6 +182,9 @@ "filter", "basic" ], + "plugins": { + "requires": "nsPlugin" + }, "setup": [ "$TC qdisc add dev $DEV1 ingress" ],
@@ -177,6 +204,9 @@ "filter", "basic" ], + "plugins": { + "requires": "nsPlugin" + }, "setup": [ "$TC qdisc add dev $DEV1 ingress" ],
@@ -196,6 +226,9 @@ "filter", "basic" ], + "plugins": { + "requires": "nsPlugin" + }, "setup": [ "$TC qdisc add dev $DEV1 ingress" ],
@@ -215,6 +248,9 @@ "filter", "basic" ], + "plugins": { + "requires": "nsPlugin" + }, "setup": [ "$TC qdisc add dev $DEV1 ingress" ],
@@ -234,6 +270,9 @@ "filter", "basic" ], + "plugins": { + "requires": "nsPlugin" + }, "setup": [ "$TC qdisc add dev $DEV1 ingress" ],
@@ -253,6 +292,9 @@ "filter", "basic" ], + "plugins": { + "requires": "nsPlugin" + }, "setup": [ "$TC qdisc add dev $DEV1 ingress" ],
@@ -272,6 +314,9 @@ "filter", "basic" ], + "plugins": { + "requires": "nsPlugin" + }, "setup": [ "$TC qdisc add dev $DEV1 ingress" ],
@@ -291,6 +336,9 @@ "filter", "basic" ], + "plugins": { + "requires": "nsPlugin" + }, "setup": [ "$TC qdisc add dev $DEV1 ingress" ],
@@ -310,6 +358,9 @@ "filter", "basic" ], + "plugins": { + "requires": "nsPlugin" + }, "setup": [ "$TC qdisc add dev $DEV1 ingress" ],
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 527/542 microblaze: Prevent the overflow of the start
In reply to Sasha LevinFrom: Shubhrajyoti Datta <[email protected]>
[ Upstream commit 061d2c1d593076424c910cb1b64ecdb5c9a6923f ]
In case the start + cache size is more than the max int the start overflows.
Prevent the same.
--- arch/microblaze/kernel/cpu/cache.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/microblaze/kernel/cpu/cache.c +2 -1
@@ -92,7 +92,8 @@ static inline void __disable_dcache_nomsr(void)#define CACHE_LOOP_LIMITS (start, end, cache_line_length, cache_size) \ do { \ int align = ~(cache_line_length - 1); \ - end = min(start + cache_size, end); \ + if (start < UINT_MAX - cache_size) \ + end = min(start + cache_size, end); \ start &= align; \ } while (0)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 528/542 brd: check and limit max_part par
In reply to Sasha LevinFrom: Zhiqiang Liu <[email protected]>
[ Upstream commit c8ab422553c81a0eb070329c63725df1cd1425bc ]
In brd_init func, rd_nr num of brd_device are firstly allocated and add in brd_devices, then brd_devices are traversed to add each brd_device by calling add_disk func. When allocating brd_device, the disk->first_minor is set to i * max_part, if rd_nr * max_part is larger than MINORMASK, two different brd_device may have the same devt, then only one of them can be successfully added. when rmmod brd.ko, it will cause oops when calling brd_exit.
Follow those steps:
# modprobe brd rd_nr=3 rd_size=102400 max_part=1048576 # rmmod brd then, the oops will appear.
Oops log:
[ 726.613722] Call trace: [ 726.614175] kernfs_find_ns+0x24/0x130 [ 726.614852] kernfs_find_and_get_ns+0x44/0x68 [ 726.615749] sysfs_remove_group+0x38/0xb0 [ 726.616520] blk_trace_remove_sysfs+0x1c/0x28 [ 726.617320] blk_unregister_queue+0x98/0x100 [ 726.618105] del_gendisk+0x144/0x2b8 [ 726.618759] brd_exit+0x68/0x560 [brd] [ 726.619501] __arm64_sys_delete_module+0x19c/0x2a0 [ 726.620384] el0_svc_common+0x78/0x130 [ 726.621057] el0_svc_handler+0x38/0x78 [ 726.621738] el0_svc+0x8/0xc [ 726.622259] Code: aa0203f6 aa0103f7 aa1e03e0 d503201f (7940e260)
Here, we add brd_check_and_reset_par func to check and limit max_part par.
--V5->V6:
- remove useless code
V4->V5:(suggested by Ming Lei)
- make sure max_part is not larger than DISK_MAX_PARTS
V3->V4:(suggested by Ming Lei)
- remove useless change
- add one limit of max_part
V2->V3: (suggested by Ming Lei)
- clear .minors when running out of consecutive minor space in brd_alloc
- remove limit of rd_nr
V1->V2:
- add more checks in brd_check_par_valid as suggested by Ming Lei.
--- drivers/block/brd.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
drivers/block/brd.c +20 -2
@@ -473,6 +473,25 @@ static struct kobject *brd_probe(dev_t dev, int *part, void *data)return kobj; } +static inline void brd_check_and_reset_par (void ) +{ +if (unlikely (!max_part)) + max_part =1 ; + +/* +* make sure 'max_part' can be divided exactly by (1U << MINORBITS), +* otherwise, it is possiable to get same dev_t when adding partitions. +*/ +if ((1U <<MINORBITS ) % max_part !=0 ) + max_part =1UL <<fls (max_part); + +if (max_part >DISK_MAX_PARTS ) { +pr_info ("brd: max_part can't be larger than %d, reset max_part = %d.\n" , +DISK_MAX_PARTS ,DISK_MAX_PARTS ); + max_part =DISK_MAX_PARTS ; + } +} +static int __init brd_init (void ) {struct brd_device *brd, *next;
@@ -496,8 +515,7 @@ static int __init brd_init(void)if (register_blkdev (RAMDISK_MAJOR ,"ramdisk" ))return -EIO ; -if (unlikely (!max_part)) - max_part =1 ; +brd_check_and_reset_par ();for (i =0 ; i < rd_nr; i++) { brd =brd_alloc (i);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 529/542 drm/amdgpu/smu10: fix smu10_get_clock_by_type_with_latency
In reply to Sasha LevinFrom: Alex Deucher <[email protected]>
[ Upstream commit 4d0a72b66065dd7e274bad6aa450196d42fd8f84 ]
Only send non-0 clocks to DC for validation. This mirrors what the windows driver does.
--- drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c +9 -6
@@ -1026,12 +1026,15 @@ static int smu10_get_clock_by_type_with_latency(struct pp_hwmgr *hwmgr, clocks->num_levels =0 ;for (i =0 ; i < pclk_vol_table->count; i++) { - clocks->data[i].clocks_in_khz = pclk_vol_table->entries[i].clk *10 ; - clocks->data[i].latency_in_us = latency_required ? -smu10_get_mem_latency (hwmgr, - pclk_vol_table->entries[i].clk) : -0 ; - clocks->num_levels++; +if (pclk_vol_table->entries[i].clk) { + clocks->data[clocks->num_levels].clocks_in_khz = + pclk_vol_table->entries[i].clk *10 ; + clocks->data[clocks->num_levels].latency_in_us = latency_required ? +smu10_get_mem_latency (hwmgr, + pclk_vol_table->entries[i].clk) : +0 ; + clocks->num_levels++; + } }return 0 ;
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Sasha Levin
maintainerPATCH 530/542 drm/amdgpu/smu10: fix smu10_get_clock_by_type_with_voltage
In reply to Sasha LevinFrom: Alex Deucher <[email protected]>
[ Upstream commit 1064ad4aeef94f51ca230ac639a9e996fb7867a0 ]
Cull out 0 clocks to avoid a warning in DC.
--- drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c +5 -3
@@ -1080,9 +1080,11 @@ static int smu10_get_clock_by_type_with_voltage(struct pp_hwmgr *hwmgr, clocks->num_levels =0 ;for (i =0 ; i < pclk_vol_table->count; i++) { - clocks->data[i].clocks_in_khz = pclk_vol_table->entries[i].clk *10 ; - clocks->data[i].voltage_in_mv = pclk_vol_table->entries[i].vol; - clocks->num_levels++; +if (pclk_vol_table->entries[i].clk) { + clocks->data[clocks->num_levels].clocks_in_khz = pclk_vol_table->entries[i].clk *10 ; + clocks->data[clocks->num_levels].voltage_in_mv = pclk_vol_table->entries[i].vol; + clocks->num_levels++; + } }return 0 ;
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH AUTOSEL 5.5 530/542] drm/amdgpu/smu10: fix smu10_get_clock_by_type_with_voltage
Quoted 8 lines · Sasha Levin
From: Alex Deucher <[email protected]>
[ Upstream commit
1064ad4aeef94f51ca230ac639a9e996fb7867a0]Cull out 0 clocks to avoid a warning in DC.
All of the upstream commits that reference this bug need to be applied or this patch set will be broken. Please either apply them all or drop them.
Alex
Quoted 29 lines
Reviewed-by Evan Quan <[email protected]>Signed-off-by Alex Deucher <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c +5
-4@@ -1080,9 +1080,11 @@ static int smu10_get_clock_by_type_with_voltage(struct pp_hwmgr *hwmgr, clocks->num_levels =0 ;for (i =0 ; i < pclk_vol_table->count; i++) { - clocks->data[i].clocks_in_khz = pclk_vol_table->entries[i].clk *10 ; - clocks->data[i].voltage_in_mv = pclk_vol_table->entries[i].vol; - clocks->num_levels++; +if (pclk_vol_table->entries[i].clk) { + clocks->data[clocks->num_levels].clocks_in_khz = pclk_vol_table->entries[i].clk *10 ; + clocks->data[clocks->num_levels].voltage_in_mv = pclk_vol_table->entries[i].vol; + clocks->num_levels++; + } }return 0 ; --2.20.1
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Sasha Levin
maintainerRe: [PATCH AUTOSEL 5.5 530/542] drm/amdgpu/smu10: fix smu10_get_clock_by_type_with_voltage
Quoted 6 lines · Alex Deucher
Quoted 5 lines · Sasha Levin
From: Alex Deucher <[email protected]>
[ Upstream commit
1064ad4aeef94f51ca230ac639a9e996fb7867a0]
Quoted 7 lines
Quoted 3 lines
Cull out 0 clocks to avoid a warning in DC.
All of the upstream commits that reference this bug need to be applied or this patch set will be broken. Please either apply them all or drop them.
Okay, so I have these 3 in 4.19-5.5:
c37243579d6c ("drm/amdgpu/display: handle multiple numbers of fclks in dcn_calcs.c (v2)") 4d0a72b66065 ("drm/amdgpu/smu10: fix smu10_get_clock_by_type_with_latency") 1064ad4aeef9 ("drm/amdgpu/smu10: fix smu10_get_clock_by_type_with_voltage"
Signature · 2 lines
Thanks, Sasha
Re: [PATCH AUTOSEL 5.5 530/542] drm/amdgpu/smu10: fix smu10_get_clock_by_type_with_voltage
Quoted 16 lines · Sasha Levin
Quoted 6 lines · Alex Deucher
Quoted 5 lines · Sasha Levin
From: Alex Deucher <[email protected]>
[ Upstream commit
1064ad4aeef94f51ca230ac639a9e996fb7867a0]Quoted 7 lines
Quoted 3 lines
Cull out 0 clocks to avoid a warning in DC.
All of the upstream commits that reference this bug need to be applied or this patch set will be broken. Please either apply them all or drop them.
Quoted 5 lines
Okay, so I have these 3 in 4.19-5.5:
c37243579d6c("drm/amdgpu/display: handle multiple numbers of fclks indcn_calcs.c(v2)")4d0a72b66065("drm/amdgpu/smu10: fixsmu10_get_clock_by_type_with_latency")1064ad4aeef9("drm/amdgpu/smu10: fixsmu10_get_clock_by_type_with_voltage"
Yes, that should do it. Thanks!
Alex
Quoted 4 lines
--
Thanks,
Sasha
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Sasha Levin
maintainerPATCH 531/542 NFS: Fix memory leaks
In reply to Sasha LevinFrom: Wenwen Wang <[email protected]>
[ Upstream commit 123c23c6a7b7ecd2a3d6060bea1d94019f71fd66 ]
In _nfs42_proc_copy(), 'res->commit_res.verf' is allocated through kzalloc() if 'args->sync' is true. In the following code, if 'res->synchronous' is false, handle_async_copy() will be invoked. If an error occurs during the invocation, the following code will not be executed and the error will be returned . However, the allocated 'res->commit_res.verf' is not deallocated, leading to a memory leak. This is also true if the invocation of process_copy_commit() returns an error.
To fix the above leaks, redirect the execution to the 'out' label if an error is encountered.
--- fs/nfs/nfs42proc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfs42proc.c +2 -2
@@ -343,14 +343,14 @@ static ssize_t _nfs42_proc_copy(struct file *src, status =handle_async_copy (res, dst_server, src_server, src, dst, &args->src_stateid, restart);if (status) -return status; + goto out; }if ((!res->synchronous || !args->sync) && res->write_res.verifier.committed !=NFS_FILE_SYNC ) { status =process_copy_commit (dst, pos_dst, res);if (status) -return status; + goto out; } truncate_pagecache_range(dst_inode, pos_dst,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 532/542 NFSv4: try lease recovery on NFS4ERR_EXPIRED
In reply to Sasha LevinFrom: Robert Milkowski <[email protected]>
[ Upstream commit 924491f2e476f7234d722b24171a4daff61bbe13 ]
Currently, if an nfs server returns NFS4ERR_EXPIRED to open(), we return EIO to applications without even trying to recover.
--- fs/nfs/nfs4proc.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/nfs/nfs4proc.c +5 -0
@@ -3187,6 +3187,11 @@ static struct nfs4_state *nfs4_do_open(struct inode *dir, exception.retry =1 ;continue ; } +if (status == -NFS4ERR_EXPIRED ) { +nfs4_schedule_lease_recovery (server->nfs_client); + exception.retry =1 ; +continue ; + }if (status == -EAGAIN ) {/* We must have found a delegation */ exception.retry =1 ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 533/542 NFSv4.0: nfs4_do_fsinfo() should not do implicit lease renewals
In reply to Sasha LevinFrom: Robert Milkowski <[email protected]>
[ Upstream commit 7dc2993a9e51dd2eee955944efec65bef90265b7 ]
Currently, each time nfs4_do_fsinfo() is called it will do an implicit NFS4 lease renewal, which is not compliant with the NFS4 specification. This can result in a lease being expired by an NFS server.
Commit 83ca7f5ab31f ("NFS: Avoid PUTROOTFH when managing leases") introduced implicit client lease renewal in nfs4_do_fsinfo(), which can result in the NFSv4.0 lease to expire on a server side, and servers returning NFS4ERR_EXPIRED or NFS4ERR_STALE_CLIENTID.
This can easily be reproduced by frequently unmounting a sub-mount, then stat'ing it to get it mounted again, which will delay or even completely prevent client from sending RENEW operations if no other NFS operations are issued. Eventually nfs server will expire client's lease and return an error on file access or next RENEW.
This can also happen when a sub-mount is automatically unmounted due to inactivity (after nfs_mountpoint_expiry_timeout), then it is mounted again via stat(). This can result in a short window during which client's lease will expire on a server but not on a client. This specific case was observed on production systems.
This patch removes the implicit lease renewal from nfs4_do_fsinfo().
--- fs/nfs/nfs4_fs.h | 4 +--- fs/nfs/nfs4proc.c | 12 ++++++++---- fs/nfs/nfs4renewd.c | 5 +---- fs/nfs/nfs4state.c | 4 +--- 4 files changed, 11 insertions(+), 14 deletions(-)
fs/nfs/nfs4_fs.h +1 -3
@@ -446,9 +446,7 @@ extern void nfs4_schedule_state_renewal(struct nfs_client *);extern void nfs4_renewd_prepare_shutdown (struct nfs_server *);extern void nfs4_kill_renewd (struct nfs_client *);extern void nfs4_renew_state (struct work_struct *); -extern void nfs4_set_lease_period (struct nfs_client *clp, -unsigned long lease, -unsigned long lastrenewed); +extern void nfs4_set_lease_period (struct nfs_client *clp,unsigned long lease);/* nfs4state.c */
fs/nfs/nfs4proc.c +8 -4
@@ -5026,16 +5026,13 @@ static int nfs4_do_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle, strstruct nfs4_exception exception = { .interruptible = true, }; -unsigned long now = jiffies;int err; do { err = _nfs4_do_fsinfo(server, fhandle, fsinfo); trace_nfs4_fsinfo(server, fhandle, fsinfo->fattr, err); if (err == 0) { - nfs4_set_lease_period(server->nfs_client, - fsinfo->lease_time * HZ, - now); + nfs4_set_lease_period(server->nfs_client, fsinfo->lease_time * HZ); break; } err = nfs4_handle_exception(server, err, &exception);
@@ -6091,6 +6088,7 @@ int nfs4_proc_setclientid(struct nfs_client *clp, u32 program, .callback_data = &setclientid, .flags = RPC_TASK_TIMEOUT | RPC_TASK_NO_ROUND_ROBIN, }; +unsigned long now = jiffies;int status;/* nfs_client_id4 */
@@ -6123,6 +6121,9 @@ int nfs4_proc_setclientid(struct nfs_client *clp, u32 program, clp->cl_acceptor =rpcauth_stringify_acceptor (setclientid.sc_cred);put_rpccred (setclientid.sc_cred); } + +if (status ==0 ) +do_renew_lease (clp, now); out:trace_nfs4_setclientid (clp, status);dprintk ("NFS reply setclientid: %d\n" , status);
@@ -8210,6 +8211,7 @@ static int _nfs4_proc_exchange_id(struct nfs_client *clp, const struct cred *crestruct rpc_task *task;struct nfs41_exchange_id_args *argp;struct nfs41_exchange_id_res *resp; +unsigned long now = jiffies;int status; task =nfs4_run_exchange_id (clp, cred, sp4_how,NULL );
@@ -8230,6 +8232,8 @@ static int _nfs4_proc_exchange_id(struct nfs_client *clp, const struct cred *creif (status !=0 ) goto out; +do_renew_lease (clp, now); + clp->cl_clientid = resp->clientid; clp->cl_exchange_flags = resp->flags; clp->cl_seqid = resp->seqid;
fs/nfs/nfs4renewd.c +1 -4
@@ -138,15 +138,12 @@ nfs4_kill_renewd(struct nfs_client *clp)* * @clp: pointer to nfs_client * @lease: new value for lease period -* @lastrenewed: time at which lease was last renewed */ void nfs4_set_lease_period (struct nfs_client *clp, -unsigned long lease, -unsigned long lastrenewed) +unsigned long lease) {spin_lock (&clp->cl_lock); clp->cl_lease_time = lease; - clp->cl_last_renewal = lastrenewed;spin_unlock (&clp->cl_lock);/* Cap maximum reconnect timeout at 1/2 lease period */
fs/nfs/nfs4state.c +1 -3
@@ -92,17 +92,15 @@ static int nfs4_setup_state_renewal(struct nfs_client *clp) {int status;struct nfs_fsinfo fsinfo; -unsigned long now;if (!test_bit (NFS_CS_CHECK_LEASE_TIME , &clp->cl_res_state)) {nfs4_schedule_state_renewal (clp);return 0 ; } - now = jiffies; status =nfs4_proc_get_lease_time (clp, &fsinfo);if (status ==0 ) { -nfs4_set_lease_period (clp, fsinfo.lease_time *HZ , now); +nfs4_set_lease_period (clp, fsinfo.lease_time *HZ );nfs4_schedule_state_renewal (clp); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 534/542 help_next should increase position index
In reply to Sasha LevinFrom: Vasily Averin <[email protected]>
[ Upstream commit 9f198a2ac543eaaf47be275531ad5cbd50db3edf ]
if seq_file .next fuction does not change position index, read after some lseek can generate unexpected output.
https://bugzilla.kernel.org/show_bug.cgi?id=206283
--- fs/orangefs/orangefs-debugfs.c | 1 + 1 file changed, 1 insertion(+)
fs/orangefs/orangefs-debugfs.c +1 -0
@@ -273,6 +273,7 @@ static void *help_start(struct seq_file *m, loff_t *pos)static void *help_next (struct seq_file *m,void *v,loff_t *pos) { + (*pos)++;gossip_debug (GOSSIP_DEBUGFS_DEBUG ,"help_next: start\n" );return NULL ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 535/542 i40e: Relax i40e_xsk_wakeup's return value when PF is busy
In reply to Sasha LevinFrom: Maciej Fijalkowski <[email protected]>
[ Upstream commit c77e9f09143822623dd71a0fdc84331129e97c3a ]
Return -EAGAIN instead of -ENETDOWN to provide a slightly milder information to user space so that an application will know to retry the syscall when __I40E_CONFIG_BUSY bit is set on pf->state.
--- drivers/net/ethernet/intel/i40e/i40e_xsk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_xsk.c +1 -1
@@ -791,7 +791,7 @@ int i40e_xsk_wakeup(struct net_device *dev, u32 queue_id, u32 flags)struct i40e_ring *ring;if (test_bit (__I40E_CONFIG_BUSY, pf->state)) -return -ENETDOWN ; +return -EAGAIN ;if (test_bit (__I40E_VSI_DOWN, vsi->state))return -ENETDOWN ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 536/542 kbuild: make multiple directory targets work
In reply to Sasha LevinFrom: Masahiro Yamada <[email protected]>
[ Upstream commit f566e1fbadb686e28f1c307e356114b2865ef588 ]
Currently, the single-target build does not work when two or more sub-directories are given:
$ make fs/ kernel/ lib/
CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
DESCEND objtool
make[2]: Nothing to be done for 'kernel/'.
make[2]: Nothing to be done for 'fs/'.
make[2]: Nothing to be done for 'lib/'.Make it work properly.
--- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
@@ -1691,7 +1691,7 @@ PHONY += descend $(build-dirs) descend: $(build-dirs) $(build-dirs): prepare $(Q)$(MAKE) $(build)=$@ \ - single-build=$(if $(filter-out $@/, $(single-no-ko)),1) \ + single-build=$(if $(filter-out $@/, $(filter $@/%, $(single-no-ko))),1) \ need-builtin=1 need-modorder=1 clean-dirs := $(addprefix _clean_, $(clean-dirs))
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 537/542 cifs: log warning message (once) if out of disk space
In reply to Sasha LevinFrom: Steve French <[email protected]>
[ Upstream commit d6fd41905ec577851734623fb905b1763801f5ef ]
We ran into a confusing problem where an application wasn't checking return code on close and so user didn't realize that the application ran out of disk space. log a warning message (once) in these cases. For example:
[ 8407.391909] Out of space writing to \\oleg-server\small-share
--- fs/cifs/smb2pdu.c | 3 +++ 1 file changed, 3 insertions(+)
fs/cifs/smb2pdu.c +3 -0
@@ -4029,6 +4029,9 @@ smb2_writev_callback(struct mid_q_entry *mid) wdata->cfile->fid.persistent_fid, tcon->tid, tcon->ses->Suid, wdata->offset, wdata->bytes, wdata->result); +if (wdata->result == -ENOSPC ) +printk_once (KERN_WARNING "Out of space writing to %s\n" , + tcon->treeName); }else trace_smb3_write_done(0 /* no xid */, wdata->cfile->fid.persistent_fid,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 538/542 virtio_balloon: prevent pfn array overflow
In reply to Sasha LevinFrom: "Michael S. Tsirkin" <[email protected]>
[ Upstream commit 6e9826e77249355c09db6ba41cd3f84e89f4b614 ]
Make sure, at build time, that pfn array is big enough to hold a single page. It happens to be true since the PAGE_SHIFT value at the moment is 20, which is 1M - exactly 256 4K balloon pages.
--- drivers/virtio/virtio_balloon.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/virtio/virtio_balloon.c +2 -0
@@ -158,6 +158,8 @@ static void set_page_pfns(struct virtio_balloon *vb, {unsigned int i; +BUILD_BUG_ON (VIRTIO_BALLOON_PAGES_PER_PAGE >VIRTIO_BALLOON_ARRAY_PFNS_MAX ); +/* * Set balloon pfns pointing at this page. * Note that the first pfn points at start of the page.
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 539/542 fuse: don't overflow LLONG_MAX with end offset
In reply to Sasha LevinFrom: Miklos Szeredi <[email protected]>
[ Upstream commit 2f1398291bf35fe027914ae7a9610d8e601fbfde ]
Handle the special case of fuse_readpages() wanting to read the last page of a hugest file possible and overflowing the end offset in the process.
This is basically to unbreak xfstests:generic/525 and prevent filesystems from doing bad things with an overflowing offset.
--- fs/fuse/file.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
fs/fuse/file.c +12 -0
@@ -803,6 +803,10 @@ static int fuse_do_readpage(struct file *file, struct page *page) attr_ver =fuse_get_attr_version (fc); +/* Don't overflow end offset */ +if (pos + (desc.length -1 ) ==LLONG_MAX ) + desc.length--; +fuse_read_args_fill (&ia, file, pos, desc.length,FUSE_READ ); res =fuse_simple_request (fc, &ia.ap.args);if (res <0 )
@@ -888,6 +892,14 @@ static void fuse_send_readpages(struct fuse_io_args *ia, struct file *file) ap->args.out_pages = true; ap->args.page_zeroing = true; ap->args.page_replace = true; + +/* Don't overflow end offset */ +if (pos + (count -1 ) ==LLONG_MAX ) { + count--; + ap->descs[ap->num_pages -1 ].length--; + } +WARN_ON ((loff_t) (pos + count) <0 ); +fuse_read_args_fill (ia, file, pos, count,FUSE_READ ); ia->read.attr_ver =fuse_get_attr_version (fc);if (fc->async_read) {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 540/542 mlxsw: core: Add validation of hardware device types for MGPIR register
In reply to Sasha LevinFrom: Vadim Pasternak <[email protected]>
[ Upstream commit 36844c855b896f90bab51ccecf72940eb7e3cfe1 ]
When reading the number of gearboxes from the hardware, the driver does not validate the returned 'device type' field. The driver can therefore wrongly assume that the queried devices are gearboxes.
On Spectrum-3 systems that support different types of devices, this can prevent the driver from loading, as it will try to query the temperature sensors from devices which it assumes are gearboxes and in fact are not.
For example:
[ 218.129230] mlxsw_minimal 2-0048: Reg cmd access status failed (status=7(bad parameter)) [ 218.138282] mlxsw_minimal 2-0048: Reg cmd access failed (reg_id=900a(mtmp),type=write) [ 218.147131] mlxsw_minimal 2-0048: Failed to setup temp sensor number 256 [ 218.534480] mlxsw_minimal 2-0048: Fail to register core bus [ 218.540714] mlxsw_minimal: probe of 2-0048 failed with error -5
Fix this by validating the 'device type' field.
--- drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c | 6 ++++-- drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +4 -2
@@ -573,6 +573,7 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon)static int mlxsw_hwmon_gearbox_init (struct mlxsw_hwmon *mlxsw_hwmon) { +enum mlxsw_reg_mgpir_device_type device_type;int index, max_index, sensor_index;char mgpir_pl[MLXSW_REG_MGPIR_LEN ];char mtmp_pl[MLXSW_REG_MTMP_LEN ];
@@ -584,8 +585,9 @@ static int mlxsw_hwmon_gearbox_init(struct mlxsw_hwmon *mlxsw_hwmon)if (err)return err; -mlxsw_reg_mgpir_unpack (mgpir_pl, &gbox_num,NULL ,NULL ,NULL ); -if (!gbox_num) +mlxsw_reg_mgpir_unpack (mgpir_pl, &gbox_num, &device_type,NULL ,NULL ); +if (device_type !=MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE || + !gbox_num)return 0 ; index = mlxsw_hwmon->module_sensor_max;
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +6 -2
@@ -895,8 +895,10 @@ static int mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core, struct mlxsw_thermal *thermal) { + enum mlxsw_reg_mgpir_device_type device_type;struct mlxsw_thermal_module *gearbox_tz;char mgpir_pl[MLXSW_REG_MGPIR_LEN ]; +u8 gbox_num;int i;int err;
@@ -908,11 +910,13 @@ mlxsw_thermal_gearboxes_init(struct device *dev, struct mlxsw_core *core,if (err)return err; -mlxsw_reg_mgpir_unpack (mgpir_pl, &thermal->tz_gearbox_num,NULL ,NULL , +mlxsw_reg_mgpir_unpack (mgpir_pl, &gbox_num, &device_type,NULL ,NULL ); -if (!thermal->tz_gearbox_num) +if (device_type !=MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE || + !gbox_num)return 0 ; + thermal->tz_gearbox_num = gbox_num; thermal->tz_gearbox_arr =kcalloc (thermal->tz_gearbox_num,sizeof (*thermal->tz_gearbox_arr),GFP_KERNEL );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 541/542 mlxsw: spectrum_dpipe: Add missing error path
In reply to Sasha LevinFrom: Ido Schimmel <[email protected]>
[ Upstream commit 3a99cbb6fa7bca1995586ec2dc21b0368aad4937 ]
In case devlink_dpipe_entry_ctx_prepare() failed, release RTNL that was previously taken and free the memory allocated by mlxsw_sp_erif_entry_prepare().
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c +2 -1
@@ -215,7 +215,7 @@ mlxsw_sp_dpipe_table_erif_entries_dump(void *priv, bool counters_enabled, start_again: err =devlink_dpipe_entry_ctx_prepare (dump_ctx);if (err) -return err; + goto err_ctx_prepare; j =0 ;for (; i < rif_count; i++) {struct mlxsw_sp_rif *rif =mlxsw_sp_rif_by_index (mlxsw_sp, i);
@@ -247,6 +247,7 @@ mlxsw_sp_dpipe_table_erif_entries_dump(void *priv, bool counters_enabled,return 0 ; err_entry_append: err_entry_get: +err_ctx_prepare:rtnl_unlock ();devlink_dpipe_entry_clear (&entry);return err;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 542/542 pipe: use exclusive waits when reading or writing
In reply to Sasha LevinFrom: Linus Torvalds <[email protected]>
[ Upstream commit 0ddad21d3e99c743a3aa473121dc5561679e26bb ]
This makes the pipe code use separate wait-queues and exclusive waiting for readers and writers, avoiding a nasty thundering herd problem when there are lots of readers waiting for data on a pipe (or, less commonly, lots of writers waiting for a pipe to have space).
While this isn't a common occurrence in the traditional "use a pipe as a data transport" case, where you typically only have a single reader and a single writer process, there is one common special case: using a pipe as a source of "locking tokens" rather than for data communication.
In particular, the GNU make jobserver code ends up using a pipe as a way to limit parallelism, where each job consumes a token by reading a byte from the jobserver pipe, and releases the token by writing a byte back to the pipe.
This pattern is fairly traditional on Unix, and works very well, but will waste a lot of time waking up a lot of processes when only a single reader needs to be woken up when a writer releases a new token.
A simplified test-case of just this pipe interaction is to create 64 processes, and then pass a single token around between them (this test-case also intentionally passes another token that gets ignored to test the "wake up next" logic too, in case anybody wonders about it):
#include <unistd.h>
int main(int argc, char **argv)
{
int fd[2], counters[2];
pipe(fd);
counters[0] = 0;
counters[1] = -1;
write(fd[1], counters, sizeof(counters));
/* 64 processes */
fork(); fork(); fork(); fork(); fork(); fork();
do {
int i;
read(fd[0], &i, sizeof(i));
if (i < 0)
continue;
counters[0] = i+1;
write(fd[1], counters, (1+(i & 1)) *sizeof(int));
} while (counters[0] < 1000000);
return 0;
}and in a perfect world, passing that token around should only cause one context switch per transfer, when the writer of a token causes a directed wakeup of just a single reader.
But with the "writer wakes all readers" model we traditionally had, on my test box the above case causes more than an order of magnitude more
scheduling: instead of the expected ~1M context switches, "perf stat" shows
231,852.37 msec task-clock # 15.857 CPUs utilized
11,250,961 context-switches # 0.049 M/sec
616,304 cpu-migrations # 0.003 M/sec
1,648 page-faults # 0.007 K/sec
1,097,903,998,514 cycles # 4.735 GHz
120,781,778,352 instructions # 0.11 insn per cycle
27,997,056,043 branches # 120.754 M/sec
283,581,233 branch-misses # 1.01% of all branches 14.621273891 seconds time elapsed
0.018243000 seconds user
3.611468000 seconds sysbefore this commit.
After this commit, I get
5,229.55 msec task-clock # 3.072 CPUs utilized
1,212,233 context-switches # 0.232 M/sec
103,951 cpu-migrations # 0.020 M/sec
1,328 page-faults # 0.254 K/sec
21,307,456,166 cycles # 4.074 GHz
12,947,819,999 instructions # 0.61 insn per cycle
2,881,985,678 branches # 551.096 M/sec
64,267,015 branch-misses # 2.23% of all branches 1.702148350 seconds time elapsed
0.004868000 seconds user
0.110786000 seconds sysinstead. Much better.
[ Note! This kernel improvement seems to be very good at triggering a
race condition in the make jobserver (in GNU make 4.2.1) for me. It's a long known bug that was fixed back in June 2017 by GNU make commit b552b0525198 ("[SV 51159] Use a non-blocking read with pselect to avoid hangs.").
But there wasn't a new release of GNU make until 4.3 on Jan 19 2020, so a number of distributions may still have the buggy version. Some have backported the fix to their 4.2.1 release, though, and even without the fix it's quite timing-dependent whether the bug actually is hit. ]
Josh Triplett says:
"I've been hammering on your pipe fix patch (switching to exclusive
wait queues) for a month or so, on several different systems, and I've run into no issues with it. The patch *substantially* improves parallel build times on large (~100 CPU) systems, both with parallel make and with other things that use make's pipe-based jobserver.
All current distributions (including stable and long-term stable distributions) have versions of GNU make that no longer have the jobserver bug"
--- fs/coredump.c | 4 +-- fs/pipe.c | 67 +++++++++++++++++++++++++-------------- fs/splice.c | 8 ++--- include/linux/pipe_fs_i.h | 2 +- 4 files changed, 51 insertions(+), 30 deletions(-)
fs/coredump.c +2 -2
@@ -517,7 +517,7 @@ static void wait_for_dump_helpers(struct file *file)pipe_lock (pipe); pipe->readers++; pipe->writers--; -wake_up_interruptible_sync (&pipe->wait); +wake_up_interruptible_sync (&pipe->rd_wait);kill_fasync (&pipe->fasync_readers,SIGIO ,POLL_IN );pipe_unlock (pipe);
@@ -525,7 +525,7 @@ static void wait_for_dump_helpers(struct file *file)* We actually want wait_event_freezable() but then we need * to clear TIF_SIGPENDING and improve dump_interrupted(). */ -wait_event_interruptible (pipe->wait, pipe->readers ==1 ); +wait_event_interruptible (pipe->rd_wait, pipe->readers ==1 );pipe_lock (pipe); pipe->readers--;
fs/pipe.c +44 -23
200 lines not on this page · raw message
fs/splice.c +4 -4
@@ -165,8 +165,8 @@ static const struct pipe_buf_operations user_page_pipe_buf_ops = {static void wakeup_pipe_readers (struct pipe_inode_info *pipe) {smp_mb (); -if (waitqueue_active (&pipe->wait)) -wake_up_interruptible (&pipe->wait); +if (waitqueue_active (&pipe->rd_wait)) +wake_up_interruptible (&pipe->rd_wait);kill_fasync (&pipe->fasync_readers,SIGIO ,POLL_IN ); }
@@ -462,8 +462,8 @@ static int pipe_to_sendpage(struct pipe_inode_info *pipe,static void wakeup_pipe_writers (struct pipe_inode_info *pipe) {smp_mb (); -if (waitqueue_active (&pipe->wait)) -wake_up_interruptible (&pipe->wait); +if (waitqueue_active (&pipe->wr_wait)) +wake_up_interruptible (&pipe->wr_wait);kill_fasync (&pipe->fasync_writers,SIGIO ,POLL_OUT ); }
include/linux/pipe_fs_i.h +1 -1
@@ -47,7 +47,7 @@ struct pipe_buffer {**/ struct pipe_inode_info {struct mutex mutex; -wait_queue_head_t wait; +wait_queue_head_t rd_wait, wr_wait;unsigned int head;unsigned int tail;unsigned int max_usage;
Signature · 1 line
2.20.1
Re: [PATCH AUTOSEL 5.5 542/542] pipe: use exclusive waits when reading or writing
Hi Linus,
This patch breaks one of CRIU tests. Here is a small reproducer:
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
int main()
{
int p[2];
pid_t p1, p2;
int status;
if (pipe(p) == -1)
return 1;
p1 = fork();
if (p1 == 0) {
close(p[1]);
read(p[0], &status, sizeof(status));
return 0;
}
p2 = fork();
if (p2 == 0) {
close(p[1]);
read(p[0], &status, sizeof(status));
return 0;
}
sleep(1);
close(p[1]);
wait(&status);
wait(&status); return 0;
}
Here are two readers which are waiting for data but only one of them will be woken up after closing the last writer.
The quick fix looks like this:
fs/pipe.c +0 -0
@@ -412,7 +412,7 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to) wake_up_interruptible_sync_poll(&pipe->wr_wait,
EPOLLOUT | EPOLLWRNORM);
kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
}
- if (wake_next_reader)
+ if (!pipe->writers || wake_next_reader)
wake_up_interruptible_sync_poll(&pipe->rd_wait,
EPOLLIN | EPOLLRDNORM);
if (ret > 0)
file_accessed(filp);I've checked that it fixes the issue, but It is too late today to read this code carefully, so I could skip something.
Thanks,
Andrei
Quoted 413 lines · Sasha Levin
From: Linus Torvalds <[email protected]>
[ Upstream commit
0ddad21d3e99c743a3aa473121dc5561679e26bb]This makes the pipe code use separate wait-queues and exclusive waiting for readers and writers, avoiding a nasty thundering herd problem when there are lots of readers waiting for data on a pipe (or, less commonly, lots of writers waiting for a pipe to have space).
While this isn't a common occurrence in the traditional "use a pipe as a data transport" case, where you typically only have a single reader and a single writer process, there is one common special case: using a pipe as a source of "locking tokens" rather than for data communication.
In particular, the GNU make jobserver code ends up using a pipe as a way to limit parallelism, where each job consumes a token by reading a byte from the jobserver pipe, and releases the token by writing a byte back to the pipe.
This pattern is fairly traditional on Unix, and works very well, but will waste a lot of time waking up a lot of processes when only a single reader needs to be woken up when a writer releases a new token.
A simplified test-case of just this pipe interaction is to create 64 processes, and then pass a single token around between them (this test-case also intentionally passes another token that gets ignored to test the "wake up next" logic too, in case anybody wonders about it):
#include <unistd.h> int main(int argc, char **argv) { int fd[2], counters[2]; pipe(fd); counters[0] = 0; counters[1] = -1; write(fd[1], counters, sizeof(counters)); /* 64 processes */ fork(); fork(); fork(); fork(); fork(); fork(); do { int i; read(fd[0], &i, sizeof(i)); if (i < 0) continue; counters[0] = i+1; write(fd[1], counters, (1+(i & 1)) *sizeof(int)); } while (counters[0] < 1000000); return 0; }and in a perfect world, passing that token around should only cause one context switch per transfer, when the writer of a token causes a directed wakeup of just a single reader.
But with the "writer wakes all readers" model we traditionally had, on my test box the above case causes more than an order of magnitude more
scheduling: instead of the expected ~1M context switches, "perf stat" shows231,852.37 msec task-clock # 15.857 CPUs utilized 11,250,961 context-switches # 0.049 M/sec 616,304 cpu-migrations # 0.003 M/sec 1,648 page-faults # 0.007 K/sec 1,097,903,998,514 cycles # 4.735 GHz 120,781,778,352 instructions # 0.11 insn per cycle 27,997,056,043 branches # 120.754 M/sec 283,581,233 branch-misses # 1.01% of all branches14.621273891 seconds time elapsed 0.018243000 seconds user 3.611468000 seconds sysbefore this commit.
After this commit, I get
5,229.55 msec task-clock # 3.072 CPUs utilized 1,212,233 context-switches # 0.232 M/sec 103,951 cpu-migrations # 0.020 M/sec 1,328 page-faults # 0.254 K/sec 21,307,456,166 cycles # 4.074 GHz 12,947,819,999 instructions # 0.61 insn per cycle 2,881,985,678 branches # 551.096 M/sec 64,267,015 branch-misses # 2.23% of all branches1.702148350 seconds time elapsed 0.004868000 seconds user 0.110786000 seconds sysinstead. Much better.
[ Note! This kernel improvement seems to be very good at triggering a
race condition in the make jobserver (in GNU make 4.2.1) for me. It's a long known bug that was fixed back in June 2017 by GNU make commitb552b0525198("[SV 51159] Use a non-blocking read with pselect to avoid hangs.").But there wasn't a new release of GNU make until 4.3 on Jan 19 2020, so a number of distributions may still have the buggy version. Some have backported the fix to their 4.2.1 release, though, and even without the fix it's quite timing-dependent whether the bug actually is hit. ]
Josh Triplett says:
"I've been hammering on your pipe fix patch (switching to exclusive
wait queues) for a month or so, on several different systems, and I've run into no issues with it. The patch *substantially* improves parallel build times on large (~100 CPU) systems, both with parallel make and with other things that use make's pipe-based jobserver.All current distributions (including stable and long-term stable distributions) have versions of GNU make that no longer have the jobserver bug"
Tested-by Josh Triplett <[email protected]>Signed-off-by Linus Torvalds <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- fs/coredump.c | 4 +-- fs/pipe.c | 67 +++++++++++++++++++++++++-------------- fs/splice.c | 8 ++--- include/linux/pipe_fs_i.h | 2 +- 4 files changed, 51 insertions(+), 30 deletions(-)fs/coredump.c +2
-2@@ -517,7 +517,7 @@ static void wait_for_dump_helpers(struct file *file)pipe_lock (pipe); pipe->readers++; pipe->writers--; -wake_up_interruptible_sync (&pipe->wait); +wake_up_interruptible_sync (&pipe->rd_wait);kill_fasync (&pipe->fasync_readers,SIGIO ,POLL_IN );pipe_unlock (pipe);@@ -525,7 +525,7 @@ static void wait_for_dump_helpers(struct file *file)* We actually want wait_event_freezable() but then we need * to clear TIF_SIGPENDING and improve dump_interrupted(). */ -wait_event_interruptible (pipe->wait, pipe->readers ==1 ); +wait_event_interruptible (pipe->rd_wait, pipe->readers ==1 );pipe_lock (pipe); pipe->readers--;fs/pipe.c +44
-23@@ -108,16 +108,19 @@ void pipe_double_lock(struct pipe_inode_info *pipe1,/* Drop the inode semaphore and wait for a pipe event, atomically */ void pipe_wait (struct pipe_inode_info *pipe) { -DEFINE_WAIT (wait); +DEFINE_WAIT (rdwait); +DEFINE_WAIT (wrwait);/* * Pipes are system-local resources, so sleeping on them * is considered a noninteractive wait: */ -prepare_to_wait (&pipe->wait, &wait,TASK_INTERRUPTIBLE ); +prepare_to_wait (&pipe->rd_wait, &rdwait,TASK_INTERRUPTIBLE ); +prepare_to_wait (&pipe->wr_wait, &wrwait,TASK_INTERRUPTIBLE );pipe_unlock (pipe);schedule (); -finish_wait (&pipe->wait, &wait); +finish_wait (&pipe->rd_wait, &rdwait); +finish_wait (&pipe->wr_wait, &wrwait);pipe_lock (pipe); }@@ -286,7 +289,7 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to)size_t total_len =iov_iter_count (to);struct file *filp = iocb->ki_filp;struct pipe_inode_info *pipe = filp->private_data; -bool was_full; +bool was_full, wake_next_reader = false;ssize_t ret;/* Null read succeeds. */ @@ -344,10 +347,10 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to)if (!buf->len) {pipe_buf_release (pipe, buf); -spin_lock_irq (&pipe->wait.lock); +spin_lock_irq (&pipe->rd_wait.lock); tail++; pipe->tail = tail; -spin_unlock_irq (&pipe->wait.lock); +spin_unlock_irq (&pipe->rd_wait.lock); } total_len -= chars;if (!total_len)@@ -384,7 +387,7 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to)* no data. */ if (unlikely (was_full)) { -wake_up_interruptible_sync_poll (&pipe->wait,EPOLLOUT |EPOLLWRNORM ); +wake_up_interruptible_sync_poll (&pipe->wr_wait,EPOLLOUT |EPOLLWRNORM );kill_fasync (&pipe->fasync_writers,SIGIO ,POLL_OUT ); }@@ -394,18 +397,23 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to)* since we've done any required wakeups and there's no need * to mark anything accessed. And we've dropped the lock. */ -if (wait_event_interruptible (pipe->wait,pipe_readable (pipe)) <0 ) +if (wait_event_interruptible_exclusive (pipe->rd_wait,pipe_readable (pipe)) <0 )return -ERESTARTSYS ;__pipe_lock (pipe); was_full =pipe_full (pipe->head, pipe->tail, pipe->max_usage); + wake_next_reader = true; } +if (pipe_empty (pipe->head, pipe->tail)) + wake_next_reader = false;__pipe_unlock (pipe);if (was_full) { -wake_up_interruptible_sync_poll (&pipe->wait,EPOLLOUT |EPOLLWRNORM ); +wake_up_interruptible_sync_poll (&pipe->wr_wait,EPOLLOUT |EPOLLWRNORM );kill_fasync (&pipe->fasync_writers,SIGIO ,POLL_OUT ); } +if (wake_next_reader) +wake_up_interruptible_sync_poll (&pipe->rd_wait,EPOLLIN |EPOLLRDNORM );if (ret >0 )file_accessed (filp);return ret;@@ -437,6 +445,7 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)size_t total_len =iov_iter_count (from);ssize_t chars;bool was_empty = false; +bool wake_next_writer = false;/* Null write succeeds. */ if (unlikely (total_len ==0 ))@@ -515,16 +524,16 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)* it, either the reader will consume it or it'll still * be there for the next write. */ -spin_lock_irq (&pipe->wait.lock); +spin_lock_irq (&pipe->rd_wait.lock); head = pipe->head;if (pipe_full (head, pipe->tail, pipe->max_usage)) { -spin_unlock_irq (&pipe->wait.lock); +spin_unlock_irq (&pipe->rd_wait.lock);continue ; } pipe->head = head +1 ; -spin_unlock_irq (&pipe->wait.lock); +spin_unlock_irq (&pipe->rd_wait.lock);/* Insert it into the buffer array */ buf = &pipe->bufs[head & mask];@@ -576,14 +585,17 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)*/ __pipe_unlock (pipe);if (was_empty) { -wake_up_interruptible_sync_poll (&pipe->wait,EPOLLIN |EPOLLRDNORM ); +wake_up_interruptible_sync_poll (&pipe->rd_wait,EPOLLIN |EPOLLRDNORM );kill_fasync (&pipe->fasync_readers,SIGIO ,POLL_IN ); } -wait_event_interruptible (pipe->wait,pipe_writable (pipe)); +wait_event_interruptible_exclusive (pipe->wr_wait,pipe_writable (pipe));__pipe_lock (pipe); was_empty =pipe_empty (pipe->head, pipe->tail); + wake_next_writer = true; } out: +if (pipe_full (pipe->head, pipe->tail, pipe->max_usage)) + wake_next_writer = false;__pipe_unlock (pipe);/* @@ -596,9 +608,11 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)* wake up pending jobs */ if (was_empty) { -wake_up_interruptible_sync_poll (&pipe->wait,EPOLLIN |EPOLLRDNORM ); +wake_up_interruptible_sync_poll (&pipe->rd_wait,EPOLLIN |EPOLLRDNORM );kill_fasync (&pipe->fasync_readers,SIGIO ,POLL_IN ); } +if (wake_next_writer) +wake_up_interruptible_sync_poll (&pipe->wr_wait,EPOLLOUT |EPOLLWRNORM );if (ret >0 &&sb_start_write_trylock (file_inode (filp)->i_sb)) {int err =file_update_time (filp);if (err)@@ -642,12 +656,15 @@ pipe_poll(struct file *filp, poll_table *wait)unsigned int head, tail;/* -* Reading only -- no need for acquiring the semaphore. +* Reading pipe state only -- no need for acquiring the semaphore. * * But because this is racy, the code has to add the * entry to the poll table _first_ .. */ -poll_wait (filp, &pipe->wait, wait); +if (filp->f_mode &FMODE_READ ) +poll_wait (filp, &pipe->rd_wait, wait); +if (filp->f_mode &FMODE_WRITE ) +poll_wait (filp, &pipe->wr_wait, wait);/* * .. and only then can you do the racy tests. That way, @@ -706,7 +723,8 @@ pipe_release(struct inode *inode, struct file *file) pipe->writers--;if (pipe->readers || pipe->writers) { -wake_up_interruptible_sync_poll (&pipe->wait,EPOLLIN |EPOLLOUT |EPOLLRDNORM |EPOLLWRNORM |EPOLLERR |EPOLLHUP ); +wake_up_interruptible_sync_poll (&pipe->rd_wait,EPOLLIN |EPOLLRDNORM |EPOLLERR |EPOLLHUP ); +wake_up_interruptible_sync_poll (&pipe->wr_wait,EPOLLOUT |EPOLLWRNORM |EPOLLERR |EPOLLHUP );kill_fasync (&pipe->fasync_readers,SIGIO ,POLL_IN );kill_fasync (&pipe->fasync_writers,SIGIO ,POLL_OUT ); }@@ -789,7 +807,8 @@ struct pipe_inode_info *alloc_pipe_info(void) GFP_KERNEL_ACCOUNT);if (pipe->bufs) { -init_waitqueue_head (&pipe->wait); +init_waitqueue_head (&pipe->rd_wait); +init_waitqueue_head (&pipe->wr_wait); pipe->r_counter = pipe->w_counter =1 ; pipe->max_usage = pipe_bufs; pipe->ring_size = pipe_bufs;@@ -1007,7 +1026,8 @@ static int wait_for_partner(struct pipe_inode_info *pipe, unsigned int *cnt)static void wake_up_partner (struct pipe_inode_info *pipe) { -wake_up_interruptible (&pipe->wait); +wake_up_interruptible (&pipe->rd_wait); +wake_up_interruptible (&pipe->wr_wait); }static int fifo_open (struct inode *inode,struct file *filp)@@ -1118,13 +1138,13 @@ static int fifo_open(struct inode *inode, struct file *filp) err_rd:if (!--pipe->readers) -wake_up_interruptible (&pipe->wait); +wake_up_interruptible (&pipe->wr_wait); ret = -ERESTARTSYS ; goto err; err_wr:if (!--pipe->writers) -wake_up_interruptible (&pipe->wait); +wake_up_interruptible (&pipe->rd_wait); ret = -ERESTARTSYS ; goto err;@@ -1251,7 +1271,8 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long arg) pipe->max_usage = nr_slots; pipe->tail = tail; pipe->head = head; -wake_up_interruptible_all (&pipe->wait); +wake_up_interruptible_all (&pipe->rd_wait); +wake_up_interruptible_all (&pipe->wr_wait);return pipe->max_usage *PAGE_SIZE ; out_revert_acct:fs/splice.c +4
-4@@ -165,8 +165,8 @@ static const struct pipe_buf_operations user_page_pipe_buf_ops = {static void wakeup_pipe_readers (struct pipe_inode_info *pipe) {smp_mb (); -if (waitqueue_active (&pipe->wait)) -wake_up_interruptible (&pipe->wait); +if (waitqueue_active (&pipe->rd_wait)) +wake_up_interruptible (&pipe->rd_wait);kill_fasync (&pipe->fasync_readers,SIGIO ,POLL_IN ); }@@ -462,8 +462,8 @@ static int pipe_to_sendpage(struct pipe_inode_info *pipe,static void wakeup_pipe_writers (struct pipe_inode_info *pipe) {smp_mb (); -if (waitqueue_active (&pipe->wait)) -wake_up_interruptible (&pipe->wait); +if (waitqueue_active (&pipe->wr_wait)) +wake_up_interruptible (&pipe->wr_wait);kill_fasync (&pipe->fasync_writers,SIGIO ,POLL_OUT ); }include/linux/pipe_fs_i.h +1
-2@@ -47,7 +47,7 @@ struct pipe_buffer {**/ struct pipe_inode_info {struct mutex mutex; -wait_queue_head_t wait; +wait_queue_head_t rd_wait, wr_wait;unsigned int head;unsigned int tail;unsigned int max_usage; --2.20.1
Re: [PATCH AUTOSEL 5.5 542/542] pipe: use exclusive waits when reading or writing
Quoted 2 lines · Andrei Vagin
This patch breaks one of CRIU tests. Here is a small reproducer:
Good catch.
Quoted 1 line
The quick fix looks like this:
That one works, but is not really right.
The things that change the number of readers or writers should simply use "wake_up_all()".
I thought we did that already, but no - there _was_ one place where we did it, but that was for the pipe buffer size case, and in that case it's actually pointless. That case acts just like a "new space or data was added"
So I think the right fix is the attached patch. Since you had such a lovely test-case, let me go test it too ;)
Linus
fs/pipe.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/pipe.c +5 -5
@@ -1026,8 +1026,8 @@ static int wait_for_partner(struct pipe_inode_info *pipe, unsigned int *cnt)static void wake_up_partner (struct pipe_inode_info *pipe) { -wake_up_interruptible (&pipe->rd_wait); -wake_up_interruptible (&pipe->wr_wait); +wake_up_interruptible_all (&pipe->rd_wait); +wake_up_interruptible_all (&pipe->wr_wait); }static int fifo_open (struct inode *inode,struct file *filp)
@@ -1144,7 +1144,7 @@ static int fifo_open(struct inode *inode, struct file *filp) err_wr:if (!--pipe->writers) -wake_up_interruptible (&pipe->rd_wait); +wake_up_interruptible_all (&pipe->rd_wait); ret = -ERESTARTSYS ; goto err;
@@ -1271,8 +1271,8 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long arg) pipe->max_usage = nr_slots; pipe->tail = tail; pipe->head = head; -wake_up_interruptible_all (&pipe->rd_wait); -wake_up_interruptible_all (&pipe->wr_wait); +wake_up_interruptible (&pipe->rd_wait); +wake_up_interruptible (&pipe->wr_wait);return pipe->max_usage *PAGE_SIZE ; out_revert_acct:
Re: [PATCH AUTOSEL 5.5 542/542] pipe: use exclusive waits when reading or writing
Quoted 6 lines · Linus Torvalds
The things that change the number of readers or writers should simply use "
wake_up_all()".So I think the right fix is the attached patch. Since you had such a lovely test-case, let me go test it too ;)
Good that I did. I missed the _real_ case of this - pipe_release(). Because that used a different wakeup function.
In fact, that case uses wake_up_interruptible_sync_poll(), which doesn't have the "all" version.
But it doesn't actually need that fancy thing, since it's only meant for "let's avoid waking up things that don't need these poll keys", and the whole point is that now we're closing the pipe so we should wake up everybody.
And in fact the test for "are there readers or writers" was nonsensical. We shouldn't wake up readers just because they still exist. We should wake up readers only if they exist, _and_ there are no writers left (and vice versa).
Anyway, new patch attached. This hasn't been tested either, but I'll let you know if it's broken too ;)
Linus
fs/pipe.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
fs/pipe.c +9 -8
@@ -722,9 +722,10 @@ pipe_release(struct inode *inode, struct file *file)if (file->f_mode &FMODE_WRITE ) pipe->writers--; -if (pipe->readers || pipe->writers) { -wake_up_interruptible_sync_poll (&pipe->rd_wait,EPOLLIN |EPOLLRDNORM |EPOLLERR |EPOLLHUP ); -wake_up_interruptible_sync_poll (&pipe->wr_wait,EPOLLOUT |EPOLLWRNORM |EPOLLERR |EPOLLHUP ); +/* Was that the last reader or writer, but not the other side? */ +if (!pipe->readers != !pipe->writers) { +wake_up_interruptible_all (&pipe->rd_wait); +wake_up_interruptible_all (&pipe->wr_wait);kill_fasync (&pipe->fasync_readers,SIGIO ,POLL_IN );kill_fasync (&pipe->fasync_writers,SIGIO ,POLL_OUT ); }
@@ -1026,8 +1027,8 @@ static int wait_for_partner(struct pipe_inode_info *pipe, unsigned int *cnt)static void wake_up_partner (struct pipe_inode_info *pipe) { -wake_up_interruptible (&pipe->rd_wait); -wake_up_interruptible (&pipe->wr_wait); +wake_up_interruptible_all (&pipe->rd_wait); +wake_up_interruptible_all (&pipe->wr_wait); }static int fifo_open (struct inode *inode,struct file *filp)
@@ -1144,7 +1145,7 @@ static int fifo_open(struct inode *inode, struct file *filp) err_wr:if (!--pipe->writers) -wake_up_interruptible (&pipe->rd_wait); +wake_up_interruptible_all (&pipe->rd_wait); ret = -ERESTARTSYS ; goto err;
@@ -1271,8 +1272,8 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long arg) pipe->max_usage = nr_slots; pipe->tail = tail; pipe->head = head; -wake_up_interruptible_all (&pipe->rd_wait); -wake_up_interruptible_all (&pipe->wr_wait); +wake_up_interruptible (&pipe->rd_wait); +wake_up_interruptible (&pipe->wr_wait);return pipe->max_usage *PAGE_SIZE ; out_revert_acct:
Re: [PATCH AUTOSEL 5.5 542/542] pipe: use exclusive waits when reading or writing
Quoted 3 lines · Linus Torvalds
Anyway, new patch attached. This hasn't been tested either, but I'll let you know if it's broken too ;)
That one looks good. Some small cosmetic edits later, and with a commit log it looks like the appended.
If you're testing this and it works for your full CRIU test case too, I'll add your tested-by if I get it before I end up pushing things out later today,
Linus
From 7e2fe96d1b760eb3e7dec771db7b8983d5b6c25c Mon Sep 17 00:00:00 2001
From: Linus Torvalds <[email protected]>
Date: Tue, 18 Feb 2020 10:12:58 -0800
Subject: [PATCH] pipe: make sure to wake up everybody when the last
reader/writer closes
Andrei Vagin reported that commit 0ddad21d3e99 ("pipe: use exclusive waits when reading or writing") broke one of the CRIU tests. He even has a trivial reproducer:
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
int main()
{
int p[2];
pid_t p1, p2;
int status;
if (pipe(p) == -1)
return 1;
p1 = fork();
if (p1 == 0) {
close(p[1]);
read(p[0], &status, sizeof(status));
return 0;
}
p2 = fork();
if (p2 == 0) {
close(p[1]);
read(p[0], &status, sizeof(status));
return 0;
}
sleep(1);
close(p[1]);
wait(&status);
wait(&status);
return 0;
}and the problem - once he points it out - is obvious. We use these nice exclusive waits, but when the last writer goes away, it then needs to wake up _every_ reader (and conversely, the last reader disappearing needs to wake every writer, of course).
In fact, when going through this, we had several small oddities around how to wake things. We did in fact wake every reader when we changed the size of the pipe buffers. But that's entirely pointless, since that just acts as a possible source of new space - no new data to read.
And when we change the size of the buffer, we don't need to wake all writers even when we add space - that case acts just as if somebody made space by reading, and any writer that finds itself not filling it up entirely will wake the next one.
On the other hand, on the exit path, we tried to limit the wakeups with the proper poll keys etc, which is entirely pointless, because at that point we obviously need to wake up everybody. So don't do that: just wake up everybody - but only do that if the counts changed to zero.
So fix those non-IO wakeups to be more proper: space change doesn't add any new data, but it might make room for writers, so it wakes up a writer. And the actual changes to reader/writer counts should wake up everybody, since everybody is affected (ie readers will all see EOF if the writers have gone away, and writers will all get EPIPE if all readers have gone away).
--- fs/pipe.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
fs/pipe.c +10 -8
@@ -722,9 +722,10 @@ pipe_release(struct inode *inode, struct file *file)if (file->f_mode &FMODE_WRITE ) pipe->writers--; -if (pipe->readers || pipe->writers) { -wake_up_interruptible_sync_poll (&pipe->rd_wait,EPOLLIN |EPOLLRDNORM |EPOLLERR |EPOLLHUP ); -wake_up_interruptible_sync_poll (&pipe->wr_wait,EPOLLOUT |EPOLLWRNORM |EPOLLERR |EPOLLHUP ); +/* Was that the last reader or writer, but not the other side? */ +if (!pipe->readers != !pipe->writers) { +wake_up_interruptible_all (&pipe->rd_wait); +wake_up_interruptible_all (&pipe->wr_wait);kill_fasync (&pipe->fasync_readers,SIGIO ,POLL_IN );kill_fasync (&pipe->fasync_writers,SIGIO ,POLL_OUT ); }
@@ -1026,8 +1027,8 @@ static int wait_for_partner(struct pipe_inode_info *pipe, unsigned int *cnt)static void wake_up_partner (struct pipe_inode_info *pipe) { -wake_up_interruptible (&pipe->rd_wait); -wake_up_interruptible (&pipe->wr_wait); +wake_up_interruptible_all (&pipe->rd_wait); +wake_up_interruptible_all (&pipe->wr_wait); }static int fifo_open (struct inode *inode,struct file *filp)
@@ -1144,7 +1145,7 @@ static int fifo_open(struct inode *inode, struct file *filp) err_wr:if (!--pipe->writers) -wake_up_interruptible (&pipe->rd_wait); +wake_up_interruptible_all (&pipe->rd_wait); ret = -ERESTARTSYS ; goto err;
@@ -1271,8 +1272,9 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long arg) pipe->max_usage = nr_slots; pipe->tail = tail; pipe->head = head; -wake_up_interruptible_all (&pipe->rd_wait); -wake_up_interruptible_all (&pipe->wr_wait); + +/* This might have made more room for writers */ +wake_up_interruptible (&pipe->wr_wait);return pipe->max_usage *PAGE_SIZE ; out_revert_acct:
Signature · 1 line
2.24.0.158.g3fed155289
Re: [PATCH AUTOSEL 5.5 542/542] pipe: use exclusive waits when reading or writing
Quoted 15 lines · Linus Torvalds
fs/pipe.c +4
-3@@ -722,9 +722,10 @@ pipe_release(struct inode *inode, struct file *file)if (file->f_mode &FMODE_WRITE ) pipe->writers--; -if (pipe->readers || pipe->writers) { -wake_up_interruptible_sync_poll (&pipe->rd_wait,EPOLLIN |EPOLLRDNORM |EPOLLERR |EPOLLHUP ); -wake_up_interruptible_sync_poll (&pipe->wr_wait,EPOLLOUT |EPOLLWRNORM |EPOLLERR |EPOLLHUP ); +/* Was that the last reader or writer, but not the other side? */ +if (!pipe->readers != !pipe->writers) { +wake_up_interruptible_all (&pipe->rd_wait); +wake_up_interruptible_all (&pipe->wr_wait);kill_fasync (&pipe->fasync_readers,SIGIO ,POLL_IN );kill_fasync (&pipe->fasync_writers,SIGIO ,POLL_OUT ); }
fs/pipe.c static int wait_for_partner(struct pipe_inode_info *pipe, unsigned int *cnt) · line 1032
Quoted 8 lines
fs/pipe.c +2
-2@@ -1026,8 +1027,8 @@ static int wait_for_partner(struct pipe_inode_info *pipe, unsigned int *cnt)static void wake_up_partner (struct pipe_inode_info *pipe) { -wake_up_interruptible (&pipe->rd_wait); -wake_up_interruptible (&pipe->wr_wait); +wake_up_interruptible_all (&pipe->rd_wait); +wake_up_interruptible_all (&pipe->wr_wait); }
You don't want to move wake_up_partner() up and call it from pipe_release()?
Re: [PATCH AUTOSEL 5.5 542/542] pipe: use exclusive waits when reading or writing
Quoted 2 lines · Matthew Wilcox
You don't want to move
wake_up_partner()up and call it frompipe_release()?
I was actually thinking of going the other way - two of three users of wake_up_partner() are redundantly waking up the wrong side, and the third user is pointlessly written too.
So I was _thinking_ of a patch like the appended (which is on top of the previous patch), but ended up not doing it. Until you brought it up.
But I won't bother committing this, since it shouldn't really matter.
Linus
fs/pipe.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
fs/pipe.c +6 -12
@@ -1025,12 +1025,6 @@ static int wait_for_partner(struct pipe_inode_info *pipe, unsigned int *cnt)return cur == *cnt ? -ERESTARTSYS :0 ; } -static void wake_up_partner (struct pipe_inode_info *pipe) -{ -wake_up_interruptible_all (&pipe->rd_wait); -wake_up_interruptible_all (&pipe->wr_wait); -} -static int fifo_open (struct inode *inode,struct file *filp) {struct pipe_inode_info *pipe;
@@ -1078,7 +1072,7 @@ static int fifo_open(struct inode *inode, struct file *filp)*/ pipe->r_counter++;if (pipe->readers++ ==0 ) -wake_up_partner (pipe); +wake_up_interruptible_all (&pipe->wr_wait);if (!is_pipe && !pipe->writers) {if ((filp->f_flags &O_NONBLOCK )) {
@@ -1104,7 +1098,7 @@ static int fifo_open(struct inode *inode, struct file *filp) pipe->w_counter++;if (!pipe->writers++) -wake_up_partner (pipe); +wake_up_interruptible_all (&pipe->rd_wait);if (!is_pipe && !pipe->readers) {if (wait_for_partner (pipe, &pipe->r_counter))
@@ -1120,12 +1114,12 @@ static int fifo_open(struct inode *inode, struct file *filp)* the process can at least talk to itself. */ - pipe->readers++; - pipe->writers++; +if (pipe->readers++ ==0 ) +wake_up_interruptible_all (&pipe->wr_wait); +if (pipe->writers++ ==0 ) +wake_up_interruptible_all (&pipe->rd_wait); pipe->r_counter++; pipe->w_counter++; -if (pipe->readers ==1 || pipe->writers ==1 ) -wake_up_partner (pipe);break ;default :
Re: [PATCH AUTOSEL 5.5 542/542] pipe: use exclusive waits when reading or writing
Quoted 8 lines · Linus Torvalds
Quoted 2 lines · Matthew Wilcox
You don't want to move
wake_up_partner()up and call it frompipe_release()?I was actually thinking of going the other way - two of three users of
wake_up_partner()are redundantly waking up the wrong side, and the third user is pointlessly written too.
Quoted 5 lines
So I was _thinking_ of a patch like the appended (which is on top of the previous patch), but ended up not doing it. Until you brought it up.
But I won't bother committing this, since it shouldn't really matter.
I run CRIU tests on the kernel with both these patches. Everything work as expected. Thank you for the fix.
Quoted 58 lines
Linus
fs/pipe.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)fs/pipe.c +6
-12@@ -1025,12 +1025,6 @@ static int wait_for_partner(struct pipe_inode_info *pipe, unsigned int *cnt)return cur == *cnt ? -ERESTARTSYS :0 ; } -static void wake_up_partner (struct pipe_inode_info *pipe) -{ -wake_up_interruptible_all (&pipe->rd_wait); -wake_up_interruptible_all (&pipe->wr_wait); -} -static int fifo_open (struct inode *inode,struct file *filp) {struct pipe_inode_info *pipe;@@ -1078,7 +1072,7 @@ static int fifo_open(struct inode *inode, struct file *filp)*/ pipe->r_counter++;if (pipe->readers++ ==0 ) -wake_up_partner (pipe); +wake_up_interruptible_all (&pipe->wr_wait);if (!is_pipe && !pipe->writers) {if ((filp->f_flags &O_NONBLOCK )) {@@ -1104,7 +1098,7 @@ static int fifo_open(struct inode *inode, struct file *filp) pipe->w_counter++;if (!pipe->writers++) -wake_up_partner (pipe); +wake_up_interruptible_all (&pipe->rd_wait);if (!is_pipe && !pipe->readers) {if (wait_for_partner (pipe, &pipe->r_counter))@@ -1120,12 +1114,12 @@ static int fifo_open(struct inode *inode, struct file *filp)* the process can at least talk to itself. */ - pipe->readers++; - pipe->writers++; +if (pipe->readers++ ==0 ) +wake_up_interruptible_all (&pipe->wr_wait); +if (pipe->writers++ ==0 ) +wake_up_interruptible_all (&pipe->rd_wait); pipe->r_counter++; pipe->w_counter++; -if (pipe->readers ==1 || pipe->writers ==1 ) -wake_up_partner (pipe);break ;default :
Re: [PATCH AUTOSEL 5.5 542/542] pipe: use exclusive waits when reading or writing
Quoted 3 lines · Andrei Vagin
I run CRIU tests on the kernel with both these patches. Everything work as expected.
Thanks. I've added your tested-by and pushed out the fix.
Linus
Re: [PATCH AUTOSEL 5.5 542/542] pipe: use exclusive waits when reading or writing
Hello Linus,
After this change, one more criu test became flaky. This is due to one of corner cases, so I am not sure that we need to fix something in the kernel. I have fixed this issue in the test. I am not sure that this will affect any real applications.
Here is the reproducer:
#include <unistd.h>
#include <stdio.h>
int main()
{
char buf[1<<20];
int pid, p[2], ret;
if (pipe(p) < 0)
return 1;
pid = fork();
if (pid == 0) {
close(p[1]);
ret = read(p[0], buf, sizeof(buf));
if (ret < 0)
return 1;
printf("read -> %d\n", ret);
return 0;
}
close(p[0]);
ret = write(p[1], buf, sizeof(buf));
if (ret < 0)
return 1;
printf("write -> %d\n", ret);
return 0;
}Before this change:
[avagin@laptop fifo]$ uname -a
Linux laptop 5.3.7-200.fc30.x86_64 #1 SMP Fri Oct 18 20:13:59 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
[avagin@laptop fifo]$ strace -e read,write,pipe -f ./pipe_bigbuf read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260r\2\0\0\0\0\0"...,
832) = 832
read(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"...,
784) = 784
read(3, "\4\0\0\0\20\0\0\0\5\0\0\0GNU\0\2\0\0\300\4\0\0\0\3\0\0\0\0\0\0\0",
32) = 32
read(3, "\4\0\0\0\24\0\0\0\3\0\0\0GNU\0gZ\316<\240z\v\206=\360\37F\32{\t\204"...,
68) = 68
read(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"...,
784) = 784
read(3, "\4\0\0\0\20\0\0\0\5\0\0\0GNU\0\2\0\0\300\4\0\0\0\3\0\0\0\0\0\0\0",
32) = 32
read(3, "\4\0\0\0\24\0\0\0\3\0\0\0GNU\0gZ\316<\240z\v\206=\360\37F\32{\t\204"...,
68) = 68pipe([3, 4]) = 0
strace: Process 622350 attached
[pid 622349] write(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576 <unfinished ...>
[pid 622350] read(3, <unfinished ...>
[pid 622349] <... write resumed> ) = 1048576
[pid 622350] <... read resumed> "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576) = 1048576
[pid 622349] write(1, "write -> 1048576\n", 17write -> 1048576
) = 17
[pid 622350] write(1, "read -> 1048576\n", 16read -> 1048576
) = 16
[pid 622349] +++ exited with 0 +++
+++ exited with 0 +++
After this change:
[root@fc24 ~]# strace -e read,write,pipe -f ./pipe_bigbuf
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260r\2\0\0\0\0\0"...,
832) = 832
read(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"...,
784) = 784
read(3, "\4\0\0\0\20\0\0\0\5\0\0\0GNU\0\2\0\0\300\4\0\0\0\3\0\0\0\0\0\0\0",
32) = 32
read(3, "\4\0\0\0\24\0\0\0\3\0\0\0GNU\0L\355\265_\4c\17r@ix\305q\26W\242"...,
68) = 68
read(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"...,
784) = 784
read(3, "\4\0\0\0\20\0\0\0\5\0\0\0GNU\0\2\0\0\300\4\0\0\0\3\0\0\0\0\0\0\0",
32) = 32
read(3, "\4\0\0\0\24\0\0\0\3\0\0\0GNU\0L\355\265_\4c\17r@ix\305q\26W\242"...,
68) = 68pipe([3, 4]) = 0
strace: Process 4946 attached
[pid 4945] write(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576 <unfinished ...>
[pid 4946] read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576) = 65536
[pid 4946] write(1, "read -> 65536\n", 14read -> 65536
) = 14
[pid 4945] <... write resumed>) = 131072
[pid 4946] +++ exited with 0 +++
--- SIGPIPE {si_signo=SIGPIPE, si_code=SI_USER, si_pid=4945, si_uid=0} --- +++ killed by SIGPIPE +++
Quoted 9 lines · Linus Torvalds
Quoted 3 lines · Andrei Vagin
I run CRIU tests on the kernel with both these patches. Everything work as expected.
Thanks. I've added your tested-by and pushed out the fix.
Linus
Re: [PATCH AUTOSEL 5.5 542/542] pipe: use exclusive waits when reading or writing
Quoted 5 lines · Andrei Vagin
After this change, one more criu test became flaky. This is due to one of corner cases, so I am not sure that we need to fix something in the kernel. I have fixed this issue in the test. I am not sure that this will affect any real applications.
It's an interesting test-case, but it's really not doing anything you should rely on.
The code basically expects a pipe write() to be "atomic" for something bigger than PIPE_BUF. We've never really guaranteed that (and POSIX doesn't), but we had this special case where readers would continue to read as long as there was an active writer, which kind of approximated that for some cases (and your test-case in particular).
A reader that wants to read everything should do multiple read() calls until it gets an EOF (or gets the expected buffer size). A regular read() on a pipe can simply always return a partial buffer (it will always do so in the case of signals, but what you're seeing is that it will also now do it if the kernel buffers emptied even when there was a writer that was ready to fill them again).
And I suspect it wasn't actually the commit you point to that changes the behavior, I think it's actually the "pipe: remove 'waiting_writers' merging logic" that changed behavior for your test
But because it's then timing-dependent on whether the reader gets all the data or not, it might bisect to any commit after that point. Particularly since some of the other commits change timing too..
We could re-introduce the "continue reading while there are active writers" logic, but if this is the only test that triggers that, I'd prefer to wait until some real user notices...
But if CRIU itself depends on this behavior (rather than just a test), then I guess we need to.
So is it just a test-case, or does CRIU itself depend on that "reads get full buffers"? As mentioned, that really _is_ fundamentally broken if there is any chance of signals..
Linus
Re: [PATCH AUTOSEL 5.5 542/542] pipe: use exclusive waits when reading or writing
Quoted 10 lines · Linus Torvalds
Quoted 5 lines · Andrei Vagin
After this change, one more criu test became flaky. This is due to one of corner cases, so I am not sure that we need to fix something in the kernel. I have fixed this issue in the test. I am not sure that this will affect any real applications.
It's an interesting test-case, but it's really not doing anything you should rely on.
I'm agree with this.
Quoted 6 lines
But if CRIU itself depends on this behavior (rather than just a test), then I guess we need to.
So is it just a test-case, or does CRIU itself depend on that "reads get full buffers"? As mentioned, that really _is_ fundamentally broken if there is any chance of signals..
No, it doesn't. I'm agree that we can wait an report from a real app.
Thanks!
Andrei
Re: [PATCH AUTOSEL 5.5 542/542] pipe: use exclusive waits when reading or writing
In reply to Sasha LevinQuoted 7 lines · Sasha Levin
From: Linus Torvalds <[email protected]>
[ Upstream commit
0ddad21d3e99c743a3aa473121dc5561679e26bb]This makes the pipe code use separate wait-queues and exclusive waiting for readers and writers, [..]
Oh, and since I didn't react initially, let me react now that Andrei found a bug here: why was this patch auto-selected for 5.5 stable in the first place?
It wasn't really a fix, and there's no Fixes: tag or stable tag in there. Yeah, there's a reference to an old commit, but that one isn't even a kernel commit.
Yeah, the performance improvements are quite nice if you hit the case this matters for, but still..
Linus