OSDN Git Service

sagit-ice-cold/kernel_xiaomi_msm8998.git
4 years agoMerge 9c59fb632e3585fe24af1eb2420bafc5884c010d on remote branch
Linux Build Service Account [Tue, 10 Sep 2019 05:46:52 +0000 (22:46 -0700)]
Merge 9c59fb632e3585fe24af1eb2420bafc5884c010d on remote branch

Change-Id: I976bf04f83cc72048f5584ca0980c1bed83c54de

4 years agoMerge "defconfig: msm8996: enable Inline Crypto Module for eMMC"
Linux Build Service Account [Fri, 6 Sep 2019 23:02:02 +0000 (16:02 -0700)]
Merge "defconfig: msm8996: enable Inline Crypto Module for eMMC"

4 years agoMerge "scsi: ufs: Fix race condition in rls_work and ufshcd_resume"
Linux Build Service Account [Fri, 6 Sep 2019 14:36:59 +0000 (07:36 -0700)]
Merge "scsi: ufs: Fix race condition in rls_work and ufshcd_resume"

4 years agoMerge "msm: qcn: Release interrupt during driver teardown"
Linux Build Service Account [Fri, 6 Sep 2019 14:36:47 +0000 (07:36 -0700)]
Merge "msm: qcn: Release interrupt during driver teardown"

4 years agoMerge "msm: camera: isp: use correct number of entries"
Linux Build Service Account [Fri, 6 Sep 2019 14:36:45 +0000 (07:36 -0700)]
Merge "msm: camera: isp: use correct number of entries"

4 years agoMerge "mmc: core: Return SD card status if sdr104_wa is not present"
Linux Build Service Account [Fri, 6 Sep 2019 14:36:43 +0000 (07:36 -0700)]
Merge "mmc: core: Return SD card status if sdr104_wa is not present"

4 years agoMerge changes into msm-4.4
Gerrit - the friendly Code Review server [Fri, 6 Sep 2019 14:31:49 +0000 (07:31 -0700)]
Merge changes  into msm-4.4

4 years agoMerge "i2c-msm-v2: Add NULL pointer check on i2c messages"
Linux Build Service Account [Fri, 6 Sep 2019 06:59:03 +0000 (23:59 -0700)]
Merge "i2c-msm-v2: Add NULL pointer check on i2c messages"

4 years agoMerge "ANDROID: cpufreq: times: add /proc/uid_concurrent_{active,policy}_time"
Linux Build Service Account [Fri, 6 Sep 2019 06:59:02 +0000 (23:59 -0700)]
Merge "ANDROID: cpufreq: times: add /proc/uid_concurrent_{active,policy}_time"

4 years agodefconfig: msm8996: enable Inline Crypto Module for eMMC
Phanindra Babu Pabba [Wed, 4 Sep 2019 08:43:33 +0000 (14:13 +0530)]
defconfig: msm8996: enable Inline Crypto Module for eMMC

Enable ICE driver for eMMC storage encryption

Change-Id: Ie6e342728441f3e091f4630c12cf04517a87ae23
Signed-off-by: Phanindra Babu Pabba <pabba@codeaurora.org>
4 years agoi2c-msm-v2: Add NULL pointer check on i2c messages
Vipin Deep Kaur [Mon, 5 Aug 2019 06:45:36 +0000 (12:15 +0530)]
i2c-msm-v2: Add NULL pointer check on i2c messages

Add check in i2c driver to ensure the client passes valid messages
for i2c transfer.

Change-Id: I75ceee649d387e4324155c01d0c1e8a40342dff5
Signed-off-by: Vipin Deep Kaur <vkaur@codeaurora.org>
4 years agoMerge "Merge android-4.4.190 (ac7fbca) into msm-4.4"
Linux Build Service Account [Thu, 5 Sep 2019 20:11:06 +0000 (13:11 -0700)]
Merge "Merge android-4.4.190 (ac7fbca) into msm-4.4"

4 years agomsm: qcn: Release interrupt during driver teardown
Amandeep Singh [Tue, 3 Sep 2019 09:46:32 +0000 (15:16 +0530)]
msm: qcn: Release interrupt during driver teardown

Release interrupt synchronously on driver teardown such as during
re-enumeration, manual rmmod and device power down.

Change-Id: I8a2f97266513001ed9a6c08b8ca865c9ffac9065
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agoMerge "ASoC: qdsp6v2: increase RTAC_MAX_ACTIVE_DEVICES to 6"
Linux Build Service Account [Wed, 4 Sep 2019 20:12:52 +0000 (13:12 -0700)]
Merge "ASoC: qdsp6v2: increase RTAC_MAX_ACTIVE_DEVICES to 6"

4 years agoscsi: ufs: Fix race condition in rls_work and ufshcd_resume
Sayali Lokhande [Tue, 12 Jun 2018 10:45:02 +0000 (16:15 +0530)]
scsi: ufs: Fix race condition in rls_work and ufshcd_resume

In some rare scenario, race condition is observed between
rls_work handler and ufshcd_resume operation.
Sequence of events:
1.rls_work is scheduled due to UIC error.
2.ufshcd_rls_handler sets host_self_blocked to 1 and then
invokes pm_runtime_get_sync
3. pm_runtime_get_sync is not yet completed because
runtime_status was RPM_RESUMING.
4.pm_runtime_work schedules at almost same time of rls_work.

Here ufshcd_resume schedules out as host_self_blocked
was set to 1 by rls_work.

Call stacks:

-006|wait_for_completion_io(?)
-007|blk_execute_rq()
-008|scsi_execute()
-009|scsi_execute_req_flags()
-010|ufshcd_set_dev_pwr_mode()
-011|ufshcd_resume()
-012|ufshcd_runtime_resume(hba)
-013|ufshcd_pltfrm_runtime_resume(?)
-014|pm_generic_runtime_resume(?)
-015|__rpm_callback(inline)

-003|schedule()
-004|spin_lock_irq(inline)
-004|rpm_resume()
-005|__pm_runtime_resume()
-006|ufshcd_rls_handler()

Fix this by calling pm_runtime_get_sync before setting
host_self_blocked to 1 during rls_work.

Change-Id: I69f23c169ac8a9eb59062b461302f5521cd57ebc
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
4 years agoMerge "msm: qcn: Add QCN SDIO core driver directory in Kconfig"
Linux Build Service Account [Wed, 4 Sep 2019 06:21:36 +0000 (23:21 -0700)]
Merge "msm: qcn: Add QCN SDIO core driver directory in Kconfig"

4 years agoMerge "msm: qcn: Fix type casting of channel descriptor"
Linux Build Service Account [Wed, 4 Sep 2019 06:21:35 +0000 (23:21 -0700)]
Merge "msm: qcn: Fix type casting of channel descriptor"

4 years agoMerge "msm: qcn: Synchronize card state change API"
Linux Build Service Account [Wed, 4 Sep 2019 06:21:34 +0000 (23:21 -0700)]
Merge "msm: qcn: Synchronize card state change API"

4 years agoMerge "msm: Add ipc router config in Makefile and Kconfig"
Linux Build Service Account [Tue, 3 Sep 2019 21:02:24 +0000 (14:02 -0700)]
Merge "msm: Add ipc router config in Makefile and Kconfig"

4 years agoMerge "mmc: sdhci-msm: Ping with known good phase"
Linux Build Service Account [Tue, 3 Sep 2019 21:02:23 +0000 (14:02 -0700)]
Merge "mmc: sdhci-msm: Ping with known good phase"

4 years agoMerge "soc: qcom: Update ipc router sdio transport plugin"
Linux Build Service Account [Tue, 3 Sep 2019 21:02:22 +0000 (14:02 -0700)]
Merge "soc: qcom: Update ipc router sdio transport plugin"

4 years agoMerge "msm: diag: Add SDIO transport in diag"
Linux Build Service Account [Tue, 3 Sep 2019 21:02:20 +0000 (14:02 -0700)]
Merge "msm: diag: Add SDIO transport in diag"

4 years agoMerge "diag: Add diag over sdio support"
Linux Build Service Account [Tue, 3 Sep 2019 21:02:19 +0000 (14:02 -0700)]
Merge "diag: Add diag over sdio support"

4 years agoMerge "Revert "msm: camera_v2: CPP AXI reset at close""
Linux Build Service Account [Tue, 3 Sep 2019 21:02:18 +0000 (14:02 -0700)]
Merge "Revert "msm: camera_v2: CPP AXI reset at close""

4 years agoMerge "qseecom: check invalid handle for app loaded query request"
Linux Build Service Account [Tue, 3 Sep 2019 21:02:17 +0000 (14:02 -0700)]
Merge "qseecom: check invalid handle for app loaded query request"

4 years agoMerge "Asoc: apr: Fix sound card failure at stability runs"
Linux Build Service Account [Tue, 3 Sep 2019 21:02:15 +0000 (14:02 -0700)]
Merge "Asoc: apr: Fix sound card failure at stability runs"

4 years agoMerge "asoc: codecs: Fix LPASS register access during bootup"
Linux Build Service Account [Tue, 3 Sep 2019 21:02:14 +0000 (14:02 -0700)]
Merge "asoc: codecs: Fix LPASS register access during bootup"

4 years agoMerge "diag: dci: Prevent using uninitialized variables"
Linux Build Service Account [Tue, 3 Sep 2019 21:02:13 +0000 (14:02 -0700)]
Merge "diag: dci: Prevent using uninitialized variables"

