wifi: ath9k: fix possible integer overflow in ath9k_get_et_stats()
Subsystems (32)
Sasha Levin
maintainerPATCH 1/139 wifi: ath9k: fix possible integer overflow in ath9k_get_et_stats()
From: Dmitry Kandybka <[email protected]>
[ Upstream commit 3f66f26703093886db81f0610b97a6794511917c ]
In 'ath9k_get_et_stats()', promote TX stats counters to 'u64' to avoid possible integer overflow. Compile tested only.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/net/wireless/ath/ath9k/debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/debug.c +2 -2
@@ -1325,11 +1325,11 @@ void ath9k_get_et_stats(struct ieee80211_hw *hw,struct ath_softc *sc = hw->priv;int i =0 ; - data[i++] = (sc->debug.stats.txstats[PR_QNUM (IEEE80211_AC_BE )].tx_pkts_all + + data[i++] = ((u64 )sc->debug.stats.txstats[PR_QNUM (IEEE80211_AC_BE )].tx_pkts_all + sc->debug.stats.txstats[PR_QNUM (IEEE80211_AC_BK )].tx_pkts_all + sc->debug.stats.txstats[PR_QNUM (IEEE80211_AC_VI )].tx_pkts_all + sc->debug.stats.txstats[PR_QNUM (IEEE80211_AC_VO )].tx_pkts_all); - data[i++] = (sc->debug.stats.txstats[PR_QNUM (IEEE80211_AC_BE )].tx_bytes_all + + data[i++] = ((u64 )sc->debug.stats.txstats[PR_QNUM (IEEE80211_AC_BE )].tx_bytes_all + sc->debug.stats.txstats[PR_QNUM (IEEE80211_AC_BK )].tx_bytes_all + sc->debug.stats.txstats[PR_QNUM (IEEE80211_AC_VI )].tx_bytes_all + sc->debug.stats.txstats[PR_QNUM (IEEE80211_AC_VO )].tx_bytes_all);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 2/139 wifi: rtw89: avoid to add interface to list twice when SER
From: Chih-Kang Chang <[email protected]>
[ Upstream commit 7dd5d2514a8ea58f12096e888b0bd050d7eae20a ]
If SER L2 occurs during the WoWLAN resume flow, the add interface flow is triggered by ieee80211_reconfig(). However, due to rtw89_wow_resume() return failure, it will cause the add interface flow to be executed again, resulting in a double add list and causing a kernel panic. Therefore, we have added a check to prevent double adding of the list.
list_add double add: new=ffff99d6992e2010, prev=ffff99d6992e2010, next=ffff99d695302628.
------------[ cut here ]------------ kernel BUG at lib/list_debug.c:37! invalid opcode: 0000 [#1] PREEMPT SMP NOPTI CPU: 0 PID: 9 Comm: kworker/0:1 Tainted: G W O 6.6.30-02659-gc18865c4dfbd #1 770df2933251a0e3c888ba69d1053a817a6376a7 Hardware name: HP Grunt/Grunt, BIOS Google_Grunt.11031.169.0 06/24/2021 Workqueue: events_freezable ieee80211_restart_work [mac80211] RIP: 0010:__list_add_valid_or_report+0x5e/0xb0 Code: c7 74 18 48 39 ce 74 13 b0 01 59 5a 5e 5f 41 58 41 59 41 5a 5d e9 e2 d6 03 00 cc 48 c7 c7 8d 4f 17 83 48 89 c2 e8 02 c0 00 00 <0f> 0b 48 c7 c7 aa 8c 1c 83 e8 f4 bf 00 00 0f 0b 48 c7 c7 c8 bc 12 RSP: 0018:ffffa91b8007bc50 EFLAGS: 00010246 RAX: 0000000000000058 RBX: ffff99d6992e0900 RCX: a014d76c70ef3900 RDX: ffffa91b8007bae8 RSI: 00000000ffffdfff RDI: 0000000000000001 RBP: ffffa91b8007bc88 R08: 0000000000000000 R09: ffffa91b8007bae0 R10: 00000000ffffdfff R11: ffffffff83a79800 R12: ffff99d695302060 R13: ffff99d695300900 R14: ffff99d6992e1be0 R15: ffff99d6992e2010 FS: 0000000000000000(0000) GS:ffff99d6aac00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000078fbdba43480 CR3: 000000010e464000 CR4: 00000000001506f0 Call Trace: <TASK> ? __die_body+0x1f/0x70 ? die+0x3d/0x60 ? do_trap+0xa4/0x110 ? __list_add_valid_or_report+0x5e/0xb0 ? do_error_trap+0x6d/0x90 ? __list_add_valid_or_report+0x5e/0xb0 ? handle_invalid_op+0x30/0x40 ? __list_add_valid_or_report+0x5e/0xb0 ? exc_invalid_op+0x3c/0x50 ? asm_exc_invalid_op+0x16/0x20 ? __list_add_valid_or_report+0x5e/0xb0 rtw89_ops_add_interface+0x309/0x310 [rtw89_core 7c32b1ee6854761c0321027c8a58c5160e41f48f] drv_add_interface+0x5c/0x130 [mac80211 83e989e6e616bd5b4b8a2b0a9f9352a2c385a3bc] ieee80211_reconfig+0x241/0x13d0 [mac80211 83e989e6e616bd5b4b8a2b0a9f9352a2c385a3bc] ? finish_wait+0x3e/0x90 ? synchronize_rcu_expedited+0x174/0x260 ? sync_rcu_exp_done_unlocked+0x50/0x50 ? wake_bit_function+0x40/0x40 ieee80211_restart_work+0xf0/0x140 [mac80211 83e989e6e616bd5b4b8a2b0a9f9352a2c385a3bc] process_scheduled_works+0x1e5/0x480 worker_thread+0xea/0x1e0 kthread+0xdb/0x110 ? move_linked_works+0x90/0x90 ? kthread_associate_blkcg+0xa0/0xa0 ret_from_fork+0x3b/0x50 ? kthread_associate_blkcg+0xa0/0xa0 ret_from_fork_asm+0x11/0x20 </TASK> Modules linked in: dm_integrity async_xor xor async_tx lz4 lz4_compress zstd zstd_compress zram zsmalloc rfcomm cmac uinput algif_hash algif_skcipher af_alg btusb btrtl iio_trig_hrtimer industrialio_sw_trigger btmtk industrialio_configfs btbcm btintel uvcvideo videobuf2_vmalloc iio_trig_sysfs videobuf2_memops videobuf2_v4l2 videobuf2_common uvc snd_hda_codec_hdmi veth snd_hda_intel snd_intel_dspcfg acpi_als snd_hda_codec industrialio_triggered_buffer kfifo_buf snd_hwdep industrialio i2c_piix4 snd_hda_core designware_i2s ip6table_nat snd_soc_max98357a xt_MASQUERADE xt_cgroup snd_soc_acp_rt5682_mach fuse rtw89_8922ae(O) rtw89_8922a(O) rtw89_pci(O) rtw89_core(O) 8021q mac80211(O) bluetooth ecdh_generic ecc cfg80211 r8152 mii joydev gsmi: Log Shutdown Reason 0x03 ---[ end trace 0000000000000000 ]---
--- drivers/net/wireless/realtek/rtw89/mac80211.c | 4 +++- drivers/net/wireless/realtek/rtw89/util.h | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw89/mac80211.c +3 -1
@@ -126,7 +126,9 @@ static int rtw89_ops_add_interface(struct ieee80211_hw *hw, rtwvif->rtwdev = rtwdev; rtwvif->roc.state =RTW89_ROC_IDLE ; rtwvif->offchan = false; -list_add_tail (&rtwvif->list, &rtwdev->rtwvifs_list); +if (!rtw89_rtwvif_in_list (rtwdev, rtwvif)) +list_add_tail (&rtwvif->list, &rtwdev->rtwvifs_list); +INIT_WORK (&rtwvif->update_beacon_work, rtw89_core_update_beacon_work);INIT_DELAYED_WORK (&rtwvif->roc.roc_work, rtw89_roc_work);rtw89_leave_ps_mode (rtwdev);
drivers/net/wireless/realtek/rtw89/util.h +18 -0
@@ -14,6 +14,24 @@#define rtw89_for_each_rtwvif (rtwdev, rtwvif) \ list_for_each_entry(rtwvif, &(rtwdev)->rtwvifs_list, list) +/* Before adding rtwvif to list, we need to check if it already exist, beacase +* in some case such as SER L2 happen during WoWLAN flow, calling reconfig +* twice cause the list to be added twice. +*/ +static inline bool rtw89_rtwvif_in_list (struct rtw89_dev *rtwdev, +struct rtw89_vif *new) +{ +struct rtw89_vif *rtwvif; + +lockdep_assert_held (&rtwdev->mutex); + +rtw89_for_each_rtwvif (rtwdev, rtwvif) +if (rtwvif == new) +return true; + +return false; +} +/* The result of negative dividend and positive divisor is undefined, but it * should be one case of round-down or round-up. So, make it round-down if the * result is round-up.
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 3/139 wifi: ath9k_htc: Use __skb_set_length() for resetting urb before resubmit
In reply to Sasha LevinFrom: Toke Høiland-Jørgensen <[email protected]>
[ Upstream commit 94745807f3ebd379f23865e6dab196f220664179 ]
Syzbot points out that skb_trim() has a sanity check on the existing length of the skb, which can be uninitialised in some error paths. The intent here is clearly just to reset the length to zero before resubmitting, so switch to calling __skb_set_length(skb, 0) directly. In addition, __skb_set_length() already contains a call to skb_reset_tail_pointer(), so remove the redundant call.
The syzbot report came from ath9k_hif_usb_reg_in_cb(), but there's a similar usage of skb_trim() in ath9k_hif_usb_rx_cb(), change both while we're at it.
--- drivers/net/wireless/ath/ath9k/hif_usb.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath9k/hif_usb.c +2 -4
@@ -716,8 +716,7 @@ static void ath9k_hif_usb_rx_cb(struct urb *urb) } resubmit: -skb_reset_tail_pointer (skb); -skb_trim (skb,0 ); +__skb_set_length (skb,0 );usb_anchor_urb (urb, &hif_dev->rx_submitted); ret =usb_submit_urb (urb,GFP_ATOMIC );
@@ -754,8 +753,7 @@ static void ath9k_hif_usb_reg_in_cb(struct urb *urb)case -ESHUTDOWN : goto free_skb;default : -skb_reset_tail_pointer (skb); -skb_trim (skb,0 ); +__skb_set_length (skb,0 ); goto resubmit; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 4/139 crypto: x86/sha256 - Add parentheses around macros' single arguments
In reply to Sasha LevinFrom: Fangrui Song <[email protected]>
[ Upstream commit 3363c460ef726ba693704dbcd73b7e7214ccc788 ]
The macros FOUR_ROUNDS_AND_SCHED and DO_4ROUNDS rely on an unexpected/undocumented behavior of the GNU assembler, which might change in the future
(https://sourceware.org/bugzilla/show_bug.cgi?id=32073).
M (1) (2) // 1 arg !? Future: 2 args
M 1 + 2 // 1 arg !? Future: 3 args
M 1 2 // 2 argsAdd parentheses around the single arguments to support future GNU assembler and LLVM integrated assembler (when the IsOperator hack from the following link is dropped).
--- arch/x86/crypto/sha256-avx2-asm.S | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
arch/x86/crypto/sha256-avx2-asm.S +8 -8
@@ -592,22 +592,22 @@ SYM_TYPED_FUNC_START(sha256_transform_rorx) leaq K256+0*32(%rip), INP ## reuse INP as scratch reg vpaddd (INP, SRND), X0, XFER vmovdqa XFER, 0*32+_XFER(%rsp, SRND) - FOUR_ROUNDS_AND_SCHED _XFER + 0*32 + FOUR_ROUNDS_AND_SCHED (_XFER + 0*32) leaq K256+1*32(%rip), INP vpaddd (INP, SRND), X0, XFER vmovdqa XFER, 1*32+_XFER(%rsp, SRND) - FOUR_ROUNDS_AND_SCHED _XFER + 1*32 + FOUR_ROUNDS_AND_SCHED (_XFER + 1*32) leaq K256+2*32(%rip), INP vpaddd (INP, SRND), X0, XFER vmovdqa XFER, 2*32+_XFER(%rsp, SRND) - FOUR_ROUNDS_AND_SCHED _XFER + 2*32 + FOUR_ROUNDS_AND_SCHED (_XFER + 2*32) leaq K256+3*32(%rip), INP vpaddd (INP, SRND), X0, XFER vmovdqa XFER, 3*32+_XFER(%rsp, SRND) - FOUR_ROUNDS_AND_SCHED _XFER + 3*32 + FOUR_ROUNDS_AND_SCHED (_XFER + 3*32) add $4*32, SRND cmp $3*4*32, SRND
@@ -618,12 +618,12 @@ SYM_TYPED_FUNC_START(sha256_transform_rorx) leaq K256+0*32(%rip), INP vpaddd (INP, SRND), X0, XFER vmovdqa XFER, 0*32+_XFER(%rsp, SRND) - DO_4ROUNDS _XFER + 0*32 + DO_4ROUNDS (_XFER + 0*32) leaq K256+1*32(%rip), INP vpaddd (INP, SRND), X1, XFER vmovdqa XFER, 1*32+_XFER(%rsp, SRND) - DO_4ROUNDS _XFER + 1*32 + DO_4ROUNDS (_XFER + 1*32) add $2*32, SRND vmovdqa X2, X0
@@ -651,8 +651,8 @@ SYM_TYPED_FUNC_START(sha256_transform_rorx) xor SRND, SRND .align 16 .Lloop3: - DO_4ROUNDS _XFER + 0*32 + 16 - DO_4ROUNDS _XFER + 1*32 + 16 + DO_4ROUNDS (_XFER + 0*32 + 16) + DO_4ROUNDS (_XFER + 1*32 + 16) add $2*32, SRND cmp $4*4*32, SRND jb .Lloop3
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 5/139 crypto: octeontx - Fix authenc setkey
In reply to Sasha LevinFrom: Herbert Xu <[email protected]>
[ Upstream commit 311eea7e37c4c0b44b557d0c100860a03b4eab65 ]
Use the generic crypto_authenc_extractkeys helper instead of custom parsing code that is slightly broken. Also fix a number of memory leaks by moving memory allocation from setkey to init_tfm (setkey can be called multiple times over the life of a tfm).
Finally accept all hash key lengths by running the digest over extra-long keys.
--- .../crypto/marvell/octeontx/otx_cptvf_algs.c | 261 +++++++----------- 1 file changed, 93 insertions(+), 168 deletions(-)
drivers/crypto/marvell/octeontx/otx_cptvf_algs.c +93 -168
@@ -17,7 +17,6 @@#include <crypto/sha2.h> #include <crypto/xts.h> #include <crypto/scatterwalk.h> -#include <linux/rtnetlink.h> #include <linux/sort.h> #include <linux/module.h> #include "otx_cptvf.h"
@@ -66,6 +65,8 @@ static struct cpt_device_table ae_devices = { .count = ATOMIC_INIT(0) }; +static struct otx_cpt_sdesc *alloc_sdesc (struct crypto_shash *alg); +static inline int get_se_device (struct pci_dev **pdev,int *cpu_num) {int count, ret =0 ;
@@ -515,44 +516,61 @@ static int cpt_aead_init(struct crypto_aead *tfm, u8 cipher_type, u8 mac_type) ctx->cipher_type = cipher_type; ctx->mac_type = mac_type; +switch (ctx->mac_type) { +case OTX_CPT_SHA1 : + ctx->hashalg =crypto_alloc_shash ("sha1" ,0 ,0 ); +break ; + +case OTX_CPT_SHA256 : + ctx->hashalg =crypto_alloc_shash ("sha256" ,0 ,0 ); +break ; + +case OTX_CPT_SHA384 : + ctx->hashalg =crypto_alloc_shash ("sha384" ,0 ,0 ); +break ; + +case OTX_CPT_SHA512 : + ctx->hashalg =crypto_alloc_shash ("sha512" ,0 ,0 ); +break ; + } + +if (IS_ERR (ctx->hashalg)) +return PTR_ERR (ctx->hashalg); + +crypto_aead_set_reqsize_dma (tfm,sizeof (struct otx_cpt_req_ctx )); + +if (!ctx->hashalg) +return 0 ; +/* * When selected cipher is NULL we use HMAC opcode instead of * FLEXICRYPTO opcode therefore we don't need to use HASH algorithms * for calculating ipad and opad */ if (ctx->cipher_type !=OTX_CPT_CIPHER_NULL ) { -switch (ctx->mac_type) { -case OTX_CPT_SHA1 : - ctx->hashalg =crypto_alloc_shash ("sha1" ,0 , -CRYPTO_ALG_ASYNC ); -if (IS_ERR (ctx->hashalg)) -return PTR_ERR (ctx->hashalg); -break ; - -case OTX_CPT_SHA256 : - ctx->hashalg =crypto_alloc_shash ("sha256" ,0 , -CRYPTO_ALG_ASYNC ); -if (IS_ERR (ctx->hashalg)) -return PTR_ERR (ctx->hashalg); -break ; +int ss =crypto_shash_statesize (ctx->hashalg); -case OTX_CPT_SHA384 : - ctx->hashalg =crypto_alloc_shash ("sha384" ,0 , -CRYPTO_ALG_ASYNC ); -if (IS_ERR (ctx->hashalg)) -return PTR_ERR (ctx->hashalg); -break ; + ctx->ipad =kzalloc (ss,GFP_KERNEL ); +if (!ctx->ipad) { +crypto_free_shash (ctx->hashalg); +return -ENOMEM ; + } -case OTX_CPT_SHA512 : - ctx->hashalg =crypto_alloc_shash ("sha512" ,0 , -CRYPTO_ALG_ASYNC ); -if (IS_ERR (ctx->hashalg)) -return PTR_ERR (ctx->hashalg); -break ; + ctx->opad =kzalloc (ss,GFP_KERNEL ); +if (!ctx->opad) { +kfree (ctx->ipad); +crypto_free_shash (ctx->hashalg); +return -ENOMEM ; } } -crypto_aead_set_reqsize_dma (tfm,sizeof (struct otx_cpt_req_ctx )); + ctx->sdesc =alloc_sdesc (ctx->hashalg); +if (!ctx->sdesc) { +kfree (ctx->opad); +kfree (ctx->ipad); +crypto_free_shash (ctx->hashalg); +return -ENOMEM ; + }return 0 ; }
@@ -608,8 +626,7 @@ static void otx_cpt_aead_exit(struct crypto_aead *tfm)kfree (ctx->ipad);kfree (ctx->opad); -if (ctx->hashalg) -crypto_free_shash (ctx->hashalg); +crypto_free_shash (ctx->hashalg);kfree (ctx->sdesc); }
@@ -705,7 +722,7 @@ static inline void swap_data64(void *buf, u32 len) *dst =cpu_to_be64p (src); } -static int copy_pad (u8 mac_type,u8 *out_pad,u8 *in_pad) +static int swap_pad (u8 mac_type,u8 *pad) {struct sha512_state *sha512;struct sha256_state *sha256;
@@ -713,22 +730,19 @@ static int copy_pad(u8 mac_type, u8 *out_pad, u8 *in_pad)switch (mac_type) {case OTX_CPT_SHA1 : - sha1 = (struct sha1_state *) in_pad; + sha1 = (struct sha1_state *)pad;swap_data32 (sha1->state,SHA1_DIGEST_SIZE ); -memcpy (out_pad, &sha1->state,SHA1_DIGEST_SIZE );break ;case OTX_CPT_SHA256 : - sha256 = (struct sha256_state *) in_pad; + sha256 = (struct sha256_state *)pad;swap_data32 (sha256->state,SHA256_DIGEST_SIZE ); -memcpy (out_pad, &sha256->state,SHA256_DIGEST_SIZE );break ;case OTX_CPT_SHA384 :case OTX_CPT_SHA512 : - sha512 = (struct sha512_state *) in_pad; + sha512 = (struct sha512_state *)pad;swap_data64 (sha512->state,SHA512_DIGEST_SIZE ); -memcpy (out_pad, &sha512->state,SHA512_DIGEST_SIZE );break ;default :
@@ -738,55 +752,53 @@ static int copy_pad(u8 mac_type, u8 *out_pad, u8 *in_pad)return 0 ; } -static int aead_hmac_init (struct crypto_aead *cipher) +static int aead_hmac_init (struct crypto_aead *cipher, +struct crypto_authenc_keys *keys) {struct otx_cpt_aead_ctx *ctx =crypto_aead_ctx_dma (cipher); -int state_size =crypto_shash_statesize (ctx->hashalg);int ds =crypto_shash_digestsize (ctx->hashalg);int bs =crypto_shash_blocksize (ctx->hashalg); -int authkeylen = ctx->auth_key_len; +int authkeylen = keys->authkeylen;u8 *ipad =NULL , *opad =NULL ; -int ret =0 , icount =0 ; +int icount =0 ; +int ret; - ctx->sdesc =alloc_sdesc (ctx->hashalg); -if (!ctx->sdesc) -return -ENOMEM ; +if (authkeylen > bs) { + ret =crypto_shash_digest (&ctx->sdesc->shash, keys->authkey, + authkeylen, ctx->key); +if (ret) +return ret; + authkeylen = ds; + }else +memcpy (ctx->key, keys->authkey, authkeylen); - ctx->ipad =kzalloc (bs,GFP_KERNEL ); -if (!ctx->ipad) { - ret = -ENOMEM ; - goto calc_fail; - } + ctx->enc_key_len = keys->enckeylen; + ctx->auth_key_len = authkeylen; - ctx->opad =kzalloc (bs,GFP_KERNEL ); -if (!ctx->opad) { - ret = -ENOMEM ; - goto calc_fail; - } +if (ctx->cipher_type ==OTX_CPT_CIPHER_NULL ) +return keys->enckeylen ? -EINVAL :0 ; - ipad =kzalloc (state_size,GFP_KERNEL ); -if (!ipad) { - ret = -ENOMEM ; - goto calc_fail; +switch (keys->enckeylen) { +case AES_KEYSIZE_128 : + ctx->key_type =OTX_CPT_AES_128_BIT ; +break ; +case AES_KEYSIZE_192 : + ctx->key_type =OTX_CPT_AES_192_BIT ; +break ; +case AES_KEYSIZE_256 : + ctx->key_type =OTX_CPT_AES_256_BIT ; +break ; +default : +/* Invalid key length */ +return -EINVAL ; } - opad =kzalloc (state_size,GFP_KERNEL ); -if (!opad) { - ret = -ENOMEM ; - goto calc_fail; - } +memcpy (ctx->key + authkeylen, keys->enckey, keys->enckeylen); -if (authkeylen > bs) { - ret =crypto_shash_digest (&ctx->sdesc->shash, ctx->key, - authkeylen, ipad); -if (ret) - goto calc_fail; - - authkeylen = ds; - }else { -memcpy (ipad, ctx->key, authkeylen); - } + ipad = ctx->ipad; + opad = ctx->opad; +memcpy (ipad, ctx->key, authkeylen);memset (ipad + authkeylen,0 , bs - authkeylen);memcpy (opad, ipad, bs);
@@ -804,7 +816,7 @@ static int aead_hmac_init(struct crypto_aead *cipher)crypto_shash_init (&ctx->sdesc->shash);crypto_shash_update (&ctx->sdesc->shash, ipad, bs);crypto_shash_export (&ctx->sdesc->shash, ipad); - ret =copy_pad (ctx->mac_type, ctx->ipad, ipad); + ret =swap_pad (ctx->mac_type, ipad);if (ret) goto calc_fail;
@@ -812,25 +824,9 @@ static int aead_hmac_init(struct crypto_aead *cipher)crypto_shash_init (&ctx->sdesc->shash);crypto_shash_update (&ctx->sdesc->shash, opad, bs);crypto_shash_export (&ctx->sdesc->shash, opad); - ret =copy_pad (ctx->mac_type, ctx->opad, opad); -if (ret) - goto calc_fail; - -kfree (ipad); -kfree (opad); - -return 0 ; + ret =swap_pad (ctx->mac_type, opad); calc_fail: -kfree (ctx->ipad); - ctx->ipad =NULL ; -kfree (ctx->opad); - ctx->opad =NULL ; -kfree (ipad); -kfree (opad); -kfree (ctx->sdesc); - ctx->sdesc =NULL ; -return ret; }
@@ -838,57 +834,15 @@ static int otx_cpt_aead_cbc_aes_sha_setkey(struct crypto_aead *cipher, const unsigned char *key, unsigned int keylen) { -struct otx_cpt_aead_ctx *ctx =crypto_aead_ctx_dma (cipher); -struct crypto_authenc_key_param *param; -int enckeylen =0 , authkeylen =0 ; -struct rtattr *rta = (void *)key; -int status = -EINVAL ; - -if (!RTA_OK (rta, keylen)) - goto badkey; - -if (rta->rta_type !=CRYPTO_AUTHENC_KEYA_PARAM ) - goto badkey; - -if (RTA_PAYLOAD (rta) <sizeof (*param)) - goto badkey; - - param =RTA_DATA (rta); - enckeylen =be32_to_cpu (param->enckeylen); - key +=RTA_ALIGN (rta->rta_len); - keylen -=RTA_ALIGN (rta->rta_len); -if (keylen < enckeylen) - goto badkey; +struct crypto_authenc_keys authenc_keys; +int status; -if (keylen >OTX_CPT_MAX_KEY_SIZE ) - goto badkey; - - authkeylen = keylen - enckeylen; -memcpy (ctx->key, key, keylen); - -switch (enckeylen) { -case AES_KEYSIZE_128 : - ctx->key_type =OTX_CPT_AES_128_BIT ; -break ; -case AES_KEYSIZE_192 : - ctx->key_type =OTX_CPT_AES_192_BIT ; -break ; -case AES_KEYSIZE_256 : - ctx->key_type =OTX_CPT_AES_256_BIT ; -break ; -default : -/* Invalid key length */ - goto badkey; - } - - ctx->enc_key_len = enckeylen; - ctx->auth_key_len = authkeylen; - - status =aead_hmac_init (cipher); + status =crypto_authenc_extractkeys (&authenc_keys, key, keylen);if (status) goto badkey; -return 0 ; + status =aead_hmac_init (cipher, &authenc_keys); + badkey:return status; }
@@ -897,36 +851,7 @@ static int otx_cpt_aead_ecb_null_sha_setkey(struct crypto_aead *cipher,const unsigned char *key, unsigned int keylen) { -struct otx_cpt_aead_ctx *ctx =crypto_aead_ctx_dma (cipher); -struct crypto_authenc_key_param *param; -struct rtattr *rta = (void *)key; -int enckeylen =0 ; - -if (!RTA_OK (rta, keylen)) - goto badkey; - -if (rta->rta_type !=CRYPTO_AUTHENC_KEYA_PARAM ) - goto badkey; - -if (RTA_PAYLOAD (rta) <sizeof (*param)) - goto badkey; - - param =RTA_DATA (rta); - enckeylen =be32_to_cpu (param->enckeylen); - key +=RTA_ALIGN (rta->rta_len); - keylen -=RTA_ALIGN (rta->rta_len); -if (enckeylen !=0 ) - goto badkey; - -if (keylen >OTX_CPT_MAX_KEY_SIZE ) - goto badkey; - -memcpy (ctx->key, key, keylen); - ctx->enc_key_len = enckeylen; - ctx->auth_key_len = keylen; -return 0 ; -badkey: -return -EINVAL ; + return otx_cpt_aead_cbc_aes_sha_setkey(cipher, key, keylen); } static int otx_cpt_aead_gcm_aes_setkey(struct crypto_aead *cipher,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 6/139 crypto: octeontx2 - Fix authenc setkey
In reply to Sasha LevinFrom: Herbert Xu <[email protected]>
[ Upstream commit 7ccb750dcac8abbfc7743aab0db6a72c1c3703c7 ]
Use the generic crypto_authenc_extractkeys helper instead of custom parsing code that is slightly broken. Also fix a number of memory leaks by moving memory allocation from setkey to init_tfm (setkey can be called multiple times over the life of a tfm).
Finally accept all hash key lengths by running the digest over extra-long keys.
--- .../marvell/octeontx2/otx2_cptvf_algs.c | 254 +++++++----------- 1 file changed, 90 insertions(+), 164 deletions(-)
drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c +90 -164
@@ -11,7 +11,6 @@#include <crypto/xts.h> #include <crypto/gcm.h> #include <crypto/scatterwalk.h> -#include <linux/rtnetlink.h> #include <linux/sort.h> #include <linux/module.h> #include "otx2_cptvf.h"
@@ -54,6 +53,8 @@ static struct cpt_device_table se_devices = { .count = ATOMIC_INIT(0) }; +static struct otx2_cpt_sdesc *alloc_sdesc (struct crypto_shash *alg); +static inline int get_se_device (struct pci_dev **pdev,int *cpu_num) {int count;
@@ -580,40 +581,56 @@ static int cpt_aead_init(struct crypto_aead *atfm, u8 cipher_type, u8 mac_type) ctx->cipher_type = cipher_type; ctx->mac_type = mac_type; +switch (ctx->mac_type) { +case OTX2_CPT_SHA1 : + ctx->hashalg =crypto_alloc_shash ("sha1" ,0 ,0 ); +break ; + +case OTX2_CPT_SHA256 : + ctx->hashalg =crypto_alloc_shash ("sha256" ,0 ,0 ); +break ; + +case OTX2_CPT_SHA384 : + ctx->hashalg =crypto_alloc_shash ("sha384" ,0 ,0 ); +break ; + +case OTX2_CPT_SHA512 : + ctx->hashalg =crypto_alloc_shash ("sha512" ,0 ,0 ); +break ; + } + +if (IS_ERR (ctx->hashalg)) +return PTR_ERR (ctx->hashalg); + +if (ctx->hashalg) { + ctx->sdesc =alloc_sdesc (ctx->hashalg); +if (!ctx->sdesc) { +crypto_free_shash (ctx->hashalg); +return -ENOMEM ; + } + } +/* * When selected cipher is NULL we use HMAC opcode instead of * FLEXICRYPTO opcode therefore we don't need to use HASH algorithms * for calculating ipad and opad */ -if (ctx->cipher_type !=OTX2_CPT_CIPHER_NULL ) { -switch (ctx->mac_type) { -case OTX2_CPT_SHA1 : - ctx->hashalg =crypto_alloc_shash ("sha1" ,0 , -CRYPTO_ALG_ASYNC ); -if (IS_ERR (ctx->hashalg)) -return PTR_ERR (ctx->hashalg); -break ; - -case OTX2_CPT_SHA256 : - ctx->hashalg =crypto_alloc_shash ("sha256" ,0 , -CRYPTO_ALG_ASYNC ); -if (IS_ERR (ctx->hashalg)) -return PTR_ERR (ctx->hashalg); -break ; +if (ctx->cipher_type !=OTX2_CPT_CIPHER_NULL && ctx->hashalg) { +int ss =crypto_shash_statesize (ctx->hashalg); -case OTX2_CPT_SHA384 : - ctx->hashalg =crypto_alloc_shash ("sha384" ,0 , -CRYPTO_ALG_ASYNC ); -if (IS_ERR (ctx->hashalg)) -return PTR_ERR (ctx->hashalg); -break ; + ctx->ipad =kzalloc (ss,GFP_KERNEL ); +if (!ctx->ipad) { +kfree (ctx->sdesc); +crypto_free_shash (ctx->hashalg); +return -ENOMEM ; + } -case OTX2_CPT_SHA512 : - ctx->hashalg =crypto_alloc_shash ("sha512" ,0 , -CRYPTO_ALG_ASYNC ); -if (IS_ERR (ctx->hashalg)) -return PTR_ERR (ctx->hashalg); -break ; + ctx->opad =kzalloc (ss,GFP_KERNEL ); +if (!ctx->opad) { +kfree (ctx->ipad); +kfree (ctx->sdesc); +crypto_free_shash (ctx->hashalg); +return -ENOMEM ; } }switch (ctx->cipher_type) {
@@ -686,8 +703,7 @@ static void otx2_cpt_aead_exit(struct crypto_aead *tfm)kfree (ctx->ipad);kfree (ctx->opad); -if (ctx->hashalg) -crypto_free_shash (ctx->hashalg); +crypto_free_shash (ctx->hashalg);kfree (ctx->sdesc);if (ctx->fbk_cipher) {
@@ -760,7 +776,7 @@ static inline void swap_data64(void *buf, u32 len)cpu_to_be64s (src); } -static int copy_pad (u8 mac_type,u8 *out_pad,u8 *in_pad) +static int swap_pad (u8 mac_type,u8 *pad) {struct sha512_state *sha512;struct sha256_state *sha256;
@@ -768,22 +784,19 @@ static int copy_pad(u8 mac_type, u8 *out_pad, u8 *in_pad)switch (mac_type) {case OTX2_CPT_SHA1 : - sha1 = (struct sha1_state *) in_pad; + sha1 = (struct sha1_state *)pad;swap_data32 (sha1->state,SHA1_DIGEST_SIZE ); -memcpy (out_pad, &sha1->state,SHA1_DIGEST_SIZE );break ;case OTX2_CPT_SHA256 : - sha256 = (struct sha256_state *) in_pad; + sha256 = (struct sha256_state *)pad;swap_data32 (sha256->state,SHA256_DIGEST_SIZE ); -memcpy (out_pad, &sha256->state,SHA256_DIGEST_SIZE );break ;case OTX2_CPT_SHA384 :case OTX2_CPT_SHA512 : - sha512 = (struct sha512_state *) in_pad; + sha512 = (struct sha512_state *)pad;swap_data64 (sha512->state,SHA512_DIGEST_SIZE ); -memcpy (out_pad, &sha512->state,SHA512_DIGEST_SIZE );break ;default :
@@ -793,55 +806,54 @@ static int copy_pad(u8 mac_type, u8 *out_pad, u8 *in_pad)return 0 ; } -static int aead_hmac_init (struct crypto_aead *cipher) +static int aead_hmac_init (struct crypto_aead *cipher, +struct crypto_authenc_keys *keys) {struct otx2_cpt_aead_ctx *ctx =crypto_aead_ctx_dma (cipher); -int state_size =crypto_shash_statesize (ctx->hashalg);int ds =crypto_shash_digestsize (ctx->hashalg);int bs =crypto_shash_blocksize (ctx->hashalg); -int authkeylen = ctx->auth_key_len; +int authkeylen = keys->authkeylen;u8 *ipad =NULL , *opad =NULL ; -int ret =0 , icount =0 ; +int icount =0 ; +int ret; - ctx->sdesc =alloc_sdesc (ctx->hashalg); -if (!ctx->sdesc) -return -ENOMEM ; +if (authkeylen > bs) { + ret =crypto_shash_digest (&ctx->sdesc->shash, keys->authkey, + authkeylen, ctx->key); +if (ret) + goto calc_fail; - ctx->ipad =kzalloc (bs,GFP_KERNEL ); -if (!ctx->ipad) { - ret = -ENOMEM ; - goto calc_fail; - } + authkeylen = ds; + }else +memcpy (ctx->key, keys->authkey, authkeylen); - ctx->opad =kzalloc (bs,GFP_KERNEL ); -if (!ctx->opad) { - ret = -ENOMEM ; - goto calc_fail; - } + ctx->enc_key_len = keys->enckeylen; + ctx->auth_key_len = authkeylen; - ipad =kzalloc (state_size,GFP_KERNEL ); -if (!ipad) { - ret = -ENOMEM ; - goto calc_fail; - } +if (ctx->cipher_type ==OTX2_CPT_CIPHER_NULL ) +return keys->enckeylen ? -EINVAL :0 ; - opad =kzalloc (state_size,GFP_KERNEL ); -if (!opad) { - ret = -ENOMEM ; - goto calc_fail; +switch (keys->enckeylen) { +case AES_KEYSIZE_128 : + ctx->key_type =OTX2_CPT_AES_128_BIT ; +break ; +case AES_KEYSIZE_192 : + ctx->key_type =OTX2_CPT_AES_192_BIT ; +break ; +case AES_KEYSIZE_256 : + ctx->key_type =OTX2_CPT_AES_256_BIT ; +break ; +default : +/* Invalid key length */ +return -EINVAL ; } -if (authkeylen > bs) { - ret =crypto_shash_digest (&ctx->sdesc->shash, ctx->key, - authkeylen, ipad); -if (ret) - goto calc_fail; +memcpy (ctx->key + authkeylen, keys->enckey, keys->enckeylen); - authkeylen = ds; - }else { -memcpy (ipad, ctx->key, authkeylen); - } + ipad = ctx->ipad; + opad = ctx->opad; +memcpy (ipad, ctx->key, authkeylen);memset (ipad + authkeylen,0 , bs - authkeylen);memcpy (opad, ipad, bs);
@@ -859,7 +871,7 @@ static int aead_hmac_init(struct crypto_aead *cipher)crypto_shash_init (&ctx->sdesc->shash);crypto_shash_update (&ctx->sdesc->shash, ipad, bs);crypto_shash_export (&ctx->sdesc->shash, ipad); - ret =copy_pad (ctx->mac_type, ctx->ipad, ipad); + ret =swap_pad (ctx->mac_type, ipad);if (ret) goto calc_fail;
@@ -867,25 +879,9 @@ static int aead_hmac_init(struct crypto_aead *cipher)crypto_shash_init (&ctx->sdesc->shash);crypto_shash_update (&ctx->sdesc->shash, opad, bs);crypto_shash_export (&ctx->sdesc->shash, opad); - ret =copy_pad (ctx->mac_type, ctx->opad, opad); -if (ret) - goto calc_fail; - -kfree (ipad); -kfree (opad); - -return 0 ; + ret =swap_pad (ctx->mac_type, opad); calc_fail: -kfree (ctx->ipad); - ctx->ipad =NULL ; -kfree (ctx->opad); - ctx->opad =NULL ; -kfree (ipad); -kfree (opad); -kfree (ctx->sdesc); - ctx->sdesc =NULL ; -return ret; }
@@ -893,87 +889,17 @@ static int otx2_cpt_aead_cbc_aes_sha_setkey(struct crypto_aead *cipher, const unsigned char *key, unsigned int keylen) { -struct otx2_cpt_aead_ctx *ctx =crypto_aead_ctx_dma (cipher); -struct crypto_authenc_key_param *param; -int enckeylen =0 , authkeylen =0 ; -struct rtattr *rta = (void *)key; - -if (!RTA_OK (rta, keylen)) -return -EINVAL ; +struct crypto_authenc_keys authenc_keys; -if (rta->rta_type !=CRYPTO_AUTHENC_KEYA_PARAM ) -return -EINVAL ; - -if (RTA_PAYLOAD (rta) <sizeof (*param)) -return -EINVAL ; - - param =RTA_DATA (rta); - enckeylen =be32_to_cpu (param->enckeylen); - key +=RTA_ALIGN (rta->rta_len); - keylen -=RTA_ALIGN (rta->rta_len); -if (keylen < enckeylen) -return -EINVAL ; - -if (keylen >OTX2_CPT_MAX_KEY_SIZE ) -return -EINVAL ; - - authkeylen = keylen - enckeylen; -memcpy (ctx->key, key, keylen); - -switch (enckeylen) { -case AES_KEYSIZE_128 : - ctx->key_type =OTX2_CPT_AES_128_BIT ; -break ; -case AES_KEYSIZE_192 : - ctx->key_type =OTX2_CPT_AES_192_BIT ; -break ; -case AES_KEYSIZE_256 : - ctx->key_type =OTX2_CPT_AES_256_BIT ; -break ; -default : -/* Invalid key length */ -return -EINVAL ; - } - - ctx->enc_key_len = enckeylen; - ctx->auth_key_len = authkeylen; - -return aead_hmac_init (cipher); +return crypto_authenc_extractkeys (&authenc_keys, key, keylen) ?: +aead_hmac_init (cipher, &authenc_keys); }static int otx2_cpt_aead_ecb_null_sha_setkey (struct crypto_aead *cipher,const unsigned char *key,unsigned int keylen) { -struct otx2_cpt_aead_ctx *ctx =crypto_aead_ctx_dma (cipher); -struct crypto_authenc_key_param *param; -struct rtattr *rta = (void *)key; -int enckeylen =0 ; - -if (!RTA_OK (rta, keylen)) -return -EINVAL ; - -if (rta->rta_type !=CRYPTO_AUTHENC_KEYA_PARAM ) -return -EINVAL ; - -if (RTA_PAYLOAD (rta) <sizeof (*param)) -return -EINVAL ; - - param =RTA_DATA (rta); - enckeylen =be32_to_cpu (param->enckeylen); - key +=RTA_ALIGN (rta->rta_len); - keylen -=RTA_ALIGN (rta->rta_len); -if (enckeylen !=0 ) -return -EINVAL ; - -if (keylen >OTX2_CPT_MAX_KEY_SIZE ) -return -EINVAL ; - -memcpy (ctx->key, key, keylen); - ctx->enc_key_len = enckeylen; - ctx->auth_key_len = keylen; - -return 0 ; +return otx2_cpt_aead_cbc_aes_sha_setkey (cipher, key, keylen); } static int otx2_cpt_aead_gcm_aes_setkey(struct crypto_aead *cipher,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 7/139 ice: Adjust over allocation of memory in ice_sched_add_root_node() and ice_sched_add_node()
In reply to Sasha LevinFrom: Aleksandr Mishin <[email protected]>
[ Upstream commit 62fdaf9e8056e9a9e6fe63aa9c816ec2122d60c6 ]
In ice_sched_add_root_node() and ice_sched_add_node() there are calls to devm_kcalloc() in order to allocate memory for array of pointers to 'ice_sched_node' structure. But incorrect types are used as sizeof() arguments in these calls (structures instead of pointers) which leads to over allocation of memory.
Adjust over allocation of memory by correcting types in devm_kcalloc() sizeof() arguments.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/net/ethernet/intel/ice/ice_sched.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ice/ice_sched.c +2 -4
@@ -28,9 +28,8 @@ ice_sched_add_root_node(struct ice_port_info *pi,if (!root)return -ENOMEM ; -/* coverity[suspicious_sizeof] */ root->children =devm_kcalloc (ice_hw_to_dev (hw), hw->max_children[0 ], -sizeof (*root),GFP_KERNEL ); +sizeof (*root->children),GFP_KERNEL );if (!root->children) {devm_kfree (ice_hw_to_dev (hw), root);return -ENOMEM ;
@@ -186,10 +185,9 @@ ice_sched_add_node(struct ice_port_info *pi, u8 layer,if (!node)return -ENOMEM ;if (hw->max_children[layer]) { -/* coverity[suspicious_sizeof] */ node->children =devm_kcalloc (ice_hw_to_dev (hw), hw->max_children[layer], -sizeof (*node),GFP_KERNEL ); +sizeof (*node->children),GFP_KERNEL );if (!node->children) {devm_kfree (ice_hw_to_dev (hw), node);return -ENOMEM ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 8/139 wifi: iwlwifi: mvm: Fix a race in scan abort flow
In reply to Sasha LevinFrom: Ilan Peer <[email protected]>
[ Upstream commit 87c1c28a9aa149489e1667f5754fc24f4973d2d0 ]
When the upper layer requests to cancel an ongoing scan, a race is possible in which by the time the driver starts to handle the upper layers scan cancel flow, the FW already completed handling the scan request and the driver received the scan complete notification but still did not handle the notification. In such a case the FW will simply ignore the scan abort request coming from the driver, no notification would arrive from the FW and the entire abort flow would be considered a failure.
To better handle this, check the status code returned by the FW for the scan abort command. In case the status indicates that no scan was aborted, complete the scan abort flow with success, i.e., the scan was aborted, as the flow is expected to consume the scan complete notification.
--- .../net/wireless/intel/iwlwifi/fw/api/scan.h | 13 ++++++ drivers/net/wireless/intel/iwlwifi/mvm/scan.c | 42 +++++++++++++++---- 2 files changed, 47 insertions(+), 8 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/api/scan.h +13 -0
@@ -1123,6 +1123,19 @@ struct iwl_umac_scan_abort {__le32 flags; } __packed;/* SCAN_ABORT_CMD_UMAC_API_S_VER_1 */ +/** +* enum iwl_umac_scan_abort_status +* +* @IWL_UMAC_SCAN_ABORT_STATUS_SUCCESS: scan was successfully aborted +* @IWL_UMAC_SCAN_ABORT_STATUS_IN_PROGRESS: scan abort is in progress +* @IWL_UMAC_SCAN_ABORT_STATUS_NOT_FOUND: nothing to abort +*/ +enum iwl_umac_scan_abort_status { +IWL_UMAC_SCAN_ABORT_STATUS_SUCCESS =0 , +IWL_UMAC_SCAN_ABORT_STATUS_IN_PROGRESS , +IWL_UMAC_SCAN_ABORT_STATUS_NOT_FOUND , +}; +/** * struct iwl_umac_scan_complete * @uid: scan id, &enum iwl_umac_scan_uid_offsets
drivers/net/wireless/intel/iwlwifi/mvm/scan.c +34 -8
83 lines not on this page · raw message
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 9/139 wifi: iwlwifi: mvm: drop wrong STA selection in TX
In reply to Sasha LevinFrom: Johannes Berg <[email protected]>
[ Upstream commit 1c7e1068a7c9c39ed27636db93e71911e0045419 ]
This shouldn't happen at all, since in station mode all MMPDUs go through the TXQ for the STA, and not this function. There may or may not be a race in mac80211 through which this might happen for some frames while a station is being added, but in that case we can also just drop the frame and pretend the STA didn't exist yet.
Also, the code is simply wrong since it uses deflink, and it's not easy to fix it since the mvmvif->ap_sta pointer cannot be used without the mutex, and perhaps the right link might not even be known.
Just drop the frame at that point instead of trying to fix it up.
--- .../net/wireless/intel/iwlwifi/mvm/mac80211.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +3 -13
@@ -766,20 +766,10 @@ void iwl_mvm_mac_tx(struct ieee80211_hw *hw,if (ieee80211_is_mgmt (hdr->frame_control)) sta =NULL ; -/* If there is no sta, and it's not offchannel - send through AP */ +/* this shouldn't even happen: just drop */ if (!sta && info->control.vif->type ==NL80211_IFTYPE_STATION && - !offchannel) { -struct iwl_mvm_vif *mvmvif = -iwl_mvm_vif_from_mac80211 (info->control.vif); -u8 ap_sta_id =READ_ONCE (mvmvif->deflink.ap_sta_id); - -if (ap_sta_id < mvm->fw->ucode_capa.num_stations) { -/* mac80211 holds rcu read lock */ - sta =rcu_dereference (mvm->fw_id_to_mac_id[ap_sta_id]); -if (IS_ERR_OR_NULL (sta)) - goto drop; - } - } + !offchannel) + goto drop;if (tmp_sta && !sta && link_id !=IEEE80211_LINK_UNSPECIFIED && !ieee80211_is_probe_resp (hdr->frame_control)) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 10/139 wifi: cfg80211: Set correct chandef when starting CAC
In reply to Sasha LevinFrom: Issam Hamdi <[email protected]>
[ Upstream commit 20361712880396e44ce80aaeec2d93d182035651 ]
When starting CAC in a mode other than AP mode, it return a "WARNING: CPU: 0 PID: 63 at cfg80211_chandef_dfs_usable+0x20/0xaf [cfg80211]" caused by the chandef.chan being null at the end of CAC.
Solution: Ensure the channel definition is set for the different modes when starting CAC to avoid getting a NULL 'chan' at the end of CAC.
Call Trace: ? show_regs.part.0+0x14/0x16 ? __warn+0x67/0xc0 ? cfg80211_chandef_dfs_usable+0x20/0xaf [cfg80211] ? report_bug+0xa7/0x130 ? exc_overflow+0x30/0x30 ? handle_bug+0x27/0x50 ? exc_invalid_op+0x18/0x60 ? handle_exception+0xf6/0xf6 ? exc_overflow+0x30/0x30 ? cfg80211_chandef_dfs_usable+0x20/0xaf [cfg80211] ? exc_overflow+0x30/0x30 ? cfg80211_chandef_dfs_usable+0x20/0xaf [cfg80211] ? regulatory_propagate_dfs_state.cold+0x1b/0x4c [cfg80211] ? cfg80211_propagate_cac_done_wk+0x1a/0x30 [cfg80211] ? process_one_work+0x165/0x280 ? worker_thread+0x120/0x3f0 ? kthread+0xc2/0xf0 ? process_one_work+0x280/0x280 ? kthread_complete_and_exit+0x20/0x20 ? ret_from_fork+0x19/0x24
--- net/wireless/nl80211.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
net/wireless/nl80211.c +14 -1
@@ -10047,7 +10047,20 @@ static int nl80211_start_radar_detection(struct sk_buff *skb, err =rdev_start_radar_detection (rdev, dev, &chandef, cac_time_ms);if (!err) { - wdev->links[0 ].ap.chandef = chandef; +switch (wdev->iftype) { +case NL80211_IFTYPE_AP : +case NL80211_IFTYPE_P2P_GO : + wdev->links[0 ].ap.chandef = chandef; +break ; +case NL80211_IFTYPE_ADHOC : + wdev->u.ibss.chandef = chandef; +break ; +case NL80211_IFTYPE_MESH_POINT : + wdev->u.mesh.chandef = chandef; +break ; +default : +break ; + } wdev->cac_started = true; wdev->cac_start_time = jiffies; wdev->cac_time_ms = cac_time_ms;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 11/139 net/xen-netback: prevent UAF in xenvif_flush_hash()
In reply to Sasha LevinFrom: Jeongjun Park <[email protected]>
[ Upstream commit 0fa5e94a1811d68fbffa0725efe6d4ca62c03d12 ]
During the list_for_each_entry_rcu iteration call of xenvif_flush_hash, kfree_rcu does not exist inside the rcu read critical section, so if kfree_rcu is called when the rcu grace period ends during the iteration, UAF occurs when accessing head->next after the entry becomes free.
Therefore, to solve this, you need to change it to list_for_each_entry_safe.
--- drivers/net/xen-netback/hash.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/xen-netback/hash.c +2 -3
@@ -95,7 +95,7 @@ static u32 xenvif_new_hash(struct xenvif *vif, const u8 *data,static void xenvif_flush_hash (struct xenvif *vif) { -struct xenvif_hash_cache_entry *entry; +struct xenvif_hash_cache_entry *entry, *n;unsigned long flags;if (xenvif_hash_cache_size ==0 )
@@ -103,8 +103,7 @@ static void xenvif_flush_hash(struct xenvif *vif)spin_lock_irqsave (&vif->hash.cache.lock, flags); -list_for_each_entry_rcu (entry, &vif->hash.cache.list, link, -lockdep_is_held (&vif->hash.cache.lock)) { +list_for_each_entry_safe (entry, n, &vif->hash.cache.list, link) {list_del_rcu (&entry->link); vif->hash.cache.count--;kfree_rcu (entry, rcu);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 12/139 net: hisilicon: hip04: fix OF node leak in probe()
In reply to Sasha LevinFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 17555297dbd5bccc93a01516117547e26a61caf1 ]
Driver is leaking OF node reference fromof_parse_phandle_with_fixed_args() in probe().
--- drivers/net/ethernet/hisilicon/hip04_eth.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/hisilicon/hip04_eth.c +1 -0
@@ -947,6 +947,7 @@ static int hip04_mac_probe(struct platform_device *pdev) priv->tx_coalesce_timer.function = tx_done; priv->map =syscon_node_to_regmap (arg.np); +of_node_put (arg.np);if (IS_ERR (priv->map)) {dev_warn (d,"no syscon hisilicon,hip04-ppe\n" ); ret =PTR_ERR (priv->map);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 13/139 net: hisilicon: hns_dsaf_mac: fix OF node leak in hns_mac_get_info()
In reply to Sasha LevinFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 5680cf8d34e1552df987e2f4bb1bff0b2a8c8b11 ]
Driver is leaking OF node reference from of_parse_phandle_with_fixed_args() in hns_mac_get_info().
--- drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c +1 -0
@@ -933,6 +933,7 @@ static int hns_mac_get_info(struct hns_mac_cb *mac_cb) mac_cb->cpld_ctrl =NULL ; }else { syscon =syscon_node_to_regmap (cpld_args.np); +of_node_put (cpld_args.np);if (IS_ERR_OR_NULL (syscon)) {dev_dbg (mac_cb->dev,"no cpld-syscon found!\n" ); mac_cb->cpld_ctrl =NULL ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 14/139 net: hisilicon: hns_mdio: fix OF node leak in probe()
In reply to Sasha LevinFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit e62beddc45f487b9969821fad3a0913d9bc18a2f ]
Driver is leaking OF node reference fromof_parse_phandle_with_fixed_args() in probe().
--- drivers/net/ethernet/hisilicon/hns_mdio.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/hisilicon/hns_mdio.c +1 -0
@@ -575,6 +575,7 @@ static int hns_mdio_probe(struct platform_device *pdev)MDIO_SC_RESET_ST ; } } +of_node_put (reg_args.np); }else {dev_warn (&pdev->dev,"find syscon ret = %#x\n" , ret); mdio_dev->subctrl_vbase =NULL ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 15/139 ACPI: PAD: fix crash in exit_round_robin()
In reply to Sasha LevinFrom: Seiji Nishikawa <[email protected]>
[ Upstream commit 0a2ed70a549e61c5181bad5db418d223b68ae932 ]
The kernel occasionally crashes in cpumask_clear_cpu(), which is called within exit_round_robin(), because when executing clear_bit(nr, addr) with nr set to 0xffffffff, the address calculation may cause misalignment within the memory, leading to access to an invalid memory address.
----------
BUG: unable to handle kernel paging request at ffffffffe0740618
...
CPU: 3 PID: 2919323 Comm: acpi_pad/14 Kdump: loaded Tainted: G OE X --------- - - 4.18.0-425.19.2.el8_7.x86_64 #1
...
RIP: 0010:power_saving_thread+0x313/0x411 [acpi_pad]
Code: 89 cd 48 89 d3 eb d1 48 c7 c7 55 70 72 c0 e8 64 86 b0 e4 c6 05 0d a1 02 00 01 e9 bc fd ff ff 45 89 e4 42 8b 04 a5 20 82 72 c0 <f0> 48 0f b3 05 f4 9c 01 00 42 c7 04 a5 20 82 72 c0 ff ff ff ff 31
RSP: 0018:ff72a5d51fa77ec8 EFLAGS: 00010202
RAX: 00000000ffffffff RBX: ff462981e5d8cb80 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000246 RDI: 0000000000000246
RBP: ff46297556959d80 R08: 0000000000000382 R09: ff46297c8d0f38d8
R10: 0000000000000000 R11: 0000000000000001 R12: 000000000000000e
R13: 0000000000000000 R14: ffffffffffffffff R15: 000000000000000e
FS: 0000000000000000(0000) GS:ff46297a800c0000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffe0740618 CR3: 0000007e20410004 CR4: 0000000000771ee0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
PKRU: 55555554
Call Trace:
? acpi_pad_add+0x120/0x120 [acpi_pad]
kthread+0x10b/0x130
? set_kthread_struct+0x50/0x50
ret_from_fork+0x1f/0x40
...CR2: ffffffffe0740618
crash> dis -lr ffffffffc0726923
...
/usr/src/debug/kernel-4.18.0-425.19.2.el8_7/linux-4.18.0-425.19.2.el8_7.x86_64/./include/linux/cpumask.h: 1140xffffffffc0726918 <power_saving_thread+776>: mov %r12d,%r12d/usr/src/debug/kernel-4.18.0-425.19.2.el8_7/linux-4.18.0-425.19.2.el8_7.x86_64/./include/linux/cpumask.h: 3250xffffffffc072691b <power_saving_thread+779>: mov -0x3f8d7de0(,%r12,4),%eax/usr/src/debug/kernel-4.18.0-425.19.2.el8_7/linux-4.18.0-425.19.2.el8_7.x86_64/./arch/x86/include/asm/bitops.h: 800xffffffffc0726923 <power_saving_thread+787>: lock btr %rax,0x19cf4(%rip) # 0xffffffffc0740620 <pad_busy_cpus_bits>
crash> px tsk_in_cpu[14]
$66 = 0xffffffff
crash> px 0xffffffffc072692c+0x19cf4
$99 = 0xffffffffc0740620
crash> sym 0xffffffffc0740620 ffffffffc0740620 (b) pad_busy_cpus_bits [acpi_pad]
crash> px pad_busy_cpus_bits[0]
$42 = 0xfffc0
----------
To fix this, ensure that tsk_in_cpu[tsk_index] != -1 before calling cpumask_clear_cpu() in exit_round_robin(), just as it is done in round_robin_cpu().
--- drivers/acpi/acpi_pad.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/acpi/acpi_pad.c +4 -2
@@ -131,8 +131,10 @@ static void exit_round_robin(unsigned int tsk_index) {struct cpumask *pad_busy_cpus =to_cpumask (pad_busy_cpus_bits); -cpumask_clear_cpu (tsk_in_cpu[tsk_index], pad_busy_cpus); - tsk_in_cpu[tsk_index] =-1 ; +if (tsk_in_cpu[tsk_index] !=-1 ) { +cpumask_clear_cpu (tsk_in_cpu[tsk_index], pad_busy_cpus); + tsk_in_cpu[tsk_index] =-1 ; + } }static unsigned int idle_pct =5 ;/* percentage */
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 16/139 ACPICA: Fix memory leak if acpi_ps_get_next_namepath() fails
In reply to Sasha LevinFrom: Armin Wolf <[email protected]>
[ Upstream commit 5accb265f7a1b23e52b0ec42313d1e12895552f4 ]
ACPICA commit 2802af722bbde7bf1a7ac68df68e179e2555d361
If acpi_ps_get_next_namepath() fails, the previously allocated union acpi_parse_object needs to be freed before returning the status code.
The issue was first being reported on the Linux ACPI mailing list:
--- drivers/acpi/acpica/psargs.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/acpi/acpica/psargs.c +8 -0
@@ -820,6 +820,10 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,acpi_ps_get_next_namepath (walk_state, parser_state, arg,ACPI_NOT_METHOD_CALL ); +if (ACPI_FAILURE (status)) { +acpi_ps_free_op (arg); +return_ACPI_STATUS (status); + } }else {/* Single complex argument, nothing returned */
@@ -854,6 +858,10 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,acpi_ps_get_next_namepath (walk_state, parser_state, arg,ACPI_POSSIBLE_METHOD_CALL ); +if (ACPI_FAILURE (status)) { +acpi_ps_free_op (arg); +return_ACPI_STATUS (status); + }if (arg->common.aml_opcode ==AML_INT_METHODCALL_OP ) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 17/139 ACPICA: Fix memory leak if acpi_ps_get_next_field() fails
In reply to Sasha LevinFrom: Armin Wolf <[email protected]>
[ Upstream commit e6169a8ffee8a012badd8c703716e761ce851b15 ]
ACPICA commit 1280045754264841b119a5ede96cd005bc09b5a7
If acpi_ps_get_next_field() fails, the previously created field list needs to be properly disposed before returning the status code.
--- drivers/acpi/acpica/psargs.c | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
drivers/acpi/acpica/psargs.c +39 -0
@@ -25,6 +25,8 @@ acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state);static union acpi_parse_object *acpi_ps_get_next_field (struct acpi_parse_state *parser_state); +static void acpi_ps_free_field_list (union acpi_parse_object *start); +/******************************************************************************* * * FUNCTION: acpi_ps_get_next_package_length
@@ -683,6 +685,39 @@ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_statereturn_PTR (field); } +/******************************************************************************* +* +* FUNCTION: acpi_ps_free_field_list +* +* PARAMETERS: start - First Op in field list +* +* RETURN: None. +* +* DESCRIPTION: Free all Op objects inside a field list. +* +******************************************************************************/ + +static void acpi_ps_free_field_list (union acpi_parse_object *start) +{ +union acpi_parse_object *cur = start; +union acpi_parse_object *next; +union acpi_parse_object *arg; + +while (cur) { + next = cur->common.next; + +/* AML_INT_CONNECTION_OP can have a single argument */ + + arg =acpi_ps_get_arg (cur,0 ); +if (arg) { +acpi_ps_free_op (arg); + } + +acpi_ps_free_op (cur); + cur = next; + } +} +/******************************************************************************* * * FUNCTION: acpi_ps_get_next_arg
@@ -751,6 +786,10 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,while (parser_state->aml < parser_state->pkg_end) { field =acpi_ps_get_next_field (parser_state);if (!field) { +if (arg) { +acpi_ps_free_field_list (arg); + } +return_ACPI_STATUS (AE_NO_MEMORY ); }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 18/139 e1000e: avoid failing the system during pm_suspend
In reply to Sasha LevinFrom: Vitaly Lifshits <[email protected]>
[ Upstream commit 0a6ad4d9e1690c7faa3a53f762c877e477093657 ]
Occasionally when the system goes into pm_suspend, the suspend might fail due to a PHY access error on the network adapter. Previously, this would have caused the whole system to fail to go to a low power state. An example of this was reported in the following Bugzilla:
https://bugzilla.kernel.org/show_bug.cgi?id=205015
[ 1663.694828] e1000e 0000:00:19.0 eth0: Failed to disable ULP [ 1664.731040] asix 2-3:1.0 eth1: link up, 100Mbps, full-duplex, lpa 0xC1E1 [ 1665.093513] e1000e 0000:00:19.0 eth0: Hardware Error [ 1665.596760] e1000e 0000:00:19.0: pci_pm_resume+0x0/0x80 returned 0 after 2975399 usecs
and then the system never recovers from it, and all the following suspend failed due to this
[22909.393854] PM: pci_pm_suspend(): e1000e_pm_suspend+0x0/0x760 [e1000e] returns -2 [22909.393858] PM: dpm_run_callback(): pci_pm_suspend+0x0/0x160 returns -2 [22909.393861] PM: Device 0000:00:1f.6 failed to suspend async: error -2
This can be avoided by changing the return values of __e1000_shutdown and e1000e_pm_suspend functions so that they always return 0 (success). This is consistent with what other drivers do.
If the e1000e driver encounters a hardware error during suspend, potential side effects include slightly higher power draw or non-working wake on LAN. This is preferred to a system-level suspend failure, and a warning message is written to the system log, so that the user can be aware that the LAN controller experienced a problem during suspend.
--- drivers/net/ethernet/intel/e1000e/netdev.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/net/ethernet/intel/e1000e/netdev.c +11 -8
@@ -6672,8 +6672,10 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime)if (adapter->flags2 &FLAG2_HAS_PHY_WAKEUP ) {/* enable wakeup by the PHY */ retval =e1000_init_phy_wakeup (adapter, wufc); -if (retval) -return retval; +if (retval) { +e_err ("Failed to enable wakeup\n" ); + goto skip_phy_configurations; + } }else {/* enable wakeup by the MAC */ ew32 (WUFC , wufc);
@@ -6694,8 +6696,10 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime)* or broadcast. */ retval =e1000_enable_ulp_lpt_lp (hw, !runtime); -if (retval) -return retval; +if (retval) { +e_err ("Failed to enable ULP\n" ); + goto skip_phy_configurations; + } }/* Force SMBUS to allow WOL */
@@ -6744,6 +6748,7 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime) hw->phy.ops.release (hw); } +skip_phy_configurations:/* Release control of h/w to f/w. If f/w is AMT enabled, this * would have already happened in close and is redundant. */
@@ -6986,15 +6991,13 @@ static __maybe_unused int e1000e_pm_suspend(struct device *dev)e1000e_pm_freeze (dev); rc =__e1000_shutdown (pdev, false); -if (rc) { -e1000e_pm_thaw (dev); - }else { +if (!rc) {/* Introduce S0ix implementation */ if (adapter->flags2 &FLAG2_ENABLE_S0IX_FLOWS )e1000e_s0ix_entry_flow (adapter); } -return rc; +return 0 ; }static __maybe_unused int e1000e_pm_resume (struct device *dev)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 19/139 wifi: mt76: mt7915: disable tx worker during tx BA session enable/disable
In reply to Sasha LevinFrom: Felix Fietkau <[email protected]>
[ Upstream commit 256cbd26fbafb30ba3314339106e5c594e9bd5f9 ]
Avoids firmware race condition.
--- drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +7 -3
@@ -688,13 +688,17 @@ int mt7915_mcu_add_tx_ba(struct mt7915_dev *dev, {struct mt7915_sta *msta = (struct mt7915_sta *)params->sta->drv_priv;struct mt7915_vif *mvif = msta->vif; +int ret; +mt76_worker_disable (&dev->mt76.tx_worker);if (enable && !params->amsdu) msta->wcid.amsdu = false; + ret =mt76_connac_mcu_sta_ba (&dev->mt76, &mvif->mt76, params, +MCU_EXT_CMD (STA_REC_UPDATE ), + enable, true); +mt76_worker_enable (&dev->mt76.tx_worker); -return mt76_connac_mcu_sta_ba (&dev->mt76, &mvif->mt76, params, -MCU_EXT_CMD (STA_REC_UPDATE ), - enable, true); +return ret; } int mt7915_mcu_add_rx_ba(struct mt7915_dev *dev,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 20/139 net: sched: consistently use rcu_replace_pointer() in taprio_change()
In reply to Sasha LevinFrom: Dmitry Antipov <[email protected]>
[ Upstream commit d5c4546062fd6f5dbce575c7ea52ad66d1968678 ]
According to Vinicius (and carefully looking through the whole
https://syzkaller.appspot.com/bug?extid=b65e0af58423fc8a73aa
once again), txtime branch of 'taprio_change()' is not going to race against 'advance_sched()'. But using 'rcu_replace_pointer()' in the former may be a good idea as well.
--- net/sched/sch_taprio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/sched/sch_taprio.c +3 -1
@@ -1975,7 +1975,9 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt, goto unlock; } -rcu_assign_pointer (q->admin_sched, new_admin); +/* Not going to race against advance_sched(), but still */ + admin =rcu_replace_pointer (q->admin_sched, new_admin, +lockdep_rtnl_is_held ());if (admin)call_rcu (&admin->rcu, taprio_free_sched_cb); }else {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 21/139 Bluetooth: btusb: Add Realtek RTL8852C support ID 0x0489:0xe122
In reply to Sasha LevinFrom: Hilda Wu <[email protected]>
[ Upstream commit bdf9557f70e7512bb2f754abf90d9e9958745316 ]
Add the support ID (0x0489, 0xe122) to usb_device_id table for Realtek RTL8852C.
The device info from /sys/kernel/debug/usb/devices as below.
T: Bus=03 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#= 2 Spd=12 MxCh= 0 D: Ver= 1.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0489 ProdID=e122 Rev= 0.00 S: Manufacturer=Realtek S: Product=Bluetooth Radio S: SerialNumber=00e04c000001 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms
--- drivers/bluetooth/btusb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
@@ -537,6 +537,8 @@ static const struct usb_device_id quirks_table[] = { BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x13d3, 0x3592), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x0489, 0xe122), .driver_info = BTUSB_REALTEK | + BTUSB_WIDEBAND_SPEECH }, /* Realtek 8852BE Bluetooth devices */ { USB_DEVICE(0x0cb8, 0xc559), .driver_info = BTUSB_REALTEK |
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 22/139 Bluetooth: btrtl: Set msft ext address filter quirk for RTL8852B
In reply to Sasha LevinFrom: Hilda Wu <[email protected]>
[ Upstream commit 9a0570948c5def5c59e588dc0e009ed850a1f5a1 ]
For tracking multiple devices concurrently with a condition. The patch enables the HCI_QUIRK_USE_MSFT_EXT_ADDRESS_FILTER quirk on RTL8852B controller.
The quirk setting is based on commit 9e14606d8f38 ("Bluetooth: msft:
Extended monitor tracking by address filter")
With this setting, when a pattern monitor detects a device, this feature issues an address monitor for tracking that device. Let the original pattern monitor keep monitor new devices.
--- drivers/bluetooth/btrtl.c | 1 + 1 file changed, 1 insertion(+)
drivers/bluetooth/btrtl.c +1 -0
@@ -1285,6 +1285,7 @@ void btrtl_set_quirks(struct hci_dev *hdev, struct btrtl_device_info *btrtl_dev)btrealtek_set_flag (hdev,REALTEK_ALT6_CONTINUOUS_TX_CHIP );if (btrtl_dev->project_id ==CHIP_ID_8852A || + btrtl_dev->project_id ==CHIP_ID_8852B || btrtl_dev->project_id ==CHIP_ID_8852C )set_bit (HCI_QUIRK_USE_MSFT_EXT_ADDRESS_FILTER , &hdev->quirks);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 23/139 ACPI: video: Add force_vendor quirk for Panasonic Toughbook CF-18
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit eb7b0f12e13ba99e64e3a690c2166895ed63b437 ]
The Panasonic Toughbook CF-18 advertises both native and vendor backlight control interfaces. But only the vendor one actually works.
acpi_video_get_backlight_type() will pick the non working native backlight by default, add a quirk to select the working vendor backlight instead.
--- drivers/acpi/video_detect.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/acpi/video_detect.c +8 -0
@@ -260,6 +260,14 @@ static const struct dmi_system_id video_detect_dmi_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "PCG-FRV35"), }, }, + { + .callback = video_detect_force_vendor, + /* Panasonic Toughbook CF-18 */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Matsushita Electric Industrial"), + DMI_MATCH(DMI_PRODUCT_NAME, "CF-18"), + }, + },/* * Toshiba models with Transflective display, these need to use
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 24/139 ACPI: CPPC: Add support for setting EPP register in FFH
In reply to Sasha LevinFrom: Mario Limonciello <[email protected]>
[ Upstream commit aaf21ac93909e08a12931173336bdb52ac8499f1 ]
Some Asus AMD systems are reported to not be able to change EPP values because the BIOS doesn't advertise support for the CPPC MSR and the PCC region is not configured.
However the ACPI 6.2 specification allows CPC registers to be declared in FFH:
``` Starting with ACPI Specification 6.2, all _CPC registers can be in PCC, System Memory, System IO, or Functional Fixed Hardware address spaces. OSPM support for this more flexible register space scheme is indicated by the “Flexible Address Space for CPPC Registers” _OSC bit. ```
If this _OSC has been set allow using FFH to configure EPP.
--- drivers/acpi/cppc_acpi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/acpi/cppc_acpi.c +9 -1
@@ -100,6 +100,11 @@ static DEFINE_PER_CPU(struct cpc_desc *, cpc_desc_ptr); (cpc)->cpc_entry.reg.space_id == \ ACPI_ADR_SPACE_PLATFORM_COMM) +/* Check if a CPC register is in FFH */ +#define CPC_IN_FFH (cpc) ((cpc)->type == ACPI_TYPE_BUFFER && \ + (cpc)->cpc_entry.reg.space_id == \ + ACPI_ADR_SPACE_FIXED_HARDWARE) +/* Check if a CPC register is in SystemMemory */ #define CPC_IN_SYSTEM_MEMORY (cpc) ((cpc)->type == ACPI_TYPE_BUFFER && \ (cpc)->cpc_entry.reg.space_id == \
@@ -1479,9 +1484,12 @@ int cppc_set_epp_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls, bool enable)/* after writing CPC, transfer the ownership of PCC to platform */ ret =send_pcc_cmd (pcc_ss_id,CMD_WRITE );up_write (&pcc_ss_data->pcc_lock); + }else if (osc_cpc_flexible_adr_space_confirmed && +CPC_SUPPORTED (epp_set_reg) &&CPC_IN_FFH (epp_set_reg)) { + ret =cpc_write (cpu, epp_set_reg, perf_ctrls->energy_perf); }else { ret = -ENOTSUPP ; -pr_debug ("_CPC in PCC is not supported\n" ); +pr_debug ("_CPC in PCC and _CPC in FFH are not supported\n" ); }return ret;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 25/139 blk_iocost: fix more out of bound shifts
In reply to Sasha LevinFrom: Konstantin Ovsepian <[email protected]>
[ Upstream commit 9bce8005ec0dcb23a58300e8522fe4a31da606fa ]
Recently running UBSAN caught few out of bound shifts in the ioc_forgive_debts() function:
UBSAN: shift-out-of-bounds in block/blk-iocost.c:2142:38 shift exponent 80 is too large for 64-bit type 'u64' (aka 'unsigned long long') ... UBSAN: shift-out-of-bounds in block/blk-iocost.c:2144:30 shift exponent 80 is too large for 64-bit type 'u64' (aka 'unsigned long long') ... Call Trace: <IRQ> dump_stack_lvl+0xca/0x130 __ubsan_handle_shift_out_of_bounds+0x22c/0x280 ? __lock_acquire+0x6441/0x7c10 ioc_timer_fn+0x6cec/0x7750 ? blk_iocost_init+0x720/0x720 ? call_timer_fn+0x5d/0x470 call_timer_fn+0xfa/0x470 ? blk_iocost_init+0x720/0x720 __run_timer_base+0x519/0x700
...
Actual impact of this issue was not identified but I propose to fix the undefined behaviour.
The proposed fix to prevent those out of bound shifts consist of precalculating exponent before using it the shift operations by taking min value from the actual exponent and maximum possible number of bits.
--- block/blk-iocost.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
block/blk-iocost.c +5 -3
@@ -2076,7 +2076,7 @@ static void ioc_forgive_debts(struct ioc *ioc, u64 usage_us_sum, int nr_debtors, struct ioc_now *now) {struct ioc_gq *iocg; -u64 dur, usage_pct, nr_cycles; +u64 dur, usage_pct, nr_cycles, nr_cycles_shift;/* if no debtor, reset the cycle */ if (!nr_debtors) {
@@ -2138,10 +2138,12 @@ static void ioc_forgive_debts(struct ioc *ioc, u64 usage_us_sum, int nr_debtors, old_debt = iocg->abs_vdebt; old_delay = iocg->delay; + nr_cycles_shift =min_t (u64, nr_cycles,BITS_PER_LONG -1 );if (iocg->abs_vdebt) - iocg->abs_vdebt = iocg->abs_vdebt >> nr_cycles ?:1 ; + iocg->abs_vdebt = iocg->abs_vdebt >> nr_cycles_shift ?:1 ; +if (iocg->delay) - iocg->delay = iocg->delay >> nr_cycles ?:1 ; + iocg->delay = iocg->delay >> nr_cycles_shift ?:1 ;iocg_kick_waitq (iocg, true, now);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 26/139 nvme-pci: qdepth 1 quirk
In reply to Sasha LevinFrom: Keith Busch <[email protected]>
[ Upstream commit 83bdfcbdbe5d901c5fa432decf12e1725a840a56 ]
Another device has been reported to be unreliable if we have more than one outstanding command. In this new case, data corruption may occur. Since we have two devices now needing this quirky behavior, make a generic quirk flag.
The same Apple quirk is clearly not "temporary", so update the comment while moving it.
--- drivers/nvme/host/nvme.h | 5 +++++ drivers/nvme/host/pci.c | 18 +++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-)
drivers/nvme/host/nvme.h +5 -0
@@ -88,6 +88,11 @@ enum nvme_quirks {*/ NVME_QUIRK_NO_DEEPEST_PS = (1 <<5 ), +/* +* Problems seen with concurrent commands +*/ + NVME_QUIRK_QDEPTH_ONE = (1 << 6), +/* * Set MEDIUM priority on SQ creation */
drivers/nvme/host/pci.c +9 -9
@@ -2526,15 +2526,8 @@ static int nvme_pci_enable(struct nvme_dev *dev)else dev->io_sqes =NVME_NVM_IOSQES ; -/* -* Temporary fix for the Apple controller found in the MacBook8,1 and -* some MacBook7,1 to avoid controller resets and data loss. -*/ -if (pdev->vendor ==PCI_VENDOR_ID_APPLE && pdev->device ==0x2001 ) { +if (dev->ctrl.quirks &NVME_QUIRK_QDEPTH_ONE ) { dev->q_depth =2 ; -dev_warn (dev->ctrl.device,"detected Apple NVMe controller, " -"set queue depth=%u to work around controller resets\n" , - dev->q_depth); }else if (pdev->vendor ==PCI_VENDOR_ID_SAMSUNG && (pdev->device ==0xa821 || pdev->device ==0xa822 ) &&NVME_CAP_MQES (dev->ctrl.cap) ==0 ) {
@@ -3399,6 +3392,8 @@ static const struct pci_device_id nvme_id_table[] = { NVME_QUIRK_BOGUS_NID, }, { PCI_VDEVICE(REDHAT, 0x0010), /* Qemu emulated controller */ .driver_data = NVME_QUIRK_BOGUS_NID, }, + { PCI_DEVICE(0x1217, 0x8760), /* O2 Micro 64GB Steam Deck */ + .driver_data = NVME_QUIRK_QDEPTH_ONE }, { PCI_DEVICE(0x126f, 0x2262), /* Silicon Motion generic */ .driver_data = NVME_QUIRK_NO_DEEPEST_PS | NVME_QUIRK_BOGUS_NID, },
@@ -3531,7 +3526,12 @@ static const struct pci_device_id nvme_id_table[] = { { PCI_DEVICE(PCI_VENDOR_ID_AMAZON, 0xcd02), .driver_data = NVME_QUIRK_DMA_ADDRESS_BITS_48, }, { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2001), - .driver_data = NVME_QUIRK_SINGLE_VECTOR }, +/* +* Fix for the Apple controller found in the MacBook8,1 and +* some MacBook7,1 to avoid controller resets and data loss. +*/ + .driver_data = NVME_QUIRK_SINGLE_VECTOR | + NVME_QUIRK_QDEPTH_ONE }, { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2003) }, { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2005), .driver_data = NVME_QUIRK_SINGLE_VECTOR |
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 27/139 wifi: ath12k: fix array out-of-bound access in SoC stats
In reply to Sasha LevinFrom: Karthikeyan Periyasamy <[email protected]>
[ Upstream commit e106b7ad13c1d246adaa57df73edb8f8b8acb240 ]
Currently, the ath12k_soc_dp_stats::hal_reo_error array is defined with a maximum size of DP_REO_DST_RING_MAX. However, the ath12k_dp_rx_process() function access ath12k_soc_dp_stats::hal_reo_error using the REO destination SRNG ring ID, which is incorrect. SRNG ring ID differ from normal ring ID, and this usage leads to out-of-bounds array access. To fix this issue, modify ath12k_dp_rx_process() to use the normal ring ID directly instead of the SRNG ring ID to avoid out-of-bounds array access.
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath12k/dp_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath12k/dp_rx.c +1 -1
@@ -2670,7 +2670,7 @@ int ath12k_dp_rx_process(struct ath12k_base *ab, int ring_id,if (push_reason !=HAL_REO_DEST_RING_PUSH_REASON_ROUTING_INSTRUCTION ) {dev_kfree_skb_any (msdu); - ab->soc_stats.hal_reo_error[dp->reo_dst_ring[ring_id].ring_id]++; + ab->soc_stats.hal_reo_error[ring_id]++;continue ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 28/139 wifi: ath11k: fix array out-of-bound access in SoC stats
In reply to Sasha LevinFrom: Karthikeyan Periyasamy <[email protected]>
[ Upstream commit 69f253e46af98af17e3efa3e5dfa72fcb7d1983d ]
Currently, the ath11k_soc_dp_stats::hal_reo_error array is defined with a maximum size of DP_REO_DST_RING_MAX. However, the ath11k_dp_process_rx() function access ath11k_soc_dp_stats::hal_reo_error using the REO destination SRNG ring ID, which is incorrect. SRNG ring ID differ from normal ring ID, and this usage leads to out-of-bounds array access. To fix this issue, modify ath11k_dp_process_rx() to use the normal ring ID directly instead of the SRNG ring ID to avoid out-of-bounds array access.
Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath11k/dp_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath11k/dp_rx.c +1 -1
@@ -2700,7 +2700,7 @@ int ath11k_dp_process_rx(struct ath11k_base *ab, int ring_id,if (unlikely (push_reason !=HAL_REO_DEST_RING_PUSH_REASON_ROUTING_INSTRUCTION )) {dev_kfree_skb_any (msdu); - ab->soc_stats.hal_reo_error[dp->reo_dst_ring[ring_id].ring_id]++; + ab->soc_stats.hal_reo_error[ring_id]++;continue ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 29/139 wifi: rtw88: select WANT_DEV_COREDUMP
In reply to Sasha LevinFrom: Zong-Zhe Yang <[email protected]>
[ Upstream commit 7e989b0c1e33210c07340bf5228aa83ea52515b5 ]
We have invoked device coredump when fw crash.
Should select WANT_DEV_COREDUMP by ourselves.
--- drivers/net/wireless/realtek/rtw88/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/realtek/rtw88/Kconfig +1 -0
@@ -12,6 +12,7 @@ if RTW88 config RTW88_CORE tristate + select WANT_DEV_COREDUMP config RTW88_PCI tristate
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 30/139 l2tp: don't use tunnel socket sk_user_data in ppp procfs output
In reply to Sasha LevinFrom: James Chapman <[email protected]>
[ Upstream commit eeb11209e000797d555aefd642e24ed6f4e70140 ]
l2tp's ppp procfs output can be used to show internal state of pppol2tp. It includes a 'user-data-ok' field, which is derived from the tunnel socket's sk_user_data being non-NULL. Use tunnel->sock being non-NULL to indicate this instead.
--- net/l2tp/l2tp_ppp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/l2tp/l2tp_ppp.c +1 -1
@@ -1511,7 +1511,7 @@ static void pppol2tp_seq_tunnel_show(struct seq_file *m, void *v)seq_printf (m,"\nTUNNEL '%s', %c %d\n" , tunnel->name, - (tunnel == tunnel->sock->sk_user_data) ?'Y' :'N' , + tunnel->sock ?'Y' :'N' ,refcount_read (&tunnel->ref_count) -1 ); seq_printf(m, " %08x %ld/%ld/%ld %ld/%ld/%ld\n", 0,
Signature · 1 line
2.43.0
Re: [PATCH AUTOSEL 6.6 030/139] l2tp: don't use tunnel socket sk_user_data in ppp procfs output
Quoted 22 lines · Sasha Levin
From: James Chapman <[email protected]>
[ Upstream commit
eeb11209e000797d555aefd642e24ed6f4e70140]l2tp's ppp procfs output can be used to show internal state of pppol2tp. It includes a 'user-data-ok' field, which is derived from the tunnel socket's
sk_user_databeing non-NULL. Usetunnel->sockbeing non-NULL to indicate this instead.Signed-off-by James Chapman <[email protected]>Signed-off-by Tom Parkin <[email protected]>Signed-off-by David S. Miller <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- net/l2tp/l2tp_ppp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/l2tp/l2tp_ppp.c +0
-0
net/l2tp/l2tp_ppp.c static void pppol2tp_seq_tunnel_show(struct seq_file *m, void *v) · line 1517
Quoted 8 lines
net/l2tp/l2tp_ppp.c +1
-1@@ -1511,7 +1511,7 @@ static void pppol2tp_seq_tunnel_show(struct seq_file *m, void *v)seq_printf (m,"\nTUNNEL '%s', %c %d\n" , tunnel->name, - (tunnel == tunnel->sock->sk_user_data) ?'Y' :'N' , + tunnel->sock ?'Y' :'N' ,refcount_read (&tunnel->ref_count) -1 ); seq_printf(m, " %08x %ld/%ld/%ld %ld/%ld/%ld\n", 0,
This change isn't needed in 6.6. The commit was part of a series for 6.12 that removed use of sk_user_data in l2tp tunnel sockets.
Sasha Levin
maintainerRe: [PATCH AUTOSEL 6.6 030/139] l2tp: don't use tunnel socket sk_user_data in ppp procfs output
Quoted 18 lines · James Chapman
Quoted 17 lines · Sasha Levin
From: James Chapman <[email protected]>
[ Upstream commit
eeb11209e000797d555aefd642e24ed6f4e70140]l2tp's ppp procfs output can be used to show internal state of pppol2tp. It includes a 'user-data-ok' field, which is derived from the tunnel socket's
sk_user_databeing non-NULL. Usetunnel->sockbeing non-NULL to indicate this instead.Signed-off-by James Chapman <[email protected]>Signed-off-by Tom Parkin <[email protected]>Signed-off-by David S. Miller <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- net/l2tp/l2tp_ppp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines
net/l2tp/l2tp_ppp.c static void pppol2tp_seq_tunnel_show(struct seq_file *m, void *v) · line 1516
Quoted 12 lines
net/l2tp/l2tp_ppp.c +1
-1@@ -1511,7 +1511,7 @@ static void pppol2tp_seq_tunnel_show(struct seq_file *m, void *v)seq_printf (m,"\nTUNNEL '%s', %c %d\n" , tunnel->name, - (tunnel == tunnel->sock->sk_user_data) ?'Y' :'N' , + tunnel->sock ?'Y' :'N' ,refcount_read (&tunnel->ref_count) -1 ); seq_printf(m, " %08x %ld/%ld/%ld %ld/%ld/%ld\n", 0,This change isn't needed in 6.6. The commit was part of a series for 6.12 that removed use of
sk_user_datain l2tp tunnel sockets.
I'll drop it, thanks!
Signature · 2 lines
Thanks, Sasha
Sasha Levin
maintainerPATCH 31/139 ACPI: EC: Do not release locks during operation region accesses
In reply to Sasha LevinFrom: "Rafael J. Wysocki" <[email protected]>
[ Upstream commit dc171114926ec390ab90f46534545420ec03e458 ]
It is not particularly useful to release locks (the EC mutex and the ACPI global lock, if present) and re-acquire them immediately thereafter during EC address space accesses in acpi_ec_space_handler().
First, releasing them for a while before grabbing them again does not really help anyone because there may not be enough time for another thread to acquire them.
Second, if another thread successfully acquires them and carries out a new EC write or read in the middle if an operation region access in progress, it may confuse the EC firmware, especially after the burst mode has been enabled.
Finally, manipulating the locks after writing or reading every single byte of data is overhead that it is better to avoid.
Accordingly, modify the code to carry out EC address space accesses entirely without releasing the locks.
--- drivers/acpi/ec.c | 55 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 6 deletions(-)
drivers/acpi/ec.c +49 -6
@@ -783,6 +783,9 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec,unsigned long tmp;int ret =0 ; +if (t->rdata) +memset (t->rdata,0 , t->rlen); +/* start transaction */ spin_lock_irqsave (&ec->lock, tmp);/* Enable GPE for command processing (IBF=0/OBF=1) */
@@ -819,8 +822,6 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t)if (!ec || (!t) || (t->wlen && !t->wdata) || (t->rlen && !t->rdata))return -EINVAL ; -if (t->rdata) -memset (t->rdata,0 , t->rlen);mutex_lock (&ec->mutex);if (ec->global_lock) {
@@ -847,7 +848,7 @@ static int acpi_ec_burst_enable(struct acpi_ec *ec) .wdata = NULL, .rdata = &d, .wlen = 0, .rlen = 1}; -return acpi_ec_transaction (ec, &t); +return acpi_ec_transaction_unlocked (ec, &t); }static int acpi_ec_burst_disable (struct acpi_ec *ec)
@@ -857,7 +858,7 @@ static int acpi_ec_burst_disable(struct acpi_ec *ec) .wlen = 0, .rlen = 0};return (acpi_ec_read_status (ec) &ACPI_EC_FLAG_BURST ) ? -acpi_ec_transaction (ec, &t) :0 ; +acpi_ec_transaction_unlocked (ec, &t) :0 ; }static int acpi_ec_read (struct acpi_ec *ec,u8 address,u8 *data)
@@ -873,6 +874,19 @@ static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 *data)return result; } +static int acpi_ec_read_unlocked (struct acpi_ec *ec,u8 address,u8 *data) +{ +int result; +u8 d; +struct transaction t = {.command =ACPI_EC_COMMAND_READ , + .wdata = &address, .rdata = &d, + .wlen =1 , .rlen =1 }; + + result =acpi_ec_transaction_unlocked (ec, &t); + *data = d; +return result; +} +static int acpi_ec_write (struct acpi_ec *ec,u8 address,u8 data) {u8 wdata[2 ] = { address, data };
@@ -883,6 +897,16 @@ static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data)return acpi_ec_transaction (ec, &t); } +static int acpi_ec_write_unlocked (struct acpi_ec *ec,u8 address,u8 data) +{ +u8 wdata[2 ] = { address, data }; +struct transaction t = {.command =ACPI_EC_COMMAND_WRITE , + .wdata = wdata, .rdata =NULL , + .wlen =2 , .rlen =0 }; + +return acpi_ec_transaction_unlocked (ec, &t); +} +int ec_read (u8 addr,u8 *val) {int err;
@@ -1323,6 +1347,7 @@ acpi_ec_space_handler(u32 function, acpi_physical_address address,struct acpi_ec *ec = handler_context;int result =0 , i, bytes = bits /8 ;u8 *value = (u8 *)value64; +u32 glk;if ((address >0xFF ) || !value || !handler_context)return AE_BAD_PARAMETER ;
@@ -1330,13 +1355,25 @@ acpi_ec_space_handler(u32 function, acpi_physical_address address,if (function !=ACPI_READ && function !=ACPI_WRITE )return AE_BAD_PARAMETER ; +mutex_lock (&ec->mutex); + +if (ec->global_lock) { +acpi_status status; + + status =acpi_acquire_global_lock (ACPI_EC_UDELAY_GLK , &glk); +if (ACPI_FAILURE (status)) { + result = -ENODEV ; + goto unlock; + } + } +if (ec->busy_polling || bits >8 )acpi_ec_burst_enable (ec);for (i =0 ; i < bytes; ++i, ++address, ++value) { result = (function ==ACPI_READ ) ? -acpi_ec_read (ec, address, value) : -acpi_ec_write (ec, address, *value); +acpi_ec_read_unlocked (ec, address, value) : +acpi_ec_write_unlocked (ec, address, *value);if (result <0 )break ; }
@@ -1344,6 +1381,12 @@ acpi_ec_space_handler(u32 function, acpi_physical_address address,if (ec->busy_polling || bits >8 )acpi_ec_burst_disable (ec); +if (ec->global_lock) +acpi_release_global_lock (glk); + +unlock: +mutex_unlock (&ec->mutex); +switch (result) {case -EINVAL :return AE_BAD_PARAMETER ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 32/139 ACPICA: check null return of ACPI_ALLOCATE_ZEROED() in acpi_db_convert_to_package()
In reply to Sasha LevinFrom: Pei Xiao <[email protected]>
[ Upstream commit a5242874488eba2b9062985bf13743c029821330 ]
ACPICA commit 4d4547cf13cca820ff7e0f859ba83e1a610b9fd0
ACPI_ALLOCATE_ZEROED() may fail, elements might be NULL and will cause NULL pointer dereference later.
--- drivers/acpi/acpica/dbconvert.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/acpi/acpica/dbconvert.c +2 -0
@@ -174,6 +174,8 @@ acpi_status acpi_db_convert_to_package(char *string, union acpi_object *object) elements =ACPI_ALLOCATE_ZEROED (DB_DEFAULT_PKG_ELEMENTS *sizeof (union acpi_object )); +if (!elements) +return (AE_NO_MEMORY ); this = string;for (i =0 ; i < (DB_DEFAULT_PKG_ELEMENTS -1 ); i++) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 33/139 tipc: guard against string buffer overrun
In reply to Sasha LevinFrom: Simon Horman <[email protected]>
[ Upstream commit 6555a2a9212be6983d2319d65276484f7c5f431a ]
Smatch reports that copying media_name and if_name to name_parts may overwrite the destination.
.../bearer.c:166 bearer_name_validate() error: strcpy() 'media_name' too large for 'name_parts->media_name' (32 vs 16) .../bearer.c:167 bearer_name_validate() error: strcpy() 'if_name' too large for 'name_parts->if_name' (1010102 vs 16)
This does seem to be the case so guard against this possibility by using strscpy() and failing if truncation occurs.
Introduced by commit b97bf3fd8f6a ("[TIPC] Initial merge")
Compile tested only.
--- net/tipc/bearer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
net/tipc/bearer.c +6 -2
@@ -163,8 +163,12 @@ static int bearer_name_validate(const char *name,/* return bearer name components, if necessary */ if (name_parts) { -strcpy (name_parts->media_name, media_name); -strcpy (name_parts->if_name, if_name); +if (strscpy (name_parts->media_name, media_name, +TIPC_MAX_MEDIA_NAME ) <0 ) +return 0 ; +if (strscpy (name_parts->if_name, if_name, +TIPC_MAX_IF_NAME ) <0 ) +return 0 ; }return 1 ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 34/139 net: mvpp2: Increase size of queue_name buffer
In reply to Sasha LevinFrom: Simon Horman <[email protected]>
[ Upstream commit 91d516d4de48532d967a77967834e00c8c53dfe6 ]
Increase size of queue_name buffer from 30 to 31 to accommodate the largest string written to it. This avoids truncation in the possibly unlikely case where the string is name is the maximum size.
Flagged by gcc-14:
.../mvpp2_main.c: In function 'mvpp2_probe':
.../mvpp2_main.c:7636:32: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
7636 | "stats-wq-%s%s", netdev_name(priv->port_list[0]->dev),
| ^
.../mvpp2_main.c:7635:9: note: 'snprintf' output between 10 and 31 bytes into a destination of size 30
7635 | snprintf(priv->queue_name, sizeof(priv->queue_name),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7636 | "stats-wq-%s%s", netdev_name(priv->port_list[0]->dev),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7637 | priv->port_count > 1 ? "+" : "");
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Introduced by commit 118d6298f6f0 ("net: mvpp2: add ethtool GOP statistics"). I am not flagging this as a bug as I am not aware that it is one.
Compile tested only.
--- drivers/net/ethernet/marvell/mvpp2/mvpp2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2.h +1 -1
@@ -1088,7 +1088,7 @@ struct mvpp2 {unsigned int max_port_rxqs;/* Workqueue to gather hardware statistics */ -char queue_name[30 ]; +char queue_name[31 ];struct workqueue_struct *stats_queue;/* Debugfs root entry */
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 35/139 bnxt_en: Extend maximum length of version string by 1 byte
In reply to Sasha LevinFrom: Simon Horman <[email protected]>
[ Upstream commit ffff7ee843c351ce71d6e0d52f0f20bea35e18c9 ]
This corrects an out-by-one error in the maximum length of the package version string. The size argument of snprintf includes space for the trailing '\0' byte, so there is no need to allow extra space for it by reducing the value of the size argument by 1.
Found by inspection.
Compile tested only.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +1 -1
@@ -3021,7 +3021,7 @@ static void bnxt_get_pkgver(struct net_device *dev)if (!bnxt_get_pkginfo (dev, buf,sizeof (buf))) { len =strlen (bp->fw_ver_str); -snprintf (bp->fw_ver_str + len,FW_VER_STR_LEN - len -1 , +snprintf (bp->fw_ver_str + len,FW_VER_STR_LEN - len,"/pkg %s" , buf); } }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 36/139 ipv4: Check !in_dev earlier for ioctl(SIOCSIFADDR).
In reply to Sasha LevinFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit e3af3d3c5b26c33a7950e34e137584f6056c4319 ]
dev->ip_ptr could be NULL if we set an invalid MTU.
Even then, if we issue ioctl(SIOCSIFADDR) for a new IPv4 address, devinet_ioctl() allocates struct in_ifaddr and fails later in inet_set_ifa() because in_dev is NULL.
Let's move the check earlier.
--- net/ipv4/devinet.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
net/ipv4/devinet.c +2 -4
@@ -569,10 +569,6 @@ static int inet_set_ifa(struct net_device *dev, struct in_ifaddr *ifa)ASSERT_RTNL (); -if (!in_dev) { -inet_free_ifa (ifa); -return -ENOBUFS ; - }ipv4_devconf_setall (in_dev);neigh_parms_data_state_setall (in_dev->arp_parms);if (ifa->ifa_dev != in_dev) {
@@ -1174,6 +1170,8 @@ int devinet_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr)if (!ifa) { ret = -ENOBUFS ; +if (!in_dev) +break ; ifa =inet_alloc_ifa ();if (!ifa)break ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 37/139 wifi: rtw89: correct base HT rate mask for firmware
In reply to Sasha LevinFrom: Ping-Ke Shih <[email protected]>
[ Upstream commit 45742881f9eee2a4daeb6008e648a460dd3742cd ]
Coverity reported that u8 rx_mask << 24 will become signed 32 bits, which casting to unsigned 64 bits will do sign extension. For example, putting 0x80000000 (signed 32 bits) to a u64 variable will become 0xFFFFFFFF_80000000.
The real case we meet is:
rx_mask[0...3] = ff ff 00 00
ra_mask = 0xffffffff_ff0ff000
After this fix:
rx_mask[0...3] = ff ff 00 00
ra_mask = 0x00000000_ff0ff000
Fortunately driver does bitwise-AND with incorrect ra_mask and supported rates (1ss and 2ss rate only) afterward, so the final rate mask of original code is still correct.
Addresses-Coverity-ID: 1504762 ("Unintended sign extension")
--- drivers/net/wireless/realtek/rtw89/phy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtw89/phy.c +2 -2
@@ -284,8 +284,8 @@ static void rtw89_phy_ra_sta_update(struct rtw89_dev *rtwdev, csi_mode =RTW89_RA_RPT_MODE_HT ; ra_mask |= ((u64 )sta->deflink.ht_cap.mcs.rx_mask[3 ] <<48 ) | ((u64 )sta->deflink.ht_cap.mcs.rx_mask[2 ] <<36 ) | - (sta->deflink.ht_cap.mcs.rx_mask[1 ] <<24 ) | - (sta->deflink.ht_cap.mcs.rx_mask[0 ] <<12 ); + ((u64 )sta->deflink.ht_cap.mcs.rx_mask[1 ] <<24 ) | + ((u64 )sta->deflink.ht_cap.mcs.rx_mask[0 ] <<12 ); high_rate_masks = rtw89_ra_mask_ht_rates;if (sta->deflink.ht_cap.cap &IEEE80211_HT_CAP_RX_STBC ) stbc_en =1 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 38/139 netfilter: nf_tables: don't initialize registers in nft_do_chain()
In reply to Sasha LevinFrom: Florian Westphal <[email protected]>
[ Upstream commit c88baabf16d1ef74ab8832de9761226406af5507 ]
revert commit 4c905f6740a3 ("netfilter: nf_tables: initialize registers in nft_do_chain()").
Previous patch makes sure that loads from uninitialized registers are detected from the control plane. in this case rule blob auto-zeroes registers. Thus the explicit zeroing is not needed anymore.
--- net/netfilter/nf_tables_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_tables_core.c +1 -1
@@ -256,7 +256,7 @@ nft_do_chain(struct nft_pktinfo *pkt, void *priv)const struct net *net =nft_net (pkt);const struct nft_expr *expr, *last;const struct nft_rule_dp *rule; -struct nft_regs regs = {}; +struct nft_regs regs;unsigned int stackptr =0 ;struct nft_jumpstack jumpstack[NFT_JUMP_STACK_SIZE ];bool genbit =READ_ONCE (net->nft.gencursor);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 39/139 ipv4: Mask upper DSCP bits and ECN bits in NETLINK_FIB_LOOKUP family
In reply to Sasha LevinFrom: Ido Schimmel <[email protected]>
[ Upstream commit 8fed54758cd248cd311a2b5c1e180abef1866237 ]
The NETLINK_FIB_LOOKUP netlink family can be used to perform a FIB lookup according to user provided parameters and communicate the result back to user space.
However, unlike other users of the FIB lookup API, the upper DSCP bits and the ECN bits of the DS field are not masked, which can result in the wrong result being returned.
Solve this by masking the upper DSCP bits and the ECN bits using IPTOS_RT_MASK.
The structure that communicates the request and the response is not exported to user space, so it is unlikely that this netlink family is actually in use [1].
[1] https://lore.kernel.org/netdev/ZpqpB8vJU%2FQ6LSqa@debian/
--- net/ipv4/fib_frontend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/fib_frontend.c +1 -1
@@ -1343,7 +1343,7 @@ static void nl_fib_lookup(struct net *net, struct fib_result_nl *frn)struct flowi4 fl4 = { .flowi4_mark = frn->fl_mark, .daddr = frn->fl_addr, - .flowi4_tos = frn->fl_tos, + .flowi4_tos = frn->fl_tos &IPTOS_RT_MASK , .flowi4_scope = frn->fl_scope, };struct fib_table *tb;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 40/139 net: atlantic: Avoid warning about potential string truncation
In reply to Sasha LevinFrom: Simon Horman <[email protected]>
[ Upstream commit 5874e0c9f25661c2faefe4809907166defae3d7f ]
W=1 builds with GCC 14.2.0 warn that:
.../aq_ethtool.c:278:59: warning: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 6 [-Wformat-truncation=]
278 | snprintf(tc_string, 8, "TC%d ", tc);
| ^~.../aq_ethtool.c:278:56: note: directive argument in the range [-2147483641, 254]
278 | snprintf(tc_string, 8, "TC%d ", tc);
| ^~~~~~~.../aq_ethtool.c:278:33: note: ‘snprintf’ output between 5 and 15 bytes into a destination of size 8
278 | snprintf(tc_string, 8, "TC%d ", tc);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~tc is always in the range 0 - cfg->tcs. And as cfg->tcs is a u8, the range is 0 - 255. Further, on inspecting the code, it seems that cfg->tcs will never be more than AQ_CFG_TCS_MAX (8), so the range is actually 0 - 8.
So, it seems that the condition that GCC flags will not occur. But, nonetheless, it would be nice if it didn't emit the warning.
It seems that this can be achieved by changing the format specifier from %d to %u, in which case I believe GCC recognises an upper bound on the range of tc of 0 - 255. After some experimentation I think this is due to the combination of the use of %u and the type of cfg->tcs (u8).
Empirically, updating the type of the tc variable to unsigned int has the same effect.
As both of these changes seem to make sense in relation to what the code is actually doing - iterating over unsigned values - do both.
Compile tested only.
--- drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c +2 -2
@@ -265,7 +265,7 @@ static void aq_ethtool_get_strings(struct net_device *ndev,const int rx_stat_cnt =ARRAY_SIZE (aq_ethtool_queue_rx_stat_names);const int tx_stat_cnt =ARRAY_SIZE (aq_ethtool_queue_tx_stat_names);char tc_string[8 ]; -int tc; +unsigned int tc;memset (tc_string,0 ,sizeof (tc_string)); memcpy(p, aq_ethtool_stat_names,
@@ -274,7 +274,7 @@ static void aq_ethtool_get_strings(struct net_device *ndev,for (tc =0 ; tc < cfg->tcs; tc++) {if (cfg->is_qos) -snprintf (tc_string,8 ,"TC%d " , tc); +snprintf (tc_string,8 ,"TC%u " , tc);for (i =0 ; i < cfg->vecs; i++) {for (si =0 ; si < rx_stat_cnt; si++) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 41/139 crypto: simd - Do not call crypto_alloc_tfm during registration
In reply to Sasha LevinFrom: Herbert Xu <[email protected]>
[ Upstream commit 3c44d31cb34ce4eb8311a2e73634d57702948230 ]
Algorithm registration is usually carried out during module init, where as little work as possible should be carried out. The SIMD code violated this rule by allocating a tfm, this then triggers a full test of the algorithm which may dead-lock in certain cases.
SIMD is only allocating the tfm to get at the alg object, which is in fact already available as it is what we are registering. Use that directly and remove the crypto_alloc_tfm call.
Also remove some obsolete and unused SIMD API.
--- arch/arm/crypto/aes-ce-glue.c | 2 +- arch/arm/crypto/aes-neonbs-glue.c | 2 +- crypto/simd.c | 76 ++++++------------------------- include/crypto/internal/simd.h | 12 +---- 4 files changed, 19 insertions(+), 73 deletions(-)
arch/arm/crypto/aes-ce-glue.c +1 -1
@@ -711,7 +711,7 @@ static int __init aes_init(void) algname = aes_algs[i].base.cra_name +2 ; drvname = aes_algs[i].base.cra_driver_name +2 ; basename = aes_algs[i].base.cra_driver_name; - simd =simd_skcipher_create_compat (algname, drvname, basename); + simd =simd_skcipher_create_compat (aes_algs + i, algname, drvname, basename); err =PTR_ERR (simd);if (IS_ERR (simd)) goto unregister_simds;
arch/arm/crypto/aes-neonbs-glue.c +1 -1
@@ -539,7 +539,7 @@ static int __init aes_init(void) algname = aes_algs[i].base.cra_name +2 ; drvname = aes_algs[i].base.cra_driver_name +2 ; basename = aes_algs[i].base.cra_driver_name; - simd =simd_skcipher_create_compat (algname, drvname, basename); + simd =simd_skcipher_create_compat (aes_algs + i, algname, drvname, basename); err =PTR_ERR (simd);if (IS_ERR (simd)) goto unregister_simds;
crypto/simd.c +15 -61
149 lines not on this page · raw message
include/crypto/internal/simd.h +2 -10
@@ -14,11 +14,10 @@struct simd_skcipher_alg ;struct skcipher_alg ; -struct simd_skcipher_alg *simd_skcipher_create_compat (const char *algname, +struct simd_skcipher_alg *simd_skcipher_create_compat (struct skcipher_alg *ialg, +const char *algname,const char *drvname,const char *basename); -struct simd_skcipher_alg *simd_skcipher_create (const char *algname, -const char *basename);void simd_skcipher_free (struct simd_skcipher_alg *alg); int simd_register_skciphers_compat(struct skcipher_alg *algs, int count,
@@ -32,13 +31,6 @@ void simd_unregister_skciphers(struct skcipher_alg *algs, int count,struct simd_aead_alg ;struct aead_alg ; -struct simd_aead_alg *simd_aead_create_compat (const char *algname, -const char *drvname, -const char *basename); -struct simd_aead_alg *simd_aead_create (const char *algname, -const char *basename); -void simd_aead_free (struct simd_aead_alg *alg); -int simd_register_aeads_compat (struct aead_alg *algs,int count,struct simd_aead_alg **simd_algs);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 42/139 netpoll: Ensure clean state on setup failures
In reply to Sasha LevinFrom: Breno Leitao <[email protected]>
[ Upstream commit ae5a0456e0b4cfd7e61619e55251ffdf1bc7adfb ]
Modify netpoll_setup() and __netpoll_setup() to ensure that the netpoll structure (np) is left in a clean state if setup fails for any reason. This prevents carrying over misconfigured fields in case of partial setup success.
Key changes:
- np->dev is now set only after successful setup, ensuring it's always NULL if netpoll is not configured or if netpoll_setup() fails.
- np->local_ip is zeroed if netpoll setup doesn't complete successfully.
- Added DEBUG_NET_WARN_ON_ONCE() checks to catch unexpected states.
- Reordered some operations in __netpoll_setup() for better logical flow.
These changes improve the reliability of netpoll configuration, since it assures that the structure is fully initialized or totally unset.
--- net/core/netpoll.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
net/core/netpoll.c +10 -5
@@ -626,12 +626,9 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev)const struct net_device_ops *ops;int err; - np->dev = ndev; -strscpy (np->dev_name, ndev->name,IFNAMSIZ ); -if (ndev->priv_flags &IFF_DISABLE_NETPOLL ) {np_err (np,"%s doesn't support polling, aborting\n" , - np->dev_name); + ndev->name); err = -ENOTSUPP ; goto out; }
@@ -649,7 +646,7 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev)refcount_set (&npinfo->refcnt,1 ); - ops = np->dev->netdev_ops; + ops = ndev->netdev_ops;if (ops->ndo_netpoll_setup) { err = ops->ndo_netpoll_setup (ndev, npinfo);if (err)
@@ -660,6 +657,8 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev)refcount_inc (&npinfo->refcnt); } + np->dev = ndev; +strscpy (np->dev_name, ndev->name,IFNAMSIZ ); npinfo->netpoll = np;/* last thing to do is link it to the net device structure */
@@ -677,6 +676,7 @@ EXPORT_SYMBOL_GPL(__netpoll_setup);int netpoll_setup (struct netpoll *np) {struct net_device *ndev =NULL ; +bool ip_overwritten = false;struct in_device *in_dev;int err;
@@ -741,6 +741,7 @@ int netpoll_setup(struct netpoll *np) } np->local_ip.ip = ifa->ifa_local; + ip_overwritten = true;np_info (np,"local IP %pI4\n" , &np->local_ip.ip); }else {#if IS_ENABLED (CONFIG_IPV6 )
@@ -757,6 +758,7 @@ int netpoll_setup(struct netpoll *np) !!(ipv6_addr_type(&np->remote_ip.in6) & IPV6_ADDR_LINKLOCAL)) continue; np->local_ip.in6 = ifp->addr; + ip_overwritten = true; err =0 ;break ; }
@@ -787,6 +789,9 @@ int netpoll_setup(struct netpoll *np)return 0 ; put: +DEBUG_NET_WARN_ON_ONCE (np->dev); +if (ip_overwritten) +memset (&np->local_ip,0 ,sizeof (np->local_ip));netdev_put (ndev, &np->dev_tracker); unlock:rtnl_unlock ();
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 43/139 tcp: avoid reusing FIN_WAIT2 when trying to find port in connect() process
In reply to Sasha LevinFrom: Jason Xing <[email protected]>
[ Upstream commit 0d9e5df4a257afc3a471a82961ace9a22b88295a ]
We found that one close-wait socket was reset by the other side due to a new connection reusing the same port which is beyond our expectation, so we have to investigate the underlying reason.
The following experiment is conducted in the test environment. We limit the port range from 40000 to 40010 and delay the time to close() after receiving a fin from the active close side, which can help us easily reproduce like what happened in production.
Here are three connections captured by tcpdump:
127.0.0.1.40002 > 127.0.0.1.9999: Flags [S], seq 2965525191 127.0.0.1.9999 > 127.0.0.1.40002: Flags [S.], seq 2769915070 127.0.0.1.40002 > 127.0.0.1.9999: Flags [.], ack 1 127.0.0.1.40002 > 127.0.0.1.9999: Flags [F.], seq 1, ack 1 // a few seconds later, within 60 seconds 127.0.0.1.40002 > 127.0.0.1.9999: Flags [S], seq 2965590730 127.0.0.1.9999 > 127.0.0.1.40002: Flags [.], ack 2 127.0.0.1.40002 > 127.0.0.1.9999: Flags [R], seq 2965525193 // later, very quickly
127.0.0.1.40002 > 127.0.0.1.9999: Flags [S], seq 2965590730 127.0.0.1.9999 > 127.0.0.1.40002: Flags [S.], seq 3120990805 127.0.0.1.40002 > 127.0.0.1.9999: Flags [.], ack 1
As we can see, the first flow is reset because:
1) client starts a new connection, I mean, the second one
2) client tries to find a suitable port which is a timewait socket (its state is timewait, substate is fin_wait2)
3) client occupies that timewait port to send a SYN
4) server finds a corresponding close-wait socket in ehash table, then replies with a challenge ack
5) client sends an RST to terminate this old close-wait socket.
I don't think the port selection algo can choose a FIN_WAIT2 socket when we turn on tcp_tw_reuse because on the server side there remain unread data. In some cases, if one side haven't call close() yet, we should not consider it as expendable and treat it at will.
Even though, sometimes, the server isn't able to call close() as soon as possible like what we expect, it can not be terminated easily, especially due to a second unrelated connection happening.
After this patch, we can see the expected failure if we start a connection when all the ports are occupied in fin_wait2 state:
"Ncat: Cannot assign requested address."
--- net/ipv4/tcp_ipv4.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv4/tcp_ipv4.c +3 -0
@@ -116,6 +116,9 @@ int tcp_twsk_unique(struct sock *sk, struct sock *sktw, void *twp)const struct tcp_timewait_sock *tcptw =tcp_twsk (sktw);struct tcp_sock *tp =tcp_sk (sk); +if (tw->tw_substate ==TCP_FIN_WAIT2 ) + reuse =0 ; +if (reuse ==2 ) {/* Still does not detect *everything* that goes through * lo, since we require a loopback src or dst address
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 44/139 wifi: iwlwifi: mvm: use correct key iteration
In reply to Sasha LevinFrom: Johannes Berg <[email protected]>
[ Upstream commit 4f1591d292277eec51d027405a92f0d4ef5e299e ]
In the cases changed here, key iteration isn't done from an RCU critical section, but rather using the wiphy lock as protection. Therefore, just use ieee80211_iter_keys(). The link switch case can therefore also use sync commands.
--- drivers/net/wireless/intel/iwlwifi/mvm/mld-key.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/mld-key.c +6 -6
@@ -141,7 +141,7 @@ static void iwl_mvm_mld_update_sta_key(struct ieee80211_hw *hw,if (sta != data->sta || key->link_id >=0 )return ; - err =iwl_mvm_send_cmd_pdu (mvm, cmd_id,CMD_ASYNC ,sizeof (cmd), &cmd); + err =iwl_mvm_send_cmd_pdu (mvm, cmd_id,0 ,sizeof (cmd), &cmd);if (err) data->err = err;
@@ -159,8 +159,8 @@ int iwl_mvm_mld_update_sta_keys(struct iwl_mvm *mvm, .new_sta_mask = new_sta_mask, }; -ieee80211_iter_keys_rcu (mvm->hw, vif, iwl_mvm_mld_update_sta_key, - &data); +ieee80211_iter_keys (mvm->hw, vif, iwl_mvm_mld_update_sta_key, + &data);return data.err; }
@@ -384,7 +384,7 @@ void iwl_mvm_sec_key_remove_ap(struct iwl_mvm *mvm,if (!sec_key_ver)return ; -ieee80211_iter_keys_rcu (mvm->hw, vif, - iwl_mvm_sec_key_remove_ap_iter, - (void *)(uintptr_t )link_id); +ieee80211_iter_keys (mvm->hw, vif, + iwl_mvm_sec_key_remove_ap_iter, + (void *)(uintptr_t )link_id); }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 45/139 wifi: iwlwifi: mvm: avoid NULL pointer dereference
In reply to Sasha LevinFrom: Miri Korenblit <[email protected]>
[ Upstream commit 557a6cd847645e667f3b362560bd7e7c09aac284 ]
iwl_mvm_tx_skb_sta() and iwl_mvm_tx_mpdu() verify that the mvmvsta pointer is not NULL.
It retrieves this pointer using iwl_mvm_sta_from_mac80211, which is dereferencing the ieee80211_sta pointer.
If sta is NULL, iwl_mvm_sta_from_mac80211 will dereference a NULL pointer.
Fix this by checking the sta pointer before retrieving the mvmsta from it. If sta is not NULL, then mvmsta isn't either.
--- drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/tx.c +7 -5
@@ -1145,6 +1145,9 @@ static int iwl_mvm_tx_mpdu(struct iwl_mvm *mvm, struct sk_buff *skb,bool is_ampdu = false;int hdrlen; +if (WARN_ON_ONCE (!sta)) +return -1 ; + mvmsta =iwl_mvm_sta_from_mac80211 (sta); fc = hdr->frame_control; hdrlen =ieee80211_hdrlen (fc);
@@ -1152,9 +1155,6 @@ static int iwl_mvm_tx_mpdu(struct iwl_mvm *mvm, struct sk_buff *skb,if (IWL_MVM_NON_TRANSMITTING_AP &&ieee80211_is_probe_resp (fc))return -1 ; -if (WARN_ON_ONCE (!mvmsta)) -return -1 ; -if (WARN_ON_ONCE (mvmsta->deflink.sta_id ==IWL_MVM_INVALID_STA ))return -1 ;
@@ -1285,7 +1285,7 @@ static int iwl_mvm_tx_mpdu(struct iwl_mvm *mvm, struct sk_buff *skb,int iwl_mvm_tx_skb_sta (struct iwl_mvm *mvm,struct sk_buff *skb,struct ieee80211_sta *sta) { -struct iwl_mvm_sta *mvmsta =iwl_mvm_sta_from_mac80211 (sta); +struct iwl_mvm_sta *mvmsta;struct ieee80211_tx_info info;struct sk_buff_head mpdus_skbs;struct ieee80211_vif *vif;
@@ -1294,9 +1294,11 @@ int iwl_mvm_tx_skb_sta(struct iwl_mvm *mvm, struct sk_buff *skb,struct sk_buff *orig_skb = skb;const u8 *addr3; -if (WARN_ON_ONCE (!mvmsta)) +if (WARN_ON_ONCE (!sta))return -1 ; + mvmsta =iwl_mvm_sta_from_mac80211 (sta); +if (WARN_ON_ONCE (mvmsta->deflink.sta_id ==IWL_MVM_INVALID_STA ))return -1 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 46/139 wifi: mac80211: fix RCU list iterations
In reply to Sasha LevinFrom: Johannes Berg <[email protected]>
[ Upstream commit ac35180032fbc5d80b29af00ba4881815ceefcb6 ]
There are a number of places where RCU list iteration is used, but that aren't (always) called with RCU held. Use just list_for_each_entry() in most, and annotate iface iteration with the required locks.
--- net/mac80211/chan.c | 4 +++- net/mac80211/mlme.c | 2 +- net/mac80211/scan.c | 2 +- net/mac80211/util.c | 4 +++- 4 files changed, 8 insertions(+), 4 deletions(-)
net/mac80211/chan.c +3 -1
@@ -245,7 +245,9 @@ ieee80211_get_max_required_bw(struct ieee80211_sub_if_data *sdata,enum nl80211_chan_width max_bw =NL80211_CHAN_WIDTH_20_NOHT ;struct sta_info *sta; -list_for_each_entry_rcu (sta, &sdata->local->sta_list, list) { +lockdep_assert_wiphy (sdata->local->hw.wiphy); + +list_for_each_entry (sta, &sdata->local->sta_list, list) {if (sdata != sta->sdata && !(sta->sdata->bss && sta->sdata->bss == sdata->bss))continue ;
net/mac80211/mlme.c +1 -1
@@ -732,7 +732,7 @@ static bool ieee80211_add_vht_ie(struct ieee80211_sub_if_data *sdata,bool disable_mu_mimo = false;struct ieee80211_sub_if_data *other; -list_for_each_entry_rcu (other, &local->interfaces, list) { +list_for_each_entry (other, &local->interfaces, list) {if (other->vif.bss_conf.mu_mimo_owner) { disable_mu_mimo = true;break ;
net/mac80211/scan.c +1 -1
@@ -489,7 +489,7 @@ static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)* the scan was in progress; if there was none this will * just be a no-op for the particular interface. */ -list_for_each_entry_rcu (sdata, &local->interfaces, list) { +list_for_each_entry (sdata, &local->interfaces, list) {if (ieee80211_sdata_running (sdata))wiphy_work_queue (sdata->local->hw.wiphy, &sdata->work); }
net/mac80211/util.c +3 -1
@@ -745,7 +745,9 @@ static void __iterate_interfaces(struct ieee80211_local *local,struct ieee80211_sub_if_data *sdata;bool active_only = iter_flags &IEEE80211_IFACE_ITER_ACTIVE ; -list_for_each_entry_rcu (sdata, &local->interfaces, list) { +list_for_each_entry_rcu (sdata, &local->interfaces, list, +lockdep_is_held (&local->iflist_mtx) || +lockdep_is_held (&local->hw.wiphy->mtx)) {switch (sdata->vif.type) {case NL80211_IFTYPE_MONITOR :if (!(sdata->u.mntr.flags &MONITOR_FLAG_ACTIVE ))
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 47/139 ACPICA: iasl: handle empty connection_node
In reply to Sasha LevinFrom: Aleksandrs Vinarskis <[email protected]>
[ Upstream commit a0a2459b79414584af6c46dd8c6f866d8f1aa421 ]
ACPICA commit 6c551e2c9487067d4b085333e7fe97e965a11625
--- drivers/acpi/acpica/exprep.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/acpi/acpica/exprep.c +3 -0
@@ -437,6 +437,9 @@ acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info)if (info->connection_node) { second_desc = info->connection_node->object; +if (second_desc ==NULL ) { +break ; + }if (!(second_desc->common.flags &AOPOBJ_DATA_VALID )) { status =acpi_ds_get_buffer_arguments (second_desc);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 48/139 proc: add config & param to block forcing mem writes
In reply to Sasha LevinFrom: Adrian Ratiu <[email protected]>
[ Upstream commit 41e8149c8892ed1962bd15350b3c3e6e90cba7f4 ]
This adds a Kconfig option and boot param to allow removing the FOLL_FORCE flag from /proc/pid/mem write calls because it can be abused.
The traditional forcing behavior is kept as default because it can break GDB and some other use cases.
Previously we tried a more sophisticated approach allowing distributions to fine-tune /proc/pid/mem behavior, however that got NAK-ed by Linus [1], who prefers this simpler approach with semantics also easier to understand for users.
--- .../admin-guide/kernel-parameters.txt | 10 +++ fs/proc/base.c | 61 ++++++++++++++++++- security/Kconfig | 32 ++++++++++ 3 files changed, 102 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +10 -0
@@ -4639,6 +4639,16 @@ printk.time= Show timing data prefixed to each printk message line Format: <bool> (1/Y/y=enable, 0/N/n=disable) + proc_mem.force_override= [KNL] + Format: {always | ptrace | never} + Traditionally /proc/pid/mem allows memory permissions to be + overridden without restrictions. This option may be set to + restrict that. Can be one of: + - 'always': traditional behavior always allows mem overrides. + - 'ptrace': only allow mem overrides for active ptracers. + - 'never': never allow mem overrides. + If not specified, default is the CONFIG_PROC_MEM_* choice. + processor.max_cstate= [HW,ACPI] Limit processor to maximum C-state max_cstate=9 overrides any DMI blacklist limit.
fs/proc/base.c +60 -1
85 lines not on this page · raw message
security/Kconfig +32 -0
@@ -19,6 +19,38 @@ config SECURITY_DMESG_RESTRICT If you are unsure how to answer this question, answer N. +choice + prompt "Allow /proc/pid/mem access override" + default PROC_MEM_ALWAYS_FORCE + help + Traditionally /proc/pid/mem allows users to override memory + permissions for users like ptrace, assuming they have ptrace + capability. + + This allows people to limit that - either never override, or + require actual active ptrace attachment. + + Defaults to the traditional behavior (for now) + +config PROC_MEM_ALWAYS_FORCE + bool "Traditional /proc/pid/mem behavior" + help + This allows /proc/pid/mem accesses to override memory mapping + permissions if you have ptrace access rights. + +config PROC_MEM_FORCE_PTRACE + bool "Require active ptrace() use for access override" + help + This allows /proc/pid/mem accesses to override memory mapping + permissions for active ptracers like gdb. + +config PROC_MEM_NO_FORCE + bool "Never" + help + Never override memory mapping permissions + +endchoice + config SECURITY bool "Enable different security models" depends on SYSFS
Signature · 1 line
2.43.0
Re: [PATCH AUTOSEL 6.6 048/139] proc: add config & param to block forcing mem writes
Quoted 7 lines · Sasha Levin
From: Adrian Ratiu <[email protected]>
[ Upstream commit
41e8149c8892ed1962bd15350b3c3e6e90cba7f4]This adds a
Kconfigoption and boot param to allow removing theFOLL_FORCEflag from/proc/pid/memwrite calls because it can be abused.
And this is not a mount option why?
Quoted 7 lines
The traditional forcing behavior is kept as default because it can break GDB and some other use cases.
Previously we tried a more sophisticated approach allowing distributions to fine-tune
/proc/pid/membehavior, however that got NAK-ed by Linus [1], who prefers this simpler approach with semantics also easier to understand for users.
Re: [PATCH AUTOSEL 6.6 048/139] proc: add config & param to block forcing mem writes
Quoted 4 lines · Alexey Dobriyan
Quoted 1 line · Sasha Levin
From: Adrian Ratiu <[email protected]> [ Upstream commit
41e8149c8892ed1962bd15350b3c3e6e90cba7f4] This adds aKconfigoption and boot param to allow removing theFOLL_FORCEflag from/proc/pid/memwrite calls because it can be abused.And this is not a mount option why?
Hello and thanks for asking!
The only reason is nobody asked for it yet. :)
We need to be careful how we do this, so the restriction is still enabled when remounting, otherwise I don't see any impediment, provided we can find a way to make it clean and safe.
I am travelling these weeks (All Systems GO conf) and have a lot going on, so please feel free to send a patch and I'll review it ASAP, otherwise I'll try to come up with something by end of October.
Adrian
Sasha Levin
maintainerPATCH 49/139 drivers/perf: arm_spe: Use perf_allow_kernel() for permissions
In reply to Sasha LevinFrom: James Clark <[email protected]>
[ Upstream commit 5e9629d0ae977d6f6916d7e519724804e95f0b07 ]
Use perf_allow_kernel() for 'pa_enable' (physical addresses), 'pct_enable' (physical timestamps) and context IDs. This means that perf_event_paranoid is now taken into account and LSM hooks can be used, which is more consistent with other perf_event_open calls. For example PERF_SAMPLE_PHYS_ADDR uses perf_allow_kernel() rather than just perfmon_capable().
This also indirectly fixes the following error message which is misleading because perf_event_paranoid is not taken into account by perfmon_capable():
$ perf record -e arm_spe/pa_enable/
Error:
Access to performance monitoring and observability operations is limited. Consider adjusting /proc/sys/kernel/perf_event_paranoid setting ...
--- drivers/perf/arm_spe_pmu.c | 9 ++++----- include/linux/perf_event.h | 8 +------- kernel/events/core.c | 9 +++++++++ 3 files changed, 14 insertions(+), 12 deletions(-)
drivers/perf/arm_spe_pmu.c +4 -5
@@ -41,7 +41,7 @@/* * Cache if the event is allowed to trace Context information. -* This allows us to perform the check, i.e, perfmon_capable(), +* This allows us to perform the check, i.e, perf_allow_kernel(), * in the context of the event owner, once, during the event_init(). */ #define SPE_PMU_HW_FLAGS_CX 0x00001
@@ -50,7 +50,7 @@ static_assert((PERF_EVENT_FLAG_ARCH & SPE_PMU_HW_FLAGS_CX) == SPE_PMU_HW_FLAGS_Cstatic void set_spe_event_has_cx (struct perf_event *event) { -if (IS_ENABLED (CONFIG_PID_IN_CONTEXTIDR ) &&perfmon_capable ()) +if (IS_ENABLED (CONFIG_PID_IN_CONTEXTIDR ) && !perf_allow_kernel (&event->attr)) event->hw.flags |=SPE_PMU_HW_FLAGS_CX ; }
@@ -767,9 +767,8 @@ static int arm_spe_pmu_event_init(struct perf_event *event)set_spe_event_has_cx (event); reg =arm_spe_event_to_pmscr (event); -if (!perfmon_capable () && - (reg & (PMSCR_EL1_PA |PMSCR_EL1_PCT ))) -return -EACCES ; +if (reg & (PMSCR_EL1_PA |PMSCR_EL1_PCT )) +return perf_allow_kernel (&event->attr);return 0 ; }
include/linux/perf_event.h +1 -7
@@ -1599,13 +1599,7 @@ static inline int perf_is_paranoid(void)return sysctl_perf_event_paranoid >-1 ; } -static inline int perf_allow_kernel (struct perf_event_attr *attr) -{ -if (sysctl_perf_event_paranoid >1 && !perfmon_capable ()) -return -EACCES ; - -return security_perf_event_open (attr,PERF_SECURITY_KERNEL ); -} +int perf_allow_kernel (struct perf_event_attr *attr);static inline int perf_allow_cpu (struct perf_event_attr *attr) {
kernel/events/core.c +9 -0
@@ -13330,6 +13330,15 @@ const struct perf_event_attr *perf_event_attrs(struct perf_event *event)return &event->attr; } +int perf_allow_kernel (struct perf_event_attr *attr) +{ +if (sysctl_perf_event_paranoid >1 && !perfmon_capable ()) +return -EACCES ; + +return security_perf_event_open (attr,PERF_SECURITY_KERNEL ); +} +EXPORT_SYMBOL_GPL (perf_allow_kernel); +/* * Inherit an event from parent task to child task. *
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 50/139 can: netlink: avoid call to do_set_data_bittiming callback with stale can_priv::ctrlmode
In reply to Sasha LevinFrom: Stefan Mätje <[email protected]>
[ Upstream commit 2423cc20087ae9a7b7af575aa62304ef67cad7b6 ]
This patch moves the evaluation of data[IFLA_CAN_CTRLMODE] in function can_changelink in front of the evaluation of data[IFLA_CAN_BITTIMING].
This avoids a call to do_set_data_bittiming providing a stale can_priv::ctrlmode with a CAN_CTRLMODE_FD flag not matching the requested state when switching between a CAN Classic and CAN-FD bitrate.
In the same manner the evaluation of data[IFLA_CAN_CTRLMODE] in function can_validate is also moved in front of the evaluation of data[IFLA_CAN_BITTIMING].
This is a preparation for patches where the nominal and data bittiming may have interdependencies on the driver side depending on the CAN_CTRLMODE_FD flag state.
--- drivers/net/can/dev/netlink.c | 102 +++++++++++++++++----------------- 1 file changed, 51 insertions(+), 51 deletions(-)
drivers/net/can/dev/netlink.c +51 -51
@@ -65,15 +65,6 @@ static int can_validate(struct nlattr *tb[], struct nlattr *data[],if (!data)return 0 ; -if (data[IFLA_CAN_BITTIMING ]) { -struct can_bittiming bt; - -memcpy (&bt,nla_data (data[IFLA_CAN_BITTIMING ]),sizeof (bt)); - err =can_validate_bittiming (&bt, extack); -if (err) -return err; - } -if (data[IFLA_CAN_CTRLMODE ]) {struct can_ctrlmode *cm =nla_data (data[IFLA_CAN_CTRLMODE ]);u32 tdc_flags = cm->flags &CAN_CTRLMODE_TDC_MASK ;
@@ -114,6 +105,15 @@ static int can_validate(struct nlattr *tb[], struct nlattr *data[], } } +if (data[IFLA_CAN_BITTIMING ]) { +struct can_bittiming bt; + +memcpy (&bt,nla_data (data[IFLA_CAN_BITTIMING ]),sizeof (bt)); + err =can_validate_bittiming (&bt, extack); +if (err) +return err; + } +if (is_can_fd) {if (!data[IFLA_CAN_BITTIMING ] || !data[IFLA_CAN_DATA_BITTIMING ])return -EOPNOTSUPP ;
@@ -195,48 +195,6 @@ static int can_changelink(struct net_device *dev, struct nlattr *tb[],/* We need synchronization with dev->stop() */ ASSERT_RTNL (); -if (data[IFLA_CAN_BITTIMING ]) { -struct can_bittiming bt; - -/* Do not allow changing bittiming while running */ -if (dev->flags &IFF_UP ) -return -EBUSY ; - -/* Calculate bittiming parameters based on -* bittiming_const if set, otherwise pass bitrate -* directly via do_set_bitrate(). Bail out if neither -* is given. -*/ -if (!priv->bittiming_const && !priv->do_set_bittiming && - !priv->bitrate_const) -return -EOPNOTSUPP ; - -memcpy (&bt,nla_data (data[IFLA_CAN_BITTIMING ]),sizeof (bt)); - err =can_get_bittiming (dev, &bt, - priv->bittiming_const, - priv->bitrate_const, - priv->bitrate_const_cnt, - extack); -if (err) -return err; - -if (priv->bitrate_max && bt.bitrate > priv->bitrate_max) { -NL_SET_ERR_MSG_FMT (extack, -"arbitration bitrate %u bps surpasses transceiver capabilities of %u bps" , - bt.bitrate, priv->bitrate_max); -return -EINVAL ; - } - -memcpy (&priv->bittiming, &bt,sizeof (bt)); - -if (priv->do_set_bittiming) { -/* Finally, set the bit-timing registers */ - err = priv->do_set_bittiming (dev); -if (err) -return err; - } - } -if (data[IFLA_CAN_CTRLMODE ]) {struct can_ctrlmode *cm;u32 ctrlstatic;
@@ -284,6 +242,48 @@ static int can_changelink(struct net_device *dev, struct nlattr *tb[], priv->ctrlmode &= cm->flags | ~CAN_CTRLMODE_TDC_MASK ; } +if (data[IFLA_CAN_BITTIMING ]) { +struct can_bittiming bt; + +/* Do not allow changing bittiming while running */ +if (dev->flags &IFF_UP ) +return -EBUSY ; + +/* Calculate bittiming parameters based on +* bittiming_const if set, otherwise pass bitrate +* directly via do_set_bitrate(). Bail out if neither +* is given. +*/ +if (!priv->bittiming_const && !priv->do_set_bittiming && + !priv->bitrate_const) +return -EOPNOTSUPP ; + +memcpy (&bt,nla_data (data[IFLA_CAN_BITTIMING ]),sizeof (bt)); + err =can_get_bittiming (dev, &bt, + priv->bittiming_const, + priv->bitrate_const, + priv->bitrate_const_cnt, + extack); +if (err) +return err; + +if (priv->bitrate_max && bt.bitrate > priv->bitrate_max) { +NL_SET_ERR_MSG_FMT (extack, +"arbitration bitrate %u bps surpasses transceiver capabilities of %u bps" , + bt.bitrate, priv->bitrate_max); +return -EINVAL ; + } + +memcpy (&priv->bittiming, &bt,sizeof (bt)); + +if (priv->do_set_bittiming) { +/* Finally, set the bit-timing registers */ + err = priv->do_set_bittiming (dev); +if (err) +return err; + } + } +if (data[IFLA_CAN_RESTART_MS ]) {/* Do not allow changing restart delay while running */ if (dev->flags &IFF_UP )
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 51/139 crypto: hisilicon/qm - reset device before enabling it
In reply to Sasha LevinFrom: Weili Qian <[email protected]>
[ Upstream commit 5d2d1ee0874c26b8010ddf7f57e2f246e848af38 ]
Before the device is enabled again, the device may still store the previously processed data. If an error occurs in the previous task, the device may fail to be enabled again. Therefore, before enabling device, reset the device to restore the initial state.
--- drivers/crypto/hisilicon/hpre/hpre_main.c | 32 +++--- drivers/crypto/hisilicon/qm.c | 114 +++++++++++++++------- drivers/crypto/hisilicon/sec2/sec_main.c | 16 ++- drivers/crypto/hisilicon/zip/zip_main.c | 23 +++-- 4 files changed, 121 insertions(+), 64 deletions(-)
drivers/crypto/hisilicon/hpre/hpre_main.c +19 -13
@@ -357,6 +357,8 @@ static struct dfx_diff_registers hpre_diff_regs[] = { }, }; +static const struct hisi_qm_err_ini hpre_err_ini; +bool hpre_check_alg_support (struct hisi_qm *qm,u32 alg) {u32 cap_val;
@@ -1161,6 +1163,7 @@ static int hpre_qm_init(struct hisi_qm *qm, struct pci_dev *pdev) qm->qp_num = pf_q_num; qm->debug.curr_qm_qp_num = pf_q_num; qm->qm_list = &hpre_devices; + qm->err_ini = &hpre_err_ini;if (pf_q_num_flag)set_bit (QM_MODULE_PARAM , &qm->misc_ctl); }
@@ -1350,8 +1353,6 @@ static int hpre_pf_probe_init(struct hpre *hpre)hpre_open_sva_prefetch (qm); - qm->err_ini = &hpre_err_ini; - qm->err_ini->err_info_init (qm);hisi_qm_dev_err_init (qm); ret =hpre_show_last_regs_init (qm);if (ret)
@@ -1380,6 +1381,18 @@ static int hpre_probe_init(struct hpre *hpre)return 0 ; } +static void hpre_probe_uninit (struct hisi_qm *qm) +{ +if (qm->fun_type ==QM_HW_VF ) +return ; + +hpre_cnt_regs_clear (qm); + qm->debug.curr_qm_qp_num =0 ; +hpre_show_last_regs_uninit (qm); +hpre_close_sva_prefetch (qm); +hisi_qm_dev_err_uninit (qm); +} +static int hpre_probe (struct pci_dev *pdev,const struct pci_device_id *id) {struct hisi_qm *qm;
@@ -1405,7 +1418,7 @@ static int hpre_probe(struct pci_dev *pdev, const struct pci_device_id *id) ret =hisi_qm_start (qm);if (ret) - goto err_with_err_init; + goto err_with_probe_init; ret =hpre_debugfs_init (qm);if (ret)
@@ -1442,9 +1455,8 @@ static int hpre_probe(struct pci_dev *pdev, const struct pci_device_id *id)hpre_debugfs_exit (qm);hisi_qm_stop (qm,QM_NORMAL ); -err_with_err_init: -hpre_show_last_regs_uninit (qm); -hisi_qm_dev_err_uninit (qm); +err_with_probe_init: +hpre_probe_uninit (qm); err_with_qm_init:hisi_qm_uninit (qm);
@@ -1465,13 +1477,7 @@ static void hpre_remove(struct pci_dev *pdev)hpre_debugfs_exit (qm);hisi_qm_stop (qm,QM_NORMAL ); -if (qm->fun_type ==QM_HW_PF ) { -hpre_cnt_regs_clear (qm); - qm->debug.curr_qm_qp_num =0 ; -hpre_show_last_regs_uninit (qm); -hisi_qm_dev_err_uninit (qm); - } - +hpre_probe_uninit (qm);hisi_qm_uninit (qm); }
drivers/crypto/hisilicon/qm.c +80 -34
183 lines not on this page · raw message
drivers/crypto/hisilicon/sec2/sec_main.c +7 -9
@@ -1061,9 +1061,6 @@ static int sec_pf_probe_init(struct sec_dev *sec)struct hisi_qm *qm = &sec->qm;int ret; - qm->err_ini = &sec_err_ini; - qm->err_ini->err_info_init (qm); - ret =sec_set_user_domain_and_cache (qm);if (ret)return ret;
@@ -1118,6 +1115,7 @@ static int sec_qm_init(struct hisi_qm *qm, struct pci_dev *pdev) qm->qp_num = pf_q_num; qm->debug.curr_qm_qp_num = pf_q_num; qm->qm_list = &sec_devices; + qm->err_ini = &sec_err_ini;if (pf_q_num_flag)set_bit (QM_MODULE_PARAM , &qm->misc_ctl); }else if (qm->fun_type ==QM_HW_VF && qm->ver ==QM_HW_V1 ) {
@@ -1182,6 +1180,12 @@ static int sec_probe_init(struct sec_dev *sec)static void sec_probe_uninit (struct hisi_qm *qm) { +if (qm->fun_type ==QM_HW_VF ) +return ; + +sec_debug_regs_clear (qm); +sec_show_last_regs_uninit (qm); +sec_close_sva_prefetch (qm);hisi_qm_dev_err_uninit (qm); }
@@ -1274,7 +1278,6 @@ static int sec_probe(struct pci_dev *pdev, const struct pci_device_id *id)sec_debugfs_exit (qm);hisi_qm_stop (qm,QM_NORMAL ); err_probe_uninit: -sec_show_last_regs_uninit (qm);sec_probe_uninit (qm); err_qm_uninit:sec_qm_uninit (qm);
@@ -1296,11 +1299,6 @@ static void sec_remove(struct pci_dev *pdev)sec_debugfs_exit (qm); (void )hisi_qm_stop (qm,QM_NORMAL ); - -if (qm->fun_type ==QM_HW_PF ) -sec_debug_regs_clear (qm); -sec_show_last_regs_uninit (qm); -sec_probe_uninit (qm);sec_qm_uninit (qm);
drivers/crypto/hisilicon/zip/zip_main.c +15 -8
@@ -1150,8 +1150,6 @@ static int hisi_zip_pf_probe_init(struct hisi_zip *hisi_zip) hisi_zip->ctrl = ctrl; ctrl->hisi_zip = hisi_zip; - qm->err_ini = &hisi_zip_err_ini; - qm->err_ini->err_info_init (qm); ret =hisi_zip_set_user_domain_and_cache (qm);if (ret)
@@ -1212,6 +1210,7 @@ static int hisi_zip_qm_init(struct hisi_qm *qm, struct pci_dev *pdev) qm->qp_num = pf_q_num; qm->debug.curr_qm_qp_num = pf_q_num; qm->qm_list = &zip_devices; + qm->err_ini = &hisi_zip_err_ini;if (pf_q_num_flag)set_bit (QM_MODULE_PARAM , &qm->misc_ctl); }else if (qm->fun_type ==QM_HW_VF && qm->ver ==QM_HW_V1 ) {
@@ -1278,6 +1277,16 @@ static int hisi_zip_probe_init(struct hisi_zip *hisi_zip)return 0 ; } +static void hisi_zip_probe_uninit (struct hisi_qm *qm) +{ +if (qm->fun_type ==QM_HW_VF ) +return ; + +hisi_zip_show_last_regs_uninit (qm); +hisi_zip_close_sva_prefetch (qm); +hisi_qm_dev_err_uninit (qm); +} +static int hisi_zip_probe (struct pci_dev *pdev,const struct pci_device_id *id) {struct hisi_zip *hisi_zip;
@@ -1304,7 +1313,7 @@ static int hisi_zip_probe(struct pci_dev *pdev, const struct pci_device_id *id) ret =hisi_qm_start (qm);if (ret) - goto err_dev_err_uninit; + goto err_probe_uninit; ret =hisi_zip_debugfs_init (qm);if (ret)
@@ -1341,9 +1350,8 @@ static int hisi_zip_probe(struct pci_dev *pdev, const struct pci_device_id *id)hisi_zip_debugfs_exit (qm);hisi_qm_stop (qm,QM_NORMAL ); -err_dev_err_uninit: -hisi_zip_show_last_regs_uninit (qm); -hisi_qm_dev_err_uninit (qm); +err_probe_uninit: +hisi_zip_probe_uninit (qm); err_qm_uninit:hisi_zip_qm_uninit (qm);
@@ -1364,8 +1372,7 @@ static void hisi_zip_remove(struct pci_dev *pdev)hisi_zip_debugfs_exit (qm);hisi_qm_stop (qm,QM_NORMAL ); -hisi_zip_show_last_regs_uninit (qm); -hisi_qm_dev_err_uninit (qm); +hisi_zip_probe_uninit (qm);hisi_zip_qm_uninit (qm); }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 52/139 wifi: mt76: mt7915: add dummy HW offload of IEEE 802.11 fragmentation
In reply to Sasha LevinFrom: Benjamin Lin <[email protected]>
[ Upstream commit f2cc859149240d910fdc6405717673e0b84bfda8 ]
Currently, CONNAC2 series do not support encryption for fragmented Tx frames. Therefore, add dummy function mt7915_set_frag_threshold() to prevent SW IEEE 802.11 fragmentation.
--- drivers/net/wireless/mediatek/mt76/mt7915/init.c | 1 + drivers/net/wireless/mediatek/mt76/mt7915/main.c | 7 +++++++ 2 files changed, 8 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7915/init.c +1 -0
@@ -386,6 +386,7 @@ mt7915_init_wiphy(struct mt7915_phy *phy)ieee80211_hw_set (hw,SUPPORTS_RX_DECAP_OFFLOAD );ieee80211_hw_set (hw,SUPPORTS_MULTI_BSSID );ieee80211_hw_set (hw,WANT_MONITOR_VIF ); +ieee80211_hw_set (hw,SUPPORTS_TX_FRAG ); hw->max_tx_fragments =4 ;
drivers/net/wireless/mediatek/mt76/mt7915/main.c +7 -0
@@ -1562,6 +1562,12 @@ mt7915_twt_teardown_request(struct ieee80211_hw *hw,mutex_unlock (&dev->mt76.mutex); } +static int +mt7915_set_frag_threshold (struct ieee80211_hw *hw,u32 val) +{ +return 0 ; +} +static int mt7915_set_radar_background (struct ieee80211_hw *hw,struct cfg80211_chan_def *chandef)
@@ -1688,6 +1694,7 @@ const struct ieee80211_ops mt7915_ops = { .sta_set_decap_offload = mt7915_sta_set_decap_offload, .add_twt_setup = mt7915_mac_add_twt_setup, .twt_teardown_request = mt7915_twt_teardown_request, + .set_frag_threshold = mt7915_set_frag_threshold, CFG80211_TESTMODE_CMD(mt76_testmode_cmd) CFG80211_TESTMODE_DUMP(mt76_testmode_dump)#ifdef CONFIG_MAC80211_DEBUGFS
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 53/139 wifi: mt76: mt7915: hold dev->mt76.mutex while disabling tx worker
In reply to Sasha LevinFrom: Felix Fietkau <[email protected]>
[ Upstream commit 8f7152f10cb434f954aeff85ca1be9cd4d01912b ]
Prevent racing against other functions disabling the same worker
--- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +3 -1
@@ -1538,12 +1538,14 @@ void mt7915_mac_reset_work(struct work_struct *work)set_bit (MT76_RESET , &phy2->mt76->state);cancel_delayed_work_sync (&phy2->mt76->mac_work); } + +mutex_lock (&dev->mt76.mutex); +mt76_worker_disable (&dev->mt76.tx_worker);mt76_for_each_q_rx (&dev->mt76, i)napi_disable (&dev->mt76.napi[i]);napi_disable (&dev->mt76.tx_napi); -mutex_lock (&dev->mt76.mutex);mt76_wr (dev,MT_MCU_INT_EVENT ,MT_MCU_INT_EVENT_DMA_STOPPED );
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 54/139 net: tls: wait for async completion on last message
In reply to Sasha LevinFrom: Sascha Hauer <[email protected]>
[ Upstream commit 54001d0f2fdbc7852136a00f3e6fc395a9547ae5 ]
When asynchronous encryption is used KTLS sends out the final data at proto->close time. This becomes problematic when the task calling close() receives a signal. In this case it can happen that tcp_sendmsg_locked() called at close time returns -ERESTARTSYS and the final data is not sent.
The described situation happens when KTLS is used in conjunction with io_uring, as io_uring uses task_work_add() to add work to the current userspace task. A discussion of the problem along with a reproducer can be found in [1] and [2]
Fix this by waiting for the asynchronous encryption to be completed on the final message. With this there is no data left to be sent at close time.
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
--- net/tls/tls_sw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/tls/tls_sw.c +1 -1
@@ -1201,7 +1201,7 @@ static int tls_sw_sendmsg_locked(struct sock *sk, struct msghdr *msg,if (!num_async) { goto send_end; - }else if (num_zc) { + }else if (num_zc || eor) {int err;/* Wait for pending encryptions to get completed */
Signature · 1 line
2.43.0
Jakub Kicinski
maintainerRe: [PATCH AUTOSEL 6.6 054/139] net: tls: wait for async completion on last message
Quoted 10 lines · On Wed, 25 Sep 2024 08:07:54 -0400 Sasha Levin wrote:
From: Sascha Hauer <[email protected]>
[ Upstream commit
54001d0f2fdbc7852136a00f3e6fc395a9547ae5]When asynchronous encryption is used KTLS sends out the final data at
proto->closetime. This becomes problematic when the task callingclose()receives a signal. In this case it can happen thattcp_sendmsg_locked()called at close time returns-ERESTARTSYSand the final data is not sent.
Quoted 8 lines
The described situation happens when KTLS is used in conjunction with
io_uring, asio_uringusestask_work_add()to add work to the current userspace task. A discussion of the problem along with a reproducer can be found in [1] and [2]Fix this by waiting for the asynchronous encryption to be completed on the final message. With this there is no data left to be sent at close time.
I wouldn't backport this, it may cause perf regressions.
Sasha Levin
maintainerRe: [PATCH AUTOSEL 6.6 054/139] net: tls: wait for async completion on last message
Quoted 16 lines · Jakub Kicinski
Quoted 15 lines · On Wed, 25 Sep 2024 08:07:54 -0400 Sasha Levin wrote:
From: Sascha Hauer <[email protected]>
[ Upstream commit
54001d0f2fdbc7852136a00f3e6fc395a9547ae5]When asynchronous encryption is used KTLS sends out the final data at
proto->closetime. This becomes problematic when the task callingclose()receives a signal. In this case it can happen thattcp_sendmsg_locked()called at close time returns-ERESTARTSYSand the final data is not sent.The described situation happens when KTLS is used in conjunction with
io_uring, asio_uringusestask_work_add()to add work to the current userspace task. A discussion of the problem along with a reproducer can be found in [1] and [2]
Quoted 5 lines
Quoted 3 lines
Fix this by waiting for the asynchronous encryption to be completed on the final message. With this there is no data left to be sent at close time.
I wouldn't backport this, it may cause perf regressions.
Dropped, thanks!
Signature · 2 lines
Thanks, Sasha
Sasha Levin
maintainerPATCH 55/139 wifi: mwifiex: Fix memcpy() field-spanning write warning in mwifiex_cmd_802_11_scan_ext()
In reply to Sasha LevinFrom: "Gustavo A. R. Silva" <[email protected]>
[ Upstream commit 498365e52bebcbc36a93279fe7e9d6aec8479cee ]
Replace one-element array with a flexible-array member in struct host_cmd_ds_802_11_scan_ext.
With this, fix the following warning:
elo 16 17:51:58 surfacebook kernel: ------------[ cut here ]------------
elo 16 17:51:58 surfacebook kernel: memcpy: detected field-spanning write (size 243) of single field "ext_scan->tlv_buffer" at drivers/net/wireless/marvell/mwifiex/scan.c:2239 (size 1) elo 16 17:51:58 surfacebook kernel: WARNING: CPU: 0 PID: 498 at drivers/net/wireless/marvell/mwifiex/scan.c:2239 mwifiex_cmd_802_11_scan_ext+0x83/0x90 [mwifiex]
--- drivers/net/wireless/marvell/mwifiex/fw.h | 2 +- drivers/net/wireless/marvell/mwifiex/scan.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/net/wireless/marvell/mwifiex/fw.h +1 -1
@@ -1587,7 +1587,7 @@ struct host_cmd_ds_802_11_scan_rsp {struct host_cmd_ds_802_11_scan_ext {u32 reserved; -u8 tlv_buffer[1 ]; +u8 tlv_buffer[]; } __packed;struct mwifiex_ie_types_bss_mode {
drivers/net/wireless/marvell/mwifiex/scan.c +1 -2
@@ -2543,8 +2543,7 @@ int mwifiex_ret_802_11_scan_ext(struct mwifiex_private *priv, ext_scan_resp = &resp->params.ext_scan; tlv = (void *)ext_scan_resp->tlv_buffer; - buf_left =le16_to_cpu (resp->size) - (sizeof (*ext_scan_resp) +S_DS_GEN - -1 ); + buf_left =le16_to_cpu (resp->size) - (sizeof (*ext_scan_resp) +S_DS_GEN );while (buf_left >=sizeof (struct mwifiex_ie_types_header )) { type =le16_to_cpu (tlv->type);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 56/139 nfp: Use IRQF_NO_AUTOEN flag in request_irq()
In reply to Sasha LevinFrom: Jinjie Ruan <[email protected]>
[ Upstream commit daaba19d357f0900b303a530ced96c78086267ea ]
disable_irq() after request_irq() still has a time gap in which interrupts can come. request_irq() with IRQF_NO_AUTOEN flag will disable IRQ auto-enable when request IRQ.
--- drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/ethernet/netronome/nfp/nfp_net_common.c +2 -3
@@ -821,14 +821,13 @@ nfp_net_prepare_vector(struct nfp_net *nn, struct nfp_net_r_vector *r_vec,snprintf (r_vec->name,sizeof (r_vec->name),"%s-rxtx-%d" ,nfp_net_name (nn), idx); - err =request_irq (r_vec->irq_vector, r_vec->handler,0 , r_vec->name, - r_vec); + err =request_irq (r_vec->irq_vector, r_vec->handler,IRQF_NO_AUTOEN , + r_vec->name, r_vec);if (err) {nfp_net_napi_del (&nn->dp, r_vec);nn_err (nn,"Error requesting IRQ %d\n" , r_vec->irq_vector);return err; } -disable_irq (r_vec->irq_vector);irq_set_affinity_hint (r_vec->irq_vector, &r_vec->affinity_mask);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 57/139 ALSA: usb-audio: Add input value sanity checks for standard types
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
[ Upstream commit 901e85677ec0bb9a69fb9eab1feafe0c4eb7d07e ]
For an invalid input value that is out of the given range, currently USB-audio driver corrects the value silently and accepts without errors. This is no wrong behavior, per se, but the recent kselftest rather wants to have an error in such a case, hence a different behavior is expected now.
This patch adds a sanity check at each control put for the standard mixer types and returns an error if an invalid value is given.
Note that this covers only the standard mixer types. The mixer quirks that have own control callbacks would need different coverage.
--- sound/usb/mixer.c | 35 +++++++++++++++++++++++++++-------- sound/usb/mixer.h | 1 + 2 files changed, 28 insertions(+), 8 deletions(-)
sound/usb/mixer.c +27 -8
@@ -1377,6 +1377,19 @@ static int get_min_max_with_quirks(struct usb_mixer_elem_info *cval,#define get_min_max (cval, def) get_min_max_with_quirks(cval, def, NULL) +/* get the max value advertised via control API */ +static int get_max_exposed (struct usb_mixer_elem_info *cval) +{ +if (!cval->max_exposed) { +if (cval->res) + cval->max_exposed = +DIV_ROUND_UP (cval->max - cval->min, cval->res); +else + cval->max_exposed = cval->max - cval->min; + } +return cval->max_exposed; +} +/* get a feature/mixer unit info */ static int mixer_ctl_feature_info (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_info *uinfo)
@@ -1389,11 +1402,8 @@ static int mixer_ctl_feature_info(struct snd_kcontrol *kcontrol,else uinfo->type =SNDRV_CTL_ELEM_TYPE_INTEGER ; uinfo->count = cval->channels; -if (cval->val_type ==USB_MIXER_BOOLEAN || - cval->val_type ==USB_MIXER_INV_BOOLEAN ) { - uinfo->value.integer.min =0 ; - uinfo->value.integer.max =1 ; - }else { +if (cval->val_type !=USB_MIXER_BOOLEAN && + cval->val_type !=USB_MIXER_INV_BOOLEAN ) {if (!cval->initialized) {get_min_max_with_quirks (cval,0 , kcontrol);if (cval->initialized && cval->dBmin >= cval->dBmax) {
@@ -1405,10 +1415,10 @@ static int mixer_ctl_feature_info(struct snd_kcontrol *kcontrol, &kcontrol->id); } } - uinfo->value.integer.min =0 ; - uinfo->value.integer.max = -DIV_ROUND_UP (cval->max - cval->min, cval->res); } + + uinfo->value.integer.min =0 ; + uinfo->value.integer.max =get_max_exposed (cval);return 0 ; }
@@ -1449,6 +1459,7 @@ static int mixer_ctl_feature_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) {struct usb_mixer_elem_info *cval = kcontrol->private_data; +int max_val =get_max_exposed (cval);int c, cnt, val, oval, err;int changed =0 ;
@@ -1461,6 +1472,8 @@ static int mixer_ctl_feature_put(struct snd_kcontrol *kcontrol,if (err <0 )return filter_error (cval, err); val = ucontrol->value.integer.value[cnt]; +if (val <0 || val > max_val) +return -EINVAL ; val =get_abs_value (cval, val);if (oval != val) {snd_usb_set_cur_mix_value (cval, c +1 , cnt, val);
@@ -1474,6 +1487,8 @@ static int mixer_ctl_feature_put(struct snd_kcontrol *kcontrol,if (err <0 )return filter_error (cval, err); val = ucontrol->value.integer.value[0 ]; +if (val <0 || val > max_val) +return -EINVAL ; val =get_abs_value (cval, val);if (val != oval) {snd_usb_set_cur_mix_value (cval,0 ,0 , val);
@@ -2337,6 +2352,8 @@ static int mixer_ctl_procunit_put(struct snd_kcontrol *kcontrol,if (err <0 )return filter_error (cval, err); val = ucontrol->value.integer.value[0 ]; +if (val <0 || val >get_max_exposed (cval)) +return -EINVAL ; val =get_abs_value (cval, val);if (val != oval) {set_cur_ctl_value (cval, cval->control <<8 , val);
@@ -2699,6 +2716,8 @@ static int mixer_ctl_selector_put(struct snd_kcontrol *kcontrol,if (err <0 )return filter_error (cval, err); val = ucontrol->value.enumerated.item[0 ]; +if (val <0 || val >= cval->max)/* here cval->max = # elements */ +return -EINVAL ; val =get_abs_value (cval, val);if (val != oval) {set_cur_ctl_value (cval, cval->control <<8 , val);
sound/usb/mixer.h +1 -0
@@ -88,6 +88,7 @@ struct usb_mixer_elem_info {int channels;int val_type;int min, max, res; +int max_exposed;/* control API exposes the value in 0..max_exposed */ int dBmin, dBmax;int cached;int cache_val[MAX_CHANNELS ];
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 58/139 x86/ioapic: Handle allocation failures gracefully
In reply to Sasha LevinFrom: Thomas Gleixner <[email protected]>
[ Upstream commit 830802a0fea8fb39d3dc9fb7d6b5581e1343eb1f ]
Breno observed panics when using failslab under certain conditions during runtime:
can not alloc irq_pin_list (-1,0,20)
Kernel panic - not syncing: IO-APIC: failed to add irq-pin. Can not proceed panic+0x4e9/0x590 mp_irqdomain_alloc+0x9ab/0xa80 irq_domain_alloc_irqs_locked+0x25d/0x8d0 __irq_domain_alloc_irqs+0x80/0x110 mp_map_pin_to_irq+0x645/0x890 acpi_register_gsi_ioapic+0xe6/0x150 hpet_open+0x313/0x480
That's a pointless panic which is a leftover of the historic IO/APIC code which panic'ed during early boot when the interrupt allocation failed.
The only place which might justify panic is the PIT/HPET timer_check() code which tries to figure out whether the timer interrupt is delivered through the IO/APIC. But that code does not require to handle interrupt allocation failures. If the interrupt cannot be allocated then timer delivery fails and it either panics due to that or falls back to legacy mode.
Cure this by removing the panic wrapper around __add_pin_to_irq_node() and making mp_irqdomain_alloc() aware of the failure condition and handle it as any other failure in this function gracefully.
--- arch/x86/kernel/apic/io_apic.c | 46 ++++++++++++++++------------------ 1 file changed, 22 insertions(+), 24 deletions(-)
arch/x86/kernel/apic/io_apic.c +22 -24
@@ -352,27 +352,26 @@ static void ioapic_mask_entry(int apic, int pin)* shared ISA-space IRQs, so we have to support them. We are super * fast in the common case, and fast for shared ISA-space IRQs. */ -static int __add_pin_to_irq_node (struct mp_chip_data *data, -int node,int apic,int pin) +static bool add_pin_to_irq_node (struct mp_chip_data *data,int node,int apic,int pin) {struct irq_pin_list *entry; -/* don't allow duplicates */ -for_each_irq_pin (entry, data->irq_2_pin) +/* Don't allow duplicates */ +for_each_irq_pin (entry, data->irq_2_pin) {if (entry->apic == apic && entry->pin == pin) -return 0 ; +return true; + } entry =kzalloc_node (sizeof (struct irq_pin_list ),GFP_ATOMIC , node);if (!entry) { -pr_err ("can not alloc irq_pin_list (%d,%d,%d)\n" , - node, apic, pin); -return -ENOMEM ; +pr_err ("Cannot allocate irq_pin_list (%d,%d,%d)\n" , node, apic, pin); +return false; } + entry->apic = apic; entry->pin = pin;list_add_tail (&entry->list, &data->irq_2_pin); - -return 0 ; +return true; }static void __remove_pin_from_irq (struct mp_chip_data *data,int apic,int pin)
@@ -387,13 +386,6 @@ static void __remove_pin_from_irq(struct mp_chip_data *data, int apic, int pin) } } -static void add_pin_to_irq_node (struct mp_chip_data *data, -int node,int apic,int pin) -{ -if (__add_pin_to_irq_node (data, node, apic, pin)) -panic ("IO-APIC: failed to add irq-pin. Can not proceed\n" ); -} -/* * Reroute an IRQ to a different pin. */
@@ -1002,8 +994,7 @@ static int alloc_isa_irq_from_domain(struct irq_domain *domain,if (irq_data && irq_data->parent_data) {if (!mp_check_pin_attr (irq, info))return -EBUSY ; -if (__add_pin_to_irq_node (irq_data->chip_data, node, ioapic, - info->ioapic.pin)) +if (!add_pin_to_irq_node (irq_data->chip_data, node, ioapic, info->ioapic.pin))return -ENOMEM ; }else { info->flags |=X86_IRQ_ALLOC_LEGACY ;
@@ -3037,10 +3028,8 @@ int mp_irqdomain_alloc(struct irq_domain *domain, unsigned int virq,return -ENOMEM ; ret =irq_domain_alloc_irqs_parent (domain, virq, nr_irqs, info); -if (ret <0 ) { -kfree (data); -return ret; - } +if (ret <0 ) + goto free_data;INIT_LIST_HEAD (&data->irq_2_pin); irq_data->hwirq = info->ioapic.pin;
@@ -3049,7 +3038,10 @@ int mp_irqdomain_alloc(struct irq_domain *domain, unsigned int virq, irq_data->chip_data = data;mp_irqdomain_get_attr (mp_pin_to_gsi (ioapic, pin), data, info); -add_pin_to_irq_node (data,ioapic_alloc_attr_node (info), ioapic, pin); +if (!add_pin_to_irq_node (data,ioapic_alloc_attr_node (info), ioapic, pin)) { + ret = -ENOMEM ; + goto free_irqs; + }mp_preconfigure_entry (data);mp_register_handler (virq, data->is_level);
@@ -3064,6 +3056,12 @@ int mp_irqdomain_alloc(struct irq_domain *domain, unsigned int virq, ioapic,mpc_ioapic_id (ioapic), pin, virq, data->is_level, data->active_low);return 0 ; + +free_irqs: +irq_domain_free_irqs_parent (domain, virq, nr_irqs); +free_data: +kfree (data); +return ret; } void mp_irqdomain_free(struct irq_domain *domain, unsigned int virq,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 59/139 ALSA: usb-audio: Support multiple control interfaces
In reply to Sasha LevinFrom: Karol Kosik <[email protected]>
[ Upstream commit 6aa8700150f7dc62f60b4cf5b1624e2e3d9ed78e ]
Registering Numark Party Mix II fails with error 'bogus bTerminalLink 1'. The problem stems from the driver not being able to find input/output terminals required to configure audio streaming. The information about those terminals is stored in AudioControl Interface. Numark device contains 2 AudioControl Interfaces and the driver checks only one of them.
According to the USB standard, a device can have multiple audio functions, each represented by Audio Interface Collection. Every audio function is considered to be closed box and will contain unique AudioControl Interface and zero or more AudioStreaming and MIDIStreaming Interfaces.
The Numark device adheres to the standard and defines two audio functions:
- MIDIStreaming function
- AudioStreaming function
It starts with MIDI function, followed by the audio function. The driver saves the first AudioControl Interface in snd_usb_audio structure associated with the entire device. It then attempts to use this interface to query for terminals and clocks. However, this fails because the correct information is stored in the second AudioControl Interface, defined in the second Audio Interface Collection.
This patch introduces a structure holding association between each MIDI/Audio Interface and its corresponding AudioControl Interface, instead of relying on AudioControl Interface defined for the entire device. This structure is populated during usb probing phase and leveraged later when querying for terminals and when sending USB requests.
Alternative solutions considered include:
- defining a quirk for Numark where the order of interface is manually changed, or terminals are hardcoded in the driver. This solution would have fixed only this model, though it seems that device is USB compliant, and it also seems that other devices from this company may be affected. What's more, it looks like products from other manufacturers have similar problems, i.e. Rane One DJ console
- keeping a list of all AudioControl Interfaces and querying all of them to find required information. That would have solved my problem and have low probability of breaking other devices, as we would always start with the same logic of querying first AudioControl Interface. This solution would not have followed the standard though.
This patch preserves the snd_usb_audio.ctrl_intf variable, which holds the first AudioControl Interface, and uses it as a fallback when some interfaces are not parsed correctly and lack an associated AudioControl Interface, i.e., when configured via quirks.
--- sound/usb/card.c | 2 ++ sound/usb/clock.c | 62 ++++++++++++++++++++++++-------------- sound/usb/format.c | 6 ++-- sound/usb/helper.c | 34 +++++++++++++++++++++ sound/usb/helper.h | 10 ++++-- sound/usb/mixer.c | 2 +- sound/usb/mixer_quirks.c | 17 ++++++----- sound/usb/mixer_scarlett.c | 4 +-- sound/usb/power.c | 3 +- sound/usb/power.h | 1 + sound/usb/stream.c | 21 ++++++++----- sound/usb/usbaudio.h | 12 ++++++++ 12 files changed, 127 insertions(+), 47 deletions(-)
sound/usb/card.c +2 -0
@@ -206,6 +206,8 @@ static int snd_usb_create_stream(struct snd_usb_audio *chip, int ctrlif, int intreturn -EINVAL ; } +snd_usb_add_ctrl_interface_link (chip, interface, ctrlif); +if (!snd_usb_parse_audio_interface (chip, interface)) {usb_set_interface (dev, interface,0 );/* reset the current interface */ return usb_driver_claim_interface(&usb_audio_driver, iface,
sound/usb/clock.c +39 -23
187 lines not on this page · raw message
sound/usb/format.c +4 -2
@@ -548,7 +548,9 @@ static int parse_audio_format_rates_v2v3(struct snd_usb_audio *chip,unsigned char tmp[2 ], *data;int nr_triplets, data_size, ret =0 , ret_l6;int clock =snd_usb_clock_find_source (chip, fp, false); +struct usb_host_interface *ctrl_intf; + ctrl_intf =snd_usb_find_ctrl_interface (chip, fp->iface);if (clock <0 ) { dev_err(&dev->dev, "%s(): unable to find clock source (clock %d)\n",
@@ -560,7 +562,7 @@ static int parse_audio_format_rates_v2v3(struct snd_usb_audio *chip, ret =snd_usb_ctl_msg (dev,usb_rcvctrlpipe (dev,0 ),UAC2_CS_RANGE ,USB_TYPE_CLASS |USB_RECIP_INTERFACE |USB_DIR_IN ,UAC2_CS_CONTROL_SAM_FREQ <<8 , -snd_usb_ctrl_intf (chip) | (clock <<8 ), +snd_usb_ctrl_intf (ctrl_intf) | (clock <<8 ), tmp,sizeof (tmp));if (ret <0 ) {
@@ -595,7 +597,7 @@ static int parse_audio_format_rates_v2v3(struct snd_usb_audio *chip, ret =snd_usb_ctl_msg (dev,usb_rcvctrlpipe (dev,0 ),UAC2_CS_RANGE ,USB_TYPE_CLASS |USB_RECIP_INTERFACE |USB_DIR_IN ,UAC2_CS_CONTROL_SAM_FREQ <<8 , -snd_usb_ctrl_intf (chip) | (clock <<8 ), +snd_usb_ctrl_intf (ctrl_intf) | (clock <<8 ), data, data_size);if (ret <0 ) {
sound/usb/helper.c +34 -0
@@ -130,3 +130,37 @@ snd_usb_get_host_interface(struct snd_usb_audio *chip, int ifnum, int altsettingreturn NULL ;return usb_altnum_to_altsetting (iface, altsetting); } + +int snd_usb_add_ctrl_interface_link (struct snd_usb_audio *chip,int ifnum, +int ctrlif) +{ +struct usb_device *dev = chip->dev; +struct usb_host_interface *host_iface; + +if (chip->num_intf_to_ctrl >=MAX_CARD_INTERFACES ) { +dev_info (&dev->dev,"Too many interfaces assigned to the single USB-audio card\n" ); +return -EINVAL ; + } + +/* find audiocontrol interface */ + host_iface = &usb_ifnum_to_if (dev, ctrlif)->altsetting[0 ]; + + chip->intf_to_ctrl[chip->num_intf_to_ctrl].interface = ifnum; + chip->intf_to_ctrl[chip->num_intf_to_ctrl].ctrl_intf = host_iface; + chip->num_intf_to_ctrl++; + +return 0 ; +} + +struct usb_host_interface *snd_usb_find_ctrl_interface (struct snd_usb_audio *chip, +int ifnum) +{ +int i; + +for (i =0 ; i < chip->num_intf_to_ctrl; ++i) +if (chip->intf_to_ctrl[i].interface == ifnum) +return chip->intf_to_ctrl[i].ctrl_intf; + +/* Fallback to first audiocontrol interface */ +return chip->ctrl_intf; +}
sound/usb/helper.h +8 -2
@@ -17,6 +17,12 @@ unsigned char snd_usb_parse_datainterval(struct snd_usb_audio *chip,struct usb_host_interface *snd_usb_get_host_interface (struct snd_usb_audio *chip,int ifnum,int altsetting); +int snd_usb_add_ctrl_interface_link (struct snd_usb_audio *chip,int ifnum, +int ctrlif); + +struct usb_host_interface *snd_usb_find_ctrl_interface (struct snd_usb_audio *chip, +int ifnum); +/* * retrieve usb_interface descriptor from the host interface * (conditional for compatibility with the older API)
@@ -28,9 +34,9 @@ snd_usb_get_host_interface(struct snd_usb_audio *chip, int ifnum, int altsetting#define snd_usb_get_speed (dev) ((dev)->speed) -static inline int snd_usb_ctrl_intf (struct snd_usb_audio *chip) +static inline int snd_usb_ctrl_intf (struct usb_host_interface *ctrl_intf) { -return get_iface_desc (chip->ctrl_intf)->bInterfaceNumber; +return get_iface_desc (ctrl_intf)->bInterfaceNumber; }/* in validate.c */
sound/usb/mixer.c +1 -1
@@ -728,7 +728,7 @@ static int get_cluster_channels_v3(struct mixer_build *state, unsigned int clustUAC3_CS_REQ_HIGH_CAPABILITY_DESCRIPTOR ,USB_RECIP_INTERFACE |USB_TYPE_CLASS |USB_DIR_IN , cluster_id, -snd_usb_ctrl_intf (state->chip), +snd_usb_ctrl_intf (state->mixer->hostif), &c_header, sizeof(c_header));if (err <0 ) goto error;
sound/usb/mixer_quirks.c +9 -8
@@ -1043,7 +1043,7 @@ static int snd_ftu_eff_switch_init(struct usb_mixer_interface *mixer, err =snd_usb_ctl_msg (dev,usb_rcvctrlpipe (dev,0 ),UAC_GET_CUR ,USB_RECIP_INTERFACE |USB_TYPE_CLASS |USB_DIR_IN , pval &0xff00 , -snd_usb_ctrl_intf (mixer->chip) | ((pval &0xff ) <<8 ), +snd_usb_ctrl_intf (mixer->hostif) | ((pval &0xff ) <<8 ), value,2 );if (err <0 )return err;
@@ -1077,7 +1077,7 @@ static int snd_ftu_eff_switch_update(struct usb_mixer_elem_list *list)UAC_SET_CUR ,USB_RECIP_INTERFACE |USB_TYPE_CLASS |USB_DIR_OUT , pval &0xff00 , -snd_usb_ctrl_intf (chip) | ((pval &0xff ) <<8 ), +snd_usb_ctrl_intf (list->mixer->hostif) | ((pval &0xff ) <<8 ), value, 2);snd_usb_unlock_shutdown (chip);return err;
@@ -2115,24 +2115,25 @@ static int dell_dock_mixer_create(struct usb_mixer_interface *mixer)return 0 ; } -static void dell_dock_init_vol (struct snd_usb_audio *chip,int ch,int id) +static void dell_dock_init_vol (struct usb_mixer_interface *mixer,int ch,int id) { +struct snd_usb_audio *chip = mixer->chip;u16 buf =0 ;snd_usb_ctl_msg (chip->dev,usb_sndctrlpipe (chip->dev,0 ),UAC_SET_CUR ,USB_RECIP_INTERFACE |USB_TYPE_CLASS |USB_DIR_OUT , (UAC_FU_VOLUME <<8 ) | ch, -snd_usb_ctrl_intf (chip) | (id <<8 ), +snd_usb_ctrl_intf (mixer->hostif) | (id <<8 ), &buf,2 ); }static int dell_dock_mixer_init (struct usb_mixer_interface *mixer) {/* fix to 0dB playback volumes */ -dell_dock_init_vol (mixer->chip,1 ,16 ); -dell_dock_init_vol (mixer->chip,2 ,16 ); -dell_dock_init_vol (mixer->chip,1 ,19 ); -dell_dock_init_vol (mixer->chip,2 ,19 ); +dell_dock_init_vol (mixer,1 ,16 ); +dell_dock_init_vol (mixer,2 ,16 ); +dell_dock_init_vol (mixer,1 ,19 ); +dell_dock_init_vol (mixer,2 ,19 );return 0 ; }
sound/usb/mixer_scarlett.c +2 -2
@@ -460,7 +460,7 @@ static int scarlett_ctl_meter_get(struct snd_kcontrol *kctl,struct snd_usb_audio *chip = elem->head.mixer->chip;unsigned char buf[2 *MAX_CHANNELS ] = {0 , };int wValue = (elem->control <<8 ) | elem->idx_off; -int idx =snd_usb_ctrl_intf (chip) | (elem->head.id <<8 ); +int idx =snd_usb_ctrl_intf (elem->head.mixer->hostif) | (elem->head.id <<8 );int err; err = snd_usb_ctl_msg(chip->dev,
@@ -1002,7 +1002,7 @@ int snd_scarlett_controls_create(struct usb_mixer_interface *mixer) err =snd_usb_ctl_msg (mixer->chip->dev,usb_sndctrlpipe (mixer->chip->dev,0 ),UAC2_CS_CUR ,USB_RECIP_INTERFACE |USB_TYPE_CLASS | -USB_DIR_OUT ,0x0100 ,snd_usb_ctrl_intf (mixer->chip) | +USB_DIR_OUT ,0x0100 ,snd_usb_ctrl_intf (mixer->hostif) | (0x29 <<8 ), sample_rate_buffer,4 );if (err <0 )return err;
sound/usb/power.c +2 -1
@@ -40,6 +40,7 @@ snd_usb_find_power_domain(struct usb_host_interface *ctrl_iface,le16_to_cpu (pd_desc->waRecoveryTime1); pd->pd_d2d0_rec =le16_to_cpu (pd_desc->waRecoveryTime2); + pd->ctrl_iface = ctrl_iface;return pd; } }
@@ -57,7 +58,7 @@ int snd_usb_power_domain_set(struct snd_usb_audio *chip,unsigned char current_state;int err, idx; - idx =snd_usb_ctrl_intf (chip) | (pd->pd_id <<8 ); + idx =snd_usb_ctrl_intf (pd->ctrl_iface) | (pd->pd_id <<8 ); err = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), UAC2_CS_CUR,
sound/usb/power.h +1 -0
@@ -6,6 +6,7 @@ struct snd_usb_power_domain {int pd_id;/* UAC3 Power Domain ID */ int pd_d1d0_rec;/* D1 to D0 recovery time */ int pd_d2d0_rec;/* D2 to D0 recovery time */ +struct usb_host_interface *ctrl_iface;/* Control interface */ };enum {
sound/usb/stream.c +13 -8
@@ -713,10 +713,13 @@ snd_usb_get_audioformat_uac12(struct snd_usb_audio *chip,struct usb_device *dev = chip->dev;struct uac_format_type_i_continuous_descriptor *fmt;unsigned int num_channels =0 , chconfig =0 ; +struct usb_host_interface *ctrl_intf;struct audioformat *fp;int clock =0 ;u64 format; + ctrl_intf =snd_usb_find_ctrl_interface (chip, iface_no); +/* get audio formats */ if (protocol ==UAC_VERSION_1 ) { struct uac1_as_header_descriptor *as =
@@ -740,7 +743,7 @@ snd_usb_get_audioformat_uac12(struct snd_usb_audio *chip, format =le16_to_cpu (as->wFormatTag);/* remember the format value */ - iterm =snd_usb_find_input_terminal_descriptor (chip->ctrl_intf, + iterm =snd_usb_find_input_terminal_descriptor (ctrl_intf, as->bTerminalLink, protocol);if (iterm) {
@@ -776,7 +779,7 @@ snd_usb_get_audioformat_uac12(struct snd_usb_audio *chip,* lookup the terminal associated to this interface * to extract the clock */ - input_term =snd_usb_find_input_terminal_descriptor (chip->ctrl_intf, + input_term =snd_usb_find_input_terminal_descriptor (ctrl_intf, as->bTerminalLink, protocol);if (input_term) {
@@ -786,7 +789,7 @@ snd_usb_get_audioformat_uac12(struct snd_usb_audio *chip, goto found_clock; } - output_term =snd_usb_find_output_terminal_descriptor (chip->ctrl_intf, + output_term =snd_usb_find_output_terminal_descriptor (ctrl_intf, as->bTerminalLink, protocol);if (output_term) {
@@ -870,6 +873,7 @@ snd_usb_get_audioformat_uac3(struct snd_usb_audio *chip,struct uac3_cluster_header_descriptor *cluster;struct uac3_as_header_descriptor *as =NULL ;struct uac3_hc_descriptor_header hc_header; +struct usb_host_interface *ctrl_intf;struct snd_pcm_chmap_elem *chmap;struct snd_usb_power_domain *pd;unsigned char badd_profile;
@@ -881,6 +885,7 @@ snd_usb_get_audioformat_uac3(struct snd_usb_audio *chip,int err; badd_profile = chip->badd_profile; + ctrl_intf =snd_usb_find_ctrl_interface (chip, iface_no);if (badd_profile >=UAC3_FUNCTION_SUBCLASS_GENERIC_IO ) { unsigned int maxpacksize =
@@ -966,7 +971,7 @@ snd_usb_get_audioformat_uac3(struct snd_usb_audio *chip,UAC3_CS_REQ_HIGH_CAPABILITY_DESCRIPTOR ,USB_RECIP_INTERFACE |USB_TYPE_CLASS |USB_DIR_IN , cluster_id, -snd_usb_ctrl_intf (chip), +snd_usb_ctrl_intf (ctrl_intf), &hc_header, sizeof(hc_header));if (err <0 )return ERR_PTR (err);
@@ -990,7 +995,7 @@ snd_usb_get_audioformat_uac3(struct snd_usb_audio *chip,UAC3_CS_REQ_HIGH_CAPABILITY_DESCRIPTOR ,USB_RECIP_INTERFACE |USB_TYPE_CLASS |USB_DIR_IN , cluster_id, -snd_usb_ctrl_intf (chip), +snd_usb_ctrl_intf (ctrl_intf), cluster, wLength);if (err <0 ) {kfree (cluster);
@@ -1011,7 +1016,7 @@ snd_usb_get_audioformat_uac3(struct snd_usb_audio *chip,* lookup the terminal associated to this interface * to extract the clock */ - input_term =snd_usb_find_input_terminal_descriptor (chip->ctrl_intf, + input_term =snd_usb_find_input_terminal_descriptor (ctrl_intf, as->bTerminalLink,UAC_VERSION_3 );if (input_term) {
@@ -1019,7 +1024,7 @@ snd_usb_get_audioformat_uac3(struct snd_usb_audio *chip, goto found_clock; } - output_term =snd_usb_find_output_terminal_descriptor (chip->ctrl_intf, + output_term =snd_usb_find_output_terminal_descriptor (ctrl_intf, as->bTerminalLink,UAC_VERSION_3 );if (output_term) {
@@ -1068,7 +1073,7 @@ snd_usb_get_audioformat_uac3(struct snd_usb_audio *chip,UAC_VERSION_3 , iface_no); - pd =snd_usb_find_power_domain (chip->ctrl_intf, + pd =snd_usb_find_power_domain (ctrl_intf, as->bTerminalLink);/* ok, let's parse further... */
sound/usb/usbaudio.h +12 -0
@@ -21,6 +21,15 @@ struct media_intf_devnode;#define MAX_CARD_INTERFACES 16 +/* +* Structure holding assosiation between Audio Control Interface +* and given Streaming or Midi Interface. +*/ +struct snd_intf_to_ctrl { +u8 interface; +struct usb_host_interface *ctrl_intf; +}; +struct snd_usb_audio {int index;struct usb_device *dev;
@@ -63,6 +72,9 @@ struct snd_usb_audio {struct usb_host_interface *ctrl_intf;/* the audio control interface */ struct media_device *media_dev;struct media_intf_devnode *ctl_intf_media_devnode; + +unsigned int num_intf_to_ctrl; +struct snd_intf_to_ctrl intf_to_ctrl[MAX_CARD_INTERFACES ]; };#define USB_AUDIO_IFACE_UNUSED ((void *)-1L)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 60/139 ALSA: usb-audio: Define macros for quirk table entries
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
[ Upstream commit 0c3ad39b791c2ecf718afcaca30e5ceafa939d5c ]
Many entries in the USB-audio quirk tables have relatively complex expressions. For improving the readability, introduce a few macros. Those are applied in the following patch.
--- sound/usb/quirks-table.h | 77 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+)
sound/usb/quirks-table.h +77 -0
@@ -35,6 +35,83 @@ .bInterfaceClass = USB_CLASS_AUDIO, \ .bInterfaceSubClass =USB_SUBCLASS_AUDIOCONTROL +/* Quirk .driver_info, followed by the definition of the quirk entry; +* put like QUIRK_DRIVER_INFO { ... } in each entry of the quirk table + */ +#define QUIRK_DRIVER_INFO \ + .driver_info = (unsigned long)&(const struct snd_usb_audio_quirk) + +/* +* Macros for quirk data entries +*/ + +/* Quirk data entry for ignoring the interface */ +#define QUIRK_DATA_IGNORE (_ifno) \ + .ifnum = (_ifno), .type = QUIRK_IGNORE_INTERFACE +/* Quirk data entry for a standard audio interface */ +#define QUIRK_DATA_STANDARD_AUDIO (_ifno) \ + .ifnum = (_ifno), .type = QUIRK_AUDIO_STANDARD_INTERFACE +/* Quirk data entry for a standard MIDI interface */ +#define QUIRK_DATA_STANDARD_MIDI (_ifno) \ + .ifnum = (_ifno), .type = QUIRK_MIDI_STANDARD_INTERFACE +/* Quirk data entry for a standard mixer interface */ +#define QUIRK_DATA_STANDARD_MIXER (_ifno) \ + .ifnum = (_ifno), .type = QUIRK_AUDIO_STANDARD_MIXER + +/* Quirk data entry for Yamaha MIDI */ +#define QUIRK_DATA_MIDI_YAMAHA (_ifno) \ + .ifnum = (_ifno), .type = QUIRK_MIDI_YAMAHA +/* Quirk data entry for Edirol UAxx */ +#define QUIRK_DATA_EDIROL_UAXX (_ifno) \ + .ifnum = (_ifno), .type = QUIRK_AUDIO_EDIROL_UAXX +/* Quirk data entry for raw bytes interface */ +#define QUIRK_DATA_RAW_BYTES (_ifno) \ + .ifnum = (_ifno), .type = QUIRK_MIDI_RAW_BYTES + +/* Quirk composite array terminator */ +#define QUIRK_COMPOSITE_END { .ifnum = -1 } + +/* Quirk data entry for composite quirks; +* followed by the quirk array that is terminated with QUIRK_COMPOSITE_END +* e.g. QUIRK_DATA_COMPOSITE { { quirk1 }, { quirk2 },..., QUIRK_COMPOSITE_END } +*/ +#define QUIRK_DATA_COMPOSITE \ + .ifnum = QUIRK_ANY_INTERFACE, \ + .type = QUIRK_COMPOSITE, \ + .data = &(const struct snd_usb_audio_quirk[]) + +/* Quirk data entry for a fixed audio endpoint; +* followed by audioformat definition +* e.g. QUIRK_DATA_AUDIOFORMAT(n) { .formats = xxx, ... } +*/ +#define QUIRK_DATA_AUDIOFORMAT (_ifno) \ + .ifnum = (_ifno), \ + .type = QUIRK_AUDIO_FIXED_ENDPOINT, \ + .data = &(const struct audioformat) + +/* Quirk data entry for a fixed MIDI endpoint; +* followed by snd_usb_midi_endpoint_info definition +* e.g. QUIRK_DATA_MIDI_FIXED_ENDPOINT(n) { .out_cables = x, .in_cables = y } +*/ +#define QUIRK_DATA_MIDI_FIXED_ENDPOINT (_ifno) \ + .ifnum = (_ifno), \ + .type = QUIRK_MIDI_FIXED_ENDPOINT, \ + .data = &(const struct snd_usb_midi_endpoint_info) +/* Quirk data entry for a MIDIMAN MIDI endpoint */ +#define QUIRK_DATA_MIDI_MIDIMAN (_ifno) \ + .ifnum = (_ifno), \ + .type = QUIRK_MIDI_MIDIMAN, \ + .data = &(const struct snd_usb_midi_endpoint_info) +/* Quirk data entry for a EMAGIC MIDI endpoint */ +#define QUIRK_DATA_MIDI_EMAGIC (_ifno) \ + .ifnum = (_ifno), \ + .type = QUIRK_MIDI_EMAGIC, \ + .data = &(const struct snd_usb_midi_endpoint_info) + +/* +* Here we go... the quirk table definition begins: +*/ +/* FTDI devices */ { USB_DEVICE(0x0403, 0xb8d8),
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 61/139 ALSA: usb-audio: Replace complex quirk lines with macros
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
[ Upstream commit d79e13f8e8abb5cd3a2a0f9fc9bc3fc750c5b06f ]
Apply the newly introduced macros for reduce the complex expressions and cast in the quirk table definitions. It results in a significant code reduction, too.
There should be no functional changes.
--- sound/usb/quirks-table.h | 2210 ++++++++++---------------------------- 1 file changed, 593 insertions(+), 1617 deletions(-)
sound/usb/quirks-table.h +593 -1617
@@ -115,7 +115,7 @@/* FTDI devices */ {USB_DEVICE (0x0403 ,0xb8d8 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO {/* .vendor_name = "STARR LABS", */ /* .product_name = "Starr Labs MIDI USB device", */ .ifnum = 0,
@@ -126,10 +126,8 @@ {/* Creative BT-D1 */ USB_DEVICE (0x041e ,0x0005 ), - .driver_info = (unsigned long ) &(const struct snd_usb_audio_quirk ) { - .ifnum =1 , - .type =QUIRK_AUDIO_FIXED_ENDPOINT , - .data = &(const struct audioformat ) { + QUIRK_DRIVER_INFO { + QUIRK_DATA_AUDIOFORMAT(1) { .formats = SNDRV_PCM_FMTBIT_S16_LE, .channels = 2, .iface = 1,
@@ -164,18 +162,11 @@*/ {USB_AUDIO_DEVICE (0x041e ,0x4095 ), - .driver_info = (unsigned long ) &(const struct snd_usb_audio_quirk ) { - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = &(const struct snd_usb_audio_quirk []) { - { - .ifnum =2 , - .type =QUIRK_AUDIO_STANDARD_MIXER , - }, + QUIRK_DRIVER_INFO { + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_MIXER(2) }, { - .ifnum =3 , - .type =QUIRK_AUDIO_FIXED_ENDPOINT , - .data = &(const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(3) { .formats = SNDRV_PCM_FMTBIT_S16_LE, .channels = 2, .fmt_bits = 16,
@@ -191,9 +182,7 @@ .rate_table = (unsigned int[]) { 48000 }, }, }, - { - .ifnum = -1 - }, +QUIRK_COMPOSITE_END }, }, },
@@ -205,31 +194,18 @@*/ {USB_DEVICE (0x0424 ,0xb832 ), - .driver_info = (unsigned long ) &(const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Standard Microsystems Corp." , .product_name = "HP Wireless Audio", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { + QUIRK_DATA_COMPOSITE {/* Mixer */ - { - .ifnum =0 , - .type =QUIRK_IGNORE_INTERFACE , - }, + { QUIRK_DATA_IGNORE(0) },/* Playback */ - { - .ifnum =1 , - .type =QUIRK_IGNORE_INTERFACE , - }, + { QUIRK_DATA_IGNORE(1) },/* Capture */ - { - .ifnum =2 , - .type =QUIRK_IGNORE_INTERFACE , - }, + { QUIRK_DATA_IGNORE(2) },/* HID Device, .ifnum = 3 */ - { - .ifnum =-1 , - } + QUIRK_COMPOSITE_END } } },
@@ -252,20 +228,18 @@#define YAMAHA_DEVICE (id, name) { \ USB_DEVICE(0x0499, id), \ - .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { \ + QUIRK_DRIVER_INFO { \ .vendor_name = "Yamaha", \ .product_name = name, \ - .ifnum = QUIRK_ANY_INTERFACE, \ - .type = QUIRK_MIDI_YAMAHA \ + QUIRK_DATA_MIDI_YAMAHA(QUIRK_ANY_INTERFACE) \ } \ }#define YAMAHA_INTERFACE (id, intf, name) { \ USB_DEVICE_VENDOR_SPEC(0x0499, id), \ - .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { \ + QUIRK_DRIVER_INFO { \ .vendor_name = "Yamaha", \ .product_name = name, \ - .ifnum = intf, \ - .type = QUIRK_MIDI_YAMAHA \ + QUIRK_DATA_MIDI_YAMAHA(intf) \ } \ } YAMAHA_DEVICE(0x1000, "UX256"),
@@ -353,135 +327,67 @@ YAMAHA_DEVICE(0x105d, NULL), YAMAHA_DEVICE(0x1718, "P-125"), { USB_DEVICE(0x0499, 0x1503), - .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { + QUIRK_DRIVER_INFO { /* .vendor_name = "Yamaha", */ /* .product_name = "MOX6/MOX8", */ - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =1 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =3 , - .type =QUIRK_MIDI_YAMAHA - }, - { - .ifnum =-1 - } + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_AUDIO(1) }, + { QUIRK_DATA_STANDARD_AUDIO(2) }, + { QUIRK_DATA_MIDI_YAMAHA(3) }, + QUIRK_COMPOSITE_END } } }, { USB_DEVICE(0x0499, 0x1507), - .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { + QUIRK_DRIVER_INFO { /* .vendor_name = "Yamaha", */ /* .product_name = "THR10", */ - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =1 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =3 , - .type =QUIRK_MIDI_YAMAHA - }, - { - .ifnum =-1 - } + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_AUDIO(1) }, + { QUIRK_DATA_STANDARD_AUDIO(2) }, + { QUIRK_DATA_MIDI_YAMAHA(3) }, + QUIRK_COMPOSITE_END } } }, { USB_DEVICE(0x0499, 0x1509), - .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { + QUIRK_DRIVER_INFO { /* .vendor_name = "Yamaha", */ /* .product_name = "Steinberg UR22", */ - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =1 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =3 , - .type =QUIRK_MIDI_YAMAHA - }, - { - .ifnum =4 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =-1 - } + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_AUDIO(1) }, + { QUIRK_DATA_STANDARD_AUDIO(2) }, + { QUIRK_DATA_MIDI_YAMAHA(3) }, + { QUIRK_DATA_IGNORE(4) }, + QUIRK_COMPOSITE_END } } }, { USB_DEVICE(0x0499, 0x150a), - .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { + QUIRK_DRIVER_INFO { /* .vendor_name = "Yamaha", */ /* .product_name = "THR5A", */ - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =1 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =3 , - .type =QUIRK_MIDI_YAMAHA - }, - { - .ifnum =-1 - } + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_AUDIO(1) }, + { QUIRK_DATA_STANDARD_AUDIO(2) }, + { QUIRK_DATA_MIDI_YAMAHA(3) }, + QUIRK_COMPOSITE_END } } }, { USB_DEVICE(0x0499, 0x150c), - .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { + QUIRK_DRIVER_INFO { /* .vendor_name = "Yamaha", */ /* .product_name = "THR10C", */ - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =1 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =3 , - .type =QUIRK_MIDI_YAMAHA - }, - { - .ifnum =-1 - } + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_AUDIO(1) }, + { QUIRK_DATA_STANDARD_AUDIO(2) }, + { QUIRK_DATA_MIDI_YAMAHA(3) }, + QUIRK_COMPOSITE_END } } },
@@ -515,7 +421,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), USB_DEVICE_ID_MATCH_INT_CLASS, .idVendor = 0x0499, .bInterfaceClass =USB_CLASS_VENDOR_SPEC , - .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { + QUIRK_DRIVER_INFO { .ifnum =QUIRK_ANY_INTERFACE , .type = QUIRK_AUTODETECT }
@@ -526,16 +432,12 @@ YAMAHA_DEVICE(0x7010, "UB99"),*/ {USB_DEVICE (0x0582 ,0x0000 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Roland" , .product_name = "UA-100", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { + QUIRK_DATA_COMPOSITE { { - .ifnum =0 , - .type =QUIRK_AUDIO_FIXED_ENDPOINT , - .data = & (const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(0) { .formats = SNDRV_PCM_FMTBIT_S16_LE, .channels = 4, .iface = 0,
@@ -550,9 +452,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { - .ifnum = 1, - .type = QUIRK_AUDIO_FIXED_ENDPOINT, - .data = & (const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(1) { .formats = SNDRV_PCM_FMTBIT_S16_LE, .channels = 2, .iface = 1,
@@ -567,106 +467,66 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { - .ifnum = 2, - .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const struct snd_usb_midi_endpoint_info) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(2) { .out_cables = 0x0007, .in_cables = 0x0007 } }, - { - .ifnum = -1 - } + QUIRK_COMPOSITE_END } } }, {USB_DEVICE (0x0582 ,0x0002 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="EDIROL" , .product_name = "UM-4", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =0 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =1 , - .type =QUIRK_IGNORE_INTERFACE - }, + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_IGNORE(0) }, + { QUIRK_DATA_IGNORE(1) }, { - .ifnum =2 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(2) { .out_cables =0x000f , .in_cables = 0x000f } }, - { - .ifnum =-1 - } + QUIRK_COMPOSITE_END } } }, {USB_DEVICE (0x0582 ,0x0003 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Roland" , .product_name = "SC-8850", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =0 , - .type =QUIRK_IGNORE_INTERFACE - }, + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_IGNORE(0) }, + { QUIRK_DATA_IGNORE(1) }, { - .ifnum =1 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(2) { .out_cables =0x003f , .in_cables = 0x003f } }, - { - .ifnum =-1 - } + QUIRK_COMPOSITE_END } } }, {USB_DEVICE (0x0582 ,0x0004 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Roland" , .product_name = "U-8", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_IGNORE(0) }, + { QUIRK_DATA_IGNORE(1) }, { - .ifnum =0 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =1 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(2) { .out_cables =0x0005 , .in_cables = 0x0005 } }, - { - .ifnum =-1 - } + QUIRK_COMPOSITE_END } } },
@@ -674,152 +534,92 @@ YAMAHA_DEVICE(0x7010, "UB99"),/* Has ID 0x0099 when not in "Advanced Driver" mode. * The UM-2EX has only one input, but we cannot detect this. */ USB_DEVICE (0x0582 ,0x0005 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="EDIROL" , .product_name = "UM-2", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =0 , - .type =QUIRK_IGNORE_INTERFACE - }, + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_IGNORE(0) }, + { QUIRK_DATA_IGNORE(1) }, { - .ifnum =1 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(2) { .out_cables =0x0003 , .in_cables = 0x0003 } }, - { - .ifnum =-1 - } + QUIRK_COMPOSITE_END } } }, {USB_DEVICE (0x0582 ,0x0007 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Roland" , .product_name = "SC-8820", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =0 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =1 , - .type =QUIRK_IGNORE_INTERFACE - }, + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_IGNORE(0) }, + { QUIRK_DATA_IGNORE(1) }, { - .ifnum =2 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(2) { .out_cables =0x0013 , .in_cables = 0x0013 } }, - { - .ifnum =-1 - } + QUIRK_COMPOSITE_END } } }, {USB_DEVICE (0x0582 ,0x0008 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Roland" , .product_name = "PC-300", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =0 , - .type =QUIRK_IGNORE_INTERFACE - }, + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_IGNORE(0) }, + { QUIRK_DATA_IGNORE(1) }, { - .ifnum =1 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(2) { .out_cables =0x0001 , .in_cables = 0x0001 } }, - { - .ifnum =-1 - } + QUIRK_COMPOSITE_END } } }, {/* has ID 0x009d when not in "Advanced Driver" mode */ USB_DEVICE (0x0582 ,0x0009 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="EDIROL" , .product_name = "UM-1", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_IGNORE(0) }, + { QUIRK_DATA_IGNORE(1) }, { - .ifnum =0 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =1 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(2) { .out_cables =0x0001 , .in_cables = 0x0001 } }, - { - .ifnum =-1 - } + QUIRK_COMPOSITE_END } } }, {USB_DEVICE (0x0582 ,0x000b ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Roland" , .product_name = "SK-500", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =0 , - .type =QUIRK_IGNORE_INTERFACE - }, + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_IGNORE(0) }, + { QUIRK_DATA_IGNORE(1) }, { - .ifnum =1 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(2) { .out_cables =0x0013 , .in_cables = 0x0013 } }, - { - .ifnum =-1 - } + QUIRK_COMPOSITE_END } } },
@@ -827,31 +627,19 @@ YAMAHA_DEVICE(0x7010, "UB99"),/* thanks to Emiliano Grilli <[email protected]> * for helping researching this data */ USB_DEVICE (0x0582 ,0x000c ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Roland" , .product_name = "SC-D70", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =0 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =1 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_AUDIO(0) }, + { QUIRK_DATA_STANDARD_AUDIO(1) }, { - .ifnum =2 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(2) { .out_cables =0x0007 , .in_cables = 0x0007 } }, - { - .ifnum =-1 - } + QUIRK_COMPOSITE_END } } },
@@ -865,35 +653,23 @@ YAMAHA_DEVICE(0x7010, "UB99"),* the 96kHz sample rate. */ USB_DEVICE (0x0582 ,0x0010 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="EDIROL" , .product_name = "UA-5", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =1 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =-1 - } + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_AUDIO(1) }, + { QUIRK_DATA_STANDARD_AUDIO(2) }, + QUIRK_COMPOSITE_END } } }, {/* has ID 0x0013 when not in "Advanced Driver" mode */ USB_DEVICE (0x0582 ,0x0012 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Roland" , .product_name = "XV-5050", - .ifnum =0 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(0) { .out_cables =0x0001 , .in_cables = 0x0001 }
@@ -902,12 +678,10 @@ YAMAHA_DEVICE(0x7010, "UB99"), {/* has ID 0x0015 when not in "Advanced Driver" mode */ USB_DEVICE (0x0582 ,0x0014 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="EDIROL" , .product_name = "UM-880", - .ifnum =0 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(0) { .out_cables =0x01ff , .in_cables = 0x01ff }
@@ -916,74 +690,48 @@ YAMAHA_DEVICE(0x7010, "UB99"), {/* has ID 0x0017 when not in "Advanced Driver" mode */ USB_DEVICE (0x0582 ,0x0016 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="EDIROL" , .product_name = "SD-90", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =0 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_AUDIO(0) }, + { QUIRK_DATA_STANDARD_AUDIO(1) }, { - .ifnum =1 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(2) { .out_cables =0x000f , .in_cables = 0x000f } }, - { - .ifnum =-1 - } + QUIRK_COMPOSITE_END } } }, {/* has ID 0x001c when not in "Advanced Driver" mode */ USB_DEVICE (0x0582 ,0x001b ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Roland" , .product_name = "MMP-2", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =0 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =1 , - .type =QUIRK_IGNORE_INTERFACE - }, + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_IGNORE(0) }, + { QUIRK_DATA_IGNORE(1) }, { - .ifnum =2 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(2) { .out_cables =0x0001 , .in_cables = 0x0001 } }, - { - .ifnum =-1 - } + QUIRK_COMPOSITE_END } } }, {/* has ID 0x001e when not in "Advanced Driver" mode */ USB_DEVICE (0x0582 ,0x001d ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Roland" , .product_name = "V-SYNTH", - .ifnum =0 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(0) { .out_cables =0x0001 , .in_cables = 0x0001 }
@@ -992,12 +740,10 @@ YAMAHA_DEVICE(0x7010, "UB99"), {/* has ID 0x0024 when not in "Advanced Driver" mode */ USB_DEVICE (0x0582 ,0x0023 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="EDIROL" , .product_name = "UM-550", - .ifnum =0 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(0) { .out_cables =0x003f , .in_cables = 0x003f }
@@ -1010,20 +756,13 @@ YAMAHA_DEVICE(0x7010, "UB99"),* and no MIDI. */ USB_DEVICE (0x0582 ,0x0025 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="EDIROL" , .product_name = "UA-20", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =0 , - .type =QUIRK_IGNORE_INTERFACE - }, + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_IGNORE(0) }, { - .ifnum =1 , - .type =QUIRK_AUDIO_FIXED_ENDPOINT , - .data = & (const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(1) { .formats = SNDRV_PCM_FMTBIT_S24_3LE, .channels = 2, .iface = 1,
@@ -1038,9 +777,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { - .ifnum = 2, - .type = QUIRK_AUDIO_FIXED_ENDPOINT, - .data = & (const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(2) { .formats = SNDRV_PCM_FMTBIT_S24_3LE, .channels = 2, .iface = 2,
@@ -1055,28 +792,22 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { - .ifnum = 3, - .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const struct snd_usb_midi_endpoint_info) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(3) { .out_cables = 0x0001, .in_cables = 0x0001 } }, - { - .ifnum = -1 - } + QUIRK_COMPOSITE_END } } }, {/* has ID 0x0028 when not in "Advanced Driver" mode */ USB_DEVICE (0x0582 ,0x0027 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="EDIROL" , .product_name = "SD-20", - .ifnum =0 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(0) { .out_cables =0x0003 , .in_cables = 0x0007 }
@@ -1085,12 +816,10 @@ YAMAHA_DEVICE(0x7010, "UB99"), {/* has ID 0x002a when not in "Advanced Driver" mode */ USB_DEVICE (0x0582 ,0x0029 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="EDIROL" , .product_name = "SD-80", - .ifnum =0 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(0) { .out_cables =0x000f , .in_cables = 0x000f }
@@ -1103,39 +832,24 @@ YAMAHA_DEVICE(0x7010, "UB99"),* but offers only 16-bit PCM and no MIDI. */ USB_DEVICE_VENDOR_SPEC (0x0582 ,0x002b ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="EDIROL" , .product_name = "UA-700", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =1 , - .type =QUIRK_AUDIO_EDIROL_UAXX - }, - { - .ifnum =2 , - .type =QUIRK_AUDIO_EDIROL_UAXX - }, - { - .ifnum =3 , - .type =QUIRK_AUDIO_EDIROL_UAXX - }, - { - .ifnum =-1 - } + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_EDIROL_UAXX(1) }, + { QUIRK_DATA_EDIROL_UAXX(2) }, + { QUIRK_DATA_EDIROL_UAXX(3) }, + QUIRK_COMPOSITE_END } } }, {/* has ID 0x002e when not in "Advanced Driver" mode */ USB_DEVICE (0x0582 ,0x002d ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Roland" , .product_name = "XV-2020", - .ifnum =0 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(0) { .out_cables =0x0001 , .in_cables = 0x0001 }
@@ -1144,12 +858,10 @@ YAMAHA_DEVICE(0x7010, "UB99"), {/* has ID 0x0030 when not in "Advanced Driver" mode */ USB_DEVICE (0x0582 ,0x002f ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Roland" , .product_name = "VariOS", - .ifnum =0 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(0) { .out_cables =0x0007 , .in_cables = 0x0007 }
@@ -1158,12 +870,10 @@ YAMAHA_DEVICE(0x7010, "UB99"), {/* has ID 0x0034 when not in "Advanced Driver" mode */ USB_DEVICE (0x0582 ,0x0033 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="EDIROL" , .product_name = "PCR", - .ifnum =0 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(0) { .out_cables =0x0003 , .in_cables = 0x0007 }
@@ -1175,12 +885,10 @@ YAMAHA_DEVICE(0x7010, "UB99"),* later revisions use IDs 0x0054 and 0x00a2. */ USB_DEVICE (0x0582 ,0x0037 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Roland" , .product_name = "Digital Piano", - .ifnum =0 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(0) { .out_cables =0x0001 , .in_cables = 0x0001 }
@@ -1193,39 +901,24 @@ YAMAHA_DEVICE(0x7010, "UB99"),* and no MIDI. */ USB_DEVICE_VENDOR_SPEC (0x0582 ,0x003b ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="BOSS" , .product_name = "GS-10", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = & (const struct snd_usb_audio_quirk []) { - { - .ifnum =1 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =3 , - .type =QUIRK_MIDI_STANDARD_INTERFACE - }, - { - .ifnum =-1 - } + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_AUDIO(1) }, + { QUIRK_DATA_STANDARD_AUDIO(2) }, + { QUIRK_DATA_STANDARD_MIDI(3) }, + QUIRK_COMPOSITE_END } } }, {/* has ID 0x0041 when not in "Advanced Driver" mode */ USB_DEVICE (0x0582 ,0x0040 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Roland" , .product_name = "GI-20", - .ifnum =0 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(0) { .out_cables =0x0001 , .in_cables = 0x0001 }
@@ -1234,12 +927,10 @@ YAMAHA_DEVICE(0x7010, "UB99"), {/* has ID 0x0043 when not in "Advanced Driver" mode */ USB_DEVICE (0x0582 ,0x0042 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Roland" , .product_name = "RS-70", - .ifnum =0 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(0) { .out_cables =0x0001 , .in_cables = 0x0001 }
@@ -1248,36 +939,24 @@ YAMAHA_DEVICE(0x7010, "UB99"), {/* has ID 0x0049 when not in "Advanced Driver" mode */ USB_DEVICE (0x0582 ,0x0047 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO {/* .vendor_name = "EDIROL", */ /* .product_name = "UR-80", */ - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { + QUIRK_DATA_COMPOSITE {/* in the 96 kHz modes, only interface 1 is there */ - { - .ifnum =1 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =-1 - } + { QUIRK_DATA_STANDARD_AUDIO(1) }, + { QUIRK_DATA_STANDARD_AUDIO(2) }, + QUIRK_COMPOSITE_END } } }, {/* has ID 0x004a when not in "Advanced Driver" mode */ USB_DEVICE (0x0582 ,0x0048 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO {/* .vendor_name = "EDIROL", */ /* .product_name = "UR-80", */ - .ifnum =0 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(0) { .out_cables = 0x0003, .in_cables = 0x0007 }
@@ -1286,35 +965,23 @@ YAMAHA_DEVICE(0x7010, "UB99"), {/* has ID 0x004e when not in "Advanced Driver" mode */ USB_DEVICE (0x0582 ,0x004c ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="EDIROL" , .product_name = "PCR-A", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =1 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =-1 - } + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_AUDIO(1) }, + { QUIRK_DATA_STANDARD_AUDIO(2) }, + QUIRK_COMPOSITE_END } } }, {/* has ID 0x004f when not in "Advanced Driver" mode */ USB_DEVICE (0x0582 ,0x004d ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="EDIROL" , .product_name = "PCR-A", - .ifnum =0 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(0) { .out_cables =0x0003 , .in_cables = 0x0007 }
@@ -1326,76 +993,52 @@ YAMAHA_DEVICE(0x7010, "UB99"),* is standard compliant, but has only 16-bit PCM. */ USB_DEVICE (0x0582 ,0x0050 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="EDIROL" , .product_name = "UA-3FX", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =1 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =-1 - } + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_AUDIO(1) }, + { QUIRK_DATA_STANDARD_AUDIO(2) }, + QUIRK_COMPOSITE_END } } }, {USB_DEVICE (0x0582 ,0x0052 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="EDIROL" , .product_name = "UM-1SX", - .ifnum =0 , - .type =QUIRK_MIDI_STANDARD_INTERFACE + QUIRK_DATA_STANDARD_MIDI(0) } }, {USB_DEVICE (0x0582 ,0x0060 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Roland" , .product_name = "EXR Series", - .ifnum =0 , - .type =QUIRK_MIDI_STANDARD_INTERFACE +QUIRK_DATA_STANDARD_MIDI (0 ) } }, {/* has ID 0x0066 when not in "Advanced Driver" mode */ USB_DEVICE (0x0582 ,0x0064 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO {/* .vendor_name = "EDIROL", */ /* .product_name = "PCR-1", */ - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =1 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =-1 - } + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_AUDIO(1) }, + { QUIRK_DATA_STANDARD_AUDIO(2) }, + QUIRK_COMPOSITE_END } } }, {/* has ID 0x0067 when not in "Advanced Driver" mode */ USB_DEVICE (0x0582 ,0x0065 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO {/* .vendor_name = "EDIROL", */ /* .product_name = "PCR-1", */ - .ifnum =0 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(0) { .out_cables = 0x0001, .in_cables =0x0003 }
@@ -1404,12 +1047,10 @@ YAMAHA_DEVICE(0x7010, "UB99"), {/* has ID 0x006e when not in "Advanced Driver" mode */ USB_DEVICE (0x0582 ,0x006d ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Roland" , .product_name = "FANTOM-X", - .ifnum =0 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(0) { .out_cables =0x0001 , .in_cables = 0x0001 }
@@ -1422,39 +1063,24 @@ YAMAHA_DEVICE(0x7010, "UB99"),* offers only 16-bit PCM at 44.1 kHz and no MIDI. */ USB_DEVICE_VENDOR_SPEC (0x0582 ,0x0074 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="EDIROL" , .product_name = "UA-25", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =0 , - .type =QUIRK_AUDIO_EDIROL_UAXX - }, - { - .ifnum =1 , - .type =QUIRK_AUDIO_EDIROL_UAXX - }, - { - .ifnum =2 , - .type =QUIRK_AUDIO_EDIROL_UAXX - }, - { - .ifnum =-1 - } + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_EDIROL_UAXX(0) }, + { QUIRK_DATA_EDIROL_UAXX(1) }, + { QUIRK_DATA_EDIROL_UAXX(2) }, + QUIRK_COMPOSITE_END } } }, {/* has ID 0x0076 when not in "Advanced Driver" mode */ USB_DEVICE (0x0582 ,0x0075 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="BOSS" , .product_name = "DR-880", - .ifnum =0 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(0) { .out_cables =0x0001 , .in_cables = 0x0001 }
@@ -1463,12 +1089,10 @@ YAMAHA_DEVICE(0x7010, "UB99"), {/* has ID 0x007b when not in "Advanced Driver" mode */ USB_DEVICE_VENDOR_SPEC (0x0582 ,0x007a ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Roland" ,/* "RD" or "RD-700SX"? */ - .ifnum =0 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(0) { .out_cables =0x0003 , .in_cables = 0x0003 }
@@ -1477,12 +1101,10 @@ YAMAHA_DEVICE(0x7010, "UB99"), {/* has ID 0x0081 when not in "Advanced Driver" mode */ USB_DEVICE (0x0582 ,0x0080 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Roland" , .product_name = "G-70", - .ifnum =0 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(0) { .out_cables =0x0001 , .in_cables = 0x0001 }
@@ -1491,12 +1113,10 @@ YAMAHA_DEVICE(0x7010, "UB99"), {/* has ID 0x008c when not in "Advanced Driver" mode */ USB_DEVICE (0x0582 ,0x008b ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="EDIROL" , .product_name = "PC-50", - .ifnum =0 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(0) { .out_cables =0x0001 , .in_cables = 0x0001 }
@@ -1508,56 +1128,31 @@ YAMAHA_DEVICE(0x7010, "UB99"),* is standard compliant, but has only 16-bit PCM and no MIDI. */ USB_DEVICE (0x0582 ,0x00a3 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="EDIROL" , .product_name = "UA-4FX", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =0 , - .type =QUIRK_AUDIO_EDIROL_UAXX - }, - { - .ifnum =1 , - .type =QUIRK_AUDIO_EDIROL_UAXX - }, - { - .ifnum =2 , - .type =QUIRK_AUDIO_EDIROL_UAXX - }, - { - .ifnum =-1 - } + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_EDIROL_UAXX(0) }, + { QUIRK_DATA_EDIROL_UAXX(1) }, + { QUIRK_DATA_EDIROL_UAXX(2) }, + QUIRK_COMPOSITE_END } } }, {/* Edirol M-16DX */ USB_DEVICE (0x0582 ,0x00c4 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { + QUIRK_DRIVER_INFO { + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_AUDIO(0) }, + { QUIRK_DATA_STANDARD_AUDIO(1) }, { - .ifnum =0 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =1 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(2) { .out_cables =0x0001 , .in_cables = 0x0001 } }, - { - .ifnum =-1 - } + QUIRK_COMPOSITE_END } } },
@@ -1567,37 +1162,22 @@ YAMAHA_DEVICE(0x7010, "UB99"),* offers only 16-bit PCM at 44.1 kHz and no MIDI. */ USB_DEVICE_VENDOR_SPEC (0x0582 ,0x00e6 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="EDIROL" , .product_name = "UA-25EX", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =0 , - .type =QUIRK_AUDIO_EDIROL_UAXX - }, - { - .ifnum =1 , - .type =QUIRK_AUDIO_EDIROL_UAXX - }, - { - .ifnum =2 , - .type =QUIRK_AUDIO_EDIROL_UAXX - }, - { - .ifnum =-1 - } + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_EDIROL_UAXX(0) }, + { QUIRK_DATA_EDIROL_UAXX(1) }, + { QUIRK_DATA_EDIROL_UAXX(2) }, + QUIRK_COMPOSITE_END } } }, {/* Edirol UM-3G */ USB_DEVICE_VENDOR_SPEC (0x0582 ,0x0108 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { - .ifnum =0 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DRIVER_INFO { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(0) { .out_cables = 0x0007, .in_cables =0x0007 }
@@ -1606,45 +1186,29 @@ YAMAHA_DEVICE(0x7010, "UB99"), {/* BOSS ME-25 */ USB_DEVICE (0x0582 ,0x0113 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { + QUIRK_DRIVER_INFO { + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_AUDIO(0) }, + { QUIRK_DATA_STANDARD_AUDIO(1) }, { - .ifnum =0 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =1 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(2) { .out_cables =0x0001 , .in_cables = 0x0001 } }, - { - .ifnum =-1 - } + QUIRK_COMPOSITE_END } } }, {/* only 44.1 kHz works at the moment */ USB_DEVICE (0x0582 ,0x0120 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO {/* .vendor_name = "Roland", */ /* .product_name = "OCTO-CAPTURE", */ - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { + QUIRK_DATA_COMPOSITE { { - .ifnum =0 , - .type =QUIRK_AUDIO_FIXED_ENDPOINT , - .data = & (const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(0) { .formats = SNDRV_PCM_FMTBIT_S32_LE, .channels = 10, .iface = 0,
@@ -1660,9 +1224,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { - .ifnum = 1, - .type = QUIRK_AUDIO_FIXED_ENDPOINT, - .data = & (const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(1) { .formats = SNDRV_PCM_FMTBIT_S32_LE, .channels = 12, .iface = 1,
@@ -1678,40 +1240,26 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { - .ifnum = 2, - .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(2) { .out_cables = 0x0001, .in_cables = 0x0001 } }, - { - .ifnum = 3, - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum = 4, - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum = -1 - } + { QUIRK_DATA_IGNORE(3) }, + { QUIRK_DATA_IGNORE(4) }, + QUIRK_COMPOSITE_END } } }, {/* only 44.1 kHz works at the moment */ USB_DEVICE (0x0582 ,0x012f ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO {/* .vendor_name = "Roland", */ /* .product_name = "QUAD-CAPTURE", */ - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { + QUIRK_DATA_COMPOSITE { { - .ifnum =0 , - .type =QUIRK_AUDIO_FIXED_ENDPOINT , - .data = & (const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(0) { .formats = SNDRV_PCM_FMTBIT_S32_LE, .channels = 4, .iface = 0,
@@ -1727,9 +1275,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { - .ifnum = 1, - .type = QUIRK_AUDIO_FIXED_ENDPOINT, - .data = & (const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(1) { .formats = SNDRV_PCM_FMTBIT_S32_LE, .channels = 6, .iface = 1,
@@ -1745,54 +1291,32 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { - .ifnum = 2, - .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(2) { .out_cables = 0x0001, .in_cables = 0x0001 } }, - { - .ifnum = 3, - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum = 4, - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum = -1 - } + { QUIRK_DATA_IGNORE(3) }, + { QUIRK_DATA_IGNORE(4) }, + QUIRK_COMPOSITE_END } } }, {USB_DEVICE (0x0582 ,0x0159 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO {/* .vendor_name = "Roland", */ /* .product_name = "UA-22", */ - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =0 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_AUDIO(0) }, + { QUIRK_DATA_STANDARD_AUDIO(1) }, { - .ifnum =1 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(2) { .out_cables =0x0001 , .in_cables = 0x0001 } }, - { - .ifnum =-1 - } + QUIRK_COMPOSITE_END } } },
@@ -1800,19 +1324,19 @@ YAMAHA_DEVICE(0x7010, "UB99"),/* UA101 and co are supported by another driver */ {USB_DEVICE (0x0582 ,0x0044 ),/* UA-1000 high speed */ - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .ifnum =QUIRK_NODEV_INTERFACE }, }, {USB_DEVICE (0x0582 ,0x007d ),/* UA-101 high speed */ - .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { + QUIRK_DRIVER_INFO { .ifnum =QUIRK_NODEV_INTERFACE }, }, {USB_DEVICE (0x0582 ,0x008d ),/* UA-101 full speed */ - .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { + QUIRK_DRIVER_INFO { .ifnum =QUIRK_NODEV_INTERFACE }, },
@@ -1823,7 +1347,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), USB_DEVICE_ID_MATCH_INT_CLASS, .idVendor = 0x0582, .bInterfaceClass =USB_CLASS_VENDOR_SPEC , - .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { + QUIRK_DRIVER_INFO { .ifnum =QUIRK_ANY_INTERFACE , .type = QUIRK_AUTODETECT }
@@ -1838,12 +1362,10 @@ YAMAHA_DEVICE(0x7010, "UB99"),* compliant USB MIDI ports for external MIDI and controls. */ USB_DEVICE_VENDOR_SPEC (0x06f8 ,0xb000 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Hercules" , .product_name = "DJ Console (WE)", - .ifnum =4 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(4) { .out_cables =0x0001 , .in_cables = 0x0001 }
@@ -1853,12 +1375,10 @@ YAMAHA_DEVICE(0x7010, "UB99"),/* Midiman/M-Audio devices */ {USB_DEVICE_VENDOR_SPEC (0x0763 ,0x1002 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="M-Audio" , .product_name = "MidiSport 2x2", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_MIDI_MIDIMAN , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_MIDIMAN(QUIRK_ANY_INTERFACE) { .out_cables =0x0003 , .in_cables = 0x0003 }
@@ -1866,12 +1386,10 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, {USB_DEVICE_VENDOR_SPEC (0x0763 ,0x1011 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="M-Audio" , .product_name = "MidiSport 1x1", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_MIDI_MIDIMAN , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_MIDIMAN(QUIRK_ANY_INTERFACE) { .out_cables =0x0001 , .in_cables = 0x0001 }
@@ -1879,12 +1397,10 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, {USB_DEVICE_VENDOR_SPEC (0x0763 ,0x1015 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="M-Audio" , .product_name = "Keystation", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_MIDI_MIDIMAN , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_MIDIMAN(QUIRK_ANY_INTERFACE) { .out_cables =0x0001 , .in_cables = 0x0001 }
@@ -1892,12 +1408,10 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, {USB_DEVICE_VENDOR_SPEC (0x0763 ,0x1021 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="M-Audio" , .product_name = "MidiSport 4x4", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_MIDI_MIDIMAN , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_MIDIMAN(QUIRK_ANY_INTERFACE) { .out_cables =0x000f , .in_cables = 0x000f }
@@ -1910,12 +1424,10 @@ YAMAHA_DEVICE(0x7010, "UB99"),* Thanks to Olaf Giesbrecht <[email protected]> */ USB_DEVICE_VER (0x0763 ,0x1031 ,0x0100 ,0x0109 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="M-Audio" , .product_name = "MidiSport 8x8", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_MIDI_MIDIMAN , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_MIDIMAN(QUIRK_ANY_INTERFACE) { .out_cables =0x01ff , .in_cables = 0x01ff }
@@ -1923,12 +1435,10 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, {USB_DEVICE_VENDOR_SPEC (0x0763 ,0x1033 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="M-Audio" , .product_name = "MidiSport 8x8", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_MIDI_MIDIMAN , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_MIDIMAN(QUIRK_ANY_INTERFACE) { .out_cables =0x01ff , .in_cables = 0x01ff }
@@ -1936,12 +1446,10 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, {USB_DEVICE_VENDOR_SPEC (0x0763 ,0x1041 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="M-Audio" , .product_name = "MidiSport 2x4", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_MIDI_MIDIMAN , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_MIDIMAN(QUIRK_ANY_INTERFACE) { .out_cables =0x000f , .in_cables = 0x0003 }
@@ -1949,76 +1457,41 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, {USB_DEVICE_VENDOR_SPEC (0x0763 ,0x2001 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="M-Audio" , .product_name = "Quattro", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = & (const struct snd_usb_audio_quirk []) { + QUIRK_DATA_COMPOSITE {/* * Interfaces 0-2 are "Windows-compatible", 16-bit only, * and share endpoints with the other interfaces. * Ignore them. The other interfaces can do 24 bits, * but captured samples are big-endian (see usbaudio.c). */ - { - .ifnum =0 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =1 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =3 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =4 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =5 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =6 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =7 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =8 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =9 , - .type =QUIRK_MIDI_MIDIMAN , - .data = & (const struct snd_usb_midi_endpoint_info ) { + { QUIRK_DATA_IGNORE(0) }, + { QUIRK_DATA_IGNORE(1) }, + { QUIRK_DATA_IGNORE(2) }, + { QUIRK_DATA_IGNORE(3) }, + { QUIRK_DATA_STANDARD_AUDIO(4) }, + { QUIRK_DATA_STANDARD_AUDIO(5) }, + { QUIRK_DATA_IGNORE(6) }, + { QUIRK_DATA_STANDARD_AUDIO(7) }, + { QUIRK_DATA_STANDARD_AUDIO(8) }, + { + QUIRK_DATA_MIDI_MIDIMAN(9) { .out_cables =0x0001 , .in_cables = 0x0001 } }, - { - .ifnum =-1 - } +QUIRK_COMPOSITE_END } } }, {USB_DEVICE_VENDOR_SPEC (0x0763 ,0x2003 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="M-Audio" , .product_name = "AudioPhile", - .ifnum =6 , - .type =QUIRK_MIDI_MIDIMAN , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_MIDIMAN(6) { .out_cables =0x0001 , .in_cables = 0x0001 }
@@ -2026,12 +1499,10 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, {USB_DEVICE_VENDOR_SPEC (0x0763 ,0x2008 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="M-Audio" , .product_name = "Ozone", - .ifnum =3 , - .type =QUIRK_MIDI_MIDIMAN , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_MIDIMAN(3) { .out_cables =0x0001 , .in_cables = 0x0001 }
@@ -2039,93 +1510,45 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { USB_DEVICE_VENDOR_SPEC(0x0763, 0x200d), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name = "M-Audio", .product_name = "OmniStudio", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = & (const struct snd_usb_audio_quirk []) { - { - .ifnum =0 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =1 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =3 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =4 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =5 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =6 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =7 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =8 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =9 , - .type =QUIRK_MIDI_MIDIMAN , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_IGNORE(0) }, + { QUIRK_DATA_IGNORE(1) }, + { QUIRK_DATA_IGNORE(2) }, + { QUIRK_DATA_IGNORE(3) }, + { QUIRK_DATA_STANDARD_AUDIO(4) }, + { QUIRK_DATA_STANDARD_AUDIO(5) }, + { QUIRK_DATA_IGNORE(6) }, + { QUIRK_DATA_STANDARD_AUDIO(7) }, + { QUIRK_DATA_STANDARD_AUDIO(8) }, + { + QUIRK_DATA_MIDI_MIDIMAN(9) { .out_cables = 0x0001, .in_cables = 0x0001 } }, - { - .ifnum =-1 - } + QUIRK_COMPOSITE_END } } }, { USB_DEVICE(0x0763, 0x2019), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { /* .vendor_name = "M-Audio", */ /* .product_name = "Ozone Academic", */ - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = & (const struct snd_usb_audio_quirk []) { - { - .ifnum =0 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =1 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_AUDIO(0) }, + { QUIRK_DATA_STANDARD_AUDIO(1) }, + { QUIRK_DATA_STANDARD_AUDIO(2) }, { - .ifnum =2 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =3 , - .type =QUIRK_MIDI_MIDIMAN , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_MIDIMAN(3) { .out_cables = 0x0001, .in_cables = 0x0001 } }, - { - .ifnum =-1 - } + QUIRK_COMPOSITE_END } } },
@@ -2135,21 +1558,14 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, {USB_DEVICE_VENDOR_SPEC (0x0763 ,0x2030 ), - .driver_info = (unsigned long ) &(const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO {/* .vendor_name = "M-Audio", */ /* .product_name = "Fast Track C400", */ - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = &(const struct snd_usb_audio_quirk []) { - { - .ifnum =1 , - .type =QUIRK_AUDIO_STANDARD_MIXER , - }, + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_MIXER(1) }, /* Playback */ { - .ifnum =2 , - .type =QUIRK_AUDIO_FIXED_ENDPOINT , - .data = &(const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(2) { .formats = SNDRV_PCM_FMTBIT_S24_3LE, .channels = 6, .iface = 2,
@@ -2173,9 +1589,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), },/* Capture */ { - .ifnum = 3, - .type = QUIRK_AUDIO_FIXED_ENDPOINT, - .data = &(const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(3) { .formats = SNDRV_PCM_FMTBIT_S24_3LE, .channels = 4, .iface = 3,
@@ -2197,30 +1611,21 @@ YAMAHA_DEVICE(0x7010, "UB99"), .clock = 0x80, } }, -/* MIDI */ - { - .ifnum = -1 /* Interface = 4 */ - } +/* MIDI: Interface = 4*/ + QUIRK_COMPOSITE_END } } }, {USB_DEVICE_VENDOR_SPEC (0x0763 ,0x2031 ), - .driver_info = (unsigned long ) &(const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO {/* .vendor_name = "M-Audio", */ /* .product_name = "Fast Track C600", */ - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = &(const struct snd_usb_audio_quirk []) { - { - .ifnum =1 , - .type =QUIRK_AUDIO_STANDARD_MIXER , - }, + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_MIXER(1) }, /* Playback */ { - .ifnum =2 , - .type =QUIRK_AUDIO_FIXED_ENDPOINT , - .data = &(const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(2) { .formats = SNDRV_PCM_FMTBIT_S24_3LE, .channels = 8, .iface = 2,
@@ -2244,9 +1649,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), },/* Capture */ { - .ifnum = 3, - .type = QUIRK_AUDIO_FIXED_ENDPOINT, - .data = &(const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(3) { .formats = SNDRV_PCM_FMTBIT_S24_3LE, .channels = 6, .iface = 3,
@@ -2268,29 +1671,20 @@ YAMAHA_DEVICE(0x7010, "UB99"), .clock = 0x80, } }, -/* MIDI */ - { - .ifnum = -1 /* Interface = 4 */ - } +/* MIDI: Interface = 4 */ + QUIRK_COMPOSITE_END } } }, {USB_DEVICE_VENDOR_SPEC (0x0763 ,0x2080 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO {/* .vendor_name = "M-Audio", */ /* .product_name = "Fast Track Ultra", */ - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = & (const struct snd_usb_audio_quirk []) { - { - .ifnum =0 , - .type =QUIRK_AUDIO_STANDARD_MIXER , - }, + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_MIXER(0) }, { - .ifnum =1 , - .type =QUIRK_AUDIO_FIXED_ENDPOINT , - .data = & (const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(1) { .formats = SNDRV_PCM_FMTBIT_S24_3LE, .channels = 8, .iface = 1,
@@ -2312,9 +1706,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { - .ifnum = 2, - .type = QUIRK_AUDIO_FIXED_ENDPOINT, - .data = & (const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(2) { .formats = SNDRV_PCM_FMTBIT_S24_3LE, .channels = 8, .iface = 2,
@@ -2336,28 +1728,19 @@ YAMAHA_DEVICE(0x7010, "UB99"), } },/* interface 3 (MIDI) is standard compliant */ - { - .ifnum = -1 - } + QUIRK_COMPOSITE_END } } }, {USB_DEVICE_VENDOR_SPEC (0x0763 ,0x2081 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO {/* .vendor_name = "M-Audio", */ /* .product_name = "Fast Track Ultra 8R", */ - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = & (const struct snd_usb_audio_quirk []) { - { - .ifnum =0 , - .type =QUIRK_AUDIO_STANDARD_MIXER , - }, + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_MIXER(0) }, { - .ifnum =1 , - .type =QUIRK_AUDIO_FIXED_ENDPOINT , - .data = & (const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(1) { .formats = SNDRV_PCM_FMTBIT_S24_3LE, .channels = 8, .iface = 1,
@@ -2379,9 +1762,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { - .ifnum = 2, - .type = QUIRK_AUDIO_FIXED_ENDPOINT, - .data = & (const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(2) { .formats = SNDRV_PCM_FMTBIT_S24_3LE, .channels = 8, .iface = 2,
@@ -2403,9 +1784,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), } },/* interface 3 (MIDI) is standard compliant */ - { - .ifnum = -1 - } + QUIRK_COMPOSITE_END } } },
@@ -2413,21 +1792,19 @@ YAMAHA_DEVICE(0x7010, "UB99"),/* Casio devices */ {USB_DEVICE (0x07cf ,0x6801 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Casio" , .product_name = "PL-40R", - .ifnum =0 , - .type =QUIRK_MIDI_YAMAHA + QUIRK_DATA_MIDI_YAMAHA(0) } }, {/* this ID is used by several devices without a product ID */ USB_DEVICE (0x07cf ,0x6802 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Casio" , .product_name = "Keyboard", - .ifnum =0 , - .type =QUIRK_MIDI_YAMAHA +QUIRK_DATA_MIDI_YAMAHA (0 ) } },
@@ -2440,23 +1817,13 @@ YAMAHA_DEVICE(0x7010, "UB99"), .idVendor = 0x07fd, .idProduct = 0x0001, .bDeviceSubClass = 2, - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name = "MOTU", .product_name = "Fastlane", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = & (const struct snd_usb_audio_quirk []) { - { - .ifnum =0 , - .type =QUIRK_MIDI_RAW_BYTES - }, - { - .ifnum =1 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =-1 - } + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_RAW_BYTES(0) }, + { QUIRK_DATA_IGNORE(1) }, + QUIRK_COMPOSITE_END } } },
@@ -2464,12 +1831,10 @@ YAMAHA_DEVICE(0x7010, "UB99"),/* Emagic devices */ {USB_DEVICE (0x086a ,0x0001 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Emagic" , .product_name = "Unitor8", - .ifnum =2 , - .type =QUIRK_MIDI_EMAGIC , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_EMAGIC(2) { .out_cables =0x80ff , .in_cables = 0x80ff }
@@ -2477,12 +1842,10 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, {USB_DEVICE (0x086a ,0x0002 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Emagic" ,/* .product_name = "AMT8", */ - .ifnum =2 , - .type =QUIRK_MIDI_EMAGIC , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_EMAGIC(2) { .out_cables =0x80ff , .in_cables = 0x80ff }
@@ -2490,12 +1853,10 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, {USB_DEVICE (0x086a ,0x0003 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Emagic" ,/* .product_name = "MT4", */ - .ifnum =2 , - .type =QUIRK_MIDI_EMAGIC , - .data = & (const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_EMAGIC(2) { .out_cables =0x800f , .in_cables = 0x8003 }
@@ -2505,38 +1866,35 @@ YAMAHA_DEVICE(0x7010, "UB99"),/* KORG devices */ {USB_DEVICE_VENDOR_SPEC (0x0944 ,0x0200 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="KORG, Inc." ,/* .product_name = "PANDORA PX5D", */ - .ifnum =3 , - .type =QUIRK_MIDI_STANDARD_INTERFACE , + QUIRK_DATA_STANDARD_MIDI(3) } }, {USB_DEVICE_VENDOR_SPEC (0x0944 ,0x0201 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="KORG, Inc." ,/* .product_name = "ToneLab ST", */ - .ifnum =3 , - .type =QUIRK_MIDI_STANDARD_INTERFACE , +QUIRK_DATA_STANDARD_MIDI (3 ) } }, {USB_DEVICE_VENDOR_SPEC (0x0944 ,0x0204 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="KORG, Inc." ,/* .product_name = "ToneLab EX", */ - .ifnum =3 , - .type =QUIRK_MIDI_STANDARD_INTERFACE , +QUIRK_DATA_STANDARD_MIDI (3 ) } },/* AKAI devices */ {USB_DEVICE (0x09e8 ,0x0062 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="AKAI" , .product_name = "MPD16", .ifnum = 0,
@@ -2547,21 +1905,11 @@ YAMAHA_DEVICE(0x7010, "UB99"), {/* Akai MPC Element */ USB_DEVICE (0x09e8 ,0x0021 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = & (const struct snd_usb_audio_quirk []) { - { - .ifnum =0 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =1 , - .type =QUIRK_MIDI_STANDARD_INTERFACE - }, - { - .ifnum =-1 - } + QUIRK_DRIVER_INFO { + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_IGNORE(0) }, + { QUIRK_DATA_STANDARD_MIDI(1) }, + QUIRK_COMPOSITE_END } } },
@@ -2570,66 +1918,36 @@ YAMAHA_DEVICE(0x7010, "UB99"), {/* Steinberg MI2 */ USB_DEVICE_VENDOR_SPEC (0x0a4e ,0x2040 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = & (const struct snd_usb_audio_quirk []) { - { - .ifnum =0 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =1 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, + QUIRK_DRIVER_INFO { + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_AUDIO(0) }, + { QUIRK_DATA_STANDARD_AUDIO(1) }, + { QUIRK_DATA_STANDARD_AUDIO(2) }, { - .ifnum =3 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = &(const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(3) { .out_cables =0x0001 , .in_cables = 0x0001 } }, - { - .ifnum =-1 - } + QUIRK_COMPOSITE_END } } }, {/* Steinberg MI4 */ USB_DEVICE_VENDOR_SPEC (0x0a4e ,0x4040 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = & (const struct snd_usb_audio_quirk []) { - { - .ifnum =0 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =1 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE - }, + QUIRK_DRIVER_INFO { + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_AUDIO(0) }, + { QUIRK_DATA_STANDARD_AUDIO(1) }, + { QUIRK_DATA_STANDARD_AUDIO(2) }, { - .ifnum =3 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = &(const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(3) { .out_cables =0x0001 , .in_cables = 0x0001 } }, - { - .ifnum =-1 - } + QUIRK_COMPOSITE_END } } },
@@ -2637,34 +1955,31 @@ YAMAHA_DEVICE(0x7010, "UB99"),/* TerraTec devices */ {USB_DEVICE_VENDOR_SPEC (0x0ccd ,0x0012 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="TerraTec" , .product_name = "PHASE 26", - .ifnum =3 , - .type =QUIRK_MIDI_STANDARD_INTERFACE + QUIRK_DATA_STANDARD_MIDI(3) } }, {USB_DEVICE_VENDOR_SPEC (0x0ccd ,0x0013 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="TerraTec" , .product_name = "PHASE 26", - .ifnum =3 , - .type =QUIRK_MIDI_STANDARD_INTERFACE +QUIRK_DATA_STANDARD_MIDI (3 ) } }, {USB_DEVICE_VENDOR_SPEC (0x0ccd ,0x0014 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="TerraTec" , .product_name = "PHASE 26", - .ifnum =3 , - .type =QUIRK_MIDI_STANDARD_INTERFACE +QUIRK_DATA_STANDARD_MIDI (3 ) } }, {USB_DEVICE (0x0ccd ,0x0035 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Miditech" , .product_name = "Play'n Roll", .ifnum = 0,
@@ -2679,7 +1994,7 @@ YAMAHA_DEVICE(0x7010, "UB99"),/* Novation EMS devices */ {USB_DEVICE_VENDOR_SPEC (0x1235 ,0x0001 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Novation" , .product_name = "ReMOTE Audio/XStation", .ifnum = 4,
@@ -2688,7 +2003,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, {USB_DEVICE_VENDOR_SPEC (0x1235 ,0x0002 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Novation" , .product_name = "Speedio", .ifnum = 3,
@@ -2697,38 +2012,29 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, {USB_DEVICE (0x1235 ,0x000a ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO {/* .vendor_name = "Novation", */ /* .product_name = "Nocturn", */ - .ifnum =0 , - .type =QUIRK_MIDI_RAW_BYTES + QUIRK_DATA_RAW_BYTES(0) } }, {USB_DEVICE (0x1235 ,0x000e ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO {/* .vendor_name = "Novation", */ /* .product_name = "Launchpad", */ - .ifnum =0 , - .type =QUIRK_MIDI_RAW_BYTES + QUIRK_DATA_RAW_BYTES(0) } }, {USB_DEVICE (0x1235 ,0x0010 ), - .driver_info = (unsigned long ) &(const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Focusrite" , .product_name = "Saffire 6 USB", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_MIXER(0) }, { - .ifnum =0 , - .type =QUIRK_AUDIO_STANDARD_MIXER , - }, - { - .ifnum =0 , - .type =QUIRK_AUDIO_FIXED_ENDPOINT , - .data = &(const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(0) { .formats = SNDRV_PCM_FMTBIT_S24_3LE, .channels = 4, .iface = 0,
@@ -2755,9 +2061,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { - .ifnum = 0, - .type = QUIRK_AUDIO_FIXED_ENDPOINT, - .data = &(const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(0) { .formats = SNDRV_PCM_FMTBIT_S24_3LE, .channels = 2, .iface = 0,
@@ -2779,28 +2083,19 @@ YAMAHA_DEVICE(0x7010, "UB99"), } } }, - { - .ifnum = 1, - .type = QUIRK_MIDI_RAW_BYTES - }, - { - .ifnum = -1 - } + { QUIRK_DATA_RAW_BYTES(1) }, + QUIRK_COMPOSITE_END } } }, {USB_DEVICE (0x1235 ,0x0018 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Novation" , .product_name = "Twitch", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { + QUIRK_DATA_COMPOSITE { { - .ifnum =0 , - .type =QUIRK_AUDIO_FIXED_ENDPOINT , - .data = & (const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(0) { .formats = SNDRV_PCM_FMTBIT_S24_3LE, .channels = 4, .iface = 0,
@@ -2819,19 +2114,14 @@ YAMAHA_DEVICE(0x7010, "UB99"), } } }, - { - .ifnum = 1, - .type = QUIRK_MIDI_RAW_BYTES - }, - { - .ifnum = -1 - } + { QUIRK_DATA_RAW_BYTES(1) }, + QUIRK_COMPOSITE_END } } }, {USB_DEVICE_VENDOR_SPEC (0x1235 ,0x4661 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Novation" , .product_name = "ReMOTE25", .ifnum = 0,
@@ -2843,25 +2133,16 @@ YAMAHA_DEVICE(0x7010, "UB99"), {/* VirusTI Desktop */ USB_DEVICE_VENDOR_SPEC (0x133e ,0x0815 ), - .driver_info = (unsigned long ) &(const struct snd_usb_audio_quirk ) { - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = &(const struct snd_usb_audio_quirk []) { + QUIRK_DRIVER_INFO { + QUIRK_DATA_COMPOSITE { { - .ifnum =3 , - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = &(const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(3) { .out_cables = 0x0003, .in_cables = 0x0003 } }, - { - .ifnum =4 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =-1 - } + { QUIRK_DATA_IGNORE(4) }, + QUIRK_COMPOSITE_END } } },
@@ -2889,7 +2170,7 @@ YAMAHA_DEVICE(0x7010, "UB99"),/* QinHeng devices */ {USB_DEVICE (0x1a86 ,0x752d ), - .driver_info = (unsigned long ) &(const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="QinHeng" , .product_name = "CH345", .ifnum = 1,
@@ -2903,7 +2184,7 @@ YAMAHA_DEVICE(0x7010, "UB99"),/* Miditech devices */ {USB_DEVICE (0x4752 ,0x0011 ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Miditech" , .product_name = "Midistart-2", .ifnum = 0,
@@ -2915,7 +2196,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), {/* this ID used by both Miditech MidiStudio-2 and CME UF-x */ USB_DEVICE (0x7104 ,0x2202 ), - .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { + QUIRK_DRIVER_INFO { .ifnum =0 , .type = QUIRK_MIDI_CME }
@@ -2925,20 +2206,13 @@ YAMAHA_DEVICE(0x7010, "UB99"), {/* Thanks to Clemens Ladisch <[email protected]> */ USB_DEVICE (0x0dba ,0x1000 ), - .driver_info = (unsigned long ) &(const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Digidesign" , .product_name = "MBox", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []){ - { - .ifnum =0 , - .type =QUIRK_AUDIO_STANDARD_MIXER , - }, + QUIRK_DATA_COMPOSITE{ + { QUIRK_DATA_STANDARD_MIXER(0) }, { - .ifnum =1 , - .type =QUIRK_AUDIO_FIXED_ENDPOINT , - .data = &(const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(1) { .formats = SNDRV_PCM_FMTBIT_S24_3BE, .channels = 2, .iface = 1,
@@ -2959,9 +2233,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { - .ifnum = 1, - .type = QUIRK_AUDIO_FIXED_ENDPOINT, - .data = &(const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(1) { .formats = SNDRV_PCM_FMTBIT_S24_3BE, .channels = 2, .iface = 1,
@@ -2982,9 +2254,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), } } }, - { - .ifnum = -1 - } + QUIRK_COMPOSITE_END } } },
@@ -2992,24 +2262,14 @@ YAMAHA_DEVICE(0x7010, "UB99"),/* DIGIDESIGN MBOX 2 */ {USB_DEVICE (0x0dba ,0x3000 ), - .driver_info = (unsigned long ) &(const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Digidesign" , .product_name = "Mbox 2", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =0 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =1 , - .type =QUIRK_IGNORE_INTERFACE - }, + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_IGNORE(0) }, + { QUIRK_DATA_IGNORE(1) }, { - .ifnum =2 , - .type =QUIRK_AUDIO_FIXED_ENDPOINT , - .data = &(const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(2) { .formats =SNDRV_PCM_FMTBIT_S24_3BE , .channels = 2, .iface = 2,
@@ -3027,15 +2287,10 @@ YAMAHA_DEVICE(0x7010, "UB99"), } } }, + { QUIRK_DATA_IGNORE(3) }, { - .ifnum = 3, - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum = 4, - .type = QUIRK_AUDIO_FIXED_ENDPOINT, - .data = &(const struct audioformat ) { - .formats =SNDRV_PCM_FMTBIT_S24_3BE , + QUIRK_DATA_AUDIOFORMAT(4) { + .formats = SNDRV_PCM_FMTBIT_S24_3BE, .channels = 2, .iface = 4, .altsetting = 2,
@@ -3052,14 +2307,9 @@ YAMAHA_DEVICE(0x7010, "UB99"), } } }, + { QUIRK_DATA_IGNORE(5) }, { - .ifnum = 5, - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum = 6, - .type = QUIRK_MIDI_MIDIMAN, - .data = &(const struct snd_usb_midi_endpoint_info ) { + QUIRK_DATA_MIDI_MIDIMAN(6) { .out_ep = 0x02, .out_cables = 0x0001, .in_ep = 0x81,
@@ -3067,33 +2317,21 @@ YAMAHA_DEVICE(0x7010, "UB99"), .in_cables = 0x0001 } }, - { - .ifnum = -1 - } + QUIRK_COMPOSITE_END } } },/* DIGIDESIGN MBOX 3 */ {USB_DEVICE (0x0dba ,0x5000 ), - .driver_info = (unsigned long ) &(const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Digidesign" , .product_name = "Mbox 3", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { - .ifnum =0 , - .type =QUIRK_IGNORE_INTERFACE - }, + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_IGNORE(0) }, + { QUIRK_DATA_IGNORE(1) }, { - .ifnum =1 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =2 , - .type =QUIRK_AUDIO_FIXED_ENDPOINT , - .data = &(const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(2) { .formats =SNDRV_PCM_FMTBIT_S24_3LE , .channels = 4, .iface = 2,
@@ -3113,9 +2351,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { - .ifnum = 3, - .type = QUIRK_AUDIO_FIXED_ENDPOINT, - .data = &(const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(3) { .formats = SNDRV_PCM_FMTBIT_S24_3LE, .channels = 4, .iface = 3,
@@ -3136,36 +2372,25 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { - .ifnum = 4, - .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = &(const struct snd_usb_midi_endpoint_info) { + QUIRK_DATA_MIDI_FIXED_ENDPOINT(4) { .out_cables = 0x0001, .in_cables = 0x0001 } }, - { - .ifnum = -1 - } + QUIRK_COMPOSITE_END } } }, {/* Tascam US122 MKII - playback-only support */ USB_DEVICE_VENDOR_SPEC (0x0644 ,0x8021 ), - .driver_info = (unsigned long ) &(const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="TASCAM" , .product_name = "US122 MKII", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_IGNORE(0) }, { - .ifnum =0 , - .type =QUIRK_IGNORE_INTERFACE - }, - { - .ifnum =1 , - .type =QUIRK_AUDIO_FIXED_ENDPOINT , - .data = &(const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(1) { .formats = SNDRV_PCM_FMTBIT_S24_3LE, .channels = 2, .iface = 1,
@@ -3186,9 +2411,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), } } }, - { - .ifnum = -1 - } + QUIRK_COMPOSITE_END } } },
@@ -3196,20 +2419,13 @@ YAMAHA_DEVICE(0x7010, "UB99"),/* Denon DN-X1600 */ {USB_AUDIO_DEVICE (0x154e ,0x500e ), - .driver_info = (unsigned long ) &(const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Denon" , .product_name = "DN-X1600", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []){ + QUIRK_DATA_COMPOSITE{ + { QUIRK_DATA_IGNORE(0) }, { - .ifnum =0 , - .type =QUIRK_IGNORE_INTERFACE , - }, - { - .ifnum =1 , - .type =QUIRK_AUDIO_FIXED_ENDPOINT , - .data = &(const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(1) { .formats = SNDRV_PCM_FMTBIT_S24_3LE, .channels = 8, .iface = 1,
@@ -3230,9 +2446,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { - .ifnum = 2, - .type = QUIRK_AUDIO_FIXED_ENDPOINT, - .data = &(const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(2) { .formats = SNDRV_PCM_FMTBIT_S24_3LE, .channels = 8, .iface = 2,
@@ -3252,13 +2466,8 @@ YAMAHA_DEVICE(0x7010, "UB99"), } } }, - { - .ifnum = 4, - .type = QUIRK_MIDI_STANDARD_INTERFACE, - }, - { - .ifnum = -1 - } + { QUIRK_DATA_STANDARD_MIDI(4) }, + QUIRK_COMPOSITE_END } } },
@@ -3267,17 +2476,13 @@ YAMAHA_DEVICE(0x7010, "UB99"), { USB_DEVICE(0x045e, 0x0283), .bInterfaceClass =USB_CLASS_PER_INTERFACE , - .driver_info = (unsigned long ) &(const struct snd_usb_audio_quirk ) { + QUIRK_DRIVER_INFO { .vendor_name ="Microsoft" , .product_name = "XboxLive Headset/Xbox Communicator", - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = &(const struct snd_usb_audio_quirk []) { + QUIRK_DATA_COMPOSITE { {/* playback */ - .ifnum =0 , - .type =QUIRK_AUDIO_FIXED_ENDPOINT , - .data = &(const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(0) { .formats = SNDRV_PCM_FMTBIT_S16_LE, .channels = 1, .iface = 0,
@@ -3293,9 +2498,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, {/* capture */ - .ifnum = 1, - .type = QUIRK_AUDIO_FIXED_ENDPOINT, - .data = &(const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(1) { .formats = SNDRV_PCM_FMTBIT_S16_LE, .channels = 1, .iface = 1,
@@ -3309,9 +2512,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), .rate_max = 16000 } }, - { - .ifnum = -1 - } + QUIRK_COMPOSITE_END } } },
@@ -3320,18 +2521,11 @@ YAMAHA_DEVICE(0x7010, "UB99"), {USB_DEVICE (0x200c ,0x100b ), .bInterfaceClass = USB_CLASS_PER_INTERFACE, - .driver_info = (unsigned long ) &(const struct snd_usb_audio_quirk ) { - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = &(const struct snd_usb_audio_quirk []) { + QUIRK_DRIVER_INFO { + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_MIXER(0) }, { - .ifnum =0 , - .type =QUIRK_AUDIO_STANDARD_MIXER , - }, - { - .ifnum =1 , - .type =QUIRK_AUDIO_FIXED_ENDPOINT , - .data = &(const struct audioformat ) { + QUIRK_DATA_AUDIOFORMAT(1) { .formats = SNDRV_PCM_FMTBIT_S24_3LE, .channels = 4, .iface = 1,
@@ -3350,9 +2544,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), } } }, - { - .ifnum = -1 - } + QUIRK_COMPOSITE_END } } },
@@ -3365,28 +2557,12 @@ YAMAHA_DEVICE(0x7010, "UB99"),* enabled in create_standard_audio_quirk(). */ USB_DEVICE (0x1686 ,0x00dd ), - .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { - .ifnum =QUIRK_ANY_INTERFACE , - .type =QUIRK_COMPOSITE , - .data = (const struct snd_usb_audio_quirk []) { - { -/* Playback */ - .ifnum =1 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE , - }, - { -/* Capture */ - .ifnum =2 , - .type =QUIRK_AUDIO_STANDARD_INTERFACE , - }, - { -/* Midi */ - .ifnum =3 , - .type =QUIRK_MIDI_STANDARD_INTERFACE - }, - { - .ifnum =-1 - }, + QUIRK_DRIVER_INFO { + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_STANDARD_AUDIO(1) }, /* Playback */ + { QUIRK_DATA_STANDARD_AUDIO(2) }, /* Capture */ + { QUIRK_DATA_STANDARD_MIDI(3) }, /* Midi */ + QUIRK_COMPOSITE_END } } },
@@ -3400,18 +2576,16 @@ YAMAHA_DEVICE(0x7010, "UB99"), USB_DEVICE_ID_MATCH_INT_SUBCLASS,
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.43.0
Part of the diff is not shown here. View the raw message.
Sasha Levin
maintainerPATCH 62/139 ALSA: usb-audio: Add logitech Audio profile quirk
In reply to Sasha LevinFrom: Joshua Pius <[email protected]>
[ Upstream commit a51c925c11d7b855167e64b63eb4378e5adfc11d ]
Specify shortnames for the following Logitech Devices: Rally bar, Rally bar mini, Tap, MeetUp and Huddle.
--- sound/usb/card.c | 6 ++++++ 1 file changed, 6 insertions(+)
sound/usb/card.c +6 -0
@@ -384,6 +384,12 @@ static const struct usb_audio_device_name usb_audio_names[] = {/* Creative/Toshiba Multimedia Center SB-0500 */ DEVICE_NAME (0x041e ,0x3048 ,"Toshiba" ,"SB-0500" ), +/* Logitech Audio Devices */ +DEVICE_NAME (0x046d ,0x0867 ,"Logitech, Inc." ,"Logi-MeetUp" ), +DEVICE_NAME (0x046d ,0x0874 ,"Logitech, Inc." ,"Logi-Tap-Audio" ), +DEVICE_NAME (0x046d ,0x087c ,"Logitech, Inc." ,"Logi-Huddle" ), +DEVICE_NAME (0x046d ,0x0898 ,"Logitech, Inc." ,"Logi-RB-Audio" ), +DEVICE_NAME (0x046d ,0x08d2 ,"Logitech, Inc." ,"Logi-RBM-Audio" ),DEVICE_NAME (0x046d ,0x0990 ,"Logitech, Inc." ,"QuickCam Pro 9000" ), DEVICE_NAME(0x05e1, 0x0408, "Syntek", "STK1160"),
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 63/139 ASoC: codecs: wsa883x: Handle reading version failure
In reply to Sasha LevinFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 2fbf16992e5aa14acf0441320033a01a32309ded ]
If reading version and variant from registers fails (which is unlikely but possible, because it is a read over bus), the driver will proceed and perform device configuration based on uninitialized stack variables. Handle it a bit better - bail out without doing any init and failing the update status Soundwire callback.
--- sound/soc/codecs/wsa883x.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
sound/soc/codecs/wsa883x.c +11 -5
@@ -998,15 +998,19 @@ static const struct reg_sequence reg_init[] = { {WSA883X_GMAMP_SUP1, 0xE2}, }; -static void wsa883x_init (struct wsa883x_priv *wsa883x) +static int wsa883x_init (struct wsa883x_priv *wsa883x) {struct regmap *regmap = wsa883x->regmap; -int variant, version; +int variant, version, ret; -regmap_read (regmap,WSA883X_OTP_REG_0 , &variant); + ret =regmap_read (regmap,WSA883X_OTP_REG_0 , &variant); +if (ret) +return ret; wsa883x->variant = variant &WSA883X_ID_MASK ; -regmap_read (regmap,WSA883X_CHIP_ID0 , &version); + ret =regmap_read (regmap,WSA883X_CHIP_ID0 , &version); +if (ret) +return ret; wsa883x->version = version;switch (wsa883x->variant) {
@@ -1041,6 +1045,8 @@ static void wsa883x_init(struct wsa883x_priv *wsa883x)WSA883X_DRE_OFFSET_MASK , wsa883x->comp_offset); } + +return 0 ; } static int wsa883x_update_status(struct sdw_slave *slave,
@@ -1049,7 +1055,7 @@ static int wsa883x_update_status(struct sdw_slave *slave,struct wsa883x_priv *wsa883x =dev_get_drvdata (&slave->dev);if (status ==SDW_SLAVE_ATTACHED && slave->dev_num >0 ) -wsa883x_init (wsa883x); +return wsa883x_init (wsa883x);return 0 ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 64/139 tools/x86/kcpuid: Protect against faulty "max subleaf" values
In reply to Sasha LevinFrom: "Ahmed S. Darwish" <[email protected]>
[ Upstream commit cf96ab1a966b87b09fdd9e8cc8357d2d00776a3a ]
Protect against the kcpuid code parsing faulty max subleaf numbers through a min() expression. Thus, ensuring that max_subleaf will always be ≤ MAX_SUBLEAF_NUM.
Use "u32" for the subleaf numbers since kcpuid is compiled with -Wextra, which includes signed/unsigned comparisons warnings.
--- tools/arch/x86/kcpuid/kcpuid.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
tools/arch/x86/kcpuid/kcpuid.c +5 -7
@@ -7,7 +7,8 @@#include <string.h> #include <getopt.h> -#define ARRAY_SIZE (x) (sizeof(x) / sizeof((x)[0])) +#define ARRAY_SIZE (x) (sizeof(x) / sizeof((x)[0])) +#define min (a, b) (((a) < (b)) ? (a) : (b))typedef unsigned int u32 ;typedef unsigned long long u64 ;
@@ -207,12 +208,9 @@ static void raw_dump_range(struct cpuid_range *range)#define MAX_SUBLEAF_NUM 32struct cpuid_range *setup_cpuid_range (u32 input_eax) { -u32 max_func, idx_func; -int subleaf; +u32 max_func, idx_func, subleaf, max_subleaf; +u32 eax, ebx, ecx, edx, f = input_eax;struct cpuid_range *range; -u32 eax, ebx, ecx, edx; -u32 f = input_eax; -int max_subleaf;bool allzero; eax = input_eax;
@@ -258,7 +256,7 @@ struct cpuid_range *setup_cpuid_range(u32 input_eax)* others have to be tried (0xf) */ if (f ==0x7 || f ==0x14 || f ==0x17 || f ==0x18 ) - max_subleaf = (eax &0xff ) +1 ; + max_subleaf =min ((eax &0xff ) +1 , max_subleaf);if (f ==0xb ) max_subleaf =2 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 65/139 x86/pkeys: Add PKRU as a parameter in signal handling functions
In reply to Sasha LevinFrom: Aruna Ramakrishna <[email protected]>
[ Upstream commit 24cf2bc982ffe02aeffb4a3885c71751a2c7023b ]
Assume there's a multithreaded application that runs untrusted user code. Each thread has its stack/code protected by a non-zero PKEY, and the PKRU register is set up such that only that particular non-zero PKEY is enabled. Each thread also sets up an alternate signal stack to handle signals, which is protected by PKEY zero. The PKEYs man page documents that the PKRU will be reset to init_pkru when the signal handler is invoked, which means that PKEY zero access will be enabled. But this reset happens after the kernel attempts to push fpu state to the alternate stack, which is not (yet) accessible by the kernel, which leads to a new SIGSEGV being sent to the application, terminating it.
Enabling both the non-zero PKEY (for the thread) and PKEY zero in userspace will not work for this use case. It cannot have the alt stack writeable by all - the rationale here is that the code running in that thread (using a non-zero PKEY) is untrusted and should not have access to the alternate signal stack (that uses PKEY zero), to prevent the return address of a function from being changed. The expectation is that kernel should be able to set up the alternate signal stack and deliver the signal to the application even if PKEY zero is explicitly disabled by the application. The signal handler accessibility should not be dictated by whatever PKRU value the thread sets up.
The PKRU register is managed by XSAVE, which means the sigframe contents must match the register contents - which is not the case here. It's required that the signal frame contains the user-defined PKRU value (so that it is restored correctly from sigcontext) but the actual register must be reset to init_pkru so that the alt stack is accessible and the signal can be delivered to the application. It seems that the proper fix here would be to remove PKRU from the XSAVE framework and manage it separately, which is quite complicated. As a workaround, do this:
orig_pkru = rdpkru();
wrpkru(orig_pkru & init_pkru_value);
xsave_to_user_sigframe();
put_user(pkru_sigframe_addr, orig_pkru)In preparation for writing PKRU to sigframe, pass PKRU as an additional parameter down the call chain from get_sigframe().
No functional change.
--- arch/x86/include/asm/fpu/signal.h | 2 +- arch/x86/kernel/fpu/signal.c | 6 +++--- arch/x86/kernel/signal.c | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-)
arch/x86/include/asm/fpu/signal.h +1 -1
@@ -29,7 +29,7 @@ fpu__alloc_mathframe(unsigned long sp, int ia32_frame,unsigned long fpu__get_fpstate_size (void ); -extern bool copy_fpstate_to_sigframe (void __user *buf,void __user *fp,int size); +extern bool copy_fpstate_to_sigframe (void __user *buf,void __user *fp,int size,u32 pkru);extern void fpu__clear_user_states (struct fpu *fpu);extern bool fpu__restore_sig (void __user *buf,int ia32_frame);
arch/x86/kernel/fpu/signal.c +3 -3
@@ -156,7 +156,7 @@ static inline bool save_xstate_epilog(void __user *buf, int ia32_frame,return !err; } -static inline int copy_fpregs_to_sigframe (struct xregs_state __user *buf) +static inline int copy_fpregs_to_sigframe (struct xregs_state __user *buf,u32 pkru) {if (use_xsave ())return xsave_to_user_sigframe (buf);
@@ -185,7 +185,7 @@ static inline int copy_fpregs_to_sigframe(struct xregs_state __user *buf)* For [f]xsave state, update the SW reserved fields in the [f]xsave frame * indicating the absence/presence of the extended state to the user. */ -bool copy_fpstate_to_sigframe (void __user *buf,void __user *buf_fx,int size) +bool copy_fpstate_to_sigframe (void __user *buf,void __user *buf_fx,int size,u32 pkru) {struct task_struct *tsk = current;struct fpstate *fpstate = tsk->thread.fpu.fpstate;
@@ -228,7 +228,7 @@ bool copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size)fpregs_restore_userregs ();pagefault_disable (); - ret =copy_fpregs_to_sigframe (buf_fx); + ret =copy_fpregs_to_sigframe (buf_fx, pkru);pagefault_enable ();fpregs_unlock ();
arch/x86/kernel/signal.c +2 -1
@@ -83,6 +83,7 @@ get_sigframe(struct ksignal *ksig, struct pt_regs *regs, size_t frame_size,unsigned long math_size =0 ;unsigned long sp = regs->sp;unsigned long buf_fx =0 ; +u32 pkru =read_pkru ();/* redzone */ if (!ia32_frame)
@@ -138,7 +139,7 @@ get_sigframe(struct ksignal *ksig, struct pt_regs *regs, size_t frame_size, }/* save i387 and extended state */ -if (!copy_fpstate_to_sigframe (*fpstate, (void __user *)buf_fx, math_size)) +if (!copy_fpstate_to_sigframe (*fpstate, (void __user *)buf_fx, math_size, pkru))return (void __user *)-1L ;return (void __user *)sp;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 66/139 x86/pkeys: Restore altstack access in sigreturn()
In reply to Sasha LevinFrom: Aruna Ramakrishna <[email protected]>
[ Upstream commit d10b554919d4cc8fa8fe2e95b57ad2624728c8e4 ]
A process can disable access to the alternate signal stack by not enabling the altstack's PKEY in the PKRU register.
Nevertheless, the kernel updates the PKRU temporarily for signal handling. However, in sigreturn(), restore_sigcontext() will restore the PKRU to the user-defined PKRU value.
This will cause restore_altstack() to fail with a SIGSEGV as it needs read access to the altstack which is prohibited by the user-defined PKRU value.
Fix this by restoring altstack before restoring PKRU.
--- arch/x86/kernel/signal_64.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/signal_64.c +3 -3
@@ -260,13 +260,13 @@ SYSCALL_DEFINE0(rt_sigreturn)set_current_blocked (&set); -if (!restore_sigcontext (regs, &frame->uc.uc_mcontext, uc_flags)) +if (restore_altstack (&frame->uc.uc_stack)) goto badframe; -if (restore_signal_shadow_stack ()) +if (!restore_sigcontext (regs, &frame->uc.uc_mcontext, uc_flags)) goto badframe; -if (restore_altstack (&frame->uc.uc_stack)) +if (restore_signal_shadow_stack ()) goto badframe;return regs->ax;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 67/139 x86/kexec: Add EFI config table identity mapping for kexec kernel
In reply to Sasha LevinFrom: Tao Liu <[email protected]>
[ Upstream commit 5760929f6545c651682de3c2c6c6786816b17bb1 ]
A kexec kernel boot failure is sometimes observed on AMD CPUs due to an unmapped EFI config table array. This can be seen when "nogbpages" is on the kernel command line, and has been observed as a full BIOS reboot rather than a successful kexec.
This was also the cause of reported regressions attributed to Commit 7143c5f4cf20 ("x86/mm/ident_map: Use gbpages only where full GB page should be mapped.") which was subsequently reverted.
To avoid this page fault, explicitly include the EFI config table array in the kexec identity map.
Further explanation:
The following 2 commits caused the EFI config table array to be accessed when enabling sev at kernel startup.
commit ec1c66af3a30 ("x86/compressed/64: Detect/setup SEV/SME features
earlier during boot")
commit c01fce9cef84 ("x86/compressed: Add SEV-SNP feature
detection/setup")
This is in the code that examines whether SEV should be enabled or not, so it can even affect systems that are not SEV capable.
This may result in a page fault if the EFI config table array's address is unmapped. Since the page fault occurs before the new kernel establishes its own identity map and page fault routines, it is unrecoverable and kexec fails.
Most often, this problem is not seen because the EFI config table array gets included in the map by the luck of being placed at a memory address close enough to other memory areas that *are* included in the map created by kexec.
Both the "nogbpages" command line option and the "use gpbages only where full GB page should be mapped" change greatly reduce the chance of being included in the map by luck, which is why the problem appears.
--- arch/x86/kernel/machine_kexec_64.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
arch/x86/kernel/machine_kexec_64.c +27 -0
@@ -28,6 +28,7 @@#include <asm/setup.h> #include <asm/set_memory.h> #include <asm/cpu.h> +#include <asm/efi.h> #ifdef CONFIG_ACPI /*
@@ -90,6 +91,8 @@ map_efi_systab(struct x86_mapping_info *info, pgd_t *level4p) {#ifdef CONFIG_EFI unsigned long mstart, mend; +void *kaddr; +int ret;if (!efi_enabled (EFI_BOOT ))return 0 ;
@@ -105,6 +108,30 @@ map_efi_systab(struct x86_mapping_info *info, pgd_t *level4p)if (!mstart)return 0 ; + ret =kernel_ident_mapping_init (info, level4p, mstart, mend); +if (ret) +return ret; + + kaddr =memremap (mstart, mend - mstart,MEMREMAP_WB ); +if (!kaddr) { +pr_err ("Could not map UEFI system table\n" ); +return -ENOMEM ; + } + + mstart = efi_config_table; + +if (efi_enabled (EFI_64BIT )) { +efi_system_table_64_t *stbl = (efi_system_table_64_t *)kaddr; + + mend = mstart +sizeof (efi_config_table_64_t) * stbl->nr_tables; + }else { +efi_system_table_32_t *stbl = (efi_system_table_32_t *)kaddr; + + mend = mstart +sizeof (efi_config_table_32_t) * stbl->nr_tables; + } + +memunmap (kaddr); +return kernel_ident_mapping_init (info, level4p, mstart, mend);#endif return 0 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 68/139 ALSA: asihpi: Fix potential OOB array access
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
[ Upstream commit 7b986c7430a6bb68d523dac7bfc74cbd5b44ef96 ]
ASIHPI driver stores some values in the static array upon a response from the driver, and its index depends on the firmware. We shouldn't trust it blindly.
This patch adds a sanity check of the array index to fit in the array size.
--- sound/pci/asihpi/hpimsgx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/asihpi/hpimsgx.c +1 -1
@@ -708,7 +708,7 @@ static u16 HPIMSGX__init(struct hpi_message *phm, phr->error =HPI_ERROR_PROCESSING_MESSAGE ;return phr->error; } -if (hr.error ==0 ) { +if (hr.error ==0 && hr.u.s.adapter_index <HPI_MAX_ADAPTERS ) {/* the adapter was created successfully save the mapping for future use */ hpi_entry_points[hr.u.s.adapter_index] = entry_point_func;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 69/139 ALSA: hdsp: Break infinite MIDI input flush loop
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
[ Upstream commit c01f3815453e2d5f699ccd8c8c1f93a5b8669e59 ]
The current MIDI input flush on HDSP and HDSPM drivers relies on the hardware reporting the right value. If the hardware doesn't give the proper value but returns -1, it may be stuck at an infinite loop.
Add a counter and break if the loop is unexpectedly too long.
--- sound/pci/rme9652/hdsp.c | 6 ++++-- sound/pci/rme9652/hdspm.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-)
sound/pci/rme9652/hdsp.c +4 -2
@@ -1298,8 +1298,10 @@ static int snd_hdsp_midi_output_possible (struct hdsp *hdsp, int id)static void snd_hdsp_flush_midi_input (struct hdsp *hdsp,int id) { -while (snd_hdsp_midi_input_available (hdsp, id)) -snd_hdsp_midi_read_byte (hdsp, id); +int count =256 ; + +while (snd_hdsp_midi_input_available (hdsp, id) && --count) +snd_hdsp_midi_read_byte (hdsp, id); }static int snd_hdsp_midi_output_write (struct hdsp_midi *hmidi)
sound/pci/rme9652/hdspm.c +4 -2
@@ -1838,8 +1838,10 @@ static inline int snd_hdspm_midi_output_possible (struct hdspm *hdspm, int id)static void snd_hdspm_flush_midi_input (struct hdspm *hdspm,int id) { -while (snd_hdspm_midi_input_available (hdspm, id)) -snd_hdspm_midi_read_byte (hdspm, id); +int count =256 ; + +while (snd_hdspm_midi_input_available (hdspm, id) && --count) +snd_hdspm_midi_read_byte (hdspm, id); }static int snd_hdspm_midi_output_write (struct hdspm_midi *hmidi)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 70/139 tools/nolibc: powerpc: limit stack-protector workaround to GCC
In reply to Sasha LevinFrom: Thomas Weißschuh <[email protected]>
[ Upstream commit 1daea158d0aae0770371f3079305a29fdb66829e ]
As mentioned in the comment, the workaround for __attribute__((no_stack_protector)) is only necessary on GCC. Avoid applying the workaround on clang, as clang does not recognize __attribute__((__optimize__)) and would fail.
--- tools/include/nolibc/arch-powerpc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/include/nolibc/arch-powerpc.h +1 -1
@@ -172,7 +172,7 @@ _ret; \ }) -#ifndef __powerpc64__ +#if !defined(__powerpc64__) && !defined(__clang__)/* FIXME: For 32-bit PowerPC, with newer gcc compilers (e.g. gcc 13.1.0), * "omit-frame-pointer" fails with __attribute__((no_stack_protector)) but * works with __attribute__((__optimize__("-fno-stack-protector")))
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 71/139 selftests/nolibc: avoid passing NULL to printf("%s")
In reply to Sasha LevinFrom: Thomas Weißschuh <[email protected]>
[ Upstream commit f1a58f61d88642ae1e6e97e9d72d73bc70a93cb8 ]
Clang on higher optimization levels detects that NULL is passed to printf("%s") and warns about it.
While printf() from nolibc gracefully handles that NULL, it is undefined behavior as per POSIX, so the warning is reasonable. Avoid the warning by transforming NULL into a non-NULL placeholder.
--- tools/testing/selftests/nolibc/nolibc-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/nolibc/nolibc-test.c +2 -2
@@ -522,7 +522,7 @@ int expect_strzr(const char *expr, int llen) {int ret =0 ; - llen +=printf (" = <%s> " , expr); + llen +=printf (" = <%s> " , expr ? expr :"(null)" );if (expr) { ret =1 ;result (llen,FAIL );
@@ -541,7 +541,7 @@ int expect_strnz(const char *expr, int llen) {int ret =0 ; - llen +=printf (" = <%s> " , expr); + llen +=printf (" = <%s> " , expr ? expr :"(null)" );if (!expr) { ret =1 ;result (llen,FAIL );
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 72/139 x86/syscall: Avoid memcpy() for ia32 syscall_get_arguments()
In reply to Sasha LevinFrom: Kees Cook <[email protected]>
[ Upstream commit d19d638b1e6cf746263ef60b7d0dee0204d8216a ]
Modern (fortified) memcpy() prefers to avoid writing (or reading) beyond the end of the addressed destination (or source) struct member:
In function ‘fortify_memcpy_chk’,
inlined from ‘syscall_get_arguments’ at ./arch/x86/include/asm/syscall.h:85:2,
inlined from ‘populate_seccomp_data’ at kernel/seccomp.c:258:2,
inlined from ‘__seccomp_filter’ at kernel/seccomp.c:1231:3:./include/linux/fortify-string.h:580:25: error: call to ‘__read_overflow2_field’ declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror=attribute-warning]
580 | __read_overflow2_field(q_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~As already done for x86_64 and compat mode, do not use memcpy() to extract syscall arguments from struct pt_regs but rather just perform direct assignments. Binary output differences are negligible, and actually ends up using less stack space:
- sub $0x84,%esp + sub $0x6c,%esp
and less text size:
text data bss dec hex filename
10794 252 0 11046 2b26 gcc-32b/kernel/seccomp.o.stock 10714 252 0 10966 2ad6 gcc-32b/kernel/seccomp.o.after
--- arch/x86/include/asm/syscall.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/x86/include/asm/syscall.h +6 -1
@@ -82,7 +82,12 @@ static inline void syscall_get_arguments(struct task_struct *task,struct pt_regs *regs, unsigned long *args) { - memcpy(args, ®s->bx, 6 * sizeof(args[0])); + args[0 ] = regs->bx; + args[1 ] = regs->cx; + args[2 ] = regs->dx; + args[3 ] = regs->si; + args[4 ] = regs->di; + args[5 ] = regs->bp; }static inline int syscall_get_arch (struct task_struct *task)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 73/139 hwmon: (nct6775) add G15CF to ASUS WMI monitoring list
In reply to Sasha LevinFrom: Denis Pauk <[email protected]>
[ Upstream commit 1f432e4cf1dd3ecfec5ed80051b4611632a0fd51 ]
Boards G15CF has got a nct6775 chip, but by default there's no use of it because of resource conflict with WMI method.
Add the board to the WMI monitoring list.
Message-ID: <[email protected]>
--- drivers/hwmon/nct6775-platform.c | 1 + 1 file changed, 1 insertion(+)
drivers/hwmon/nct6775-platform.c +1 -0
@@ -1269,6 +1269,7 @@ static const char * const asus_msi_boards[] = {"EX-B760M-V5 D4" ,"EX-H510M-V3" ,"EX-H610M-V3 D4" , +"G15CF" ,"PRIME A620M-A" ,"PRIME B560-PLUS" , "PRIME B560-PLUS AC-HES",
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 74/139 fbdev: efifb: Register sysfs groups through driver core
In reply to Sasha LevinFrom: Thomas Weißschuh <[email protected]>
[ Upstream commit 95cdd538e0e5677efbdf8aade04ec098ab98f457 ]
The driver core can register and cleanup sysfs groups already. Make use of that functionality to simplify the error handling and cleanup.
Also avoid a UAF race during unregistering where the sysctl attributes were usable after the info struct was freed.
--- drivers/video/fbdev/efifb.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/video/fbdev/efifb.c +2 -9
@@ -571,15 +571,10 @@ static int efifb_probe(struct platform_device *dev)break ; } - err =sysfs_create_groups (&dev->dev.kobj, efifb_groups); -if (err) { -pr_err ("efifb: cannot add sysfs attrs\n" ); - goto err_unmap; - } err =fb_alloc_cmap (&info->cmap,256 ,0 );if (err <0 ) {pr_err ("efifb: cannot allocate colormap\n" ); - goto err_groups; + goto err_unmap; }if (efifb_pci_dev)
@@ -603,8 +598,6 @@ static int efifb_probe(struct platform_device *dev)pm_runtime_put (&efifb_pci_dev->dev);fb_dealloc_cmap (&info->cmap); -err_groups: -sysfs_remove_groups (&dev->dev.kobj, efifb_groups); err_unmap:if (mem_flags & (EFI_MEMORY_UC |EFI_MEMORY_WC ))iounmap (info->screen_base);
@@ -624,12 +617,12 @@ static void efifb_remove(struct platform_device *pdev)/* efifb_destroy takes care of info cleanup */ unregister_framebuffer (info); -sysfs_remove_groups (&pdev->dev.kobj, efifb_groups); }static struct platform_driver efifb_driver = { .driver = { .name ="efi-framebuffer" , + .dev_groups = efifb_groups, }, .probe = efifb_probe, .remove_new = efifb_remove,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 75/139 fbdev: pxafb: Fix possible use after free in pxafb_task()
In reply to Sasha LevinFrom: Kaixin Wang <[email protected]>
[ Upstream commit 4a6921095eb04a900e0000da83d9475eb958e61e ]
In the pxafb_probe function, it calls the pxafb_init_fbinfo function, after which &fbi->task is associated with pxafb_task. Moreover, within this pxafb_init_fbinfo function, the pxafb_blank function within the &pxafb_ops struct is capable of scheduling work.
If we remove the module which will call pxafb_remove to make cleanup, it will call unregister_framebuffer function which can call do_unregister_framebuffer to free fbi->fb through put_fb_info(fb_info), while the work mentioned above will be used. The sequence of operations that may lead to a UAF bug is as follows:
CPU0 CPU1
| pxafb_task
pxafb_remove |
unregister_framebuffer(info) |
do_unregister_framebuffer(fb_info) |
put_fb_info(fb_info) |
// free fbi->fb | set_ctrlr_state(fbi, state)
| __pxafb_lcd_power(fbi, 0)
| fbi->lcd_power(on, &fbi->fb.var)
| //use fbi->fbFix it by ensuring that the work is canceled before proceeding with the cleanup in pxafb_remove.
Note that only root user can remove the driver at runtime.
--- drivers/video/fbdev/pxafb.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/pxafb.c +1 -0
@@ -2403,6 +2403,7 @@ static void pxafb_remove(struct platform_device *dev) info = &fbi->fb;pxafb_overlay_exit (fbi); +cancel_work_sync (&fbi->task);unregister_framebuffer (info);pxafb_disable_controller (fbi);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 76/139 coredump: Standartize and fix logging
In reply to Sasha LevinFrom: Roman Kisel <[email protected]>
[ Upstream commit c114e9948c2b6a0b400266e59cc656b59e795bca ]
The coredump code does not log the process ID and the comm consistently, logs unescaped comm when it does log it, and does not always use the ratelimited logging. That makes it harder to analyze logs and puts the system at the risk of spamming the system log incase something crashes many times over and over again.
Fix that by logging TGID and comm (escaped) consistently and using the ratelimited logging always.
--- fs/coredump.c | 43 +++++++++++++++------------------------- include/linux/coredump.h | 22 ++++++++++++++++++++ 2 files changed, 38 insertions(+), 27 deletions(-)
fs/coredump.c +16 -27
@@ -583,8 +583,7 @@ void do_coredump(const kernel_siginfo_t *siginfo)struct subprocess_info *sub_info;if (ispipe <0 ) { -printk (KERN_WARNING "format_corename failed\n" ); -printk (KERN_WARNING "Aborting core\n" ); +coredump_report_failure ("format_corename failed, aborting core" ); goto fail_unlock; }
@@ -604,27 +603,21 @@ void do_coredump(const kernel_siginfo_t *siginfo)* right pid if a thread in a multi-threaded * core_pattern process dies. */ -printk (KERN_WARNING -"Process %d(%s) has RLIMIT_CORE set to 1\n" , -task_tgid_vnr (current), current->comm); -printk (KERN_WARNING "Aborting core\n" ); +coredump_report_failure ("RLIMIT_CORE is set to 1, aborting core" ); goto fail_unlock; } cprm.limit =RLIM_INFINITY ; dump_count =atomic_inc_return (&core_dump_count);if (core_pipe_limit && (core_pipe_limit < dump_count)) { -printk (KERN_WARNING "Pid %d(%s) over core_pipe_limit\n" , -task_tgid_vnr (current), current->comm); -printk (KERN_WARNING "Skipping core dump\n" ); +coredump_report_failure ("over core_pipe_limit, skipping core dump" ); goto fail_dropcount; } helper_argv =kmalloc_array (argc +1 ,sizeof (*helper_argv),GFP_KERNEL );if (!helper_argv) { -printk (KERN_WARNING "%s failed to allocate memory\n" , - __func__); +coredump_report_failure ("%s failed to allocate memory" , __func__); goto fail_dropcount; }for (argi =0 ; argi < argc; argi++)
@@ -641,8 +634,7 @@ void do_coredump(const kernel_siginfo_t *siginfo)kfree (helper_argv);if (retval) { -printk (KERN_INFO "Core dump to |%s pipe failed\n" , - cn.corename); +coredump_report_failure ("|%s pipe failed" , cn.corename); goto close_fail; } }else {
@@ -655,10 +647,8 @@ void do_coredump(const kernel_siginfo_t *siginfo) goto fail_unlock;if (need_suid_safe && cn.corename[0 ] !='/' ) { -printk (KERN_WARNING "Pid %d(%s) can only dump core " \ -"to fully qualified path!\n" , -task_tgid_vnr (current), current->comm); -printk (KERN_WARNING "Skipping core dump\n" ); +coredump_report_failure ( +"this process can only dump core to a fully qualified path, skipping core dump" ); goto fail_unlock; }
@@ -727,13 +717,13 @@ void do_coredump(const kernel_siginfo_t *siginfo) idmap =file_mnt_idmap (cprm.file);if (!vfsuid_eq_kuid (i_uid_into_vfsuid (idmap, inode),current_fsuid ())) { -pr_info_ratelimited ("Core dump to %s aborted: cannot preserve file owner\n" , - cn.corename); +coredump_report_failure ("Core dump to %s aborted: " +"cannot preserve file owner" , cn.corename); goto close_fail; }if ((inode->i_mode &0677 ) !=0600 ) { -pr_info_ratelimited ("Core dump to %s aborted: cannot preserve file permissions\n" , - cn.corename); +coredump_report_failure ("Core dump to %s aborted: " +"cannot preserve file permissions" , cn.corename); goto close_fail; }if (!(cprm.file->f_mode &FMODE_CAN_WRITE ))
@@ -754,7 +744,7 @@ void do_coredump(const kernel_siginfo_t *siginfo)* have this set to NULL. */ if (!cprm.file) { -pr_info ("Core dump to |%s disabled\n" , cn.corename); +coredump_report_failure ("Core dump to |%s disabled" , cn.corename); goto close_fail; }if (!dump_vma_snapshot (&cprm))
@@ -941,11 +931,10 @@ void validate_coredump_safety(void) {if (suid_dumpable ==SUID_DUMP_ROOT && core_pattern[0 ] !='/' && core_pattern[0 ] !='|' ) { -pr_warn ( -"Unsafe core_pattern used with fs.suid_dumpable=2.\n" -"Pipe handler or fully qualified core dump path required.\n" -"Set kernel.core_pattern before fs.suid_dumpable.\n" - ); + +coredump_report_failure ("Unsafe core_pattern used with fs.suid_dumpable=2: " +"pipe handler or fully qualified core dump path required. " +"Set kernel.core_pattern before fs.suid_dumpable." ); } }
include/linux/coredump.h +22 -0
@@ -41,8 +41,30 @@ extern int dump_align(struct coredump_params *cprm, int align);int dump_user_range (struct coredump_params *cprm,unsigned long start,unsigned long len);extern void do_coredump (const kernel_siginfo_t *siginfo); + +/* +* Logging for the coredump code, ratelimited. +* The TGID and comm fields are added to the message. +*/ + +#define __COREDUMP_PRINTK (Level, Format, ...) \ + do { \ + char comm[TASK_COMM_LEN]; \ + \ + get_task_comm(comm, current); \ + printk_ratelimited(Level "coredump: %d(%*pE): " Format "\n", \ + task_tgid_vnr(current), (int)strlen(comm), comm, ##__VA_ARGS__); \ + } while (0) \ + +#define coredump_report (fmt, ...) __COREDUMP_PRINTK(KERN_INFO, fmt, ##__VA_ARGS__) +#define coredump_report_failure (fmt, ...) __COREDUMP_PRINTK(KERN_WARNING, fmt, ##__VA_ARGS__) +#else static inline void do_coredump (const kernel_siginfo_t *siginfo) {} + +#define coredump_report (...) +#define coredump_report_failure (...) +#endif #if defined(CONFIG_COREDUMP ) && defined(CONFIG_SYSCTL )
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 77/139 rcuscale: Provide clear error when async specified without primitives
In reply to Sasha LevinFrom: "Paul E. McKenney" <[email protected]>
[ Upstream commit 11377947b5861fa59bf77c827e1dd7c081842cc9 ]
Currently, if the rcuscale module's async module parameter is specified for RCU implementations that do not have async primitives such as RCU Tasks Rude (which now lacks a call_rcu_tasks_rude() function), there will be a series of splats due to calls to a NULL pointer. This commit therefore warns of this situation, but switches to non-async testing.
--- kernel/rcu/rcuscale.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/rcu/rcuscale.c +2 -2
@@ -498,7 +498,7 @@ rcu_scale_writer(void *arg)schedule_timeout_idle (torture_random (&tr) % writer_holdoff_jiffies +1 ); wdp = &wdpp[i]; *wdp =ktime_get_mono_fast_ns (); -if (gp_async) { +if (gp_async && !WARN_ON_ONCE (!cur_ops->async)) { retry:if (!rhp) rhp =kmalloc (sizeof (*rhp),GFP_KERNEL );
@@ -554,7 +554,7 @@ rcu_scale_writer(void *arg) i++;rcu_scale_wait_shutdown (); }while (!torture_must_stop ()); -if (gp_async) { +if (gp_async && cur_ops->async) { cur_ops->gp_barrier (); } writer_n_durations[me] = i_max +1 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 78/139 iommu/arm-smmu-qcom: hide last LPASS SMMU context bank from linux
In reply to Sasha LevinFrom: Marc Gonzalez <[email protected]>
[ Upstream commit 3a8990b8a778219327c5f8ecf10b5d81377b925a ]
On qcom msm8998, writing to the last context bank of lpass_q6_smmu (base address 0x05100000) produces a system freeze & reboot.
The hardware/hypervisor reports 13 context banks for the LPASS SMMU on msm8998, but only the first 12 are accessible... Override the number of context banks
[ 2.546101] arm-smmu 5100000.iommu: probing hardware configuration... [ 2.552439] arm-smmu 5100000.iommu: SMMUv2 with: [ 2.558945] arm-smmu 5100000.iommu: stage 1 translation [ 2.563627] arm-smmu 5100000.iommu: address translation ops [ 2.568923] arm-smmu 5100000.iommu: non-coherent table walk [ 2.574566] arm-smmu 5100000.iommu: (IDR0.CTTW overridden by FW configuration) [ 2.580220] arm-smmu 5100000.iommu: stream matching with 12 register groups [ 2.587263] arm-smmu 5100000.iommu: 13 context banks (0 stage-2 only) [ 2.614447] arm-smmu 5100000.iommu: Supported page sizes: 0x63315000 [ 2.621358] arm-smmu 5100000.iommu: Stage-1: 36-bit VA -> 36-bit IPA [ 2.627772] arm-smmu 5100000.iommu: preserved 0 boot mappings
Specifically, the crashes occur here:
qsmmu->bypass_cbndx = smmu->num_context_banks - 1; arm_smmu_cb_write(smmu, qsmmu->bypass_cbndx, ARM_SMMU_CB_SCTLR, 0);
and here:
arm_smmu_write_context_bank(smmu, i); arm_smmu_cb_write(smmu, i, ARM_SMMU_CB_FSR, ARM_SMMU_CB_FSR_FAULT);
It is likely that FW reserves the last context bank for its own use, thus a simple work-around is: DON'T USE IT in Linux.
If we decrease the number of context banks, last one will be "hidden".
--- drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +7 -0
@@ -278,6 +278,13 @@ static int qcom_smmu_cfg_probe(struct arm_smmu_device *smmu)u32 smr;int i; +/* +* MSM8998 LPASS SMMU reports 13 context banks, but accessing +* the last context bank crashes the system. +*/ +if (of_device_is_compatible (smmu->dev->of_node,"qcom,msm8998-smmu-v2" ) && smmu->num_context_banks ==13 ) + smmu->num_context_banks =12 ; +/* * Some platforms support more than the Arm SMMU architected maximum of * 128 stream matching groups. For unknown reasons, the additional
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 79/139 iommu/arm-smmu-qcom: Work around SDM845 Adreno SMMU w/ 16K pages
In reply to Sasha LevinFrom: Konrad Dybcio <[email protected]>
[ Upstream commit 2d42d3ba443706c9164fa0bef4e5fd1c36bc1bd9 ]
SDM845's Adreno SMMU is unique in that it actually advertizes support for 16K (and 32M) pages, which doesn't hold for newer SoCs.
This however, seems either broken in the hardware implementation, the hypervisor middleware that abstracts the SMMU, or there's a bug in the Linux kernel somewhere down the line that nobody managed to track down.
Booting SDM845 with 16K page sizes and drm/msm results in:
*** gpu fault: ttbr0=0000000000000000 iova=000100000000c000 dir=READ type=TRANSLATION source=CP (0,0,0,0)
right after loading the firmware. The GPU then starts spitting out illegal intstruction errors, as it's quite obvious that it got a bogus pointer.
Moreover, it seems like this issue also concerns other implementations of SMMUv2 on Qualcomm SoCs, such as the one on SC7180.
Hide 16K support on such instances to work around this.
--- drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +9 -0
@@ -341,6 +341,14 @@ static int qcom_smmu_cfg_probe(struct arm_smmu_device *smmu)return 0 ; } +static int qcom_adreno_smmuv2_cfg_probe (struct arm_smmu_device *smmu) +{ +/* Support for 16K pages is advertised on some SoCs, but it doesn't seem to work */ + smmu->features &= ~ARM_SMMU_FEAT_FMT_AARCH64_16K ; + +return 0 ; +} +static void qcom_smmu_write_s2cr (struct arm_smmu_device *smmu,int idx) {struct arm_smmu_s2cr *s2cr = smmu->s2crs + idx;
@@ -431,6 +439,7 @@ static const struct arm_smmu_impl sdm845_smmu_500_impl = {static const struct arm_smmu_impl qcom_adreno_smmu_v2_impl = { .init_context = qcom_adreno_smmu_init_context, + .cfg_probe = qcom_adreno_smmuv2_cfg_probe, .def_domain_type = qcom_smmu_def_domain_type, .alloc_context_bank = qcom_adreno_smmu_alloc_context_bank, .write_sctlr = qcom_adreno_smmu_write_sctlr,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 80/139 power: reset: brcmstb: Do not go into infinite loop if reset fails
In reply to Sasha LevinFrom: Andrew Davis <[email protected]>
[ Upstream commit cf8c39b00e982fa506b16f9d76657838c09150cb ]
There may be other backup reset methods available, do not halt here so that other reset methods can be tried.
--- drivers/power/reset/brcmstb-reboot.c | 3 --- 1 file changed, 3 deletions(-)
drivers/power/reset/brcmstb-reboot.c +0 -3
@@ -62,9 +62,6 @@ static int brcmstb_restart_handler(struct notifier_block *this,return NOTIFY_DONE ; } -while (1 ) - ; -return NOTIFY_DONE ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 81/139 iommu/vt-d: Always reserve a domain ID for identity setup
In reply to Sasha LevinFrom: Lu Baolu <[email protected]>
[ Upstream commit 2c13012e09190174614fd6901857a1b8c199e17d ]
We will use a global static identity domain. Reserve a static domain ID for it.
--- drivers/iommu/intel/iommu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iommu/intel/iommu.c +3 -3
@@ -1692,10 +1692,10 @@ static int iommu_init_domains(struct intel_iommu *iommu)* entry for first-level or pass-through translation modes should * be programmed with a domain id different from those used for * second-level or nested translation. We reserve a domain id for -* this purpose. +* this purpose. This domain id is also used for identity domain +* in legacy mode. */ -if (sm_supported (iommu)) -set_bit (FLPT_DEFAULT_DID , iommu->domain_ids); +set_bit (FLPT_DEFAULT_DID , iommu->domain_ids);return 0 ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 82/139 iommu/vt-d: Fix potential lockup if qi_submit_sync called with 0 count
In reply to Sasha LevinFrom: Sanjay K Kumar <[email protected]>
[ Upstream commit 3cf74230c139f208b7fb313ae0054386eee31a81 ]
If qi_submit_sync() is invoked with 0 invalidation descriptors (for instance, for DMA draining purposes), we can run into a bug where a submitting thread fails to detect the completion of invalidation_wait. Subsequently, this led to a soft lockup. Currently, there is no impact by this bug on the existing users because no callers are submitting invalidations with 0 descriptors. This fix will enable future users (such as DMA drain) calling qi_submit_sync() with 0 count.
Suppose thread T1 invokes qi_submit_sync() with non-zero descriptors, while concurrently, thread T2 calls qi_submit_sync() with zero descriptors. Both threads then enter a while loop, waiting for their respective descriptors to complete. T1 detects its completion (i.e., T1's invalidation_wait status changes to QI_DONE by HW) and proceeds to call reclaim_free_desc() to reclaim all descriptors, potentially including adjacent ones of other threads that are also marked as QI_DONE.
During this time, while T2 is waiting to acquire the qi->q_lock, the IOMMU hardware may complete the invalidation for T2, setting its status to QI_DONE. However, if T1's execution of reclaim_free_desc() frees T2's invalidation_wait descriptor and changes its status to QI_FREE, T2 will not observe the QI_DONE status for its invalidation_wait and will indefinitely remain stuck.
This soft lockup does not occur when only non-zero descriptors are submitted.In such cases, invalidation descriptors are interspersed among wait descriptors with the status QI_IN_USE, acting as barriers. These barriers prevent the reclaim code from mistakenly freeing descriptors belonging to other submitters.
Considered the following example timeline:
T1 T2 ======================================== ID1 WD1 while(WD1!=QI_DONE) unlock lock WD1=QI_DONE* WD2 while(WD2!=QI_DONE) unlock lock WD1==QI_DONE? ID1=QI_DONE WD2=DONE* reclaim() ID1=FREE WD1=FREE WD2=FREE unlock soft lockup! T2 never sees QI_DONE in WD2
Where:
ID = invalidation descriptor
WD = wait descriptor
* Written by hardware
The root of the problem is that the descriptor status QI_DONE flag is used for two conflicting purposes:
1. signal a descriptor is ready for reclaim (to be freed)
2. signal by the hardware that a wait descriptor is complete
The solution (in this patch) is state separation by using QI_FREE flag for #1.
Once a thread's invalidation descriptors are complete, their status would be set to QI_FREE. The reclaim_free_desc() function would then only free descriptors marked as QI_FREE instead of those marked as QI_DONE. This change ensures that T2 (from the previous example) will correctly observe the completion of its invalidation_wait (marked as QI_DONE).
--- drivers/iommu/intel/dmar.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/iommu/intel/dmar.c +11 -5
@@ -1202,9 +1202,7 @@ static void free_iommu(struct intel_iommu *iommu)*/ static inline void reclaim_free_desc (struct q_inval *qi) { -while (qi->desc_status[qi->free_tail] ==QI_DONE || - qi->desc_status[qi->free_tail] ==QI_ABORT ) { - qi->desc_status[qi->free_tail] =QI_FREE ; +while (qi->desc_status[qi->free_tail] ==QI_FREE && qi->free_tail != qi->free_head) { qi->free_tail = (qi->free_tail +1 ) %QI_LENGTH ; qi->free_cnt++; }
@@ -1439,8 +1437,16 @@ int qi_submit_sync(struct intel_iommu *iommu, struct qi_desc *desc,raw_spin_lock (&qi->q_lock); } -for (i =0 ; i < count; i++) - qi->desc_status[(index + i) %QI_LENGTH ] =QI_DONE ; +/* +* The reclaim code can free descriptors from multiple submissions +* starting from the tail of the queue. When count == 0, the +* status of the standalone wait descriptor at the tail of the queue +* must be set to QI_FREE to allow the reclaim code to proceed. +* It is also possible that descriptors from one of the previous +* submissions has to be reclaimed by a subsequent submission. +*/ +for (i =0 ; i <= count; i++) + qi->desc_status[(index + i) %QI_LENGTH ] =QI_FREE ;reclaim_free_desc (qi);raw_spin_unlock_irqrestore (&qi->q_lock, flags);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 83/139 cgroup: Disallow mounting v1 hierarchies without controller implementation
In reply to Sasha LevinFrom: Michal Koutný <[email protected]>
[ Upstream commit 3c41382e920f1dd5c9f432948fe799c07af1cced ]
The configs that disable some v1 controllers would still allow mounting them but with no controller-specific files. (Making such hierarchies equivalent to named v1 hierarchies.) To achieve behavior consistent with actual out-compilation of a whole controller, the mounts should treat respective controllers as non-existent.
Wrap implementation into a helper function, leverage legacy_files to detect compiled out controllers. The effect is that mounts on v1 would fail and produce a message like:
[ 1543.999081] cgroup: Unknown subsys name 'memory'
--- kernel/cgroup/cgroup-v1.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
kernel/cgroup/cgroup-v1.c +10 -2
@@ -46,6 +46,12 @@ bool cgroup1_ssid_disabled(int ssid)return cgroup_no_v1_mask & (1 << ssid); } +static bool cgroup1_subsys_absent (struct cgroup_subsys *ss) +{ +/* Check also dfl_cftypes for file-less controllers, i.e. perf_event */ +return ss->legacy_cftypes ==NULL && ss->dfl_cftypes; +} +/** * cgroup_attach_task_all - attach task 'tsk' to all cgroups of task 'from' * @from: attach to all cgroups of a given task
@@ -932,7 +938,8 @@ int cgroup1_parse_param(struct fs_context *fc, struct fs_parameter *param)if (ret != -ENOPARAM )return ret;for_each_subsys (ss, i) { -if (strcmp (param->key, ss->legacy_name)) +if (strcmp (param->key, ss->legacy_name) || +cgroup1_subsys_absent (ss))continue ;if (!cgroup_ssid_enabled (i) ||cgroup1_ssid_disabled (i)) return invalfc(fc, "Disabled controller '%s'",
@@ -1024,7 +1031,8 @@ static int check_cgroupfs_options(struct fs_context *fc) mask = ~((u16 )1 << cpuset_cgrp_id);#endif for_each_subsys (ss, i) -if (cgroup_ssid_enabled (i) && !cgroup1_ssid_disabled (i)) +if (cgroup_ssid_enabled (i) && !cgroup1_ssid_disabled (i) && + !cgroup1_subsys_absent (ss)) enabled |=1 << i; ctx->subsys_mask &= enabled;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 84/139 drm/stm: Avoid use-after-free issues with crtc and plane
In reply to Sasha LevinFrom: Katya Orlova <[email protected]>
[ Upstream commit 19dd9780b7ac673be95bf6fd6892a184c9db611f ]
ltdc_load() calls functions drm_crtc_init_with_planes(), drm_universal_plane_init() and drm_encoder_init(). These functions should not be called with parameters allocated with devm_kzalloc() to avoid use-after-free issues [1].
Use allocations managed by the DRM framework.
Found by Linux Verification Center (linuxtesting.org).
[1]
https://lore.kernel.org/lkml/u366i76e3qhh3ra5oxrtngjtm2u5lterkekcz6y2jkndhuxzli@diujon4h7qwb/
--- drivers/gpu/drm/stm/drv.c | 3 +- drivers/gpu/drm/stm/ltdc.c | 73 ++++++++++---------------------------- 2 files changed, 20 insertions(+), 56 deletions(-)
drivers/gpu/drm/stm/drv.c +2 -1
@@ -25,6 +25,7 @@#include <drm/drm_module.h> #include <drm/drm_probe_helper.h> #include <drm/drm_vblank.h> +#include <drm/drm_managed.h> #include "ltdc.h"
@@ -75,7 +76,7 @@ static int drv_load(struct drm_device *ddev)DRM_DEBUG ("%s\n" , __func__); - ldev =devm_kzalloc (ddev->dev,sizeof (*ldev),GFP_KERNEL ); + ldev =drmm_kzalloc (ddev,sizeof (*ldev),GFP_KERNEL );if (!ldev)return -ENOMEM ;
drivers/gpu/drm/stm/ltdc.c +18 -55
177 lines not on this page · raw message
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 85/139 drm/amdgpu: disallow multiple BO_HANDLES chunks in one submit
In reply to Sasha LevinFrom: Pierre-Eric Pelloux-Prayer <[email protected]>
[ Upstream commit fec5f8e8c6bcf83ed7a392801d7b44c5ecfc1e82 ]
Before this commit, only submits with both a BO_HANDLES chunk and a 'bo_list_handle' would be rejected (by amdgpu_cs_parser_bos).
But if UMD sent multiple BO_HANDLES, what would happen is:
* only the last one would be really used
* all the others would leak memory as amdgpu_cs_p1_bo_handles would overwrite the previous p->bo_list value
This commit rejects submissions with multiple BO_HANDLES chunks to match the implementation of the parser.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +4 -0
@@ -263,6 +263,10 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p,if (size <sizeof (struct drm_amdgpu_bo_list_in )) goto free_partial_kdata; +/* Only a single BO list is allowed to simplify handling. */ +if (p->bo_list) + ret = -EINVAL ; + ret =amdgpu_cs_p1_bo_handles (p, p->chunks[i].kdata);if (ret) goto free_partial_kdata;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 86/139 drm/amdkfd: amdkfd_free_gtt_mem clear the correct pointer
In reply to Sasha LevinFrom: Philip Yang <[email protected]>
[ Upstream commit c86ad39140bbcb9dc75a10046c2221f657e8083b ]
Pass pointer reference to amdgpu_bo_unref to clear the correct pointer, otherwise amdgpu_bo_unref clear the local variable, the original pointer not set to NULL, this could cause use-after-free bug.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 14 +++++++------- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_device.c | 4 ++-- .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 2 +- .../gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +7 -7
@@ -335,15 +335,15 @@ int amdgpu_amdkfd_alloc_gtt_mem(struct amdgpu_device *adev, size_t size,return r; } -void amdgpu_amdkfd_free_gtt_mem (struct amdgpu_device *adev,void *mem_obj) +void amdgpu_amdkfd_free_gtt_mem (struct amdgpu_device *adev,void **mem_obj) { -struct amdgpu_bo *bo = (struct amdgpu_bo *) mem_obj; +struct amdgpu_bo **bo = (struct amdgpu_bo **) mem_obj; -amdgpu_bo_reserve (bo, true); -amdgpu_bo_kunmap (bo); -amdgpu_bo_unpin (bo); -amdgpu_bo_unreserve (bo); -amdgpu_bo_unref (&(bo)); +amdgpu_bo_reserve (*bo, true); +amdgpu_bo_kunmap (*bo); +amdgpu_bo_unpin (*bo); +amdgpu_bo_unreserve (*bo); +amdgpu_bo_unref (bo); } int amdgpu_amdkfd_alloc_gws(struct amdgpu_device *adev, size_t size,
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +1 -1
@@ -221,7 +221,7 @@ int amdgpu_amdkfd_evict_userptr(struct mmu_interval_notifier *mni,int amdgpu_amdkfd_alloc_gtt_mem (struct amdgpu_device *adev,size_t size,void **mem_obj,uint64_t *gpu_addr,void **cpu_ptr,bool mqd_gfx9); -void amdgpu_amdkfd_free_gtt_mem (struct amdgpu_device *adev,void *mem_obj); +void amdgpu_amdkfd_free_gtt_mem (struct amdgpu_device *adev,void **mem_obj);int amdgpu_amdkfd_alloc_gws (struct amdgpu_device *adev,size_t size,void **mem_obj);void amdgpu_amdkfd_free_gws (struct amdgpu_device *adev,void *mem_obj);
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +1 -1
@@ -417,7 +417,7 @@ static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p, err_create_queue:if (wptr_bo) -amdgpu_amdkfd_free_gtt_mem (dev->adev, wptr_bo); +amdgpu_amdkfd_free_gtt_mem (dev->adev, (void **)&wptr_bo); err_wptr_map_gart: err_bind_process: err_pdd:
drivers/gpu/drm/amd/amdkfd/kfd_device.c +2 -2
@@ -838,7 +838,7 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd, kfd_doorbell_error:kfd_gtt_sa_fini (kfd); kfd_gtt_sa_init_error: -amdgpu_amdkfd_free_gtt_mem (kfd->adev, kfd->gtt_mem); +amdgpu_amdkfd_free_gtt_mem (kfd->adev, &kfd->gtt_mem); alloc_gtt_mem_failure: dev_err(kfd_device, "device %x:%x NOT added due to errors\n",
@@ -856,7 +856,7 @@ void kgd2kfd_device_exit(struct kfd_dev *kfd)kfd_doorbell_fini (kfd);ida_destroy (&kfd->doorbell_ida);kfd_gtt_sa_fini (kfd); -amdgpu_amdkfd_free_gtt_mem (kfd->adev, kfd->gtt_mem); +amdgpu_amdkfd_free_gtt_mem (kfd->adev, &kfd->gtt_mem); }kfree (kfd);
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +1 -1
@@ -2610,7 +2610,7 @@ static void deallocate_hiq_sdma_mqd(struct kfd_node *dev, {WARN (!mqd,"No hiq sdma mqd trunk to free" ); -amdgpu_amdkfd_free_gtt_mem (dev->adev, mqd->gtt_mem); +amdgpu_amdkfd_free_gtt_mem (dev->adev, &mqd->gtt_mem); }void device_queue_manager_uninit (struct device_queue_manager *dqm)
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +1 -1
@@ -223,7 +223,7 @@ void kfd_free_mqd_cp(struct mqd_manager *mm, void *mqd, struct kfd_mem_obj *mqd_mem_obj) {if (mqd_mem_obj->gtt_mem) { -amdgpu_amdkfd_free_gtt_mem (mm->dev->adev, mqd_mem_obj->gtt_mem); +amdgpu_amdkfd_free_gtt_mem (mm->dev->adev, &mqd_mem_obj->gtt_mem);kfree (mqd_mem_obj); }else {kfd_gtt_sa_free (mm->dev, mqd_mem_obj);
drivers/gpu/drm/amd/amdkfd/kfd_process.c +1 -1
@@ -1047,7 +1047,7 @@ static void kfd_process_destroy_pdds(struct kfd_process *p)if (pdd->dev->kfd->shared_resources.enable_mes)amdgpu_amdkfd_free_gtt_mem (pdd->dev->adev, - pdd->proc_ctx_bo); + &pdd->proc_ctx_bo);/* * before destroying pdd, make sure to report availability * for auto suspend
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +2 -2
@@ -199,9 +199,9 @@ static void pqm_clean_queue_resource(struct process_queue_manager *pqm, }if (dev->kfd->shared_resources.enable_mes) { -amdgpu_amdkfd_free_gtt_mem (dev->adev, pqn->q->gang_ctx_bo); +amdgpu_amdkfd_free_gtt_mem (dev->adev, &pqn->q->gang_ctx_bo);if (pqn->q->wptr_bo) -amdgpu_amdkfd_free_gtt_mem (dev->adev, pqn->q->wptr_bo); +amdgpu_amdkfd_free_gtt_mem (dev->adev, (void **)&pqn->q->wptr_bo); } }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 87/139 drm/amd/display: Add null check for top_pipe_to_program in commit_planes_for_stream
In reply to Sasha LevinFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit 66d71a72539e173a9b00ca0b1852cbaa5f5bf1ad ]
This commit addresses a null pointer dereference issue in the commit_planes_for_stream function at line 4140. The issue could occur when top_pipe_to_program is null.
The fix adds a check to ensure top_pipe_to_program is not null before accessing its stream_res. This prevents a null pointer dereference.
Reported by smatch:drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc.c:4140 commit_planes_for_stream() error: we previously assumed 'top_pipe_to_program' could be null (see line 3906)
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +2 -1
@@ -3797,7 +3797,8 @@ static void commit_planes_for_stream(struct dc *dc, }if ((update_type !=UPDATE_TYPE_FAST ) && stream->update_flags.bits.dsc_changed) -if (top_pipe_to_program->stream_res.tg->funcs->lock_doublebuffer_enable) { +if (top_pipe_to_program && + top_pipe_to_program->stream_res.tg->funcs->lock_doublebuffer_enable) { top_pipe_to_program->stream_res.tg->funcs->wait_for_state ( top_pipe_to_program->stream_res.tg,CRTC_STATE_VACTIVE );
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 88/139 ata: pata_serverworks: Do not use the term blacklist
In reply to Sasha LevinFrom: Damien Le Moal <[email protected]>
[ Upstream commit 858048568c9e3887d8b19e101ee72f129d65cb15 ]
Let's not use the term blacklist in the function serverworks_osb4_filter() documentation comment and rather simply refer to what that function looks at: the list of devices with groken UDMA5.
While at it, also constify the values of the csb_bad_ata100 array.
Of note is that all of this should probably be handled using libata quirk mechanism but it is unclear if these UDMA5 quirks are specific to this controller only.
--- drivers/ata/pata_serverworks.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/ata/pata_serverworks.c +9 -7
@@ -46,10 +46,11 @@#define SVWKS_CSB5_REVISION_NEW 0x92/* min PCI_REVISION_ID for UDMA5 (A2.0) */ #define SVWKS_CSB6_REVISION 0xa0/* min PCI_REVISION_ID for UDMA4 (A1.0) */ -/* Seagate Barracuda ATA IV Family drives in UDMA mode 5 -* can overrun their FIFOs when used with the CSB5 */ - -static const char *csb_bad_ata100[] = { +/* +* Seagate Barracuda ATA IV Family drives in UDMA mode 5 +* can overrun their FIFOs when used with the CSB5. +*/ +static const char *const csb_bad_ata100[] = {"ST320011A" ,"ST340016A" ,"ST360021A" ,
@@ -163,10 +164,11 @@ static unsigned int serverworks_osb4_filter(struct ata_device *adev, unsigned in* @adev: ATA device * @mask: Mask of proposed modes * -* Check the blacklist and disable UDMA5 if matched +* Check the list of devices with broken UDMA5 and +* disable UDMA5 if matched. */ - -static unsigned int serverworks_csb_filter (struct ata_device *adev,unsigned int mask) +static unsigned int serverworks_csb_filter (struct ata_device *adev, +unsigned int mask) {const char *p;char model_num[ATA_ID_PROD_LEN +1 ];
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 89/139 ata: sata_sil: Rename sil_blacklist to sil_quirks
In reply to Sasha LevinFrom: Damien Le Moal <[email protected]>
[ Upstream commit 93b0f9e11ce511353c65b7f924cf5f95bd9c3aba ]
Rename the array sil_blacklist to sil_quirks as this name is more neutral and is also consistent with how this driver define quirks with the SIL_QUIRK_XXX flags.
--- drivers/ata/sata_sil.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/ata/sata_sil.c +6 -6
@@ -128,7 +128,7 @@ static const struct pci_device_id sil_pci_tbl[] = {static const struct sil_drivelist {const char *product;unsigned int quirk; -} sil_blacklist [] = { +} sil_quirks[] = { {"ST320012AS" ,SIL_QUIRK_MOD15WRITE }, {"ST330013AS" ,SIL_QUIRK_MOD15WRITE }, {"ST340017AS" ,SIL_QUIRK_MOD15WRITE },
@@ -600,8 +600,8 @@ static void sil_thaw(struct ata_port *ap)* list, and apply the fixups to only the specific * devices/hosts/firmwares that need it. * -* 20040111 - Seagate drives affected by the Mod15Write bug are blacklisted -* The Maxtor quirk is in the blacklist, but I'm keeping the original +* 20040111 - Seagate drives affected by the Mod15Write bug are quirked +* The Maxtor quirk is in sil_quirks, but I'm keeping the original * pessimistic fix for the following reasons... * - There seems to be less info on it, only one device gleaned off the * Windows driver, maybe only one is affected. More info would be greatly
@@ -620,9 +620,9 @@ static void sil_dev_config(struct ata_device *dev)ata_id_c_string (dev->id, model_num,ATA_ID_PROD ,sizeof (model_num)); -for (n =0 ; sil_blacklist[n].product; n++) -if (!strcmp (sil_blacklist[n].product, model_num)) { - quirks = sil_blacklist[n].quirk; +for (n =0 ; sil_quirks[n].product; n++) +if (!strcmp (sil_quirks[n].product, model_num)) { + quirks = sil_quirks[n].quirk;break ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 90/139 HID: Ignore battery for all ELAN I2C-HID devices
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit bcc31692a1d1e21f0d06c5f727c03ee299d2264e ]
Before this change there were 16 vid:pid based quirks to ignore the battery reported by Elan I2C-HID touchscreens on various Asus and HP laptops.
And a report has been received that the 04F3:2A00 I2C touchscreen on the HP ProBook x360 11 G5 EE/86CF also reports a non present battery.
Since I2C-HID devices are always builtin to laptops they are not battery owered so it should be safe to just ignore the battery on all Elan I2C-HID devices, rather then adding a 17th quirk for the 04F3:2A00 touchscreen.
As reported in the changelog of commit a3a5a37efba1 ("HID: Ignore battery for ELAN touchscreens 2F2C and 4116"), which added 2 new Elan touchscreen quirks about a month ago, the HID reported battery seems to be related to a stylus being used. But even when a stylus is in use it does not properly report the charge of the stylus battery, instead the reported battery charge jumps from 0% to 1%. So it is best to just ignore the HID battery.
--- drivers/hid/hid-ids.h | 16 ---------------- drivers/hid/hid-input.c | 37 +++++-------------------------------- 2 files changed, 5 insertions(+), 48 deletions(-)
drivers/hid/hid-ids.h +0 -16
@@ -411,24 +411,8 @@#define USB_DEVICE_ID_TOSHIBA_CLICK_L9W 0x0401#define USB_DEVICE_ID_HP_X2 0x074d#define USB_DEVICE_ID_HP_X2_10_COVER 0x0755 -#define I2C_DEVICE_ID_HP_ENVY_X360_15 0x2d05 -#define I2C_DEVICE_ID_HP_ENVY_X360_15T_DR100 0x29CF -#define I2C_DEVICE_ID_HP_ENVY_X360_EU0009NV 0x2CF9 -#define I2C_DEVICE_ID_HP_SPECTRE_X360_15 0x2817 -#define I2C_DEVICE_ID_HP_SPECTRE_X360_13_AW0020NG 0x29DF -#define I2C_DEVICE_ID_ASUS_TP420IA_TOUCHSCREEN 0x2BC8 -#define I2C_DEVICE_ID_ASUS_GV301RA_TOUCHSCREEN 0x2C82 -#define I2C_DEVICE_ID_ASUS_UX3402_TOUCHSCREEN 0x2F2C -#define I2C_DEVICE_ID_ASUS_UX6404_TOUCHSCREEN 0x4116#define USB_DEVICE_ID_ASUS_UX550VE_TOUCHSCREEN 0x2544#define USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN 0x2706 -#define I2C_DEVICE_ID_SURFACE_GO_TOUCHSCREEN 0x261A -#define I2C_DEVICE_ID_SURFACE_GO2_TOUCHSCREEN 0x2A1C -#define I2C_DEVICE_ID_LENOVO_YOGA_C630_TOUCHSCREEN 0x279F -#define I2C_DEVICE_ID_HP_SPECTRE_X360_13T_AW100 0x29F5 -#define I2C_DEVICE_ID_HP_SPECTRE_X360_14T_EA100_V1 0x2BED -#define I2C_DEVICE_ID_HP_SPECTRE_X360_14T_EA100_V2 0x2BEE -#define I2C_DEVICE_ID_HP_ENVY_X360_15_EU0556NG 0x2D02#define I2C_DEVICE_ID_CHROMEBOOK_TROGDOR_POMPOM 0x2F81#define USB_VENDOR_ID_ELECOM 0x056e
drivers/hid/hid-input.c +5 -32
@@ -373,14 +373,6 @@ static const struct hid_device_id hid_battery_quirks[] = { {HID_BLUETOOTH_DEVICE (USB_VENDOR_ID_LOGITECH ,USB_DEVICE_ID_LOGITECH_DINOVO_EDGE_KBD ), HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_ASUS_TP420IA_TOUCHSCREEN), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_ASUS_GV301RA_TOUCHSCREEN), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_ASUS_UX3402_TOUCHSCREEN), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_ASUS_UX6404_TOUCHSCREEN), - HID_BATTERY_QUIRK_IGNORE }, { HID_USB_DEVICE(USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN), HID_BATTERY_QUIRK_IGNORE }, { HID_USB_DEVICE(USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ASUS_UX550VE_TOUCHSCREEN),
@@ -391,32 +383,13 @@ static const struct hid_device_id hid_battery_quirks[] = { HID_BATTERY_QUIRK_AVOID_QUERY }, {HID_USB_DEVICE (USB_VENDOR_ID_UGEE ,USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_PRO_SW ), HID_BATTERY_QUIRK_AVOID_QUERY }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_ENVY_X360_15), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_ENVY_X360_15T_DR100), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_ENVY_X360_EU0009NV), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_SPECTRE_X360_15), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_SPECTRE_X360_13_AW0020NG), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_SURFACE_GO_TOUCHSCREEN), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_SURFACE_GO2_TOUCHSCREEN), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_LENOVO_YOGA_C630_TOUCHSCREEN), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_SPECTRE_X360_13T_AW100), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_SPECTRE_X360_14T_EA100_V1), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_SPECTRE_X360_14T_EA100_V2), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_ENVY_X360_15_EU0556NG), - HID_BATTERY_QUIRK_IGNORE }, { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_CHROMEBOOK_TROGDOR_POMPOM), HID_BATTERY_QUIRK_AVOID_QUERY }, +/* +* Elan I2C-HID touchscreens seem to all report a non present battery, +* set HID_BATTERY_QUIRK_IGNORE for all Elan I2C-HID devices. +*/ + { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, HID_ANY_ID), HID_BATTERY_QUIRK_IGNORE }, {} };
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 91/139 drm/amd/display: Handle null 'stream_status' in 'planes_changed_for_existing_stream'
In reply to Sasha LevinFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit 8141f21b941710ecebe49220b69822cab3abd23d ]
This commit adds a null check for 'stream_status' in the function 'planes_changed_for_existing_stream'. Previously, the code assumed 'stream_status' could be null, but did not handle the case where it was actually null. This could lead to a null pointer dereference.
Reported by smatch:drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_resource.c:3784 planes_changed_for_existing_stream() error: we previously assumed 'stream_status' could be null (see line 3774)
--- drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_resource.c +3 -1
@@ -2877,8 +2877,10 @@ static bool planes_changed_for_existing_stream(struct dc_state *context, } } -if (!stream_status) +if (!stream_status) {ASSERT (0 ); +return false; + }for (i =0 ; i < set_count; i++)if (set[i].stream == stream)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 92/139 drm/amd/display: Check null pointers before using dc->clk_mgr
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit 95d9e0803e51d5a24276b7643b244c7477daf463 ]
[WHY & HOW]dc->clk_mgr is null checked previously in the same function, indicating it might be null.
Passing "dc" to "dc->hwss.apply_idle_power_optimizations", which dereferences null "dc->clk_mgr". (The function pointer resolves to "dcn35_apply_idle_power_optimizations".)
This fixes 1 FORWARD_NULL issue reported by Coverity.
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +2 -1
@@ -4716,7 +4716,8 @@ void dc_allow_idle_optimizations(struct dc *dc, bool allow)if (allow == dc->idle_optimizations_allowed)return ; -if (dc->hwss.apply_idle_power_optimizations && dc->hwss.apply_idle_power_optimizations (dc, allow)) +if (dc->hwss.apply_idle_power_optimizations && dc->clk_mgr !=NULL && + dc->hwss.apply_idle_power_optimizations (dc, allow)) dc->idle_optimizations_allowed = allow; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 93/139 drm/amd/display: Add null check for 'afb' in amdgpu_dm_plane_handle_cursor_update (v2)
In reply to Sasha LevinFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit cd9e9e0852d501f169aa3bb34e4b413d2eb48c37 ]
This commit adds a null check for the 'afb' variable in the amdgpu_dm_plane_handle_cursor_update function. Previously, 'afb' was assumed to be null, but was used later in the code without a null check. This could potentially lead to a null pointer dereference.
Changes since v1:
- Moved the null check for 'afb' to the line where 'afb' is used. (Alex)
Fixes the below:drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_plane.c:1298 amdgpu_dm_plane_handle_cursor_update() error: we previously assumed 'afb' could be null (see line 1252)
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c +2 -1
@@ -1281,7 +1281,8 @@ void amdgpu_dm_plane_handle_cursor_update(struct drm_plane *plane, adev->dm.dc->caps.color.dpp.gamma_corr) attributes.attribute_flags.bits.ENABLE_CURSOR_DEGAMMA =1 ; - attributes.pitch = afb->base.pitches[0 ] / afb->base.format->cpp[0 ]; +if (afb) + attributes.pitch = afb->base.pitches[0 ] / afb->base.format->cpp[0 ];if (crtc_state->stream) {mutex_lock (&adev->dm.dc_lock);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 94/139 drm/amd/display: fix double free issue during amdgpu module unload
In reply to Sasha LevinFrom: Tim Huang <[email protected]>
[ Upstream commit 20b5a8f9f4670a8503aa9fa95ca632e77c6bf55d ]
Flexible endpoints use DIGs from available inflexible endpoints, so only the encoders of inflexible links need to be freed. Otherwise, a double free issue may occur when unloading the amdgpu module.
[ 279.190523] RIP: 0010:__slab_free+0x152/0x2f0 [ 279.190577] Call Trace: [ 279.190580] <TASK> [ 279.190582] ? show_regs+0x69/0x80 [ 279.190590] ? die+0x3b/0x90 [ 279.190595] ? do_trap+0xc8/0xe0 [ 279.190601] ? do_error_trap+0x73/0xa0 [ 279.190605] ? __slab_free+0x152/0x2f0 [ 279.190609] ? exc_invalid_op+0x56/0x70 [ 279.190616] ? __slab_free+0x152/0x2f0 [ 279.190642] ? asm_exc_invalid_op+0x1f/0x30 [ 279.190648] ? dcn10_link_encoder_destroy+0x19/0x30 [amdgpu] [ 279.191096] ? __slab_free+0x152/0x2f0 [ 279.191102] ? dcn10_link_encoder_destroy+0x19/0x30 [amdgpu] [ 279.191469] kfree+0x260/0x2b0 [ 279.191474] dcn10_link_encoder_destroy+0x19/0x30 [amdgpu] [ 279.191821] link_destroy+0xd7/0x130 [amdgpu] [ 279.192248] dc_destruct+0x90/0x270 [amdgpu] [ 279.192666] dc_destroy+0x19/0x40 [amdgpu] [ 279.193020] amdgpu_dm_fini+0x16e/0x200 [amdgpu] [ 279.193432] dm_hw_fini+0x26/0x40 [amdgpu] [ 279.193795] amdgpu_device_fini_hw+0x24c/0x400 [amdgpu] [ 279.194108] amdgpu_driver_unload_kms+0x4f/0x70 [amdgpu] [ 279.194436] amdgpu_pci_remove+0x40/0x80 [amdgpu] [ 279.194632] pci_device_remove+0x3a/0xa0 [ 279.194638] device_remove+0x40/0x70 [ 279.194642] device_release_driver_internal+0x1ad/0x210 [ 279.194647] driver_detach+0x4e/0xa0 [ 279.194650] bus_remove_driver+0x6f/0xf0 [ 279.194653] driver_unregister+0x33/0x60 [ 279.194657] pci_unregister_driver+0x44/0x90 [ 279.194662] amdgpu_exit+0x19/0x1f0 [amdgpu] [ 279.194939] __do_sys_delete_module.isra.0+0x198/0x2f0 [ 279.194946] __x64_sys_delete_module+0x16/0x20 [ 279.194950] do_syscall_64+0x58/0x120 [ 279.194954] entry_SYSCALL_64_after_hwframe+0x6e/0x76 [ 279.194980] </TASK>
--- drivers/gpu/drm/amd/display/dc/link/link_factory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/link/link_factory.c +1 -1
@@ -403,7 +403,7 @@ static void link_destruct(struct dc_link *link)if (link->panel_cntl) link->panel_cntl->funcs->destroy (&link->panel_cntl); -if (link->link_enc) { +if (link->link_enc && !link->is_dig_mapping_flexible) {/* Update link encoder resource tracking variables. These are used for * the dynamic assignment of link encoders to streams. Virtual links * are not assigned encoder resources on creation.
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 95/139 jfs: UBSAN: shift-out-of-bounds in dbFindBits
In reply to Sasha LevinFrom: Remington Brasga <[email protected]>
[ Upstream commit b0b2fc815e514221f01384f39fbfbff65d897e1c ]
Fix issue with UBSAN throwing shift-out-of-bounds warning.
--- fs/jfs/jfs_dmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/jfs/jfs_dmap.c +1 -1
@@ -3022,7 +3022,7 @@ static int dbFindBits(u32 word, int l2nb)/* scan the word for nb free bits at nb alignments. */ -for (bitno =0 ; mask !=0 ; bitno += nb, mask >>= nb) { +for (bitno =0 ; mask !=0 ; bitno += nb, mask = (mask >> nb)) {if ((mask & word) == mask)break ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 96/139 jfs: Fix uaf in dbFreeBits
In reply to Sasha LevinFrom: Edward Adam Davis <[email protected]>
[ Upstream commit d6c1b3599b2feb5c7291f5ac3a36e5fa7cedb234 ]
[syzbot reported]
==================================================================
BUG: KASAN: slab-use-after-free in __mutex_lock_common kernel/locking/mutex.c:587 [inline] BUG: KASAN: slab-use-after-free in __mutex_lock+0xfe/0xd70 kernel/locking/mutex.c:752 Read of size 8 at addr ffff8880229254b0 by task syz-executor357/5216 CPU: 0 UID: 0 PID: 5216 Comm: syz-executor357 Not tainted 6.11.0-rc3-syzkaller-00156-gd7a5aa4b3c00 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/2024 Call Trace: <TASK> __dump_stack lib/dump_stack.c:93 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:119 print_address_description mm/kasan/report.c:377 [inline] print_report+0x169/0x550 mm/kasan/report.c:488 kasan_report+0x143/0x180 mm/kasan/report.c:601 __mutex_lock_common kernel/locking/mutex.c:587 [inline] __mutex_lock+0xfe/0xd70 kernel/locking/mutex.c:752 dbFreeBits+0x7ea/0xd90 fs/jfs/jfs_dmap.c:2390 dbFreeDmap fs/jfs/jfs_dmap.c:2089 [inline] dbFree+0x35b/0x680 fs/jfs/jfs_dmap.c:409 dbDiscardAG+0x8a9/0xa20 fs/jfs/jfs_dmap.c:1650 jfs_ioc_trim+0x433/0x670 fs/jfs/jfs_discard.c:100 jfs_ioctl+0x2d0/0x3e0 fs/jfs/ioctl.c:131 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:907 [inline] __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:893 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 Freed by task 5218: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579 poison_slab_object+0xe0/0x150 mm/kasan/common.c:240 __kasan_slab_free+0x37/0x60 mm/kasan/common.c:256 kasan_slab_free include/linux/kasan.h:184 [inline] slab_free_hook mm/slub.c:2252 [inline] slab_free mm/slub.c:4473 [inline] kfree+0x149/0x360 mm/slub.c:4594 dbUnmount+0x11d/0x190 fs/jfs/jfs_dmap.c:278 jfs_mount_rw+0x4ac/0x6a0 fs/jfs/jfs_mount.c:247 jfs_remount+0x3d1/0x6b0 fs/jfs/super.c:454 reconfigure_super+0x445/0x880 fs/super.c:1083 vfs_cmd_reconfigure fs/fsopen.c:263 [inline] vfs_fsconfig_locked fs/fsopen.c:292 [inline] __do_sys_fsconfig fs/fsopen.c:473 [inline] __se_sys_fsconfig+0xb6e/0xf80 fs/fsopen.c:345 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f
[Analysis]
There are two paths (dbUnmount and jfs_ioc_trim) that generate race condition when accessing bmap, which leads to the occurrence of uaf.
Use the lock s_umount to synchronize them, in order to avoid uaf caused by race condition.
--- fs/jfs/jfs_discard.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
fs/jfs/jfs_discard.c +9 -2
@@ -65,7 +65,7 @@ void jfs_issue_discard(struct inode *ip, u64 blkno, u64 nblocks)int jfs_ioc_trim (struct inode *ip,struct fstrim_range *range) {struct inode *ipbmap =JFS_SBI (ip->i_sb)->ipbmap; -struct bmap *bmp =JFS_SBI (ip->i_sb)->bmap; +struct bmap *bmp;struct super_block *sb = ipbmap->i_sb;int agno, agno_end;u64 start, end, minlen;
@@ -83,10 +83,15 @@ int jfs_ioc_trim(struct inode *ip, struct fstrim_range *range)if (minlen ==0 ) minlen =1 ; +down_read (&sb->s_umount); + bmp =JFS_SBI (ip->i_sb)->bmap; +if (minlen > bmp->db_agsize || start >= bmp->db_mapsize || - range->len < sb->s_blocksize) + range->len < sb->s_blocksize) { +up_read (&sb->s_umount);return -EINVAL ; + }if (end >= bmp->db_mapsize) end = bmp->db_mapsize -1 ;
@@ -100,6 +105,8 @@ int jfs_ioc_trim(struct inode *ip, struct fstrim_range *range) trimmed +=dbDiscardAG (ip, agno, minlen); agno++; } + +up_read (&sb->s_umount); range->len = trimmed << sb->s_blocksize_bits;return 0 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 97/139 jfs: check if leafidx greater than num leaves per dmap tree
In reply to Sasha LevinFrom: Edward Adam Davis <[email protected]>
[ Upstream commit d64ff0d2306713ff084d4b09f84ed1a8c75ecc32 ]
syzbot report a out of bounds in dbSplit, it because dmt_leafidx greater than num leaves per dmap tree, add a checking for dmt_leafidx in dbFindLeaf.
Shaggy:
Modified sanity check to apply to control pages as well as leaf pages.
--- fs/jfs/jfs_dmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/jfs/jfs_dmap.c +4 -1
@@ -2944,9 +2944,10 @@ static void dbAdjTree(dmtree_t *tp, int leafno, int newval, bool is_ctl)static int dbFindLeaf (dmtree_t *tp,int l2nb,int *leafidx,bool is_ctl) {int ti, n =0 , k, x =0 ; -int max_size; +int max_size, max_idx; max_size = is_ctl ?CTLTREESIZE :TREESIZE ; + max_idx = is_ctl ?LPERCTL :LPERDMAP ;/* first check the root of the tree to see if there is * sufficient free space.
@@ -2978,6 +2979,8 @@ static int dbFindLeaf(dmtree_t *tp, int l2nb, int *leafidx, bool is_ctl)*/ assert (n <4 ); } +if (le32_to_cpu (tp->dmt_leafidx) >= max_idx) +return -ENOSPC ;/* set the return to the leftmost leaf describing sufficient * free space.
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 98/139 scsi: smartpqi: correct stream detection
In reply to Sasha LevinFrom: Mahesh Rajashekhara <[email protected]>
[ Upstream commit 4c76114932d1d6fad2e72823e7898a3c960cf2a7 ]
Correct stream detection by initializing the structure pqi_scsi_dev_raid_map_data to 0s.
When the OS issues SCSI READ commands, the driver erroneously considers them as SCSI WRITES. If they are identified as sequential IOs, the driver then submits those requests via the RAID path instead of the AIO path.
The 'is_write' flag might be set for SCSI READ commands also. The driver may interpret SCSI READ commands as SCSI WRITE commands, resulting in IOs being submitted through the RAID path.
Note: This does not cause data corruption.
--- drivers/scsi/smartpqi/smartpqi_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/smartpqi/smartpqi_init.c +1 -1
@@ -5934,7 +5934,7 @@ static bool pqi_is_parity_write_stream(struct pqi_ctrl_info *ctrl_info,int rc;struct pqi_scsi_dev *device;struct pqi_stream_data *pqi_stream_data; -struct pqi_scsi_dev_raid_map_data rmd; +struct pqi_scsi_dev_raid_map_data rmd = {0 };if (!ctrl_info->enable_stream_detection)return false;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 99/139 drm/msm/adreno: Assign msm_gpu->pdev earlier to avoid nullptrs
In reply to Sasha LevinFrom: Konrad Dybcio <[email protected]>
[ Upstream commit 16007768551d5bfe53426645401435ca8d2ef54f ]
There are some cases, such as the one uncovered by Commit 46d4efcccc68 ("drm/msm/a6xx: Avoid a nullptr dereference when speedbin setting fails") where
msm_gpu_cleanup() : platform_set_drvdata(gpu->pdev, NULL);
is called on gpu->pdev == NULL, as the GPU device has not been fully initialized yet.
Turns out that there's more than just the aforementioned path that causes this to happen (e.g. the case when there's speedbin data in the catalog, but opp-supported-hw is missing in DT).
Assigning msm_gpu->pdev earlier seems like the least painful solution to this, therefore do so.
Patchwork: https://patchwork.freedesktop.org/patch/602742/
--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 1 + drivers/gpu/drm/msm/msm_gpu.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +1 -0
@@ -1071,6 +1071,7 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, adreno_gpu->chip_id = config->chip_id; gpu->allow_relocs = config->info->family <ADRENO_6XX_GEN1 ; + gpu->pdev = pdev;/* Only handle the core clock when GMU is not in use (or is absent). */ if (adreno_has_gmu_wrapper(adreno_gpu) ||
drivers/gpu/drm/msm/msm_gpu.c +0 -1
@@ -927,7 +927,6 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,if (IS_ERR (gpu->gpu_cx)) gpu->gpu_cx =NULL ; - gpu->pdev = pdev;platform_set_drvdata (pdev, &gpu->adreno_smmu);msm_devfreq_init (gpu);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 100/139 jfs: Fix uninit-value access of new_ea in ea_buffer
In reply to Sasha LevinFrom: Zhao Mengmeng <[email protected]>
[ Upstream commit 2b59ffad47db1c46af25ccad157bb3b25147c35c ]
syzbot reports that lzo1x_1_do_compress is using uninit-value:
=====================================================
BUG: KMSAN: uninit-value in lzo1x_1_do_compress+0x19f9/0x2510 lib/lzo/lzo1x_compress.c:178
...
Uninit was stored to memory at:
ea_put fs/jfs/xattr.c:639 [inline]
...
Local variable ea_buf created at:
__jfs_setxattr+0x5d/0x1ae0 fs/jfs/xattr.c:662 __jfs_xattr_set+0xe6/0x1f0 fs/jfs/xattr.c:934
=====================================================
The reason is ea_buf->new_ea is not initialized properly.
Fix this by using memset to empty its content at the beginning in ea_get().
--- fs/jfs/xattr.c | 2 ++ 1 file changed, 2 insertions(+)
fs/jfs/xattr.c +2 -0
@@ -434,6 +434,8 @@ static int ea_get(struct inode *inode, struct ea_buffer *ea_buf, int min_size)int rc;int quota_allocation =0 ; +memset (&ea_buf->new_ea,0 ,sizeof (ea_buf->new_ea)); +/* When fsck.jfs clears a bad ea, it doesn't clear the size */ if (ji->ea.flag ==0 ) ea_size =0 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 101/139 drm/amdgpu: add raven1 gfxoff quirk
In reply to Sasha LevinFrom: Peng Liu <[email protected]>
[ Upstream commit 0126c0ae11e8b52ecfde9d1b174ee2f32d6c3a5d ]
Fix screen corruption with openkylin.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -0
@@ -1172,6 +1172,8 @@ static const struct amdgpu_gfxoff_quirk amdgpu_gfxoff_quirk_list[] = { { 0x1002, 0x15dd, 0x1002, 0x15dd, 0xc6 },/* Apple MacBook Pro (15-inch, 2019) Radeon Pro Vega 20 4 GB */ { 0x1002, 0x69af, 0x106b, 0x019a, 0xc0 }, +/* https://bbs.openkylin.top/t/topic/171497 */ + { 0x1002, 0x15d8, 0x19e5, 0x3e14, 0xc2 }, { 0, 0, 0, 0, 0 }, };
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 102/139 drm/amdgpu: enable gfxoff quirk on HP 705G4
In reply to Sasha LevinFrom: Peng Liu <[email protected]>
[ Upstream commit 2c7795e245d993bcba2f716a8c93a5891ef910c9 ]
Enabling gfxoff quirk results in perfectly usable graphical user interface on HP 705G4 DM with R5 2400G.
Without the quirk, X server is completely unusable as every few seconds there is gpu reset due to ring gfx timeout.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -0
@@ -1174,6 +1174,8 @@ static const struct amdgpu_gfxoff_quirk amdgpu_gfxoff_quirk_list[] = { { 0x1002, 0x69af, 0x106b, 0x019a, 0xc0 },/* https://bbs.openkylin.top/t/topic/171497 */ { 0x1002, 0x15d8, 0x19e5, 0x3e14, 0xc2 }, +/* HP 705G4 DM with R5 2400G */ + { 0x1002, 0x15dd, 0x103c, 0x8464, 0xd6 }, { 0, 0, 0, 0, 0 }, };
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 103/139 drm/amdkfd: Fix resource leak in criu restore queue
In reply to Sasha LevinFrom: Jesse Zhang <[email protected]>
[ Upstream commit aa47fe8d3595365a935921a90d00bc33ee374728 ]
To avoid memory leaks, release q_extra_data when exiting the restore queue.
v2: Correct the proto (Alex)
--- drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +1 -0
@@ -982,6 +982,7 @@ int kfd_criu_restore_queue(struct kfd_process *p,pr_debug ("Queue id %d was restored successfully\n" , queue_id);kfree (q_data); +kfree (q_extra_data);return ret; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 104/139 HID: multitouch: Add support for Thinkpad X12 Gen 2 Kbd Portfolio
In reply to Sasha LevinFrom: Vishnu Sankar <[email protected]>
[ Upstream commit 65b72ea91a257a5f0cb5a26b01194d3dd4b85298 ]
This applies similar quirks used by previous generation device, so that Trackpoint and buttons on the touchpad works. New USB KBD PID 0x61AE for Thinkpad X12 Tab is added.
--- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-multitouch.c | 6 ++++++ 2 files changed, 7 insertions(+)
drivers/hid/hid-ids.h +1 -0
@@ -786,6 +786,7 @@#define USB_DEVICE_ID_LENOVO_X1_TAB 0x60a3#define USB_DEVICE_ID_LENOVO_X1_TAB3 0x60b5#define USB_DEVICE_ID_LENOVO_X12_TAB 0x60fe +#define USB_DEVICE_ID_LENOVO_X12_TAB2 0x61ae#define USB_DEVICE_ID_LENOVO_OPTICAL_USB_MOUSE_600E 0x600e#define USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_608D 0x608d#define USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_6019 0x6019
drivers/hid/hid-multitouch.c +6 -0
@@ -2084,6 +2084,12 @@ static const struct hid_device_id mt_devices[] = { USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_X12_TAB) }, +/* Lenovo X12 TAB Gen 2 */ + { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU, +HID_DEVICE (BUS_USB ,HID_GROUP_MULTITOUCH_WIN_8 , +USB_VENDOR_ID_LENOVO , + USB_DEVICE_ID_LENOVO_X12_TAB2) }, + /* Logitech devices */ { .driver_data = MT_CLS_NSMU, HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_MULTITOUCH_WIN_8,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 105/139 platform/x86: touchscreen_dmi: add nanote-next quirk
In reply to Sasha LevinFrom: Ckath <[email protected]>
[ Upstream commit c11619af35bae5884029bd14170c3e4b55ddf6f3 ]
Add touschscreen info for the nanote next (UMPC-03-SR).
After checking with multiple owners the DMI info really is this generic.
--- drivers/platform/x86/touchscreen_dmi.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
drivers/platform/x86/touchscreen_dmi.c +26 -0
@@ -885,6 +885,21 @@ static const struct ts_dmi_data rwc_nanote_p8_data = { .properties = rwc_nanote_p8_props, }; +static const struct property_entry rwc_nanote_next_props[] = { +PROPERTY_ENTRY_U32 ("touchscreen-min-x" ,5 ), +PROPERTY_ENTRY_U32 ("touchscreen-min-y" ,5 ), +PROPERTY_ENTRY_U32 ("touchscreen-size-x" ,1785 ), +PROPERTY_ENTRY_U32 ("touchscreen-size-y" ,1145 ), +PROPERTY_ENTRY_BOOL ("touchscreen-inverted-y" ), +PROPERTY_ENTRY_STRING ("firmware-name" ,"gsl1680-rwc-nanote-next.fw" ), + { } +}; + +static const struct ts_dmi_data rwc_nanote_next_data = { + .acpi_name ="MSSL1680:00" , + .properties = rwc_nanote_next_props, +}; +static const struct property_entry schneider_sct101ctm_props[] = {PROPERTY_ENTRY_U32 ("touchscreen-size-x" ,1715 ),PROPERTY_ENTRY_U32 ("touchscreen-size-y" ,1140 ),
@@ -1648,6 +1663,17 @@ const struct dmi_system_id touchscreen_dmi_table[] = {DMI_MATCH (DMI_PRODUCT_SKU ,"0001" ) }, }, + { +/* RWC NANOTE NEXT */ + .driver_data = (void *)&rwc_nanote_next_data, + .matches = { +DMI_MATCH (DMI_PRODUCT_NAME ,"To be filled by O.E.M." ), +DMI_MATCH (DMI_BOARD_NAME ,"To be filled by O.E.M." ), +DMI_MATCH (DMI_BOARD_VENDOR ,"To be filled by O.E.M." ), +/* Above matches are too generic, add bios-version match */ + DMI_MATCH(DMI_BIOS_VERSION, "S8A70R100-V005"), + }, + }, {/* Schneider SCT101CTM */ .driver_data = (void *)&schneider_sct101ctm_data,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 106/139 drm/stm: ltdc: reset plane transparency after plane disable
In reply to Sasha LevinFrom: Yannick Fertre <[email protected]>
[ Upstream commit 02fa62d41c8abff945bae5bfc3ddcf4721496aca ]
The plane's opacity should be reseted while the plane is disabled. It prevents from seeing a possible global or layer background color set earlier.
--- drivers/gpu/drm/stm/ltdc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/stm/ltdc.c +3 -0
@@ -1513,6 +1513,9 @@ static void ltdc_plane_atomic_disable(struct drm_plane *plane,/* Disable layer */ regmap_write_bits (ldev->regmap,LTDC_L1CR + lofs,LXCR_LEN |LXCR_CLUTEN |LXCR_HMEN ,0 ); +/* Reset the layer transparency to hide any related background color */ +regmap_write_bits (ldev->regmap,LTDC_L1CACR + lofs,LXCACR_CONSTA ,0x00 ); +/* Commit shadow registers = update plane at next vblank */ if (ldev->caps.plane_reg_shadow) regmap_write_bits(ldev->regmap, LTDC_L1RCR + lofs,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 107/139 drm/amd/display: Check stream before comparing them
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit 35ff747c86767937ee1e0ca987545b7eed7a0810 ]
[WHAT & HOW]amdgpu_dm can pass a null stream to dc_is_stream_unchanged. It is necessary to check for null before dereferencing them.
This fixes 1 FORWARD_NULL issue reported by Coverity.
--- drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/display/dc/core/dc_resource.c +2 -0
@@ -2154,6 +2154,8 @@ static bool are_stream_backends_same(bool dc_is_stream_unchanged (struct dc_stream_state *old_stream,struct dc_stream_state *stream) { +if (!old_stream || !stream) +return false;if (!are_stream_backends_same (old_stream, stream))return false;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 108/139 drm/amd/display: Check link_res->hpo_dp_link_enc before using it
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit 0beca868cde8742240cd0038141c30482d2b7eb8 ]
[WHAT & HOW]
Functions dp_enable_link_phy and dp_disable_link_phy can pass link_res without initializing hpo_dp_link_enc and it is necessary to check for null before dereferencing.
This fixes 2 FORWARD_NULL issues reported by Coverity.
--- .../gpu/drm/amd/display/dc/link/hwss/link_hwss_hpo_dp.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/display/dc/link/hwss/link_hwss_hpo_dp.c +7 -0
@@ -28,6 +28,8 @@#include "dccg.h" #include "clk_mgr.h" +#define DC_LOGGER link->ctx->logger +void set_hpo_dp_throttled_vcp_size (struct pipe_ctx *pipe_ctx,struct fixed31_32 throttled_vcp_size) {
@@ -124,6 +126,11 @@ void disable_hpo_dp_link_output(struct dc_link *link,const struct link_resource *link_res, enum signal_type signal) { + if (!link_res->hpo_dp_link_enc) { + DC_LOG_ERROR("%s: invalid hpo_dp_link_enc\n", __func__); +return ; + } + link_res->hpo_dp_link_enc->funcs->link_disable (link_res->hpo_dp_link_enc); link_res->hpo_dp_link_enc->funcs->disable_link_phy ( link_res->hpo_dp_link_enc, signal);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 109/139 drm/amd/display: Fix index out of bounds in DCN30 degamma hardware format translation
In reply to Sasha LevinFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit bc50b614d59990747dd5aeced9ec22f9258991ff ]
This commit addresses a potential index out of bounds issue in the cm3_helper_translate_curve_to_degamma_hw_format function in the DCN30 color management module. The issue could occur when the index 'i' exceeds the number of transfer function points (TRANSFER_FUNC_POINTS).
The fix adds a check to ensure 'i' is within bounds before accessing the transfer function points. If 'i' is out of bounds, the function returns false to indicate an error.
Reported by smatch:drivers/gpu/drm/amd/amdgpu/../display/dc/dcn30/dcn30_cm_common.c:338 cm3_helper_translate_curve_to_degamma_hw_format() error: buffer overflow 'output_tf->tf_pts.red' 1025 <= s32max drivers/gpu/drm/amd/amdgpu/../display/dc/dcn30/dcn30_cm_common.c:339 cm3_helper_translate_curve_to_degamma_hw_format() error: buffer overflow 'output_tf->tf_pts.green' 1025 <= s32max drivers/gpu/drm/amd/amdgpu/../display/dc/dcn30/dcn30_cm_common.c:340 cm3_helper_translate_curve_to_degamma_hw_format() error: buffer overflow 'output_tf->tf_pts.blue' 1025 <= s32max
--- drivers/gpu/drm/amd/display/dc/dcn30/dcn30_cm_common.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_cm_common.c +2 -0
@@ -355,6 +355,8 @@ bool cm3_helper_translate_curve_to_degamma_hw_format( i += increment) {if (j == hw_points -1 )break ; +if (i >=TRANSFER_FUNC_POINTS ) +return false; rgb_resulted[j].red = output_tf->tf_pts.red[i]; rgb_resulted[j].green = output_tf->tf_pts.green[i]; rgb_resulted[j].blue = output_tf->tf_pts.blue[i];
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 110/139 drm/amd/display: Fix index out of bounds in degamma hardware format translation
In reply to Sasha LevinFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit b7e99058eb2e86aabd7a10761e76cae33d22b49f ]
Fixes index out of bounds issue in cm_helper_translate_curve_to_degamma_hw_format function. The issue could occur when the index 'i' exceeds the number of transfer function points (TRANSFER_FUNC_POINTS).
The fix adds a check to ensure 'i' is within bounds before accessing the transfer function points. If 'i' is out of bounds the function returns false to indicate an error.
Reported by smatch:drivers/gpu/drm/amd/amdgpu/../display/dc/dcn10/dcn10_cm_common.c:594 cm_helper_translate_curve_to_degamma_hw_format() error: buffer overflow 'output_tf->tf_pts.red' 1025 <= s32max drivers/gpu/drm/amd/amdgpu/../display/dc/dcn10/dcn10_cm_common.c:595 cm_helper_translate_curve_to_degamma_hw_format() error: buffer overflow 'output_tf->tf_pts.green' 1025 <= s32max drivers/gpu/drm/amd/amdgpu/../display/dc/dcn10/dcn10_cm_common.c:596 cm_helper_translate_curve_to_degamma_hw_format() error: buffer overflow 'output_tf->tf_pts.blue' 1025 <= s32max
--- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_cm_common.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_cm_common.c +2 -0
@@ -571,6 +571,8 @@ bool cm_helper_translate_curve_to_degamma_hw_format( i += increment) {if (j == hw_points -1 )break ; +if (i >=TRANSFER_FUNC_POINTS ) +return false; rgb_resulted[j].red = output_tf->tf_pts.red[i]; rgb_resulted[j].green = output_tf->tf_pts.green[i]; rgb_resulted[j].blue = output_tf->tf_pts.blue[i];
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 111/139 drm/amd/display: Fix index out of bounds in DCN30 color transformation
In reply to Sasha LevinFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit d81873f9e715b72d4f8d391c8eb243946f784dfc ]
This commit addresses a potential index out of bounds issue in the cm3_helper_translate_curve_to_hw_format function in the DCN30 color management module. The issue could occur when the index 'i' exceeds the number of transfer function points (TRANSFER_FUNC_POINTS).
The fix adds a check to ensure 'i' is within bounds before accessing the transfer function points. If 'i' is out of bounds, the function returns false to indicate an error.
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn30/dcn30_cm_common.c:180 cm3_helper_translate_curve_to_hw_format() error: buffer overflow 'output_tf->tf_pts.red' 1025 <= s32max drivers/gpu/drm/amd/amdgpu/../display/dc/dcn30/dcn30_cm_common.c:181 cm3_helper_translate_curve_to_hw_format() error: buffer overflow 'output_tf->tf_pts.green' 1025 <= s32max drivers/gpu/drm/amd/amdgpu/../display/dc/dcn30/dcn30_cm_common.c:182 cm3_helper_translate_curve_to_hw_format() error: buffer overflow 'output_tf->tf_pts.blue' 1025 <= s32max
--- drivers/gpu/drm/amd/display/dc/dcn30/dcn30_cm_common.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_cm_common.c +2 -0
@@ -178,6 +178,8 @@ bool cm3_helper_translate_curve_to_hw_format( i += increment) {if (j == hw_points -1 )break ; +if (i >=TRANSFER_FUNC_POINTS ) +return false; rgb_resulted[j].red = output_tf->tf_pts.red[i]; rgb_resulted[j].green = output_tf->tf_pts.green[i]; rgb_resulted[j].blue = output_tf->tf_pts.blue[i];
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 112/139 drm/amd/display: Avoid overflow assignment in link_dp_cts
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit a15268787b79fd183dd526cc16bec9af4f4e49a1 ]
sampling_rate is an uint8_t but is assigned an unsigned int, and thus it can overflow. As a result, sampling_rate is changed to uint32_t.
Similarly, LINK_QUAL_PATTERN_SET has a size of 2 bits, and it should only be assigned to a value less or equal than 4.
This fixes 2 INTEGER_OVERFLOW issues reported by Coverity.
--- drivers/gpu/drm/amd/display/dc/dc_dp_types.h | 2 +- drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c | 3 ++- drivers/gpu/drm/amd/display/include/dpcd_defs.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/dc_dp_types.h +1 -1
@@ -721,7 +721,7 @@ struct dp_audio_test_data_flags {struct dp_audio_test_data {struct dp_audio_test_data_flags flags; -uint8_t sampling_rate; +uint32_t sampling_rate;uint8_t channel_count;uint8_t pattern_type;uint8_t pattern_period[8 ];
drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c +2 -1
@@ -849,7 +849,8 @@ bool dp_set_test_pattern(core_link_read_dpcd (link,DP_TRAINING_PATTERN_SET , &training_pattern.raw,sizeof (training_pattern)); - training_pattern.v1_3.LINK_QUAL_PATTERN_SET = pattern; +if (pattern <=PHY_TEST_PATTERN_END_DP11 ) + training_pattern.v1_3.LINK_QUAL_PATTERN_SET = pattern;core_link_write_dpcd (link,DP_TRAINING_PATTERN_SET , &training_pattern.raw,sizeof (training_pattern));
drivers/gpu/drm/amd/display/include/dpcd_defs.h +1 -0
@@ -76,6 +76,7 @@ enum dpcd_phy_test_patterns {PHY_TEST_PATTERN_D10_2 ,PHY_TEST_PATTERN_SYMBOL_ERROR ,PHY_TEST_PATTERN_PRBS7 , +PHY_TEST_PATTERN_END_DP11 =PHY_TEST_PATTERN_PRBS7 ,PHY_TEST_PATTERN_80BIT_CUSTOM ,/* For DP1.2 only */ PHY_TEST_PATTERN_CP2520_1 , PHY_TEST_PATTERN_CP2520_2,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 113/139 drm/amd/display: Initialize get_bytes_per_element's default to 1
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit 4067f4fa0423a89fb19a30b57231b384d77d2610 ]
Variables, used as denominators and maybe not assigned to other values, should not be 0. bytes_per_element_y & bytes_per_element_c are initialized by get_bytes_per_element() which should never return 0.
This fixes 10 DIVIDE_BY_ZERO issues reported by Coverity.
--- .../gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20v2.c | 2 +- .../gpu/drm/amd/display/dc/dml/dcn21/display_rq_dlg_calc_21.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20v2.c +1 -1
@@ -78,7 +78,7 @@ static void calculate_ttu_cursor(struct display_mode_lib *mode_lib,static unsigned int get_bytes_per_element (enum source_format_class source_format,bool is_chroma) { -unsigned int ret_val =0 ; +unsigned int ret_val =1 ;if (source_format == dm_444_16) {if (!is_chroma)
drivers/gpu/drm/amd/display/dc/dml/dcn21/display_rq_dlg_calc_21.c +1 -1
@@ -53,7 +53,7 @@ static void calculate_ttu_cursor(static unsigned int get_bytes_per_element (enum source_format_class source_format,bool is_chroma) { -unsigned int ret_val =0 ; +unsigned int ret_val =1 ;if (source_format == dm_444_16) {if (!is_chroma)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 114/139 drm/printer: Allow NULL data in devcoredump printer
In reply to Sasha LevinFrom: Matthew Brost <[email protected]>
[ Upstream commit 53369581dc0c68a5700ed51e1660f44c4b2bb524 ]
We want to determine the size of the devcoredump before writing it out. To that end, we will run the devcoredump printer with NULL data to get the size, alloc data based on the generated offset, then run the devcorecump again with a valid data pointer to print. This necessitates not writing data to the data pointer on the initial pass, when it is NULL.
v5:
- Better commit message (Jonathan)
- Add kerenl doc with examples (Jani)
--- drivers/gpu/drm/drm_print.c | 13 +++++---- include/drm/drm_print.h | 54 ++++++++++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 6 deletions(-)
drivers/gpu/drm/drm_print.c +8 -5
@@ -100,8 +100,9 @@ void __drm_puts_coredump(struct drm_printer *p, const char *str) copy = iterator->remain;/* Copy out the bit of the string that we need */ -memcpy (iterator->data, - str + (iterator->start - iterator->offset), copy); +if (iterator->data) +memcpy (iterator->data, + str + (iterator->start - iterator->offset), copy); iterator->offset = iterator->start + copy; iterator->remain -= copy;
@@ -110,7 +111,8 @@ void __drm_puts_coredump(struct drm_printer *p, const char *str) len =min_t (ssize_t,strlen (str), iterator->remain); -memcpy (iterator->data + pos, str, len); +if (iterator->data) +memcpy (iterator->data + pos, str, len); iterator->offset += len; iterator->remain -= len;
@@ -140,8 +142,9 @@ void __drm_printfn_coredump(struct drm_printer *p, struct va_format *vaf)if ((iterator->offset >= iterator->start) && (len < iterator->remain)) {ssize_t pos = iterator->offset - iterator->start; -snprintf (((char *) iterator->data) + pos, - iterator->remain,"%pV" , vaf); +if (iterator->data) +snprintf (((char *) iterator->data) + pos, + iterator->remain,"%pV" , vaf); iterator->offset += len; iterator->remain -= len;
include/drm/drm_print.h +53 -1
66 lines not on this page · raw message
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 115/139 perf,x86: avoid missing caller address in stack traces captured in uprobe
In reply to Sasha LevinFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit cfa7f3d2c526c224a6271cc78a4a27a0de06f4f0 ]
When tracing user functions with uprobe functionality, it's common to install the probe (e.g., a BPF program) at the first instruction of the function. This is often going to be push %rbp instruction in function preamble, which means that within that function frame pointer hasn't been established yet. This leads to consistently missing an actual caller of the traced function, because perf_callchain_user() only records current IP (capturing traced function) and then following frame pointer chain (which would be caller's frame, containing the address of caller's caller).
So when we have target_1 -> target_2 -> target_3 call chain and we are tracing an entry to target_3, captured stack trace will report target_1 -> target_3 call chain, which is wrong and confusing.
This patch proposes a x86-64-specific heuristic to detect push %rbp (push %ebp on 32-bit architecture) instruction being traced. Given entire kernel implementation of user space stack trace capturing works under assumption that user space code was compiled with frame pointer register (%rbp/%ebp) preservation, it seems pretty reasonable to use this instruction as a strong indicator that this is the entry to the function. In that case, return address is still pointed to by %rsp/%esp, so we fetch it and add to stack trace before proceeding to unwind the rest using frame pointer-based logic.
We also check for endbr64 (for 64-bit modes) as another common pattern for function entry, as suggested by Josh Poimboeuf. Even if we get this wrong sometimes for uprobes attached not at the function entry, it's OK because stack trace will still be overall meaningful, just with one extra bogus entry. If we don't detect this, we end up with guaranteed to be missing caller function entry in the stack trace, which is worse overall.
--- arch/x86/events/core.c | 63 +++++++++++++++++++++++++++++++++++++++++ include/linux/uprobes.h | 2 ++ kernel/events/uprobes.c | 2 ++ 3 files changed, 67 insertions(+)
arch/x86/events/core.c +63 -0
@@ -41,6 +41,8 @@#include <asm/desc.h> #include <asm/ldt.h> #include <asm/unwind.h> +#include <asm/uprobes.h> +#include <asm/ibt.h> #include "perf_event.h"
@@ -2816,6 +2818,46 @@ static unsigned long get_segment_base(unsigned int segment)return get_desc_base (desc); } +#ifdef CONFIG_UPROBES +/* +* Heuristic-based check if uprobe is installed at the function entry. +* +* Under assumption of user code being compiled with frame pointers, +* `push %rbp/%ebp` is a good indicator that we indeed are. +* +* Similarly, `endbr64` (assuming 64-bit mode) is also a common pattern. +* If we get this wrong, captured stack trace might have one extra bogus +* entry, but the rest of stack trace will still be meaningful. +*/ +static bool is_uprobe_at_func_entry (struct pt_regs *regs) +{ +struct arch_uprobe *auprobe; + +if (!current->utask) +return false; + + auprobe = current->utask->auprobe; +if (!auprobe) +return false; + +/* push %rbp/%ebp */ +if (auprobe->insn[0 ] ==0x55 ) +return true; + +/* endbr64 (64-bit only) */ +if (user_64bit_mode (regs) &&is_endbr (*(u32 *)auprobe->insn)) +return true; + +return false; +} + +#else +static bool is_uprobe_at_func_entry (struct pt_regs *regs) +{ +return false; +} +#endif /* CONFIG_UPROBES */ +#ifdef CONFIG_IA32_EMULATION #include <linux/compat.h>
@@ -2827,6 +2869,7 @@ perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry_ctx *entunsigned long ss_base, cs_base;struct stack_frame_ia32 frame;const struct stack_frame_ia32 __user *fp; +u32 ret_addr;if (user_64bit_mode (regs))return 0 ;
@@ -2836,6 +2879,12 @@ perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry_ctx *ent fp =compat_ptr (ss_base + regs->bp);pagefault_disable (); + +/* see perf_callchain_user() below for why we do this */ +if (is_uprobe_at_func_entry (regs) && + !get_user (ret_addr, (const u32 __user *)regs->sp)) +perf_callchain_store (entry, ret_addr); +while (entry->nr < entry->max_stack) {if (!valid_user_frame (fp,sizeof (frame)))break ;
@@ -2864,6 +2913,7 @@ perf_callchain_user(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs {struct stack_frame frame;const struct stack_frame __user *fp; +unsigned long ret_addr;if (perf_guest_state ()) {/* TODO: We don't support guest os callchain now */
@@ -2887,6 +2937,19 @@ perf_callchain_user(struct perf_callchain_entry_ctx *entry, struct pt_regs *regsreturn ;pagefault_disable (); + +/* +* If we are called from uprobe handler, and we are indeed at the very +* entry to user function (which is normally a `push %rbp` instruction, +* under assumption of application being compiled with frame pointers), +* we should read return address from *regs->sp before proceeding +* to follow frame pointers, otherwise we'll skip immediate caller +* as %rbp is not yet setup. +*/ +if (is_uprobe_at_func_entry (regs) && + !get_user (ret_addr, (const unsigned long __user *)regs->sp)) +perf_callchain_store (entry, ret_addr); +while (entry->nr < entry->max_stack) {if (!valid_user_frame (fp,sizeof (frame)))break ;
include/linux/uprobes.h +2 -0
@@ -76,6 +76,8 @@ struct uprobe_task {struct uprobe *active_uprobe;unsigned long xol_vaddr; +struct arch_uprobe *auprobe; +struct return_instance *return_instances;unsigned int depth; };
kernel/events/uprobes.c +2 -0
@@ -2071,6 +2071,7 @@ static void handler_chain(struct uprobe *uprobe, struct pt_regs *regs)bool need_prep = false;/* prepare return uprobe, when needed */ down_read (&uprobe->register_rwsem); + current->utask->auprobe = &uprobe->arch;for (uc = uprobe->consumers; uc; uc = uc->next) {int rc =0 ;
@@ -2085,6 +2086,7 @@ static void handler_chain(struct uprobe *uprobe, struct pt_regs *regs) remove &= rc; } + current->utask->auprobe =NULL ;if (need_prep && !remove)prepare_uretprobe (uprobe, regs);/* put bp at return */
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 116/139 scsi: aacraid: Rearrange order of struct aac_srb_unit
In reply to Sasha LevinFrom: Kees Cook <[email protected]>
[ Upstream commit 6e5860b0ad4934baee8c7a202c02033b2631bb44 ]
struct aac_srb_unit contains struct aac_srb, which contains struct sgmap, which ends in a (currently) "fake" (1-element) flexible array. Converting this to a flexible array is needed so that runtime bounds checking won't think the array is fixed size (i.e. under CONFIG_FORTIFY_SOURCE=y and/or CONFIG_UBSAN_BOUNDS=y), as other parts of aacraid use struct sgmap as a flexible array.
It is not legal to have a flexible array in the middle of a structure, so it either needs to be split up or rearranged so that it is at the end of the structure. Luckily, struct aac_srb_unit, which is exclusively consumed/updated by aac_send_safw_bmic_cmd(), does not depend on member ordering.
The values set in the on-stack struct aac_srb_unit instance "srbu" by the only two callers, aac_issue_safw_bmic_identify() and aac_get_safw_ciss_luns(), do not contain anything in srbu.srb.sgmap.sg, and they both implicitly initialize srbu.srb.sgmap.count to 0 during memset(). For example:
memset(&srbu, 0, sizeof(struct aac_srb_unit));
srbcmd = &srbu.srb;
srbcmd->flags = cpu_to_le32(SRB_DataIn);
srbcmd->cdb[0] = CISS_REPORT_PHYSICAL_LUNS;
srbcmd->cdb[1] = 2; /* extended reporting */
srbcmd->cdb[8] = (u8)(datasize >> 8);
srbcmd->cdb[9] = (u8)(datasize);
rcode = aac_send_safw_bmic_cmd(dev, &srbu, phys_luns, datasize);During aac_send_safw_bmic_cmd(), a separate srb is mapped into DMA, and has srbu.srb copied into it:
srb = fib_data(fibptr);
memcpy(srb, &srbu->srb, sizeof(struct aac_srb));Only then is srb.sgmap.count written and srb->sg populated:
srb->count = cpu_to_le32(xfer_len);
sg64 = (struct sgmap64 *)&srb->sg;
sg64->count = cpu_to_le32(1);
sg64->sg[0].addr[1] = cpu_to_le32(upper_32_bits(addr));
sg64->sg[0].addr[0] = cpu_to_le32(lower_32_bits(addr));
sg64->sg[0].count = cpu_to_le32(xfer_len);But this is happening in the DMA memory, not in srbu.srb. An attempt to copy the changes back to srbu does happen:
/*
* Copy the updated data for other dumping or other usage if
* needed
*/
memcpy(&srbu->srb, srb, sizeof(struct aac_srb));But this was never correct: the sg64 (3 u32s) overlap of srb.sg (2 u32s) always meant that srbu.srb would have held truncated information and any attempt to walk srbu.srb.sg.sg based on the value of srbu.srb.sg.count would result in attempting to parse past the end of srbu.srb.sg.sg[0] into srbu.srb_reply.
After getting a reply from hardware, the reply is copied into srbu.srb_reply:
srb_reply = (struct aac_srb_reply *)fib_data(fibptr);
memcpy(&srbu->srb_reply, srb_reply, sizeof(struct aac_srb_reply));This has always been fixed-size, so there's no issue here. It is worth noting that the two callers _never check_ srbu contents -- neither srbu.srb nor srbu.srb_reply is examined. (They depend on the mapped xfer_buf instead.)
Therefore, the ordering of members in struct aac_srb_unit does not matter, and the flexible array member can moved to the end.
(Additionally, the two memcpy()s that update srbu could be entirely removed as they are never consumed, but I left that as-is.)
--- drivers/scsi/aacraid/aacraid.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/aacraid/aacraid.h +1 -1
@@ -2029,8 +2029,8 @@ struct aac_srb_reply };struct aac_srb_unit { -struct aac_srb srb;struct aac_srb_reply srb_reply; +struct aac_srb srb; };/*
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 117/139 scsi: lpfc: Update PRLO handling in direct attached topology
In reply to Sasha LevinFrom: Justin Tee <[email protected]>
[ Upstream commit 1f0f7679ad8942f810b0f19ee9cf098c3502d66a ]
A kref imbalance occurs when handling an unsolicited PRLO in direct attached topology.
Rework PRLO rcv handling when in MAPPED state. Save the state that we were handling a PRLO by setting nlp_last_elscmd to ELS_CMD_PRLO. Then in the lpfc_cmpl_els_logo_acc() completion routine, manually restart discovery. By issuing the PLOGI, which nlp_gets, before nlp_put at the end of the lpfc_cmpl_els_logo_acc() routine, we are saving us from a final nlp_put. And, we are still allowing the unreg_rpi to happen.
--- drivers/scsi/lpfc/lpfc_els.c | 27 ++++++++++++++++----------- drivers/scsi/lpfc/lpfc_nportdisc.c | 22 ++++++++++++++++++++-- 2 files changed, 36 insertions(+), 13 deletions(-)
drivers/scsi/lpfc/lpfc_els.c +16 -11
@@ -5228,9 +5228,10 @@ lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,/* ACC to LOGO completes to NPort <nlp_DID> */ lpfc_printf_vlog (vport,KERN_INFO ,LOG_ELS ,"0109 ACC to LOGO completes to NPort x%x refcnt %d " -"Data: x%x x%x x%x\n" , - ndlp->nlp_DID,kref_read (&ndlp->kref), ndlp->nlp_flag, - ndlp->nlp_state, ndlp->nlp_rpi); +"last els x%x Data: x%x x%x x%x\n" , + ndlp->nlp_DID,kref_read (&ndlp->kref), + ndlp->nlp_last_elscmd, ndlp->nlp_flag, ndlp->nlp_state, + ndlp->nlp_rpi);/* This clause allows the LOGO ACC to complete and free resources * for the Fabric Domain Controller. It does deliberately skip
@@ -5242,18 +5243,22 @@ lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, goto out;if (ndlp->nlp_state ==NLP_STE_NPR_NODE ) { -/* If PLOGI is being retried, PLOGI completion will cleanup the -* node. The NLP_NPR_2B_DISC flag needs to be retained to make -* progress on nodes discovered from last RSCN. -*/ -if ((ndlp->nlp_flag &NLP_DELAY_TMO ) && - (ndlp->nlp_last_elscmd ==ELS_CMD_PLOGI )) - goto out; -if (ndlp->nlp_flag &NLP_RPI_REGISTERED )lpfc_unreg_rpi (vport, ndlp); +/* If came from PRLO, then PRLO_ACC is done. +* Start rediscovery now. +*/ +if (ndlp->nlp_last_elscmd ==ELS_CMD_PRLO ) { +spin_lock_irq (&ndlp->lock); + ndlp->nlp_flag |=NLP_NPR_2B_DISC ; +spin_unlock_irq (&ndlp->lock); + ndlp->nlp_prev_state = ndlp->nlp_state; +lpfc_nlp_set_state (vport, ndlp,NLP_STE_PLOGI_ISSUE ); +lpfc_issue_els_plogi (vport, ndlp->nlp_DID,0 ); + } } + out:/* * The driver received a LOGO from the rport and has ACK'd it.
drivers/scsi/lpfc/lpfc_nportdisc.c +20 -2
@@ -2635,8 +2635,26 @@ lpfc_rcv_prlo_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,/* flush the target */ lpfc_sli_abort_iocb (vport, ndlp->nlp_sid,0 ,LPFC_CTX_TGT ); -/* Treat like rcv logo */ -lpfc_rcv_logo (vport, ndlp, cmdiocb,ELS_CMD_PRLO ); +/* Send PRLO_ACC */ +spin_lock_irq (&ndlp->lock); + ndlp->nlp_flag |=NLP_LOGO_ACC ; +spin_unlock_irq (&ndlp->lock); +lpfc_els_rsp_acc (vport,ELS_CMD_PRLO , cmdiocb, ndlp,NULL ); + +/* Save ELS_CMD_PRLO as the last elscmd and then set to NPR. +* lpfc_cmpl_els_logo_acc is expected to restart discovery. +*/ + ndlp->nlp_last_elscmd =ELS_CMD_PRLO ; + ndlp->nlp_prev_state = ndlp->nlp_state; + +lpfc_printf_vlog (vport,KERN_INFO ,LOG_NODE |LOG_ELS |LOG_DISCOVERY , +"3422 DID x%06x nflag x%x lastels x%x ref cnt %u\n" , + ndlp->nlp_DID, ndlp->nlp_flag, + ndlp->nlp_last_elscmd, +kref_read (&ndlp->kref)); + +lpfc_nlp_set_state (vport, ndlp,NLP_STE_NPR_NODE ); +return ndlp->nlp_state; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 118/139 drm/amdgpu: fix unchecked return value warning for amdgpu_gfx
In reply to Sasha LevinFrom: Tim Huang <[email protected]>
[ Upstream commit c0277b9d7c2ee9ee5dbc948548984f0fbb861301 ]
This resolves the unchecded return value warning reported by Coverity.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +14 -4
@@ -793,8 +793,11 @@ int amdgpu_gfx_ras_late_init(struct amdgpu_device *adev, struct ras_common_if *rint r;if (amdgpu_ras_is_supported (adev, ras_block->block)) { -if (!amdgpu_persistent_edc_harvesting_supported (adev)) -amdgpu_ras_reset_error_status (adev,AMDGPU_RAS_BLOCK__GFX ); +if (!amdgpu_persistent_edc_harvesting_supported (adev)) { + r =amdgpu_ras_reset_error_status (adev,AMDGPU_RAS_BLOCK__GFX ); +if (r) +return r; + } r =amdgpu_ras_block_late_init (adev, ras_block);if (r)
@@ -938,7 +941,10 @@ uint32_t amdgpu_kiq_rreg(struct amdgpu_device *adev, uint32_t reg)pr_err ("critical bug! too many kiq readers\n" ); goto failed_unlock; } -amdgpu_ring_alloc (ring,32 ); + r =amdgpu_ring_alloc (ring,32 ); +if (r) + goto failed_unlock; +amdgpu_ring_emit_rreg (ring, reg, reg_val_offs); r =amdgpu_fence_emit_polling (ring, &seq,MAX_KIQ_REG_WAIT );if (r)
@@ -1004,7 +1010,10 @@ void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v) }spin_lock_irqsave (&kiq->ring_lock, flags); -amdgpu_ring_alloc (ring,32 ); + r =amdgpu_ring_alloc (ring,32 ); +if (r) + goto failed_unlock; +amdgpu_ring_emit_wreg (ring, reg, v); r =amdgpu_fence_emit_polling (ring, &seq,MAX_KIQ_REG_WAIT );if (r)
@@ -1040,6 +1049,7 @@ void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v) failed_undo:amdgpu_ring_undo (ring); +failed_unlock:spin_unlock_irqrestore (&kiq->ring_lock, flags); failed_kiq_write:dev_err (adev->dev,"failed to write reg:%x\n" , reg);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 119/139 perf: Fix event_function_call() locking
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 558abc7e3f895049faa46b08656be4c60dc6e9fd ]
All the event_function/@func call context already uses perf_ctx_lock() except for the !ctx->is_active case. Make it all consistent.
--- kernel/events/core.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
kernel/events/core.c +5 -4
@@ -263,6 +263,7 @@ static int event_function(void *info)static void event_function_call (struct perf_event *event,event_f func,void *data) {struct perf_event_context *ctx = event->ctx; +struct perf_cpu_context *cpuctx =this_cpu_ptr (&perf_cpu_context);struct task_struct *task =READ_ONCE (ctx->task);/* verified in event_function */ struct event_function_struct efs = { .event = event,
@@ -291,22 +292,22 @@ static void event_function_call(struct perf_event *event, event_f func, void *daif (!task_function_call (task, event_function, &efs))return ; -raw_spin_lock_irq (&ctx->lock); +perf_ctx_lock (cpuctx, ctx);/* * Reload the task pointer, it might have been changed by * a concurrent perf_event_context_sched_out(). */ task = ctx->task;if (task ==TASK_TOMBSTONE ) { -raw_spin_unlock_irq (&ctx->lock); +perf_ctx_unlock (cpuctx, ctx);return ; }if (ctx->is_active) { -raw_spin_unlock_irq (&ctx->lock); +perf_ctx_unlock (cpuctx, ctx); goto again; }func (event,NULL , ctx, data); -raw_spin_unlock_irq (&ctx->lock); +perf_ctx_unlock (cpuctx, ctx); }/*
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 120/139 scsi: NCR5380: Initialize buffer for MSG IN and STATUS transfers
In reply to Sasha LevinFrom: Finn Thain <[email protected]>
[ Upstream commit 1c71065df2df693d208dd32758171c1dece66341 ]
Following an incomplete transfer in MSG IN phase, the driver would not notice the problem and would make use of invalid data. Initialize 'tmp' appropriately and bail out if no message was received. For STATUS phase, preserve the existing status code unless a new value was transferred.
--- drivers/scsi/NCR5380.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/scsi/NCR5380.c +4 -0
@@ -1807,8 +1807,11 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance)return ;case PHASE_MSGIN : len =1 ; + tmp =0xff ; data = &tmp;NCR5380_transfer_pio (instance, &phase, &len, &data,0 ); +if (tmp ==0xff ) +break ; ncmd->message = tmp;switch (tmp) {
@@ -1996,6 +1999,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance)break ;case PHASE_STATIN : len =1 ; + tmp = ncmd->status; data = &tmp;NCR5380_transfer_pio (instance, &phase, &len, &data,0 ); ncmd->status = tmp;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 121/139 drm/radeon/r100: Handle unknown family in r100_cp_init_microcode()
In reply to Sasha LevinFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit c6dbab46324b1742b50dc2fb5c1fee2c28129439 ]
With -Werror:
In function ‘r100_cp_init_microcode’,
inlined from ‘r100_cp_init’ at drivers/gpu/drm/radeon/r100.c:1136:7:
include/linux/printk.h:465:44: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
465 | #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
| ^
include/linux/printk.h:437:17: note: in definition of macro ‘printk_index_wrap’
437 | _p_func(_fmt, ##__VA_ARGS__); \
| ^~~~~~~
include/linux/printk.h:508:9: note: in expansion of macro ‘printk’
508 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~
drivers/gpu/drm/radeon/r100.c:1062:17: note: in expansion of macro ‘pr_err’
1062 | pr_err("radeon_cp: Failed to load firmware \"%s\"\n", fw_name);
| ^~~~~~Fix this by converting the if/else if/... construct into a proper switch() statement with a default to handle the error case.
As a bonus, the generated code is ca. 100 bytes smaller (with gcc 11.4.0 targeting arm32).
--- drivers/gpu/drm/radeon/r100.c | 70 ++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 25 deletions(-)
drivers/gpu/drm/radeon/r100.c +45 -25
@@ -1015,45 +1015,65 @@ static int r100_cp_init_microcode(struct radeon_device *rdev)DRM_DEBUG_KMS ("\n" ); -if ((rdev->family ==CHIP_R100 ) || (rdev->family ==CHIP_RV100 ) || - (rdev->family ==CHIP_RV200 ) || (rdev->family ==CHIP_RS100 ) || - (rdev->family ==CHIP_RS200 )) { +switch (rdev->family) { +case CHIP_R100 : +case CHIP_RV100 : +case CHIP_RV200 : +case CHIP_RS100 : +case CHIP_RS200 :DRM_INFO ("Loading R100 Microcode\n" ); fw_name =FIRMWARE_R100 ; - }else if ((rdev->family ==CHIP_R200 ) || - (rdev->family ==CHIP_RV250 ) || - (rdev->family ==CHIP_RV280 ) || - (rdev->family ==CHIP_RS300 )) { +break ; + +case CHIP_R200 : +case CHIP_RV250 : +case CHIP_RV280 : +case CHIP_RS300 :DRM_INFO ("Loading R200 Microcode\n" ); fw_name =FIRMWARE_R200 ; - }else if ((rdev->family ==CHIP_R300 ) || - (rdev->family ==CHIP_R350 ) || - (rdev->family ==CHIP_RV350 ) || - (rdev->family ==CHIP_RV380 ) || - (rdev->family ==CHIP_RS400 ) || - (rdev->family ==CHIP_RS480 )) { +break ; + +case CHIP_R300 : +case CHIP_R350 : +case CHIP_RV350 : +case CHIP_RV380 : +case CHIP_RS400 : +case CHIP_RS480 :DRM_INFO ("Loading R300 Microcode\n" ); fw_name =FIRMWARE_R300 ; - }else if ((rdev->family ==CHIP_R420 ) || - (rdev->family ==CHIP_R423 ) || - (rdev->family ==CHIP_RV410 )) { +break ; + +case CHIP_R420 : +case CHIP_R423 : +case CHIP_RV410 :DRM_INFO ("Loading R400 Microcode\n" ); fw_name =FIRMWARE_R420 ; - }else if ((rdev->family ==CHIP_RS690 ) || - (rdev->family ==CHIP_RS740 )) { +break ; + +case CHIP_RS690 : +case CHIP_RS740 :DRM_INFO ("Loading RS690/RS740 Microcode\n" ); fw_name =FIRMWARE_RS690 ; - }else if (rdev->family ==CHIP_RS600 ) { +break ; + +case CHIP_RS600 :DRM_INFO ("Loading RS600 Microcode\n" ); fw_name =FIRMWARE_RS600 ; - }else if ((rdev->family ==CHIP_RV515 ) || - (rdev->family ==CHIP_R520 ) || - (rdev->family ==CHIP_RV530 ) || - (rdev->family ==CHIP_R580 ) || - (rdev->family ==CHIP_RV560 ) || - (rdev->family ==CHIP_RV570 )) { +break ; + +case CHIP_RV515 : +case CHIP_R520 : +case CHIP_RV530 : +case CHIP_R580 : +case CHIP_RV560 : +case CHIP_RV570 :DRM_INFO ("Loading R500 Microcode\n" ); fw_name =FIRMWARE_R520 ; +break ; + +default : +DRM_ERROR ("Unsupported Radeon family %u\n" , rdev->family); +return -EINVAL ; } err =request_firmware (&rdev->me_fw, fw_name, rdev->dev);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 122/139 drm/amdgpu: Block MMR_READ IOCTL in reset
In reply to Sasha LevinFrom: Victor Skvortsov <[email protected]>
[ Upstream commit 9e823f307074c0f82b5f6044943b0086e3079bed ]
Register access from userspace should be blocked until reset is complete.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 43 ++++++++++++++++++------- 1 file changed, 31 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +31 -12
@@ -43,6 +43,7 @@#include "amdgpu_gem.h" #include "amdgpu_display.h" #include "amdgpu_ras.h" +#include "amdgpu_reset.h" #include "amd_pcie.h" void amdgpu_unregister_gpu_instance (struct amdgpu_device *adev)
@@ -722,6 +723,7 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) ? -EFAULT :0 ; }case AMDGPU_INFO_READ_MMR_REG : { +int ret =0 ;unsigned int n, alloc_size;uint32_t *regs; unsigned int se_num = (info->read_mmr_reg.instance >>
@@ -731,24 +733,37 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) AMDGPU_INFO_MMR_SH_INDEX_SHIFT) &AMDGPU_INFO_MMR_SH_INDEX_MASK ; +if (!down_read_trylock (&adev->reset_domain->sem)) +return -ENOENT ; +/* set full masks if the userspace set all bits * in the bitfields */ -if (se_num ==AMDGPU_INFO_MMR_SE_INDEX_MASK ) +if (se_num ==AMDGPU_INFO_MMR_SE_INDEX_MASK ) { se_num =0xffffffff ; -else if (se_num >=AMDGPU_GFX_MAX_SE ) -return -EINVAL ; -if (sh_num ==AMDGPU_INFO_MMR_SH_INDEX_MASK ) + }else if (se_num >=AMDGPU_GFX_MAX_SE ) { + ret = -EINVAL ; + goto out; + } + +if (sh_num ==AMDGPU_INFO_MMR_SH_INDEX_MASK ) { sh_num =0xffffffff ; -else if (sh_num >=AMDGPU_GFX_MAX_SH_PER_SE ) -return -EINVAL ; + }else if (sh_num >=AMDGPU_GFX_MAX_SH_PER_SE ) { + ret = -EINVAL ; + goto out; + } -if (info->read_mmr_reg.count >128 ) -return -EINVAL ; +if (info->read_mmr_reg.count >128 ) { + ret = -EINVAL ; + goto out; + } regs =kmalloc_array (info->read_mmr_reg.count,sizeof (*regs),GFP_KERNEL ); -if (!regs) -return -ENOMEM ; +if (!regs) { + ret = -ENOMEM ; + goto out; + } + alloc_size = info->read_mmr_reg.count *sizeof (*regs);amdgpu_gfx_off_ctrl (adev, false);
@@ -760,13 +775,17 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) info->read_mmr_reg.dword_offset + i);kfree (regs);amdgpu_gfx_off_ctrl (adev, true); -return -EFAULT ; + ret = -EFAULT ; + goto out; } }amdgpu_gfx_off_ctrl (adev, true); n =copy_to_user (out, regs,min (size, alloc_size));kfree (regs); -return n ? -EFAULT :0 ; + ret = (n ? -EFAULT :0 ); +out: +up_read (&adev->reset_domain->sem); +return ret; }case AMDGPU_INFO_DEV_INFO : {struct drm_amdgpu_info_device *dev_info;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 123/139 drm/amdgpu/gfx9: use rlc safe mode for soft recovery
In reply to Sasha LevinFrom: Alex Deucher <[email protected]>
[ Upstream commit 3ec2ad7c34c412bd9264cd1ff235d0812be90e82 ]
Protect the MMIO access with safe mode.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -0
@@ -5709,7 +5709,9 @@ static void gfx_v9_0_ring_soft_recovery(struct amdgpu_ring *ring, unsigned vmid) value =REG_SET_FIELD (value,SQ_CMD ,MODE ,0x01 ); value =REG_SET_FIELD (value,SQ_CMD ,CHECK_VMID ,1 ); value =REG_SET_FIELD (value,SQ_CMD ,VM_ID , vmid); +amdgpu_gfx_rlc_enter_safe_mode (adev,0 );WREG32_SOC15 (GC ,0 , mmSQ_CMD, value); +amdgpu_gfx_rlc_exit_safe_mode (adev,0 ); } static void gfx_v9_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 124/139 drm/amd/pm: ensure the fw_info is not null before using it
In reply to Sasha LevinFrom: Tim Huang <[email protected]>
[ Upstream commit 186fb12e7a7b038c2710ceb2fb74068f1b5d55a4 ]
This resolves the dereference null return value warning reported by Coverity.
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c +2 -0
@@ -1185,6 +1185,8 @@ static int init_overdrive_limits(struct pp_hwmgr *hwmgr, fw_info =smu_atom_get_data_table (hwmgr->adev,GetIndexIntoMasterTable (DATA , FirmwareInfo), &size, &frev, &crev); +PP_ASSERT_WITH_CODE (fw_info !=NULL , +"Missing firmware info!" , return -EINVAL );if ((fw_info->ucTableFormatRevision ==1 ) && (le16_to_cpu (fw_info->usStructureSize) >=sizeof (ATOM_FIRMWARE_INFO_V1_4 )))
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 125/139 of/irq: Refer to actual buffer size in of_irq_parse_one()
In reply to Sasha LevinFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 39ab331ab5d377a18fbf5a0e0b228205edfcc7f4 ]
Replace two open-coded calculations of the buffer size by invocations of sizeof() on the buffer itself, to make sure the code will always use the actual buffer size.
--- drivers/of/irq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/of/irq.c +2 -2
@@ -357,8 +357,8 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar addr =of_get_property (device,"reg" , &addr_len);/* Prevent out-of-bounds read in case of longer interrupt parent address size */ -if (addr_len > (3 *sizeof (__be32))) - addr_len =3 *sizeof (__be32); +if (addr_len >sizeof (addr_buf)) + addr_len =sizeof (addr_buf);if (addr)memcpy (addr_buf, addr, addr_len);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 126/139 powerpc/pseries: Use correct data types from pseries_hp_errorlog struct
In reply to Sasha LevinFrom: Haren Myneni <[email protected]>
[ Upstream commit b76e0d4215b6b622127ebcceaa7f603313ceaec4 ]
_be32 type is defined for some elements in pseries_hp_errorlog struct but also used them u32 after be32_to_cpu() conversion.
Example: In handle_dlpar_errorlog() hp_elog->_drc_u.drc_index = be32_to_cpu(hp_elog->_drc_u.drc_index);
And later assigned to u32 typedlpar_cpu() - u32 drc_index = hp_elog->_drc_u.drc_index;
This incorrect usage is giving the following warnings and the patch resolve these warnings with the correct assignment.
arch/powerpc/platforms/pseries/dlpar.c:398:53: sparse: sparse:
incorrect type in argument 1 (different base types) @@ expected unsigned int [usertype] drc_index @@
got restricted __be32 [usertype] drc_index @@
...arch/powerpc/platforms/pseries/dlpar.c:418:43: sparse: sparse:
incorrect type in assignment (different base types) @@ expected restricted __be32 [usertype] drc_count @@ got unsigned int [usertype] @@
v3:
- Fix warnings from using incorrect data types in pseries_hp_errorlog struct
v2:
- Remove pr_info() and TODO comments
- Update more information in the commit logs
--- arch/powerpc/platforms/pseries/dlpar.c | 17 ----------------- arch/powerpc/platforms/pseries/hotplug-cpu.c | 2 +- arch/powerpc/platforms/pseries/hotplug-memory.c | 16 ++++++++-------- arch/powerpc/platforms/pseries/pmem.c | 2 +- 4 files changed, 10 insertions(+), 27 deletions(-)
arch/powerpc/platforms/pseries/dlpar.c +0 -17
@@ -334,23 +334,6 @@ int handle_dlpar_errorlog(struct pseries_hp_errorlog *hp_elog) {int rc; -/* pseries error logs are in BE format, convert to cpu type */ -switch (hp_elog->id_type) { -case PSERIES_HP_ELOG_ID_DRC_COUNT : - hp_elog->_drc_u.drc_count = -be32_to_cpu (hp_elog->_drc_u.drc_count); -break ; -case PSERIES_HP_ELOG_ID_DRC_INDEX : - hp_elog->_drc_u.drc_index = -be32_to_cpu (hp_elog->_drc_u.drc_index); -break ; -case PSERIES_HP_ELOG_ID_DRC_IC : - hp_elog->_drc_u.ic.count = -be32_to_cpu (hp_elog->_drc_u.ic.count); - hp_elog->_drc_u.ic.index = -be32_to_cpu (hp_elog->_drc_u.ic.index); - } -switch (hp_elog->resource) {case PSERIES_HP_ELOG_RESOURCE_MEM : rc =dlpar_memory (hp_elog);
arch/powerpc/platforms/pseries/hotplug-cpu.c +1 -1
@@ -757,7 +757,7 @@ int dlpar_cpu(struct pseries_hp_errorlog *hp_elog)u32 drc_index;int rc; - drc_index = hp_elog->_drc_u.drc_index; + drc_index =be32_to_cpu (hp_elog->_drc_u.drc_index);lock_device_hotplug ();
arch/powerpc/platforms/pseries/hotplug-memory.c +8 -8
@@ -811,16 +811,16 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog)case PSERIES_HP_ELOG_ACTION_ADD :switch (hp_elog->id_type) {case PSERIES_HP_ELOG_ID_DRC_COUNT : - count = hp_elog->_drc_u.drc_count; + count =be32_to_cpu (hp_elog->_drc_u.drc_count); rc =dlpar_memory_add_by_count (count);break ;case PSERIES_HP_ELOG_ID_DRC_INDEX : - drc_index = hp_elog->_drc_u.drc_index; + drc_index =be32_to_cpu (hp_elog->_drc_u.drc_index); rc =dlpar_memory_add_by_index (drc_index);break ;case PSERIES_HP_ELOG_ID_DRC_IC : - count = hp_elog->_drc_u.ic.count; - drc_index = hp_elog->_drc_u.ic.index; + count =be32_to_cpu (hp_elog->_drc_u.ic.count); + drc_index =be32_to_cpu (hp_elog->_drc_u.ic.index); rc =dlpar_memory_add_by_ic (count, drc_index);break ;default :
@@ -832,16 +832,16 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog)case PSERIES_HP_ELOG_ACTION_REMOVE :switch (hp_elog->id_type) {case PSERIES_HP_ELOG_ID_DRC_COUNT : - count = hp_elog->_drc_u.drc_count; + count =be32_to_cpu (hp_elog->_drc_u.drc_count); rc =dlpar_memory_remove_by_count (count);break ;case PSERIES_HP_ELOG_ID_DRC_INDEX : - drc_index = hp_elog->_drc_u.drc_index; + drc_index =be32_to_cpu (hp_elog->_drc_u.drc_index); rc =dlpar_memory_remove_by_index (drc_index);break ;case PSERIES_HP_ELOG_ID_DRC_IC : - count = hp_elog->_drc_u.ic.count; - drc_index = hp_elog->_drc_u.ic.index; + count =be32_to_cpu (hp_elog->_drc_u.ic.count); + drc_index =be32_to_cpu (hp_elog->_drc_u.ic.index); rc =dlpar_memory_remove_by_ic (count, drc_index);break ;default :
arch/powerpc/platforms/pseries/pmem.c +1 -1
@@ -121,7 +121,7 @@ int dlpar_hp_pmem(struct pseries_hp_errorlog *hp_elog)return -EINVAL ; } - drc_index = hp_elog->_drc_u.drc_index; + drc_index =be32_to_cpu (hp_elog->_drc_u.drc_index);lock_device_hotplug ();
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 127/139 drm/amdgpu/gfx11: use rlc safe mode for soft recovery
In reply to Sasha LevinFrom: Alex Deucher <[email protected]>
[ Upstream commit 3f2d35c325534c1b7ac5072173f0dc7ca969dec2 ]
Protect the MMIO access with safe mode.
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +2 -0
@@ -5701,7 +5701,9 @@ static void gfx_v11_0_ring_soft_recovery(struct amdgpu_ring *ring, value =REG_SET_FIELD (value,SQ_CMD ,MODE ,0x01 ); value =REG_SET_FIELD (value,SQ_CMD ,CHECK_VMID ,1 ); value =REG_SET_FIELD (value,SQ_CMD ,VM_ID , vmid); +amdgpu_gfx_rlc_enter_safe_mode (adev,0 );WREG32_SOC15 (GC ,0 , regSQ_CMD, value); +amdgpu_gfx_rlc_exit_safe_mode (adev,0 ); } static void
Signature · 1 line
2.43.0