[PATCH 5.10 079/221] arm64: dts: ls1043a: mark crypto engine dma coherent

2021-03-29 Thread Greg Kroah-Hartman
From: Horia Geantă 

commit 4fb3a074755b7737c4081cffe0ccfa08c2f2d29d upstream.

Crypto engine (CAAM) on LS1043A platform is configured HW-coherent,
mark accordingly the DT node.

Lack of "dma-coherent" property for an IP that is configured HW-coherent
can lead to problems, similar to what has been reported for LS1046A.

Cc:  # v4.8+
Fixes: 63dac35b58f4 ("arm64: dts: ls1043a: add crypto node")
Link: 
https://lore.kernel.org/linux-crypto/fe6faa24-d8f7-d18f-adfa-44fa0caa1...@arm.com
Signed-off-by: Horia Geantă 
Acked-by: Li Yang 
Signed-off-by: Shawn Guo 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi |1 +
 1 file changed, 1 insertion(+)

--- a/arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi
@@ -322,6 +322,7 @@
ranges = <0x0 0x00 0x170 0x10>;
reg = <0x00 0x170 0x0 0x10>;
interrupts = <0 75 0x4>;
+   dma-coherent;
 
sec_jr0: jr@1 {
compatible = "fsl,sec-v5.4-job-ring",




[PATCH 5.10 082/221] ARM: dts: at91-sama5d27_som1: fix phy address to 7

2021-03-29 Thread Greg Kroah-Hartman
From: Claudiu Beznea 

commit 221c3a09ddf70a0a51715e6c2878d8305e95c558 upstream.

Fix the phy address to 7 for Ethernet PHY on SAMA5D27 SOM1. No
connection established if phy address 0 is used.

The board uses the 24 pins version of the KSZ8081RNA part, KSZ8081RNA
pin 16 REFCLK as PHYAD bit [2] has weak internal pull-down.  But at
reset, connected to PD09 of the MPU it's connected with an internal
pull-up forming PHYAD[2:0] = 7.

Signed-off-by: Claudiu Beznea 
Fixes: 2f61929eb10a ("ARM: dts: at91: at91-sama5d27_som1: fix PHY ID")
Cc: Ludovic Desroches 
Signed-off-by: Nicolas Ferre 
Cc:  # 4.14+
Signed-off-by: Greg Kroah-Hartman 
---
 arch/arm/boot/dts/at91-sama5d27_som1.dtsi |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/arch/arm/boot/dts/at91-sama5d27_som1.dtsi
+++ b/arch/arm/boot/dts/at91-sama5d27_som1.dtsi
@@ -84,8 +84,8 @@
pinctrl-0 = <&pinctrl_macb0_default>;
phy-mode = "rmii";
 
-   ethernet-phy@0 {
-   reg = <0x0>;
+   ethernet-phy@7 {
+   reg = <0x7>;
interrupt-parent = <&pioA>;
interrupts = ;
pinctrl-names = "default";




[PATCH 5.10 064/221] selinux: fix variable scope issue in live sidtab conversion

2021-03-29 Thread Greg Kroah-Hartman
From: Ondrej Mosnacek 

commit 6406887a12ee5dcda1a8508d91113d545559 upstream.

Commit 02a52c5c8c3b ("selinux: move policy commit after updating
selinuxfs") moved the selinux_policy_commit() call out of
security_load_policy() into sel_write_load(), which caused a subtle yet
rather serious bug.

The problem is that security_load_policy() passes a reference to the
convert_params local variable to sidtab_convert(), which stores it in
the sidtab, where it may be accessed until the policy is swapped over
and RCU synchronized. Before 02a52c5c8c3b, selinux_policy_commit() was
called directly from security_load_policy(), so the convert_params
pointer remained valid all the way until the old sidtab was destroyed,
but now that's no longer the case and calls to sidtab_context_to_sid()
on the old sidtab after security_load_policy() returns may cause invalid
memory accesses.

This can be easily triggered using the stress test from commit
ee1a84fdfeed ("selinux: overhaul sidtab to fix bug and improve
performance"):
```
function rand_cat() {
echo $(( $RANDOM % 1024 ))
}

function do_work() {
while true; do
echo -n 
"system_u:system_r:kernel_t:s0:c$(rand_cat),c$(rand_cat)" \
>/sys/fs/selinux/context 2>/dev/null || true
done
}

do_work >/dev/null &
do_work >/dev/null &
do_work >/dev/null &

while load_policy; do echo -n .; sleep 0.1; done

kill %1
kill %2
kill %3
```

Fix this by allocating the temporary sidtab convert structures
dynamically and passing them among the
selinux_policy_{load,cancel,commit} functions.

Fixes: 02a52c5c8c3b ("selinux: move policy commit after updating selinuxfs")
Cc: sta...@vger.kernel.org
Tested-by: Tyler Hicks 
Reviewed-by: Tyler Hicks 
Signed-off-by: Ondrej Mosnacek 
[PM: merge fuzz in security.h and services.c]
Signed-off-by: Paul Moore 
Signed-off-by: Greg Kroah-Hartman 
---
 security/selinux/include/security.h |   15 ++--
 security/selinux/selinuxfs.c|   10 ++---
 security/selinux/ss/services.c  |   65 ++--
 3 files changed, 56 insertions(+), 34 deletions(-)

--- a/security/selinux/include/security.h
+++ b/security/selinux/include/security.h
@@ -219,14 +219,21 @@ static inline bool selinux_policycap_gen
return 
READ_ONCE(state->policycap[POLICYDB_CAPABILITY_GENFS_SECLABEL_SYMLINKS]);
 }
 
+struct selinux_policy_convert_data;
+
+struct selinux_load_state {
+   struct selinux_policy *policy;
+   struct selinux_policy_convert_data *convert_data;
+};
+
 int security_mls_enabled(struct selinux_state *state);
 int security_load_policy(struct selinux_state *state,
-   void *data, size_t len,
-   struct selinux_policy **newpolicyp);
+void *data, size_t len,
+struct selinux_load_state *load_state);
 void selinux_policy_commit(struct selinux_state *state,
-   struct selinux_policy *newpolicy);
+  struct selinux_load_state *load_state);
 void selinux_policy_cancel(struct selinux_state *state,
-   struct selinux_policy *policy);
+  struct selinux_load_state *load_state);
 int security_read_policy(struct selinux_state *state,
 void **data, size_t *len);
 
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -616,7 +616,7 @@ static ssize_t sel_write_load(struct fil
 
 {
struct selinux_fs_info *fsi = file_inode(file)->i_sb->s_fs_info;
-   struct selinux_policy *newpolicy;
+   struct selinux_load_state load_state;
ssize_t length;
void *data = NULL;
 
@@ -642,19 +642,19 @@ static ssize_t sel_write_load(struct fil
if (copy_from_user(data, buf, count) != 0)
goto out;
 
-   length = security_load_policy(fsi->state, data, count, &newpolicy);
+   length = security_load_policy(fsi->state, data, count, &load_state);
if (length) {
pr_warn_ratelimited("SELinux: failed to load policy\n");
goto out;
}
 
-   length = sel_make_policy_nodes(fsi, newpolicy);
+   length = sel_make_policy_nodes(fsi, load_state.policy);
if (length) {
-   selinux_policy_cancel(fsi->state, newpolicy);
+   selinux_policy_cancel(fsi->state, &load_state);
goto out;
}
 
-   selinux_policy_commit(fsi->state, newpolicy);
+   selinux_policy_commit(fsi->state, &load_state);
 
length = count;
 
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -66,6 +66,17 @@
 #include "audit.h"
 #include "policycap_names.h"
 
+struct convert_context_args {
+   struct selinux_state *state;
+   struct policydb *oldp;
+   struct policydb *newp;
+};
+
+struct selinux_policy_convert_data {
+   struct convert_context_args args;
+   struct sidtab_convert_params sidtab_params;
+};
+
 /* Forward d

[PATCH 5.10 085/221] drm/amd/pm: workaround for audio noise issue

2021-03-29 Thread Greg Kroah-Hartman
From: Kenneth Feng 

commit 9d03730ecbc5afabfda26d4dbb014310bc4ea4d9 upstream.

On some Intel platforms, audio noise can be detected due to
high pcie speed switch latency.
This patch leaverages ppfeaturemask to fix to the highest pcie
speed then disable pcie switching.

v2:
coding style fix

Signed-off-by: Kenneth Feng 
Reviewed-by: Alex Deucher 
Signed-off-by: Alex Deucher 
Cc: sta...@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c   |   54 +
 drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c |   74 +++---
 drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_hwmgr.c |   24 +
 drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c |   25 ++
 4 files changed, 166 insertions(+), 11 deletions(-)

--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
@@ -524,6 +524,48 @@ static int smu7_force_switch_to_arbf0(st
tmp, MC_CG_ARB_FREQ_F0);
 }
 
+static uint16_t smu7_override_pcie_speed(struct pp_hwmgr *hwmgr)
+{
+   struct amdgpu_device *adev = (struct amdgpu_device *)(hwmgr->adev);
+   uint16_t pcie_gen = 0;
+
+   if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN4 &&
+   adev->pm.pcie_gen_mask & CAIL_ASIC_PCIE_LINK_SPEED_SUPPORT_GEN4)
+   pcie_gen = 3;
+   else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3 &&
+   adev->pm.pcie_gen_mask & CAIL_ASIC_PCIE_LINK_SPEED_SUPPORT_GEN3)
+   pcie_gen = 2;
+   else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2 &&
+   adev->pm.pcie_gen_mask & CAIL_ASIC_PCIE_LINK_SPEED_SUPPORT_GEN2)
+   pcie_gen = 1;
+   else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN1 &&
+   adev->pm.pcie_gen_mask & CAIL_ASIC_PCIE_LINK_SPEED_SUPPORT_GEN1)
+   pcie_gen = 0;
+
+   return pcie_gen;
+}
+
+static uint16_t smu7_override_pcie_width(struct pp_hwmgr *hwmgr)
+{
+   struct amdgpu_device *adev = (struct amdgpu_device *)(hwmgr->adev);
+   uint16_t pcie_width = 0;
+
+   if (adev->pm.pcie_mlw_mask & CAIL_PCIE_LINK_WIDTH_SUPPORT_X16)
+   pcie_width = 16;
+   else if (adev->pm.pcie_mlw_mask & CAIL_PCIE_LINK_WIDTH_SUPPORT_X12)
+   pcie_width = 12;
+   else if (adev->pm.pcie_mlw_mask & CAIL_PCIE_LINK_WIDTH_SUPPORT_X8)
+   pcie_width = 8;
+   else if (adev->pm.pcie_mlw_mask & CAIL_PCIE_LINK_WIDTH_SUPPORT_X4)
+   pcie_width = 4;
+   else if (adev->pm.pcie_mlw_mask & CAIL_PCIE_LINK_WIDTH_SUPPORT_X2)
+   pcie_width = 2;
+   else if (adev->pm.pcie_mlw_mask & CAIL_PCIE_LINK_WIDTH_SUPPORT_X1)
+   pcie_width = 1;
+
+   return pcie_width;
+}
+
 static int smu7_setup_default_pcie_table(struct pp_hwmgr *hwmgr)
 {
struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend);
@@ -620,6 +662,11 @@ static int smu7_setup_default_pcie_table
PP_Min_PCIEGen),
get_pcie_lane_support(data->pcie_lane_cap,
PP_Max_PCIELane));
+
+   if (data->pcie_dpm_key_disabled)
+   
phm_setup_pcie_table_entry(&data->dpm_table.pcie_speed_table,
+   data->dpm_table.pcie_speed_table.count,
+   smu7_override_pcie_speed(hwmgr), 
smu7_override_pcie_width(hwmgr));
}
return 0;
 }
@@ -1180,6 +1227,13 @@ static int smu7_start_dpm(struct pp_hwmg
NULL)),
"Failed to enable pcie DPM during DPM Start 
Function!",
return -EINVAL);
+   } else {
+   PP_ASSERT_WITH_CODE(
+   (0 == smum_send_msg_to_smc(hwmgr,
+   PPSMC_MSG_PCIeDPM_Disable,
+   NULL)),
+   "Failed to disble pcie DPM during DPM Start 
Function!",
+   return -EINVAL);
}
 
if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c
@@ -54,6 +54,9 @@
 #include "smuio/smuio_9_0_offset.h"
 #include "smuio/smuio_9_0_sh_mask.h"
 
+#define smnPCIE_LC_SPEED_CNTL  0x11140290
+#define smnPCIE_LC_LINK_WIDTH_CNTL 0x11140288
+
 #define HBM_MEMORY_CHANNEL_WIDTH128
 
 static const uint32_t channel_number[] = {1, 2, 0, 4, 0, 8, 0, 16, 2};
@@ -443,8 +446,7 @@ static void vega10_init_dpm_defaults(str
if (PP_CAP(PHM_PlatformCaps_VCEDPM))
data->smu_features[GNLD_DPM_VCE].supported = true;
 
-   if (!data->registry_data.pcie_dpm_key_disabled)
-   data->

[PATCH 5.10 090/221] dm ioctl: fix out of bounds array access when no devices

2021-03-29 Thread Greg Kroah-Hartman
From: Mikulas Patocka 

commit 4edbe1d7bcffcd6269f3b5eb63f710393ff2ec7a upstream.

If there are not any dm devices, we need to zero the "dev" argument in
the first structure dm_name_list. However, this can cause out of
bounds write, because the "needed" variable is zero and len may be
less than eight.

Fix this bug by reporting DM_BUFFER_FULL_FLAG if the result buffer is
too small to hold the "nl->dev" value.

Signed-off-by: Mikulas Patocka 
Reported-by: Dan Carpenter 
Cc: sta...@vger.kernel.org
Signed-off-by: Mike Snitzer 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/md/dm-ioctl.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -529,7 +529,7 @@ static int list_devices(struct file *fil
 * Grab our output buffer.
 */
nl = orig_nl = get_result_buffer(param, param_size, &len);
-   if (len < needed) {
+   if (len < needed || len < sizeof(nl->dev)) {
param->flags |= DM_BUFFER_FULL_FLAG;
goto out;
}




[PATCH 5.10 084/221] drm/etnaviv: Use FOLL_FORCE for userptr

2021-03-29 Thread Greg Kroah-Hartman
From: Daniel Vetter 

commit cd5297b0855f17c8b4e3ef1d20c6a3656209c7b3 upstream.

Nothing checks userptr.ro except this call to pup_fast, which means
there's nothing actually preventing userspace from writing to this.
Which means you can just read-only mmap any file you want, userptr it
and then write to it with the gpu. Not good.

The right way to handle this is FOLL_WRITE | FOLL_FORCE, which will
break any COW mappings and update tracking for MAY_WRITE mappings so
there's no exploit and the vm isn't confused about what's going on.
For any legit use case there's no difference from what userspace can
observe and do.

Reviewed-by: Lucas Stach 
Cc: sta...@vger.kernel.org
Cc: John Hubbard 
Signed-off-by: Daniel Vetter 
Cc: Lucas Stach 
Cc: Russell King 
Cc: Christian Gmeiner 
Cc: etna...@lists.freedesktop.org
Link: 
https://patchwork.freedesktop.org/patch/msgid/20210301095254.1946084-1-daniel.vet...@ffwll.ch
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/gpu/drm/etnaviv/etnaviv_gem.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
@@ -675,7 +675,7 @@ static int etnaviv_gem_userptr_get_pages
struct page **pages = pvec + pinned;
 
ret = pin_user_pages_fast(ptr, num_pages,
- !userptr->ro ? FOLL_WRITE : 0, pages);
+ FOLL_WRITE | FOLL_FORCE, pages);
if (ret < 0) {
unpin_user_pages(pvec, pinned);
kvfree(pvec);




[PATCH 5.10 089/221] dm verity: fix DM_VERITY_OPTS_MAX value

2021-03-29 Thread Greg Kroah-Hartman
From: JeongHyeon Lee 

commit 160f99db943224e55906dd83880da1a704c6e6b9 upstream.

Three optional parameters must be accepted at once in a DM verity table, e.g.:
  (verity_error_handling_mode) (ignore_zero_block) (check_at_most_once)
Fix this to be possible by incrementing DM_VERITY_OPTS_MAX.

Signed-off-by: JeongHyeon Lee 
Fixes: 843f38d382b1 ("dm verity: add 'check_at_most_once' option to only 
validate hashes once")
Cc: sta...@vger.kernel.org
Signed-off-by: Mike Snitzer 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/md/dm-verity-target.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/md/dm-verity-target.c
+++ b/drivers/md/dm-verity-target.c
@@ -34,7 +34,7 @@
 #define DM_VERITY_OPT_IGN_ZEROES   "ignore_zero_blocks"
 #define DM_VERITY_OPT_AT_MOST_ONCE "check_at_most_once"
 
-#define DM_VERITY_OPTS_MAX (2 + DM_VERITY_OPTS_FEC + \
+#define DM_VERITY_OPTS_MAX (3 + DM_VERITY_OPTS_FEC + \
 DM_VERITY_ROOT_HASH_VERIFICATION_OPTS)
 
 static unsigned dm_verity_prefetch_cluster = DM_VERITY_DEFAULT_PREFETCH_SIZE;




[PATCH 5.10 087/221] drm/amdgpu: Add additional Sienna Cichlid PCI ID

2021-03-29 Thread Greg Kroah-Hartman
From: Alex Deucher 

commit c933b111094f2818571fc51b81b98ee0d370c035 upstream.

Add new DID.

Reviewed-by: Guchun Chen 
Signed-off-by: Alex Deucher 
Cc: sta...@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |1 +
 1 file changed, 1 insertion(+)

--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1093,6 +1093,7 @@ static const struct pci_device_id pciidl
{0x1002, 0x73A3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SIENNA_CICHLID},
{0x1002, 0x73AB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SIENNA_CICHLID},
{0x1002, 0x73AE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SIENNA_CICHLID},
+   {0x1002, 0x73AF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SIENNA_CICHLID},
{0x1002, 0x73BF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SIENNA_CICHLID},
 
{0, 0, 0}




[PATCH 5.10 088/221] drm/i915: Fix the GT fence revocation runtime PM logic

2021-03-29 Thread Greg Kroah-Hartman
From: Imre Deak 

commit 8840e3bd981f128846b01c12d3966d115e8617c9 upstream.

To optimize some task deferring it until runtime resume unless someone
holds a runtime PM reference (because in this case the task can be done
w/o the overhead of runtime resume), we have to use the runtime PM
get-if-active logic: If the runtime PM usage count is 0 (and so
get-if-in-use would return false) the runtime suspend handler is not
necessarily called yet (it could be just pending), so the device is not
necessarily powered down, and so the runtime resume handler is not
guaranteed to be called.

The fence revocation depends on the above deferral, so add a
get-if-active helper and use it during fence revocation.

v2:
- Add code comment explaining the fence reg programming deferral logic
  to i915_vma_revoke_fence(). (Chris)
- Add Cc: stable and Fixes: tags. (Chris)
- Fix the function docbook comment.

Cc: Chris Wilson 
Cc:  # v4.12+
Fixes: 181df2d458f3 ("drm/i915: Take rpm wakelock for releasing the fence on 
unbind")
Reviewed-by: Chris Wilson 
Signed-off-by: Imre Deak 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20210322204223.919936-1-imre.d...@intel.com
(cherry picked from commit 9d58aa46291d4d696bb1eac3436d3118f7bf2573)
Signed-off-by: Rodrigo Vivi 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c |   13 +++-
 drivers/gpu/drm/i915/intel_runtime_pm.c  |   29 ++-
 drivers/gpu/drm/i915/intel_runtime_pm.h  |5 
 3 files changed, 41 insertions(+), 6 deletions(-)

--- a/drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c
+++ b/drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c
@@ -316,7 +316,18 @@ void i915_vma_revoke_fence(struct i915_v
WRITE_ONCE(fence->vma, NULL);
vma->fence = NULL;
 
-   with_intel_runtime_pm_if_in_use(fence_to_uncore(fence)->rpm, wakeref)
+   /*
+* Skip the write to HW if and only if the device is currently
+* suspended.
+*
+* If the driver does not currently hold a wakeref (if_in_use == 0),
+* the device may currently be runtime suspended, or it may be woken
+* up before the suspend takes place. If the device is not suspended
+* (powered down) and we skip clearing the fence register, the HW is
+* left in an undefined state where we may end up with multiple
+* registers overlapping.
+*/
+   with_intel_runtime_pm_if_active(fence_to_uncore(fence)->rpm, wakeref)
fence_write(fence);
 }
 
--- a/drivers/gpu/drm/i915/intel_runtime_pm.c
+++ b/drivers/gpu/drm/i915/intel_runtime_pm.c
@@ -412,12 +412,20 @@ intel_wakeref_t intel_runtime_pm_get(str
 }
 
 /**
- * intel_runtime_pm_get_if_in_use - grab a runtime pm reference if device in 
use
+ * __intel_runtime_pm_get_if_active - grab a runtime pm reference if device is 
active
  * @rpm: the intel_runtime_pm structure
+ * @ignore_usecount: get a ref even if dev->power.usage_count is 0
  *
  * This function grabs a device-level runtime pm reference if the device is
- * already in use and ensures that it is powered up. It is illegal to try
- * and access the HW should intel_runtime_pm_get_if_in_use() report failure.
+ * already active and ensures that it is powered up. It is illegal to try
+ * and access the HW should intel_runtime_pm_get_if_active() report failure.
+ *
+ * If @ignore_usecount=true, a reference will be acquired even if there is no
+ * user requiring the device to be powered up (dev->power.usage_count == 0).
+ * If the function returns false in this case then it's guaranteed that the
+ * device's runtime suspend hook has been called already or that it will be
+ * called (and hence it's also guaranteed that the device's runtime resume
+ * hook will be called eventually).
  *
  * Any runtime pm reference obtained by this function must have a symmetric
  * call to intel_runtime_pm_put() to release the reference again.
@@ -425,7 +433,8 @@ intel_wakeref_t intel_runtime_pm_get(str
  * Returns: the wakeref cookie to pass to intel_runtime_pm_put(), evaluates
  * as True if the wakeref was acquired, or False otherwise.
  */
-intel_wakeref_t intel_runtime_pm_get_if_in_use(struct intel_runtime_pm *rpm)
+static intel_wakeref_t __intel_runtime_pm_get_if_active(struct 
intel_runtime_pm *rpm,
+   bool ignore_usecount)
 {
if (IS_ENABLED(CONFIG_PM)) {
/*
@@ -434,7 +443,7 @@ intel_wakeref_t intel_runtime_pm_get_if_
 * function, since the power state is undefined. This applies
 * atm to the late/early system suspend/resume handlers.
 */
-   if (pm_runtime_get_if_in_use(rpm->kdev) <= 0)
+   if (pm_runtime_get_if_active(rpm->kdev, ignore_usecount) <= 0)
return 0;
}
 
@@ -443,6 +452,16 @@ intel_wakeref_t intel_runtime_pm_get_if_
return track_intel_runtime_pm_wakeref(rpm);
 }
 
+intel_wakeref_t i

[PATCH 5.10 093/221] soc: ti: omap-prm: Fix occasional abort on reset deassert for dra7 iva

2021-03-29 Thread Greg Kroah-Hartman
From: Tony Lindgren 

[ Upstream commit effe89e40037038db7711bdab5d3401fe297d72c ]

On reset deassert, we must wait a bit after the rstst bit change before
we allow clockdomain autoidle again. Otherwise we get the following oops
sometimes on dra7 with iva:

Unhandled fault: imprecise external abort (0x1406) at 0x
4400.ocp:L3 Standard Error: MASTER MPU TARGET IVA_CONFIG (Read Link):
At Address: 0x0005A410 : Data Access in User mode during Functional access
Internal error: : 1406 [#1] SMP ARM
...
(sysc_write_sysconfig) from [] (sysc_enable_module+0xcc/0x260)
(sysc_enable_module) from [] (sysc_runtime_resume+0xc8/0x174)
(sysc_runtime_resume) from [] (genpd_runtime_resume+0x94/0x224)
(genpd_runtime_resume) from [] (__rpm_callback+0xd8/0x180)

It is unclear what all devices this might affect, but presumably other
devices with the rstst bit too can be affected. So let's just enable the
delay for all the devices with rstst bit for now. Later on we may want to
limit the list to the know affected devices if needed.

Fixes: d30cd83f6853 ("soc: ti: omap-prm: add support for denying idle for reset 
clockdomain")
Reported-by: Yongqin Liu 
Signed-off-by: Tony Lindgren 
Signed-off-by: Sasha Levin 
---
 drivers/soc/ti/omap_prm.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/ti/omap_prm.c b/drivers/soc/ti/omap_prm.c
index c8b14b3a171f..fb067b5e4a97 100644
--- a/drivers/soc/ti/omap_prm.c
+++ b/drivers/soc/ti/omap_prm.c
@@ -522,8 +522,12 @@ static int omap_reset_deassert(struct reset_controller_dev 
*rcdev,
   reset->prm->data->name, id);
 
 exit:
-   if (reset->clkdm)
+   if (reset->clkdm) {
+   /* At least dra7 iva needs a delay before clkdm idle */
+   if (has_rstst)
+   udelay(1);
pdata->clkdm_allow_idle(reset->clkdm);
+   }
 
return ret;
 }
-- 
2.30.1





[PATCH 5.10 086/221] drm/amdgpu/display: restore AUX_DPHY_TX_CONTROL for DCN2.x

2021-03-29 Thread Greg Kroah-Hartman
From: Alex Deucher 

commit 5c458585c0141754cdcbf25feebb547dd671b559 upstream.

Commit 098214999c8f added fetching of the AUX_DPHY register
values from the vbios, but it also changed the default values
in the case when there are no values in the vbios.  This causes
problems with displays with high refresh rates.  To fix this,
switch back to the original default value for AUX_DPHY_TX_CONTROL.

Fixes: 098214999c8f ("drm/amd/display: Read VBIOS Golden Settings Tbl")
Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1426
Reviewed-by: Harry Wentland 
Signed-off-by: Alex Deucher 
Cc: Igor Kravchenko 
Cc: Aric Cyr 
Cc: Aurabindo Pillai 
Cc: sta...@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/gpu/drm/amd/display/dc/dcn20/dcn20_link_encoder.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_link_encoder.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_link_encoder.c
@@ -341,8 +341,7 @@ void enc2_hw_init(struct link_encoder *e
} else {
AUX_REG_WRITE(AUX_DPHY_RX_CONTROL0, 0x103d1110);
 
-   AUX_REG_WRITE(AUX_DPHY_TX_CONTROL, 0x21c4d);
-
+   AUX_REG_WRITE(AUX_DPHY_TX_CONTROL, 0x21c7a);
}
 
//AUX_DPHY_TX_REF_CONTROL'AUX_TX_REF_DIV HW default is 0x32;




[PATCH 5.10 094/221] veth: Store queue_mapping independently of XDP prog presence

2021-03-29 Thread Greg Kroah-Hartman
From: Maciej Fijalkowski 

[ Upstream commit edbea922025169c0e5cdca5ebf7bf5374cc5566c ]

Currently, veth_xmit() would call the skb_record_rx_queue() only when
there is XDP program loaded on peer interface in native mode.

If peer has XDP prog in generic mode, then netif_receive_generic_xdp()
has a call to netif_get_rxqueue(skb), so for multi-queue veth it will
not be possible to grab a correct rxq.

To fix that, store queue_mapping independently of XDP prog presence on
peer interface.

Fixes: 638264dc9022 ("veth: Support per queue XDP ring")
Signed-off-by: Maciej Fijalkowski 
Signed-off-by: Daniel Borkmann 
Acked-by: Toshiaki Makita 
Link: 
https://lore.kernel.org/bpf/20210303152903.11172-1-maciej.fijalkow...@intel.com
Signed-off-by: Sasha Levin 
---
 drivers/net/veth.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 8c737668008a..be18b243642f 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -301,8 +301,7 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct 
net_device *dev)
if (rxq < rcv->real_num_rx_queues) {
rq = &rcv_priv->rq[rxq];
rcv_xdp = rcu_access_pointer(rq->xdp_prog);
-   if (rcv_xdp)
-   skb_record_rx_queue(skb, rxq);
+   skb_record_rx_queue(skb, rxq);
}
 
skb_tx_timestamp(skb);
-- 
2.30.1





[PATCH 5.10 097/221] net/mlx5e: RX, Mind the MPWQE gaps when calculating offsets

2021-03-29 Thread Greg Kroah-Hartman
From: Tariq Toukan 

[ Upstream commit d5dd03b26ba49c4ffe67ee1937add82293c19794 ]

Since cited patch, MLX5E_REQUIRED_WQE_MTTS is not a power of two.
Hence, usage of MLX5E_LOG_ALIGNED_MPWQE_PPW should be replaced,
as it lost some accuracy. Use the designated macro to calculate
the number of required MTTs.

This makes sure the solution in cited patch works properly.

While here, un-inline mlx5e_get_mpwqe_offset(), and remove the
unused RQ parameter.

Fixes: c3c9402373fe ("net/mlx5e: Add resiliency in Striding RQ mode for packets 
larger than MTU")
Signed-off-by: Tariq Toukan 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/mellanox/mlx5/core/en.h  | 7 ---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 6 +++---
 drivers/net/ethernet/mellanox/mlx5/core/en_rx.c   | 4 ++--
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h 
b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 2f05b0f9de01..9da34f82d466 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -90,14 +90,15 @@ struct page_pool;
MLX5_MPWRQ_LOG_WQE_SZ - PAGE_SHIFT : 0)
 #define MLX5_MPWRQ_PAGES_PER_WQE   BIT(MLX5_MPWRQ_WQE_PAGE_ORDER)
 
-#define MLX5_MTT_OCTW(npages) (ALIGN(npages, 8) / 2)
+#define MLX5_ALIGN_MTTS(mtts)  (ALIGN(mtts, 8))
+#define MLX5_ALIGNED_MTTS_OCTW(mtts)   ((mtts) / 2)
+#define MLX5_MTT_OCTW(mtts)
(MLX5_ALIGNED_MTTS_OCTW(MLX5_ALIGN_MTTS(mtts)))
 /* Add another page to MLX5E_REQUIRED_WQE_MTTS as a buffer between
  * WQEs, This page will absorb write overflow by the hardware, when
  * receiving packets larger than MTU. These oversize packets are
  * dropped by the driver at a later stage.
  */
-#define MLX5E_REQUIRED_WQE_MTTS(ALIGN(MLX5_MPWRQ_PAGES_PER_WQE 
+ 1, 8))
-#define MLX5E_LOG_ALIGNED_MPWQE_PPW(ilog2(MLX5E_REQUIRED_WQE_MTTS))
+#define MLX5E_REQUIRED_WQE_MTTS
(MLX5_ALIGN_MTTS(MLX5_MPWRQ_PAGES_PER_WQE + 1))
 #define MLX5E_REQUIRED_MTTS(wqes)  (wqes * MLX5E_REQUIRED_WQE_MTTS)
 #define MLX5E_MAX_RQ_NUM_MTTS  \
((1 << 16) * 2) /* So that MLX5_MTT_OCTW(num_mtts) fits into u16 */
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 6394f9d8c685..8b0826d689c0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -303,9 +303,9 @@ static int mlx5e_create_rq_umr_mkey(struct mlx5_core_dev 
*mdev, struct mlx5e_rq
 rq->wqe_overflow.addr);
 }
 
-static inline u64 mlx5e_get_mpwqe_offset(struct mlx5e_rq *rq, u16 wqe_ix)
+static u64 mlx5e_get_mpwqe_offset(u16 wqe_ix)
 {
-   return (wqe_ix << MLX5E_LOG_ALIGNED_MPWQE_PPW) << PAGE_SHIFT;
+   return MLX5E_REQUIRED_MTTS(wqe_ix) << PAGE_SHIFT;
 }
 
 static void mlx5e_init_frags_partition(struct mlx5e_rq *rq)
@@ -544,7 +544,7 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
mlx5_wq_ll_get_wqe(&rq->mpwqe.wq, i);
u32 byte_count =
rq->mpwqe.num_strides << 
rq->mpwqe.log_stride_sz;
-   u64 dma_offset = mlx5e_get_mpwqe_offset(rq, i);
+   u64 dma_offset = mlx5e_get_mpwqe_offset(i);
 
wqe->data[0].addr = cpu_to_be64(dma_offset + 
rq->buff.headroom);
wqe->data[0].byte_count = cpu_to_be32(byte_count);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index 6d2ba8b84187..7e1f8660dfec 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -506,7 +506,6 @@ static int mlx5e_alloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix)
struct mlx5e_icosq *sq = &rq->channel->icosq;
struct mlx5_wq_cyc *wq = &sq->wq;
struct mlx5e_umr_wqe *umr_wqe;
-   u16 xlt_offset = ix << (MLX5E_LOG_ALIGNED_MPWQE_PPW - 1);
u16 pi;
int err;
int i;
@@ -537,7 +536,8 @@ static int mlx5e_alloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix)
umr_wqe->ctrl.opmod_idx_opcode =
cpu_to_be32((sq->pc << MLX5_WQE_CTRL_WQE_INDEX_SHIFT) |
MLX5_OPCODE_UMR);
-   umr_wqe->uctrl.xlt_offset = cpu_to_be16(xlt_offset);
+   umr_wqe->uctrl.xlt_offset =
+   cpu_to_be16(MLX5_ALIGNED_MTTS_OCTW(MLX5E_REQUIRED_MTTS(ix)));
 
sq->db.wqe_info[pi] = (struct mlx5e_icosq_wqe_info) {
.wqe_type   = MLX5E_ICOSQ_WQE_UMR_RX,
-- 
2.30.1





[PATCH 5.10 095/221] bpf: Change inode_storages lookup_elem return value from NULL to -EBADF

2021-03-29 Thread Greg Kroah-Hartman
From: Tal Lossos 

[ Upstream commit 769c18b254ca191b45047e1fcb3b2ce56fada0b6 ]

bpf_fd_inode_storage_lookup_elem() returned NULL when getting a bad FD,
which caused -ENOENT in bpf_map_copy_value. -EBADF error is better than
-ENOENT for a bad FD behaviour.

The patch was partially contributed by CyberArk Software, Inc.

Fixes: 8ea636848aca ("bpf: Implement bpf_local_storage for inodes")
Signed-off-by: Tal Lossos 
Signed-off-by: Daniel Borkmann 
Acked-by: Yonghong Song 
Acked-by: KP Singh 
Link: https://lore.kernel.org/bpf/20210307120948.61414-1-tallos...@gmail.com
Signed-off-by: Sasha Levin 
---
 kernel/bpf/bpf_inode_storage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/bpf/bpf_inode_storage.c b/kernel/bpf/bpf_inode_storage.c
index c2a501cd90eb..a4ac48c7dada 100644
--- a/kernel/bpf/bpf_inode_storage.c
+++ b/kernel/bpf/bpf_inode_storage.c
@@ -109,7 +109,7 @@ static void *bpf_fd_inode_storage_lookup_elem(struct 
bpf_map *map, void *key)
fd = *(int *)key;
f = fget_raw(fd);
if (!f)
-   return NULL;
+   return ERR_PTR(-EBADF);
 
sdata = inode_storage_lookup(f->f_inode, map, true);
fput(f);
-- 
2.30.1





[PATCH 5.10 068/221] z3fold: prevent reclaim/free race for headless pages

2021-03-29 Thread Greg Kroah-Hartman
From: Thomas Hebb 

commit 6d679578fe9c762c8fbc3d796a067cbba84a7884 upstream.

Commit ca0246bb97c2 ("z3fold: fix possible reclaim races") introduced
the PAGE_CLAIMED flag "to avoid racing on a z3fold 'headless' page
release." By atomically testing and setting the bit in each of
z3fold_free() and z3fold_reclaim_page(), a double-free was avoided.

However, commit dcf5aedb24f8 ("z3fold: stricter locking and more careful
reclaim") appears to have unintentionally broken this behavior by moving
the PAGE_CLAIMED check in z3fold_reclaim_page() to after the page lock
gets taken, which only happens for non-headless pages.  For headless
pages, the check is now skipped entirely and races can occur again.

I have observed such a race on my system:

page:ffbd76b7 refcount:0 mapcount:0 mapping: 
index:0x0 pfn:0x165316
flags: 0x200()
raw: 0200 ea0004535f48 8881d553a170 
raw:  0011  
page dumped because: VM_BUG_ON_PAGE(page_ref_count(page) == 0)
[ cut here ]
kernel BUG at include/linux/mm.h:707!
invalid opcode:  [#1] PREEMPT SMP KASAN PTI
CPU: 2 PID: 291928 Comm: kworker/2:0 Tainted: GB 
5.10.7-arch1-1-kasan #1
Hardware name: Gigabyte Technology Co., Ltd. H97N-WIFI/H97N-WIFI, BIOS F9b 
03/03/2016
Workqueue: zswap-shrink shrink_worker
RIP: 0010:__free_pages+0x10a/0x130
Code: c1 e7 06 48 01 ef 45 85 e4 74 d1 44 89 e6 31 d2 41 83 ec 01 e8 e7 b0 
ff ff eb da 48 c7 c6 e0 32 91 88 48 89 ef e8 a6 89 f8 ff <0f> 0b 4c 89 e7 e8 fc 
79 07 00 e9 33 ff ff ff 48 89 ef e8 ff 79 07
RSP: :88819a2ffb98 EFLAGS: 00010296
RAX:  RBX: ea000594c5a8 RCX: 
RDX: 1d4000b298b7 RSI:  RDI: ea000594c5b8
RBP: ea000594c580 R08: 003e R09: 8881d5520bbb
R10: ed103aaa4177 R11: 0001 R12: ea000594c5b4
R13:  R14: 888165316000 R15: ea000594c588
FS:  () GS:8881d550() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 7f7c8c3654d8 CR3: 000103f42004 CR4: 001706e0
Call Trace:
 z3fold_zpool_shrink+0x9b6/0x1240
 shrink_worker+0x35/0x90
 process_one_work+0x70c/0x1210
 worker_thread+0x539/0x1200
 kthread+0x330/0x400
 ret_from_fork+0x22/0x30
Modules linked in: rfcomm ebtable_filter ebtables ip6table_filter 
ip6_tables iptable_filter ccm algif_aead des_generic libdes ecb algif_skcipher 
cmac bnep md4 algif_hash af_alg vfat fat intel_rapl_msr intel_rapl_common 
x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel iwlmvm 
hid_logitech_hidpp kvm at24 mac80211 snd_hda_codec_realtek iTCO_wdt 
snd_hda_codec_generic intel_pmc_bxt snd_hda_codec_hdmi ledtrig_audio 
iTCO_vendor_support mei_wdt mei_hdcp snd_hda_intel snd_intel_dspcfg libarc4 
soundwire_intel irqbypass iwlwifi soundwire_generic_allocation rapl 
soundwire_cadence intel_cstate snd_hda_codec intel_uncore btusb joydev mousedev 
snd_usb_audio pcspkr btrtl uvcvideo nouveau btbcm i2c_i801 btintel snd_hda_core 
videobuf2_vmalloc i2c_smbus snd_usbmidi_lib videobuf2_memops bluetooth 
snd_hwdep soundwire_bus snd_soc_rt5640 videobuf2_v4l2 cfg80211 snd_soc_rl6231 
videobuf2_common snd_rawmidi lpc_ich alx videodev mdio snd_seq_device 
snd_soc_core mc ecdh_generic mxm_wmi mei_me
 hid_logitech_dj wmi snd_compress e1000e ac97_bus mei ttm rfkill 
snd_pcm_dmaengine ecc snd_pcm snd_timer snd soundcore mac_hid acpi_pad 
pkcs8_key_parser it87 hwmon_vid crypto_user fuse ip_tables x_tables ext4 
crc32c_generic crc16 mbcache jbd2 dm_crypt cbc encrypted_keys trusted tpm 
rng_core usbhid dm_mod crct10dif_pclmul crc32_pclmul crc32c_intel 
ghash_clmulni_intel aesni_intel crypto_simd cryptd glue_helper xhci_pci 
xhci_pci_renesas i915 video intel_gtt i2c_algo_bit drm_kms_helper syscopyarea 
sysfillrect sysimgblt fb_sys_fops cec drm agpgart
---[ end trace 126d646fc3dc0ad8 ]---

To fix the issue, re-add the earlier test and set in the case where we
have a headless page.

Link: 
https://lkml.kernel.org/r/c8106dbe6d8390b290cd1d7f873a2942e805349e.1615452048.git.tommyh...@gmail.com
Fixes: dcf5aedb24f8 ("z3fold: stricter locking and more careful reclaim")
Signed-off-by: Thomas Hebb 
Reviewed-by: Vitaly Wool 
Cc: Jongseok Kim 
Cc: Snild Dolkow 
Cc: 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Greg Kroah-Hartman 
---
 mm/z3fold.c |   16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

--- a/mm/z3fold.c
+++ b/mm/z3fold.c
@@ -1350,8 +1350,22 @@ static int z3fold_reclaim_page(struct z3
page = list_entry(pos, struct page, lru);
 
zhdr = page_address(page);
-   if (test_bit(PAGE_HEADLESS, &page->private))
+   if (test_bit(

[PATCH 5.10 067/221] psample: Fix user API breakage

2021-03-29 Thread Greg Kroah-Hartman
From: Ido Schimmel 

commit e43accba9b071dcd106b5e7643b1b106a158cbb1 upstream.

Cited commit added a new attribute before the existing group reference
count attribute, thereby changing its value and breaking existing
applications on new kernels.

Before:

 # psample -l
 libpsample ERROR psample_group_foreach: failed to recv message: Operation not 
supported

After:

 # psample -l
 Group Num   RefcountGroup Seq
 1   1   0

Fix by restoring the value of the old attribute and remove the
misleading comments from the enumerator to avoid future bugs.

Cc: sta...@vger.kernel.org
Fixes: d8bed686ab96 ("net: psample: Add tunnel support")
Signed-off-by: Ido Schimmel 
Reported-by: Adiel Bidani 
Reviewed-by: Jiri Pirko 
Reviewed-by: Petr Machata 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 include/uapi/linux/psample.h |5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

--- a/include/uapi/linux/psample.h
+++ b/include/uapi/linux/psample.h
@@ -3,7 +3,6 @@
 #define __UAPI_PSAMPLE_H
 
 enum {
-   /* sampled packet metadata */
PSAMPLE_ATTR_IIFINDEX,
PSAMPLE_ATTR_OIFINDEX,
PSAMPLE_ATTR_ORIGSIZE,
@@ -11,10 +10,8 @@ enum {
PSAMPLE_ATTR_GROUP_SEQ,
PSAMPLE_ATTR_SAMPLE_RATE,
PSAMPLE_ATTR_DATA,
-   PSAMPLE_ATTR_TUNNEL,
-
-   /* commands attributes */
PSAMPLE_ATTR_GROUP_REFCOUNT,
+   PSAMPLE_ATTR_TUNNEL,
 
__PSAMPLE_ATTR_MAX
 };




[PATCH 5.10 069/221] squashfs: fix inode lookup sanity checks

2021-03-29 Thread Greg Kroah-Hartman
From: Sean Nyekjaer 

commit c1b2028315c6b15e8d6725e0d5884b15887d3daa upstream.

When mouting a squashfs image created without inode compression it fails
with: "unable to read inode lookup table"

It turns out that the BLOCK_OFFSET is missing when checking the
SQUASHFS_METADATA_SIZE agaist the actual size.

Link: https://lkml.kernel.org/r/20210226092903.1473545-1-s...@geanix.com
Fixes: eabac19e40c0 ("squashfs: add more sanity checks in inode lookup")
Signed-off-by: Sean Nyekjaer 
Acked-by: Phillip Lougher 
Cc: 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Greg Kroah-Hartman 
---
 fs/squashfs/export.c  |8 ++--
 fs/squashfs/squashfs_fs.h |1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

--- a/fs/squashfs/export.c
+++ b/fs/squashfs/export.c
@@ -152,14 +152,18 @@ __le64 *squashfs_read_inode_lookup_table
start = le64_to_cpu(table[n]);
end = le64_to_cpu(table[n + 1]);
 
-   if (start >= end || (end - start) > SQUASHFS_METADATA_SIZE) {
+   if (start >= end
+   || (end - start) >
+   (SQUASHFS_METADATA_SIZE + SQUASHFS_BLOCK_OFFSET)) {
kfree(table);
return ERR_PTR(-EINVAL);
}
}
 
start = le64_to_cpu(table[indexes - 1]);
-   if (start >= lookup_table_start || (lookup_table_start - start) > 
SQUASHFS_METADATA_SIZE) {
+   if (start >= lookup_table_start ||
+   (lookup_table_start - start) >
+   (SQUASHFS_METADATA_SIZE + SQUASHFS_BLOCK_OFFSET)) {
kfree(table);
return ERR_PTR(-EINVAL);
}
--- a/fs/squashfs/squashfs_fs.h
+++ b/fs/squashfs/squashfs_fs.h
@@ -17,6 +17,7 @@
 
 /* size of metadata (inode and directory) blocks */
 #define SQUASHFS_METADATA_SIZE 8192
+#define SQUASHFS_BLOCK_OFFSET  2
 
 /* default size of block device I/O */
 #ifdef CONFIG_SQUASHFS_4K_DEVBLK_SIZE




[PATCH 5.10 070/221] squashfs: fix xattr id and id lookup sanity checks

2021-03-29 Thread Greg Kroah-Hartman
From: Phillip Lougher 

commit 8b44ca2b634527151af07447a8090a5f3a043321 upstream.

The checks for maximum metadata block size is missing
SQUASHFS_BLOCK_OFFSET (the two byte length count).

Link: 
https://lkml.kernel.org/r/2069685113.2081245.1614583677...@webmail.123-reg.co.uk
Fixes: f37aa4c7366e23f ("squashfs: add more sanity checks in id lookup")
Signed-off-by: Phillip Lougher 
Cc: Sean Nyekjaer 
Cc: 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Greg Kroah-Hartman 
---
 fs/squashfs/id.c   |6 --
 fs/squashfs/xattr_id.c |6 --
 2 files changed, 8 insertions(+), 4 deletions(-)

--- a/fs/squashfs/id.c
+++ b/fs/squashfs/id.c
@@ -97,14 +97,16 @@ __le64 *squashfs_read_id_index_table(str
start = le64_to_cpu(table[n]);
end = le64_to_cpu(table[n + 1]);
 
-   if (start >= end || (end - start) > SQUASHFS_METADATA_SIZE) {
+   if (start >= end || (end - start) >
+   (SQUASHFS_METADATA_SIZE + 
SQUASHFS_BLOCK_OFFSET)) {
kfree(table);
return ERR_PTR(-EINVAL);
}
}
 
start = le64_to_cpu(table[indexes - 1]);
-   if (start >= id_table_start || (id_table_start - start) > 
SQUASHFS_METADATA_SIZE) {
+   if (start >= id_table_start || (id_table_start - start) >
+   (SQUASHFS_METADATA_SIZE + 
SQUASHFS_BLOCK_OFFSET)) {
kfree(table);
return ERR_PTR(-EINVAL);
}
--- a/fs/squashfs/xattr_id.c
+++ b/fs/squashfs/xattr_id.c
@@ -109,14 +109,16 @@ __le64 *squashfs_read_xattr_id_table(str
start = le64_to_cpu(table[n]);
end = le64_to_cpu(table[n + 1]);
 
-   if (start >= end || (end - start) > SQUASHFS_METADATA_SIZE) {
+   if (start >= end || (end - start) >
+   (SQUASHFS_METADATA_SIZE + 
SQUASHFS_BLOCK_OFFSET)) {
kfree(table);
return ERR_PTR(-EINVAL);
}
}
 
start = le64_to_cpu(table[indexes - 1]);
-   if (start >= table_start || (table_start - start) > 
SQUASHFS_METADATA_SIZE) {
+   if (start >= table_start || (table_start - start) >
+   (SQUASHFS_METADATA_SIZE + 
SQUASHFS_BLOCK_OFFSET)) {
kfree(table);
return ERR_PTR(-EINVAL);
}




[PATCH 5.10 109/221] e1000e: add rtnl_lock() to e1000_reset_task

2021-03-29 Thread Greg Kroah-Hartman
From: Vitaly Lifshits 

[ Upstream commit 21f857f0321d0d0ea9b1a758bd55dc63d1cb2437 ]

A possible race condition was found in e1000_reset_task,
after discovering a similar issue in igb driver via
commit 024a8168b749 ("igb: reinit_locked() should be called
with rtnl_lock").

Added rtnl_lock() and rtnl_unlock() to avoid this.

Fixes: bc7f75fa9788 ("[E1000E]: New pci-express e1000 driver (currently for 
ICH9 devices only)")
Suggested-by: Jakub Kicinski 
Signed-off-by: Vitaly Lifshits 
Tested-by: Dvora Fuxbrumer 
Signed-off-by: Tony Nguyen 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/intel/e1000e/netdev.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c 
b/drivers/net/ethernet/intel/e1000e/netdev.c
index e9b82c209c2d..a0948002ddf8 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -5974,15 +5974,19 @@ static void e1000_reset_task(struct work_struct *work)
struct e1000_adapter *adapter;
adapter = container_of(work, struct e1000_adapter, reset_task);
 
+   rtnl_lock();
/* don't run the task if already down */
-   if (test_bit(__E1000_DOWN, &adapter->state))
+   if (test_bit(__E1000_DOWN, &adapter->state)) {
+   rtnl_unlock();
return;
+   }
 
if (!(adapter->flags & FLAG_RESTART_NOW)) {
e1000e_dump(adapter);
e_err("Reset adapter unexpectedly\n");
}
e1000e_reinit_locked(adapter);
+   rtnl_unlock();
 }
 
 /**
-- 
2.30.1





[PATCH 5.10 071/221] hugetlb_cgroup: fix imbalanced css_get and css_put pair for shared mappings

2021-03-29 Thread Greg Kroah-Hartman
From: Miaohe Lin 

commit d85aecf2844ff02a0e5f077252b2461d4f10c9f0 upstream.

The current implementation of hugetlb_cgroup for shared mappings could
have different behavior.  Consider the following two scenarios:

 1.Assume initial css reference count of hugetlb_cgroup is 1:
  1.1 Call hugetlb_reserve_pages with from = 1, to = 2. So css reference
  count is 2 associated with 1 file_region.
  1.2 Call hugetlb_reserve_pages with from = 2, to = 3. So css reference
  count is 3 associated with 2 file_region.
  1.3 coalesce_file_region will coalesce these two file_regions into
  one. So css reference count is 3 associated with 1 file_region
  now.

 2.Assume initial css reference count of hugetlb_cgroup is 1 again:
  2.1 Call hugetlb_reserve_pages with from = 1, to = 3. So css reference
  count is 2 associated with 1 file_region.

Therefore, we might have one file_region while holding one or more css
reference counts. This inconsistency could lead to imbalanced css_get()
and css_put() pair. If we do css_put one by one (i.g. hole punch case),
scenario 2 would put one more css reference. If we do css_put all
together (i.g. truncate case), scenario 1 will leak one css reference.

The imbalanced css_get() and css_put() pair would result in a non-zero
reference when we try to destroy the hugetlb cgroup. The hugetlb cgroup
directory is removed __but__ associated resource is not freed. This
might result in OOM or can not create a new hugetlb cgroup in a busy
workload ultimately.

In order to fix this, we have to make sure that one file_region must
hold exactly one css reference. So in coalesce_file_region case, we
should release one css reference before coalescence. Also only put css
reference when the entire file_region is removed.

The last thing to note is that the caller of region_add() will only hold
one reference to h_cg->css for the whole contiguous reservation region.
But this area might be scattered when there are already some
file_regions reside in it. As a result, many file_regions may share only
one h_cg->css reference. In order to ensure that one file_region must
hold exactly one css reference, we should do css_get() for each
file_region and release the reference held by caller when they are done.

[linmia...@huawei.com: fix imbalanced css_get and css_put pair for shared 
mappings]
  Link: https://lkml.kernel.org/r/20210316023002.53921-1-linmia...@huawei.com

Link: https://lkml.kernel.org/r/20210301120540.37076-1-linmia...@huawei.com
Fixes: 075a61d07a8e ("hugetlb_cgroup: add accounting for shared mappings")
Reported-by: kernel test robot  (auto build test ERROR)
Signed-off-by: Miaohe Lin 
Reviewed-by: Mike Kravetz 
Cc: Aneesh Kumar K.V 
Cc: Wanpeng Li 
Cc: Mina Almasry 
Cc: 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Greg Kroah-Hartman 
---
 include/linux/hugetlb_cgroup.h |   15 +--
 mm/hugetlb.c   |   41 +
 mm/hugetlb_cgroup.c|   10 --
 3 files changed, 58 insertions(+), 8 deletions(-)

--- a/include/linux/hugetlb_cgroup.h
+++ b/include/linux/hugetlb_cgroup.h
@@ -113,6 +113,11 @@ static inline bool hugetlb_cgroup_disabl
return !cgroup_subsys_enabled(hugetlb_cgrp_subsys);
 }
 
+static inline void hugetlb_cgroup_put_rsvd_cgroup(struct hugetlb_cgroup *h_cg)
+{
+   css_put(&h_cg->css);
+}
+
 extern int hugetlb_cgroup_charge_cgroup(int idx, unsigned long nr_pages,
struct hugetlb_cgroup **ptr);
 extern int hugetlb_cgroup_charge_cgroup_rsvd(int idx, unsigned long nr_pages,
@@ -138,7 +143,8 @@ extern void hugetlb_cgroup_uncharge_coun
 
 extern void hugetlb_cgroup_uncharge_file_region(struct resv_map *resv,
struct file_region *rg,
-   unsigned long nr_pages);
+   unsigned long nr_pages,
+   bool region_del);
 
 extern void hugetlb_cgroup_file_init(void) __init;
 extern void hugetlb_cgroup_migrate(struct page *oldhpage,
@@ -147,7 +153,8 @@ extern void hugetlb_cgroup_migrate(struc
 #else
 static inline void hugetlb_cgroup_uncharge_file_region(struct resv_map *resv,
   struct file_region *rg,
-  unsigned long nr_pages)
+  unsigned long nr_pages,
+  bool region_del)
 {
 }
 
@@ -185,6 +192,10 @@ static inline bool hugetlb_cgroup_disabl
return true;
 }
 
+static inline void hugetlb_cgroup_put_rsvd_cgroup(struct hugetlb_cgroup *h_cg)
+{
+}
+
 static inline int hugetlb_cgroup_charge_cgroup(int idx, unsigned long nr_pages,
   struct hugetlb_cgroup **ptr)
 {
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -28

[PATCH 5.10 062/221] btrfs: fix sleep while in non-sleep context during qgroup removal

2021-03-29 Thread Greg Kroah-Hartman
From: Filipe Manana 

commit 0bb788300990d3eb5582d3301a720f846c78925c upstream.

While removing a qgroup's sysfs entry we end up taking the kernfs_mutex,
through kobject_del(), while holding the fs_info->qgroup_lock spinlock,
producing the following trace:

  [821.843637] BUG: sleeping function called from invalid context at 
kernel/locking/mutex.c:281
  [821.843641] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 28214, 
name: podman
  [821.843644] CPU: 3 PID: 28214 Comm: podman Tainted: GW 
5.11.6 #15
  [821.843646] Hardware name: Dell Inc. PowerEdge R330/084XW4, BIOS 2.11.0 
12/08/2020
  [821.843647] Call Trace:
  [821.843650]  dump_stack+0xa1/0xfb
  [821.843656]  ___might_sleep+0x144/0x160
  [821.843659]  mutex_lock+0x17/0x40
  [821.843662]  kernfs_remove_by_name_ns+0x1f/0x80
  [821.843666]  sysfs_remove_group+0x7d/0xe0
  [821.843668]  sysfs_remove_groups+0x28/0x40
  [821.843670]  kobject_del+0x2a/0x80
  [821.843672]  btrfs_sysfs_del_one_qgroup+0x2b/0x40 [btrfs]
  [821.843685]  __del_qgroup_rb+0x12/0x150 [btrfs]
  [821.843696]  btrfs_remove_qgroup+0x288/0x2a0 [btrfs]
  [821.843707]  btrfs_ioctl+0x3129/0x36a0 [btrfs]
  [821.843717]  ? __mod_lruvec_page_state+0x5e/0xb0
  [821.843719]  ? page_add_new_anon_rmap+0xbc/0x150
  [821.843723]  ? kfree+0x1b4/0x300
  [821.843725]  ? mntput_no_expire+0x55/0x330
  [821.843728]  __x64_sys_ioctl+0x5a/0xa0
  [821.843731]  do_syscall_64+0x33/0x70
  [821.843733]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
  [821.843736] RIP: 0033:0x4cd3fb
  [821.843741] RSP: 002b:00c000906b20 EFLAGS: 0206 ORIG_RAX: 
0010
  [821.843744] RAX: ffda RBX: 00c5 RCX: 004cd3fb
  [821.843745] RDX: 00c000906b98 RSI: 4010942a RDI: 000f
  [821.843747] RBP: 00c000907cd0 R08: 00c000622901 R09: 
  [821.843748] R10: 00c000d992c0 R11: 0206 R12: 012d
  [821.843749] R13: 012c R14: 0200 R15: 0049

Fix this by removing the qgroup sysfs entry while not holding the spinlock,
since the spinlock is only meant for protection of the qgroup rbtree.

Reported-by: Stuart Shelton 
Link: 
https://lore.kernel.org/linux-btrfs/7a5485bb-0628-419d-a4d3-27b1af47e...@gmail.com/
Fixes: 49e5fb46211de0 ("btrfs: qgroup: export qgroups in sysfs")
CC: sta...@vger.kernel.org # 5.10+
Reviewed-by: Qu Wenruo 
Signed-off-by: Filipe Manana 
Reviewed-by: David Sterba 
Signed-off-by: David Sterba 
Signed-off-by: Greg Kroah-Hartman 
---
 fs/btrfs/qgroup.c |   12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -226,7 +226,6 @@ static void __del_qgroup_rb(struct btrfs
 {
struct btrfs_qgroup_list *list;
 
-   btrfs_sysfs_del_one_qgroup(fs_info, qgroup);
list_del(&qgroup->dirty);
while (!list_empty(&qgroup->groups)) {
list = list_first_entry(&qgroup->groups,
@@ -243,7 +242,6 @@ static void __del_qgroup_rb(struct btrfs
list_del(&list->next_member);
kfree(list);
}
-   kfree(qgroup);
 }
 
 /* must be called with qgroup_lock held */
@@ -569,6 +567,8 @@ void btrfs_free_qgroup_config(struct btr
qgroup = rb_entry(n, struct btrfs_qgroup, node);
rb_erase(n, &fs_info->qgroup_tree);
__del_qgroup_rb(fs_info, qgroup);
+   btrfs_sysfs_del_one_qgroup(fs_info, qgroup);
+   kfree(qgroup);
}
/*
 * We call btrfs_free_qgroup_config() when unmounting
@@ -1580,6 +1580,14 @@ int btrfs_remove_qgroup(struct btrfs_tra
spin_lock(&fs_info->qgroup_lock);
del_qgroup_rb(fs_info, qgroupid);
spin_unlock(&fs_info->qgroup_lock);
+
+   /*
+* Remove the qgroup from sysfs now without holding the qgroup_lock
+* spinlock, since the sysfs_remove_group() function needs to take
+* the mutex kernfs_mutex through kernfs_remove_by_name_ns().
+*/
+   btrfs_sysfs_del_one_qgroup(fs_info, qgroup);
+   kfree(qgroup);
 out:
mutex_unlock(&fs_info->qgroup_ioctl_lock);
return ret;




[PATCH 5.10 110/221] e1000e: Fix error handling in e1000_set_d0_lplu_state_82571

2021-03-29 Thread Greg Kroah-Hartman
From: Dinghao Liu 

[ Upstream commit b52912b8293f2c496f42583e65599aee606a0c18 ]

There is one e1e_wphy() call in e1000_set_d0_lplu_state_82571
that we have caught its return value but lack further handling.
Check and terminate the execution flow just like other e1e_wphy()
in this function.

Fixes: bc7f75fa9788 ("[E1000E]: New pci-express e1000 driver (currently for 
ICH9 devices only)")
Signed-off-by: Dinghao Liu 
Acked-by: Sasha Neftin 
Tested-by: Dvora Fuxbrumer 
Signed-off-by: Tony Nguyen 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/intel/e1000e/82571.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/intel/e1000e/82571.c 
b/drivers/net/ethernet/intel/e1000e/82571.c
index 88faf05e23ba..0b1e890dd583 100644
--- a/drivers/net/ethernet/intel/e1000e/82571.c
+++ b/drivers/net/ethernet/intel/e1000e/82571.c
@@ -899,6 +899,8 @@ static s32 e1000_set_d0_lplu_state_82571(struct e1000_hw 
*hw, bool active)
} else {
data &= ~IGP02E1000_PM_D0_LPLU;
ret_val = e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, data);
+   if (ret_val)
+   return ret_val;
/* LPLU and SmartSpeed are mutually exclusive.  LPLU is used
 * during Dx states where the power conservation is most
 * important.  During driver activity we should enable
-- 
2.30.1





[PATCH 5.10 111/221] net/qlcnic: Fix a use after free in qlcnic_83xx_get_minidump_template

2021-03-29 Thread Greg Kroah-Hartman
From: Lv Yunlong 

[ Upstream commit db74623a3850db99cb9692fda9e836a56b74198d ]

In qlcnic_83xx_get_minidump_template, fw_dump->tmpl_hdr was freed by
vfree(). But unfortunately, it is used when extended is true.

Fixes: 7061b2bdd620e ("qlogic: Deletion of unnecessary checks before two 
function calls")
Signed-off-by: Lv Yunlong 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c 
b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
index 7760a3394e93..7ecb3dfe30bd 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
@@ -1425,6 +1425,7 @@ void qlcnic_83xx_get_minidump_template(struct 
qlcnic_adapter *adapter)
 
if (fw_dump->tmpl_hdr == NULL || current_version > prev_version) {
vfree(fw_dump->tmpl_hdr);
+   fw_dump->tmpl_hdr = NULL;
 
if (qlcnic_83xx_md_check_extended_dump_capability(adapter))
extended = !qlcnic_83xx_extend_md_capab(adapter);
@@ -1443,6 +1444,8 @@ void qlcnic_83xx_get_minidump_template(struct 
qlcnic_adapter *adapter)
struct qlcnic_83xx_dump_template_hdr *hdr;
 
hdr = fw_dump->tmpl_hdr;
+   if (!hdr)
+   return;
hdr->drv_cap_mask = 0x1f;
fw_dump->cap_mask = 0x1f;
dev_info(&pdev->dev,
-- 
2.30.1





[PATCH 5.10 112/221] net: phy: broadcom: Add power down exit reset state delay

2021-03-29 Thread Greg Kroah-Hartman
From: Florian Fainelli 

[ Upstream commit 7a1468ba0e02eee24ae1353e8933793a27198e20 ]

Per the datasheet, when we clear the power down bit, the PHY remains in
an internal reset state for 40us and then resume normal operation.
Account for that delay to avoid any issues in the future if
genphy_resume() changes.

Fixes: fe26821fa614 ("net: phy: broadcom: Wire suspend/resume for BCM54810")
Signed-off-by: Florian Fainelli 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/phy/broadcom.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
index cd271de9609b..69713ea36d4e 100644
--- a/drivers/net/phy/broadcom.c
+++ b/drivers/net/phy/broadcom.c
@@ -332,6 +332,11 @@ static int bcm54xx_resume(struct phy_device *phydev)
if (ret < 0)
return ret;
 
+   /* Upon exiting power down, the PHY remains in an internal reset state
+* for 40us
+*/
+   fsleep(40);
+
return bcm54xx_config_init(phydev);
 }
 
-- 
2.30.1





[PATCH 5.10 113/221] ftgmac100: Restart MAC HW once

2021-03-29 Thread Greg Kroah-Hartman
From: Dylan Hung 

[ Upstream commit 6897087323a2fde46df32917462750c069668b2f ]

The interrupt handler may set the flag to reset the mac in the future,
but that flag is not cleared once the reset has occurred.

Fixes: 10cbd6407609 ("ftgmac100: Rework NAPI & interrupts handling")
Signed-off-by: Dylan Hung 
Acked-by: Benjamin Herrenschmidt 
Reviewed-by: Joel Stanley 
Signed-off-by: Joel Stanley 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/faraday/ftgmac100.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c 
b/drivers/net/ethernet/faraday/ftgmac100.c
index 80fb1f537bb3..c9c380c50879 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1308,6 +1308,7 @@ static int ftgmac100_poll(struct napi_struct *napi, int 
budget)
 */
if (unlikely(priv->need_mac_restart)) {
ftgmac100_start_hw(priv);
+   priv->need_mac_restart = false;
 
/* Re-enable "bad" interrupts */
iowrite32(FTGMAC100_INT_BAD,
-- 
2.30.1





[PATCH 5.10 100/221] ipv6: fix suspecious RCU usage warning

2021-03-29 Thread Greg Kroah-Hartman
From: Wei Wang 

[ Upstream commit 28259bac7f1dde06d8ba324e222bbec9d4e92f2b ]

Syzbot reported the suspecious RCU usage in nexthop_fib6_nh() when
called from ipv6_route_seq_show(). The reason is ipv6_route_seq_start()
calls rcu_read_lock_bh(), while nexthop_fib6_nh() calls
rcu_dereference_rtnl().
The fix proposed is to add a variant of nexthop_fib6_nh() to use
rcu_dereference_bh_rtnl() for ipv6_route_seq_show().

The reported trace is as follows:
./include/net/nexthop.h:416 suspicious rcu_dereference_check() usage!

other info that might help us debug this:

rcu_scheduler_active = 2, debug_locks = 1
2 locks held by syz-executor.0/17895:
 at: seq_read+0x71/0x12a0 fs/seq_file.c:169
 at: seq_file_net include/linux/seq_file_net.h:19 [inline]
 at: ipv6_route_seq_start+0xaf/0x300 net/ipv6/ip6_fib.c:2616

stack backtrace:
CPU: 1 PID: 17895 Comm: syz-executor.0 Not tainted 4.15.0-syzkaller #0
Call Trace:
 [] __dump_stack lib/dump_stack.c:17 [inline]
 [] dump_stack+0xd8/0x147 lib/dump_stack.c:53
 [] lockdep_rcu_suspicious+0x153/0x15d 
kernel/locking/lockdep.c:5745
 [] nexthop_fib6_nh include/net/nexthop.h:416 [inline]
 [] ipv6_route_native_seq_show net/ipv6/ip6_fib.c:2488 
[inline]
 [] ipv6_route_seq_show+0x436/0x7a0 net/ipv6/ip6_fib.c:2673
 [] seq_read+0xccf/0x12a0 fs/seq_file.c:276
 [] proc_reg_read+0x10c/0x1d0 fs/proc/inode.c:231
 [] do_loop_readv_writev fs/read_write.c:714 [inline]
 [] do_loop_readv_writev fs/read_write.c:701 [inline]
 [] do_iter_read+0x49e/0x660 fs/read_write.c:935
 [] vfs_readv+0xfb/0x170 fs/read_write.c:997
 [] kernel_readv fs/splice.c:361 [inline]
 [] default_file_splice_read+0x487/0x9c0 fs/splice.c:416
 [] do_splice_to+0x129/0x190 fs/splice.c:879
 [] splice_direct_to_actor+0x256/0x890 fs/splice.c:951
 [] do_splice_direct+0x1dd/0x2b0 fs/splice.c:1060
 [] do_sendfile+0x597/0xce0 fs/read_write.c:1459
 [] SYSC_sendfile64 fs/read_write.c:1520 [inline]
 [] SyS_sendfile64+0x155/0x170 fs/read_write.c:1506
 [] do_syscall_64+0x1ff/0x310 arch/x86/entry/common.c:305
 [] entry_SYSCALL_64_after_hwframe+0x42/0xb7

Fixes: f88d8ea67fbdb ("ipv6: Plumb support for nexthop object in a fib6_info")
Reported-by: syzbot 
Signed-off-by: Wei Wang 
Cc: David Ahern 
Cc: Ido Schimmel 
Cc: Petr Machata 
Cc: Eric Dumazet 
Reviewed-by: Ido Schimmel 
Reviewed-by: David Ahern 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 include/net/nexthop.h | 24 
 net/ipv6/ip6_fib.c|  2 +-
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/include/net/nexthop.h b/include/net/nexthop.h
index 2fd76a9b6dc8..4c8c9fe9a3f0 100644
--- a/include/net/nexthop.h
+++ b/include/net/nexthop.h
@@ -362,6 +362,7 @@ static inline struct fib_nh *fib_info_nh(struct fib_info 
*fi, int nhsel)
 int fib6_check_nexthop(struct nexthop *nh, struct fib6_config *cfg,
   struct netlink_ext_ack *extack);
 
+/* Caller should either hold rcu_read_lock(), or RTNL. */
 static inline struct fib6_nh *nexthop_fib6_nh(struct nexthop *nh)
 {
struct nh_info *nhi;
@@ -382,6 +383,29 @@ static inline struct fib6_nh *nexthop_fib6_nh(struct 
nexthop *nh)
return NULL;
 }
 
+/* Variant of nexthop_fib6_nh().
+ * Caller should either hold rcu_read_lock_bh(), or RTNL.
+ */
+static inline struct fib6_nh *nexthop_fib6_nh_bh(struct nexthop *nh)
+{
+   struct nh_info *nhi;
+
+   if (nh->is_group) {
+   struct nh_group *nh_grp;
+
+   nh_grp = rcu_dereference_bh_rtnl(nh->nh_grp);
+   nh = nexthop_mpath_select(nh_grp, 0);
+   if (!nh)
+   return NULL;
+   }
+
+   nhi = rcu_dereference_bh_rtnl(nh->nh_info);
+   if (nhi->family == AF_INET6)
+   return &nhi->fib6_nh;
+
+   return NULL;
+}
+
 static inline struct net_device *fib6_info_nh_dev(struct fib6_info *f6i)
 {
struct fib6_nh *fib6_nh;
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index f43e27555725..1fb79dbde0cb 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -2485,7 +2485,7 @@ static int ipv6_route_native_seq_show(struct seq_file 
*seq, void *v)
const struct net_device *dev;
 
if (rt->nh)
-   fib6_nh = nexthop_fib6_nh(rt->nh);
+   fib6_nh = nexthop_fib6_nh_bh(rt->nh);
 
seq_printf(seq, "%pi6 %02x ", &rt->fib6_dst.addr, rt->fib6_dst.plen);
 
-- 
2.30.1





[PATCH 5.10 116/221] net: qrtr: fix a kernel-infoleak in qrtr_recvmsg()

2021-03-29 Thread Greg Kroah-Hartman
From: Eric Dumazet 

[ Upstream commit 50535249f624d0072cd885bcdce4e4b6fb770160 ]

struct sockaddr_qrtr has a 2-byte hole, and qrtr_recvmsg() currently
does not clear it before copying kernel data to user space.

It might be too late to name the hole since sockaddr_qrtr structure is uapi.

BUG: KMSAN: kernel-infoleak in kmsan_copy_to_user+0x9c/0xb0 
mm/kmsan/kmsan_hooks.c:249
CPU: 0 PID: 29705 Comm: syz-executor.3 Not tainted 5.11.0-rc7-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 
01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:79 [inline]
 dump_stack+0x21c/0x280 lib/dump_stack.c:120
 kmsan_report+0xfb/0x1e0 mm/kmsan/kmsan_report.c:118
 kmsan_internal_check_memory+0x202/0x520 mm/kmsan/kmsan.c:402
 kmsan_copy_to_user+0x9c/0xb0 mm/kmsan/kmsan_hooks.c:249
 instrument_copy_to_user include/linux/instrumented.h:121 [inline]
 _copy_to_user+0x1ac/0x270 lib/usercopy.c:33
 copy_to_user include/linux/uaccess.h:209 [inline]
 move_addr_to_user+0x3a2/0x640 net/socket.c:237
 sys_recvmsg+0x696/0xd50 net/socket.c:2575
 ___sys_recvmsg net/socket.c:2610 [inline]
 do_recvmmsg+0xa97/0x22d0 net/socket.c:2710
 __sys_recvmmsg net/socket.c:2789 [inline]
 __do_sys_recvmmsg net/socket.c:2812 [inline]
 __se_sys_recvmmsg+0x24a/0x410 net/socket.c:2805
 __x64_sys_recvmmsg+0x62/0x80 net/socket.c:2805
 do_syscall_64+0x9f/0x140 arch/x86/entry/common.c:48
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x465f69
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 
89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 
c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:7f43659d6188 EFLAGS: 0246 ORIG_RAX: 012b
RAX: ffda RBX: 0056bf60 RCX: 00465f69
RDX: 0008 RSI: 20003e40 RDI: 0003
RBP: 004bfa8f R08:  R09: 
R10: 00010060 R11: 0246 R12: 0056bf60
R13: 00a9fb1f R14: 7f43659d6300 R15: 00022000

Local variable addr@sys_recvmsg created at:
 sys_recvmsg+0x168/0xd50 net/socket.c:2550
 sys_recvmsg+0x168/0xd50 net/socket.c:2550

Bytes 2-3 of 12 are uninitialized
Memory access of size 12 starts at 88817c627b40
Data copied to user address 2140

Fixes: bdabad3e363d ("net: Add Qualcomm IPC router")
Signed-off-by: Eric Dumazet 
Cc: Courtney Cavin 
Reported-by: syzbot 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 net/qrtr/qrtr.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c
index 54031ee079a2..45fbf5f4dcd2 100644
--- a/net/qrtr/qrtr.c
+++ b/net/qrtr/qrtr.c
@@ -1035,6 +1035,11 @@ static int qrtr_recvmsg(struct socket *sock, struct 
msghdr *msg,
rc = copied;
 
if (addr) {
+   /* There is an anonymous 2-byte hole after sq_family,
+* make sure to clear it.
+*/
+   memset(addr, 0, sizeof(*addr));
+
addr->sq_family = AF_QIPCRTR;
addr->sq_node = cb->src_node;
addr->sq_port = cb->src_port;
-- 
2.30.1





[PATCH 5.10 114/221] clk: qcom: gcc-sc7180: Use floor ops for the correct sdcc1 clk

2021-03-29 Thread Greg Kroah-Hartman
From: Douglas Anderson 

[ Upstream commit 148ddaa89d4a0a927c4353398096cc33687755c1 ]

While picking commit a8cd989e1a57 ("mmc: sdhci-msm: Warn about
overclocking SD/MMC") back to my tree I was surprised that it was
reporting warnings.  I thought I fixed those!  Looking closer at the
fix, I see that I totally bungled it (or at least I halfway bungled
it).  The SD card clock got fixed (and that was the one I was really
focused on fixing), but I totally adjusted the wrong clock for eMMC.
Sigh.  Let's fix my dumb mistake.

Now both SD and eMMC have floor for the "apps" clock.

This doesn't matter a lot for the final clock rate for HS400 eMMC but
could matter if someone happens to put some slower eMMC on a sc7180.
We also transition through some of these lower rates sometimes and
having them wrong could cause problems during these transitions.
These were the messages I was seeing at boot:
  mmc1: Card appears overclocked; req 5200 Hz, actual 1 Hz
  mmc1: Card appears overclocked; req 5200 Hz, actual 1 Hz
  mmc1: Card appears overclocked; req 10400 Hz, actual 19200 Hz

Fixes: 6d37a8d19283 ("clk: qcom: gcc-sc7180: Use floor ops for sdcc clks")
Signed-off-by: Douglas Anderson 
Link: 
https://lore.kernel.org/r/20210224095013.1.I2e2ba4978cfca06520dfb5d757768f9c42140f7c@changeid
Reviewed-by: Taniya Das 
Signed-off-by: Stephen Boyd 
Signed-off-by: Sasha Levin 
---
 drivers/clk/qcom/gcc-sc7180.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/qcom/gcc-sc7180.c b/drivers/clk/qcom/gcc-sc7180.c
index b080739ab0c3..7e80dbd4a3f9 100644
--- a/drivers/clk/qcom/gcc-sc7180.c
+++ b/drivers/clk/qcom/gcc-sc7180.c
@@ -620,7 +620,7 @@ static struct clk_rcg2 gcc_sdcc1_apps_clk_src = {
.name = "gcc_sdcc1_apps_clk_src",
.parent_data = gcc_parent_data_1,
.num_parents = 5,
-   .ops = &clk_rcg2_ops,
+   .ops = &clk_rcg2_floor_ops,
},
 };
 
@@ -642,7 +642,7 @@ static struct clk_rcg2 gcc_sdcc1_ice_core_clk_src = {
.name = "gcc_sdcc1_ice_core_clk_src",
.parent_data = gcc_parent_data_0,
.num_parents = 4,
-   .ops = &clk_rcg2_floor_ops,
+   .ops = &clk_rcg2_ops,
},
 };
 
-- 
2.30.1





[PATCH 5.10 115/221] net: ipa: terminate message handler arrays

2021-03-29 Thread Greg Kroah-Hartman
From: Alex Elder 

[ Upstream commit 3a9ef3e11c5d33e5cb355b4aad1a4caad2407541 ]

When a QMI handle is initialized, an array of message handler
structures is provided, defining how any received message should
be handled based on its type and message ID.  The QMI core code
traverses this array when a message arrives and calls the function
associated with the (type, msg_id) found in the array.

The array is supposed to be terminated with an empty (all zero)
entry though.  Without it, an unsupported message will cause
the QMI core code to go past the end of the array.

Fix this bug, by properly terminating the message handler arrays
provided when QMI handles are set up by the IPA driver.

Fixes: 530f9216a9537 ("soc: qcom: ipa: AP/modem communications")
Reported-by: Sujit Kautkar 
Signed-off-by: Alex Elder 
Reviewed-by: Bjorn Andersson 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ipa/ipa_qmi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ipa/ipa_qmi.c b/drivers/net/ipa/ipa_qmi.c
index 5090f0f923ad..1a87a49538c5 100644
--- a/drivers/net/ipa/ipa_qmi.c
+++ b/drivers/net/ipa/ipa_qmi.c
@@ -249,6 +249,7 @@ static struct qmi_msg_handler ipa_server_msg_handlers[] = {
.decoded_size   = IPA_QMI_DRIVER_INIT_COMPLETE_REQ_SZ,
.fn = ipa_server_driver_init_complete,
},
+   { },
 };
 
 /* Handle an INIT_DRIVER response message from the modem. */
@@ -269,6 +270,7 @@ static struct qmi_msg_handler ipa_client_msg_handlers[] = {
.decoded_size   = IPA_QMI_INIT_DRIVER_RSP_SZ,
.fn = ipa_client_init_driver,
},
+   { },
 };
 
 /* Return a pointer to an init modem driver request structure, which contains
-- 
2.30.1





[PATCH 5.10 101/221] drop_monitor: Perform cleanup upon probe registration failure

2021-03-29 Thread Greg Kroah-Hartman
From: Ido Schimmel 

[ Upstream commit 9398e9c0b1d44eeb700e9e766c02bcc765c82570 ]

In the rare case that drop_monitor fails to register its probe on the
'napi_poll' tracepoint, it will not deactivate its hysteresis timer as
part of the error path. If the hysteresis timer was armed by the shortly
lived 'kfree_skb' probe and user space retries to initiate tracing, a
warning will be emitted for trying to initialize an active object [1].

Fix this by properly undoing all the operations that were done prior to
probe registration, in both software and hardware code paths.

Note that syzkaller managed to fail probe registration by injecting a
slab allocation failure [2].

[1]
ODEBUG: init active (active state 0) object type: timer_list hint: 
sched_send_work+0x0/0x60 include/linux/list.h:135
WARNING: CPU: 1 PID: 8649 at lib/debugobjects.c:505 
debug_print_object+0x16e/0x250 lib/debugobjects.c:505
Modules linked in:
CPU: 1 PID: 8649 Comm: syz-executor.0 Not tainted 5.11.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 
01/01/2011
RIP: 0010:debug_print_object+0x16e/0x250 lib/debugobjects.c:505
[...]
Call Trace:
 __debug_object_init+0x524/0xd10 lib/debugobjects.c:588
 debug_timer_init kernel/time/timer.c:722 [inline]
 debug_init kernel/time/timer.c:770 [inline]
 init_timer_key+0x2d/0x340 kernel/time/timer.c:814
 net_dm_trace_on_set net/core/drop_monitor.c: [inline]
 set_all_monitor_traces net/core/drop_monitor.c:1188 [inline]
 net_dm_monitor_start net/core/drop_monitor.c:1295 [inline]
 net_dm_cmd_trace+0x720/0x1220 net/core/drop_monitor.c:1339
 genl_family_rcv_msg_doit+0x228/0x320 net/netlink/genetlink.c:739
 genl_family_rcv_msg net/netlink/genetlink.c:783 [inline]
 genl_rcv_msg+0x328/0x580 net/netlink/genetlink.c:800
 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2502
 genl_rcv+0x24/0x40 net/netlink/genetlink.c:811
 netlink_unicast_kernel net/netlink/af_netlink.c:1312 [inline]
 netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1338
 netlink_sendmsg+0x856/0xd90 net/netlink/af_netlink.c:1927
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:672
 sys_sendmsg+0x6e8/0x810 net/socket.c:2348
 ___sys_sendmsg+0xf3/0x170 net/socket.c:2402
 __sys_sendmsg+0xe5/0x1b0 net/socket.c:2435
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xae

[2]
 FAULT_INJECTION: forcing a failure.
 name failslab, interval 1, probability 0, space 0, times 1
 CPU: 1 PID: 8645 Comm: syz-executor.0 Not tainted 5.11.0-syzkaller #0
 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 
01/01/2011
 Call Trace:
  dump_stack+0xfa/0x151
  should_fail.cold+0x5/0xa
  should_failslab+0x5/0x10
  __kmalloc+0x72/0x3f0
  tracepoint_add_func+0x378/0x990
  tracepoint_probe_register+0x9c/0xe0
  net_dm_cmd_trace+0x7fc/0x1220
  genl_family_rcv_msg_doit+0x228/0x320
  genl_rcv_msg+0x328/0x580
  netlink_rcv_skb+0x153/0x420
  genl_rcv+0x24/0x40
  netlink_unicast+0x533/0x7d0
  netlink_sendmsg+0x856/0xd90
  sock_sendmsg+0xcf/0x120
  sys_sendmsg+0x6e8/0x810
  ___sys_sendmsg+0xf3/0x170
  __sys_sendmsg+0xe5/0x1b0
  do_syscall_64+0x2d/0x70
  entry_SYSCALL_64_after_hwframe+0x44/0xae

Fixes: 70c69274f354 ("drop_monitor: Initialize timer and work item upon tracing 
enable")
Fixes: 8ee2267ad33e ("drop_monitor: Convert to using devlink tracepoint")
Reported-by: syzbot+779559d6503f3a562...@syzkaller.appspotmail.com
Signed-off-by: Ido Schimmel 
Reviewed-by: Jiri Pirko 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 net/core/drop_monitor.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
index 571f191c06d9..db65ce62b625 100644
--- a/net/core/drop_monitor.c
+++ b/net/core/drop_monitor.c
@@ -1053,6 +1053,20 @@ static int net_dm_hw_monitor_start(struct 
netlink_ext_ack *extack)
return 0;
 
 err_module_put:
+   for_each_possible_cpu(cpu) {
+   struct per_cpu_dm_data *hw_data = &per_cpu(dm_hw_cpu_data, cpu);
+   struct sk_buff *skb;
+
+   del_timer_sync(&hw_data->send_timer);
+   cancel_work_sync(&hw_data->dm_alert_work);
+   while ((skb = __skb_dequeue(&hw_data->drop_queue))) {
+   struct devlink_trap_metadata *hw_metadata;
+
+   hw_metadata = NET_DM_SKB_CB(skb)->hw_metadata;
+   net_dm_hw_metadata_free(hw_metadata);
+   consume_skb(skb);
+   }
+   }
module_put(THIS_MODULE);
return rc;
 }
@@ -1134,6 +1148,15 @@ static int net_dm_trace_on_set(struct netlink_ext_ack 
*extack)
 err_unregister_trace:
unregister_trace_kfree_skb(ops->kfree_skb_probe, NULL);
 err_module_put:
+   for_each_possible_cpu(cpu) {
+   struct per_cpu_dm_data *data = &per_cpu(dm_cpu_data, cpu);
+   struct sk_buff *skb;
+
+   del_timer_s

[PATCH 5.10 118/221] selftests/bpf: Set gopt opt_class to 0 if get tunnel opt failed

2021-03-29 Thread Greg Kroah-Hartman
From: Hangbin Liu 

[ Upstream commit 31254dc9566221429d2cfb45fd5737985d70f2b6 ]

When fixing the bpf test_tunnel.sh geneve failure. I only fixed the IPv4
part but forgot the IPv6 issue. Similar with the IPv4 fixes 557c223b643a
("selftests/bpf: No need to drop the packet when there is no geneve opt"),
when there is no tunnel option and bpf_skb_get_tunnel_opt() returns error,
there is no need to drop the packets and break all geneve rx traffic.
Just set opt_class to 0 and keep returning TC_ACT_OK at the end.

Fixes: 557c223b643a ("selftests/bpf: No need to drop the packet when there is 
no geneve opt")
Fixes: 933a741e3b82 ("selftests/bpf: bpf tunnel test.")
Signed-off-by: Hangbin Liu 
Signed-off-by: Daniel Borkmann 
Acked-by: William Tu 
Link: https://lore.kernel.org/bpf/20210309032214.2112438-1-liuhang...@gmail.com
Signed-off-by: Sasha Levin 
---
 tools/testing/selftests/bpf/progs/test_tunnel_kern.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c 
b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
index 9afe947cfae9..ba6eadfec565 100644
--- a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
+++ b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
@@ -508,10 +508,8 @@ int _ip6geneve_get_tunnel(struct __sk_buff *skb)
}
 
ret = bpf_skb_get_tunnel_opt(skb, &gopt, sizeof(gopt));
-   if (ret < 0) {
-   ERROR(ret);
-   return TC_ACT_SHOT;
-   }
+   if (ret < 0)
+   gopt.opt_class = 0;
 
bpf_trace_printk(fmt, sizeof(fmt),
key.tunnel_id, key.remote_ipv4, gopt.opt_class);
-- 
2.30.1





[PATCH 5.10 117/221] flow_dissector: fix byteorder of dissected ICMP ID

2021-03-29 Thread Greg Kroah-Hartman
From: Alexander Lobakin 

[ Upstream commit a25f822285420486f5da434efc8d940d42a83bce ]

flow_dissector_key_icmp::id is of type u16 (CPU byteorder),
ICMP header has its ID field in network byteorder obviously.
Sparse says:

net/core/flow_dissector.c:178:43: warning: restricted __be16 degrades to integer

Convert ID value to CPU byteorder when storing it into
flow_dissector_key_icmp.

Fixes: 5dec597e5cd0 ("flow_dissector: extract more ICMP information")
Signed-off-by: Alexander Lobakin 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 net/core/flow_dissector.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index e21950a2c897..c79be25b2e0c 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -175,7 +175,7 @@ void skb_flow_get_icmp_tci(const struct sk_buff *skb,
 * avoid confusion with packets without such field
 */
if (icmp_has_id(ih->type))
-   key_icmp->id = ih->un.echo.id ? : 1;
+   key_icmp->id = ih->un.echo.id ? ntohs(ih->un.echo.id) : 1;
else
key_icmp->id = 0;
 }
-- 
2.30.1





[PATCH 5.10 121/221] net: phylink: Fix phylink_err() function name error in phylink_major_config

2021-03-29 Thread Greg Kroah-Hartman
From: Ong Boon Leong 

[ Upstream commit d82c6c1aaccd2877b6082cebcb1746a13648a16d ]

if pl->mac_ops->mac_finish() failed, phylink_err should use
"mac_finish" instead of "mac_prepare".

Fixes: b7ad14c2fe2d4 ("net: phylink: re-implement interface configuration with 
PCS")
Signed-off-by: Ong Boon Leong 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/phy/phylink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index fe2296fdda19..6072e87ed6c3 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -472,7 +472,7 @@ static void phylink_major_config(struct phylink *pl, bool 
restart,
err = pl->mac_ops->mac_finish(pl->config, pl->cur_link_an_mode,
  state->interface);
if (err < 0)
-   phylink_err(pl, "mac_prepare failed: %pe\n",
+   phylink_err(pl, "mac_finish failed: %pe\n",
ERR_PTR(err));
}
 }
-- 
2.30.1





[PATCH 5.10 120/221] net: hdlc_x25: Prevent racing between "x25_close" and "x25_xmit"/"x25_rx"

2021-03-29 Thread Greg Kroah-Hartman
From: Xie He 

[ Upstream commit bf0ffea336b493c0a8c8bc27b46683ecf1e8f294 ]

"x25_close" is called by "hdlc_close" in "hdlc.c", which is called by
hardware drivers' "ndo_stop" function.
"x25_xmit" is called by "hdlc_start_xmit" in "hdlc.c", which is hardware
drivers' "ndo_start_xmit" function.
"x25_rx" is called by "hdlc_rcv" in "hdlc.c", which receives HDLC frames
from "net/core/dev.c".

"x25_close" races with "x25_xmit" and "x25_rx" because their callers race.

However, we need to ensure that the LAPB APIs called in "x25_xmit" and
"x25_rx" are called before "lapb_unregister" is called in "x25_close".

This patch adds locking to ensure when "x25_xmit" and "x25_rx" are doing
their work, "lapb_unregister" is not yet called in "x25_close".

Reasons for not solving the racing between "x25_close" and "x25_xmit" by
calling "netif_tx_disable" in "x25_close":
1. We still need to solve the racing between "x25_close" and "x25_rx";
2. The design of the HDLC subsystem assumes the HDLC hardware drivers
have full control over the TX queue, and the HDLC protocol drivers (like
this driver) have no control. Controlling the queue here in the protocol
driver may interfere with hardware drivers' control of the queue.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Xie He 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/wan/hdlc_x25.c | 42 +-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wan/hdlc_x25.c b/drivers/net/wan/hdlc_x25.c
index 34bc53facd11..6938cb3bdf4e 100644
--- a/drivers/net/wan/hdlc_x25.c
+++ b/drivers/net/wan/hdlc_x25.c
@@ -23,6 +23,8 @@
 
 struct x25_state {
x25_hdlc_proto settings;
+   bool up;
+   spinlock_t up_lock; /* Protects "up" */
 };
 
 static int x25_ioctl(struct net_device *dev, struct ifreq *ifr);
@@ -105,6 +107,8 @@ static void x25_data_transmit(struct net_device *dev, 
struct sk_buff *skb)
 
 static netdev_tx_t x25_xmit(struct sk_buff *skb, struct net_device *dev)
 {
+   hdlc_device *hdlc = dev_to_hdlc(dev);
+   struct x25_state *x25st = state(hdlc);
int result;
 
/* There should be a pseudo header of 1 byte added by upper layers.
@@ -115,12 +119,20 @@ static netdev_tx_t x25_xmit(struct sk_buff *skb, struct 
net_device *dev)
return NETDEV_TX_OK;
}
 
+   spin_lock_bh(&x25st->up_lock);
+   if (!x25st->up) {
+   spin_unlock_bh(&x25st->up_lock);
+   kfree_skb(skb);
+   return NETDEV_TX_OK;
+   }
+
switch (skb->data[0]) {
case X25_IFACE_DATA:/* Data to be transmitted */
skb_pull(skb, 1);
skb_reset_network_header(skb);
if ((result = lapb_data_request(dev, skb)) != LAPB_OK)
dev_kfree_skb(skb);
+   spin_unlock_bh(&x25st->up_lock);
return NETDEV_TX_OK;
 
case X25_IFACE_CONNECT:
@@ -149,6 +161,7 @@ static netdev_tx_t x25_xmit(struct sk_buff *skb, struct 
net_device *dev)
break;
}
 
+   spin_unlock_bh(&x25st->up_lock);
dev_kfree_skb(skb);
return NETDEV_TX_OK;
 }
@@ -166,6 +179,7 @@ static int x25_open(struct net_device *dev)
.data_transmit = x25_data_transmit,
};
hdlc_device *hdlc = dev_to_hdlc(dev);
+   struct x25_state *x25st = state(hdlc);
struct lapb_parms_struct params;
int result;
 
@@ -192,6 +206,10 @@ static int x25_open(struct net_device *dev)
if (result != LAPB_OK)
return -EINVAL;
 
+   spin_lock_bh(&x25st->up_lock);
+   x25st->up = true;
+   spin_unlock_bh(&x25st->up_lock);
+
return 0;
 }
 
@@ -199,6 +217,13 @@ static int x25_open(struct net_device *dev)
 
 static void x25_close(struct net_device *dev)
 {
+   hdlc_device *hdlc = dev_to_hdlc(dev);
+   struct x25_state *x25st = state(hdlc);
+
+   spin_lock_bh(&x25st->up_lock);
+   x25st->up = false;
+   spin_unlock_bh(&x25st->up_lock);
+
lapb_unregister(dev);
 }
 
@@ -207,15 +232,28 @@ static void x25_close(struct net_device *dev)
 static int x25_rx(struct sk_buff *skb)
 {
struct net_device *dev = skb->dev;
+   hdlc_device *hdlc = dev_to_hdlc(dev);
+   struct x25_state *x25st = state(hdlc);
 
if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) {
dev->stats.rx_dropped++;
return NET_RX_DROP;
}
 
-   if (lapb_data_received(dev, skb) == LAPB_OK)
+   spin_lock_bh(&x25st->up_lock);
+   if (!x25st->up) {
+   spin_unlock_bh(&x25st->up_lock);
+   kfree_skb(skb);
+   dev->stats.rx_dropped++;
+   return NET_RX_DROP;
+   }
+
+   if (lapb_data_received(dev, skb) == LAPB_OK) {
+   spin_unlock_bh(&x25st->up_lock);
return NET_RX_SUCCESS;
+   }
 
+   spin_unlock_bh(&x25st->up_lock);
dev->s

[PATCH 5.10 119/221] netfilter: ctnetlink: fix dump of the expect mask attribute

2021-03-29 Thread Greg Kroah-Hartman
From: Florian Westphal 

[ Upstream commit b58f33d49e426dc66e98ed73afb5d97b15a25f2d ]

Before this change, the mask is never included in the netlink message, so
"conntrack -E expect" always prints 0.0.0.0.

In older kernels the l3num callback struct was passed as argument, based
on tuple->src.l3num. After the l3num indirection got removed, the call
chain is based on m.src.l3num, but this value is 0x.

Init l3num to the correct value.

Fixes: f957be9d349a3 ("netfilter: conntrack: remove ctnetlink callbacks from l3 
protocol trackers")
Signed-off-by: Florian Westphal 
Signed-off-by: Pablo Neira Ayuso 
Signed-off-by: Sasha Levin 
---
 net/netfilter/nf_conntrack_netlink.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/netfilter/nf_conntrack_netlink.c 
b/net/netfilter/nf_conntrack_netlink.c
index 3d0fd33be018..c1bfd8181341 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -2960,6 +2960,7 @@ static int ctnetlink_exp_dump_mask(struct sk_buff *skb,
memset(&m, 0xFF, sizeof(m));
memcpy(&m.src.u3, &mask->src.u3, sizeof(m.src.u3));
m.src.u.all = mask->src.u.all;
+   m.src.l3num = tuple->src.l3num;
m.dst.protonum = tuple->dst.protonum;
 
nest_parms = nla_nest_start(skb, CTA_EXPECT_MASK);
-- 
2.30.1





[PATCH 5.10 123/221] tcp: relookup sock for RST+ACK packets handled by obsolete req sock

2021-03-29 Thread Greg Kroah-Hartman
From: Alexander Ovechkin 

[ Upstream commit 7233da86697efef41288f8b713c10c2499cffe85 ]

Currently tcp_check_req can be called with obsolete req socket for which big
socket have been already created (because of CPU race or early demux
assigning req socket to multiple packets in gro batch).

Commit e0f9759f530bf789e984 ("tcp: try to keep packet if SYN_RCV race
is lost") added retry in case when tcp_check_req is called for PSH|ACK packet.
But if client sends RST+ACK immediatly after connection being
established (it is performing healthcheck, for example) retry does not
occur. In that case tcp_check_req tries to close req socket,
leaving big socket active.

Fixes: e0f9759f530 ("tcp: try to keep packet if SYN_RCV race is lost")
Signed-off-by: Alexander Ovechkin 
Reported-by: Oleg Senin 
Reviewed-by: Eric Dumazet 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 include/net/inet_connection_sock.h | 2 +-
 net/ipv4/inet_connection_sock.c| 7 +--
 net/ipv4/tcp_minisocks.c   | 7 +--
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/include/net/inet_connection_sock.h 
b/include/net/inet_connection_sock.h
index 111d7771b208..aa92af3dd444 100644
--- a/include/net/inet_connection_sock.h
+++ b/include/net/inet_connection_sock.h
@@ -284,7 +284,7 @@ static inline int inet_csk_reqsk_queue_is_full(const struct 
sock *sk)
return inet_csk_reqsk_queue_len(sk) >= sk->sk_max_ack_backlog;
 }
 
-void inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req);
+bool inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req);
 void inet_csk_reqsk_queue_drop_and_put(struct sock *sk, struct request_sock 
*req);
 
 static inline void inet_csk_prepare_for_destroy_sock(struct sock *sk)
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 48d2b615edc2..1dfa561e8f98 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -705,12 +705,15 @@ static bool reqsk_queue_unlink(struct request_sock *req)
return found;
 }
 
-void inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req)
+bool inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req)
 {
-   if (reqsk_queue_unlink(req)) {
+   bool unlinked = reqsk_queue_unlink(req);
+
+   if (unlinked) {
reqsk_queue_removed(&inet_csk(sk)->icsk_accept_queue, req);
reqsk_put(req);
}
+   return unlinked;
 }
 EXPORT_SYMBOL(inet_csk_reqsk_queue_drop);
 
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 495dda2449fe..f0f67b25c97a 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -804,8 +804,11 @@ embryonic_reset:
tcp_reset(sk);
}
if (!fastopen) {
-   inet_csk_reqsk_queue_drop(sk, req);
-   __NET_INC_STATS(sock_net(sk), LINUX_MIB_EMBRYONICRSTS);
+   bool unlinked = inet_csk_reqsk_queue_drop(sk, req);
+
+   if (unlinked)
+   __NET_INC_STATS(sock_net(sk), LINUX_MIB_EMBRYONICRSTS);
+   *req_stolen = !unlinked;
}
return NULL;
 }
-- 
2.30.1





[PATCH 5.10 126/221] can: peak_usb: add forgotten supported devices

2021-03-29 Thread Greg Kroah-Hartman
From: Stephane Grosjean 

[ Upstream commit 59ec7b89ed3e921cd0625a8c83f31a30d485fdf8 ]

Since the peak_usb driver also supports the CAN-USB interfaces
"PCAN-USB X6" and "PCAN-Chip USB" from PEAK-System GmbH, this patch adds
their names to the list of explicitly supported devices.

Fixes: ea8b65b596d7 ("can: usb: Add support of PCAN-Chip USB stamp module")
Fixes: f00b534ded60 ("can: peak: Add support for PCAN-USB X6 USB interface")
Link: 
https://lore.kernel.org/r/20210309082128.23125-3-s.grosj...@peak-system.com
Signed-off-by: Stephane Grosjean 
Signed-off-by: Marc Kleine-Budde 
Signed-off-by: Sasha Levin 
---
 drivers/net/can/usb/peak_usb/pcan_usb_fd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c 
b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
index d56592283818..3f8d99286b1e 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
@@ -18,6 +18,8 @@
 
 MODULE_SUPPORTED_DEVICE("PEAK-System PCAN-USB FD adapter");
 MODULE_SUPPORTED_DEVICE("PEAK-System PCAN-USB Pro FD adapter");
+MODULE_SUPPORTED_DEVICE("PEAK-System PCAN-Chip USB");
+MODULE_SUPPORTED_DEVICE("PEAK-System PCAN-USB X6 adapter");
 
 #define PCAN_USBPROFD_CHANNEL_COUNT2
 #define PCAN_USBFD_CHANNEL_COUNT   1
-- 
2.30.1





[PATCH 5.10 122/221] tipc: better validate user input in tipc_nl_retrieve_key()

2021-03-29 Thread Greg Kroah-Hartman
From: Eric Dumazet 

[ Upstream commit 0217ed2848e8538bcf9172d97ed2eeb4a26041bb ]

Before calling tipc_aead_key_size(ptr), we need to ensure
we have enough data to dereference ptr->keylen.

We probably also want to make sure tipc_aead_key_size()
wont overflow with malicious ptr->keylen values.

Syzbot reported:

BUG: KMSAN: uninit-value in __tipc_nl_node_set_key net/tipc/node.c:2971 [inline]
BUG: KMSAN: uninit-value in tipc_nl_node_set_key+0x9bf/0x13b0 
net/tipc/node.c:3023
CPU: 0 PID: 21060 Comm: syz-executor.5 Not tainted 5.11.0-rc7-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 
01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:79 [inline]
 dump_stack+0x21c/0x280 lib/dump_stack.c:120
 kmsan_report+0xfb/0x1e0 mm/kmsan/kmsan_report.c:118
 __msan_warning+0x5f/0xa0 mm/kmsan/kmsan_instr.c:197
 __tipc_nl_node_set_key net/tipc/node.c:2971 [inline]
 tipc_nl_node_set_key+0x9bf/0x13b0 net/tipc/node.c:3023
 genl_family_rcv_msg_doit net/netlink/genetlink.c:739 [inline]
 genl_family_rcv_msg net/netlink/genetlink.c:783 [inline]
 genl_rcv_msg+0x1319/0x1610 net/netlink/genetlink.c:800
 netlink_rcv_skb+0x6fa/0x810 net/netlink/af_netlink.c:2494
 genl_rcv+0x63/0x80 net/netlink/genetlink.c:811
 netlink_unicast_kernel net/netlink/af_netlink.c:1304 [inline]
 netlink_unicast+0x11d6/0x14a0 net/netlink/af_netlink.c:1330
 netlink_sendmsg+0x1740/0x1840 net/netlink/af_netlink.c:1919
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg net/socket.c:672 [inline]
 sys_sendmsg+0xcfc/0x12f0 net/socket.c:2345
 ___sys_sendmsg net/socket.c:2399 [inline]
 __sys_sendmsg+0x714/0x830 net/socket.c:2432
 __compat_sys_sendmsg net/compat.c:347 [inline]
 __do_compat_sys_sendmsg net/compat.c:354 [inline]
 __se_compat_sys_sendmsg+0xa7/0xc0 net/compat.c:351
 __ia32_compat_sys_sendmsg+0x4a/0x70 net/compat.c:351
 do_syscall_32_irqs_on arch/x86/entry/common.c:79 [inline]
 __do_fast_syscall_32+0x102/0x160 arch/x86/entry/common.c:141
 do_fast_syscall_32+0x6a/0xc0 arch/x86/entry/common.c:166
 do_SYSENTER_32+0x73/0x90 arch/x86/entry/common.c:209
 entry_SYSENTER_compat_after_hwframe+0x4d/0x5c
RIP: 0023:0xf7f60549
Code: 03 74 c0 01 10 05 03 74 b8 01 10 06 03 74 b4 01 10 07 03 74 b0 01 10 08 
03 74 d8 01 00 00 00 00 00 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 
8d b4 26 00 00 00 00 8d b4 26 00 00 00 00
RSP: 002b:f555a5fc EFLAGS: 0296 ORIG_RAX: 0172
RAX: ffda RBX: 0003 RCX: 2200
RDX:  RSI:  RDI: 
RBP:  R08:  R09: 
R10:  R11:  R12: 
R13:  R14:  R15: 

Uninit was created at:
 kmsan_save_stack_with_flags mm/kmsan/kmsan.c:121 [inline]
 kmsan_internal_poison_shadow+0x5c/0xf0 mm/kmsan/kmsan.c:104
 kmsan_slab_alloc+0x8d/0xe0 mm/kmsan/kmsan_hooks.c:76
 slab_alloc_node mm/slub.c:2907 [inline]
 __kmalloc_node_track_caller+0xa37/0x1430 mm/slub.c:4527
 __kmalloc_reserve net/core/skbuff.c:142 [inline]
 __alloc_skb+0x2f8/0xb30 net/core/skbuff.c:210
 alloc_skb include/linux/skbuff.h:1099 [inline]
 netlink_alloc_large_skb net/netlink/af_netlink.c:1176 [inline]
 netlink_sendmsg+0xdbc/0x1840 net/netlink/af_netlink.c:1894
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg net/socket.c:672 [inline]
 sys_sendmsg+0xcfc/0x12f0 net/socket.c:2345
 ___sys_sendmsg net/socket.c:2399 [inline]
 __sys_sendmsg+0x714/0x830 net/socket.c:2432
 __compat_sys_sendmsg net/compat.c:347 [inline]
 __do_compat_sys_sendmsg net/compat.c:354 [inline]
 __se_compat_sys_sendmsg+0xa7/0xc0 net/compat.c:351
 __ia32_compat_sys_sendmsg+0x4a/0x70 net/compat.c:351
 do_syscall_32_irqs_on arch/x86/entry/common.c:79 [inline]
 __do_fast_syscall_32+0x102/0x160 arch/x86/entry/common.c:141
 do_fast_syscall_32+0x6a/0xc0 arch/x86/entry/common.c:166
 do_SYSENTER_32+0x73/0x90 arch/x86/entry/common.c:209
 entry_SYSENTER_compat_after_hwframe+0x4d/0x5c

Fixes: e1f32190cf7d ("tipc: add support for AEAD key setting via netlink")
Signed-off-by: Eric Dumazet 
Cc: Tuong Lien 
Cc: Jon Maloy 
Cc: Ying Xue 
Reported-by: syzbot 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 net/tipc/node.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/net/tipc/node.c b/net/tipc/node.c
index 83978d5dae59..e4452d55851f 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -2855,17 +2855,22 @@ int tipc_nl_node_dump_monitor_peer(struct sk_buff *skb,
 
 #ifdef CONFIG_TIPC_CRYPTO
 static int tipc_nl_retrieve_key(struct nlattr **attrs,
-   struct tipc_aead_key **key)
+   struct tipc_aead_key **pkey)
 {
struct nlattr *attr = attrs[TIPC_NLA_NODE_KEY];
+   struct tipc_aead_key *key;
 
if (!attr)
return -ENODATA;
 
-   *key = (struct tipc_aead_key *)nla_data(attr);
-   if (nla_len(attr)

[PATCH 5.10 125/221] can: isotp: TX-path: ensure that CAN frame flags are initialized

2021-03-29 Thread Greg Kroah-Hartman
From: Marc Kleine-Budde 

[ Upstream commit d4eb538e1f48b3cf7bb6cb9eb39fe3e9e8a701f7 ]

The previous patch ensures that the TX flags (struct
can_isotp_ll_options::tx_flags) are 0 for classic CAN frames or a user
configured value for CAN-FD frames.

This patch sets the CAN frames flags unconditionally to the ISO-TP TX
flags, so that they are initialized to a proper value. Otherwise when
running "candump -x" on a classical CAN ISO-TP stream shows wrongly
set "B" and "E" flags.

| $ candump any,0:0,# -extA
| [...]
| can0  TX B E  713   [8]  2B 0A 0B 0C 0D 0E 0F 00
| can0  TX B E  713   [8]  2C 01 02 03 04 05 06 07
| can0  TX B E  713   [8]  2D 08 09 0A 0B 0C 0D 0E
| can0  TX B E  713   [8]  2E 0F 00 01 02 03 04 05

Fixes: e057dd3fc20f ("can: add ISO 15765-2:2016 transport protocol")
Link: https://lore.kernel.org/r/20210218215434.1708249-2-...@pengutronix.de
Cc: Oliver Hartkopp 
Signed-off-by: Marc Kleine-Budde 
Signed-off-by: Sasha Levin 
---
 net/can/isotp.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/net/can/isotp.c b/net/can/isotp.c
index a9b96a6e6317..b01662d2f2cd 100644
--- a/net/can/isotp.c
+++ b/net/can/isotp.c
@@ -215,8 +215,7 @@ static int isotp_send_fc(struct sock *sk, int ae, u8 
flowstatus)
if (ae)
ncf->data[0] = so->opt.ext_address;
 
-   if (so->ll.mtu == CANFD_MTU)
-   ncf->flags = so->ll.tx_flags;
+   ncf->flags = so->ll.tx_flags;
 
can_send_ret = can_send(nskb, 1);
if (can_send_ret)
@@ -790,8 +789,7 @@ isotp_tx_burst:
so->tx.sn %= 16;
so->tx.bs++;
 
-   if (so->ll.mtu == CANFD_MTU)
-   cf->flags = so->ll.tx_flags;
+   cf->flags = so->ll.tx_flags;
 
skb->dev = dev;
can_skb_set_owner(skb, sk);
@@ -934,8 +932,7 @@ static int isotp_sendmsg(struct socket *sock, struct msghdr 
*msg, size_t size)
}
 
/* send the first or only CAN frame */
-   if (so->ll.mtu == CANFD_MTU)
-   cf->flags = so->ll.tx_flags;
+   cf->flags = so->ll.tx_flags;
 
skb->dev = dev;
skb->sk = sk;
-- 
2.30.1





[PATCH 5.10 128/221] can: kvaser_pciefd: Always disable bus load reporting

2021-03-29 Thread Greg Kroah-Hartman
From: Jimmy Assarsson 

[ Upstream commit 7c6e6bce08f918b64459415f58061d4d6df44994 ]

Under certain circumstances, when switching from Kvaser's linuxcan driver
(kvpciefd) to the SocketCAN driver (kvaser_pciefd), the bus load reporting
is not disabled.
This is flooding the kernel log with prints like:
[3485.574677] kvaser_pciefd :02:00.0: Received unexpected packet type 
0x0009

Always put the controller in the expected state, instead of assuming that
bus load reporting is inactive.

Note: If bus load reporting is enabled when the driver is loaded, you will
  still get a number of bus load packages (and printouts), before it is
  disabled.

Fixes: 26ad340e582d ("can: kvaser_pciefd: Add driver for Kvaser PCIEcan 
devices")
Link: https://lore.kernel.org/r/20210309091724.31262-1-jimmyassars...@gmail.com
Signed-off-by: Jimmy Assarsson 
Signed-off-by: Marc Kleine-Budde 
Signed-off-by: Sasha Levin 
---
 drivers/net/can/kvaser_pciefd.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/can/kvaser_pciefd.c b/drivers/net/can/kvaser_pciefd.c
index 43151dd6cb1c..99323c273aa5 100644
--- a/drivers/net/can/kvaser_pciefd.c
+++ b/drivers/net/can/kvaser_pciefd.c
@@ -57,6 +57,7 @@ MODULE_DESCRIPTION("CAN driver for Kvaser CAN/PCIe devices");
 #define KVASER_PCIEFD_KCAN_STAT_REG 0x418
 #define KVASER_PCIEFD_KCAN_MODE_REG 0x41c
 #define KVASER_PCIEFD_KCAN_BTRN_REG 0x420
+#define KVASER_PCIEFD_KCAN_BUS_LOAD_REG 0x424
 #define KVASER_PCIEFD_KCAN_BTRD_REG 0x428
 #define KVASER_PCIEFD_KCAN_PWM_REG 0x430
 /* Loopback control register */
@@ -949,6 +950,9 @@ static int kvaser_pciefd_setup_can_ctrls(struct 
kvaser_pciefd *pcie)
timer_setup(&can->bec_poll_timer, kvaser_pciefd_bec_poll_timer,
0);
 
+   /* Disable Bus load reporting */
+   iowrite32(0, can->reg_base + KVASER_PCIEFD_KCAN_BUS_LOAD_REG);
+
tx_npackets = ioread32(can->reg_base +
   KVASER_PCIEFD_KCAN_TX_NPACKETS_REG);
if (((tx_npackets >> KVASER_PCIEFD_KCAN_TX_NPACKETS_MAX_SHIFT) &
-- 
2.30.1





[PATCH 5.10 102/221] macvlan: macvlan_count_rx() needs to be aware of preemption

2021-03-29 Thread Greg Kroah-Hartman
From: Eric Dumazet 

[ Upstream commit dd4fa1dae9f4847cc1fd78ca468ad69e16e5db3e ]

macvlan_count_rx() can be called from process context, it is thus
necessary to disable preemption before calling u64_stats_update_begin()

syzbot was able to spot this on 32bit arch:

WARNING: CPU: 1 PID: 4632 at include/linux/seqlock.h:271 __seqprop_assert 
include/linux/seqlock.h:271 [inline]
WARNING: CPU: 1 PID: 4632 at include/linux/seqlock.h:271 
__seqprop_assert.constprop.0+0xf0/0x11c include/linux/seqlock.h:269
Modules linked in:
Kernel panic - not syncing: panic_on_warn set ...
CPU: 1 PID: 4632 Comm: kworker/1:3 Not tainted 5.12.0-rc2-syzkaller #0
Hardware name: ARM-Versatile Express
Workqueue: events macvlan_process_broadcast
Backtrace:
[<82740468>] (dump_backtrace) from [<827406dc>] (show_stack+0x18/0x1c 
arch/arm/kernel/traps.c:252)
 r7:0080 r6:6093 r5: r4:8422a3c4
[<827406c4>] (show_stack) from [<82751b58>] (__dump_stack lib/dump_stack.c:79 
[inline])
[<827406c4>] (show_stack) from [<82751b58>] (dump_stack+0xb8/0xe8 
lib/dump_stack.c:120)
[<82751aa0>] (dump_stack) from [<82741270>] (panic+0x130/0x378 
kernel/panic.c:231)
 r7:830209b4 r6:84069ea4 r5: r4:844350d0
[<82741140>] (panic) from [<80244924>] (__warn+0xb0/0x164 kernel/panic.c:605)
 r3:8404ec8c r2: r1: r0:830209b4
 r7:010f
[<80244874>] (__warn) from [<82741520>] (warn_slowpath_fmt+0x68/0xd4 
kernel/panic.c:628)
 r7:81363f70 r6:010f r5:83018e50 r4:
[<827414bc>] (warn_slowpath_fmt) from [<81363f70>] (__seqprop_assert 
include/linux/seqlock.h:271 [inline])
[<827414bc>] (warn_slowpath_fmt) from [<81363f70>] 
(__seqprop_assert.constprop.0+0xf0/0x11c include/linux/seqlock.h:269)
 r8:5a109000 r7:000f r6:a568dac0 r5:89802300 r4:0001
[<81363e80>] (__seqprop_assert.constprop.0) from [<81364af0>] 
(u64_stats_update_begin include/linux/u64_stats_sync.h:128 [inline])
[<81363e80>] (__seqprop_assert.constprop.0) from [<81364af0>] (macvlan_count_rx 
include/linux/if_macvlan.h:47 [inline])
[<81363e80>] (__seqprop_assert.constprop.0) from [<81364af0>] 
(macvlan_broadcast+0x154/0x26c drivers/net/macvlan.c:291)
 r5:89802300 r4:8a927740
[<8136499c>] (macvlan_broadcast) from [<81365020>] 
(macvlan_process_broadcast+0x258/0x2d0 drivers/net/macvlan.c:317)
 r10:81364f78 r9:8a86d000 r8:8a9c7e7c r7:8413aa5c r6: r5:
 r4:89802840
[<81364dc8>] (macvlan_process_broadcast) from [<802696a4>] 
(process_one_work+0x2d4/0x998 kernel/workqueue.c:2275)
 r10:0008 r9:8404ec98 r8:84367a02 r7:ddfe6400 r6:ddfe2d40 r5:898dac80
 r4:8a86d43c
[<802693d0>] (process_one_work) from [<80269dcc>] (worker_thread+0x64/0x54c 
kernel/workqueue.c:2421)
 r10:0008 r9:8a9c6000 r8:84006d00 r7:ddfe2d78 r6:898dac94 r5:ddfe2d40
 r4:898dac80
[<80269d68>] (worker_thread) from [<80271f40>] (kthread+0x184/0x1a4 
kernel/kthread.c:292)
 r10:85247e64 r9:898dac80 r8:80269d68 r7: r6:8a9c6000 r5:89a2ee40
 r4:8a97bd00
[<80271dbc>] (kthread) from [<80200114>] (ret_from_fork+0x14/0x20 
arch/arm/kernel/entry-common.S:158)
Exception stack(0x8a9c7fb0 to 0x8a9c7ff8)

Fixes: 412ca1550cbe ("macvlan: Move broadcasts into a work queue")
Signed-off-by: Eric Dumazet 
Cc: Herbert Xu 
Reported-by: syzbot 
Acked-by: Herbert Xu 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 include/linux/if_macvlan.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/if_macvlan.h b/include/linux/if_macvlan.h
index a367ead4bf4b..e11555989090 100644
--- a/include/linux/if_macvlan.h
+++ b/include/linux/if_macvlan.h
@@ -42,13 +42,14 @@ static inline void macvlan_count_rx(const struct 
macvlan_dev *vlan,
if (likely(success)) {
struct vlan_pcpu_stats *pcpu_stats;
 
-   pcpu_stats = this_cpu_ptr(vlan->pcpu_stats);
+   pcpu_stats = get_cpu_ptr(vlan->pcpu_stats);
u64_stats_update_begin(&pcpu_stats->syncp);
pcpu_stats->rx_packets++;
pcpu_stats->rx_bytes += len;
if (multicast)
pcpu_stats->rx_multicast++;
u64_stats_update_end(&pcpu_stats->syncp);
+   put_cpu_ptr(vlan->pcpu_stats);
} else {
this_cpu_inc(vlan->pcpu_stats->rx_errors);
}
-- 
2.30.1





[PATCH 5.10 124/221] can: isotp: isotp_setsockopt(): only allow to set low level TX flags for CAN-FD

2021-03-29 Thread Greg Kroah-Hartman
From: Marc Kleine-Budde 

[ Upstream commit e4912459bd5edd493b61bc7c3a5d9b2eb17f5a89 ]

CAN-FD frames have struct canfd_frame::flags, while classic CAN frames
don't.

This patch refuses to set TX flags (struct
can_isotp_ll_options::tx_flags) on non CAN-FD isotp sockets.

Fixes: e057dd3fc20f ("can: add ISO 15765-2:2016 transport protocol")
Link: https://lore.kernel.org/r/20210218215434.1708249-2-...@pengutronix.de
Cc: Oliver Hartkopp 
Signed-off-by: Marc Kleine-Budde 
Signed-off-by: Sasha Levin 
---
 net/can/isotp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/can/isotp.c b/net/can/isotp.c
index 8bd565f2073e..a9b96a6e6317 100644
--- a/net/can/isotp.c
+++ b/net/can/isotp.c
@@ -1212,7 +1212,8 @@ static int isotp_setsockopt(struct socket *sock, int 
level, int optname,
if (ll.mtu != CAN_MTU && ll.mtu != CANFD_MTU)
return -EINVAL;
 
-   if (ll.mtu == CAN_MTU && ll.tx_dl > CAN_MAX_DLEN)
+   if (ll.mtu == CAN_MTU &&
+   (ll.tx_dl > CAN_MAX_DLEN || ll.tx_flags != 0))
return -EINVAL;
 
memcpy(&so->ll, &ll, sizeof(ll));
-- 
2.30.1





[PATCH 5.10 130/221] can: c_can: move runtime PM enable/disable to c_can_platform

2021-03-29 Thread Greg Kroah-Hartman
From: Tong Zhang 

[ Upstream commit 6e2fe01dd6f98da6cae8b07cd5cfa67abc70d97d ]

Currently doing modprobe c_can_pci will make the kernel complain:

Unbalanced pm_runtime_enable!

this is caused by pm_runtime_enable() called before pm is initialized.

This fix is similar to 227619c3ff7c, move those pm_enable/disable code
to c_can_platform.

Fixes: 4cdd34b26826 ("can: c_can: Add runtime PM support to Bosch C_CAN/D_CAN 
controller")
Link: http://lore.kernel.org/r/20210302025542.987600-1-ztong0...@gmail.com
Signed-off-by: Tong Zhang 
Tested-by: Uwe Kleine-König 
Signed-off-by: Marc Kleine-Budde 
Signed-off-by: Sasha Levin 
---
 drivers/net/can/c_can/c_can.c  | 24 +---
 drivers/net/can/c_can/c_can_platform.c |  6 +-
 2 files changed, 6 insertions(+), 24 deletions(-)

diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
index 1a9e9b9a4bf6..6c75e5897620 100644
--- a/drivers/net/can/c_can/c_can.c
+++ b/drivers/net/can/c_can/c_can.c
@@ -212,18 +212,6 @@ static const struct can_bittiming_const 
c_can_bittiming_const = {
.brp_inc = 1,
 };
 
-static inline void c_can_pm_runtime_enable(const struct c_can_priv *priv)
-{
-   if (priv->device)
-   pm_runtime_enable(priv->device);
-}
-
-static inline void c_can_pm_runtime_disable(const struct c_can_priv *priv)
-{
-   if (priv->device)
-   pm_runtime_disable(priv->device);
-}
-
 static inline void c_can_pm_runtime_get_sync(const struct c_can_priv *priv)
 {
if (priv->device)
@@ -1335,7 +1323,6 @@ static const struct net_device_ops c_can_netdev_ops = {
 
 int register_c_can_dev(struct net_device *dev)
 {
-   struct c_can_priv *priv = netdev_priv(dev);
int err;
 
/* Deactivate pins to prevent DRA7 DCAN IP from being
@@ -1345,28 +1332,19 @@ int register_c_can_dev(struct net_device *dev)
 */
pinctrl_pm_select_sleep_state(dev->dev.parent);
 
-   c_can_pm_runtime_enable(priv);
-
dev->flags |= IFF_ECHO; /* we support local echo */
dev->netdev_ops = &c_can_netdev_ops;
 
err = register_candev(dev);
-   if (err)
-   c_can_pm_runtime_disable(priv);
-   else
+   if (!err)
devm_can_led_init(dev);
-
return err;
 }
 EXPORT_SYMBOL_GPL(register_c_can_dev);
 
 void unregister_c_can_dev(struct net_device *dev)
 {
-   struct c_can_priv *priv = netdev_priv(dev);
-
unregister_candev(dev);
-
-   c_can_pm_runtime_disable(priv);
 }
 EXPORT_SYMBOL_GPL(unregister_c_can_dev);
 
diff --git a/drivers/net/can/c_can/c_can_platform.c 
b/drivers/net/can/c_can/c_can_platform.c
index 05f425ceb53a..47b251b1607c 100644
--- a/drivers/net/can/c_can/c_can_platform.c
+++ b/drivers/net/can/c_can/c_can_platform.c
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -386,6 +387,7 @@ static int c_can_plat_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, dev);
SET_NETDEV_DEV(dev, &pdev->dev);
 
+   pm_runtime_enable(priv->device);
ret = register_c_can_dev(dev);
if (ret) {
dev_err(&pdev->dev, "registering %s failed (err=%d)\n",
@@ -398,6 +400,7 @@ static int c_can_plat_probe(struct platform_device *pdev)
return 0;
 
 exit_free_device:
+   pm_runtime_disable(priv->device);
free_c_can_dev(dev);
 exit:
dev_err(&pdev->dev, "probe failed\n");
@@ -408,9 +411,10 @@ exit:
 static int c_can_plat_remove(struct platform_device *pdev)
 {
struct net_device *dev = platform_get_drvdata(pdev);
+   struct c_can_priv *priv = netdev_priv(dev);
 
unregister_c_can_dev(dev);
-
+   pm_runtime_disable(priv->device);
free_c_can_dev(dev);
 
return 0;
-- 
2.30.1





[PATCH 5.10 133/221] mac80211: fix rate mask reset

2021-03-29 Thread Greg Kroah-Hartman
From: Johannes Berg 

[ Upstream commit 1944015fe9c1d9fa5e9eb7ffbbb5ef8954d6753b ]

Coverity reported the strange "if (~...)" condition that's
always true. It suggested that ! was intended instead of ~,
but upon further analysis I'm convinced that what really was
intended was a comparison to 0xff/0x (in HT/VHT cases
respectively), since this indicates that all of the rates
are enabled.

Change the comparison accordingly.

I'm guessing this never really mattered because a reset to
not having a rate mask is basically equivalent to having a
mask that enables all rates.

Reported-by: Colin Ian King 
Fixes: 2ffbe6d33366 ("mac80211: fix and optimize MCS mask handling")
Fixes: b119ad6e726c ("mac80211: add rate mask logic for vht rates")
Reviewed-by: Colin Ian King 
Link: 
https://lore.kernel.org/r/20210212112213.36b38078f569.I8546a20c80bc1669058eb453e213630b846e107b@changeid
Signed-off-by: Johannes Berg 
Signed-off-by: Sasha Levin 
---
 net/mac80211/cfg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 7276e66ae435..2bf6271d9e3f 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2961,14 +2961,14 @@ static int ieee80211_set_bitrate_mask(struct wiphy 
*wiphy,
continue;
 
for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++) {
-   if (~sdata->rc_rateidx_mcs_mask[i][j]) {
+   if (sdata->rc_rateidx_mcs_mask[i][j] != 0xff) {
sdata->rc_has_mcs_mask[i] = true;
break;
}
}
 
for (j = 0; j < NL80211_VHT_NSS_MAX; j++) {
-   if (~sdata->rc_rateidx_vht_mcs_mask[i][j]) {
+   if (sdata->rc_rateidx_vht_mcs_mask[i][j] != 0x) {
sdata->rc_has_vht_mcs_mask[i] = true;
break;
}
-- 
2.30.1





[PATCH 5.10 137/221] nfp: flower: add ipv6 bit to pre_tunnel control message

2021-03-29 Thread Greg Kroah-Hartman
From: Louis Peens 

[ Upstream commit 5c4f5e19d6a8e159127b9d653bb67e0dc7a28047 ]

Differentiate between ipv4 and ipv6 flows when configuring the pre_tunnel
table to prevent them trampling each other in the table.

Fixes: 783461604f7e ("nfp: flower: update flow merge code to support IPv6 
tunnels")
Signed-off-by: Louis Peens 
Signed-off-by: Simon Horman 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 .../ethernet/netronome/nfp/flower/tunnel_conf.c   | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c 
b/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c
index 7248d248f604..d19c02e99114 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c
@@ -16,8 +16,9 @@
 #define NFP_FL_MAX_ROUTES   32
 
 #define NFP_TUN_PRE_TUN_RULE_LIMIT 32
-#define NFP_TUN_PRE_TUN_RULE_DEL   0x1
-#define NFP_TUN_PRE_TUN_IDX_BIT0x8
+#define NFP_TUN_PRE_TUN_RULE_DEL   BIT(0)
+#define NFP_TUN_PRE_TUN_IDX_BITBIT(3)
+#define NFP_TUN_PRE_TUN_IPV6_BIT   BIT(7)
 
 /**
  * struct nfp_tun_pre_run_rule - rule matched before decap
@@ -1268,6 +1269,7 @@ int nfp_flower_xmit_pre_tun_flow(struct nfp_app *app,
 {
struct nfp_flower_priv *app_priv = app->priv;
struct nfp_tun_offloaded_mac *mac_entry;
+   struct nfp_flower_meta_tci *key_meta;
struct nfp_tun_pre_tun_rule payload;
struct net_device *internal_dev;
int err;
@@ -1290,6 +1292,15 @@ int nfp_flower_xmit_pre_tun_flow(struct nfp_app *app,
if (!mac_entry)
return -ENOENT;
 
+   /* Set/clear IPV6 bit. cpu_to_be16() swap will lead to MSB being
+* set/clear for port_idx.
+*/
+   key_meta = (struct nfp_flower_meta_tci *)flow->unmasked_data;
+   if (key_meta->nfp_flow_key_layer & NFP_FLOWER_LAYER_IPV6)
+   mac_entry->index |= NFP_TUN_PRE_TUN_IPV6_BIT;
+   else
+   mac_entry->index &= ~NFP_TUN_PRE_TUN_IPV6_BIT;
+
payload.port_idx = cpu_to_be16(mac_entry->index);
 
/* Copy mac id and vlan to flow - dev may not exist at delete time. */
-- 
2.30.1





[PATCH 5.10 127/221] can: flexcan: flexcan_chip_freeze(): fix chip freeze for missing bitrate

2021-03-29 Thread Greg Kroah-Hartman
From: Angelo Dureghello 

[ Upstream commit 47c5e474bc1e1061fb037d13b5000b38967eb070 ]

For cases when flexcan is built-in, bitrate is still not set at
registering. So flexcan_chip_freeze() generates:

[1.86] *** ZERO DIVIDE ***   FORMAT=4
[1.86] Current process id is 1
[1.86] BAD KERNEL TRAP: 
[1.86] PC: [<402e70c8>] flexcan_chip_freeze+0x1a/0xa8

To allow chip freeze, using an hardcoded timeout when bitrate is still
not set.

Fixes: ec15e27cc890 ("can: flexcan: enable RX FIFO after FRZ/HALT valid")
Link: https://lore.kernel.org/r/20210315231510.650593-1-ang...@kernel-space.org
Signed-off-by: Angelo Dureghello 
[mkl: use if instead of ? operator]
Signed-off-by: Marc Kleine-Budde 
Signed-off-by: Sasha Levin 
---
 drivers/net/can/flexcan.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index d712c6fdbc87..7cbaac238ff6 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -658,9 +658,15 @@ static int flexcan_chip_disable(struct flexcan_priv *priv)
 static int flexcan_chip_freeze(struct flexcan_priv *priv)
 {
struct flexcan_regs __iomem *regs = priv->regs;
-   unsigned int timeout = 1000 * 1000 * 10 / priv->can.bittiming.bitrate;
+   unsigned int timeout;
+   u32 bitrate = priv->can.bittiming.bitrate;
u32 reg;
 
+   if (bitrate)
+   timeout = 1000 * 1000 * 10 / bitrate;
+   else
+   timeout = FLEXCAN_TIMEOUT_US / 10;
+
reg = priv->read(®s->mcr);
reg |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_HALT;
priv->write(reg, ®s->mcr);
-- 
2.30.1





[PATCH 5.10 131/221] can: m_can: m_can_do_rx_poll(): fix extraneous msg loss warning

2021-03-29 Thread Greg Kroah-Hartman
From: Torin Cooper-Bennun 

[ Upstream commit c0e399f3baf42279f48991554240af8c457535d1 ]

Message loss from RX FIFO 0 is already handled in
m_can_handle_lost_msg(), with netdev output included.

Removing this warning also improves driver performance under heavy
load, where m_can_do_rx_poll() may be called many times before this
interrupt is cleared, causing this message to be output many
times (thanks Mariusz Madej for this report).

Fixes: e0d1f4816f2a ("can: m_can: add Bosch M_CAN controller support")
Link: 
https://lore.kernel.org/r/20210303103151.3760532-1-to...@maxiluxsystems.com
Reported-by: Mariusz Madej 
Signed-off-by: Torin Cooper-Bennun 
Signed-off-by: Marc Kleine-Budde 
Signed-off-by: Sasha Levin 
---
 drivers/net/can/m_can/m_can.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 3c1e37975168..6952d5b396e8 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -502,9 +502,6 @@ static int m_can_do_rx_poll(struct net_device *dev, int 
quota)
}
 
while ((rxfs & RXFS_FFL_MASK) && (quota > 0)) {
-   if (rxfs & RXFS_RFL)
-   netdev_warn(dev, "Rx FIFO 0 Message Lost\n");
-
m_can_read_fifo(dev, rxfs);
 
quota--;
-- 
2.30.1





[PATCH] hwmon: (nzxt-kraken2) mark and order concurrent accesses

2021-03-29 Thread Jonas Malaco
To avoid a spinlock, the driver explores concurrent memory accesses
between _raw_event and _read, having the former updating fields on a
data structure while the latter could be reading from them.  Because
these are "plain" accesses, those are data races according to the Linux
kernel memory model (LKMM).

Data races are undefined behavior in both C11 and LKMM.  In practice,
the compiler is free to make optimizations assuming there is no data
race, including load tearing, load fusing and many others,[1] most of
which could result in corruption of the values reported to user-space.

Prevent undesirable optimizations to those concurrent accesses by
marking them with READ_ONCE() and WRITE_ONCE().  This also removes the
data races, according to the LKMM, because both loads and stores to each
location are now "marked" accesses.

As a special case, use smp_load_acquire() and smp_load_release() when
loading and storing ->updated, as it is used to track the validity of
the other values, and thus has to be stored after and loaded before
them.  These imply READ_ONCE()/WRITE_ONCE() but also ensure the desired
order of memory accesses.

[1] https://lwn.net/Articles/793253/

Signed-off-by: Jonas Malaco 
---
 drivers/hwmon/nzxt-kraken2.c | 23 ---
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/hwmon/nzxt-kraken2.c b/drivers/hwmon/nzxt-kraken2.c
index 89f7ea4f42d4..f4fbc8771930 100644
--- a/drivers/hwmon/nzxt-kraken2.c
+++ b/drivers/hwmon/nzxt-kraken2.c
@@ -46,16 +46,22 @@ static int kraken2_read(struct device *dev, enum 
hwmon_sensor_types type,
u32 attr, int channel, long *val)
 {
struct kraken2_priv_data *priv = dev_get_drvdata(dev);
+   unsigned long expires;
 
-   if (time_after(jiffies, priv->updated + STATUS_VALIDITY * HZ))
+   /*
+* Order load from ->updated before the data it refers to.
+*/
+   expires = smp_load_acquire(&priv->updated) + STATUS_VALIDITY * HZ;
+
+   if (time_after(jiffies, expires))
return -ENODATA;
 
switch (type) {
case hwmon_temp:
-   *val = priv->temp_input[channel];
+   *val = READ_ONCE(priv->temp_input[channel]);
break;
case hwmon_fan:
-   *val = priv->fan_input[channel];
+   *val = READ_ONCE(priv->fan_input[channel]);
break;
default:
return -EOPNOTSUPP; /* unreachable */
@@ -119,12 +125,15 @@ static int kraken2_raw_event(struct hid_device *hdev,
 * and that the missing steps are artifacts of how the firmware
 * processes the raw sensor data.
 */
-   priv->temp_input[0] = data[1] * 1000 + data[2] * 100;
+   WRITE_ONCE(priv->temp_input[0], data[1] * 1000 + data[2] * 100);
 
-   priv->fan_input[0] = get_unaligned_be16(data + 3);
-   priv->fan_input[1] = get_unaligned_be16(data + 5);
+   WRITE_ONCE(priv->fan_input[0], get_unaligned_be16(data + 3));
+   WRITE_ONCE(priv->fan_input[1], get_unaligned_be16(data + 5));
 
-   priv->updated = jiffies;
+   /*
+* Order store to ->updated after the data it refers to.
+*/
+   smp_store_release(&priv->updated, jiffies);
 
return 0;
 }

base-commit: 644b9af5c605762feffac96bd7ea2499e0197656
-- 
2.31.1



[PATCH 5.10 134/221] mac80211: Allow HE operation to be longer than expected.

2021-03-29 Thread Greg Kroah-Hartman
From: Brian Norris 

[ Upstream commit 0f7e90faddeef53a3568f449a0c3992d77510b66 ]

We observed some Cisco APs sending the following HE Operation IE in
associate response:

  ff 0a 24 f4 3f 00 01 fc ff 00 00 00

Its HE operation parameter is 0x003ff4, so the expected total length is
7 which does not match the actual length = 10. This causes association
failing with "HE AP is missing HE Capability/operation."

According to P802.11ax_D4 Table9-94, HE operation is extensible, and
according to 802.11-2016 10.27.8, STA should discard the part beyond
the maximum length and parse the truncated element.

Allow HE operation element to be longer than expected to handle this
case and future extensions.

Fixes: e4d005b80dee ("mac80211: refactor extended element parsing")
Signed-off-by: Brian Norris 
Signed-off-by: Yen-lin Lai 
Link: https://lore.kernel.org/r/20210223051926.2653301-1-yenlin...@chromium.org
Signed-off-by: Johannes Berg 
Signed-off-by: Sasha Levin 
---
 net/mac80211/mlme.c | 2 +-
 net/mac80211/util.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 6adfcb9c06dc..3f483e84d5df 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -5023,7 +5023,7 @@ static int ieee80211_prep_channel(struct 
ieee80211_sub_if_data *sdata,
he_oper_ie = cfg80211_find_ext_ie(WLAN_EID_EXT_HE_OPERATION,
  ies->data, ies->len);
if (he_oper_ie &&
-   he_oper_ie[1] == ieee80211_he_oper_size(&he_oper_ie[3]))
+   he_oper_ie[1] >= ieee80211_he_oper_size(&he_oper_ie[3]))
he_oper = (void *)(he_oper_ie + 3);
else
he_oper = NULL;
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 94e624e9439b..d8f9fb0646a4 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -967,7 +967,7 @@ static void ieee80211_parse_extension_element(u32 *crc,
break;
case WLAN_EID_EXT_HE_OPERATION:
if (len >= sizeof(*elems->he_operation) &&
-   len == ieee80211_he_oper_size(data) - 1) {
+   len >= ieee80211_he_oper_size(data) - 1) {
if (crc)
*crc = crc32_be(*crc, (void *)elem,
elem->datalen + 2);
-- 
2.30.1





[PATCH 5.10 104/221] net: dsa: bcm_sf2: Qualify phydev->dev_flags based on port

2021-03-29 Thread Greg Kroah-Hartman
From: Florian Fainelli 

[ Upstream commit 47142ed6c34d544ae9f0463e58d482289cbe0d46 ]

Similar to commit 92696286f3bb37ba50e4bd8d1beb24afb759a799 ("net:
bcmgenet: Set phydev->dev_flags only for internal PHYs") we need to
qualify the phydev->dev_flags based on whether the port is connected to
an internal or external PHY otherwise we risk having a flags collision
with a completely different interpretation depending on the driver.

Fixes: aa9aef77c761 ("net: dsa: bcm_sf2: communicate integrated PHY revision to 
PHY driver")
Signed-off-by: Florian Fainelli 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/dsa/bcm_sf2.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index edb0a1027b38..510324916e91 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -584,8 +584,10 @@ static u32 bcm_sf2_sw_get_phy_flags(struct dsa_switch *ds, 
int port)
 * in bits 15:8 and the patch level in bits 7:0 which is exactly what
 * the REG_PHY_REVISION register layout is.
 */
-
-   return priv->hw_params.gphy_rev;
+   if (priv->int_phy_mask & BIT(port))
+   return priv->hw_params.gphy_rev;
+   else
+   return 0;
 }
 
 static void bcm_sf2_sw_validate(struct dsa_switch *ds, int port,
-- 
2.30.1





[PATCH 5.10 135/221] selftests/net: fix warnings on reuseaddr_ports_exhausted

2021-03-29 Thread Greg Kroah-Hartman
From: Carlos Llamas 

[ Upstream commit 81f711d67a973bf8a6db9556faf299b4074d536e ]

Fix multiple warnings seen with gcc 10.2.1:
reuseaddr_ports_exhausted.c:32:41: warning: missing braces around initializer 
[-Wmissing-braces]
   32 | struct reuse_opts unreusable_opts[12] = {
  | ^
   33 |  {0, 0, 0, 0},
  |   {   } {   }

Fixes: 7f204a7de8b0 ("selftests: net: Add SO_REUSEADDR test to check if 
4-tuples are fully utilized.")
Signed-off-by: Carlos Llamas 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 .../selftests/net/reuseaddr_ports_exhausted.c | 32 +--
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/tools/testing/selftests/net/reuseaddr_ports_exhausted.c 
b/tools/testing/selftests/net/reuseaddr_ports_exhausted.c
index 7b01b7c2ec10..066efd30e294 100644
--- a/tools/testing/selftests/net/reuseaddr_ports_exhausted.c
+++ b/tools/testing/selftests/net/reuseaddr_ports_exhausted.c
@@ -30,25 +30,25 @@ struct reuse_opts {
 };
 
 struct reuse_opts unreusable_opts[12] = {
-   {0, 0, 0, 0},
-   {0, 0, 0, 1},
-   {0, 0, 1, 0},
-   {0, 0, 1, 1},
-   {0, 1, 0, 0},
-   {0, 1, 0, 1},
-   {0, 1, 1, 0},
-   {0, 1, 1, 1},
-   {1, 0, 0, 0},
-   {1, 0, 0, 1},
-   {1, 0, 1, 0},
-   {1, 0, 1, 1},
+   {{0, 0}, {0, 0}},
+   {{0, 0}, {0, 1}},
+   {{0, 0}, {1, 0}},
+   {{0, 0}, {1, 1}},
+   {{0, 1}, {0, 0}},
+   {{0, 1}, {0, 1}},
+   {{0, 1}, {1, 0}},
+   {{0, 1}, {1, 1}},
+   {{1, 0}, {0, 0}},
+   {{1, 0}, {0, 1}},
+   {{1, 0}, {1, 0}},
+   {{1, 0}, {1, 1}},
 };
 
 struct reuse_opts reusable_opts[4] = {
-   {1, 1, 0, 0},
-   {1, 1, 0, 1},
-   {1, 1, 1, 0},
-   {1, 1, 1, 1},
+   {{1, 1}, {0, 0}},
+   {{1, 1}, {0, 1}},
+   {{1, 1}, {1, 0}},
+   {{1, 1}, {1, 1}},
 };
 
 int bind_port(struct __test_metadata *_metadata, int reuseaddr, int reuseport)
-- 
2.30.1





[PATCH 5.10 136/221] nfp: flower: fix unsupported pre_tunnel flows

2021-03-29 Thread Greg Kroah-Hartman
From: Louis Peens 

[ Upstream commit 982e5ee23d764fe6158f67a7813d416335e978b0 ]

There are some pre_tunnel flows combinations which are incorrectly being
offloaded without proper support, fix these.

- Matching on MPLS is not supported for pre_tun.
- Match on IPv4/IPv6 layer must be present.
- Destination MAC address must match pre_tun.dev MAC

Fixes: 120ffd84a9ec ("nfp: flower: verify pre-tunnel rules")
Signed-off-by: Louis Peens 
Signed-off-by: Simon Horman 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 .../ethernet/netronome/nfp/flower/offload.c| 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c 
b/drivers/net/ethernet/netronome/nfp/flower/offload.c
index 1c59aff2163c..d72225d64a75 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/offload.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c
@@ -1142,6 +1142,12 @@ nfp_flower_validate_pre_tun_rule(struct nfp_app *app,
return -EOPNOTSUPP;
}
 
+   if (!(key_layer & NFP_FLOWER_LAYER_IPV4) &&
+   !(key_layer & NFP_FLOWER_LAYER_IPV6)) {
+   NL_SET_ERR_MSG_MOD(extack, "unsupported pre-tunnel rule: match 
on ipv4/ipv6 eth_type must be present");
+   return -EOPNOTSUPP;
+   }
+
/* Skip fields known to exist. */
mask += sizeof(struct nfp_flower_meta_tci);
ext += sizeof(struct nfp_flower_meta_tci);
@@ -1152,6 +1158,13 @@ nfp_flower_validate_pre_tun_rule(struct nfp_app *app,
mask += sizeof(struct nfp_flower_in_port);
ext += sizeof(struct nfp_flower_in_port);
 
+   /* Ensure destination MAC address matches pre_tun_dev. */
+   mac = (struct nfp_flower_mac_mpls *)ext;
+   if (memcmp(&mac->mac_dst[0], flow->pre_tun_rule.dev->dev_addr, 6)) {
+   NL_SET_ERR_MSG_MOD(extack, "unsupported pre-tunnel rule: dest 
MAC must match output dev MAC");
+   return -EOPNOTSUPP;
+   }
+
/* Ensure destination MAC address is fully matched. */
mac = (struct nfp_flower_mac_mpls *)mask;
if (!is_broadcast_ether_addr(&mac->mac_dst[0])) {
@@ -1159,6 +1172,11 @@ nfp_flower_validate_pre_tun_rule(struct nfp_app *app,
return -EOPNOTSUPP;
}
 
+   if (mac->mpls_lse) {
+   NL_SET_ERR_MSG_MOD(extack, "unsupported pre-tunnel rule: MPLS 
not supported");
+   return -EOPNOTSUPP;
+   }
+
mask += sizeof(struct nfp_flower_mac_mpls);
ext += sizeof(struct nfp_flower_mac_mpls);
if (key_layer & NFP_FLOWER_LAYER_IPV4 ||
-- 
2.30.1





[PATCH 5.10 103/221] net: sched: validate stab values

2021-03-29 Thread Greg Kroah-Hartman
From: Eric Dumazet 

[ Upstream commit e323d865b36134e8c5c82c834df89109a5c60dab ]

iproute2 package is well behaved, but malicious user space can
provide illegal shift values and trigger UBSAN reports.

Add stab parameter to red_check_params() to validate user input.

syzbot reported:

UBSAN: shift-out-of-bounds in ./include/net/red.h:312:18
shift exponent 111 is too large for 64-bit type 'long unsigned int'
CPU: 1 PID: 14662 Comm: syz-executor.3 Not tainted 5.12.0-rc2-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 
01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:79 [inline]
 dump_stack+0x141/0x1d7 lib/dump_stack.c:120
 ubsan_epilogue+0xb/0x5a lib/ubsan.c:148
 __ubsan_handle_shift_out_of_bounds.cold+0xb1/0x181 lib/ubsan.c:327
 red_calc_qavg_from_idle_time include/net/red.h:312 [inline]
 red_calc_qavg include/net/red.h:353 [inline]
 choke_enqueue.cold+0x18/0x3dd net/sched/sch_choke.c:221
 __dev_xmit_skb net/core/dev.c:3837 [inline]
 __dev_queue_xmit+0x1943/0x2e00 net/core/dev.c:4150
 neigh_hh_output include/net/neighbour.h:499 [inline]
 neigh_output include/net/neighbour.h:508 [inline]
 ip6_finish_output2+0x911/0x1700 net/ipv6/ip6_output.c:117
 __ip6_finish_output net/ipv6/ip6_output.c:182 [inline]
 __ip6_finish_output+0x4c1/0xe10 net/ipv6/ip6_output.c:161
 ip6_finish_output+0x35/0x200 net/ipv6/ip6_output.c:192
 NF_HOOK_COND include/linux/netfilter.h:290 [inline]
 ip6_output+0x1e4/0x530 net/ipv6/ip6_output.c:215
 dst_output include/net/dst.h:448 [inline]
 NF_HOOK include/linux/netfilter.h:301 [inline]
 NF_HOOK include/linux/netfilter.h:295 [inline]
 ip6_xmit+0x127e/0x1eb0 net/ipv6/ip6_output.c:320
 inet6_csk_xmit+0x358/0x630 net/ipv6/inet6_connection_sock.c:135
 dccp_transmit_skb+0x973/0x12c0 net/dccp/output.c:138
 dccp_send_reset+0x21b/0x2b0 net/dccp/output.c:535
 dccp_finish_passive_close net/dccp/proto.c:123 [inline]
 dccp_finish_passive_close+0xed/0x140 net/dccp/proto.c:118
 dccp_terminate_connection net/dccp/proto.c:958 [inline]
 dccp_close+0xb3c/0xe60 net/dccp/proto.c:1028
 inet_release+0x12e/0x280 net/ipv4/af_inet.c:431
 inet6_release+0x4c/0x70 net/ipv6/af_inet6.c:478
 __sock_release+0xcd/0x280 net/socket.c:599
 sock_close+0x18/0x20 net/socket.c:1258
 __fput+0x288/0x920 fs/file_table.c:280
 task_work_run+0xdd/0x1a0 kernel/task_work.c:140
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]

Fixes: 8afa10cbe281 ("net_sched: red: Avoid illegal values")
Signed-off-by: Eric Dumazet 
Reported-by: syzbot 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 include/net/red.h | 10 +-
 net/sched/sch_choke.c |  7 ---
 net/sched/sch_gred.c  |  2 +-
 net/sched/sch_red.c   |  7 +--
 net/sched/sch_sfq.c   |  2 +-
 5 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/include/net/red.h b/include/net/red.h
index 932f0d79d60c..9e6647c4ccd1 100644
--- a/include/net/red.h
+++ b/include/net/red.h
@@ -168,7 +168,8 @@ static inline void red_set_vars(struct red_vars *v)
v->qcount   = -1;
 }
 
-static inline bool red_check_params(u32 qth_min, u32 qth_max, u8 Wlog, u8 
Scell_log)
+static inline bool red_check_params(u32 qth_min, u32 qth_max, u8 Wlog,
+   u8 Scell_log, u8 *stab)
 {
if (fls(qth_min) + Wlog > 32)
return false;
@@ -178,6 +179,13 @@ static inline bool red_check_params(u32 qth_min, u32 
qth_max, u8 Wlog, u8 Scell_
return false;
if (qth_max < qth_min)
return false;
+   if (stab) {
+   int i;
+
+   for (i = 0; i < RED_STAB_SIZE; i++)
+   if (stab[i] >= 32)
+   return false;
+   }
return true;
 }
 
diff --git a/net/sched/sch_choke.c b/net/sched/sch_choke.c
index 50f680f03a54..2adbd945bf15 100644
--- a/net/sched/sch_choke.c
+++ b/net/sched/sch_choke.c
@@ -345,6 +345,7 @@ static int choke_change(struct Qdisc *sch, struct nlattr 
*opt,
struct sk_buff **old = NULL;
unsigned int mask;
u32 max_P;
+   u8 *stab;
 
if (opt == NULL)
return -EINVAL;
@@ -361,8 +362,8 @@ static int choke_change(struct Qdisc *sch, struct nlattr 
*opt,
max_P = tb[TCA_CHOKE_MAX_P] ? nla_get_u32(tb[TCA_CHOKE_MAX_P]) : 0;
 
ctl = nla_data(tb[TCA_CHOKE_PARMS]);
-
-   if (!red_check_params(ctl->qth_min, ctl->qth_max, ctl->Wlog, 
ctl->Scell_log))
+   stab = nla_data(tb[TCA_CHOKE_STAB]);
+   if (!red_check_params(ctl->qth_min, ctl->qth_max, ctl->Wlog, 
ctl->Scell_log, stab))
return -EINVAL;
 
if (ctl->limit > CHOKE_MAX_QUEUE)
@@ -412,7 +413,7 @@ static int choke_change(struct Qdisc *sch, struct nlattr 
*opt,
 
red_set_parms(&q->parms, ctl->qth_min, ctl->qth_max, ctl->Wlog,
  ctl->Plog, ctl->Scell_log,
- nla_data(tb[TCA_CHOKE_STAB]),
+ stab,
  max_P);
red_set_vars(

[PATCH 5.10 106/221] igc: Fix Pause Frame Advertising

2021-03-29 Thread Greg Kroah-Hartman
From: Muhammad Husaini Zulkifli 

[ Upstream commit 8876529465c368beafd51a70f79d7a738f2aadf4 ]

Fix Pause Frame Advertising when getting the advertisement via ethtool.
Remove setting the "advertising" bit in link_ksettings during default
case when Tx and Rx are in off state with Auto Negotiate off.

Below is the original output of advertisement link during Tx and Rx off:
Advertised pause frame use: Symmetric Receive-only

Expected output:
Advertised pause frame use: No

Fixes: 8c5ad0dae93c ("igc: Add ethtool support")
Signed-off-by: Muhammad Husaini Zulkifli 
Reviewed-by: Malli C 
Acked-by: Sasha Neftin 
Tested-by: Dvora Fuxbrumer 
Signed-off-by: Tony Nguyen 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/intel/igc/igc_ethtool.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c 
b/drivers/net/ethernet/intel/igc/igc_ethtool.c
index ec8cd69d4992..35c104a02bed 100644
--- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
+++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
@@ -1709,9 +1709,7 @@ static int igc_ethtool_get_link_ksettings(struct 
net_device *netdev,
 Asym_Pause);
break;
default:
-   ethtool_link_ksettings_add_link_mode(cmd, advertising, Pause);
-   ethtool_link_ksettings_add_link_mode(cmd, advertising,
-Asym_Pause);
+   break;
}
 
status = pm_runtime_suspended(&adapter->pdev->dev) ?
-- 
2.30.1





[PATCH 5.10 107/221] igc: Fix Supported Pause Frame Link Setting

2021-03-29 Thread Greg Kroah-Hartman
From: Muhammad Husaini Zulkifli 

[ Upstream commit 9a4a1cdc5ab52118c1f2b216f4240830b6528d32 ]

The Supported Pause Frame always display "No" even though the Advertised
pause frame showing the correct setting based on the pause parameters via
ethtool. Set bit in link_ksettings to "Supported" for Pause Frame.

Before output:
Supported pause frame use: No

Expected output:
Supported pause frame use: Symmetric

Fixes: 8c5ad0dae93c ("igc: Add ethtool support")
Signed-off-by: Muhammad Husaini Zulkifli 
Reviewed-by: Malli C 
Tested-by: Dvora Fuxbrumer 
Acked-by: Sasha Neftin 
Signed-off-by: Tony Nguyen 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/intel/igc/igc_ethtool.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c 
b/drivers/net/ethernet/intel/igc/igc_ethtool.c
index 35c104a02bed..da259cd59add 100644
--- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
+++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
@@ -1695,6 +1695,9 @@ static int igc_ethtool_get_link_ksettings(struct 
net_device *netdev,
 Autoneg);
}
 
+   /* Set pause flow control settings */
+   ethtool_link_ksettings_add_link_mode(cmd, supported, Pause);
+
switch (hw->fc.requested_mode) {
case igc_fc_full:
ethtool_link_ksettings_add_link_mode(cmd, advertising, Pause);
-- 
2.30.1





[PATCH 5.10 065/221] netsec: restore phy power state after controller reset

2021-03-29 Thread Greg Kroah-Hartman
From: Mian Yousaf Kaukab 

commit 804741ac7b9f2fdebe3740cb0579cb8d94d49e60 upstream.

Since commit 8e850f25b581 ("net: socionext: Stop PHY before resetting
netsec") netsec_netdev_init() power downs phy before resetting the
controller. However, the state is not restored once the reset is
complete. As a result it is not possible to bring up network on a
platform with Broadcom BCM5482 phy.

Fix the issue by restoring phy power state after controller reset is
complete.

Fixes: 8e850f25b581 ("net: socionext: Stop PHY before resetting netsec")
Cc: sta...@vger.kernel.org
Signed-off-by: Mian Yousaf Kaukab 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/net/ethernet/socionext/netsec.c |9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -1708,14 +1708,17 @@ static int netsec_netdev_init(struct net
goto err1;
 
/* set phy power down */
-   data = netsec_phy_read(priv->mii_bus, priv->phy_addr, MII_BMCR) |
-   BMCR_PDOWN;
-   netsec_phy_write(priv->mii_bus, priv->phy_addr, MII_BMCR, data);
+   data = netsec_phy_read(priv->mii_bus, priv->phy_addr, MII_BMCR);
+   netsec_phy_write(priv->mii_bus, priv->phy_addr, MII_BMCR,
+data | BMCR_PDOWN);
 
ret = netsec_reset_hardware(priv, true);
if (ret)
goto err2;
 
+   /* Restore phy power state */
+   netsec_phy_write(priv->mii_bus, priv->phy_addr, MII_BMCR, data);
+
spin_lock_init(&priv->desc_ring[NETSEC_RING_TX].lock);
spin_lock_init(&priv->desc_ring[NETSEC_RING_RX].lock);
 




[PATCH 5.10 091/221] bus: omap_l3_noc: mark l3 irqs as IRQF_NO_THREAD

2021-03-29 Thread Greg Kroah-Hartman
From: Grygorii Strashko 

[ Upstream commit 7d7275b3e866cf8092bd12553ec53ba26864f7bb ]

The main purpose of l3 IRQs is to catch OCP bus access errors and identify
corresponding code places by showing call stack, so it's important to
handle L3 interconnect errors as fast as possible. On RT these IRQs will
became threaded and will be scheduled much more late from the moment actual
error occurred so showing completely useless information.

Hence, mark l3 IRQs as IRQF_NO_THREAD so they will not be forced threaded
on RT or if force_irqthreads = true.

Fixes: 0ee7261c9212 ("drivers: bus: Move the OMAP interconnect driver to 
drivers/bus/")
Signed-off-by: Grygorii Strashko 
Signed-off-by: Tony Lindgren 
Signed-off-by: Sasha Levin 
---
 drivers/bus/omap_l3_noc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/omap_l3_noc.c b/drivers/bus/omap_l3_noc.c
index b040447575ad..dcfb32ee5cb6 100644
--- a/drivers/bus/omap_l3_noc.c
+++ b/drivers/bus/omap_l3_noc.c
@@ -285,7 +285,7 @@ static int omap_l3_probe(struct platform_device *pdev)
 */
l3->debug_irq = platform_get_irq(pdev, 0);
ret = devm_request_irq(l3->dev, l3->debug_irq, l3_interrupt_handler,
-  0x0, "l3-dbg-irq", l3);
+  IRQF_NO_THREAD, "l3-dbg-irq", l3);
if (ret) {
dev_err(l3->dev, "request_irq failed for %d\n",
l3->debug_irq);
@@ -294,7 +294,7 @@ static int omap_l3_probe(struct platform_device *pdev)
 
l3->app_irq = platform_get_irq(pdev, 1);
ret = devm_request_irq(l3->dev, l3->app_irq, l3_interrupt_handler,
-  0x0, "l3-app-irq", l3);
+  IRQF_NO_THREAD, "l3-app-irq", l3);
if (ret)
dev_err(l3->dev, "request_irq failed for %d\n", l3->app_irq);
 
-- 
2.30.1





[PATCH 5.10 092/221] ARM: OMAP2+: Fix smartreflex init regression after dropping legacy data

2021-03-29 Thread Greg Kroah-Hartman
From: Tony Lindgren 

[ Upstream commit fbfa463be8dc7957ee4f81556e9e1ea2a951807d ]

When I dropped legacy data for omap4 and dra7 smartreflex in favor of
device tree based data, it seems I only testd for the "SmartReflex Class3
initialized" line in dmesg. I missed the fact that there is also
omap_devinit_smartreflex() that happens later, and now it produces an
error on boot for "No Voltage table for the corresponding vdd. Cannot
create debugfs entries for n-values".

This happens as we no longer have the smartreflex instance legacy data,
and have not yet moved completely to device tree based booting for the
driver. Let's fix the issue by changing the smartreflex init to use names.
This should all eventually go away in favor of doing the init in the
driver based on devicetree compatible value.

Note that dra7xx_init_early() is not calling any voltage domain init like
omap54xx_voltagedomains_init(), or a dra7 specific voltagedomains init.
This means that on dra7 smartreflex is still not fully initialized, and
also seems to be missing the related devicetree nodes.

Fixes: a6b1e717e942 ("ARM: OMAP2+: Drop legacy platform data for omap4 
smartreflex")
Fixes: e54740b4afe8 ("ARM: OMAP2+: Drop legacy platform data for dra7 
smartreflex")
Signed-off-by: Tony Lindgren 
Signed-off-by: Sasha Levin 
---
 arch/arm/mach-omap2/sr_device.c | 75 +
 1 file changed, 58 insertions(+), 17 deletions(-)

diff --git a/arch/arm/mach-omap2/sr_device.c b/arch/arm/mach-omap2/sr_device.c
index 62df666c2bd0..17b66f0d0dee 100644
--- a/arch/arm/mach-omap2/sr_device.c
+++ b/arch/arm/mach-omap2/sr_device.c
@@ -88,34 +88,26 @@ static void __init sr_set_nvalues(struct omap_volt_data 
*volt_data,
 
 extern struct omap_sr_data omap_sr_pdata[];
 
-static int __init sr_dev_init(struct omap_hwmod *oh, void *user)
+static int __init sr_init_by_name(const char *name, const char *voltdm)
 {
struct omap_sr_data *sr_data = NULL;
struct omap_volt_data *volt_data;
-   struct omap_smartreflex_dev_attr *sr_dev_attr;
static int i;
 
-   if (!strncmp(oh->name, "smartreflex_mpu_iva", 20) ||
-   !strncmp(oh->name, "smartreflex_mpu", 16))
+   if (!strncmp(name, "smartreflex_mpu_iva", 20) ||
+   !strncmp(name, "smartreflex_mpu", 16))
sr_data = &omap_sr_pdata[OMAP_SR_MPU];
-   else if (!strncmp(oh->name, "smartreflex_core", 17))
+   else if (!strncmp(name, "smartreflex_core", 17))
sr_data = &omap_sr_pdata[OMAP_SR_CORE];
-   else if (!strncmp(oh->name, "smartreflex_iva", 16))
+   else if (!strncmp(name, "smartreflex_iva", 16))
sr_data = &omap_sr_pdata[OMAP_SR_IVA];
 
if (!sr_data) {
-   pr_err("%s: Unknown instance %s\n", __func__, oh->name);
+   pr_err("%s: Unknown instance %s\n", __func__, name);
return -EINVAL;
}
 
-   sr_dev_attr = (struct omap_smartreflex_dev_attr *)oh->dev_attr;
-   if (!sr_dev_attr || !sr_dev_attr->sensor_voltdm_name) {
-   pr_err("%s: No voltage domain specified for %s. Cannot 
initialize\n",
-  __func__, oh->name);
-   goto exit;
-   }
-
-   sr_data->name = oh->name;
+   sr_data->name = name;
if (cpu_is_omap343x())
sr_data->ip_type = 1;
else
@@ -136,10 +128,10 @@ static int __init sr_dev_init(struct omap_hwmod *oh, void 
*user)
}
}
 
-   sr_data->voltdm = voltdm_lookup(sr_dev_attr->sensor_voltdm_name);
+   sr_data->voltdm = voltdm_lookup(voltdm);
if (!sr_data->voltdm) {
pr_err("%s: Unable to get voltage domain pointer for VDD %s\n",
-   __func__, sr_dev_attr->sensor_voltdm_name);
+   __func__, voltdm);
goto exit;
}
 
@@ -160,6 +152,20 @@ exit:
return 0;
 }
 
+static int __init sr_dev_init(struct omap_hwmod *oh, void *user)
+{
+   struct omap_smartreflex_dev_attr *sr_dev_attr;
+
+   sr_dev_attr = (struct omap_smartreflex_dev_attr *)oh->dev_attr;
+   if (!sr_dev_attr || !sr_dev_attr->sensor_voltdm_name) {
+   pr_err("%s: No voltage domain specified for %s. Cannot 
initialize\n",
+  __func__, oh->name);
+   return 0;
+   }
+
+   return sr_init_by_name(oh->name, sr_dev_attr->sensor_voltdm_name);
+}
+
 /*
  * API to be called from board files to enable smartreflex
  * autocompensation at init.
@@ -169,7 +175,42 @@ void __init omap_enable_smartreflex_on_init(void)
sr_enable_on_init = true;
 }
 
+static const char * const omap4_sr_instances[] = {
+   "mpu",
+   "iva",
+   "core",
+};
+
+static const char * const dra7_sr_instances[] = {
+   "mpu",
+   "core",
+};
+
 int __init omap_devinit_smartreflex(void)
 {
+   const char * const *sr_inst;
+   int i, nr_sr = 0;
+
+   if (soc_is_omap44xx()) {
+   sr_inst = omap

[PATCH 5.10 096/221] libbpf: Fix INSTALL flag order

2021-03-29 Thread Greg Kroah-Hartman
From: Georgi Valkov 

[ Upstream commit e7fb6465d4c8e767e39cbee72464e0060ab3d20c ]

It was reported ([0]) that having optional -m flag between source and
destination arguments in install command breaks bpftools cross-build
on MacOS. Move -m to the front to fix this issue.

  [0] https://github.com/openwrt/openwrt/pull/3959

Fixes: 7110d80d53f4 ("libbpf: Makefile set specified permission mode")
Signed-off-by: Georgi Valkov 
Signed-off-by: Andrii Nakryiko 
Signed-off-by: Daniel Borkmann 
Link: https://lore.kernel.org/bpf/20210308183038.613432-1-and...@kernel.org
Signed-off-by: Sasha Levin 
---
 tools/lib/bpf/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile
index 55bd78b3496f..310f647c2d5b 100644
--- a/tools/lib/bpf/Makefile
+++ b/tools/lib/bpf/Makefile
@@ -236,7 +236,7 @@ define do_install
if [ ! -d '$(DESTDIR_SQ)$2' ]; then \
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2'; \
fi; \
-   $(INSTALL) $1 $(if $3,-m $3,) '$(DESTDIR_SQ)$2'
+   $(INSTALL) $(if $3,-m $3,) $1 '$(DESTDIR_SQ)$2'
 endef
 
 install_lib: all_cmd
-- 
2.30.1





[PATCH 5.10 098/221] net/mlx5e: When changing XDP program without reset, take refs for XSK RQs

2021-03-29 Thread Greg Kroah-Hartman
From: Maxim Mikityanskiy 

[ Upstream commit e5eb01344e9b09bb9d255b9727449186f7168df8 ]

Each RQ (including XSK RQs) takes a reference to the XDP program. When
an XDP program is attached or detached, the channels and queues are
recreated, however, there is a special flow for changing an active XDP
program to another one. In that flow, channels and queues stay alive,
but the refcounts of the old and new XDP programs are adjusted. This
flow didn't increment refcount by the number of active XSK RQs, and this
commit fixes it.

Fixes: db05815b36cb ("net/mlx5e: Add XSK zero-copy support")
Signed-off-by: Maxim Mikityanskiy 
Reviewed-by: Tariq Toukan 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 8b0826d689c0..0dc572aaf177 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -4494,8 +4494,10 @@ static int mlx5e_xdp_set(struct net_device *netdev, 
struct bpf_prog *prog)
struct mlx5e_channel *c = priv->channels.c[i];
 
mlx5e_rq_replace_xdp_prog(&c->rq, prog);
-   if (test_bit(MLX5E_CHANNEL_STATE_XSK, c->state))
+   if (test_bit(MLX5E_CHANNEL_STATE_XSK, c->state)) {
+   bpf_prog_inc(prog);
mlx5e_rq_replace_xdp_prog(&c->xskrq, prog);
+   }
}
 
 unlock:
-- 
2.30.1





[PATCH 5.10 108/221] igc: Fix igc_ptp_rx_pktstamp()

2021-03-29 Thread Greg Kroah-Hartman
From: Andre Guedes 

[ Upstream commit fc9e5020971d57d7d0b3fef9e2ab2108fcb5588b ]

The comment describing the timestamps layout in the packet buffer is
wrong and the code is actually retrieving the timestamp in Timer 1
reference instead of Timer 0. This hasn't been a big issue so far
because hardware is configured to report both timestamps using Timer 0
(see IGC_SRRCTL register configuration in igc_ptp_enable_rx_timestamp()
helper). This patch fixes the comment and the code so we retrieve the
timestamp in Timer 0 reference as expected.

This patch also takes the opportunity to get rid of the hw.mac.type check
since it is not required.

Fixes: 81b055205e8ba ("igc: Add support for RX timestamping")
Signed-off-by: Andre Guedes 
Signed-off-by: Vedang Patel 
Signed-off-by: Jithu Joseph 
Reviewed-by: Maciej Fijalkowski 
Tested-by: Dvora Fuxbrumer 
Signed-off-by: Tony Nguyen 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/intel/igc/igc.h |  2 +-
 drivers/net/ethernet/intel/igc/igc_ptp.c | 72 +---
 2 files changed, 41 insertions(+), 33 deletions(-)

diff --git a/drivers/net/ethernet/intel/igc/igc.h 
b/drivers/net/ethernet/intel/igc/igc.h
index 35baae900c1f..6dca67d9c25d 100644
--- a/drivers/net/ethernet/intel/igc/igc.h
+++ b/drivers/net/ethernet/intel/igc/igc.h
@@ -545,7 +545,7 @@ void igc_ptp_init(struct igc_adapter *adapter);
 void igc_ptp_reset(struct igc_adapter *adapter);
 void igc_ptp_suspend(struct igc_adapter *adapter);
 void igc_ptp_stop(struct igc_adapter *adapter);
-void igc_ptp_rx_pktstamp(struct igc_q_vector *q_vector, void *va,
+void igc_ptp_rx_pktstamp(struct igc_q_vector *q_vector, __le32 *va,
 struct sk_buff *skb);
 int igc_ptp_set_ts_config(struct net_device *netdev, struct ifreq *ifr);
 int igc_ptp_get_ts_config(struct net_device *netdev, struct ifreq *ifr);
diff --git a/drivers/net/ethernet/intel/igc/igc_ptp.c 
b/drivers/net/ethernet/intel/igc/igc_ptp.c
index ac0b9c85da7c..545f4d0e67cf 100644
--- a/drivers/net/ethernet/intel/igc/igc_ptp.c
+++ b/drivers/net/ethernet/intel/igc/igc_ptp.c
@@ -152,46 +152,54 @@ static void igc_ptp_systim_to_hwtstamp(struct igc_adapter 
*adapter,
 }
 
 /**
- * igc_ptp_rx_pktstamp - retrieve Rx per packet timestamp
+ * igc_ptp_rx_pktstamp - Retrieve timestamp from Rx packet buffer
  * @q_vector: Pointer to interrupt specific structure
  * @va: Pointer to address containing Rx buffer
  * @skb: Buffer containing timestamp and packet
  *
- * This function is meant to retrieve the first timestamp from the
- * first buffer of an incoming frame. The value is stored in little
- * endian format starting on byte 0. There's a second timestamp
- * starting on byte 8.
- **/
-void igc_ptp_rx_pktstamp(struct igc_q_vector *q_vector, void *va,
+ * This function retrieves the timestamp saved in the beginning of packet
+ * buffer. While two timestamps are available, one in timer0 reference and the
+ * other in timer1 reference, this function considers only the timestamp in
+ * timer0 reference.
+ */
+void igc_ptp_rx_pktstamp(struct igc_q_vector *q_vector, __le32 *va,
 struct sk_buff *skb)
 {
struct igc_adapter *adapter = q_vector->adapter;
-   __le64 *regval = (__le64 *)va;
-   int adjust = 0;
-
-   /* The timestamp is recorded in little endian format.
-* DWORD: | 0  | 1   | 2  | 3
-* Field: | Timer0 Low | Timer0 High | Timer1 Low | Timer1 High
+   u64 regval;
+   int adjust;
+
+   /* Timestamps are saved in little endian at the beginning of the packet
+* buffer following the layout:
+*
+* DWORD: | 0  | 1  | 2  | 3
  |
+* Field: | Timer1 SYSTIML | Timer1 SYSTIMH | Timer0 SYSTIML | Timer0 
SYSTIMH |
+*
+* SYSTIML holds the nanoseconds part while SYSTIMH holds the seconds
+* part of the timestamp.
 */
-   igc_ptp_systim_to_hwtstamp(adapter, skb_hwtstamps(skb),
-  le64_to_cpu(regval[0]));
-
-   /* adjust timestamp for the RX latency based on link speed */
-   if (adapter->hw.mac.type == igc_i225) {
-   switch (adapter->link_speed) {
-   case SPEED_10:
-   adjust = IGC_I225_RX_LATENCY_10;
-   break;
-   case SPEED_100:
-   adjust = IGC_I225_RX_LATENCY_100;
-   break;
-   case SPEED_1000:
-   adjust = IGC_I225_RX_LATENCY_1000;
-   break;
-   case SPEED_2500:
-   adjust = IGC_I225_RX_LATENCY_2500;
-   break;
-   }
+   regval = le32_to_cpu(va[2]);
+   regval |= (u64)le32_to_cpu(va[3]) << 32;
+   igc_ptp_systim_to_hwtstamp(adapter, skb_hwtstamps(skb), regval);
+
+   /* Adjust timestamp for the RX latency based on link speed */
+   switch (adapte

[PATCH 5.10 066/221] platform/x86: intel-vbtn: Stop reporting SW_DOCK events

2021-03-29 Thread Greg Kroah-Hartman
From: Hans de Goede 

commit 538d2dd0b9920334e6596977a664e9e7bac73703 upstream.

Stop reporting SW_DOCK events because this breaks suspend-on-lid-close.

SW_DOCK should only be reported for docking stations, but all the DSDTs in
my DSDT collection which use the intel-vbtn code, always seem to use this
for 2-in-1s / convertibles and set SW_DOCK=1 when in laptop-mode (in tandem
with setting SW_TABLET_MODE=0).

This causes userspace to think the laptop is docked to a port-replicator
and to disable suspend-on-lid-close, which is undesirable.

Map the dock events to KEY_IGNORE to avoid this broken SW_DOCK reporting.

Note this may theoretically cause us to stop reporting SW_DOCK on some
device where the 0xCA and 0xCB intel-vbtn events are actually used for
reporting docking to a classic docking-station / port-replicator but
I'm not aware of any such devices.

Also the most important thing is that we only report SW_DOCK when it
reliably reports being docked to a classic docking-station without any
false positives, which clearly is not the case here. If there is a
chance of reporting false positives then it is better to not report
SW_DOCK at all.

Cc: sta...@vger.kernel.org
Signed-off-by: Hans de Goede 
Link: https://lore.kernel.org/r/20210321163513.72328-1-hdego...@redhat.com
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/platform/x86/intel-vbtn.c |   12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

--- a/drivers/platform/x86/intel-vbtn.c
+++ b/drivers/platform/x86/intel-vbtn.c
@@ -47,8 +47,16 @@ static const struct key_entry intel_vbtn
 };
 
 static const struct key_entry intel_vbtn_switchmap[] = {
-   { KE_SW, 0xCA, { .sw = { SW_DOCK, 1 } } },  /* Docked */
-   { KE_SW, 0xCB, { .sw = { SW_DOCK, 0 } } },  /* Undocked */
+   /*
+* SW_DOCK should only be reported for docking stations, but DSDTs 
using the
+* intel-vbtn code, always seem to use this for 2-in-1s / convertibles 
and set
+* SW_DOCK=1 when in laptop-mode (in tandem with setting 
SW_TABLET_MODE=0).
+* This causes userspace to think the laptop is docked to a 
port-replicator
+* and to disable suspend-on-lid-close, which is undesirable.
+* Map the dock events to KEY_IGNORE to avoid this broken SW_DOCK 
reporting.
+*/
+   { KE_IGNORE, 0xCA, { .sw = { SW_DOCK, 1 } } },  /* Docked */
+   { KE_IGNORE, 0xCB, { .sw = { SW_DOCK, 0 } } },  /* Undocked */
{ KE_SW, 0xCC, { .sw = { SW_TABLET_MODE, 1 } } },   /* Tablet */
{ KE_SW, 0xCD, { .sw = { SW_TABLET_MODE, 0 } } },   /* Laptop */
 };




[PATCH 5.10 099/221] net/mlx5e: Dont match on Geneve options in case option masks are all zero

2021-03-29 Thread Greg Kroah-Hartman
From: Maor Dickman 

[ Upstream commit 385d40b042e60aa0b677d7b400a0fefb44bcbaf4 ]

The cited change added offload support for Geneve options without verifying
the validity of the options masks, this caused offload of rules with match
on Geneve options with class,type and data masks which are zero to fail.

Fix by ignoring the match on Geneve options in case option masks are
all zero.

Fixes: 9272e3df3023 ("net/mlx5e: Geneve, Add support for encap/decap flows 
offload")
Signed-off-by: Maor Dickman 
Reviewed-by: Roi Dayan 
Reviewed-by: Oz Shlomo 
Reviewed-by: Yevgeny Kliteynik 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c
index e472ed0eacfb..7ed3f9f79f11 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c
@@ -227,6 +227,10 @@ static int mlx5e_tc_tun_parse_geneve_options(struct 
mlx5e_priv *priv,
option_key = (struct geneve_opt *)&enc_opts.key->data[0];
option_mask = (struct geneve_opt *)&enc_opts.mask->data[0];
 
+   if (option_mask->opt_class == 0 && option_mask->type == 0 &&
+   !memchr_inv(option_mask->opt_data, 0, option_mask->length * 4))
+   return 0;
+
if (option_key->length > max_tlv_option_data_len) {
NL_SET_ERR_MSG_MOD(extack,
   "Matching on GENEVE options: unsupported 
option len");
-- 
2.30.1





[PATCH 5.10 105/221] igc: reinit_locked() should be called with rtnl_lock

2021-03-29 Thread Greg Kroah-Hartman
From: Sasha Neftin 

[ Upstream commit 6da262378c99b17b1a1ac2e42aa65acc1bd471c7 ]

This commit applies to the igc_reset_task the same changes that
were applied to the igb driver in commit 024a8168b749 ("igb:
reinit_locked() should be called with rtnl_lock")
and fix possible race in reset subtask.

Fixes: 0507ef8a0372 ("igc: Add transmit and receive fastpath and interrupt 
handlers")
Suggested-by: Jakub Kicinski 
Signed-off-by: Sasha Neftin 
Tested-by: Dvora Fuxbrumer 
Signed-off-by: Tony Nguyen 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/intel/igc/igc_main.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/intel/igc/igc_main.c 
b/drivers/net/ethernet/intel/igc/igc_main.c
index b673ac1199bb..7b822cdcc6c5 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -3846,10 +3846,19 @@ static void igc_reset_task(struct work_struct *work)
 
adapter = container_of(work, struct igc_adapter, reset_task);
 
+   rtnl_lock();
+   /* If we're already down or resetting, just bail */
+   if (test_bit(__IGC_DOWN, &adapter->state) ||
+   test_bit(__IGC_RESETTING, &adapter->state)) {
+   rtnl_unlock();
+   return;
+   }
+
igc_rings_dump(adapter);
igc_regs_dump(adapter);
netdev_err(adapter->netdev, "Reset adapter\n");
igc_reinit_locked(adapter);
+   rtnl_unlock();
 }
 
 /**
-- 
2.30.1





[PATCH 5.10 139/221] ftrace: Fix modify_ftrace_direct.

2021-03-29 Thread Greg Kroah-Hartman
From: Alexei Starovoitov 

[ Upstream commit 8a141dd7f7060d1e64c14a5257e0babae20ac99b ]

The following sequence of commands:
  register_ftrace_direct(ip, addr1);
  modify_ftrace_direct(ip, addr1, addr2);
  unregister_ftrace_direct(ip, addr2);
will cause the kernel to warn:
[   30.179191] WARNING: CPU: 2 PID: 1961 at kernel/trace/ftrace.c:5223 
unregister_ftrace_direct+0x130/0x150
[   30.180556] CPU: 2 PID: 1961 Comm: test_progsW  O  
5.12.0-rc2-00378-g86bc10a0a711-dirty #3246
[   30.182453] RIP: 0010:unregister_ftrace_direct+0x130/0x150

When modify_ftrace_direct() changes the addr from old to new it should update
the addr stored in ftrace_direct_funcs. Otherwise the final
unregister_ftrace_direct() won't find the address and will cause the splat.

Fixes: 0567d6809182 ("ftrace: Add modify_ftrace_direct()")
Signed-off-by: Alexei Starovoitov 
Signed-off-by: Daniel Borkmann 
Reviewed-by: Steven Rostedt (VMware) 
Link: 
https://lore.kernel.org/bpf/20210316195815.34714-1-alexei.starovoi...@gmail.com
Signed-off-by: Sasha Levin 
---
 kernel/trace/ftrace.c | 43 ++-
 1 file changed, 38 insertions(+), 5 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 9c1bba8cc51b..82041bbf8fc2 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -5045,6 +5045,20 @@ struct ftrace_direct_func 
*ftrace_find_direct_func(unsigned long addr)
return NULL;
 }
 
+static struct ftrace_direct_func *ftrace_alloc_direct_func(unsigned long addr)
+{
+   struct ftrace_direct_func *direct;
+
+   direct = kmalloc(sizeof(*direct), GFP_KERNEL);
+   if (!direct)
+   return NULL;
+   direct->addr = addr;
+   direct->count = 0;
+   list_add_rcu(&direct->next, &ftrace_direct_funcs);
+   ftrace_direct_func_count++;
+   return direct;
+}
+
 /**
  * register_ftrace_direct - Call a custom trampoline directly
  * @ip: The address of the nop at the beginning of a function
@@ -5120,15 +5134,11 @@ int register_ftrace_direct(unsigned long ip, unsigned 
long addr)
 
direct = ftrace_find_direct_func(addr);
if (!direct) {
-   direct = kmalloc(sizeof(*direct), GFP_KERNEL);
+   direct = ftrace_alloc_direct_func(addr);
if (!direct) {
kfree(entry);
goto out_unlock;
}
-   direct->addr = addr;
-   direct->count = 0;
-   list_add_rcu(&direct->next, &ftrace_direct_funcs);
-   ftrace_direct_func_count++;
}
 
entry->ip = ip;
@@ -5329,6 +5339,7 @@ int __weak ftrace_modify_direct_caller(struct 
ftrace_func_entry *entry,
 int modify_ftrace_direct(unsigned long ip,
 unsigned long old_addr, unsigned long new_addr)
 {
+   struct ftrace_direct_func *direct, *new_direct = NULL;
struct ftrace_func_entry *entry;
struct dyn_ftrace *rec;
int ret = -ENODEV;
@@ -5344,6 +5355,20 @@ int modify_ftrace_direct(unsigned long ip,
if (entry->direct != old_addr)
goto out_unlock;
 
+   direct = ftrace_find_direct_func(old_addr);
+   if (WARN_ON(!direct))
+   goto out_unlock;
+   if (direct->count > 1) {
+   ret = -ENOMEM;
+   new_direct = ftrace_alloc_direct_func(new_addr);
+   if (!new_direct)
+   goto out_unlock;
+   direct->count--;
+   new_direct->count++;
+   } else {
+   direct->addr = new_addr;
+   }
+
/*
 * If there's no other ftrace callback on the rec->ip location,
 * then it can be changed directly by the architecture.
@@ -5357,6 +5382,14 @@ int modify_ftrace_direct(unsigned long ip,
ret = 0;
}
 
+   if (unlikely(ret && new_direct)) {
+   direct->count++;
+   list_del_rcu(&new_direct->next);
+   synchronize_rcu_tasks();
+   kfree(new_direct);
+   ftrace_direct_func_count--;
+   }
+
  out_unlock:
mutex_unlock(&ftrace_lock);
mutex_unlock(&direct_mutex);
-- 
2.30.1





[PATCH 5.10 148/221] ARM: dts: imx6ull: fix ubi filesystem mount failed

2021-03-29 Thread Greg Kroah-Hartman
From: dillon min 

[ Upstream commit e4817a1b6b77db538bc0141c3b138f2df803ce87 ]

For NAND Ecc layout, there is a dependency from old kernel's nand driver
setting and current. if old kernel use 4 bit ecc , we should use 4 bit
in new kernel either. else will run into following error at filesystem
mounting.

So, enable fsl,use-minimum-ecc from device tree, to fix this mismatch

[9.449265] ubi0: scanning is finished
[9.463968] ubi0 warning: ubi_io_read: error -74 (ECC error) while reading
22528 bytes from PEB 513:4096, read only 22528 bytes, retry
[9.486940] ubi0 warning: ubi_io_read: error -74 (ECC error) while reading
22528 bytes from PEB 513:4096, read only 22528 bytes, retry
[9.509906] ubi0 warning: ubi_io_read: error -74 (ECC error) while reading
22528 bytes from PEB 513:4096, read only 22528 bytes, retry
[9.532845] ubi0 error: ubi_io_read: error -74 (ECC error) while reading
22528 bytes from PEB 513:4096, read 22528 bytes

Fixes: f9ecf10cb88c ("ARM: dts: imx6ull: add MYiR MYS-6ULX SBC")
Signed-off-by: dillon min 
Reviewed-by: Fabio Estevam 
Signed-off-by: Shawn Guo 
Signed-off-by: Sasha Levin 
---
 arch/arm/boot/dts/imx6ull-myir-mys-6ulx-eval.dts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/imx6ull-myir-mys-6ulx-eval.dts 
b/arch/arm/boot/dts/imx6ull-myir-mys-6ulx-eval.dts
index ecbb2cc5b9ab..79cc45728cd2 100644
--- a/arch/arm/boot/dts/imx6ull-myir-mys-6ulx-eval.dts
+++ b/arch/arm/boot/dts/imx6ull-myir-mys-6ulx-eval.dts
@@ -14,5 +14,6 @@
 };
 
 &gpmi {
+   fsl,use-minimum-ecc;
status = "okay";
 };
-- 
2.30.1





[PATCH 5.10 150/221] octeontx2-af: Formatting debugfs entry rsrc_alloc.

2021-03-29 Thread Greg Kroah-Hartman
From: Rakesh Babu 

[ Upstream commit f7884097141b615b6ce89c16f456a53902b4eec3 ]

With the existing rsrc_alloc's format, there is misalignment for the
pcifunc entries whose VF's index is a double digit. This patch fixes
this.

pcifunc NPA NIX0NIX1SSO GROUP   SSOWS
TIM CPT0CPT1REE0REE1
PF0:VF0 8   5
PF0:VF1 9   3
PF0:VF1018  10
PF0:VF1119  8
PF0:VF1220  11
PF0:VF1321  9
PF0:VF1422  12
PF0:VF1523  10
PF1 0   0

Fixes: 23205e6d06d4 ("octeontx2-af: Dump current resource provisioning status")
Signed-off-by: Rakesh Babu 
Signed-off-by: Hariprasad Kelam 
Signed-off-by: Sunil Kovvuri Goutham 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 .../marvell/octeontx2/af/rvu_debugfs.c| 46 ---
 1 file changed, 29 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
index 809f50ab0432..c018121d4cc5 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
@@ -144,12 +144,14 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file 
*filp,
  char __user *buffer,
  size_t count, loff_t *ppos)
 {
-   int index, off = 0, flag = 0, go_back = 0, off_prev;
+   int index, off = 0, flag = 0, go_back = 0, len = 0;
struct rvu *rvu = filp->private_data;
int lf, pf, vf, pcifunc;
struct rvu_block block;
int bytes_not_copied;
+   int lf_str_size = 12;
int buf_size = 2048;
+   char *lfs;
char *buf;
 
/* don't allow partial reads */
@@ -159,12 +161,18 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file 
*filp,
buf = kzalloc(buf_size, GFP_KERNEL);
if (!buf)
return -ENOSPC;
-   off +=  scnprintf(&buf[off], buf_size - 1 - off, "\npcifunc\t\t");
+
+   lfs = kzalloc(lf_str_size, GFP_KERNEL);
+   if (!lfs)
+   return -ENOMEM;
+   off +=  scnprintf(&buf[off], buf_size - 1 - off, "%-*s", lf_str_size,
+ "pcifunc");
for (index = 0; index < BLK_COUNT; index++)
-   if (strlen(rvu->hw->block[index].name))
-   off +=  scnprintf(&buf[off], buf_size - 1 - off,
- "%*s\t", (index - 1) * 2,
- rvu->hw->block[index].name);
+   if (strlen(rvu->hw->block[index].name)) {
+   off += scnprintf(&buf[off], buf_size - 1 - off,
+"%-*s", lf_str_size,
+rvu->hw->block[index].name);
+   }
off += scnprintf(&buf[off], buf_size - 1 - off, "\n");
for (pf = 0; pf < rvu->hw->total_pfs; pf++) {
for (vf = 0; vf <= rvu->hw->total_vfs; vf++) {
@@ -173,14 +181,15 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file 
*filp,
continue;
 
if (vf) {
+   sprintf(lfs, "PF%d:VF%d", pf, vf - 1);
go_back = scnprintf(&buf[off],
buf_size - 1 - off,
-   "PF%d:VF%d\t\t", pf,
-   vf - 1);
+   "%-*s", lf_str_size, lfs);
} else {
+   sprintf(lfs, "PF%d", pf);
go_back = scnprintf(&buf[off],
buf_size - 1 - off,
-   "PF%d\t\t", pf);
+   "%-*s", lf_str_size, lfs);
}
 
off += go_back;
@@ -188,20 +197,22 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file 
*filp,
block = rvu->hw->block[index];
if (!strlen(block.name))
continue;
-   off_prev = off;
+   len = 0;
+   lfs[len] = '\0';
for (lf = 0; lf < block.lf.max; lf++) {
if (block.fn_map[lf] != pcifunc)
continue;
flag = 1;
-   off += scnprintf(&buf[off], buf_size - 1
-  

[PATCH 5.10 152/221] octeontx2-af: Remove TOS field from MKEX TX

2021-03-29 Thread Greg Kroah-Hartman
From: Subbaraya Sundeep 

[ Upstream commit ce86c2a531e2f2995ee55ea527c1f39ba1d95f73 ]

The MKEX profile describes what packet fields need to be extracted from
the input packet and how to place those packet fields in the output key
for MCAM matching.  The MKEX profile can be in a way where higher layer
packet fields can overwrite lower layer packet fields in output MCAM
Key.
Hence MKEX profile is always ensured that there are no overlaps between
any of the layers. But the commit 42006910b5ea
("octeontx2-af: cleanup KPU config data") introduced TX TOS field which
overlaps with DMAC in MCAM key.
This led to AF driver returning error when TX rule is installed with
DMAC as match criteria since DMAC gets overwritten and cannot be
supported. This patch fixes the issue by removing TOS field from MKEX TX
profile.

Fixes: 42006910b5ea ("octeontx2-af: cleanup KPU config data")
Signed-off-by: Subbaraya Sundeep 
Signed-off-by: Hariprasad Kelam 
Signed-off-by: Sunil Kovvuri Goutham 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h 
b/drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h
index 077efc5007dd..0e4af93be0fb 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h
@@ -13499,8 +13499,6 @@ static const struct npc_mcam_kex npc_mkex_default = {
[NPC_LT_LC_IP] = {
/* SIP+DIP: 8 bytes, KW2[63:0] */
KEX_LD_CFG(0x07, 0xc, 0x1, 0x0, 0x10),
-   /* TOS: 1 byte, KW1[63:56] */
-   KEX_LD_CFG(0x0, 0x1, 0x1, 0x0, 0xf),
},
/* Layer C: IPv6 */
[NPC_LT_LC_IP6] = {
-- 
2.30.1





[PATCH 5.10 153/221] octeontx2-af: Fix irq free in rvu teardown

2021-03-29 Thread Greg Kroah-Hartman
From: Geetha sowjanya 

[ Upstream commit ae2619dd4fccdad9876aa5f900bd85484179c50f ]

Current devlink code try to free already freed irqs as the
irq_allocate flag is not cleared after free leading to kernel
crash while removing rvu driver. The patch fixes the irq free
sequence and clears the irq_allocate flag on free.

Fixes: 7304ac4567bc ("octeontx2-af: Add mailbox IRQ and msg handlers")
Signed-off-by: Geetha sowjanya 
Signed-off-by: Hariprasad Kelam 
Signed-off-by: Sunil Kovvuri Goutham 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
index e1f918960730..644d28b0692b 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
@@ -2151,8 +2151,10 @@ static void rvu_unregister_interrupts(struct rvu *rvu)
INTR_MASK(rvu->hw->total_pfs) & ~1ULL);
 
for (irq = 0; irq < rvu->num_vec; irq++) {
-   if (rvu->irq_allocated[irq])
+   if (rvu->irq_allocated[irq]) {
free_irq(pci_irq_vector(rvu->pdev, irq), rvu);
+   rvu->irq_allocated[irq] = false;
+   }
}
 
pci_free_irq_vectors(rvu->pdev);
-- 
2.30.1





[PATCH 5.10 151/221] octeontx2-af: Modify default KEX profile to extract TX packet fields

2021-03-29 Thread Greg Kroah-Hartman
From: Stanislaw Kardach 

[ Upstream commit f1517f6f1d6fd97a18836b0fb6921f2cb105eeb4 ]

The current default Key Extraction(KEX) profile can only use RX
packet fields while generating the MCAM search key. The profile
can't be used for matching TX packet fields. This patch modifies
the default KEX profile to add support for extracting TX packet
fields into MCAM search key. Enabled Tx KPU packet parsing by
configuring TX PKIND in tx_parse_cfg.

Modified the KEX profile to extract 2 bytes of VLAN TCI from an
offset of 2 bytes from LB_PTR. The LB_PTR points to the byte offset
where the VLAN header starts. The NPC KPU parser profile has been
modified to point LB_PTR to the starting byte offset of VLAN header
which points to the tpid field.

Signed-off-by: Stanislaw Kardach 
Signed-off-by: Sunil Goutham 
Signed-off-by: Naveen Mamindlapalli 
Signed-off-by: Jakub Kicinski 
Signed-off-by: Sasha Levin 
---
 .../net/ethernet/marvell/octeontx2/af/npc.h   | 31 ++
 .../marvell/octeontx2/af/npc_profile.h| 99 ---
 .../ethernet/marvell/octeontx2/af/rvu_nix.c   |  4 +
 3 files changed, 120 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/npc.h 
b/drivers/net/ethernet/marvell/octeontx2/af/npc.h
index 91a9d00e4fb5..407b9477da24 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/npc.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/npc.h
@@ -140,6 +140,15 @@ enum npc_kpu_lh_ltype {
NPC_LT_LH_CUSTOM1 = 0xF,
 };
 
+/* NPC port kind defines how the incoming or outgoing packets
+ * are processed. NPC accepts packets from up to 64 pkinds.
+ * Software assigns pkind for each incoming port such as CGX
+ * Ethernet interfaces, LBK interfaces, etc.
+ */
+enum npc_pkind_type {
+   NPC_TX_DEF_PKIND = 63ULL,   /* NIX-TX PKIND */
+};
+
 struct npc_kpu_profile_cam {
u8 state;
u8 state_mask;
@@ -300,6 +309,28 @@ struct nix_rx_action {
 /* NPC_AF_INTFX_KEX_CFG field masks */
 #define NPC_PARSE_NIBBLE   GENMASK_ULL(30, 0)
 
+/* NPC_PARSE_KEX_S nibble definitions for each field */
+#define NPC_PARSE_NIBBLE_CHAN  GENMASK_ULL(2, 0)
+#define NPC_PARSE_NIBBLE_ERRLEVBIT_ULL(3)
+#define NPC_PARSE_NIBBLE_ERRCODE   GENMASK_ULL(5, 4)
+#define NPC_PARSE_NIBBLE_L2L3_BCASTBIT_ULL(6)
+#define NPC_PARSE_NIBBLE_LA_FLAGS  GENMASK_ULL(8, 7)
+#define NPC_PARSE_NIBBLE_LA_LTYPE  BIT_ULL(9)
+#define NPC_PARSE_NIBBLE_LB_FLAGS  GENMASK_ULL(11, 10)
+#define NPC_PARSE_NIBBLE_LB_LTYPE  BIT_ULL(12)
+#define NPC_PARSE_NIBBLE_LC_FLAGS  GENMASK_ULL(14, 13)
+#define NPC_PARSE_NIBBLE_LC_LTYPE  BIT_ULL(15)
+#define NPC_PARSE_NIBBLE_LD_FLAGS  GENMASK_ULL(17, 16)
+#define NPC_PARSE_NIBBLE_LD_LTYPE  BIT_ULL(18)
+#define NPC_PARSE_NIBBLE_LE_FLAGS  GENMASK_ULL(20, 19)
+#define NPC_PARSE_NIBBLE_LE_LTYPE  BIT_ULL(21)
+#define NPC_PARSE_NIBBLE_LF_FLAGS  GENMASK_ULL(23, 22)
+#define NPC_PARSE_NIBBLE_LF_LTYPE  BIT_ULL(24)
+#define NPC_PARSE_NIBBLE_LG_FLAGS  GENMASK_ULL(26, 25)
+#define NPC_PARSE_NIBBLE_LG_LTYPE  BIT_ULL(27)
+#define NPC_PARSE_NIBBLE_LH_FLAGS  GENMASK_ULL(29, 28)
+#define NPC_PARSE_NIBBLE_LH_LTYPE  BIT_ULL(30)
+
 /* NIX Receive Vtag Action Structure */
 #define VTAG0_VALID_BITBIT_ULL(15)
 #define VTAG0_TYPE_MASKGENMASK_ULL(14, 12)
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h 
b/drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h
index 77bb4ed32600..077efc5007dd 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h
@@ -148,6 +148,20 @@
(((bytesm1) << 16) | ((hdr_ofs) << 8) | ((ena) << 7) | \
 ((flags_ena) << 6) | ((key_ofs) & 0x3F))
 
+/* Rx parse key extract nibble enable */
+#define NPC_PARSE_NIBBLE_INTF_RX   (NPC_PARSE_NIBBLE_CHAN | \
+NPC_PARSE_NIBBLE_LA_LTYPE | \
+NPC_PARSE_NIBBLE_LB_LTYPE | \
+NPC_PARSE_NIBBLE_LC_LTYPE | \
+NPC_PARSE_NIBBLE_LD_LTYPE | \
+NPC_PARSE_NIBBLE_LE_LTYPE)
+/* Tx parse key extract nibble enable */
+#define NPC_PARSE_NIBBLE_INTF_TX   (NPC_PARSE_NIBBLE_LA_LTYPE | \
+NPC_PARSE_NIBBLE_LB_LTYPE | \
+NPC_PARSE_NIBBLE_LC_LTYPE | \
+NPC_PARSE_NIBBLE_LD_LTYPE | \
+NPC_PARSE_NIBBLE_LE_LTYPE)
+
 enum npc_kpu_parser_state {
NPC_S_NA = 0,
NPC_S_KPU1_ETHER,
@@ -13385,9 +13399,10 @@ static const struct npc_mcam_kex npc_mkex_default = {
.name = "default",
.kpu_version = NPC_KPU_PROFILE_VER,
.keyx_cfg = {
-   /* nibble: LA..LE (ltype only) + Channel */
-  

[PATCH 5.10 155/221] octeontx2-af: fix infinite loop in unmapping NPC counter

2021-03-29 Thread Greg Kroah-Hartman
From: Hariprasad Kelam 

[ Upstream commit 64451b98306bf1334a62bcd020ec92bdb4cb68db ]

unmapping npc counter works in a way by traversing all mcam
entries to find which mcam rule is associated with counter.
But loop cursor variable 'entry' is not incremented before
checking next mcam entry which resulting in infinite loop.

This in turn hogs the kworker thread forever and no other
mbox message is processed by AF driver after that.
Fix this by updating entry value before checking next
mcam entry.

Fixes: a958dd59f9ce ("octeontx2-af: Map or unmap NPC MCAM entry and counter")
Signed-off-by: Hariprasad Kelam 
Signed-off-by: Sunil Kovvuri Goutham 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
index 511b01dd03ed..169ae491f978 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
@@ -2035,10 +2035,10 @@ int rvu_mbox_handler_npc_mcam_free_counter(struct rvu 
*rvu,
index = find_next_bit(mcam->bmap, mcam->bmap_entries, entry);
if (index >= mcam->bmap_entries)
break;
+   entry = index + 1;
if (mcam->entry2cntr_map[index] != req->cntr)
continue;
 
-   entry = index + 1;
npc_unmap_mcam_entry_and_cntr(rvu, mcam, blkaddr,
  index, req->cntr);
}
-- 
2.30.1





[PATCH 5.10 149/221] ipv6: weaken the v4mapped source check

2021-03-29 Thread Greg Kroah-Hartman
From: Jakub Kicinski 

[ Upstream commit dcc32f4f183ab8479041b23a1525d48233df1d43 ]

This reverts commit 6af1799aaf3f1bc8defedddfa00df3192445bbf3.

Commit 6af1799aaf3f ("ipv6: drop incoming packets having a v4mapped
source address") introduced an input check against v4mapped addresses.
Use of such addresses on the wire is indeed questionable and not
allowed on public Internet. As the commit pointed out

  https://tools.ietf.org/html/draft-itojun-v6ops-v4mapped-harmful-02

lists potential issues.

Unfortunately there are applications which use v4mapped addresses,
and breaking them is a clear regression. For example v4mapped
addresses (or any semi-valid addresses, really) may be used
for uni-direction event streams or packet export.

Since the issue which sparked the addition of the check was with
TCP and request_socks in particular push the check down to TCPv6
and DCCP. This restores the ability to receive UDPv6 packets with
v4mapped address as the source.

Keep using the IPSTATS_MIB_INHDRERRORS statistic to minimize the
user-visible changes.

Fixes: 6af1799aaf3f ("ipv6: drop incoming packets having a v4mapped source 
address")
Reported-by: Sunyi Shao 
Signed-off-by: Jakub Kicinski 
Acked-by: Mat Martineau 
Reviewed-by: Eric Dumazet 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 net/dccp/ipv6.c  |  5 +
 net/ipv6/ip6_input.c | 10 --
 net/ipv6/tcp_ipv6.c  |  5 +
 net/mptcp/subflow.c  |  5 +
 4 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 78ee1b5acf1f..49f4034bf126 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -319,6 +319,11 @@ static int dccp_v6_conn_request(struct sock *sk, struct 
sk_buff *skb)
if (!ipv6_unicast_destination(skb))
return 0;   /* discard, don't send a reset here */
 
+   if (ipv6_addr_v4mapped(&ipv6_hdr(skb)->saddr)) {
+   __IP6_INC_STATS(sock_net(sk), NULL, IPSTATS_MIB_INHDRERRORS);
+   return 0;
+   }
+
if (dccp_bad_service_code(sk, service)) {
dcb->dccpd_reset_code = DCCP_RESET_CODE_BAD_SERVICE_CODE;
goto drop;
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index e96304d8a4a7..06d60662717d 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -245,16 +245,6 @@ static struct sk_buff *ip6_rcv_core(struct sk_buff *skb, 
struct net_device *dev,
if (ipv6_addr_is_multicast(&hdr->saddr))
goto err;
 
-   /* While RFC4291 is not explicit about v4mapped addresses
-* in IPv6 headers, it seems clear linux dual-stack
-* model can not deal properly with these.
-* Security models could be fooled by :::127.0.0.1 for example.
-*
-* https://tools.ietf.org/html/draft-itojun-v6ops-v4mapped-harmful-02
-*/
-   if (ipv6_addr_v4mapped(&hdr->saddr))
-   goto err;
-
skb->transport_header = skb->network_header + sizeof(*hdr);
IP6CB(skb)->nhoff = offsetof(struct ipv6hdr, nexthdr);
 
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 991dc36f95ff..3f9bb6dd1f98 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1170,6 +1170,11 @@ static int tcp_v6_conn_request(struct sock *sk, struct 
sk_buff *skb)
if (!ipv6_unicast_destination(skb))
goto drop;
 
+   if (ipv6_addr_v4mapped(&ipv6_hdr(skb)->saddr)) {
+   __IP6_INC_STATS(sock_net(sk), NULL, IPSTATS_MIB_INHDRERRORS);
+   return 0;
+   }
+
return tcp_conn_request(&tcp6_request_sock_ops,
&tcp_request_sock_ipv6_ops, sk, skb);
 
diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index 16adba172fb9..6317b9bc8681 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -398,6 +398,11 @@ static int subflow_v6_conn_request(struct sock *sk, struct 
sk_buff *skb)
if (!ipv6_unicast_destination(skb))
goto drop;
 
+   if (ipv6_addr_v4mapped(&ipv6_hdr(skb)->saddr)) {
+   __IP6_INC_STATS(sock_net(sk), NULL, IPSTATS_MIB_INHDRERRORS);
+   return 0;
+   }
+
return tcp_conn_request(&mptcp_subflow_request_sock_ops,
&subflow_request_sock_ipv6_ops, sk, skb);
 
-- 
2.30.1





[PATCH 5.10 157/221] net: cdc-phonet: fix data-interface release on probe failure

2021-03-29 Thread Greg Kroah-Hartman
From: Johan Hovold 

[ Upstream commit c79a707072fe3fea0e3c92edee6ca85c1e53c29f ]

Set the disconnected flag before releasing the data interface in case
netdev registration fails to avoid having the disconnect callback try to
deregister the never registered netdev (and trigger a WARN_ON()).

Fixes: 87cf65601e17 ("USB host CDC Phonet network interface driver")
Signed-off-by: Johan Hovold 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/usb/cdc-phonet.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/usb/cdc-phonet.c b/drivers/net/usb/cdc-phonet.c
index dba847f28096..2520421946a6 100644
--- a/drivers/net/usb/cdc-phonet.c
+++ b/drivers/net/usb/cdc-phonet.c
@@ -387,6 +387,8 @@ static int usbpn_probe(struct usb_interface *intf, const 
struct usb_device_id *i
 
err = register_netdev(dev);
if (err) {
+   /* Set disconnected flag so that disconnect() returns early. */
+   pnd->disconnected = 1;
usb_driver_release_interface(&usbpn_driver, data_intf);
goto out;
}
-- 
2.30.1





[PATCH 5.10 156/221] net: check all name nodes in __dev_alloc_name

2021-03-29 Thread Greg Kroah-Hartman
From: Jiri Bohac 

[ Upstream commit 6c015a2256801597fadcbc11d287774c9c512fa5 ]

__dev_alloc_name(), when supplied with a name containing '%d',
will search for the first available device number to generate a
unique device name.

Since commit ff92741270bf8b6e78aa885f166b68c7a67ab13a ("net:
introduce name_node struct to be used in hashlist") network
devices may have alternate names.  __dev_alloc_name() does take
these alternate names into account, possibly generating a name
that is already taken and failing with -ENFILE as a result.

This demonstrates the bug:

# rmmod dummy 2>/dev/null
# ip link property add dev lo altname dummy0
# modprobe dummy numdummies=1
modprobe: ERROR: could not insert 'dummy': Too many open files in system

Instead of creating a device named dummy1, modprobe fails.

Fix this by checking all the names in the d->name_node list, not just d->name.

Signed-off-by: Jiri Bohac 
Fixes: ff92741270bf ("net: introduce name_node struct to be used in hashlist")
Reviewed-by: Jiri Pirko 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 net/core/dev.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/net/core/dev.c b/net/core/dev.c
index 75ca6c6d01d6..dbc286fd2047 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1195,6 +1195,18 @@ static int __dev_alloc_name(struct net *net, const char 
*name, char *buf)
return -ENOMEM;
 
for_each_netdev(net, d) {
+   struct netdev_name_node *name_node;
+   list_for_each_entry(name_node, &d->name_node->list, 
list) {
+   if (!sscanf(name_node->name, name, &i))
+   continue;
+   if (i < 0 || i >= max_netdevices)
+   continue;
+
+   /*  avoid cases where sscanf is not exact 
inverse of printf */
+   snprintf(buf, IFNAMSIZ, name, i);
+   if (!strncmp(buf, name_node->name, IFNAMSIZ))
+   set_bit(i, inuse);
+   }
if (!sscanf(d->name, name, &i))
continue;
if (i < 0 || i >= max_netdevices)
-- 
2.30.1





[PATCH 5.10 159/221] r8152: limit the RX buffer size of RTL8153A for USB 2.0

2021-03-29 Thread Greg Kroah-Hartman
From: Hayes Wang 

[ Upstream commit f91a50d8b51b5c8ef1cfb08115a005bba4250507 ]

If the USB host controller is EHCI, the throughput is reduced from
300Mb/s to 60Mb/s, when the rx buffer size is modified from 16K to
32K.

According to the EHCI spec, the maximum size of the qTD is 20K.
Therefore, when the driver uses more than 20K buffer, the latency
time of EHCI would be increased. And, it let the RTL8153A get worse
throughput.

However, the driver uses alloc_pages() for rx buffer, so I limit
the rx buffer to 16K rather than 20K.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=205923
Fixes: ec5791c202ac ("r8152: separate the rx buffer size")
Reported-by: Robert Davies 
Signed-off-by: Hayes Wang 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/usb/r8152.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index d2862071b697..f5010f8ac1ec 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -6519,7 +6519,10 @@ static int rtl_ops_init(struct r8152 *tp)
ops->in_nway= rtl8153_in_nway;
ops->hw_phy_cfg = r8153_hw_phy_cfg;
ops->autosuspend_en = rtl8153_runtime_enable;
-   tp->rx_buf_sz   = 32 * 1024;
+   if (tp->udev->speed < USB_SPEED_SUPER)
+   tp->rx_buf_sz   = 16 * 1024;
+   else
+   tp->rx_buf_sz   = 32 * 1024;
tp->eee_en  = true;
tp->eee_adv = MDIO_EEE_1000T | MDIO_EEE_100TX;
break;
-- 
2.30.1





[PATCH 5.10 154/221] octeontx2-pf: Clear RSS enable flag on interace down

2021-03-29 Thread Greg Kroah-Hartman
From: Geetha sowjanya 

[ Upstream commit f12098ce9b43e1a6fcaa524acbd90f9118a74c0a ]

RSS configuration can not be get/set when interface is in down state
as they required mbox communication. RSS enable flag status
is used for set/get configuration. Current code do not clear the
RSS enable flag on interface down which lead to mbox error while
trying to set/get RSS configuration.

Fixes: 85069e95e531 ("octeontx2-pf: Receive side scaling support")
Signed-off-by: Geetha sowjanya 
Signed-off-by: Hariprasad Kelam 
Signed-off-by: Sunil Kovvuri Goutham 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c 
b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
index 66f1a212f1f4..9fef9be015e5 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
@@ -1616,6 +1616,7 @@ int otx2_stop(struct net_device *netdev)
struct otx2_nic *pf = netdev_priv(netdev);
struct otx2_cq_poll *cq_poll = NULL;
struct otx2_qset *qset = &pf->qset;
+   struct otx2_rss_info *rss;
int qidx, vec, wrk;
 
netif_carrier_off(netdev);
@@ -1628,6 +1629,10 @@ int otx2_stop(struct net_device *netdev)
/* First stop packet Rx/Tx */
otx2_rxtx_enable(pf, false);
 
+   /* Clear RSS enable flag */
+   rss = &pf->hw.rss_info;
+   rss->enable = false;
+
/* Cleanup Queue IRQ */
vec = pci_irq_vector(pf->pdev,
 pf->hw.nix_msixoff + NIX_LF_QINT_VEC_START);
-- 
2.30.1





[PATCH 4.14 37/59] can: peak_usb: add forgotten supported devices

2021-03-29 Thread Greg Kroah-Hartman
From: Stephane Grosjean 

[ Upstream commit 59ec7b89ed3e921cd0625a8c83f31a30d485fdf8 ]

Since the peak_usb driver also supports the CAN-USB interfaces
"PCAN-USB X6" and "PCAN-Chip USB" from PEAK-System GmbH, this patch adds
their names to the list of explicitly supported devices.

Fixes: ea8b65b596d7 ("can: usb: Add support of PCAN-Chip USB stamp module")
Fixes: f00b534ded60 ("can: peak: Add support for PCAN-USB X6 USB interface")
Link: 
https://lore.kernel.org/r/20210309082128.23125-3-s.grosj...@peak-system.com
Signed-off-by: Stephane Grosjean 
Signed-off-by: Marc Kleine-Budde 
Signed-off-by: Sasha Levin 
---
 drivers/net/can/usb/peak_usb/pcan_usb_fd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c 
b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
index 0d762bdac4f8..56280a28e135 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
@@ -26,6 +26,8 @@
 
 MODULE_SUPPORTED_DEVICE("PEAK-System PCAN-USB FD adapter");
 MODULE_SUPPORTED_DEVICE("PEAK-System PCAN-USB Pro FD adapter");
+MODULE_SUPPORTED_DEVICE("PEAK-System PCAN-Chip USB");
+MODULE_SUPPORTED_DEVICE("PEAK-System PCAN-USB X6 adapter");
 
 #define PCAN_USBPROFD_CHANNEL_COUNT2
 #define PCAN_USBFD_CHANNEL_COUNT   1
-- 
2.30.1





[PATCH 4/6] pinctrl: add pinctrl driver on mt8195

2021-03-29 Thread Zhiyong Tao
This commit includes pinctrl driver for mt8195.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/Kconfig |   6 +
 drivers/pinctrl/mediatek/Makefile|   1 +
 drivers/pinctrl/mediatek/pinctrl-mt8195.c| 828 
 include/dt-bindings/pinctrl/mt8195-pinfunc.h | 962 +++
 4 files changed, 1797 insertions(+)
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8195.c
 create mode 100644 include/dt-bindings/pinctrl/mt8195-pinfunc.h

diff --git a/drivers/pinctrl/mediatek/Kconfig b/drivers/pinctrl/mediatek/Kconfig
index eef17f228669..90f0c8255eaf 100644
--- a/drivers/pinctrl/mediatek/Kconfig
+++ b/drivers/pinctrl/mediatek/Kconfig
@@ -147,6 +147,12 @@ config PINCTRL_MT8192
default ARM64 && ARCH_MEDIATEK
select PINCTRL_MTK_PARIS
 
+config PINCTRL_MT8195
+   bool "Mediatek MT8195 pin control"
+   depends on OF
+   depends on ARM64 || COMPILE_TEST
+   select PINCTRL_MTK_PARIS
+
 config PINCTRL_MT8516
bool "Mediatek MT8516 pin control"
depends on OF
diff --git a/drivers/pinctrl/mediatek/Makefile 
b/drivers/pinctrl/mediatek/Makefile
index 01218bf4dc30..06fde993ace2 100644
--- a/drivers/pinctrl/mediatek/Makefile
+++ b/drivers/pinctrl/mediatek/Makefile
@@ -21,5 +21,6 @@ obj-$(CONFIG_PINCTRL_MT8167)  += pinctrl-mt8167.o
 obj-$(CONFIG_PINCTRL_MT8173)   += pinctrl-mt8173.o
 obj-$(CONFIG_PINCTRL_MT8183)   += pinctrl-mt8183.o
 obj-$(CONFIG_PINCTRL_MT8192)   += pinctrl-mt8192.o
+obj-$(CONFIG_PINCTRL_MT8195)+= pinctrl-mt8195.o
 obj-$(CONFIG_PINCTRL_MT8516)   += pinctrl-mt8516.o
 obj-$(CONFIG_PINCTRL_MT6397)   += pinctrl-mt6397.o
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8195.c 
b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
new file mode 100644
index ..063f164d7c9b
--- /dev/null
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
@@ -0,0 +1,828 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 MediaTek Inc.
+ *
+ * Author: Zhiyong Tao 
+ *
+ */
+
+#include "pinctrl-mtk-mt8195.h"
+#include "pinctrl-paris.h"
+
+/* MT8195 have multiple bases to program pin configuration listed as the below:
+ * iocfg[0]:0x10005000, iocfg[1]:0x11d1, iocfg[2]:0x11d3,
+ * iocfg[3]:0x11d4, iocfg[4]:0x11e2, iocfg[5]:0x11eb,
+ * iocfg[6]:0x11f4.
+ * _i_based could be used to indicate what base the pin should be mapped into.
+ */
+
+#define PIN_FIELD_BASE(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits) \
+   PIN_FIELD_CALC(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits, \
+  32, 0)
+
+#define PINS_FIELD_BASE(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits) \
+   PIN_FIELD_CALC(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits,  \
+  32, 1)
+
+static const struct mtk_pin_field_calc mt8195_pin_mode_range[] = {
+   PIN_FIELD(0, 144, 0x300, 0x10, 0, 4),
+};
+
+static const struct mtk_pin_field_calc mt8195_pin_dir_range[] = {
+   PIN_FIELD(0, 144, 0x0, 0x10, 0, 1),
+};
+
+static const struct mtk_pin_field_calc mt8195_pin_di_range[] = {
+   PIN_FIELD(0, 144, 0x200, 0x10, 0, 1),
+};
+
+static const struct mtk_pin_field_calc mt8195_pin_do_range[] = {
+   PIN_FIELD(0, 144, 0x100, 0x10, 0, 1),
+};
+
+static const struct mtk_pin_field_calc mt8195_pin_ies_range[] = {
+   PIN_FIELD_BASE(0, 0, 4, 0x040, 0x10, 0, 1),
+   PIN_FIELD_BASE(1, 1, 4, 0x040, 0x10, 1, 1),
+   PIN_FIELD_BASE(2, 2, 4, 0x040, 0x10, 2, 1),
+   PIN_FIELD_BASE(3, 3, 4, 0x040, 0x10, 3, 1),
+   PIN_FIELD_BASE(4, 4, 4, 0x040, 0x10, 4, 1),
+   PIN_FIELD_BASE(5, 5, 4, 0x040, 0x10, 5, 1),
+   PIN_FIELD_BASE(6, 6, 4, 0x040, 0x10, 6, 1),
+   PIN_FIELD_BASE(7, 7, 4, 0x040, 0x10, 7, 1),
+   PIN_FIELD_BASE(8, 8, 4, 0x040, 0x10, 13, 1),
+   PIN_FIELD_BASE(9, 9, 4, 0x040, 0x10, 8, 1),
+   PIN_FIELD_BASE(10, 10, 4, 0x040, 0x10, 14, 1),
+   PIN_FIELD_BASE(11, 11, 4, 0x040, 0x10, 9, 1),
+   PIN_FIELD_BASE(12, 12, 4, 0x040, 0x10, 15, 1),
+   PIN_FIELD_BASE(13, 13, 4, 0x040, 0x10, 10, 1),
+   PIN_FIELD_BASE(14, 14, 4, 0x040, 0x10, 16, 1),
+   PIN_FIELD_BASE(15, 15, 4, 0x040, 0x10, 11, 1),
+   PIN_FIELD_BASE(16, 16, 4, 0x040, 0x10, 17, 1),
+   PIN_FIELD_BASE(17, 17, 4, 0x040, 0x10, 12, 1),
+   PIN_FIELD_BASE(18, 18, 2, 0x040, 0x10, 5, 1),
+   PIN_FIELD_BASE(19, 19, 2, 0x040, 0x10, 12, 1),
+   PIN_FIELD_BASE(20, 20, 2, 0x040, 0x10, 11, 1),
+   PIN_FIELD_BASE(21, 21, 2, 0x040, 0x10, 10, 1),
+   PIN_FIELD_BASE(22, 22, 2, 0x040, 0x10, 0, 1),
+   PIN_FIELD_BASE(23, 23, 2, 0x040, 0x10, 1, 1),
+   PIN_FIELD_BASE(24, 24, 2, 0x040, 0x10, 2, 1),
+   PIN_FIELD_BASE(25, 25, 2, 0x040, 0x10, 4, 1),
+   PIN_FIELD_BASE(26, 26, 2, 0x040, 0x10, 3, 1),
+   PIN_FIELD_BASE(27, 27, 2, 0x040, 0x10, 6, 1),
+   PIN_FIELD_BASE(28, 28, 2, 0x040, 0x10, 7, 1),
+   PIN_FIELD_BASE(29, 29, 2, 0x040, 0x10, 8, 1),
+   PIN_FIELD_BASE(30, 30, 2, 0x040, 0x10, 9, 1),
+   PIN_FIELD_BA

[PATCH 5.10 158/221] igb: check timestamp validity

2021-03-29 Thread Greg Kroah-Hartman
From: Jesse Brandeburg 

[ Upstream commit f0a03a026857d6c7766eb7d5835edbf5523ca15c ]

Add a couple of checks to make sure timestamping is on and that the
timestamp value from DMA is valid. This avoids any functional issues
that could come from a misinterpreted time stamp.

One of the functions changed doesn't need a return value added because
there was no value in checking from the calling locations.

While here, fix a couple of reverse christmas tree issues next to
the code being changed.

Fixes: f56e7bba22fa ("igb: Pull timestamp from fragment before adding it to 
skb")
Fixes: 9cbc948b5a20 ("igb: add XDP support")
Signed-off-by: Jesse Brandeburg 
Tested-by: Dave Switzer 
Signed-off-by: Tony Nguyen 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/intel/igb/igb.h  |  4 +--
 drivers/net/ethernet/intel/igb/igb_main.c | 11 
 drivers/net/ethernet/intel/igb/igb_ptp.c  | 31 ++-
 3 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb.h 
b/drivers/net/ethernet/intel/igb/igb.h
index aaa954aae574..7bda8c5edea5 100644
--- a/drivers/net/ethernet/intel/igb/igb.h
+++ b/drivers/net/ethernet/intel/igb/igb.h
@@ -748,8 +748,8 @@ void igb_ptp_suspend(struct igb_adapter *adapter);
 void igb_ptp_rx_hang(struct igb_adapter *adapter);
 void igb_ptp_tx_hang(struct igb_adapter *adapter);
 void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector, struct sk_buff *skb);
-void igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector, void *va,
-struct sk_buff *skb);
+int igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector, void *va,
+   struct sk_buff *skb);
 int igb_ptp_set_ts_config(struct net_device *netdev, struct ifreq *ifr);
 int igb_ptp_get_ts_config(struct net_device *netdev, struct ifreq *ifr);
 void igb_set_flag_queue_pairs(struct igb_adapter *, const u32);
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c 
b/drivers/net/ethernet/intel/igb/igb_main.c
index 0d343d050973..ebe80ec6e437 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -8319,9 +8319,10 @@ static struct sk_buff *igb_construct_skb(struct igb_ring 
*rx_ring,
return NULL;
 
if (unlikely(igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TSIP))) {
-   igb_ptp_rx_pktstamp(rx_ring->q_vector, xdp->data, skb);
-   xdp->data += IGB_TS_HDR_LEN;
-   size -= IGB_TS_HDR_LEN;
+   if (!igb_ptp_rx_pktstamp(rx_ring->q_vector, xdp->data, skb)) {
+   xdp->data += IGB_TS_HDR_LEN;
+   size -= IGB_TS_HDR_LEN;
+   }
}
 
/* Determine available headroom for copy */
@@ -8382,8 +8383,8 @@ static struct sk_buff *igb_build_skb(struct igb_ring 
*rx_ring,
 
/* pull timestamp out of packet data */
if (igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TSIP)) {
-   igb_ptp_rx_pktstamp(rx_ring->q_vector, skb->data, skb);
-   __skb_pull(skb, IGB_TS_HDR_LEN);
+   if (!igb_ptp_rx_pktstamp(rx_ring->q_vector, skb->data, skb))
+   __skb_pull(skb, IGB_TS_HDR_LEN);
}
 
/* update buffer offset */
diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c 
b/drivers/net/ethernet/intel/igb/igb_ptp.c
index 7cc5428c3b3d..86a576201f5f 100644
--- a/drivers/net/ethernet/intel/igb/igb_ptp.c
+++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
@@ -856,6 +856,9 @@ static void igb_ptp_tx_hwtstamp(struct igb_adapter *adapter)
dev_kfree_skb_any(skb);
 }
 
+#define IGB_RET_PTP_DISABLED 1
+#define IGB_RET_PTP_INVALID 2
+
 /**
  * igb_ptp_rx_pktstamp - retrieve Rx per packet timestamp
  * @q_vector: Pointer to interrupt specific structure
@@ -864,19 +867,29 @@ static void igb_ptp_tx_hwtstamp(struct igb_adapter 
*adapter)
  *
  * This function is meant to retrieve a timestamp from the first buffer of an
  * incoming frame.  The value is stored in little endian format starting on
- * byte 8.
+ * byte 8
+ *
+ * Returns: 0 if success, nonzero if failure
  **/
-void igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector, void *va,
-struct sk_buff *skb)
+int igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector, void *va,
+   struct sk_buff *skb)
 {
-   __le64 *regval = (__le64 *)va;
struct igb_adapter *adapter = q_vector->adapter;
+   __le64 *regval = (__le64 *)va;
int adjust = 0;
 
+   if (!(adapter->ptp_flags & IGB_PTP_ENABLED))
+   return IGB_RET_PTP_DISABLED;
+
/* The timestamp is recorded in little endian format.
 * DWORD: 0123
 * Field: Reserved Reserved SYSTIML  SYSTIMH
 */
+
+   /* check reserved dwords are zero, be/le doesn't matter for zero */
+   if (regval[0])
+   return IGB_RET_PTP_INVALID;
+
igb_ptp_systim_to_hwtstamp(adapter, skb_hwtstamps(skb),

[PATCH 6/6] pinctrl: add rsel setting on MT8195

2021-03-29 Thread Zhiyong Tao
This patch provides rsel setting on MT8195.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/pinctrl-mt8195.c | 22 +++
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.c  | 14 
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.h  | 10 +
 drivers/pinctrl/mediatek/pinctrl-paris.c  | 16 ++
 4 files changed, 62 insertions(+)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8195.c 
b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
index a7500e18bb1d..66608b8d346a 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt8195.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
@@ -779,6 +779,25 @@ static const struct mtk_pin_field_calc 
mt8195_pin_drv_adv_range[] = {
PIN_FIELD_BASE(45, 45, 1, 0x040, 0x10, 9, 3),
 };
 
+static const struct mtk_pin_field_calc mt8195_pin_rsel_range[] = {
+   PIN_FIELD_BASE(8, 8, 4, 0x0c0, 0x10, 15, 3),
+   PIN_FIELD_BASE(9, 9, 4, 0x0c0, 0x10, 0, 3),
+   PIN_FIELD_BASE(10, 10, 4, 0x0c0, 0x10, 18, 3),
+   PIN_FIELD_BASE(11, 11, 4, 0x0c0, 0x10, 3, 3),
+   PIN_FIELD_BASE(12, 12, 4, 0x0c0, 0x10, 21, 3),
+   PIN_FIELD_BASE(13, 13, 4, 0x0c0, 0x10, 6, 3),
+   PIN_FIELD_BASE(14, 14, 4, 0x0c0, 0x10, 24, 3),
+   PIN_FIELD_BASE(15, 15, 4, 0x0c0, 0x10, 9, 3),
+   PIN_FIELD_BASE(16, 16, 4, 0x0c0, 0x10, 27, 3),
+   PIN_FIELD_BASE(17, 17, 4, 0x0c0, 0x10, 12, 3),
+   PIN_FIELD_BASE(29, 29, 2, 0x080, 0x10, 0, 3),
+   PIN_FIELD_BASE(30, 30, 2, 0x080, 0x10, 3, 3),
+   PIN_FIELD_BASE(34, 34, 1, 0x0e0, 0x10, 0, 3),
+   PIN_FIELD_BASE(35, 35, 1, 0x0e0, 0x10, 3, 3),
+   PIN_FIELD_BASE(44, 44, 1, 0x0e0, 0x10, 6, 3),
+   PIN_FIELD_BASE(45, 45, 1, 0x0e0, 0x10, 9, 3),
+};
+
 static const struct mtk_pin_reg_calc mt8195_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt8195_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt8195_pin_dir_range),
@@ -793,6 +812,7 @@ static const struct mtk_pin_reg_calc 
mt8195_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt8195_pin_r0_range),
[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt8195_pin_r1_range),
[PINCTRL_PIN_REG_DRV_ADV] = MTK_RANGE(mt8195_pin_drv_adv_range),
+   [PINCTRL_PIN_REG_RSEL] = MTK_RANGE(mt8195_pin_rsel_range),
 };
 
 static const char * const mt8195_pinctrl_register_base_names[] = {
@@ -823,6 +843,8 @@ static const struct mtk_pin_soc mt8195_data = {
.drive_get = mtk_pinconf_drive_get_rev1,
.adv_drive_get = mtk_pinconf_adv_drive_get_raw,
.adv_drive_set = mtk_pinconf_adv_drive_set_raw,
+   .rsel_set = mtk_pinconf_rsel_set,
+   .rsel_get = mtk_pinconf_rsel_get,
 };
 
 static const struct of_device_id mt8195_pinctrl_of_match[] = {
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index 2b51f4a9b860..d1526d0c6248 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -1041,6 +1041,20 @@ int mtk_pinconf_adv_drive_get_raw(struct mtk_pinctrl *hw,
 }
 EXPORT_SYMBOL_GPL(mtk_pinconf_adv_drive_get_raw);
 
+int mtk_pinconf_rsel_set(struct mtk_pinctrl *hw,
+const struct mtk_pin_desc *desc, u32 arg)
+{
+   return mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_RSEL, arg);
+}
+EXPORT_SYMBOL_GPL(mtk_pinconf_rsel_set);
+
+int mtk_pinconf_rsel_get(struct mtk_pinctrl *hw,
+const struct mtk_pin_desc *desc, u32 *val)
+{
+   return mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_RSEL, val);
+}
+EXPORT_SYMBOL_GPL(mtk_pinconf_rsel_get);
+
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Sean Wang ");
 MODULE_DESCRIPTION("Pin configuration library module for mediatek SoCs");
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
index fd5ce9c5dcbd..570e8da7bf38 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
@@ -67,6 +67,7 @@ enum {
PINCTRL_PIN_REG_DRV_E0,
PINCTRL_PIN_REG_DRV_E1,
PINCTRL_PIN_REG_DRV_ADV,
+   PINCTRL_PIN_REG_RSEL,
PINCTRL_PIN_REG_MAX,
 };
 
@@ -237,6 +238,10 @@ struct mtk_pin_soc {
 const struct mtk_pin_desc *desc, u32 arg);
int (*adv_drive_get)(struct mtk_pinctrl *hw,
 const struct mtk_pin_desc *desc, u32 *val);
+   int (*rsel_set)(struct mtk_pinctrl *hw,
+   const struct mtk_pin_desc *desc, u32 arg);
+   int (*rsel_get)(struct mtk_pinctrl *hw,
+   const struct mtk_pin_desc *desc, u32 *val);
 
/* Specific driver data */
void*driver_data;
@@ -320,5 +325,10 @@ int mtk_pinconf_adv_drive_set_raw(struct mtk_pinctrl *hw,
 int mtk_pinconf_adv_drive_get_raw(struct mtk_pinctrl *hw,
  const struct mtk_pin_desc *desc, u32 *val);
 
+int mtk_pinconf_rse

[PATCH 4.14 38/59] can: c_can_pci: c_can_pci_remove(): fix use-after-free

2021-03-29 Thread Greg Kroah-Hartman
From: Tong Zhang 

[ Upstream commit 0429d6d89f97ebff4f17f13f5b5069c66bde8138 ]

There is a UAF in c_can_pci_remove(). dev is released by
free_c_can_dev() and is used by pci_iounmap(pdev, priv->base) later.
To fix this issue, save the mmio address before releasing dev.

Fixes: 5b92da0443c2 ("c_can_pci: generic module for C_CAN/D_CAN on PCI")
Link: https://lore.kernel.org/r/20210301024512.539039-1-ztong0...@gmail.com
Signed-off-by: Tong Zhang 
Signed-off-by: Marc Kleine-Budde 
Signed-off-by: Sasha Levin 
---
 drivers/net/can/c_can/c_can_pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/c_can/c_can_pci.c 
b/drivers/net/can/c_can/c_can_pci.c
index d065c0e2d18e..f3e0b2124a37 100644
--- a/drivers/net/can/c_can/c_can_pci.c
+++ b/drivers/net/can/c_can/c_can_pci.c
@@ -239,12 +239,13 @@ static void c_can_pci_remove(struct pci_dev *pdev)
 {
struct net_device *dev = pci_get_drvdata(pdev);
struct c_can_priv *priv = netdev_priv(dev);
+   void __iomem *addr = priv->base;
 
unregister_c_can_dev(dev);
 
free_c_can_dev(dev);
 
-   pci_iounmap(pdev, priv->base);
+   pci_iounmap(pdev, addr);
pci_disable_msi(pdev);
pci_clear_master(pdev);
pci_release_regions(pdev);
-- 
2.30.1





[PATCH 4.19 12/72] NFS: Correct size calculation for create reply length

2021-03-29 Thread Greg Kroah-Hartman
From: Frank Sorenson 

[ Upstream commit ad3dbe35c833c2d4d0bbf3f04c785d32f931e7c9 ]

CREATE requests return a post_op_fh3, rather than nfs_fh3. The
post_op_fh3 includes an extra word to indicate 'handle_follows'.

Without that additional word, create fails when full 64-byte
filehandles are in use.

Add NFS3_post_op_fh_sz, and correct the size calculation for
NFS3_createres_sz.

Signed-off-by: Frank Sorenson 
Signed-off-by: Anna Schumaker 
Signed-off-by: Sasha Levin 
---
 fs/nfs/nfs3xdr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c
index 9956453aa6ff..0ed419bb02b0 100644
--- a/fs/nfs/nfs3xdr.c
+++ b/fs/nfs/nfs3xdr.c
@@ -34,6 +34,7 @@
  */
 #define NFS3_fhandle_sz(1+16)
 #define NFS3_fh_sz (NFS3_fhandle_sz)   /* shorthand */
+#define NFS3_post_op_fh_sz (1+NFS3_fh_sz)
 #define NFS3_sattr_sz  (15)
 #define NFS3_filename_sz   (1+(NFS3_MAXNAMLEN>>2))
 #define NFS3_path_sz   (1+(NFS3_MAXPATHLEN>>2))
@@ -71,7 +72,7 @@
 #define NFS3_readlinkres_sz(1+NFS3_post_op_attr_sz+1)
 #define NFS3_readres_sz(1+NFS3_post_op_attr_sz+3)
 #define NFS3_writeres_sz   (1+NFS3_wcc_data_sz+4)
-#define NFS3_createres_sz  
(1+NFS3_fh_sz+NFS3_post_op_attr_sz+NFS3_wcc_data_sz)
+#define NFS3_createres_sz  
(1+NFS3_post_op_fh_sz+NFS3_post_op_attr_sz+NFS3_wcc_data_sz)
 #define NFS3_renameres_sz  (1+(2 * NFS3_wcc_data_sz))
 #define NFS3_linkres_sz
(1+NFS3_post_op_attr_sz+NFS3_wcc_data_sz)
 #define NFS3_readdirres_sz (1+NFS3_post_op_attr_sz+2)
-- 
2.30.1





[PATCH 4.19 11/72] nfs: fix PNFS_FLEXFILE_LAYOUT Kconfig default

2021-03-29 Thread Greg Kroah-Hartman
From: Timo Rothenpieler 

[ Upstream commit a0590473c5e6c4ef17c3132ad08fbad170f72d55 ]

This follows what was done in 8c2fabc6542d9d0f8b16bd1045c2eda59bdcde13.
With the default being m, it's impossible to build the module into the
kernel.

Signed-off-by: Timo Rothenpieler 
Signed-off-by: Anna Schumaker 
Signed-off-by: Sasha Levin 
---
 fs/nfs/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfs/Kconfig b/fs/nfs/Kconfig
index ac3e06367cb6..e55f86713948 100644
--- a/fs/nfs/Kconfig
+++ b/fs/nfs/Kconfig
@@ -127,7 +127,7 @@ config PNFS_BLOCK
 config PNFS_FLEXFILE_LAYOUT
tristate
depends on NFS_V4_1 && NFS_V3
-   default m
+   default NFS_V4
 
 config NFS_V4_1_IMPLEMENTATION_ID_DOMAIN
string "NFSv4.1 Implementation ID Domain"
-- 
2.30.1





[PATCH 4.19 16/72] atm: idt77252: fix null-ptr-dereference

2021-03-29 Thread Greg Kroah-Hartman
From: Tong Zhang 

[ Upstream commit 4416e98594dc04590ebc498fc4e530009535c511 ]

this one is similar to the phy_data allocation fix in uPD98402, the
driver allocate the idt77105_priv and store to dev_data but later
dereference using dev->dev_data, which will cause null-ptr-dereference.

fix this issue by changing dev_data to phy_data so that PRIV(dev) can
work correctly.

Signed-off-by: Tong Zhang 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/atm/idt77105.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/atm/idt77105.c b/drivers/atm/idt77105.c
index 0a67487c0b1d..a2ecb4190f78 100644
--- a/drivers/atm/idt77105.c
+++ b/drivers/atm/idt77105.c
@@ -261,7 +261,7 @@ static int idt77105_start(struct atm_dev *dev)
 {
unsigned long flags;
 
-   if (!(dev->dev_data = kmalloc(sizeof(struct idt77105_priv),GFP_KERNEL)))
+   if (!(dev->phy_data = kmalloc(sizeof(struct idt77105_priv),GFP_KERNEL)))
return -ENOMEM;
PRIV(dev)->dev = dev;
spin_lock_irqsave(&idt77105_priv_lock, flags);
@@ -336,7 +336,7 @@ static int idt77105_stop(struct atm_dev *dev)
 else
 idt77105_all = walk->next;
dev->phy = NULL;
-dev->dev_data = NULL;
+dev->phy_data = NULL;
 kfree(walk);
 break;
 }
-- 
2.30.1





[PATCH 4.19 10/72] gpiolib: acpi: Add missing IRQF_ONESHOT

2021-03-29 Thread Greg Kroah-Hartman
From: Yang Li 

[ Upstream commit 6e5d5791730b55a1f987e1db84b078b91eb49e99 ]

fixed the following coccicheck:
./drivers/gpio/gpiolib-acpi.c:176:7-27: ERROR: Threaded IRQ with no
primary handler requested without IRQF_ONESHOT

Make sure threaded IRQs without a primary handler are always request
with IRQF_ONESHOT

Reported-by: Abaci Robot 
Signed-off-by: Yang Li 
Acked-by: Andy Shevchenko 
Signed-off-by: Andy Shevchenko 
Signed-off-by: Sasha Levin 
---
 drivers/gpio/gpiolib-acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 18f5973b9697..4ad34c6803ad 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -177,7 +177,7 @@ static void acpi_gpiochip_request_irq(struct acpi_gpio_chip 
*acpi_gpio,
int ret, value;
 
ret = request_threaded_irq(event->irq, NULL, event->handler,
-  event->irqflags, "ACPI:Event", event);
+  event->irqflags | IRQF_ONESHOT, 
"ACPI:Event", event);
if (ret) {
dev_err(acpi_gpio->chip->parent,
"Failed to setup interrupt handler for %d\n",
-- 
2.30.1





[PATCH 4.19 14/72] net: wan: fix error return code of uhdlc_init()

2021-03-29 Thread Greg Kroah-Hartman
From: Jia-Ju Bai 

[ Upstream commit 62765d39553cfd1ad340124fe1e280450e8c89e2 ]

When priv->rx_skbuff or priv->tx_skbuff is NULL, no error return code of
uhdlc_init() is assigned.
To fix this bug, ret is assigned with -ENOMEM in these cases.

Reported-by: TOTE Robot 
Signed-off-by: Jia-Ju Bai 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/wan/fsl_ucc_hdlc.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index 9ab04ef532f3..5df6e85e7ccb 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -201,14 +201,18 @@ static int uhdlc_init(struct ucc_hdlc_private *priv)
priv->rx_skbuff = kcalloc(priv->rx_ring_size,
  sizeof(*priv->rx_skbuff),
  GFP_KERNEL);
-   if (!priv->rx_skbuff)
+   if (!priv->rx_skbuff) {
+   ret = -ENOMEM;
goto free_ucc_pram;
+   }
 
priv->tx_skbuff = kcalloc(priv->tx_ring_size,
  sizeof(*priv->tx_skbuff),
  GFP_KERNEL);
-   if (!priv->tx_skbuff)
+   if (!priv->tx_skbuff) {
+   ret = -ENOMEM;
goto free_rx_skbuff;
+   }
 
priv->skb_curtx = 0;
priv->skb_dirtytx = 0;
-- 
2.30.1





[PATCH 4.19 15/72] atm: uPD98402: fix incorrect allocation

2021-03-29 Thread Greg Kroah-Hartman
From: Tong Zhang 

[ Upstream commit 3153724fc084d8ef640c611f269ddfb576d1dcb1 ]

dev->dev_data is set in zatm.c, calling zatm_start() will overwrite this
dev->dev_data in uPD98402_start() and a subsequent PRIV(dev)->lock
(i.e dev->phy_data->lock) will result in a null-ptr-dereference.

I believe this is a typo and what it actually want to do is to allocate
phy_data instead of dev_data.

Signed-off-by: Tong Zhang 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/atm/uPD98402.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
index 4fa13a807873..cf517fd148ea 100644
--- a/drivers/atm/uPD98402.c
+++ b/drivers/atm/uPD98402.c
@@ -210,7 +210,7 @@ static void uPD98402_int(struct atm_dev *dev)
 static int uPD98402_start(struct atm_dev *dev)
 {
DPRINTK("phy_start\n");
-   if (!(dev->dev_data = kmalloc(sizeof(struct uPD98402_priv),GFP_KERNEL)))
+   if (!(dev->phy_data = kmalloc(sizeof(struct uPD98402_priv),GFP_KERNEL)))
return -ENOMEM;
spin_lock_init(&PRIV(dev)->lock);
memset(&PRIV(dev)->sonet_stats,0,sizeof(struct k_sonet_stats));
-- 
2.30.1





[PATCH 4.19 13/72] net: hisilicon: hns: fix error return code of hns_nic_clear_all_rx_fetch()

2021-03-29 Thread Greg Kroah-Hartman
From: Jia-Ju Bai 

[ Upstream commit 143c253f42bad20357e7e4432087aca747c43384 ]

When hns_assemble_skb() returns NULL to skb, no error return code of
hns_nic_clear_all_rx_fetch() is assigned.
To fix this bug, ret is assigned with -ENOMEM in this case.

Reported-by: TOTE Robot 
Signed-off-by: Jia-Ju Bai 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/hisilicon/hns/hns_enet.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c 
b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index 4de65a9de0a6..b7fe3e849872 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -1677,8 +1677,10 @@ static int hns_nic_clear_all_rx_fetch(struct net_device 
*ndev)
for (j = 0; j < fetch_num; j++) {
/* alloc one skb and init */
skb = hns_assemble_skb(ndev);
-   if (!skb)
+   if (!skb) {
+   ret = -ENOMEM;
goto out;
+   }
rd = &tx_ring_data(priv, skb->queue_mapping);
hns_nic_net_xmit_hw(ndev, skb, rd);
 
-- 
2.30.1





[PATCH 5.4 110/111] ext4: add reclaim checks to xattr code

2021-03-29 Thread Greg Kroah-Hartman
From: Jan Kara 

commit 163f0ec1df33cf468509ff38cbcbb5eb0d7fac60 upstream.

Syzbot is reporting that ext4 can enter fs reclaim from kvmalloc() while
the transaction is started like:

  fs_reclaim_acquire+0x117/0x150 mm/page_alloc.c:4340
  might_alloc include/linux/sched/mm.h:193 [inline]
  slab_pre_alloc_hook mm/slab.h:493 [inline]
  slab_alloc_node mm/slub.c:2817 [inline]
  __kmalloc_node+0x5f/0x430 mm/slub.c:4015
  kmalloc_node include/linux/slab.h:575 [inline]
  kvmalloc_node+0x61/0xf0 mm/util.c:587
  kvmalloc include/linux/mm.h:781 [inline]
  ext4_xattr_inode_cache_find fs/ext4/xattr.c:1465 [inline]
  ext4_xattr_inode_lookup_create fs/ext4/xattr.c:1508 [inline]
  ext4_xattr_set_entry+0x1ce6/0x3780 fs/ext4/xattr.c:1649
  ext4_xattr_ibody_set+0x78/0x2b0 fs/ext4/xattr.c:2224
  ext4_xattr_set_handle+0x8f4/0x13e0 fs/ext4/xattr.c:2380
  ext4_xattr_set+0x13a/0x340 fs/ext4/xattr.c:2493

This should be impossible since transaction start sets PF_MEMALLOC_NOFS.
Add some assertions to the code to catch if something isn't working as
expected early.

Link: 
https://lore.kernel.org/linux-ext4/563a0205bafb7...@google.com/
Signed-off-by: Jan Kara 
Link: https://lore.kernel.org/r/20210222171626.21884-1-j...@suse.cz
Signed-off-by: Theodore Ts'o 
Signed-off-by: Greg Kroah-Hartman 
---
 fs/ext4/xattr.c |4 
 1 file changed, 4 insertions(+)

--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1476,6 +1476,9 @@ ext4_xattr_inode_cache_find(struct inode
if (!ce)
return NULL;
 
+   WARN_ON_ONCE(ext4_handle_valid(journal_current_handle()) &&
+!(current->flags & PF_MEMALLOC_NOFS));
+
ea_data = ext4_kvmalloc(value_len, GFP_NOFS);
if (!ea_data) {
mb_cache_entry_put(ea_inode_cache, ce);
@@ -2342,6 +2345,7 @@ ext4_xattr_set_handle(handle_t *handle,
error = -ENOSPC;
goto cleanup;
}
+   WARN_ON_ONCE(!(current->flags & PF_MEMALLOC_NOFS));
}
 
error = ext4_reserve_inode_write(handle, inode, &is.iloc);




[PATCH v4 0/2] add one regulator used to power up pcie phy

2021-03-29 Thread Richard Zhu
Changes:
v3 -> v4
Split the DTS changes to a standalone patch from this patch-set.
And would post to Shawn to take it, after the other two are accepted
by PCIe tree.
Refine the DT binding descriptions refer to Lucas' suggestion.
Use "Regarding" to replace the "Regarding to" in the comments
refer to Krzysztof's suggestion.

v2 -> v3:
Refine the DT binding descriptions, and the condition adjustment in the codes.

v1 -> v2:
Don't use the boolean property to specify the different power supply of PCIe 
PHY.
Use one regulator as a supply to the PCIe controller node, and the regulator 
APIs
to get the voltage of it.

Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt |  3 +++
drivers/pci/controller/dwc/pci-imx6.c| 20 

2 files changed, 23 insertions(+)

[PATCH v4 1/2] dt-bindings: imx6q-pcie: add one regulator used to
[PATCH v4 2/2] PCI: imx: clear vreg bypass when pcie vph voltage is



[PATCH 5.10 021/221] gpiolib: acpi: Add missing IRQF_ONESHOT

2021-03-29 Thread Greg Kroah-Hartman
From: Yang Li 

[ Upstream commit 6e5d5791730b55a1f987e1db84b078b91eb49e99 ]

fixed the following coccicheck:
./drivers/gpio/gpiolib-acpi.c:176:7-27: ERROR: Threaded IRQ with no
primary handler requested without IRQF_ONESHOT

Make sure threaded IRQs without a primary handler are always request
with IRQF_ONESHOT

Reported-by: Abaci Robot 
Signed-off-by: Yang Li 
Acked-by: Andy Shevchenko 
Signed-off-by: Andy Shevchenko 
Signed-off-by: Sasha Levin 
---
 drivers/gpio/gpiolib-acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 49a1f8ce4baa..863f059bc498 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -174,7 +174,7 @@ static void acpi_gpiochip_request_irq(struct acpi_gpio_chip 
*acpi_gpio,
int ret, value;
 
ret = request_threaded_irq(event->irq, NULL, event->handler,
-  event->irqflags, "ACPI:Event", event);
+  event->irqflags | IRQF_ONESHOT, 
"ACPI:Event", event);
if (ret) {
dev_err(acpi_gpio->chip->parent,
"Failed to setup interrupt handler for %d\n",
-- 
2.30.1





[PATCH 5.10 008/221] atm: lanai: dont run lanai_dev_close if not open

2021-03-29 Thread Greg Kroah-Hartman
From: Tong Zhang 

[ Upstream commit a2bd45834e83d6c5a04d397bde13d744a4812dfc ]

lanai_dev_open() can fail. When it fail, lanai->base is unmapped and the
pci device is disabled. The caller, lanai_init_one(), then tries to run
atm_dev_deregister(). This will subsequently call lanai_dev_close() and
use the already released MMIO area.

To fix this issue, set the lanai->base to NULL if open fail,
and test the flag in lanai_dev_close().

[8.324153] lanai: lanai_start() failed, err=19
[8.324819] lanai(itf 0): shutting down interface
[8.325211] BUG: unable to handle page fault for address: c9180024
[8.325781] #PF: supervisor write access in kernel mode
[8.326215] #PF: error_code(0x0002) - not-present page
[8.326641] PGD 10067 P4D 10067 PUD 100139067 PMD 10013a067 PTE 0
[8.327206] Oops: 0002 [#1] SMP KASAN NOPTI
[8.327557] CPU: 0 PID: 95 Comm: modprobe Not tainted 
5.11.0-rc7-00090-gdcc0b49040c7 #12
[8.328229] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 
rel-1.13.0-48-gd9c812dda519-4
[8.329145] RIP: 0010:lanai_dev_close+0x4f/0xe5 [lanai]
[8.329587] Code: 00 48 c7 c7 00 d3 01 c0 e8 49 4e 0a c2 48 8d bd 08 02 00 
00 e8 6e 52 14 c1 48 80
[8.330917] RSP: 0018:8881029ef680 EFLAGS: 00010246
[8.331196] RAX: 0003fffe RBX: 888102fb4800 RCX: c001a98a
[8.331572] RDX: c918 RSI: 0246 RDI: 888102fb4000
[8.331948] RBP: 888102fb4000 R08: 8115da8a R09: ed102053deaa
[8.332326] R10: 0003 R11: ed102053dea9 R12: 888102fb48a4
[8.332701] R13: c00123c0 R14: 888102fb4b90 R15: 888102fb4b88
[8.333077] FS:  7f08eb9056a0() GS:88815b40() 
knlGS:
[8.333502] CS:  0010 DS:  ES:  CR0: 80050033
[8.333806] CR2: c9180024 CR3: 000102a28000 CR4: 06f0
[8.334182] DR0:  DR1:  DR2: 
[8.334557] DR3:  DR6: fffe0ff0 DR7: 0400
[8.334932] Call Trace:
[8.335066]  atm_dev_deregister+0x161/0x1a0 [atm]
[8.335324]  lanai_init_one.cold+0x20c/0x96d [lanai]
[8.335594]  ? lanai_send+0x2a0/0x2a0 [lanai]
[8.335831]  local_pci_probe+0x6f/0xb0
[8.336039]  pci_device_probe+0x171/0x240
[8.336255]  ? pci_device_remove+0xe0/0xe0
[8.336475]  ? kernfs_create_link+0xb6/0x110
[8.336704]  ? sysfs_do_create_link_sd.isra.0+0x76/0xe0
[8.336983]  really_probe+0x161/0x420
[8.337181]  driver_probe_device+0x6d/0xd0
[8.337401]  device_driver_attach+0x82/0x90
[8.337626]  ? device_driver_attach+0x90/0x90
[8.337859]  __driver_attach+0x60/0x100
[8.338065]  ? device_driver_attach+0x90/0x90
[8.338298]  bus_for_each_dev+0xe1/0x140
[8.338511]  ? subsys_dev_iter_exit+0x10/0x10
[8.338745]  ? klist_node_init+0x61/0x80
[8.338956]  bus_add_driver+0x254/0x2a0
[8.339164]  driver_register+0xd3/0x150
[8.339370]  ? 0xc0028000
[8.339550]  do_one_initcall+0x84/0x250
[8.339755]  ? trace_event_raw_event_initcall_finish+0x150/0x150
[8.340076]  ? free_vmap_area_noflush+0x1a5/0x5c0
[8.340329]  ? unpoison_range+0xf/0x30
[8.340532]  ? kasan_kmalloc.constprop.0+0x84/0xa0
[8.340806]  ? unpoison_range+0xf/0x30
[8.341014]  ? unpoison_range+0xf/0x30
[8.341217]  do_init_module+0xf8/0x350
[8.341419]  load_module+0x3fe6/0x4340
[8.341621]  ? vm_unmap_ram+0x1d0/0x1d0
[8.341826]  ? kasan_kmalloc.constprop.0+0x84/0xa0
[8.342101]  ? module_frob_arch_sections+0x20/0x20
[8.342358]  ? __do_sys_finit_module+0x108/0x170
[8.342604]  __do_sys_finit_module+0x108/0x170
[8.342841]  ? __ia32_sys_init_module+0x40/0x40
[8.343083]  ? file_open_root+0x200/0x200
[8.343298]  ? do_sys_open+0x85/0xe0
[8.343491]  ? filp_open+0x50/0x50
[8.343675]  ? exit_to_user_mode_prepare+0xfc/0x130
[8.343935]  do_syscall_64+0x33/0x40
[8.344132]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[8.344401] RIP: 0033:0x7f08eb887cf7
[8.344594] Code: 48 89 57 30 48 8b 04 24 48 89 47 38 e9 1d a0 02 00 48 89 
f8 48 89 f7 48 89 d6 41
[8.345565] RSP: 002b:7ffcd5c98ad8 EFLAGS: 0246 ORIG_RAX: 
0139
[8.345962] RAX: ffda RBX: 008fea70 RCX: 7f08eb887cf7
[8.346336] RDX:  RSI: 008fd9e0 RDI: 0003
[8.346711] RBP: 0003 R08:  R09: 0001
[8.347085] R10: 7f08eb8eb300 R11: 0246 R12: 008fd9e0
[8.347460] R13:  R14: 008fddd0 R15: 0001
[8.347836] Modules linked in: lanai(+) atm
[8.348065] CR2: c9180024
[8.348244] ---[ end trace 7fdc1c668f2003e5 ]---
[8.348490] RIP: 0010:lanai_dev_close+0x4f/0xe5 [lanai]
[8.348772] Code: 00 48 c7 c7 00 d3 01 c0 e8 49 4e 0a c2 48 8d bd 08 02 00 
00 e8 6e 52 14 c1 48 80
[8.3

[PATCH 5.10 025/221] net: wan: fix error return code of uhdlc_init()

2021-03-29 Thread Greg Kroah-Hartman
From: Jia-Ju Bai 

[ Upstream commit 62765d39553cfd1ad340124fe1e280450e8c89e2 ]

When priv->rx_skbuff or priv->tx_skbuff is NULL, no error return code of
uhdlc_init() is assigned.
To fix this bug, ret is assigned with -ENOMEM in these cases.

Reported-by: TOTE Robot 
Signed-off-by: Jia-Ju Bai 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/wan/fsl_ucc_hdlc.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index dca97cd7c4e7..7eac6a3e1cde 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -204,14 +204,18 @@ static int uhdlc_init(struct ucc_hdlc_private *priv)
priv->rx_skbuff = kcalloc(priv->rx_ring_size,
  sizeof(*priv->rx_skbuff),
  GFP_KERNEL);
-   if (!priv->rx_skbuff)
+   if (!priv->rx_skbuff) {
+   ret = -ENOMEM;
goto free_ucc_pram;
+   }
 
priv->tx_skbuff = kcalloc(priv->tx_ring_size,
  sizeof(*priv->tx_skbuff),
  GFP_KERNEL);
-   if (!priv->tx_skbuff)
+   if (!priv->tx_skbuff) {
+   ret = -ENOMEM;
goto free_rx_skbuff;
+   }
 
priv->skb_curtx = 0;
priv->skb_dirtytx = 0;
-- 
2.30.1





[PATCH 5.10 129/221] can: c_can_pci: c_can_pci_remove(): fix use-after-free

2021-03-29 Thread Greg Kroah-Hartman
From: Tong Zhang 

[ Upstream commit 0429d6d89f97ebff4f17f13f5b5069c66bde8138 ]

There is a UAF in c_can_pci_remove(). dev is released by
free_c_can_dev() and is used by pci_iounmap(pdev, priv->base) later.
To fix this issue, save the mmio address before releasing dev.

Fixes: 5b92da0443c2 ("c_can_pci: generic module for C_CAN/D_CAN on PCI")
Link: https://lore.kernel.org/r/20210301024512.539039-1-ztong0...@gmail.com
Signed-off-by: Tong Zhang 
Signed-off-by: Marc Kleine-Budde 
Signed-off-by: Sasha Levin 
---
 drivers/net/can/c_can/c_can_pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/c_can/c_can_pci.c 
b/drivers/net/can/c_can/c_can_pci.c
index 406b4847e5dc..7efb60b50876 100644
--- a/drivers/net/can/c_can/c_can_pci.c
+++ b/drivers/net/can/c_can/c_can_pci.c
@@ -239,12 +239,13 @@ static void c_can_pci_remove(struct pci_dev *pdev)
 {
struct net_device *dev = pci_get_drvdata(pdev);
struct c_can_priv *priv = netdev_priv(dev);
+   void __iomem *addr = priv->base;
 
unregister_c_can_dev(dev);
 
free_c_can_dev(dev);
 
-   pci_iounmap(pdev, priv->base);
+   pci_iounmap(pdev, addr);
pci_disable_msi(pdev);
pci_clear_master(pdev);
pci_release_regions(pdev);
-- 
2.30.1





[PATCH 5.10 132/221] can: m_can: m_can_rx_peripheral(): fix RX being blocked by errors

2021-03-29 Thread Greg Kroah-Hartman
From: Torin Cooper-Bennun 

[ Upstream commit e98d9ee64ee2cc9b1d1a8e26610ec4d0392ebe50 ]

For M_CAN peripherals, m_can_rx_handler() was called with quota = 1,
which caused any error handling to block RX from taking place until
the next time the IRQ handler is called. This had been observed to
cause RX to be blocked indefinitely in some cases.

This is fixed by calling m_can_rx_handler with a sensibly high quota.

Fixes: f524f829b75a ("can: m_can: Create a m_can platform framework")
Link: 
https://lore.kernel.org/r/20210303144350.4093750-1-to...@maxiluxsystems.com
Suggested-by: Marc Kleine-Budde 
Signed-off-by: Torin Cooper-Bennun 
Signed-off-by: Marc Kleine-Budde 
Signed-off-by: Sasha Levin 
---
 drivers/net/can/m_can/m_can.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 6952d5b396e8..6f0bf5db885c 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -882,7 +882,7 @@ static int m_can_rx_peripheral(struct net_device *dev)
 {
struct m_can_classdev *cdev = netdev_priv(dev);
 
-   m_can_rx_handler(dev, 1);
+   m_can_rx_handler(dev, M_CAN_NAPI_WEIGHT);
 
m_can_enable_all_interrupts(cdev);
 
-- 
2.30.1





[PATCH 5.10 140/221] drm/msm/dsi: fix check-before-set in the 7nm dsi_pll code

2021-03-29 Thread Greg Kroah-Hartman
From: Dmitry Baryshkov 

[ Upstream commit 3b24cdfc721a5f1098da22f9f68ff5f4a5efccc9 ]

Fix setting min/max DSI PLL rate for the V4.1 7nm DSI PLL (used on
sm8250). Current code checks for pll->type before it is set (as it is
set in the msm_dsi_pll_init() after calling device-specific functions.

Cc: Jonathan Marek 
Fixes: 1ef7c99d145c ("drm/msm/dsi: add support for 7nm DSI PHY/PLL")
Signed-off-by: Dmitry Baryshkov 
Signed-off-by: Rob Clark 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/msm/dsi/pll/dsi_pll.c | 2 +-
 drivers/gpu/drm/msm/dsi/pll/dsi_pll.h | 6 --
 drivers/gpu/drm/msm/dsi/pll/dsi_pll_7nm.c | 5 +++--
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/pll/dsi_pll.c 
b/drivers/gpu/drm/msm/dsi/pll/dsi_pll.c
index a45fe95aff49..3dc65877fa10 100644
--- a/drivers/gpu/drm/msm/dsi/pll/dsi_pll.c
+++ b/drivers/gpu/drm/msm/dsi/pll/dsi_pll.c
@@ -163,7 +163,7 @@ struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device 
*pdev,
break;
case MSM_DSI_PHY_7NM:
case MSM_DSI_PHY_7NM_V4_1:
-   pll = msm_dsi_pll_7nm_init(pdev, id);
+   pll = msm_dsi_pll_7nm_init(pdev, type, id);
break;
default:
pll = ERR_PTR(-ENXIO);
diff --git a/drivers/gpu/drm/msm/dsi/pll/dsi_pll.h 
b/drivers/gpu/drm/msm/dsi/pll/dsi_pll.h
index 3405982a092c..bbecb1de5678 100644
--- a/drivers/gpu/drm/msm/dsi/pll/dsi_pll.h
+++ b/drivers/gpu/drm/msm/dsi/pll/dsi_pll.h
@@ -117,10 +117,12 @@ msm_dsi_pll_10nm_init(struct platform_device *pdev, int 
id)
 }
 #endif
 #ifdef CONFIG_DRM_MSM_DSI_7NM_PHY
-struct msm_dsi_pll *msm_dsi_pll_7nm_init(struct platform_device *pdev, int id);
+struct msm_dsi_pll *msm_dsi_pll_7nm_init(struct platform_device *pdev,
+   enum msm_dsi_phy_type type, int id);
 #else
 static inline struct msm_dsi_pll *
-msm_dsi_pll_7nm_init(struct platform_device *pdev, int id)
+msm_dsi_pll_7nm_init(struct platform_device *pdev,
+   enum msm_dsi_phy_type type, int id)
 {
return ERR_PTR(-ENODEV);
 }
diff --git a/drivers/gpu/drm/msm/dsi/pll/dsi_pll_7nm.c 
b/drivers/gpu/drm/msm/dsi/pll/dsi_pll_7nm.c
index 93bf142e4a4e..c1f6708367ae 100644
--- a/drivers/gpu/drm/msm/dsi/pll/dsi_pll_7nm.c
+++ b/drivers/gpu/drm/msm/dsi/pll/dsi_pll_7nm.c
@@ -852,7 +852,8 @@ err_base_clk_hw:
return ret;
 }
 
-struct msm_dsi_pll *msm_dsi_pll_7nm_init(struct platform_device *pdev, int id)
+struct msm_dsi_pll *msm_dsi_pll_7nm_init(struct platform_device *pdev,
+   enum msm_dsi_phy_type type, int id)
 {
struct dsi_pll_7nm *pll_7nm;
struct msm_dsi_pll *pll;
@@ -885,7 +886,7 @@ struct msm_dsi_pll *msm_dsi_pll_7nm_init(struct 
platform_device *pdev, int id)
pll = &pll_7nm->base;
pll->min_rate = 10UL;
pll->max_rate = 35UL;
-   if (pll->type == MSM_DSI_PHY_7NM_V4_1) {
+   if (type == MSM_DSI_PHY_7NM_V4_1) {
pll->min_rate = 6UL;
pll->max_rate = (unsigned long)50ULL;
/* workaround for max rate overflowing on 32-bit builds: */
-- 
2.30.1





[PATCH 5.10 163/221] libbpf: Fix BTF dump of pointer-to-array-of-struct

2021-03-29 Thread Greg Kroah-Hartman
From: Jean-Philippe Brucker 

[ Upstream commit 901ee1d750f29a335423eeb9463c3ca461ca18c2 ]

The vmlinux.h generated from BTF is invalid when building
drivers/phy/ti/phy-gmii-sel.c with clang:

vmlinux.h:61702:27: error: array type has incomplete element type ‘struct 
reg_field’
61702 |  const struct reg_field (*regfields)[3];
  |   ^

bpftool generates a forward declaration for this struct regfield, which
compilers aren't happy about. Here's a simplified reproducer:

struct inner {
int val;
};
struct outer {
struct inner (*ptr_to_array)[2];
} A;

After build with clang -> bpftool btf dump c -> clang/gcc:
./def-clang.h:11:23: error: array has incomplete element type 'struct inner'
struct inner (*ptr_to_array)[2];

Member ptr_to_array of struct outer is a pointer to an array of struct
inner. In the DWARF generated by clang, struct outer appears before
struct inner, so when converting BTF of struct outer into C, bpftool
issues a forward declaration to struct inner. With GCC the DWARF info is
reversed so struct inner gets fully defined.

That forward declaration is not sufficient when compilers handle an
array of the struct, even when it's only used through a pointer. Note
that we can trigger the same issue with an intermediate typedef:

struct inner {
int val;
};
typedef struct inner inner2_t[2];
struct outer {
inner2_t *ptr_to_array;
} A;

Becomes:

struct inner;
typedef struct inner inner2_t[2];

And causes:

./def-clang.h:10:30: error: array has incomplete element type 'struct inner'
typedef struct inner inner2_t[2];

To fix this, clear through_ptr whenever we encounter an intermediate
array, to make the inner struct part of a strong link and force full
declaration.

Fixes: 351131b51c7a ("libbpf: add btf_dump API for BTF-to-C conversion")
Signed-off-by: Jean-Philippe Brucker 
Signed-off-by: Andrii Nakryiko 
Link: 
https://lore.kernel.org/bpf/20210319112554.794552-2-jean-phili...@linaro.org
Signed-off-by: Sasha Levin 
---
 tools/lib/bpf/btf_dump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c
index 2f9d685bd522..0911aea4cdbe 100644
--- a/tools/lib/bpf/btf_dump.c
+++ b/tools/lib/bpf/btf_dump.c
@@ -462,7 +462,7 @@ static int btf_dump_order_type(struct btf_dump *d, __u32 
id, bool through_ptr)
return err;
 
case BTF_KIND_ARRAY:
-   return btf_dump_order_type(d, btf_array(t)->type, through_ptr);
+   return btf_dump_order_type(d, btf_array(t)->type, false);
 
case BTF_KIND_STRUCT:
case BTF_KIND_UNION: {
-- 
2.30.1





[PATCH 5.10 162/221] selftests: forwarding: vxlan_bridge_1d: Fix vxlan ecn decapsulate value

2021-03-29 Thread Greg Kroah-Hartman
From: Hangbin Liu 

[ Upstream commit 5aa3c334a449bab24519c4967f5ac2b3304c8dcf ]

The ECN bit defines ECT(1) = 1, ECT(0) = 2. So inner 0x02 + outer 0x01
should be inner ECT(0) + outer ECT(1). Based on the description of
__INET_ECN_decapsulate, the final decapsulate value should be
ECT(1). So fix the test expect value to 0x01.

Before the fix:
TEST: VXLAN: ECN decap: 01/02->0x02 [FAIL]
Expected to capture 10 packets, got 0.

After the fix:
TEST: VXLAN: ECN decap: 01/02->0x01 [ OK ]

Fixes: a0b61f3d8ebf ("selftests: forwarding: vxlan_bridge_1d: Add an ECN decap 
test")
Signed-off-by: Hangbin Liu 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh 
b/tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh
index ce6bea9675c0..0ccb1dda099a 100755
--- a/tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh
+++ b/tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh
@@ -658,7 +658,7 @@ test_ecn_decap()
# In accordance with INET_ECN_decapsulate()
__test_ecn_decap 00 00 0x00
__test_ecn_decap 01 01 0x01
-   __test_ecn_decap 02 01 0x02
+   __test_ecn_decap 02 01 0x01
__test_ecn_decap 01 03 0x03
__test_ecn_decap 02 03 0x03
test_ecn_decap_error
-- 
2.30.1





[PATCH 5.10 164/221] bpf: Fix umd memory leak in copy_process()

2021-03-29 Thread Greg Kroah-Hartman
From: Zqiang 

[ Upstream commit f60a85cad677c4f9bb4cadd764f1d106c38c7cf8 ]

The syzbot reported a memleak as follows:

BUG: memory leak
unreferenced object 0x888101b41d00 (size 120):
  comm "kworker/u4:0", pid 8, jiffies 4294944270 (age 12.780s)
  backtrace:
[] alloc_pid+0x66/0x560
[] copy_process+0x1465/0x25e0
[] kernel_clone+0xf3/0x670
[] kernel_thread+0x61/0x80
[] call_usermodehelper_exec_work
[] call_usermodehelper_exec_work+0xc4/0x120
[] process_one_work+0x2c9/0x600
[] worker_thread+0x59/0x5d0
[] kthread+0x178/0x1b0
[] ret_from_fork+0x1f/0x30

unreferenced object 0x888110ef5c00 (size 232):
  comm "kworker/u4:0", pid 8414, jiffies 4294944270 (age 12.780s)
  backtrace:
[] kmem_cache_zalloc
[] __alloc_file+0x1f/0xf0
[] alloc_empty_file+0x69/0x120
[] alloc_file+0x33/0x1b0
[] alloc_file_pseudo+0xb2/0x140
[] create_pipe_files+0x138/0x2e0
[] umd_setup+0x33/0x220
[] call_usermodehelper_exec_async+0xb4/0x1b0
[] ret_from_fork+0x1f/0x30

After the UMD process exits, the pipe_to_umh/pipe_from_umh and
tgid need to be released.

Fixes: d71fa5c9763c ("bpf: Add kernel module with user mode driver that 
populates bpffs.")
Reported-by: syzbot+44908bb56d2bfe56b...@syzkaller.appspotmail.com
Signed-off-by: Zqiang 
Signed-off-by: Daniel Borkmann 
Link: 
https://lore.kernel.org/bpf/20210317030915.2865-1-qiang.zh...@windriver.com
Signed-off-by: Sasha Levin 
---
 include/linux/usermode_driver.h   |  1 +
 kernel/bpf/preload/bpf_preload_kern.c | 19 +++
 kernel/usermode_driver.c  | 21 +++--
 3 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/include/linux/usermode_driver.h b/include/linux/usermode_driver.h
index 073a9e0ec07d..ad970416260d 100644
--- a/include/linux/usermode_driver.h
+++ b/include/linux/usermode_driver.h
@@ -14,5 +14,6 @@ struct umd_info {
 int umd_load_blob(struct umd_info *info, const void *data, size_t len);
 int umd_unload_blob(struct umd_info *info);
 int fork_usermode_driver(struct umd_info *info);
+void umd_cleanup_helper(struct umd_info *info);
 
 #endif /* __LINUX_USERMODE_DRIVER_H__ */
diff --git a/kernel/bpf/preload/bpf_preload_kern.c 
b/kernel/bpf/preload/bpf_preload_kern.c
index 79c5772465f1..53736e52c1df 100644
--- a/kernel/bpf/preload/bpf_preload_kern.c
+++ b/kernel/bpf/preload/bpf_preload_kern.c
@@ -60,9 +60,12 @@ static int finish(void)
 &magic, sizeof(magic), &pos);
if (n != sizeof(magic))
return -EPIPE;
+
tgid = umd_ops.info.tgid;
-   wait_event(tgid->wait_pidfd, thread_group_exited(tgid));
-   umd_ops.info.tgid = NULL;
+   if (tgid) {
+   wait_event(tgid->wait_pidfd, thread_group_exited(tgid));
+   umd_cleanup_helper(&umd_ops.info);
+   }
return 0;
 }
 
@@ -80,10 +83,18 @@ static int __init load_umd(void)
 
 static void __exit fini_umd(void)
 {
+   struct pid *tgid;
+
bpf_preload_ops = NULL;
+
/* kill UMD in case it's still there due to earlier error */
-   kill_pid(umd_ops.info.tgid, SIGKILL, 1);
-   umd_ops.info.tgid = NULL;
+   tgid = umd_ops.info.tgid;
+   if (tgid) {
+   kill_pid(tgid, SIGKILL, 1);
+
+   wait_event(tgid->wait_pidfd, thread_group_exited(tgid));
+   umd_cleanup_helper(&umd_ops.info);
+   }
umd_unload_blob(&umd_ops.info);
 }
 late_initcall(load_umd);
diff --git a/kernel/usermode_driver.c b/kernel/usermode_driver.c
index 0b35212ffc3d..bb7bb3b478ab 100644
--- a/kernel/usermode_driver.c
+++ b/kernel/usermode_driver.c
@@ -139,13 +139,22 @@ static void umd_cleanup(struct subprocess_info *info)
struct umd_info *umd_info = info->data;
 
/* cleanup if umh_setup() was successful but exec failed */
-   if (info->retval) {
-   fput(umd_info->pipe_to_umh);
-   fput(umd_info->pipe_from_umh);
-   put_pid(umd_info->tgid);
-   umd_info->tgid = NULL;
-   }
+   if (info->retval)
+   umd_cleanup_helper(umd_info);
+}
+
+/**
+ * umd_cleanup_helper - release the resources which were allocated in umd_setup
+ * @info: information about usermode driver
+ */
+void umd_cleanup_helper(struct umd_info *info)
+{
+   fput(info->pipe_to_umh);
+   fput(info->pipe_from_umh);
+   put_pid(info->tgid);
+   info->tgid = NULL;
 }
+EXPORT_SYMBOL_GPL(umd_cleanup_helper);
 
 /**
  * fork_usermode_driver - fork a usermode driver
-- 
2.30.1





[PATCH 5.10 166/221] drm/msm: fix shutdown hook in case GPU components failed to bind

2021-03-29 Thread Greg Kroah-Hartman
From: Dmitry Baryshkov 

[ Upstream commit 623f279c77811475ac8fd5635cc4e4451aa71291 ]

If GPU components have failed to bind, shutdown callback would fail with
the following backtrace. Add safeguard check to stop that oops from
happening and allow the board to reboot.

[   66.617046] Unable to handle kernel NULL pointer dereference at virtual 
address 
[   66.626066] Mem abort info:
[   66.628939]   ESR = 0x9606
[   66.632088]   EC = 0x25: DABT (current EL), IL = 32 bits
[   66.637542]   SET = 0, FnV = 0
[   66.640688]   EA = 0, S1PTW = 0
[   66.643924] Data abort info:
[   66.646889]   ISV = 0, ISS = 0x0006
[   66.650832]   CM = 0, WnR = 0
[   66.653890] user pgtable: 4k pages, 48-bit VAs, pgdp=000107f81000
[   66.660505] [] pgd=000100bb2003, p4d=000100bb2003, 
pud=000100897003, pmd=
[   66.671398] Internal error: Oops: 9606 [#1] PREEMPT SMP
[   66.677115] Modules linked in:
[   66.680261] CPU: 6 PID: 352 Comm: reboot Not tainted 
5.11.0-rc2-00309-g79e3faa756b2 #38
[   66.688473] Hardware name: Qualcomm Technologies, Inc. Robotics RB5 (DT)
[   66.695347] pstate: 6045 (nZCv daif +PAN -UAO -TCO BTYPE=--)
[   66.701507] pc : msm_atomic_commit_tail+0x78/0x4e0
[   66.706437] lr : commit_tail+0xa4/0x184
[   66.710381] sp : 8000108f3af0
[   66.713791] x29: 8000108f3af0 x28: 418c44337000
[   66.719242] x27:  x26: 418c40a24490
[   66.724693] x25: d3a842a4f1a0 x24: 0008
[   66.730146] x23: d3a84313f030 x22: 418c444ce000
[   66.735598] x21: 418c408a4980 x20: 
[   66.741049] x19:  x18: 800010710fbc
[   66.746500] x17: 000c x16: 0001
[   66.751954] x15: 00010008 x14: 0068
[   66.757405] x13: 0001 x12: 
[   66.762855] x11: 0001 x10: 09b0
[   66.768306] x9 : d3a843192000 x8 : 418c44337000
[   66.773757] x7 :  x6 : a401b34e
[   66.779210] x5 : 00ff x4 : 
[   66.784660] x3 :  x2 : 418c444ce000
[   66.790111] x1 : d3a841dce530 x0 : 418c444cf000
[   66.795563] Call trace:
[   66.798075]  msm_atomic_commit_tail+0x78/0x4e0
[   66.802633]  commit_tail+0xa4/0x184
[   66.806217]  drm_atomic_helper_commit+0x160/0x390
[   66.811051]  drm_atomic_commit+0x4c/0x60
[   66.815082]  drm_atomic_helper_disable_all+0x1f4/0x210
[   66.820355]  drm_atomic_helper_shutdown+0x80/0x130
[   66.825276]  msm_pdev_shutdown+0x14/0x20
[   66.829303]  platform_shutdown+0x28/0x40
[   66.80]  device_shutdown+0x158/0x330
[   66.837357]  kernel_restart+0x40/0xa0
[   66.841122]  __do_sys_reboot+0x228/0x250
[   66.845148]  __arm64_sys_reboot+0x28/0x34
[   66.849264]  el0_svc_common.constprop.0+0x74/0x190
[   66.854187]  do_el0_svc+0x24/0x90
[   66.857595]  el0_svc+0x14/0x20
[   66.860739]  el0_sync_handler+0x1a4/0x1b0
[   66.864858]  el0_sync+0x174/0x180
[   66.868269] Code: 1ac020a0 2a000273 eb02007f 5401 (f9400285)
[   66.874525] ---[ end trace 20dedb2a3229fec8 ]---

Fixes: 9d5cbf5fe46e ("drm/msm: add shutdown support for display 
platform_driver")
Signed-off-by: Dmitry Baryshkov 
Signed-off-by: Fabio Estevam 
Signed-off-by: Rob Clark 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/msm/msm_drv.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 3d0adfa6736a..45e325c982c2 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -1318,6 +1318,10 @@ static int msm_pdev_remove(struct platform_device *pdev)
 static void msm_pdev_shutdown(struct platform_device *pdev)
 {
struct drm_device *drm = platform_get_drvdata(pdev);
+   struct msm_drm_private *priv = drm ? drm->dev_private : NULL;
+
+   if (!priv || !priv->kms)
+   return;
 
drm_atomic_helper_shutdown(drm);
 }
-- 
2.30.1





<    1   2   3   4   5   6   7   8   9   10   >