4 years agoMerge "ks_bridge: Kill anchored urbs in release callback"
Linux Build Service Account [Tue, 3 Sep 2019 21:02:12 +0000 (14:02 -0700)]
Merge "ks_bridge: Kill anchored urbs in release callback"

4 years agoMerge "msm: ipa3: Fix to memory allocation failure"
Linux Build Service Account [Tue, 3 Sep 2019 21:02:10 +0000 (14:02 -0700)]
Merge "msm: ipa3: Fix to memory allocation failure"

4 years agomsm: qcn: Add QCN SDIO core driver directory in Kconfig
Amandeep Singh [Wed, 6 Feb 2019 11:09:42 +0000 (16:39 +0530)]
msm: qcn: Add QCN SDIO core driver directory in Kconfig

Add QCN SDIO core diver directory in parent directory's Kconfig
to enable its compilation.

Change-Id: I176d17040bf4a63d19635272088e0c4053f8a092
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agomsm: qcn: Fix type casting of channel descriptor
Amandeep Singh [Thu, 29 Aug 2019 11:47:36 +0000 (17:17 +0530)]
msm: qcn: Fix type casting of channel descriptor

Fix type casting of channel descriptor to avoid memory access
violations during the descriptor usage.

Change-Id: I3d73bf327fd796f482e492265d18d3417f21dc9a
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agomsm: qcn: Synchronize card state change API
Amandeep Singh [Tue, 27 Aug 2019 07:42:12 +0000 (13:12 +0530)]
msm: qcn: Synchronize card state change API

Update card state change API to synchronize multiple invocation
of the same API from different drivers.

Change-Id: I03c18a9540bdb64fa462262faa9cabe158e9e199
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agomsm: Add ipc router config in Makefile and Kconfig
Amandeep Singh [Tue, 7 May 2019 06:30:28 +0000 (12:00 +0530)]
msm: Add ipc router config in Makefile and Kconfig

Add ipc router sdio plugin config in Makefile and Kconfig
to enable it for compilation.

Change-Id: If3bc8e812240bd86f2ef3bc63452edcdf69deac6
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agomsm: qcn: Disable logs to console after reporting error
Amandeep Singh [Fri, 23 Aug 2019 10:04:28 +0000 (15:34 +0530)]
msm: qcn: Disable logs to console after reporting error

Disable logs to console after reporting error only once,to stop
excessive prints on console whcich causes watchdog bite due to
console lock up.

Change-Id: I26d9f3f258e0428c059440369c88691b2d523bba
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agoqti_sdio_client: Free rx DMA buffers after use
Amandeep Singh [Tue, 27 Aug 2019 05:30:56 +0000 (11:00 +0530)]
qti_sdio_client: Free rx DMA buffers after use

Free rx DMA buffere after the data is read from the buffer.

Change-Id: I2b8f97beb50b4752674fc8b4034feb84d2a36302
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agomsm: qcn: Add driver state information param
Amandeep Singh [Mon, 12 Aug 2019 08:18:15 +0000 (13:48 +0530)]
msm: qcn: Add driver state information param

Add driver state information param to view from the user space.

Change-Id: I2d4cd86ae5d67ac948a93d28e24ea96394343513
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agomsm: qcn: Disable retuning in function 1 driver
Amandeep Singh [Wed, 7 Aug 2019 10:26:33 +0000 (15:56 +0530)]
msm: qcn: Disable retuning in function 1 driver

Disable retuning in function 1 driver by default. Created a sysfs
entry to enable it if needed.

Change-Id: I29b5ea4a8e0f1614b10226edb21c6cbeb7a327cd
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agomsm: qcn: Detect and switch host to RDDM
Amandeep Singh [Tue, 6 Aug 2019 09:54:57 +0000 (15:24 +0530)]
msm: qcn: Detect and switch host to RDDM

Switch driver operating mode to RDDM when target device switches to RDDM.

Change-Id: I501672f4965e57e59f5a272e35534e66c63b67c1
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agommc: sdhci-msm: Ping with known good phase
Amandeep Singh [Wed, 24 Jul 2019 06:16:12 +0000 (11:46 +0530)]
mmc: sdhci-msm: Ping with known good phase

Ping with known good phase if last phase of tuning fails.

Change-Id: I3d8d8ce3d8a4dc00146668b815b69619d3a4cea8
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agoqti_sdio_client: Drop read write request during removal
Amandeep Singh [Wed, 24 Jul 2019 06:06:25 +0000 (11:36 +0530)]
qti_sdio_client: Drop read write request during removal

Update read write API to drop further messages during transport or
interface removal.

Change-Id: Ied43de8aa7cef1c36c9c520976357ba1e63017db
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agomsm: qcn: Add dynamic add and remove of SDIO card
Amandeep Singh [Wed, 24 Jul 2019 06:00:29 +0000 (11:30 +0530)]
msm: qcn: Add dynamic add and remove of SDIO card

Add API to dynamically add and remove the SDIO card on demand.

Change-Id: I946115880da75804a6636616d9cf7cfb4a682b92
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agomsm: qcn: Enable QCN SDIO core driver for compilation
Amandeep Singh [Fri, 7 Jun 2019 10:37:58 +0000 (16:07 +0530)]
msm: qcn: Enable QCN SDIO core driver for compilation

Add QCN SDIO core diver config into Makefile and
Kconfig to enable its compilation.

Change-Id: I19d184c628658175179d9b5c52a3a8bd07dd7999
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agomsm: qcn: Enable QCN SDIO client driver for compilation
Amandeep Singh [Fri, 7 Jun 2019 10:35:07 +0000 (16:05 +0530)]
msm: qcn: Enable QCN SDIO client driver for compilation

Add QCN SDIO client driver config into Makefile and
Kconfig to enable its compilation.

Change-Id: I40ffa1844b2030aca53d0e36f1bee2900a3ea8d4
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agosoc: qcom: Update ipc router sdio transport plugin
Amandeep Singh [Wed, 3 Jul 2019 06:17:52 +0000 (11:47 +0530)]
soc: qcom: Update ipc router sdio transport plugin

Update ipc router sdio plugin initial snapshot to support peripheral
device over sdio transport.

Change-Id: I097ad755b3bd2270cda74738bed409e88dee343c
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agosoc: qcom: Add ipc router plugin for sdio transport
Amandeep Singh [Tue, 4 Jun 2019 06:05:03 +0000 (11:35 +0530)]
soc: qcom: Add ipc router plugin for sdio transport

This snapshot is taken as of msm-4.4 commit dc86ce0faae2 ("soc: qcom:
ipc_rtr_xprt: Add support to set version in transport").

Change-Id: I729d3c910372d2c3c0bbaaae74a42150c9929732
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agomsm: diag: Add SDIO transport in diag
Amandeep Singh [Mon, 6 May 2019 10:10:51 +0000 (15:40 +0530)]
msm: diag: Add SDIO transport in diag

Add support for SDIO transport in diag core framework.

Change-Id: Ic3ccfec3acd60b36a96aebb49a5681219a25e643
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agodiag: Update diag over sdio snapshot
Amandeep Singh [Wed, 3 Jul 2019 07:17:41 +0000 (12:47 +0530)]
diag: Update diag over sdio snapshot

Update code to support diag for peripheral devices over sdio bus.

Change-Id: I14678f301f94b239b61c4c94d3c0ff65204e739e
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agodiag: Add diag over sdio support
Amandeep Singh [Fri, 31 May 2019 08:57:11 +0000 (14:27 +0530)]
diag: Add diag over sdio support

This commit is taken as of msm-4.4 commit f185067e3685 ("diag: Fix
HSIC read complete work function").

Change-Id: I629fe0d9ed697fb20fd9263ecea6009157181e63
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agomsm: qcn: Update completion sequence during tx
Amandeep Singh [Tue, 25 Jun 2019 06:34:34 +0000 (12:04 +0530)]
msm: qcn: Update completion sequence during tx

Update the completion variable sequence to avoid multiple complete
call on a stale staack completion variable.

Change-Id: I582777431918c359cd10e4e072f33589dc600e62
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agomsm: qcn: Add QCN bridge client driver
Amandeep Singh [Fri, 7 Jun 2019 06:35:28 +0000 (12:05 +0530)]
msm: qcn: Add QCN bridge client driver

Add QCN bridge client driver to provide interface to QCN SDIO
core function-1 driver. This driver currently provides interfacing
for diag, IPC router and sahara application.

Change-Id: Ie992aec91347bb68e46a01ee6f67a1d07ce40ecc
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agomsm: qcn: Synchronize clients operating at different modes
Amandeep Singh [Mon, 24 Jun 2019 09:21:08 +0000 (14:51 +0530)]
msm: qcn: Synchronize clients operating at different modes

Add synchronization support between clients that operate on different
modes, i.e. synchronous or asynchronous. The synchronous client will
momentarily switch to asynchronous if any asynchronous transmission is
scheduled.

Change-Id: I41aec9bff950d2816a9ce55017e118e8504be77a
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agomsm: qcn: Reserve 8 bufferes in RW queue for RX
Amandeep Singh [Mon, 24 Jun 2019 08:54:19 +0000 (14:24 +0530)]
msm: qcn: Reserve 8 bufferes in RW queue for RX

The current QCN core driver support four concurrent clients,
and there can be only two CRQ's that can be raised per client
from device.
Reserve 8 bufferes for data reception from device to host.

Change-Id: Iac72b5dd51988ffd1139bf55ecb9799bded77710
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agomsm: qcn: Increase RW queue size
Amandeep Singh [Mon, 24 Jun 2019 08:44:07 +0000 (14:14 +0530)]
msm: qcn: Increase RW queue size

Increase RW queue size to compensate higer data transfer from host
to device, when device is operating at lower frequencies.

Change-Id: I443aead06c757cde40ee99ea2c29a5f323249b8b
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agomsm: qcn: Update read/write APIs
Amandeep Singh [Mon, 24 Jun 2019 08:24:00 +0000 (13:54 +0530)]
msm: qcn: Update read/write APIs

Update read/write API in QCN sdio core driver to issue CMD53
instead of CMD52 for data equal or greater than 4 bytes.

Change-Id: I5641f32fa8896d3fafb087b440ff69ad936a83ee
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agomsm: Add QCN SDIO core driver
Amandeep Singh [Thu, 6 Jun 2019 05:53:42 +0000 (11:23 +0530)]
msm: Add QCN SDIO core driver

Add QCN SDIO core driver as function-1 driver to provide streamlined
communication for peripheral device connected over sdio.

Change-Id: Ia8aec77807b59d3e1476b0a12ee7016809335b39
Signed-off-by: Amandeep Singh <amansing@codeaurora.org>
4 years agoMerge "Merge android-4.4.189 (74c8219) into msm-4.4"
Linux Build Service Account [Tue, 3 Sep 2019 04:56:44 +0000 (21:56 -0700)]
Merge "Merge android-4.4.189 (74c8219) into msm-4.4"

4 years agoMerge "Merge android-4.4.188 (886d085) into msm-4.4"
Linux Build Service Account [Tue, 3 Sep 2019 04:56:43 +0000 (21:56 -0700)]
Merge "Merge android-4.4.188 (886d085) into msm-4.4"

4 years agoqseecom: check invalid handle for app loaded query request
Zhen Kong [Tue, 27 Aug 2019 21:02:35 +0000 (14:02 -0700)]
qseecom: check invalid handle for app loaded query request

Check if the handle data type received from userspace is valid
for app loaded query request to avoid the offset boundary check
for qseecom_send_modfd_resp is bypassed.

Change-Id: I5f3611a8f830d6904213781c5ba70cfc0ba3e2e0
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
4 years agoRevert "msm: camera_v2: CPP AXI reset at close"
Venu Raidu [Fri, 30 Aug 2019 05:31:21 +0000 (22:31 -0700)]
Revert "msm: camera_v2: CPP AXI reset at close"

This reverts commit e4250ce4ec84a9d511f390a8dcdab9979378efb4.

AB/IB voting is not required to reset CPP AXI/HW during
camera close.

Change-Id: I230276b9d2c821dbc651fc5dd2a458e4e987baf9
Signed-off-by: Venu Raidu <vraidu@codeaurora.org>
4 years agoAsoc: apr: Fix sound card failure at stability runs
Soumya Managoli [Fri, 2 Aug 2019 05:31:33 +0000 (11:01 +0530)]
Asoc: apr: Fix sound card failure at stability runs

In stability reboot tests, deferred audio drivers
are not invoked after lpass loading sometimes and
results in sound card failure. Change APR to platform
device and after APR status changes to loaded state,
add dummy module child device under APR which invokes
deferred audio drivers and sound card registers successfully.

In analog codec driver defers until Q6 core ready.

Change-Id: I1c82d9da55e771299df356a2771de2b2e62348cf
Signed-off-by: Soumya Managoli <smanag@codeaurora.org>
4 years agoMerge android-4.4.190 (ac7fbca) into msm-4.4
Srinivasarao P [Mon, 26 Aug 2019 05:46:26 +0000 (11:16 +0530)]
Merge android-4.4.190 (ac7fbca) into msm-4.4

* refs/heads/tmp-ac7fbca
  Linux 4.4.190
  bonding: Add vlan tx offload to hw_enc_features
  sctp: fix the transport error_count check
  net/mlx5e: Only support tx/rx pause setting for port owner
  xen/netback: Reset nr_frags before freeing skb
  net/packet: fix race in tpacket_snd()
  x86/boot: Disable the address-of-packed-member compiler warning
  iommu/amd: Move iommu_init_pci() to .init section
  x86/vdso: Remove direct HPET access through the vDSO
  IB/mlx5: Make coding style more consistent
  RDMA: Directly cast the sockaddr union to sockaddr
  scsi: fcoe: Embed fc_rport_priv in fcoe_rport structure
  asm-generic: default BUG_ON(x) to if(x)BUG()
  Input: psmouse - fix build error of multiple definition
  arm64: compat: Allow single-byte watchpoints on all addresses
  include/linux/module.h: copy __init/__exit attrs to init/cleanup_module
  Backport minimal compiler_attributes.h to support GCC 9
  USB: serial: option: Add Motorola modem UARTs
  USB: serial: option: add the BroadMobi BM818 card
  USB: serial: option: Add support for ZTE MF871A
  USB: serial: option: add D-Link DWM-222 device ID
  usb: cdc-acm: make sure a refcount is taken early enough
  USB: core: Fix races in character device registration and deregistraion
  staging: comedi: dt3000: Fix rounding up of timer divisor
  staging: comedi: dt3000: Fix signed integer overflow 'divider * base'
  asm-generic: fix -Wtype-limits compiler warnings
  ocfs2: remove set but not used variable 'last_hash'
  IB/core: Add mitigation for Spectre V1
  kbuild: modpost: handle KBUILD_EXTRA_SYMBOLS only for external modules
  ata: libahci: do not complain in case of deferred probe
  scsi: hpsa: correct scsi command status issue after reset
  libata: zpodd: Fix small read overflow in zpodd_get_mech_type()
  perf header: Fix use of unitialized value warning
  perf header: Fix divide by zero error if f_header.attr_size==0
  irqchip/irq-imx-gpcv2: Forward irq type to parent
  xen/pciback: remove set but not used variable 'old_state'
  net: usb: pegasus: fix improper read if get_registers() fail
  Input: iforce - add sanity checks
  Input: kbtab - sanity check for endpoint type
  HID: hiddev: do cleanup in failure of opening a device
  HID: hiddev: avoid opening a disconnected device
  HID: holtek: test for sanity of intfdata
  ALSA: hda - Fix a memory leak bug
  mm/memcontrol.c: fix use after free in mem_cgroup_iter()
  USB: gadget: f_midi: fixing a possible double-free in f_midi
  usb: gadget: f_midi: fail if set_alt fails to allocate requests
  sh: kernel: hw_breakpoint: Fix missing break in switch statement
  scsi: mpt3sas: Use 63-bit DMA addressing on SAS35 HBA
  mwifiex: fix 802.11n/WPA detection
  smb3: send CAP_DFS capability during session setup
  SMB3: Fix deadlock in validate negotiate hits reconnect
  mac80211: don't WARN on short WMM parameters from AP
  ALSA: firewire: fix a memory leak bug
  hwmon: (nct7802) Fix wrong detection of in4 presence
  can: peak_usb: pcan_usb_fd: Fix info-leaks to USB devices
  can: peak_usb: pcan_usb_pro: Fix info-leaks to USB devices
  perf/core: Fix creating kernel counters for PMUs that override event->cpu
  tty/ldsem, locking/rwsem: Add missing ACQUIRE to read_failed sleep loop
  scsi: ibmvfc: fix WARN_ON during event pool release
  scsi: megaraid_sas: fix panic on loading firmware crashdump
  ARM: davinci: fix sleep.S build error on ARMv4
  perf probe: Avoid calling freeing routine multiple times for same pointer
  ALSA: compress: Be more restrictive about when a drain is allowed
  ALSA: compress: Prevent bypasses of set_params
  ALSA: compress: Fix regression on compressed capture streams
  s390/qdio: add sanity checks to the fast-requeue path
  cpufreq/pasemi: fix use-after-free in pas_cpufreq_cpu_init()
  hwmon: (nct6775) Fix register address and added missed tolerance for nct6106
  mac80211: don't warn about CW params when not using them
  iscsi_ibft: make ISCSI_IBFT dependson ACPI instead of ISCSI_IBFT_FIND
  netfilter: nfnetlink: avoid deadlock due to synchronous request_module
  can: peak_usb: fix potential double kfree_skb()
  usb: yurex: Fix use-after-free in yurex_delete
  perf db-export: Fix thread__exec_comm()
  mm/vmalloc: Sync unmappings in __purge_vmap_area_lazy()
  x86/mm: Sync also unmappings in vmalloc_sync_all()
  x86/mm: Check for pfn instead of page in vmalloc_sync_one()
  sound: fix a memory leak bug
  usb: iowarrior: fix deadlock on disconnect
  ANDROID: fix binder change in merge of 4.4.183

Conflicts:
sound/core/compress_offload.c

Change-Id: I30e498c36dc295fbfa0e1d455e31f192fd99479e
Signed-off-by: Srinivasarao P <spathi@codeaurora.org>
4 years agoks_bridge: Kill anchored urbs in release callback
Vijayavardhan Vennapusa [Fri, 23 Aug 2019 06:02:22 +0000 (11:32 +0530)]
ks_bridge: Kill anchored urbs in release callback

Currently ks_bridge driver queues requests to USB hardware in
open callback, but killing those urbs in disconnect() callback.
Due to this, USB host controller tries to ping on these endpoints
of ks_bridge driver, even though release callback is called. This
results in not using bandwidth for usecase data transfers in highspeed
mode. Fix this by killing those anchored urbs in release callback.

Change-Id: Iebe60125bfa3311337b0c9e5aaca44197a67c2be
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
4 years agoMerge 4.4.190 into android-4.4
Greg Kroah-Hartman [Sun, 25 Aug 2019 12:51:28 +0000 (14:51 +0200)]
Merge 4.4.190 into android-4.4

Changes in 4.4.190
usb: iowarrior: fix deadlock on disconnect
sound: fix a memory leak bug
x86/mm: Check for pfn instead of page in vmalloc_sync_one()
x86/mm: Sync also unmappings in vmalloc_sync_all()
mm/vmalloc: Sync unmappings in __purge_vmap_area_lazy()
perf db-export: Fix thread__exec_comm()
usb: yurex: Fix use-after-free in yurex_delete
can: peak_usb: fix potential double kfree_skb()
netfilter: nfnetlink: avoid deadlock due to synchronous request_module
iscsi_ibft: make ISCSI_IBFT dependson ACPI instead of ISCSI_IBFT_FIND
mac80211: don't warn about CW params when not using them
hwmon: (nct6775) Fix register address and added missed tolerance for nct6106
cpufreq/pasemi: fix use-after-free in pas_cpufreq_cpu_init()
s390/qdio: add sanity checks to the fast-requeue path
ALSA: compress: Fix regression on compressed capture streams
ALSA: compress: Prevent bypasses of set_params
ALSA: compress: Be more restrictive about when a drain is allowed
perf probe: Avoid calling freeing routine multiple times for same pointer
ARM: davinci: fix sleep.S build error on ARMv4
scsi: megaraid_sas: fix panic on loading firmware crashdump
scsi: ibmvfc: fix WARN_ON during event pool release
tty/ldsem, locking/rwsem: Add missing ACQUIRE to read_failed sleep loop
perf/core: Fix creating kernel counters for PMUs that override event->cpu
can: peak_usb: pcan_usb_pro: Fix info-leaks to USB devices
can: peak_usb: pcan_usb_fd: Fix info-leaks to USB devices
hwmon: (nct7802) Fix wrong detection of in4 presence
ALSA: firewire: fix a memory leak bug
mac80211: don't WARN on short WMM parameters from AP
SMB3: Fix deadlock in validate negotiate hits reconnect
smb3: send CAP_DFS capability during session setup
mwifiex: fix 802.11n/WPA detection
scsi: mpt3sas: Use 63-bit DMA addressing on SAS35 HBA
sh: kernel: hw_breakpoint: Fix missing break in switch statement
usb: gadget: f_midi: fail if set_alt fails to allocate requests
USB: gadget: f_midi: fixing a possible double-free in f_midi
mm/memcontrol.c: fix use after free in mem_cgroup_iter()
ALSA: hda - Fix a memory leak bug
HID: holtek: test for sanity of intfdata
HID: hiddev: avoid opening a disconnected device
HID: hiddev: do cleanup in failure of opening a device
Input: kbtab - sanity check for endpoint type
Input: iforce - add sanity checks
net: usb: pegasus: fix improper read if get_registers() fail
xen/pciback: remove set but not used variable 'old_state'
irqchip/irq-imx-gpcv2: Forward irq type to parent
perf header: Fix divide by zero error if f_header.attr_size==0
perf header: Fix use of unitialized value warning
libata: zpodd: Fix small read overflow in zpodd_get_mech_type()
scsi: hpsa: correct scsi command status issue after reset
ata: libahci: do not complain in case of deferred probe
kbuild: modpost: handle KBUILD_EXTRA_SYMBOLS only for external modules
IB/core: Add mitigation for Spectre V1
ocfs2: remove set but not used variable 'last_hash'
asm-generic: fix -Wtype-limits compiler warnings
staging: comedi: dt3000: Fix signed integer overflow 'divider * base'
staging: comedi: dt3000: Fix rounding up of timer divisor
USB: core: Fix races in character device registration and deregistraion
usb: cdc-acm: make sure a refcount is taken early enough
USB: serial: option: add D-Link DWM-222 device ID
USB: serial: option: Add support for ZTE MF871A
USB: serial: option: add the BroadMobi BM818 card
USB: serial: option: Add Motorola modem UARTs
Backport minimal compiler_attributes.h to support GCC 9
include/linux/module.h: copy __init/__exit attrs to init/cleanup_module
arm64: compat: Allow single-byte watchpoints on all addresses
Input: psmouse - fix build error of multiple definition
asm-generic: default BUG_ON(x) to if(x)BUG()
scsi: fcoe: Embed fc_rport_priv in fcoe_rport structure
RDMA: Directly cast the sockaddr union to sockaddr
IB/mlx5: Make coding style more consistent
x86/vdso: Remove direct HPET access through the vDSO
iommu/amd: Move iommu_init_pci() to .init section
x86/boot: Disable the address-of-packed-member compiler warning
net/packet: fix race in tpacket_snd()
xen/netback: Reset nr_frags before freeing skb
net/mlx5e: Only support tx/rx pause setting for port owner
sctp: fix the transport error_count check
bonding: Add vlan tx offload to hw_enc_features
Linux 4.4.190

Change-Id: I2af7fee66e6ce77c41266cec8cfa7b7c4a78a05c
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
4 years agoLinux 4.4.190
Greg Kroah-Hartman [Sun, 25 Aug 2019 08:53:06 +0000 (10:53 +0200)]
Linux 4.4.190

4 years agobonding: Add vlan tx offload to hw_enc_features
YueHaibing [Wed, 7 Aug 2019 02:19:59 +0000 (10:19 +0800)]
bonding: Add vlan tx offload to hw_enc_features

[ Upstream commit d595b03de2cb0bdf9bcdf35ff27840cc3a37158f ]

As commit 30d8177e8ac7 ("bonding: Always enable vlan tx offload")
said, we should always enable bonding's vlan tx offload, pass the
vlan packets to the slave devices with vlan tci, let them to handle
vlan implementation.

Now if encapsulation protocols like VXLAN is used, skb->encapsulation
may be set, then the packet is passed to vlan device which based on
bonding device. However in netif_skb_features(), the check of
hw_enc_features:

 if (skb->encapsulation)
                 features &= dev->hw_enc_features;

clears NETIF_F_HW_VLAN_CTAG_TX/NETIF_F_HW_VLAN_STAG_TX. This results
in same issue in commit 30d8177e8ac7 like this:

vlan_dev_hard_start_xmit
  -->dev_queue_xmit
    -->validate_xmit_skb
      -->netif_skb_features //NETIF_F_HW_VLAN_CTAG_TX is cleared
      -->validate_xmit_vlan
        -->__vlan_hwaccel_push_inside //skb->tci is cleared
...
 --> bond_start_xmit
   --> bond_xmit_hash //BOND_XMIT_POLICY_ENCAP34
     --> __skb_flow_dissect // nhoff point to IP header
        -->  case htons(ETH_P_8021Q)
             // skb_vlan_tag_present is false, so
             vlan = __skb_header_pointer(skb, nhoff, sizeof(_vlan),
             //vlan point to ip header wrongly

Fixes: b2a103e6d0af ("bonding: convert to ndo_fix_features")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Acked-by: Jay Vosburgh <jay.vosburgh@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agosctp: fix the transport error_count check
Xin Long [Mon, 12 Aug 2019 12:49:12 +0000 (20:49 +0800)]
sctp: fix the transport error_count check

[ Upstream commit a1794de8b92ea6bc2037f445b296814ac826693e ]

As the annotation says in sctp_do_8_2_transport_strike():

  "If the transport error count is greater than the pf_retrans
   threshold, and less than pathmaxrtx ..."

It should be transport->error_count checked with pathmaxrxt,
instead of asoc->pf_retrans.

Fixes: 5aa93bcf66f4 ("sctp: Implement quick failover draft from tsvwg")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agonet/mlx5e: Only support tx/rx pause setting for port owner
Huy Nguyen [Thu, 1 Aug 2019 16:10:19 +0000 (11:10 -0500)]
net/mlx5e: Only support tx/rx pause setting for port owner

[ Upstream commit 466df6eb4a9e813b3cfc674363316450c57a89c5 ]

Only support changing tx/rx pause frame setting if the net device
is the vport group manager.

Fixes: 3c2d18ef22df ("net/mlx5e: Support ethtool get/set_pauseparam")
Signed-off-by: Huy Nguyen <huyn@mellanox.com>
Reviewed-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoxen/netback: Reset nr_frags before freeing skb
Ross Lagerwall [Mon, 5 Aug 2019 15:34:34 +0000 (16:34 +0100)]
xen/netback: Reset nr_frags before freeing skb

[ Upstream commit 3a0233ddec554b886298de2428edb5c50a20e694 ]

At this point nr_frags has been incremented but the frag does not yet
have a page assigned so freeing the skb results in a crash. Reset
nr_frags before freeing the skb to prevent this.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agonet/packet: fix race in tpacket_snd()
Eric Dumazet [Wed, 14 Aug 2019 09:11:57 +0000 (02:11 -0700)]
net/packet: fix race in tpacket_snd()

[ Upstream commit 32d3182cd2cd29b2e7e04df7b0db350fbe11289f ]

packet_sendmsg() checks tx_ring.pg_vec to decide
if it must call tpacket_snd().

Problem is that the check is lockless, meaning another thread
can issue a concurrent setsockopt(PACKET_TX_RING ) to flip
tx_ring.pg_vec back to NULL.

Given that tpacket_snd() grabs pg_vec_lock mutex, we can
perform the check again to solve the race.

syzbot reported :

kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] PREEMPT SMP KASAN
CPU: 1 PID: 11429 Comm: syz-executor394 Not tainted 5.3.0-rc4+ #101
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:packet_lookup_frame+0x8d/0x270 net/packet/af_packet.c:474
Code: c1 ee 03 f7 73 0c 80 3c 0e 00 0f 85 cb 01 00 00 48 8b 0b 89 c0 4c 8d 24 c1 48 b8 00 00 00 00 00 fc ff df 4c 89 e1 48 c1 e9 03 <80> 3c 01 00 0f 85 94 01 00 00 48 8d 7b 10 4d 8b 3c 24 48 b8 00 00
RSP: 0018:ffff88809f82f7b8 EFLAGS: 00010246
RAX: dffffc0000000000 RBX: ffff8880a45c7030 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 1ffff110148b8e06 RDI: ffff8880a45c703c
RBP: ffff88809f82f7e8 R08: ffff888087aea200 R09: fffffbfff134ae50
R10: fffffbfff134ae4f R11: ffffffff89a5727f R12: 0000000000000000
R13: 0000000000000001 R14: ffff8880a45c6ac0 R15: 0000000000000000
FS:  00007fa04716f700(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fa04716edb8 CR3: 0000000091eb4000 CR4: 00000000001406e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 packet_current_frame net/packet/af_packet.c:487 [inline]
 tpacket_snd net/packet/af_packet.c:2667 [inline]
 packet_sendmsg+0x590/0x6250 net/packet/af_packet.c:2975
 sock_sendmsg_nosec net/socket.c:637 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:657
 ___sys_sendmsg+0x3e2/0x920 net/socket.c:2311
 __sys_sendmmsg+0x1bf/0x4d0 net/socket.c:2413
 __do_sys_sendmmsg net/socket.c:2442 [inline]
 __se_sys_sendmmsg net/socket.c:2439 [inline]
 __x64_sys_sendmmsg+0x9d/0x100 net/socket.c:2439
 do_syscall_64+0xfd/0x6a0 arch/x86/entry/common.c:296
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Fixes: 69e3c75f4d54 ("net: TX_RING and packet mmap")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agox86/boot: Disable the address-of-packed-member compiler warning
Matthias Kaehlcke [Tue, 25 Jul 2017 21:50:53 +0000 (14:50 -0700)]
x86/boot: Disable the address-of-packed-member compiler warning

commit 20c6c189045539d29f4854d92b7ea9c329e1edfc upstream.

The clang warning 'address-of-packed-member' is disabled for the general
kernel code, also disable it for the x86 boot code.

This suppresses a bunch of warnings like this when building with clang:

./arch/x86/include/asm/processor.h:535:30: warning: taking address of
  packed member 'sp0' of class or structure 'x86_hw_tss' may result in an
  unaligned pointer value [-Waddress-of-packed-member]
    return this_cpu_read_stable(cpu_tss.x86_tss.sp0);
                                ^~~~~~~~~~~~~~~~~~~
./arch/x86/include/asm/percpu.h:391:59: note: expanded from macro
  'this_cpu_read_stable'
    #define this_cpu_read_stable(var)       percpu_stable_op("mov", var)
                                                                    ^~~
./arch/x86/include/asm/percpu.h:228:16: note: expanded from macro
  'percpu_stable_op'
    : "p" (&(var)));
             ^~~

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Cc: Doug Anderson <dianders@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20170725215053.135586-1-mka@chromium.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoiommu/amd: Move iommu_init_pci() to .init section
Joerg Roedel [Fri, 5 Oct 2018 10:32:46 +0000 (12:32 +0200)]
iommu/amd: Move iommu_init_pci() to .init section

commit 24d2c521749d8547765b555b7a85cca179bb2275 upstream.

The function is only called from another __init function, so
it should be moved to .init too.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agox86/vdso: Remove direct HPET access through the vDSO
Andy Lutomirski [Fri, 8 Apr 2016 00:16:59 +0000 (17:16 -0700)]
x86/vdso: Remove direct HPET access through the vDSO

commit 1ed95e52d902035e39a715ff3a314a893a96e5b7 upstream.

Allowing user code to map the HPET is problematic.  HPET
implementations are notoriously buggy, and there are probably many
machines on which even MMIO reads from bogus HPET addresses are
problematic.

We have a report that the Dell Precision M2800 with:

  ACPI: HPET 0x00000000C8FE6238 000038 (v01 DELL   CBX3  01072009 AMI. 00000005)

is either so slow when accessing the HPET or actually hangs in some
regard, causing soft lockups to be reported if users do unexpected
things to the HPET.

The vclock HPET code has also always been a questionable speedup.
Accessing an HPET is exceedingly slow (on the order of several
microseconds), so the added overhead in requiring a syscall to read
the HPET is a small fraction of the total code of accessing it.

To avoid future problems, let's just delete the code entirely.

In the long run, this could actually be a speedup.  Waiman Long as a
patch to optimize the case where multiple CPUs contend for the HPET,
but that won't help unless all the accesses are mediated by the
kernel.

Reported-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Borislav Petkov <bp@alien8.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Waiman Long <Waiman.Long@hpe.com>
Cc: Waiman Long <waiman.long@hpe.com>
Link: http://lkml.kernel.org/r/d2f90bba98db9905041cff294646d290d378f67a.1460074438.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoIB/mlx5: Make coding style more consistent
Doug Ledford [Thu, 3 Mar 2016 16:23:37 +0000 (11:23 -0500)]
IB/mlx5: Make coding style more consistent

commit 0025b0bdeae7c13b8ab1dce64b0108ed9c071e2e upstream.

These three related functions can't agree whether to put the
umrwr on the stack dirty and then memset it, or to initialize
it on the stack.  Make them all agree.

Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoRDMA: Directly cast the sockaddr union to sockaddr
Jason Gunthorpe [Mon, 13 May 2019 00:57:57 +0000 (21:57 -0300)]
RDMA: Directly cast the sockaddr union to sockaddr

commit 641114d2af312d39ca9bbc2369d18a5823da51c6 upstream.

gcc 9 now does allocation size tracking and thinks that passing the member
of a union and then accessing beyond that member's bounds is an overflow.

Instead of using the union member, use the entire union with a cast to
get to the sockaddr. gcc will now know that the memory extends the full
size of the union.

Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoscsi: fcoe: Embed fc_rport_priv in fcoe_rport structure
Hannes Reinecke [Wed, 24 Jul 2019 09:00:55 +0000 (11:00 +0200)]
scsi: fcoe: Embed fc_rport_priv in fcoe_rport structure

commit 023358b136d490ca91735ac6490db3741af5a8bd upstream.

Gcc-9 complains for a memset across pointer boundaries, which happens as
the code tries to allocate a flexible array on the stack.  Turns out we
cannot do this without relying on gcc-isms, so with this patch we'll embed
the fc_rport_priv structure into fcoe_rport, can use the normal
'container_of' outcast, and will only have to do a memset over one
structure.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoasm-generic: default BUG_ON(x) to if(x)BUG()
Arnd Bergmann [Fri, 20 Nov 2015 23:27:26 +0000 (00:27 +0100)]
asm-generic: default BUG_ON(x) to if(x)BUG()

commit 3c047057d1206ec0f3b88c7809cacba478067a0c upstream.

When CONFIG_BUG is disabled, BUG_ON() will only evaluate the condition,
but will not actually stop the current thread. GCC warns about a couple
of BUG_ON() users where this actually leads to further undefined
behavior:

include/linux/ceph/osdmap.h: In function 'ceph_can_shift_osds':
include/linux/ceph/osdmap.h:54:1: warning: control reaches end of non-void function
fs/ext4/inode.c: In function 'ext4_map_blocks':
fs/ext4/inode.c:548:5: warning: 'retval' may be used uninitialized in this function
drivers/mfd/db8500-prcmu.c: In function 'prcmu_config_clkout':
drivers/mfd/db8500-prcmu.c:762:10: warning: 'div_mask' may be used uninitialized in this function
drivers/mfd/db8500-prcmu.c:769:13: warning: 'mask' may be used uninitialized in this function
drivers/mfd/db8500-prcmu.c:757:7: warning: 'bits' may be used uninitialized in this function
drivers/tty/serial/8250/8250_core.c: In function 'univ8250_release_irq':
drivers/tty/serial/8250/8250_core.c:252:18: warning: 'i' may be used uninitialized in this function
drivers/tty/serial/8250/8250_core.c:235:19: note: 'i' was declared here

There is an obvious conflict of interest here: on the one hand, someone
who disables CONFIG_BUG() will want the kernel to be as small as possible
and doesn't care about printing error messages to a console that nobody
looks at. On the other hand, running into a BUG_ON() condition means that
something has gone wrong, and we probably want to also stop doing things
that might cause data corruption.

This patch picks the second choice, and changes the NOP to BUG(), which
normally stops the execution of the current thread in some form (endless
loop or a trap). This follows the logic we applied in a4b5d580e078 ("bug:
Make BUG() always stop the machine").

For ARM multi_v7_defconfig, the size slightly increases:

section CONFIG_BUG=y CONFIG_BUG=n CONFIG_BUG=n+patch

  .text            8320248   |     8180944   |     8207688
  .rodata          3633720   |     3567144   |     3570648
  __bug_table        32508   |         ---   |         ---
  __modver             692   |        1584   |        2176
  .init.text        558132   |      548300   |      550088
  .exit.text         12380   |       12256   |       12380
  .data            1016672   |     1016064   |     1016128
  Total           14622556   |    14374510   |    14407326

So instead of saving 1.70% of the total image size, we only save 1.48%
by turning off CONFIG_BUG, but in return we can ensure that we don't run
into cases of uninitialized variable or return code uses when something
bad happens. Aside from that, we significantly reduce the number of
warnings in randconfig builds, which makes it easier to fix the warnings
about other problems.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoInput: psmouse - fix build error of multiple definition
YueHaibing [Tue, 16 Jul 2019 18:17:20 +0000 (20:17 +0200)]
Input: psmouse - fix build error of multiple definition

commit 49e6979e7e92cf496105b5636f1df0ac17c159c0 upstream.

trackpoint_detect() should be static inline while
CONFIG_MOUSE_PS2_TRACKPOINT is not set, otherwise, we build fails:

drivers/input/mouse/alps.o: In function `trackpoint_detect':
alps.c:(.text+0x8e00): multiple definition of `trackpoint_detect'
drivers/input/mouse/psmouse-base.o:psmouse-base.c:(.text+0x1b50): first defined here

Reported-by: Hulk Robot <hulkci@huawei.com>
Fixes: 55e3d9224b60 ("Input: psmouse - allow disabing certain protocol extensions")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoarm64: compat: Allow single-byte watchpoints on all addresses
Will Deacon [Mon, 29 Jul 2019 10:06:17 +0000 (11:06 +0100)]
arm64: compat: Allow single-byte watchpoints on all addresses

commit 849adec41203ac5837c40c2d7e08490ffdef3c2c upstream.

Commit d968d2b801d8 ("ARM: 7497/1: hw_breakpoint: allow single-byte
watchpoints on all addresses") changed the validation requirements for
hardware watchpoints on arch/arm/. Update our compat layer to implement
the same relaxation.

Cc: <stable@vger.kernel.org>
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoinclude/linux/module.h: copy __init/__exit attrs to init/cleanup_module
Miguel Ojeda [Sat, 19 Jan 2019 19:59:34 +0000 (20:59 +0100)]
include/linux/module.h: copy __init/__exit attrs to init/cleanup_module

[ Upstream commit a6e60d84989fa0e91db7f236eda40453b0e44afa ]

The upcoming GCC 9 release extends the -Wmissing-attributes warnings
(enabled by -Wall) to C and aliases: it warns when particular function
attributes are missing in the aliases but not in their target.

In particular, it triggers for all the init/cleanup_module
aliases in the kernel (defined by the module_init/exit macros),
ending up being very noisy.

These aliases point to the __init/__exit functions of a module,
which are defined as __cold (among other attributes). However,
the aliases themselves do not have the __cold attribute.

Since the compiler behaves differently when compiling a __cold
function as well as when compiling paths leading to calls
to __cold functions, the warning is trying to point out
the possibly-forgotten attribute in the alias.

In order to keep the warning enabled, we decided to silence
this case. Ideally, we would mark the aliases directly
as __init/__exit. However, there are currently around 132 modules
in the kernel which are missing __init/__exit in their init/cleanup
functions (either because they are missing, or for other reasons,
e.g. the functions being called from somewhere else); and
a section mismatch is a hard error.

A conservative alternative was to mark the aliases as __cold only.
However, since we would like to eventually enforce __init/__exit
to be always marked,  we chose to use the new __copy function
attribute (introduced by GCC 9 as well to deal with this).
With it, we copy the attributes used by the target functions
into the aliases. This way, functions that were not marked
as __init/__exit won't have their aliases marked either,
and therefore there won't be a section mismatch.

Note that the warning would go away marking either the extern
declaration, the definition, or both. However, we only mark
the definition of the alias, since we do not want callers
(which only see the declaration) to be compiled as if the function
was __cold (and therefore the paths leading to those calls
would be assumed to be unlikely).

Link: https://lore.kernel.org/lkml/20190123173707.GA16603@gmail.com/
Link: https://lore.kernel.org/lkml/20190206175627.GA20399@gmail.com/
Suggested-by: Martin Sebor <msebor@gcc.gnu.org>
Acked-by: Jessica Yu <jeyu@kernel.org>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
4 years agoBackport minimal compiler_attributes.h to support GCC 9
Miguel Ojeda [Fri, 2 Aug 2019 10:37:56 +0000 (12:37 +0200)]
Backport minimal compiler_attributes.h to support GCC 9

This adds support for __copy to v4.9.y so that we can use it in
init/exit_module to avoid -Werror=missing-attributes errors on GCC 9.

Link: https://lore.kernel.org/lkml/259986242.BvXPX32bHu@devpool35/
Cc: <stable@vger.kernel.org>
Suggested-by: Rolf Eike Beer <eb@emlix.com>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
4 years agoUSB: serial: option: Add Motorola modem UARTs
Tony Lindgren [Thu, 15 Aug 2019 08:26:02 +0000 (01:26 -0700)]
USB: serial: option: Add Motorola modem UARTs

commit 6caf0be40a707689e8ff8824fdb96ef77685b1ba upstream.

On Motorola Mapphone devices such as Droid 4 there are five USB ports
that do not use the same layout as Gobi 1K/2K/etc devices listed in
qcserial.c. So we should use qcaux.c or option.c as noted by
Dan Williams <dan.j.williams@intel.com>.

As the Motorola USB serial ports have an interrupt endpoint as shown
with lsusb -v, we should use option.c instead of qcaux.c as pointed out
by Johan Hovold <johan@kernel.org>.

The ff/ff/ff interfaces seem to always be UARTs on Motorola devices.
For the other interfaces, class 0x0a (CDC Data) should not in general
be added as they are typically part of a multi-interface function as
noted earlier by Bjørn Mork <bjorn@mork.no>.

However, looking at the Motorola mapphone kernel code, the mdm6600 0x0a
class is only used for flashing the modem firmware, and there are no
other interfaces. So I've added that too with more details below as it
works just fine.

The ttyUSB ports on Droid 4 are:

ttyUSB0 DIAG, CQDM-capable
ttyUSB1 MUX or NMEA, no response
ttyUSB2 MUX or NMEA, no response
ttyUSB3 TCMD
ttyUSB4 AT-capable

The ttyUSB0 is detected as QCDM capable by ModemManager. I think
it's only used for debugging with ModemManager --debug for sending
custom AT commands though. ModemManager already can manage data
connection using the USB QMI ports that are already handled by the
qmi_wwan.c driver.

To enable the MUX or NMEA ports, it seems that something needs to be
done additionally to enable them, maybe via the DIAG or TCMD port.
It might be just a NVRAM setting somewhere, but I have no idea what
NVRAM settings may need changing for that.

The TCMD port seems to be a Motorola custom protocol for testing
the modem and to configure it's NVRAM and seems to work just fine
based on a quick test with a minimal tcmdrw tool I wrote.

The voice modem AT-capable port seems to provide only partial
support, and no PM support compared to the TS 27.010 based UART
wired directly to the modem.

The UARTs added with this change are the same product IDs as the
Motorola Mapphone Android Linux kernel mdm6600_id_table. I don't
have any mdm9600 based devices, so I have only tested these on
mdm6600 based droid 4.

Then for the class 0x0a (CDC Data) mode, the Motorola Mapphone Android
Linux kernel driver moto_flashqsc.c just seems to change the
port->bulk_out_size to 8K from the default. And is only used for
flashing the modem firmware it seems.

I've verified that flashing the modem with signed firmware works just
fine with the option driver after manually toggling the GPIO pins, so
I've added droid 4 modem flashing mode to the option driver. I've not
added the other devices listed in moto_flashqsc.c in case they really
need different port->bulk_out_size. Those can be added as they get
tested to work for flashing the modem.

After this patch the output of /sys/kernel/debug/usb/devices has
the following for normal 22b8:2a70 mode including the related qmi_wwan
interfaces:

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=12   MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=22b8 ProdID=2a70 Rev= 0.00
S:  Manufacturer=Motorola, Incorporated
S:  Product=Flash MZ600
C:* #Ifs= 9 Cfg#= 1 Atr=e0 MxPwr=500mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
E:  Ad=81(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=01(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
I:* If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
E:  Ad=83(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=03(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
I:* If#= 3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
E:  Ad=84(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=04(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
E:  Ad=85(I) Atr=03(Int.) MxPS=  64 Ivl=5ms
E:  Ad=86(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=05(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
I:* If#= 5 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=fb Prot=ff Driver=qmi_wwan
E:  Ad=87(I) Atr=03(Int.) MxPS=  64 Ivl=5ms
E:  Ad=88(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=06(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
I:* If#= 6 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=fb Prot=ff Driver=qmi_wwan
E:  Ad=89(I) Atr=03(Int.) MxPS=  64 Ivl=5ms
E:  Ad=8a(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=07(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
I:* If#= 7 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=fb Prot=ff Driver=qmi_wwan
E:  Ad=8b(I) Atr=03(Int.) MxPS=  64 Ivl=5ms
E:  Ad=8c(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=08(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
I:* If#= 8 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=fb Prot=ff Driver=qmi_wwan
E:  Ad=8d(I) Atr=03(Int.) MxPS=  64 Ivl=5ms
E:  Ad=8e(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=09(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms

In 22b8:900e "qc_dload" mode the device shows up as:

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=12   MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=22b8 ProdID=900e Rev= 0.00
S:  Manufacturer=Motorola, Incorporated
S:  Product=Flash MZ600
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=500mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
E:  Ad=81(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=01(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms

And in 22b8:4281 "ram_downloader" mode the device shows up as:

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=12   MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=22b8 ProdID=4281 Rev= 0.00
S:  Manufacturer=Motorola, Incorporated
S:  Product=Flash MZ600
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=500mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=fc Driver=option
E:  Ad=81(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=01(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms

Cc: Bjørn Mork <bjorn@mork.no>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Lars Melin <larsm17@gmail.com>
Cc: Marcel Partap <mpartap@gmx.net>
Cc: Merlijn Wajer <merlijn@wizzup.org>
Cc: Michael Scott <hashcode0f@gmail.com>
Cc: NeKit <nekit1000@gmail.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Sebastian Reichel <sre@kernel.org>
Tested-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoUSB: serial: option: add the BroadMobi BM818 card
Bob Ham [Wed, 24 Jul 2019 14:52:26 +0000 (07:52 -0700)]
USB: serial: option: add the BroadMobi BM818 card

commit e5d8badf37e6b547842f2fcde10361b29e08bd36 upstream.

Add a VID:PID for the BroadMobi BM818 M.2 card

T:  Bus=01 Lev=03 Prnt=40 Port=03 Cnt=01 Dev#= 44 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=2020 ProdID=2060 Rev=00.00
S:  Manufacturer=Qualcomm, Incorporated
S:  Product=Qualcomm CDMA Technologies MSM
C:  #Ifs= 5 Cfg#= 1 Atr=e0 MxPwr=500mA
I:  If#=0x0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
I:  If#=0x1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
I:  If#=0x2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
I:  If#=0x3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=fe Prot=ff Driver=(none)
I:  If#=0x4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)

Signed-off-by: Bob Ham <bob.ham@puri.sm>
Signed-off-by: Angus Ainslie (Purism) <angus@akkea.ca>
Cc: stable <stable@vger.kernel.org>
[ johan: use USB_DEVICE_INTERFACE_CLASS() ]
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoUSB: serial: option: Add support for ZTE MF871A
Yoshiaki Okamoto [Sat, 20 Jul 2019 13:23:18 +0000 (22:23 +0900)]
USB: serial: option: Add support for ZTE MF871A

commit 7e7ae38bf928c5cfa6dd6e9a2cf8b42c84a27c92 upstream.

This patch adds support for MF871A USB modem (aka Speed USB STICK U03)
to option driver. This modem is manufactured by ZTE corporation, and
sold by KDDI.

Interface layout:
0: AT
1: MODEM

usb-devices output:
T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  9 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=19d2 ProdID=1481 Rev=52.87
S:  Manufacturer=ZTE,Incorporated
S:  Product=ZTE Technologies MSM
S:  SerialNumber=1234567890ABCDEF
C:  #Ifs= 2 Cfg#= 1 Atr=80 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option

Co-developed-by: Hiroyuki Yamamoto <hyamamo@allied-telesis.co.jp>
Signed-off-by: Hiroyuki Yamamoto <hyamamo@allied-telesis.co.jp>
Signed-off-by: Yoshiaki Okamoto <yokamoto@allied-telesis.co.jp>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoUSB: serial: option: add D-Link DWM-222 device ID
Rogan Dawes [Wed, 17 Jul 2019 09:11:34 +0000 (11:11 +0200)]
USB: serial: option: add D-Link DWM-222 device ID

commit 552573e42aab5f75aff9bab855a9677979d9a7d5 upstream.

Add device id for D-Link DWM-222 A2.

MI_00 D-Link HS-USB Diagnostics
MI_01 D-Link HS-USB Modem
MI_02 D-Link HS-USB AT Port
MI_03 D-Link HS-USB NMEA
MI_04 D-Link HS-USB WWAN Adapter (qmi_wwan)
MI_05 USB Mass Storage Device

Cc: stable@vger.kernel.org
Signed-off-by: Rogan Dawes <rogan@dawes.za.net>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agousb: cdc-acm: make sure a refcount is taken early enough
Oliver Neukum [Thu, 8 Aug 2019 14:21:19 +0000 (16:21 +0200)]
usb: cdc-acm: make sure a refcount is taken early enough

commit c52873e5a1ef72f845526d9f6a50704433f9c625 upstream.

destroy() will decrement the refcount on the interface, so that
it needs to be taken so early that it never undercounts.

Fixes: 7fb57a019f94e ("USB: cdc-acm: Fix potential deadlock (lockdep warning)")
Cc: stable <stable@vger.kernel.org>
Reported-and-tested-by: syzbot+1b2449b7b5dc240d107a@syzkaller.appspotmail.com
Signed-off-by: Oliver Neukum <oneukum@suse.com>
Link: https://lore.kernel.org/r/20190808142119.7998-1-oneukum@suse.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoUSB: core: Fix races in character device registration and deregistraion
Alan Stern [Mon, 12 Aug 2019 20:11:07 +0000 (16:11 -0400)]
USB: core: Fix races in character device registration and deregistraion

commit 303911cfc5b95d33687d9046133ff184cf5043ff upstream.

The syzbot fuzzer has found two (!) races in the USB character device
registration and deregistration routines.  This patch fixes the races.

The first race results from the fact that usb_deregister_dev() sets
usb_minors[intf->minor] to NULL before calling device_destroy() on the
class device.  This leaves a window during which another thread can
allocate the same minor number but will encounter a duplicate name
error when it tries to register its own class device.  A typical error
message in the system log would look like:

    sysfs: cannot create duplicate filename '/class/usbmisc/ldusb0'

The patch fixes this race by destroying the class device first.

The second race is in usb_register_dev().  When that routine runs, it
first allocates a minor number, then drops minor_rwsem, and then
creates the class device.  If the device creation fails, the minor
number is deallocated and the whole routine returns an error.  But
during the time while minor_rwsem was dropped, there is a window in
which the minor number is allocated and so another thread can
successfully open the device file.  Typically this results in
use-after-free errors or invalid accesses when the other thread closes
its open file reference, because the kernel then tries to release
resources that were already deallocated when usb_register_dev()
failed.  The patch fixes this race by keeping minor_rwsem locked
throughout the entire routine.

Reported-and-tested-by: syzbot+30cf45ebfe0b0c4847a1@syzkaller.appspotmail.com
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/Pine.LNX.4.44L0.1908121607590.1659-100000@iolanthe.rowland.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: comedi: dt3000: Fix rounding up of timer divisor
Ian Abbott [Mon, 12 Aug 2019 12:08:14 +0000 (13:08 +0100)]
staging: comedi: dt3000: Fix rounding up of timer divisor

commit 8e2a589a3fc36ce858d42e767c3bcd8fc62a512b upstream.

`dt3k_ns_to_timer()` determines the prescaler and divisor to use to
produce a desired timing period.  It is influenced by a rounding mode
and can round the divisor up, down, or to the nearest value.  However,
the code for rounding up currently does the same as rounding down!  Fix
ir by using the `DIV_ROUND_UP()` macro to calculate the divisor when
rounding up.

Also, change the types of the `divider`, `base` and `prescale` variables
from `int` to `unsigned int` to avoid mixing signed and unsigned types
in the calculations.

Also fix a typo in a nearby comment: "improvment" => "improvement".

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20190812120814.21188-1-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: comedi: dt3000: Fix signed integer overflow 'divider * base'
Ian Abbott [Mon, 12 Aug 2019 11:15:17 +0000 (12:15 +0100)]
staging: comedi: dt3000: Fix signed integer overflow 'divider * base'

commit b4d98bc3fc93ec3a58459948a2c0e0c9b501cd88 upstream.

In `dt3k_ns_to_timer()` the following lines near the end of the function
result in a signed integer overflow:

prescale = 15;
base = timer_base * (1 << prescale);
divider = 65535;
*nanosec = divider * base;

(`divider`, `base` and `prescale` are type `int`, `timer_base` and
`*nanosec` are type `unsigned int`.  The value of `timer_base` will be
either 50 or 100.)

The main reason for the overflow is that the calculation for `base` is
completely wrong.  It should be:

base = timer_base * (prescale + 1);

which matches an earlier instance of this calculation in the same
function.

Reported-by: David Binderman <dcb314@hotmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Link: https://lore.kernel.org/r/20190812111517.26803-1-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoasm-generic: fix -Wtype-limits compiler warnings
Qian Cai [Sat, 3 Aug 2019 04:49:19 +0000 (21:49 -0700)]
asm-generic: fix -Wtype-limits compiler warnings

[ Upstream commit cbedfe11347fe418621bd188d58a206beb676218 ]

Commit d66acc39c7ce ("bitops: Optimise get_order()") introduced a
compilation warning because "rx_frag_size" is an "ushort" while
PAGE_SHIFT here is 16.

The commit changed the get_order() to be a multi-line macro where
compilers insist to check all statements in the macro even when
__builtin_constant_p(rx_frag_size) will return false as "rx_frag_size"
is a module parameter.

In file included from ./arch/powerpc/include/asm/page_64.h:107,
                 from ./arch/powerpc/include/asm/page.h:242,
                 from ./arch/powerpc/include/asm/mmu.h:132,
                 from ./arch/powerpc/include/asm/lppaca.h:47,
                 from ./arch/powerpc/include/asm/paca.h:17,
                 from ./arch/powerpc/include/asm/current.h:13,
                 from ./include/linux/thread_info.h:21,
                 from ./arch/powerpc/include/asm/processor.h:39,
                 from ./include/linux/prefetch.h:15,
                 from drivers/net/ethernet/emulex/benet/be_main.c:14:
drivers/net/ethernet/emulex/benet/be_main.c: In function 'be_rx_cqs_create':
./include/asm-generic/getorder.h:54:9: warning: comparison is always
true due to limited range of data type [-Wtype-limits]
   (((n) < (1UL << PAGE_SHIFT)) ? 0 :  \
         ^
drivers/net/ethernet/emulex/benet/be_main.c:3138:33: note: in expansion
of macro 'get_order'
  adapter->big_page_size = (1 << get_order(rx_frag_size)) * PAGE_SIZE;
                                 ^~~~~~~~~

Fix it by moving all of this multi-line macro into a proper function,
and killing __get_order() off.

[akpm@linux-foundation.org: remove __get_order() altogether]
[cai@lca.pw: v2]
Link: http://lkml.kernel.org/r/1564000166-31428-1-git-send-email-cai@lca.pw
Link: http://lkml.kernel.org/r/1563914986-26502-1-git-send-email-cai@lca.pw
Fixes: d66acc39c7ce ("bitops: Optimise get_order()")
Signed-off-by: Qian Cai <cai@lca.pw>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: David Howells <dhowells@redhat.com>
Cc: Jakub Jelinek <jakub@redhat.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Bill Wendling <morbo@google.com>
Cc: James Y Knight <jyknight@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
4 years agoocfs2: remove set but not used variable 'last_hash'
YueHaibing [Sat, 3 Aug 2019 04:48:40 +0000 (21:48 -0700)]
ocfs2: remove set but not used variable 'last_hash'

[ Upstream commit 7bc36e3ce91471b6377c8eadc0a2f220a2280083 ]

Fixes gcc '-Wunused-but-set-variable' warning:

  fs/ocfs2/xattr.c: In function ocfs2_xattr_bucket_find:
  fs/ocfs2/xattr.c:3828:6: warning: variable last_hash set but not used [-Wunused-but-set-variable]

It's never used and can be removed.

Link: http://lkml.kernel.org/r/20190716132110.34836-1-yuehaibing@huawei.com
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Acked-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Gang He <ghe@suse.com>
Cc: Jun Piao <piaojun@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
4 years agoIB/core: Add mitigation for Spectre V1
Luck, Tony [Wed, 31 Jul 2019 04:39:57 +0000 (21:39 -0700)]
IB/core: Add mitigation for Spectre V1

[ Upstream commit 61f259821dd3306e49b7d42a3f90fb5a4ff3351b ]

Some processors may mispredict an array bounds check and
speculatively access memory that they should not. With
a user supplied array index we like to play things safe
by masking the value with the array size before it is
used as an index.

Signed-off-by: Tony Luck <tony.luck@intel.com>
Link: https://lore.kernel.org/r/20190731043957.GA1600@agluck-desk2.amr.corp.intel.com
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
4 years agokbuild: modpost: handle KBUILD_EXTRA_SYMBOLS only for external modules
Masahiro Yamada [Tue, 30 Jul 2019 15:59:00 +0000 (00:59 +0900)]
kbuild: modpost: handle KBUILD_EXTRA_SYMBOLS only for external modules

[ Upstream commit cb4819934a7f9b87876f11ed05b8624c0114551b ]

KBUILD_EXTRA_SYMBOLS makes sense only when building external modules.
Moreover, the modpost sets 'external_module' if the -e option is given.

I replaced $(patsubst %, -e %,...) with simpler $(addprefix -e,...)
while I was here.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
4 years agoata: libahci: do not complain in case of deferred probe
Miquel Raynal [Wed, 31 Jul 2019 12:26:51 +0000 (14:26 +0200)]
ata: libahci: do not complain in case of deferred probe

[ Upstream commit 090bb803708198e5ab6b0046398c7ed9f4d12d6b ]

Retrieving PHYs can defer the probe, do not spawn an error when
-EPROBE_DEFER is returned, it is normal behavior.

Fixes: b1a9edbda040 ("ata: libahci: allow to use multiple PHYs")
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
4 years agoscsi: hpsa: correct scsi command status issue after reset
Don Brace [Wed, 24 Jul 2019 22:08:06 +0000 (17:08 -0500)]
scsi: hpsa: correct scsi command status issue after reset

[ Upstream commit eeebce1862970653cdf5c01e98bc669edd8f529a ]

Reviewed-by: Bader Ali - Saleh <bader.alisaleh@microsemi.com>
Reviewed-by: Scott Teel <scott.teel@microsemi.com>
Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
4 years agolibata: zpodd: Fix small read overflow in zpodd_get_mech_type()
Kees Cook [Mon, 29 Jul 2019 21:47:22 +0000 (14:47 -0700)]
libata: zpodd: Fix small read overflow in zpodd_get_mech_type()

[ Upstream commit 71d6c505b4d9e6f76586350450e785e3d452b346 ]

Jeffrin reported a KASAN issue:

  BUG: KASAN: global-out-of-bounds in ata_exec_internal_sg+0x50f/0xc70
  Read of size 16 at addr ffffffff91f41f80 by task scsi_eh_1/149
  ...
  The buggy address belongs to the variable:
    cdb.48319+0x0/0x40

Much like commit 18c9a99bce2a ("libata: zpodd: small read overflow in
eject_tray()"), this fixes a cdb[] buffer length, this time in
zpodd_get_mech_type():

We read from the cdb[] buffer in ata_exec_internal_sg(). It has to be
ATAPI_CDB_LEN (16) bytes long, but this buffer is only 12 bytes.

Reported-by: Jeffrin Jose T <jeffrin@rajagiritech.edu.in>
Fixes: afe759511808c ("libata: identify and init ZPODD devices")
Link: https://lore.kernel.org/lkml/201907181423.E808958@keescook/
Tested-by: Jeffrin Jose T <jeffrin@rajagiritech.edu.in>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
4 years agoperf header: Fix use of unitialized value warning
Numfor Mbiziwo-Tiapo [Wed, 24 Jul 2019 23:44:58 +0000 (16:44 -0700)]
perf header: Fix use of unitialized value warning

[ Upstream commit 20f9781f491360e7459c589705a2e4b1f136bee9 ]

When building our local version of perf with MSAN (Memory Sanitizer) and
running the perf record command, MSAN throws a use of uninitialized
value warning in "tools/perf/util/util.c:333:6".

This warning stems from the "buf" variable being passed into "write".
It originated as the variable "ev" with the type union perf_event*
defined in the "perf_event__synthesize_attr" function in
"tools/perf/util/header.c".

In the "perf_event__synthesize_attr" function they allocate space with a malloc
call using ev, then go on to only assign some of the member variables before
passing "ev" on as a parameter to the "process" function therefore "ev"
contains uninitialized memory. Changing the malloc call to zalloc to initialize
all the members of "ev" which gets rid of the warning.

To reproduce this warning, build perf by running:
make -C tools/perf CLANG=1 CC=clang EXTRA_CFLAGS="-fsanitize=memory\
 -fsanitize-memory-track-origins"

(Additionally, llvm might have to be installed and clang might have to
be specified as the compiler - export CC=/usr/bin/clang)

then running:
tools/perf/perf record -o - ls / | tools/perf/perf --no-pager annotate\
 -i - --stdio

Please see the cover letter for why false positive warnings may be
generated.

Signed-off-by: Numfor Mbiziwo-Tiapo <nums@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Drayton <mbd@fb.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <songliubraving@fb.com>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20190724234500.253358-2-nums@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
4 years agoperf header: Fix divide by zero error if f_header.attr_size==0
Vince Weaver [Tue, 23 Jul 2019 15:06:01 +0000 (11:06 -0400)]
perf header: Fix divide by zero error if f_header.attr_size==0

[ Upstream commit 7622236ceb167aa3857395f9bdaf871442aa467e ]

So I have been having lots of trouble with hand-crafted perf.data files
causing segfaults and the like, so I have started fuzzing the perf tool.

First issue found:

If f_header.attr_size is 0 in the perf.data file, then perf will crash
with a divide-by-zero error.

Committer note:

Added a pr_err() to tell the user why the command failed.

Signed-off-by: Vince Weaver <vincent.weaver@maine.edu>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/alpine.DEB.2.21.1907231100440.14532@macbook-air
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
4 years agoirqchip/irq-imx-gpcv2: Forward irq type to parent
Lucas Stach [Fri, 12 Jul 2019 13:29:05 +0000 (15:29 +0200)]
irqchip/irq-imx-gpcv2: Forward irq type to parent

[ Upstream commit 9a446ef08f3bfc0c3deb9c6be840af2528ef8cf8 ]

The GPCv2 is a stacked IRQ controller below the ARM GIC. It doesn't
care about the IRQ type itself, but needs to forward the type to the
parent IRQ controller, so this one can be configured correctly.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
4 years agoxen/pciback: remove set but not used variable 'old_state'
YueHaibing [Wed, 24 Jul 2019 14:08:50 +0000 (22:08 +0800)]
xen/pciback: remove set but not used variable 'old_state'

[ Upstream commit 09e088a4903bd0dd911b4f1732b250130cdaffed ]

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/xen/xen-pciback/conf_space_capability.c: In function pm_ctrl_write:
drivers/xen/xen-pciback/conf_space_capability.c:119:25: warning:
 variable old_state set but not used [-Wunused-but-set-variable]

It is never used so can be removed.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>