5.12.18-rc1 review
Subsystems (4)
Greg Kroah-Hartman
maintainerPATCH 134/242 RDMA/cma: Fix rdma_resolve_route() memory leak
In reply to Greg Kroah-HartmanFrom: Gerd Rausch <[email protected]>
[ Upstream commit 74f160ead74bfe5f2b38afb4fcf86189f9ff40c9 ]
Fix a memory leak when "mda_resolve_route() is called more than once on the same "rdma_cm_id".
This is possible if cma_query_handler() triggers the RDMA_CM_EVENT_ROUTE_ERROR flow which puts the state machine back and allows rdma_resolve_route() to be called again.
--- drivers/infiniband/core/cma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/core/cma.c +2 -1
@@ -2793,7 +2793,8 @@ static int cma_resolve_ib_route(struct rdma_id_private *id_priv,cma_init_resolve_route_work (work, id_priv); - route->path_rec =kmalloc (sizeof *route->path_rec,GFP_KERNEL ); +if (!route->path_rec) + route->path_rec =kmalloc (sizeof *route->path_rec,GFP_KERNEL );if (!route->path_rec) { ret = -ENOMEM ; goto err1;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 135/242 Bluetooth: btusb: Fixed too many in-token issue for Mediatek Chip.
In reply to Greg Kroah-HartmanFrom: mark-yw.chen <[email protected]>
[ Upstream commit 8454ed9ff9647e31e061fb5eb2e39ce79bc5e960 ]
This patch reduce in-token during download patch procedure. Don't submit urb for polling event before sending hci command.
--- drivers/bluetooth/btusb.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/bluetooth/btusb.c +5 -5
@@ -3377,11 +3377,6 @@ static int btusb_mtk_hci_wmt_sync(struct hci_dev *hdev,struct btmtk_wmt_hdr *hdr;int err; -/* Submit control IN URB on demand to process the WMT event */ - err =btusb_mtk_submit_wmt_recv_urb (hdev); -if (err <0 ) -return err; -/* Send the WMT command and wait until the WMT event returns */ hlen =sizeof (*hdr) + wmt_params->dlen;if (hlen >255 )
@@ -3407,6 +3402,11 @@ static int btusb_mtk_hci_wmt_sync(struct hci_dev *hdev, goto err_free_wc; } +/* Submit control IN URB on demand to process the WMT event */ + err =btusb_mtk_submit_wmt_recv_urb (hdev); +if (err <0 ) +return err; +/* The vendor specific WMT commands are all answered by a vendor * specific event and will have the Command Status or Command * Complete as with usual HCI command flow control.
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 136/242 Bluetooth: Fix the HCI to MGMT status conversion table
In reply to Greg Kroah-HartmanFrom: Yu Liu <[email protected]>
[ Upstream commit 4ef36a52b0e47c80bbfd69c0cce61c7ae9f541ed ]
0x2B, 0x31 and 0x33 are reserved for future use but were not present in the HCI to MGMT conversion table, this caused the conversion to be incorrect for the HCI status code greater than 0x2A.
--- net/bluetooth/mgmt.c | 3 +++ 1 file changed, 3 insertions(+)
net/bluetooth/mgmt.c +3 -0
@@ -250,12 +250,15 @@ static const u8 mgmt_status_table[] = {MGMT_STATUS_TIMEOUT ,/* Instant Passed */ MGMT_STATUS_NOT_SUPPORTED ,/* Pairing Not Supported */ MGMT_STATUS_FAILED ,/* Transaction Collision */ +MGMT_STATUS_FAILED ,/* Reserved for future use */ MGMT_STATUS_INVALID_PARAMS ,/* Unacceptable Parameter */ MGMT_STATUS_REJECTED ,/* QoS Rejected */ MGMT_STATUS_NOT_SUPPORTED ,/* Classification Not Supported */ MGMT_STATUS_REJECTED ,/* Insufficient Security */ MGMT_STATUS_INVALID_PARAMS ,/* Parameter Out Of Range */ +MGMT_STATUS_FAILED ,/* Reserved for future use */ MGMT_STATUS_BUSY ,/* Role Switch Pending */ +MGMT_STATUS_FAILED ,/* Reserved for future use */ MGMT_STATUS_FAILED ,/* Slot Violation */ MGMT_STATUS_FAILED ,/* Role Switch Failed */ MGMT_STATUS_INVALID_PARAMS, /* EIR Too Large */
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 137/242 Bluetooth: Fix alt settings for incoming SCO with transparent coding format
In reply to Greg Kroah-HartmanFrom: Kiran K <[email protected]>
[ Upstream commit 06d213d8a89a6f55b708422c3dda2b22add10748 ]
For incoming SCO connection with transparent coding format, alt setting of CVSD is getting applied instead of Transparent.
Before fix:
< HCI Command: Accept Synchron.. (0x01|0x0029) plen 21 #2196 [hci0] 321.342548
Address: 1C:CC:D6:E2:EA:80 (Xiaomi Communications Co Ltd) Transmit bandwidth: 8000
Receive bandwidth: 8000
Max latency: 13
Setting: 0x0003
Input Coding: Linear
Input Data Format: 1's complement
Input Sample Size: 8-bit
# of bits padding at MSB: 0
Air Coding Format: Transparent Data
Retransmission effort: Optimize for link quality (0x02) Packet type: 0x003f
HV1 may be used
HV2 may be used
HV3 may be used
EV3 may be used
EV4 may be used
EV5 may be used
Quoted 1 line
HCI Event: Command Status (
0x0f) plen 4 #2197 [hci0] 321.343585
Accept Synchronous Connection Request (0x01|0x0029) ncmd 1
Status: Success (0x00)Quoted 1 line
HCI Event: Synchronous Connect Comp.. (
0x2c) plen 17 #2198 [hci0] 321.351666
Status: Success (0x00)
Handle: 257
Address: 1C:CC:D6:E2:EA:80 (Xiaomi Communications Co Ltd)
Link type: eSCO (0x02)
Transmission interval: 0x0c
Retransmission window: 0x04
RX packet length: 60
TX packet length: 60
Air mode: Transparent (0x03)........
Quoted 1 line
SCO Data RX: Handle 257 flags
0x00dlen 48 #2336 [hci0] 321.383655
< SCO Data TX: Handle 257 flags 0x00 dlen 60 #2337 [hci0] 321.389558 > SCO Data RX: Handle 257 flags 0x00 dlen 48 #2338 [hci0] 321.393615 > SCO Data RX: Handle 257 flags 0x00 dlen 48 #2339 [hci0] 321.393618 > SCO Data RX: Handle 257 flags 0x00 dlen 48 #2340 [hci0] 321.393618 < SCO Data TX: Handle 257 flags 0x00 dlen 60 #2341 [hci0] 321.397070 > SCO Data RX: Handle 257 flags 0x00 dlen 48 #2342 [hci0] 321.403622 > SCO Data RX: Handle 257 flags 0x00 dlen 48 #2343 [hci0] 321.403625 > SCO Data RX: Handle 257 flags 0x00 dlen 48 #2344 [hci0] 321.403625 > SCO Data RX: Handle 257 flags 0x00 dlen 48 #2345 [hci0] 321.403625 < SCO Data TX: Handle 257 flags 0x00 dlen 60 #2346 [hci0] 321.404569 < SCO Data TX: Handle 257 flags 0x00 dlen 60 #2347 [hci0] 321.412091 > SCO Data RX: Handle 257 flags 0x00 dlen 48 #2348 [hci0] 321.413626 > SCO Data RX: Handle 257 flags 0x00 dlen 48 #2349 [hci0] 321.413630 > SCO Data RX: Handle 257 flags 0x00 dlen 48 #2350 [hci0] 321.413630 < SCO Data TX: Handle 257 flags 0x00 dlen 60 #2351 [hci0] 321.419674
After fix:
< HCI Command: Accept Synchronou.. (0x01|0x0029) plen 21 #309 [hci0] 49.439693
Address: 1C:CC:D6:E2:EA:80 (Xiaomi Communications Co Ltd) Transmit bandwidth: 8000
Receive bandwidth: 8000
Max latency: 13
Setting: 0x0003
Input Coding: Linear
Input Data Format: 1's complement
Input Sample Size: 8-bit
# of bits padding at MSB: 0
Air Coding Format: Transparent Data
Retransmission effort: Optimize for link quality (0x02) Packet type: 0x003f
HV1 may be used
HV2 may be used
HV3 may be used
EV3 may be used
EV4 may be used
EV5 may be used
Quoted 1 line
HCI Event: Command Status (
0x0f) plen 4 #310 [hci0] 49.440308
Accept Synchronous Connection Request (0x01|0x0029) ncmd 1
Status: Success (0x00)Quoted 1 line
HCI Event: Synchronous Connect Complete (
0x2c) plen 17 #311 [hci0] 49.449308
Status: Success (0x00)
Handle: 257
Address: 1C:CC:D6:E2:EA:80 (Xiaomi Communications Co Ltd)
Link type: eSCO (0x02)
Transmission interval: 0x0c
Retransmission window: 0x04
RX packet length: 60
TX packet length: 60
Air mode: Transparent (0x03)
< SCO Data TX: Handle 257 flags 0x00 dlen 60 #312 [hci0] 49.450421
< SCO Data TX: Handle 257 flags 0x00 dlen 60 #313 [hci0] 49.457927
> HCI Event: Max Slots Change (0x1b) plen 3 #314 [hci0] 49.460345
Handle: 256
Max slots: 5
< SCO Data TX: Handle 257 flags 0x00 dlen 60 #315 [hci0] 49.465453
> SCO Data RX: Handle 257 flags 0x00 dlen 60 #316 [hci0] 49.470502
> SCO Data RX: Handle 257 flags 0x00 dlen 60 #317 [hci0] 49.470519
< SCO Data TX: Handle 257 flags 0x00 dlen 60 #318 [hci0] 49.472996
> SCO Data RX: Handle 257 flags 0x00 dlen 60 #319 [hci0] 49.480412
< SCO Data TX: Handle 257 flags 0x00 dlen 60 #320 [hci0] 49.480492
< SCO Data TX: Handle 257 flags 0x00 dlen 60 #321 [hci0] 49.487989
> SCO Data RX: Handle 257 flags 0x00 dlen 60 #322 [hci0] 49.490303
< SCO Data TX: Handle 257 flags 0x00 dlen 60 #323 [hci0] 49.495496
> SCO Data RX: Handle 257 flags 0x00 dlen 60 #324 [hci0] 49.500304
> SCO Data RX: Handle 257 flags 0x00 dlen 60 #325 [hci0] 49.500311--- net/bluetooth/hci_event.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/bluetooth/hci_event.c +3 -3
@@ -4379,12 +4379,12 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev,bt_dev_dbg (hdev,"SCO connected with air mode: %02x" , ev->air_mode); -switch (conn->setting &SCO_AIRMODE_MASK ) { -case SCO_AIRMODE_CVSD : +switch (ev->air_mode) { +case 0x02 :if (hdev->notify) hdev->notify (hdev,HCI_NOTIFY_ENABLE_SCO_CVSD );break ; -case SCO_AIRMODE_TRANSP : +case 0x03 :if (hdev->notify) hdev->notify (hdev,HCI_NOTIFY_ENABLE_SCO_TRANSP );break ;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 138/242 Bluetooth: Shutdown controller after workqueues are flushed or cancelled
In reply to Greg Kroah-HartmanFrom: Kai-Heng Feng <[email protected]>
[ Upstream commit 0ea9fd001a14ebc294f112b0361a4e601551d508 ]
Rfkill block and unblock Intel USB Bluetooth [8087:0026] may make it stops working:
[ 509.691509] Bluetooth: hci0: HCI reset during shutdown failed [ 514.897584] Bluetooth: hci0: MSFT filter_enable is already on [ 530.044751] usb 3-10: reset full-speed USB device number 5 using xhci_hcd [ 545.660350] usb 3-10: device descriptor read/64, error -110 [ 561.283530] usb 3-10: device descriptor read/64, error -110 [ 561.519682] usb 3-10: reset full-speed USB device number 5 using xhci_hcd [ 566.686650] Bluetooth: hci0: unexpected event for opcode 0x0500 [ 568.752452] Bluetooth: hci0: urb 0000000096cd309b failed to resubmit (113) [ 578.797955] Bluetooth: hci0: Failed to read MSFT supported features (-110) [ 586.286565] Bluetooth: hci0: urb 00000000c522f633 failed to resubmit (113) [ 596.215302] Bluetooth: hci0: Failed to read MSFT supported features (-110)
Or kernel panics because other workqueues already freed skb:
[ 2048.663763] BUG: kernel NULL pointer dereference, address: 0000000000000000 [ 2048.663775] #PF: supervisor read access in kernel mode [ 2048.663779] #PF: error_code(0x0000) - not-present page [ 2048.663782] PGD 0 P4D 0 [ 2048.663787] Oops: 0000 [#1] SMP NOPTI [ 2048.663793] CPU: 3 PID: 4491 Comm: rfkill Tainted: G W 5.13.0-rc1-next-20210510+ #20 [ 2048.663799] Hardware name: HP HP EliteBook 850 G8 Notebook PC/8846, BIOS T76 Ver. 01.01.04 12/02/2020 [ 2048.663801] RIP: 0010:__skb_ext_put+0x6/0x50 [ 2048.663814] Code: 8b 1b 48 85 db 75 db 5b 41 5c 5d c3 be 01 00 00 00 e8 de 13 c0 ff eb e7 be 02 00 00 00 e8 d2 13 c0 ff eb db 0f 1f 44 00 00 55 <8b> 07 48 89 e5 83 f8 01 74 14 b8 ff ff ff ff f0 0f c1 07 83 f8 01 [ 2048.663819] RSP: 0018:ffffc1d105b6fd80 EFLAGS: 00010286 [ 2048.663824] RAX: 0000000000000000 RBX: ffff9d9ac5649000 RCX: 0000000000000000 [ 2048.663827] RDX: ffffffffc0d1daf6 RSI: 0000000000000206 RDI: 0000000000000000 [ 2048.663830] RBP: ffffc1d105b6fd98 R08: 0000000000000001 R09: ffff9d9ace8ceac0 [ 2048.663834] R10: ffff9d9ace8ceac0 R11: 0000000000000001 R12: ffff9d9ac5649000 [ 2048.663838] R13: 0000000000000000 R14: 00007ffe0354d650 R15: 0000000000000000 [ 2048.663843] FS: 00007fe02ab19740(0000) GS:ffff9d9e5f8c0000(0000) knlGS:0000000000000000 [ 2048.663849] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 2048.663853] CR2: 0000000000000000 CR3: 0000000111a52004 CR4: 0000000000770ee0 [ 2048.663856] PKRU: 55555554 [ 2048.663859] Call Trace: [ 2048.663865] ? skb_release_head_state+0x5e/0x80 [ 2048.663873] kfree_skb+0x2f/0xb0 [ 2048.663881] btusb_shutdown_intel_new+0x36/0x60 [btusb] [ 2048.663905] hci_dev_do_close+0x48c/0x5e0 [bluetooth] [ 2048.663954] ? __cond_resched+0x1a/0x50 [ 2048.663962] hci_rfkill_set_block+0x56/0xa0 [bluetooth] [ 2048.664007] rfkill_set_block+0x98/0x170 [ 2048.664016] rfkill_fop_write+0x136/0x1e0 [ 2048.664022] vfs_write+0xc7/0x260 [ 2048.664030] ksys_write+0xb1/0xe0 [ 2048.664035] ? exit_to_user_mode_prepare+0x37/0x1c0 [ 2048.664042] __x64_sys_write+0x1a/0x20 [ 2048.664048] do_syscall_64+0x40/0xb0 [ 2048.664055] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 2048.664060] RIP: 0033:0x7fe02ac23c27 [ 2048.664066] Code: 0d 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 48 89 54 24 18 48 89 74 24 [ 2048.664070] RSP: 002b:00007ffe0354d638 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 [ 2048.664075] RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00007fe02ac23c27 [ 2048.664078] RDX: 0000000000000008 RSI: 00007ffe0354d650 RDI: 0000000000000003 [ 2048.664081] RBP: 0000000000000000 R08: 0000559b05998440 R09: 0000559b05998440 [ 2048.664084] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000003 [ 2048.664086] R13: 0000000000000000 R14: ffffffff00000000 R15: 00000000ffffffff
So move the shutdown callback to a place where workqueues are either flushed or cancelled to resolve the issue.
--- net/bluetooth/hci_core.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
net/bluetooth/hci_core.c +8 -8
@@ -1719,14 +1719,6 @@ int hci_dev_do_close(struct hci_dev *hdev)BT_DBG ("%s %p" , hdev->name, hdev); -if (!hci_dev_test_flag (hdev,HCI_UNREGISTER ) && - !hci_dev_test_flag (hdev,HCI_USER_CHANNEL ) && -test_bit (HCI_UP , &hdev->flags)) { -/* Execute vendor specific shutdown routine */ -if (hdev->shutdown) - hdev->shutdown (hdev); - } -cancel_delayed_work (&hdev->power_off);hci_request_cancel_all (hdev);
@@ -1802,6 +1794,14 @@ int hci_dev_do_close(struct hci_dev *hdev)clear_bit (HCI_INIT , &hdev->flags); } +if (!hci_dev_test_flag (hdev,HCI_UNREGISTER ) && + !hci_dev_test_flag (hdev,HCI_USER_CHANNEL ) && +test_bit (HCI_UP , &hdev->flags)) { +/* Execute vendor specific shutdown routine */ +if (hdev->shutdown) + hdev->shutdown (hdev); + } +/* flush cmd work */ flush_work (&hdev->cmd_work);
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 139/242 Bluetooth: btusb: Add a new QCA_ROME device (0cf3:e500)
In reply to Greg Kroah-HartmanFrom: Daniel Lenski <[email protected]>
[ Upstream commit 0324d19cb99804d99e42c990b8b1e191575a091b ]
This patch adds the 0cf3:e500 Bluetooth device (from a QCA9377 board) as a QCA_ROME device. It appears to be functionally identical to another device ID, also from a QCA9377 board, which was previously marked as QCA_ROME in 0a03f98b98c201191e3ba15a0e33f46d8660e1fd
("Bluetooth: Add a new 04ca:3015 QCA_ROME device").
Without this patch, the WiFi side of the QCA9377 board is slow or unusable when the Bluetooth side is in use.
See https://askubuntu.com/a/1137852 for another report of QCA_ROME fixing this issue for this device ID.
/sys/kernel/debug/usb/devices:
T: Bus=05 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=12 MxCh= 0 D: Ver= 2.01 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0cf3 ProdID=e500 Rev= 0.01 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA 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=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=02(O) 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=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=03(O) 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=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=03(O) 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=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=03(O) 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=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=03(O) 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=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=03(O) 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=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms
--- drivers/bluetooth/btusb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
@@ -270,6 +270,8 @@ static const struct usb_device_id blacklist_table[] = { BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x0cf3, 0xe360), .driver_info = BTUSB_QCA_ROME | BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x0cf3, 0xe500), .driver_info = BTUSB_QCA_ROME | + BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x0489, 0xe092), .driver_info = BTUSB_QCA_ROME | BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x0489, 0xe09f), .driver_info = BTUSB_QCA_ROME |
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 140/242 Bluetooth: L2CAP: Fix invalid access if ECRED Reconfigure fails
In reply to Greg Kroah-HartmanFrom: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 1fa20d7d4aad02206e84b74915819fbe9f81dab3 ]
The use of l2cap_chan_del is not safe under a loop using list_for_each_entry.
--- net/bluetooth/l2cap_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/bluetooth/l2cap_core.c +2 -2
@@ -6244,7 +6244,7 @@ static inline int l2cap_ecred_reconf_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u16 cmd_len, u8 *data) { - struct l2cap_chan *chan; + struct l2cap_chan *chan, *tmp;struct l2cap_ecred_conn_rsp *rsp = (void *) data;u16 result;
@@ -6258,7 +6258,7 @@ static inline int l2cap_ecred_reconf_rsp(struct l2cap_conn *conn,if (!result)return 0 ; -list_for_each_entry (chan, &conn->chan_l, list) { +list_for_each_entry_safe (chan, tmp, &conn->chan_l, list) {if (chan->ident != cmd->ident)continue ;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 141/242 Bluetooth: L2CAP: Fix invalid access on ECRED Connection response
In reply to Greg Kroah-HartmanFrom: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit de895b43932cb47e69480540be7eca289af24f23 ]
The use of l2cap_chan_del is not safe under a loop using list_for_each_entry.
--- net/bluetooth/l2cap_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/bluetooth/l2cap_core.c +2 -2
@@ -6062,7 +6062,7 @@ static inline int l2cap_ecred_conn_rsp(struct l2cap_conn *conn,struct l2cap_ecred_conn_rsp *rsp = (void *) data;struct hci_conn *hcon = conn->hcon;u16 mtu, mps, credits, result; -struct l2cap_chan *chan; +struct l2cap_chan *chan, *tmp;int err =0 , sec_level;int i =0 ;
@@ -6081,7 +6081,7 @@ static inline int l2cap_ecred_conn_rsp(struct l2cap_conn *conn, cmd_len -=sizeof (*rsp); -list_for_each_entry (chan, &conn->chan_l, list) { +list_for_each_entry_safe (chan, tmp, &conn->chan_l, list) {u16 dcid; if (chan->ident != cmd->ident ||
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 142/242 Bluetooth: btusb: Add support USB ALT 3 for WBS
In reply to Greg Kroah-HartmanFrom: Hilda Wu <[email protected]>
[ Upstream commit e848dbd364aca44c9d23c04bef964fab79e2b34f ]
Because mSBC frames do not need to be aligned to the SCO packet boundary. Using USB ALT 3 let HCI payload >= 60 bytes, let mSBC data satisfy 60 Bytes avoid payload unaligned situation and fixed some headset no voise issue.
USB Alt 3 supported also need HFP support transparent MTU in 72 Bytes.
--- drivers/bluetooth/btusb.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/bluetooth/btusb.c +7 -0
@@ -1749,6 +1749,13 @@ static void btusb_work(struct work_struct *work)* which work with WBS at all. */ new_alts =btusb_find_altsetting (data,6 ) ?6 :1 ; +/* Because mSBC frames do not need to be aligned to the +* SCO packet boundary. If support the Alt 3, use the +* Alt 3 for HCI payload >= 60 Bytes let air packet +* data satisfy 60 bytes. +*/ +if (new_alts ==1 &&btusb_find_altsetting (data,3 )) + new_alts =3 ; }if (btusb_switch_alt_setting (hdev, new_alts) <0 )
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 143/242 Bluetooth: mgmt: Fix the command returns garbage parameter value
In reply to Greg Kroah-HartmanFrom: Tedd Ho-Jeong An <[email protected]>
[ Upstream commit 02ce2c2c24024aade65a8d91d6a596651eaf2d0a ]
When the Get Device Flags command fails, it returns the error status with the parameters filled with the garbage values. Although the parameters are not used, it is better to fill with zero than the random values.
--- net/bluetooth/mgmt.c | 2 ++ 1 file changed, 2 insertions(+)
net/bluetooth/mgmt.c +2 -0
@@ -4056,6 +4056,8 @@ static int get_device_flags(struct sock *sk, struct hci_dev *hdev, void *data,hci_dev_lock (hdev); +memset (&rp,0 ,sizeof (rp)); +if (cp->addr.type ==BDADDR_BREDR ) { br_params = hci_bdaddr_list_lookup_with_flags(&hdev->whitelist, &cp->addr.bdaddr,
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 144/242 Bluetooth: btusb: use default nvm if boardID is 0 for wcn6855.
In reply to Greg Kroah-HartmanFrom: Tim Jiang <[email protected]>
[ Upstream commit ca17a5cccf8b6d35dab4729bea8f4350bc0b4caf ]
if boardID is 0, will use the default nvm file without surfix.
--- drivers/bluetooth/btusb.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/bluetooth/btusb.c +9 -3
@@ -4228,9 +4228,15 @@ static int btusb_setup_qca_load_nvm(struct hci_dev *hdev,int err;if (((ver->flag >>8 ) &0xff ) ==QCA_FLAG_MULTI_NVM ) { -snprintf (fwname,sizeof (fwname),"qca/nvm_usb_%08x_%04x.bin" , -le32_to_cpu (ver->rom_version), -le16_to_cpu (ver->board_id)); +/* if boardid equal 0, use default nvm without surfix */ +if (le16_to_cpu (ver->board_id) ==0x0 ) { +snprintf (fwname,sizeof (fwname),"qca/nvm_usb_%08x.bin" , +le32_to_cpu (ver->rom_version)); + }else { +snprintf (fwname,sizeof (fwname),"qca/nvm_usb_%08x_%04x.bin" , +le32_to_cpu (ver->rom_version), +le16_to_cpu (ver->board_id)); + } }else {snprintf (fwname,sizeof (fwname),"qca/nvm_usb_%08x.bin" ,le32_to_cpu (ver->rom_version));
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 145/242 Bluetooth: btusb: fix bt fiwmare downloading failure issue for qca btsoc.
In reply to Greg Kroah-HartmanFrom: Tim Jiang <[email protected]>
[ Upstream commit 4f00bfb372674d586c4a261bfc595cbce101fbb6 ]
This is btsoc timing issue, after host start to downloading bt firmware, ep2 need time to switch from function acl to function dfu, so host add 20ms delay as workaround.
--- drivers/bluetooth/btusb.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/bluetooth/btusb.c +5 -0
@@ -4136,6 +4136,11 @@ static int btusb_setup_qca_download_fw(struct hci_dev *hdev, sent += size; count -= size; +/* ep2 need time to switch from function acl to function dfu, +* so we add 20ms delay here. +*/ +msleep (20 ); +while (count) { size =min_t (size_t, count,QCA_DFU_PACKET_LEN );
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 146/242 sched/fair: Ensure _sum and _avg values stay consistent
In reply to Greg Kroah-HartmanFrom: Odin Ugedal <[email protected]>
[ Upstream commit 1c35b07e6d3986474e5635be566e7bc79d97c64d ]
The _sum and _avg values are in general sync together with the PELT divider. They are however not always completely in perfect sync, resulting in situations where _sum gets to zero while _avg stays positive. Such situations are undesirable.
This comes from the fact that PELT will increase period_contrib, also increasing the PELT divider, without updating _sum and _avg values to stay in perfect sync where (_sum == _avg * divider). However, such PELT change will never lower _sum, making it impossible to end up in a situation where _sum is zero and _avg is not.
Therefore, we need to ensure that when subtracting load outside PELT, that when _sum is zero, _avg is also set to zero. This occurs when (_sum < _avg * divider), and the subtracted (_avg * divider) is bigger or equal to the current _sum, while the subtracted _avg is smaller than the current _avg.
--- kernel/sched/fair.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/sched/fair.c +3 -3
@@ -3665,15 +3665,15 @@ update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq) r = removed_load;sub_positive (&sa->load_avg, r); -sub_positive (&sa->load_sum, r * divider); + sa->load_sum = sa->load_avg * divider; r = removed_util;sub_positive (&sa->util_avg, r); -sub_positive (&sa->util_sum, r * divider); + sa->util_sum = sa->util_avg * divider; r = removed_runnable;sub_positive (&sa->runnable_avg, r); -sub_positive (&sa->runnable_sum, r * divider); + sa->runnable_sum = sa->runnable_avg * divider;/* * removed_runnable is the unweighted version of removed_load so we
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 147/242 bpf: Fix false positive kmemleak report in bpf_ringbuf_area_alloc()
In reply to Greg Kroah-HartmanFrom: Rustam Kovhaev <[email protected]>
[ Upstream commit ccff81e1d028bbbf8573d3364a87542386c707bf ]
kmemleak scans struct page, but it does not scan the page content. If we allocate some memory with kmalloc(), then allocate page with alloc_page(), and if we put kmalloc pointer somewhere inside that page, kmemleak will report kmalloc pointer as a false positive.
We can instruct kmemleak to scan the memory area by calling kmemleak_alloc() and kmemleak_free(), but part of struct bpf_ringbuf is mmaped to user space, and if struct bpf_ringbuf changes we would have to revisit and review size argument in kmemleak_alloc(), because we do not want kmemleak to scan the user space memory. Let's simplify things and use kmemleak_not_leak() here.
For posterity, also adding additional prior analysis from Andrii:
I think either kmemleak or syzbot are misreporting this. I've added a bunch of printks around all allocations performed by BPF ringbuf. [...] On repro side I get these two warnings:
[vmuser@archvm bpf]$ sudo ./repro
BUG: memory leak
unreferenced object 0xffff88810d538c00 (size 64):
comm "repro", pid 2140, jiffies 4294692933 (age 14.540s)
hex dump (first 32 bytes):
00 af 19 04 00 ea ff ff c0 ae 19 04 00 ea ff ff ................
80 ae 19 04 00 ea ff ff c0 29 2e 04 00 ea ff ff .........)......
backtrace:
[<0000000077bfbfbd>] __bpf_map_area_alloc+0x31/0xc0
[<00000000587fa522>] ringbuf_map_alloc.cold.4+0x48/0x218
[<0000000044d49e96>] __do_sys_bpf+0x359/0x1d90
[<00000000f601d565>] do_syscall_64+0x2d/0x40
[<0000000043d3112a>] entry_SYSCALL_64_after_hwframe+0x44/0xae
BUG: memory leak
unreferenced object 0xffff88810d538c80 (size 64):
comm "repro", pid 2143, jiffies 4294699025 (age 8.448s)
hex dump (first 32 bytes):
80 aa 19 04 00 ea ff ff 00 ab 19 04 00 ea ff ff ................
c0 ab 19 04 00 ea ff ff 80 44 28 04 00 ea ff ff .........D(.....
backtrace:
[<0000000077bfbfbd>] __bpf_map_area_alloc+0x31/0xc0
[<00000000587fa522>] ringbuf_map_alloc.cold.4+0x48/0x218
[<0000000044d49e96>] __do_sys_bpf+0x359/0x1d90
[<00000000f601d565>] do_syscall_64+0x2d/0x40
[<0000000043d3112a>] entry_SYSCALL_64_after_hwframe+0x44/0xae Note that both reported leaks (ffff88810d538c80 and ffff88810d538c00) correspond to pages array bpf_ringbuf is allocating and tracking properly internally. Note also that syzbot repro doesn't close FD of created BPF ringbufs, and even when ./repro itself exits with error, there are still two forked processes hanging around in my system. So clearly ringbuf maps are alive at that point. So reporting any memory leak looks weird at that point, because that memory is being used by active referenced BPF ringbuf.
It's also a question why repro doesn't clean up its forks. But if I do a pkill repro, I do see that all the allocated memory is /properly/ cleaned up [and the] "leaks" are deallocated properly.
BTW, if I add close() right after bpf() syscall in syzbot repro, I see that everything is immediately deallocated, like designed. And no memory leak is reported. So I don't think the problem is anywhere in bpf_ringbuf code, rather in the leak detection and/or repro itself.
--- kernel/bpf/ringbuf.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/bpf/ringbuf.c +2 -0
@@ -8,6 +8,7 @@#include <linux/vmalloc.h> #include <linux/wait.h> #include <linux/poll.h> +#include <linux/kmemleak.h> #include <uapi/linux/btf.h> #define RINGBUF_CREATE_FLAG_MASK (BPF_F_NUMA_NODE)
@@ -105,6 +106,7 @@ static struct bpf_ringbuf *bpf_ringbuf_area_alloc(size_t data_sz, int numa_node) rb =vmap (pages, nr_meta_pages +2 * nr_data_pages,VM_ALLOC |VM_USERMAP ,PAGE_KERNEL );if (rb) { +kmemleak_not_leak (pages); rb->pages = pages; rb->nr_pages = nr_pages;return rb;
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 148/242 flow_offload: action should not be NULL when it is referenced
In reply to Greg Kroah-HartmanFrom: gushengxian <[email protected]>
[ Upstream commit 9ea3e52c5bc8bb4a084938dc1e3160643438927a ]
"action" should not be NULL when it is referenced.
--- include/net/flow_offload.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
include/net/flow_offload.h +7 -5
@@ -313,12 +313,14 @@ flow_action_mixed_hw_stats_check(const struct flow_action *action,if (flow_offload_has_one_action (action))return true; -flow_action_for_each (i, action_entry, action) { -if (i && action_entry->hw_stats != last_hw_stats) { -NL_SET_ERR_MSG_MOD (extack,"Mixing HW stats types for actions is not supported" ); -return false; +if (action) { +flow_action_for_each (i, action_entry, action) { +if (i && action_entry->hw_stats != last_hw_stats) { +NL_SET_ERR_MSG_MOD (extack,"Mixing HW stats types for actions is not supported" ); +return false; + } + last_hw_stats = action_entry->hw_stats; } - last_hw_stats = action_entry->hw_stats; }return true; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 149/242 sctp: validate from_addr_param return
In reply to Greg Kroah-HartmanFrom: Marcelo Ricardo Leitner <[email protected]>
[ Upstream commit 0c5dc070ff3d6246d22ddd931f23a6266249e3db ]
Ilja reported that, simply putting it, nothing was validating that from_addr_param functions were operating on initialized memory. That is, the parameter itself was being validated by sctp_walk_params, but it doesn't check for types and their specific sizes and it could be a 0-length one, causing from_addr_param to potentially work over the next parameter or even uninitialized memory.
The fix here is to, in all calls to from_addr_param, check if enough space is there for the wanted IP address type.
--- include/net/sctp/structs.h | 2 +- net/sctp/bind_addr.c | 19 +++++++++++-------- net/sctp/input.c | 6 ++++-- net/sctp/ipv6.c | 7 ++++++- net/sctp/protocol.c | 7 ++++++- net/sctp/sm_make_chunk.c | 29 ++++++++++++++++------------- 6 files changed, 44 insertions(+), 26 deletions(-)
include/net/sctp/structs.h +1 -1
@@ -461,7 +461,7 @@ struct sctp_af { int saddr);void (*from_sk) (union sctp_addr *,struct sock *sk); -void (*from_addr_param) (union sctp_addr *, +bool (*from_addr_param) (union sctp_addr *,union sctp_addr_param *,__be16 port,int iif); int (*to_addr_param) (const union sctp_addr *,
net/sctp/bind_addr.c +11 -8
@@ -270,22 +270,19 @@ int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw_addr_list, rawaddr = (union sctp_addr_param *)raw_addr_list; af =sctp_get_af_specific (param_type2af (param->type)); -if (unlikely (!af)) { +if (unlikely (!af) || + !af->from_addr_param (&addr, rawaddr,htons (port),0 )) { retval = -EINVAL ; -sctp_bind_addr_clean (bp); -break ; + goto out_err; } - af->from_addr_param (&addr, rawaddr,htons (port),0 );if (sctp_bind_addr_state (bp, &addr) !=-1 ) goto next; retval =sctp_add_bind_addr (bp, &addr,sizeof (addr),SCTP_ADDR_SRC , gfp); -if (retval) { +if (retval)/* Can't finish building the list, clean up. */ -sctp_bind_addr_clean (bp); -break ; - } + goto out_err; next: len =ntohs (param->length);
@@ -294,6 +291,12 @@ next: }return retval; + +out_err: +if (retval) +sctp_bind_addr_clean (bp); + +return retval; }/********************************************************************
net/sctp/input.c +4 -2
@@ -1131,7 +1131,8 @@ static struct sctp_association *__sctp_rcv_init_lookup(struct net *net,if (!af)continue ; - af->from_addr_param (paddr, params.addr, sh->source,0 ); +if (!af->from_addr_param (paddr, params.addr, sh->source,0 )) +continue ; asoc =__sctp_lookup_association (net, laddr, paddr, transportp);if (asoc)
@@ -1174,7 +1175,8 @@ static struct sctp_association *__sctp_rcv_asconf_lookup(if (unlikely (!af))return NULL ; - af->from_addr_param (&paddr, param, peer_port,0 ); +if (af->from_addr_param (&paddr, param, peer_port,0 )) +return NULL ;return __sctp_lookup_association (net, laddr, &paddr, transportp); }
net/sctp/ipv6.c +6 -1
@@ -551,15 +551,20 @@ static void sctp_v6_to_sk_daddr(union sctp_addr *addr, struct sock *sk) }/* Initialize a sctp_addr from an address parameter. */ -static void sctp_v6_from_addr_param (union sctp_addr *addr, +static bool sctp_v6_from_addr_param (union sctp_addr *addr,union sctp_addr_param *param,__be16 port,int iif) { +if (ntohs (param->v6.param_hdr.length) <sizeof (struct sctp_ipv6addr_param )) +return false; + addr->v6.sin6_family =AF_INET6 ; addr->v6.sin6_port = port; addr->v6.sin6_flowinfo =0 ;/* BUG */ addr->v6.sin6_addr = param->v6.addr; addr->v6.sin6_scope_id = iif; + +return true; }/* Initialize an address parameter from a sctp_addr and return the length
net/sctp/protocol.c +6 -1
@@ -254,14 +254,19 @@ static void sctp_v4_to_sk_daddr(union sctp_addr *addr, struct sock *sk) }/* Initialize a sctp_addr from an address parameter. */ -static void sctp_v4_from_addr_param (union sctp_addr *addr, +static bool sctp_v4_from_addr_param (union sctp_addr *addr,union sctp_addr_param *param,__be16 port,int iif) { +if (ntohs (param->v4.param_hdr.length) <sizeof (struct sctp_ipv4addr_param )) +return false; + addr->v4.sin_family =AF_INET ; addr->v4.sin_port = port; addr->v4.sin_addr.s_addr = param->v4.addr.s_addr;memset (addr->v4.sin_zero,0 ,sizeof (addr->v4.sin_zero)); + +return true; }/* Initialize an address parameter from a sctp_addr and return the length
net/sctp/sm_make_chunk.c +16 -13
@@ -2350,11 +2350,13 @@ int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk,/* Process the initialization parameters. */ sctp_walk_params(param, peer_init, init_hdr.params) { -if (!src_match && (param.p->type ==SCTP_PARAM_IPV4_ADDRESS || - param.p->type ==SCTP_PARAM_IPV6_ADDRESS )) { +if (!src_match && + (param.p->type ==SCTP_PARAM_IPV4_ADDRESS || + param.p->type ==SCTP_PARAM_IPV6_ADDRESS )) { af =sctp_get_af_specific (param_type2af (param.p->type)); - af->from_addr_param (&addr, param.addr, - chunk->sctp_hdr->source,0 ); +if (!af->from_addr_param (&addr, param.addr, + chunk->sctp_hdr->source,0 )) +continue ;if (sctp_cmp_addr_exact (sctp_source (chunk), &addr)) src_match =1 ; }
@@ -2535,7 +2537,8 @@ static int sctp_process_param(struct sctp_association *asoc,break ; do_addr_param: af =sctp_get_af_specific (param_type2af (param.p->type)); - af->from_addr_param (&addr, param.addr,htons (asoc->peer.port),0 ); +if (!af->from_addr_param (&addr, param.addr,htons (asoc->peer.port),0 )) +break ; scope =sctp_scope (peer_addr);if (sctp_in_scope (net, &addr, scope))if (!sctp_assoc_add_peer (asoc, &addr, gfp,SCTP_UNCONFIRMED ))
@@ -2636,15 +2639,13 @@ do_addr_param: addr_param = param.v +sizeof (struct sctp_addip_param ); af =sctp_get_af_specific (param_type2af (addr_param->p.type)); -if (af ==NULL ) +if (!af)break ; - af->from_addr_param (&addr, addr_param, -htons (asoc->peer.port),0 ); +if (!af->from_addr_param (&addr, addr_param, +htons (asoc->peer.port),0 )) +break ; -/* if the address is invalid, we can't process it. -* XXX: see spec for what to do. -*/ if (!af->addr_valid (&addr,NULL ,NULL ))break ;
@@ -3058,7 +3059,8 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc,if (unlikely (!af))return SCTP_ERROR_DNS_FAILED ; - af->from_addr_param (&addr, addr_param,htons (asoc->peer.port),0 ); +if (!af->from_addr_param (&addr, addr_param,htons (asoc->peer.port),0 )) +return SCTP_ERROR_DNS_FAILED ;/* ADDIP 4.2.1 This parameter MUST NOT contain a broadcast * or multicast address.
@@ -3335,7 +3337,8 @@ static void sctp_asconf_param_success(struct sctp_association *asoc,/* We have checked the packet before, so we do not check again. */ af =sctp_get_af_specific (param_type2af (addr_param->p.type)); - af->from_addr_param (&addr, addr_param,htons (bp->port),0 ); +if (!af->from_addr_param (&addr, addr_param,htons (bp->port),0 )) +return ;switch (asconf_param->param_hdr.type) {case SCTP_PARAM_ADD_IP :
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 150/242 sctp: add size validation when walking chunks
In reply to Greg Kroah-HartmanFrom: Marcelo Ricardo Leitner <[email protected]>
[ Upstream commit 50619dbf8db77e98d821d615af4f634d08e22698 ]
The first chunk in a packet is ensured to be present at the beginning of sctp_rcv(), as a packet needs to have at least 1 chunk. But the second one, may not be completely available and ch->length can be over uninitialized memory.
Fix here is by only trying to walk on the next chunk if there is enough to hold at least the header, and then proceed with the ch->length validation that is already there.
--- net/sctp/input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sctp/input.c +1 -1
@@ -1247,7 +1247,7 @@ static struct sctp_association *__sctp_rcv_walk_lookup(struct net *net, ch = (struct sctp_chunkhdr *)ch_end; chunk_num++; - }while (ch_end <skb_tail_pointer (skb)); + }while (ch_end +sizeof (*ch) <skb_tail_pointer (skb));return asoc; }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 151/242 MIPS: loongsoon64: Reserve memory below starting pfn to prevent Oops
In reply to Greg Kroah-HartmanFrom: zhanglianjie <[email protected]>
[ Upstream commit 6817c944430d00f71ccaa9c99ff5b0096aeb7873 ]
The cause of the problem is as follows:
1. when cat /sys/devices/system/memory/memory0/valid_zones, test_pages_in_a_zone() will be called.
2. test_pages_in_a_zone() finds the zone according to stat_pfn = 0. The smallest pfn of the numa node in the mips architecture is 128, and the page corresponding to the previous 0~127 pfn is not initialized (page->flags is 0xFFFFFFFF)
3. The nid and zonenum obtained using page_zone(pfn_to_page(0)) are out of bounds in the corresponding array, &NODE_DATA(page_to_nid(page))->node_zones[page_zonenum(page)], access to the out-of-bounds zone member variables appear abnormal, resulting in Oops.
Therefore, it is necessary to keep the page between 0 and the minimum pfn to prevent Oops from appearing.
--- arch/mips/loongson64/numa.c | 3 +++ 1 file changed, 3 insertions(+)
arch/mips/loongson64/numa.c +3 -0
@@ -118,6 +118,9 @@ static void __init node_mem_init(unsigned int node)if (node_end_pfn (0 ) >= (0xffffffff >>PAGE_SHIFT ))memblock_reserve ((node_addrspace_offset |0xfe000000 ),32 <<20 ); + +/* Reserve pfn range 0~node[0]->node_start_pfn */ +memblock_reserve (0 ,PAGE_SIZE * start_pfn); } }
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 152/242 MIPS: set mips32r5 for virt extensions
In reply to Greg Kroah-HartmanFrom: Nick Desaulniers <[email protected]>
[ Upstream commit c994a3ec7ecc8bd2a837b2061e8a76eb8efc082b ]
Clang's integrated assembler only accepts these instructions when the cpu is set to mips32r5. With this change, we can assemble malta_defconfig with Clang via make LLVM_IAS=1.
--- arch/mips/include/asm/mipsregs.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/mips/include/asm/mipsregs.h +4 -4
@@ -2077,7 +2077,7 @@ _ASM_MACRO_0(tlbginvf, _ASM_INSN_IF_MIPS(0x4200000c) ({ int __res; \ __asm__ __volatile__( \ ".set\tpush\n\t" \ - ".set\tmips32r2\n\t" \ + ".set\tmips32r5\n\t" \ _ASM_SET_VIRT \ "mfgc0\t%0, " #source ", %1\n\t" \ ".set\tpop" \
@@ -2090,7 +2090,7 @@ _ASM_MACRO_0(tlbginvf, _ASM_INSN_IF_MIPS(0x4200000c) ({ unsigned long long __res; \ __asm__ __volatile__( \ ".set\tpush\n\t" \ - ".set\tmips64r2\n\t" \ + ".set\tmips64r5\n\t" \ _ASM_SET_VIRT \ "dmfgc0\t%0, " #source ", %1\n\t" \ ".set\tpop" \
@@ -2103,7 +2103,7 @@ _ASM_MACRO_0(tlbginvf, _ASM_INSN_IF_MIPS(0x4200000c) do { \ __asm__ __volatile__( \ ".set\tpush\n\t" \ - ".set\tmips32r2\n\t" \ + ".set\tmips32r5\n\t" \ _ASM_SET_VIRT \ "mtgc0\t%z0, " #register ", %1\n\t" \ ".set\tpop" \
@@ -2115,7 +2115,7 @@ do { \ do { \ __asm__ __volatile__( \ ".set\tpush\n\t" \ - ".set\tmips64r2\n\t" \ + ".set\tmips64r5\n\t" \ _ASM_SET_VIRT \ "dmtgc0\t%z0, " #register ", %1\n\t" \ ".set\tpop" \
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 153/242 MIPS: CI20: Reduce clocksource to 750 kHz.
In reply to Greg Kroah-HartmanFrom: 周琰杰 (Zhou Yanjie) <[email protected]>
[ Upstream commit 23c64447b3538a6f34cb38aae3bc19dc1ec53436 ]
The original clock (3 MHz) is too fast for the clocksource, there will be a chance that the system may get stuck.
--- arch/mips/boot/dts/ingenic/ci20.dts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/boot/dts/ingenic/ci20.dts +2 -2
@@ -525,10 +525,10 @@ &tcu { /* - * 750 kHz for the system timer and 3 MHz for the clocksource, + * 750 kHz for the system timer and clocksource, * use channel #0 for the system timer, #1 for the clocksource. */ assigned-clocks = <&tcu TCU_CLK_TIMER0>, <&tcu TCU_CLK_TIMER1>, <&tcu TCU_CLK_OST>; - assigned-clock-rates = <750000>, <3000000>, <3000000>; + assigned-clock-rates = <750000>, <750000>, <3000000>; };
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerPATCH 154/242 PCI: tegra194: Fix host initialization during resume
In reply to Greg Kroah-HartmanFrom: Vidya Sagar <[email protected]>
commit c4bf1f25c6c187864681d5ad4dd1fa92f62d5d32 upstream.
Commit 275e88b06a27 ("PCI: tegra: Fix host link initialization") broke host initialization during resume as it misses out calling the API dw_pcie_setup_rc() which is required for host and MSI initialization.
--- drivers/pci/controller/dwc/pcie-tegra194.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pci/controller/dwc/pcie-tegra194.c +2 -0
@@ -2214,6 +2214,8 @@ static int tegra_pcie_dw_resume_noirq(st goto fail_host_init; } +dw_pcie_setup_rc (&pcie->pci.pp); + ret =tegra_pcie_dw_start_link (&pcie->pci);if (ret <0 ) goto fail_host_init;
Greg Kroah-Hartman
maintainerPATCH 155/242 selftests/resctrl: Fix incorrect parsing of option "-t"
In reply to Greg Kroah-HartmanFrom: Xiaochen Shen <[email protected]>
commit 1421ec684a43379b2aa3cfda20b03d38282dc990 upstream.
Resctrl test suite accepts command line argument "-t" to specify the unit tests to run in the test list (e.g., -t mbm,mba,cmt,cat) as documented in the help.
When calling strtok() to parse the option, the incorrect delimiters argument ":\t" is used. As a result, passing "-t mbm,mba,cmt,cat" throws an invalid option error.
Fix this by using delimiters argument "," instead of ":\t" for parsing of unit tests list. At the same time, remove the unnecessary "spaces" between the unit tests in help documentation to prevent confusion.
--- tools/testing/selftests/resctrl/README | 2 +- tools/testing/selftests/resctrl/resctrl_tests.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/resctrl/README +1 -1
@@ -47,7 +47,7 @@ Parameter '-h' shows usage information. usage: resctrl_tests [-h] [-b "benchmark_cmd [options]"] [-t test list] [-n no_of_bits] -b benchmark_cmd [options]: run specified benchmark for MBM, MBA and CQM default benchmark is builtin fill_buf - -t test list: run tests specified in the test list, e.g. -t mbm, mba, cqm, cat + -t test list: run tests specified in the test list, e.g. -t mbm,mba,cqm,cat -n no_of_bits: run cache tests using specified no of bits in cache bit mask -p cpu_no: specify CPU number to run the test. 1 is default -h: help
tools/testing/selftests/resctrl/resctrl_tests.c +2 -2
@@ -40,7 +40,7 @@ static void cmd_help(void)printf ("\t-b benchmark_cmd [options]: run specified benchmark for MBM, MBA and CQM" );printf ("\t default benchmark is builtin fill_buf\n" );printf ("\t-t test list: run tests specified in the test list, " ); -printf ("e.g. -t mbm, mba, cqm, cat\n" ); +printf ("e.g. -t mbm,mba,cqm,cat\n" );printf ("\t-n no_of_bits: run cache tests using specified no of bits in cache bit mask\n" );printf ("\t-p cpu_no: specify CPU number to run the test. 1 is default\n" );printf ("\t-h: help\n" );
@@ -98,7 +98,7 @@ int main(int argc, char **argv)return -1 ; } - token =strtok (NULL ,":\t" ); + token =strtok (NULL ,"," ); }break ;case 'p' :
Greg Kroah-Hartman
maintainerPATCH 156/242 MIPS: MT extensions are not available on MIPS32r1
In reply to Greg Kroah-HartmanFrom: Paul Cercueil <[email protected]>
commit cad065ed8d8831df67b9754cc4437ed55d8b48c0 upstream.
MIPS MT extensions were added with the MIPS 34K processor, which was based on the MIPS32r2 ISA.
This fixes a build error when building a generic kernel for a MIPS32r1 CPU.
--- arch/mips/include/asm/cpu-features.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/mips/include/asm/cpu-features.h +3 -1
@@ -64,6 +64,8 @@ ((MIPS_ISA_REV >= (ge)) && (MIPS_ISA_REV < (lt)))#define __isa_range_or_flag (ge, lt, flag) \ (__isa_range(ge, lt) || ((MIPS_ISA_REV < (lt)) && __isa(flag))) +#define __isa_range_and_ase (ge, lt, ase) \ + (__isa_range(ge, lt) && __ase(ase))/* * SMP assumption: Options of CPU 0 are a superset of all processors.
@@ -421,7 +423,7 @@#endif #ifndef cpu_has_mipsmt -#define cpu_has_mipsmt __isa_lt_and_ase(6, MIPS_ASE_MIPSMT) +#define cpu_has_mipsmt __isa_range_and_ase(2, 6, MIPS_ASE_MIPSMT)#endif #ifndef cpu_has_vp
Greg Kroah-Hartman
maintainerPATCH 157/242 mm/mremap: hold the rmap lock in write mode when moving page table entries.
In reply to Greg Kroah-HartmanFrom: Aneesh Kumar K.V <[email protected]>
commit 97113eb39fa7972722ff490b947d8af023e1f6a2 upstream.
To avoid a race between rmap walk and mremap, mremap does take_rmap_locks(). The lock was taken to ensure that rmap walk don't miss a page table entry due to PTE moves via move_pagetables(). The kernel does further optimization of this lock such that if we are going to find the newly added vma after the old vma, the rmap lock is not taken. This is because rmap walk would find the vmas in the same order and if we don't find the page table attached to older vma we would find it with the new vma which we would iterate later.
As explained in commit eb66ae030829 ("mremap: properly flush TLB before releasing the page") mremap is special in that it doesn't take ownership of the page. The optimized version for PUD/PMD aligned mremap also doesn't hold the ptl lock. This can result in stale TLB entries as show below.
This patch updates the rmap locking requirement in mremap to handle the race condition explained below with optimized mremap::
Optmized PMD move
CPU 1 CPU 2 CPU 3
mremap(old_addr, new_addr) page_shrinker/try_to_unmap_one
mmap_write_lock_killable()
addr = old_addr lock(pte_ptl)
lock(pmd_ptl)
pmd = *old_pmd
pmd_clear(old_pmd) flush_tlb_range(old_addr)
*new_pmd = pmd
*new_addr = 10; and fills TLB with new addr and old pfn
unlock(pmd_ptl)
ptep_clear_flush()
old pfn is free.
Stale TLB entry
Optimized PUD move also suffers from a similar race. Both the above race condition can be fixed if we force mremap path to take rmap lock.
--- mm/mremap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/mremap.c +2 -2
@@ -439,7 +439,7 @@ unsigned long move_page_tables(struct vmif (!new_pud)break ;if (move_pgt_entry (NORMAL_PUD , vma, old_addr, new_addr, - old_pud, new_pud, need_rmap_locks)) + old_pud, new_pud, true))continue ; }
@@ -466,7 +466,7 @@ unsigned long move_page_tables(struct vm* moving at the PMD level if possible. */ if (move_pgt_entry (NORMAL_PMD , vma, old_addr, new_addr, - old_pmd, new_pmd, need_rmap_locks)) + old_pmd, new_pmd, true))continue ; }
Greg Kroah-Hartman
maintainerPATCH 158/242 powerpc/mm: Fix lockup on kernel exec fault
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit cd5d5e602f502895e47e18cd46804d6d7014e65c upstream.
The powerpc kernel is not prepared to handle exec faults from kernel. Especially, the function is_exec_fault() will return 'false' when an exec fault is taken by kernel, because the check is based on reading current->thread.regs->trap which contains the trap from user.
For instance, when provoking a LKDTM EXEC_USERSPACE test, current->thread.regs->trap is set to SYSCALL trap (0xc00), and the fault taken by the kernel is not seen as an exec fault by set_access_flags_filter().
Commit d7df2443cd5f ("powerpc/mm: Fix spurious segfaults on radix with autonuma") made it clear and handled it properly. But later on commit d3ca587404b3 ("powerpc/mm: Fix reporting of kernel execute faults") removed that handling, introducing test based on error_code. And here is the problem, because on the 603 all upper bits of SRR1 get cleared when the TLB instruction miss handler bails out to ISI.
Until commit cbd7e6ca0210 ("powerpc/fault: Avoid heavy search_exception_tables() verification"), an exec fault from kernel at a userspace address was indirectly caught by the lack of entry for that address in the exception tables. But after that commit the kernel mainly relies on KUAP or on core mm handling to catch wrong user accesses. Here the access is not wrong, so mm handles it. It is a minor fault because PAGE_EXEC is not set, set_access_flags_filter() should set PAGE_EXEC and voila. But as is_exec_fault() returns false as explained in the beginning, set_access_flags_filter() bails out without setting PAGE_EXEC flag, which leads to a forever minor exec fault.
As the kernel is not prepared to handle such exec faults, the thing to do is to fire in bad_kernel_fault() for any exec fault taken by the kernel, as it was prior to commit d3ca587404b3.
--- arch/powerpc/mm/fault.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/powerpc/mm/fault.c +1 -3
@@ -199,9 +199,7 @@ static bool bad_kernel_fault(struct pt_r {int is_exec =TRAP (regs) ==0x400 ; -/* NX faults set DSISR_PROTFAULT on the 8xx, DSISR_NOEXEC_OR_G on others */ -if (is_exec && (error_code & (DSISR_NOEXEC_OR_G |DSISR_KEYFAULT | -DSISR_PROTFAULT ))) { +if (is_exec) { pr_crit_ratelimited("kernel tried to execute %s page (%lx) - exploit attempt? (uid: %d)\n", address >= TASK_SIZE ? "exec-protected" : "user", address,
Greg Kroah-Hartman
maintainerPATCH 159/242 powerpc/barrier: Avoid collision with clangs __lwsync macro
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit 015d98149b326e0f1f02e44413112ca8b4330543 upstream.
A change in clang 13 results in the __lwsync macro being defined as __builtin_ppc_lwsync, which emits 'lwsync' or 'msync' depending on what the target supports. This breaks the build because of -Werror in arch/powerpc, along with thousands of warnings:
In file included from arch/powerpc/kernel/pmc.c:12:
In file included from include/linux/bug.h:5:
In file included from arch/powerpc/include/asm/bug.h:109:
In file included from include/asm-generic/bug.h:20:
In file included from include/linux/kernel.h:12:
In file included from include/linux/bitops.h:32:
In file included from arch/powerpc/include/asm/bitops.h:62:
arch/powerpc/include/asm/barrier.h:49:9: error: '__lwsync' macro redefined [-Werror,-Wmacro-redefined]
#define __lwsync() __asm__ __volatile__ (stringify_in_c(LWSYNC) : : :"memory")
^
<built-in>:308:9: note: previous definition is here
#define __lwsync __builtin_ppc_lwsync
^1 error generated.
Undefine this macro so that the runtime patching introduced by commit 2d1b2027626d ("powerpc: Fixup lwsync at runtime") continues to work properly with clang and the build no longer breaks.
--- arch/powerpc/include/asm/barrier.h | 2 ++ 1 file changed, 2 insertions(+)
arch/powerpc/include/asm/barrier.h +2 -0
@@ -46,6 +46,8 @@# define SMPWMB eieio#endif +/* clang defines this macro for a builtin, which will not work with runtime patching */ +#undef __lwsync#define __lwsync () __asm__ __volatile__ (stringify_in_c(LWSYNC) : : :"memory")#define dma_rmb () __lwsync()#define dma_wmb () __asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
Greg Kroah-Hartman
maintainerPATCH 160/242 powerpc/powernv/vas: Release reference to tgid during window close
In reply to Greg Kroah-HartmanFrom: Haren Myneni <[email protected]>
commit 91cdbb955aa94ee0841af4685be40937345d29b8 upstream.
The kernel handles the NX fault by updating CSB or sending signal to process. In multithread applications, children can open VAS windows and can exit without closing them. But the parent can continue to send NX requests with these windows. To prevent pid reuse, reference will be taken on pid and tgid when the window is opened and release them during window close.
The current code is not releasing the tgid reference which can cause pid leak and this patch fixes the issue.
--- arch/powerpc/platforms/powernv/vas-window.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
arch/powerpc/platforms/powernv/vas-window.c +5 -4
@@ -1093,9 +1093,9 @@ struct vas_window *vas_tx_win_open(int v/* * Process closes window during exit. In the case of * multithread application, the child thread can open -* window and can exit without closing it. Expects parent -* thread to use and close the window. So do not need -* to take pid reference for parent thread. +* window and can exit without closing it. so takes tgid +* reference until window closed to make sure tgid is not +* reused. */ txwin->tgid =find_get_pid (task_tgid_vnr (current));/*
@@ -1339,8 +1339,9 @@ int vas_win_close(struct vas_window *win/* if send window, drop reference to matching receive window */ if (window->tx_win) {if (window->user_win) { -/* Drop references to pid and mm */ +/* Drop references to pid. tgid and mm */ put_pid (window->pid); +put_pid (window->tgid);if (window->mm) {mm_context_remove_vas_window (window->mm);mmdrop (window->mm);
Greg Kroah-Hartman
maintainerPATCH 161/242 drm/amdgpu: add new dimgrey cavefish DID
In reply to Greg Kroah-HartmanFrom: Alex Deucher <[email protected]>
commit 06ac9b6c736ac9da600b1782d7ac6d6e746286c4 upstream.
Add new PCI device id.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -0
@@ -1123,6 +1123,7 @@ static const struct pci_device_id pciidl {0x1002, 0x73E0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_DIMGREY_CAVEFISH}, {0x1002, 0x73E1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_DIMGREY_CAVEFISH}, {0x1002, 0x73E2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_DIMGREY_CAVEFISH}, + {0x1002, 0x73E3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_DIMGREY_CAVEFISH}, {0x1002, 0x73FF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_DIMGREY_CAVEFISH}, {0, 0, 0}
Greg Kroah-Hartman
maintainerPATCH 162/242 drm/amdgpu: Update NV SIMD-per-CU to 2
In reply to Greg Kroah-HartmanFrom: Joseph Greathouse <[email protected]>
commit aa6158112645aae514982ad8d56df64428fcf203 upstream.
Navi series GPUs have 2 SIMDs per CU (and then 2 CUs per WGP). The NV enum headers incorrectly listed this as 4, which later meant we were incorrectly reporting the number of SIMDs in the HSA topology. This could cause problems down the line for user-space applications that want to launch a fixed amount of work to each SIMD.
--- drivers/gpu/drm/amd/include/navi10_enum.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/include/navi10_enum.h +1 -1
@@ -430,7 +430,7 @@ ARRAY_2D_DEPTH*/ typedef enum ENUM_NUM_SIMD_PER_CU { -NUM_SIMD_PER_CU =0x00000004 , +NUM_SIMD_PER_CU =0x00000002 , }ENUM_NUM_SIMD_PER_CU ;/*
Greg Kroah-Hartman
maintainerPATCH 163/242 drm/amdgpu: enable sdma0 tmz for Raven/Renoir(V2)
In reply to Greg Kroah-HartmanFrom: Aaron Liu <[email protected]>
commit e2329e74a615cc58b25c42b7aa1477a5e3f6a435 upstream.
Without driver loaded, SDMA0_UTCL1_PAGE.TMZ_ENABLE is set to 1 by default for all asic. On Raven/Renoir, the sdma goldsetting changes SDMA0_UTCL1_PAGE.TMZ_ENABLE to 0.
This patch restores SDMA0_UTCL1_PAGE.TMZ_ENABLE to 1.
--- drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +2 -2
@@ -142,7 +142,7 @@ static const struct soc15_reg_golden golSOC15_REG_GOLDEN_VALUE (SDMA0 ,0 , mmSDMA0_RLC0_RB_WPTR_POLL_CNTL,0xfffffff7 ,0x00403000 ),SOC15_REG_GOLDEN_VALUE (SDMA0 ,0 , mmSDMA0_RLC1_IB_CNTL,0x800f0111 ,0x00000100 ),SOC15_REG_GOLDEN_VALUE (SDMA0 ,0 , mmSDMA0_RLC1_RB_WPTR_POLL_CNTL,0xfffffff7 ,0x00403000 ), -SOC15_REG_GOLDEN_VALUE (SDMA0 ,0 , mmSDMA0_UTCL1_PAGE,0x000003ff ,0x000003c0 ), +SOC15_REG_GOLDEN_VALUE (SDMA0 ,0 , mmSDMA0_UTCL1_PAGE,0x000003ff ,0x000003e0 ), SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_UTCL1_WATERMK, 0xfc000000, 0x00000000) };
@@ -268,7 +268,7 @@ static const struct soc15_reg_golden golSOC15_REG_GOLDEN_VALUE (SDMA0 ,0 , mmSDMA0_POWER_CNTL,0x003fff07 ,0x40000051 ),SOC15_REG_GOLDEN_VALUE (SDMA0 ,0 , mmSDMA0_RLC0_RB_WPTR_POLL_CNTL,0xfffffff7 ,0x00403000 ),SOC15_REG_GOLDEN_VALUE (SDMA0 ,0 , mmSDMA0_RLC1_RB_WPTR_POLL_CNTL,0xfffffff7 ,0x00403000 ), -SOC15_REG_GOLDEN_VALUE (SDMA0 ,0 , mmSDMA0_UTCL1_PAGE,0x000003ff ,0x000003c0 ), +SOC15_REG_GOLDEN_VALUE (SDMA0 ,0 , mmSDMA0_UTCL1_PAGE,0x000003ff ,0x000003e0 ), SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_UTCL1_WATERMK, 0xfc000000, 0x03fbe1fe) };
Greg Kroah-Hartman
maintainerPATCH 164/242 drm/amdgpu: fix NAK-G generation during PCI-e link width switch
In reply to Greg Kroah-HartmanFrom: Evan Quan <[email protected]>
commit 5a5da8ae9546031e43efd4fa5aa8baa481e83dfb upstream.
A lot of NAK-G being generated when link widht switching is happening. WA for this issue is to program the SPC to 4 symbols per clock during bootup when the native PCIE width is x4.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h | 1 + drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c | 28 ++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/nv.c | 3 +++ 3 files changed, 32 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h +1 -0
@@ -89,6 +89,7 @@ struct amdgpu_nbio_funcs {void (*enable_aspm)(struct amdgpu_device *adev,bool enable);void (*program_aspm)(struct amdgpu_device *adev); +void (*apply_lc_spc_mode_wa)(struct amdgpu_device *adev); };struct amdgpu_nbio {
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +28 -0
@@ -51,6 +51,8 @@#define mmBIF_MMSCH1_DOORBELL_RANGE 0x01d8#define mmBIF_MMSCH1_DOORBELL_RANGE_BASE_IDX 2 +#define smnPCIE_LC_LINK_WIDTH_CNTL 0x11140288 +static void nbio_v2_3_remap_hdp_registers (struct amdgpu_device *adev) { WREG32_SOC15(NBIO, 0, mmREMAP_HDP_MEM_FLUSH_CNTL,
@@ -463,6 +465,31 @@ static void nbio_v2_3_program_aspm(strucWREG32_PCIE (smnPCIE_LC_CNTL3, data); } +static void nbio_v2_3_apply_lc_spc_mode_wa (struct amdgpu_device *adev) +{ +uint32_t reg_data =0 ; +uint32_t link_width =0 ; + +if (!((adev->asic_type >=CHIP_NAVI10 ) && + (adev->asic_type <=CHIP_NAVI12 ))) +return ; + + reg_data =RREG32_PCIE (smnPCIE_LC_LINK_WIDTH_CNTL); + link_width = (reg_data &PCIE_LC_LINK_WIDTH_CNTL__LC_LINK_WIDTH_RD_MASK ) + >>PCIE_LC_LINK_WIDTH_CNTL__LC_LINK_WIDTH_RD__SHIFT ; + +/* +* Program PCIE_LC_CNTL6.LC_SPC_MODE_8GT to 0x2 (4 symbols per clock data) +* if link_width is 0x3 (x4) +*/ +if (0x3 == link_width) { + reg_data =RREG32_PCIE (smnPCIE_LC_CNTL6); + reg_data &= ~PCIE_LC_CNTL6__LC_SPC_MODE_8GT_MASK ; + reg_data |= (0x2 <<PCIE_LC_CNTL6__LC_SPC_MODE_8GT__SHIFT ); +WREG32_PCIE (smnPCIE_LC_CNTL6, reg_data); + } +} +const struct amdgpu_nbio_funcs nbio_v2_3_funcs = { .get_hdp_flush_req_offset = nbio_v2_3_get_hdp_flush_req_offset, .get_hdp_flush_done_offset = nbio_v2_3_get_hdp_flush_done_offset,
@@ -484,4 +511,5 @@ const struct amdgpu_nbio_funcs nbio_v2_3 .remap_hdp_registers = nbio_v2_3_remap_hdp_registers, .enable_aspm = nbio_v2_3_enable_aspm, .program_aspm = nbio_v2_3_program_aspm, + .apply_lc_spc_mode_wa = nbio_v2_3_apply_lc_spc_mode_wa, };
drivers/gpu/drm/amd/amdgpu/nv.c +3 -0
@@ -1073,6 +1073,9 @@ static int nv_common_hw_init(void *handl {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +if (adev->nbio.funcs->apply_lc_spc_mode_wa) + adev->nbio.funcs->apply_lc_spc_mode_wa (adev); +/* enable pcie gen2/3 link */ nv_pcie_gen3_enable (adev);/* enable aspm */
Greg Kroah-Hartman
maintainerPATCH 165/242 drm/amdgpu: fix the hang caused by PCIe link width switch
In reply to Greg Kroah-HartmanFrom: Evan Quan <[email protected]>
commit adcf949e664a8b04df2fb8aa916892e58561653c upstream.
SMU had set all the necessary fields for a link width switch but the width switch wasn't occurring because the link was idle in the L1 state. Setting LC_L1_RECONFIG_EN=0x1 will allow width switches to also be initiated while in L1 instead of waiting until the link is back in L0.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h | 1 + drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c | 13 +++++++++++++ drivers/gpu/drm/amd/amdgpu/nv.c | 3 +++ 3 files changed, 17 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h +1 -0
@@ -90,6 +90,7 @@ struct amdgpu_nbio_funcs { bool enable);void (*program_aspm)(struct amdgpu_device *adev);void (*apply_lc_spc_mode_wa)(struct amdgpu_device *adev); +void (*apply_l1_link_width_reconfig_wa)(struct amdgpu_device *adev); };struct amdgpu_nbio {
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +13 -0
@@ -490,6 +490,18 @@ static void nbio_v2_3_apply_lc_spc_mode_ } } +static void nbio_v2_3_apply_l1_link_width_reconfig_wa (struct amdgpu_device *adev) +{ +uint32_t reg_data =0 ; + +if (adev->asic_type !=CHIP_NAVI10 ) +return ; + + reg_data =RREG32_PCIE (smnPCIE_LC_LINK_WIDTH_CNTL); + reg_data |=PCIE_LC_LINK_WIDTH_CNTL__LC_L1_RECONFIG_EN_MASK ; +WREG32_PCIE (smnPCIE_LC_LINK_WIDTH_CNTL, reg_data); +} +const struct amdgpu_nbio_funcs nbio_v2_3_funcs = { .get_hdp_flush_req_offset = nbio_v2_3_get_hdp_flush_req_offset, .get_hdp_flush_done_offset = nbio_v2_3_get_hdp_flush_done_offset,
@@ -512,4 +524,5 @@ const struct amdgpu_nbio_funcs nbio_v2_3 .enable_aspm = nbio_v2_3_enable_aspm, .program_aspm = nbio_v2_3_program_aspm, .apply_lc_spc_mode_wa = nbio_v2_3_apply_lc_spc_mode_wa, + .apply_l1_link_width_reconfig_wa = nbio_v2_3_apply_l1_link_width_reconfig_wa, };
drivers/gpu/drm/amd/amdgpu/nv.c +3 -0
@@ -1076,6 +1076,9 @@ static int nv_common_hw_init(void *handlif (adev->nbio.funcs->apply_lc_spc_mode_wa) adev->nbio.funcs->apply_lc_spc_mode_wa (adev); +if (adev->nbio.funcs->apply_l1_link_width_reconfig_wa) + adev->nbio.funcs->apply_l1_link_width_reconfig_wa (adev); +/* enable pcie gen2/3 link */ nv_pcie_gen3_enable (adev);/* enable aspm */
Greg Kroah-Hartman
maintainerPATCH 166/242 drm/radeon: Add the missed drm_gem_object_put() in radeon_user_framebuffer_create()
In reply to Greg Kroah-HartmanFrom: Jing Xiangfeng <[email protected]>
commit 9ba85914c36c8fed9bf3e8b69c0782908c1247b7 upstream.
radeon_user_framebuffer_create() misses to call drm_gem_object_put() in an error path. Add the missed function call to fix it.
--- drivers/gpu/drm/radeon/radeon_display.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/radeon/radeon_display.c +1 -0
@@ -1325,6 +1325,7 @@ radeon_user_framebuffer_create(struct dr/* Handle is imported dma-buf, so cannot be migrated to VRAM for scanout */ if (obj->import_attach) {DRM_DEBUG_KMS ("Cannot create framebuffer from imported dma_buf\n" ); +drm_gem_object_put (obj);return ERR_PTR (-EINVAL ); }
Greg Kroah-Hartman
maintainerPATCH 167/242 drm/radeon: Call radeon_suspend_kms() in radeon_pci_shutdown() for Loongson64
In reply to Greg Kroah-HartmanFrom: Tiezhu Yang <[email protected]>
commit c1bfd74bfef77bcefc88d12eaf8996c0dfd51331 upstream.
On the Loongson64 platform used with Radeon GPU, shutdown or reboot failed when console=tty is in the boot cmdline.
radeon_suspend_kms() puts the hw in the suspend state, especially set fb state as FBINFO_STATE_SUSPENDED:
if (fbcon) {
console_lock();
radeon_fbdev_set_suspend(rdev, 1);
console_unlock();
}Then avoid to do any more fb operations in the related functions:
if (p->state != FBINFO_STATE_RUNNING)
return;So call radeon_suspend_kms() in radeon_pci_shutdown() for Loongson64 to fix this issue, it looks like some kind of workaround like powerpc.
--- drivers/gpu/drm/radeon/radeon_drv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/radeon/radeon_drv.c +4 -4
@@ -386,13 +386,13 @@ radeon_pci_shutdown(struct pci_dev *pdevif (radeon_device_is_virtual ())radeon_pci_remove (pdev); -#ifdef CONFIG_PPC64 +#if defined(CONFIG_PPC64 ) || defined(CONFIG_MACH_LOONGSON64 )/* * Some adapters need to be suspended before a * shutdown occurs in order to prevent an error -* during kexec. -* Make this power specific becauase it breaks -* some non-power boards. +* during kexec, shutdown or reboot. +* Make this power and Loongson specific because +* it breaks some other boards. */ radeon_suspend_kms (pci_get_drvdata (pdev), true, true, false);#endif
Greg Kroah-Hartman
maintainerPATCH 168/242 drm/vc4: txp: Properly set the possible_crtcs mask
In reply to Greg Kroah-HartmanFrom: Maxime Ripard <[email protected]>
commit bf6de8e61509f3c957d7f75f017b18d40a18a950 upstream.
The current code does a binary OR on the possible_crtcs variable of the TXP encoder, while we want to set it to that value instead.
--- drivers/gpu/drm/vc4/vc4_txp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_txp.c +1 -1
@@ -507,7 +507,7 @@ static int vc4_txp_bind(struct device *dreturn ret; encoder = &txp->connector.encoder; - encoder->possible_crtcs |=drm_crtc_mask (crtc); + encoder->possible_crtcs =drm_crtc_mask (crtc); ret =devm_request_irq (dev, irq, vc4_txp_interrupt,0 ,dev_name (dev), txp);
Greg Kroah-Hartman
maintainerPATCH 169/242 drm/vc4: crtc: Skip the TXP
In reply to Greg Kroah-HartmanFrom: Maxime Ripard <[email protected]>
commit 47a50743031ad4138050ae6d266ddd3dfe845ead upstream.
The vc4_set_crtc_possible_masks is meant to run over all the encoders and then set their possible_crtcs mask to their associated pixelvalve.
However, since the commit 39fcb2808376 ("drm/vc4: txp: Turn the TXP into a CRTC of its own"), the TXP has been turned to a CRTC and encoder of its own, and while it does indeed register an encoder, it no longer has an associated pixelvalve. The code will thus run over the TXP encoder and set a bogus possible_crtcs mask, overriding the one set in the TXP bind function.
In order to fix this, let's skip any virtual encoder.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/vc4/vc4_crtc.c +3 -0
@@ -1076,6 +1076,9 @@ static void vc4_set_crtc_possible_masks(struct vc4_encoder *vc4_encoder;int i; +if (encoder->encoder_type ==DRM_MODE_ENCODER_VIRTUAL ) +continue ; + vc4_encoder =to_vc4_encoder (encoder);for (i =0 ; i <ARRAY_SIZE (pv_data->encoder_types); i++) {if (vc4_encoder->type == encoder_types[i]) {
Greg Kroah-Hartman
maintainerPATCH 170/242 drm/vc4: hdmi: Prevent clock unbalance
In reply to Greg Kroah-HartmanFrom: Maxime Ripard <[email protected]>
commit 5b006000423667ef0f55721fc93e477b31f22d28 upstream.
Since we fixed the hooks to disable the encoder at boot, we now have an unbalanced clk_disable call at boot since we never enabled them in the first place.
Let's mimic the state of the hardware and enable the clocks at boot if the controller is enabled to get the use-count right.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/vc4/vc4_hdmi.c +8 -0
@@ -2012,6 +2012,14 @@ static int vc4_hdmi_bind(struct device *if (vc4_hdmi->variant->reset) vc4_hdmi->variant->reset (vc4_hdmi); +if ((of_device_is_compatible (dev->of_node,"brcm,bcm2711-hdmi0" ) || +of_device_is_compatible (dev->of_node,"brcm,bcm2711-hdmi1" )) && +HDMI_READ (HDMI_VID_CTL ) &VC4_HD_VID_CTL_ENABLE ) { +clk_prepare_enable (vc4_hdmi->pixel_clock); +clk_prepare_enable (vc4_hdmi->hsm_clock); +clk_prepare_enable (vc4_hdmi->pixel_bvb_clock); + } +pm_runtime_enable (dev);drm_simple_encoder_init (drm, encoder,DRM_MODE_ENCODER_TMDS );
Greg Kroah-Hartman
maintainerPATCH 171/242 drm/dp: Handle zeroed port counts in drm_dp_read_downstream_info()
In reply to Greg Kroah-HartmanFrom: Lyude Paul <[email protected]>
commit 205bb69a90363541a634a662a599fddb95956524 upstream.
While the DP specification isn't entirely clear on if this should be allowed or not, some branch devices report having downstream ports present while also reporting a downstream port count of 0. So to avoid breaking those devices, we need to handle this in drm_dp_read_downstream_info().
So, to do this we assume there's no downstream port info when the downstream port count is 0.
Bugzilla: https://gitlab.freedesktop.org/drm/intel/-/issues/3416
--- drivers/gpu/drm/drm_dp_helper.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/drm_dp_helper.c +7 -0
@@ -679,7 +679,14 @@ int drm_dp_read_downstream_info(struct d !(dpcd[DP_DOWNSTREAMPORT_PRESENT] & DP_DWN_STRM_PORT_PRESENT))return 0 ; +/* Some branches advertise having 0 downstream ports, despite also advertising they have a +* downstream port present. The DP spec isn't clear on if this is allowed or not, but since +* some branches do it we need to handle it regardless. +*/ len =drm_dp_downstream_port_count (dpcd); +if (!len) +return 0 ; +if (dpcd[DP_DOWNSTREAMPORT_PRESENT ] &DP_DETAILED_CAP_INFO_AVAILABLE ) len *=4 ;
Greg Kroah-Hartman
maintainerPATCH 172/242 drm/rockchip: dsi: remove extra component_del() call
In reply to Greg Kroah-HartmanFrom: Thomas Hebb <[email protected]>
commit b354498bbe65c917d521b3b56317ddc9ab217425 upstream.
commit cf6d100dd238 ("drm/rockchip: dsi: add dual mipi support") added this devcnt field and call to component_del(). However, these both appear to be erroneous changes left over from an earlier version of the patch. In the version merged, nothing ever modifies devcnt, meaning component_del() runs unconditionally and in addition to the component_del() calls in dw_mipi_dsi_rockchip_host_detach(). The second call fails to delete anything and produces a warning in dmesg.
If we look at the previous version of the patch[1], however, we see that it had logic to calculate devcnt and call component_add() in certain situations. This was removed in v6, and the fact that the deletion code was not appears to have been an oversight.
[1] https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/
--- drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +0 -4
@@ -243,7 +243,6 @@ struct dw_mipi_dsi_rockchip {struct dw_mipi_dsi *dmd;const struct rockchip_dw_dsi_chip_data *cdata;struct dw_mipi_dsi_plat_data pdata; -int devcnt; };struct dphy_pll_parameter_map {
@@ -1141,9 +1140,6 @@ static int dw_mipi_dsi_rockchip_remove(s {struct dw_mipi_dsi_rockchip *dsi =platform_get_drvdata (pdev); -if (dsi->devcnt ==0 ) -component_del (dsi->dev, &dw_mipi_dsi_rockchip_ops); -dw_mipi_dsi_remove (dsi->dmd);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 173/242 drm/amd/display: fix incorrrect valid irq check
In reply to Greg Kroah-HartmanFrom: Guchun Chen <[email protected]>
commit e38ca7e422791a4d1c01e56dbf7f9982db0ed365 upstream.
valid DAL irq should be < DAL_IRQ_SOURCES_NUMBER.
--- drivers/gpu/drm/amd/display/dc/irq_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/irq_types.h +1 -1
@@ -164,7 +164,7 @@ enum irq_type };#define DAL_VALID_IRQ_SRC_NUM (src) \ - ((src) <= DAL_IRQ_SOURCES_NUMBER && (src) > DC_IRQ_SOURCE_INVALID) + ((src) < DAL_IRQ_SOURCES_NUMBER && (src) > DC_IRQ_SOURCE_INVALID)/* Number of Page Flip IRQ Sources. */ #define DAL_PFLIP_IRQ_SRC_NUM \
Greg Kroah-Hartman
maintainerPATCH 174/242 pinctrl/amd: Add device HID for new AMD GPIO controller
In reply to Greg Kroah-HartmanFrom: Maximilian Luz <[email protected]>
commit 1ca46d3e43569186bd1decfb02a6b4c4ddb4304b upstream.
Add device HID AMDI0031 to the AMD GPIO controller driver match table. This controller can be found on Microsoft Surface Laptop 4 devices and seems similar enough that we can just copy the existing AMDI0030 entry.
--- drivers/pinctrl/pinctrl-amd.c | 1 + 1 file changed, 1 insertion(+)
drivers/pinctrl/pinctrl-amd.c +1 -0
@@ -991,6 +991,7 @@ static int amd_gpio_remove(struct platfostatic const struct acpi_device_id amd_gpio_acpi_match[] = { {"AMD0030" ,0 }, {"AMDI0030" ,0 }, + {"AMDI0031" ,0 }, { }, };MODULE_DEVICE_TABLE (acpi, amd_gpio_acpi_match);
Greg Kroah-Hartman
maintainerPATCH 175/242 drm/amd/display: Reject non-zero src_y and src_x for video planes
In reply to Greg Kroah-HartmanFrom: Harry Wentland <[email protected]>
commit c6c6a712199ab355ce333fa5764a59506bb107c1 upstream.
[Why]
This hasn't been well tested and leads to complete system hangs on DCN1 based systems, possibly others.
The system hang can be reproduced by gesturing the video on the YouTube Android app on ChromeOS into full screen.
[How]
Reject atomic commits with non-zero drm_plane_state.src_x or src_y values.
v2:
- Add code comment describing the reason we're rejecting non-zero src_x and src_y
- Drop gerrit Change-Id
- Add stable CC
- Based on amd-staging-drm-next
v3: removed trailing whitespace
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +17 -0
@@ -3884,6 +3884,23 @@ static int fill_dc_scaling_info(const st scaling_info->src_rect.y != 0))return -EINVAL ; +/* +* For reasons we don't (yet) fully understand a non-zero +* src_y coordinate into an NV12 buffer can cause a +* system hang. To avoid hangs (and maybe be overly cautious) +* let's reject both non-zero src_x and src_y. +* +* We currently know of only one use-case to reproduce a +* scenario with non-zero src_x and src_y for NV12, which +* is to gesture the YouTube Android app into full screen +* on ChromeOS. +*/ +if (state->fb && + state->fb->format->format ==DRM_FORMAT_NV12 && + (scaling_info->src_rect.x !=0 || + scaling_info->src_rect.y !=0 )) +return -EINVAL ; + scaling_info->src_rect.width = state->src_w >>16 ;if (scaling_info->src_rect.width ==0 )return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 176/242 drm/ingenic: Fix pixclock rate for 24-bit serial panels
In reply to Greg Kroah-HartmanFrom: Paul Cercueil <[email protected]>
commit 60a6b73dd821e98fe958b2a83393ccd724b306b1 upstream.
When using a 24-bit panel on a 8-bit serial bus, the pixel clock requested by the panel has to be multiplied by 3, since the subpixels are shifted sequentially.
The code (in ingenic_drm_encoder_atomic_check) already computed crtc_state->adjusted_mode->crtc_clock accordingly, but clk_set_rate() used crtc_state->adjusted_mode->clock instead.
--- drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ingenic/ingenic-drm-drv.c +1 -1
@@ -341,7 +341,7 @@ static void ingenic_drm_crtc_atomic_flusif (priv->update_clk_rate) {mutex_lock (&priv->clk_mutex);clk_set_rate (priv->pix_clk, - crtc_state->adjusted_mode.clock *1000 ); + crtc_state->adjusted_mode.crtc_clock *1000 ); priv->update_clk_rate = false;mutex_unlock (&priv->clk_mutex); }
Greg Kroah-Hartman
maintainerPATCH 177/242 drm/tegra: Dont set allow_fb_modifiers explicitly
In reply to Greg Kroah-HartmanFrom: Daniel Vetter <[email protected]>
commit be4306ad928fcf736cbe2616b6dd19d91f1bc083 upstream.
Since
commit 890880ddfdbe256083170866e49c87618b706ac7
Author: Paul Kocialkowski <[email protected]> Date: Fri Jan 4 09:56:10 2019 +0100
drm: Auto-set allow_fb_modifiers when given modifiers at plane init
this is done automatically as part of plane init, if drivers set the modifier list correctly. Which is the case here.
It was slightly inconsistently though, since planes with only linear modifier support haven't listed that explicitly. Fix that, and cc:
stable to allow userspace to rely on this. Again don't backport further than where Paul's patch got added.
--- drivers/gpu/drm/tegra/dc.c | 10 ++++++++-- drivers/gpu/drm/tegra/drm.c | 2 -- 2 files changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/tegra/dc.c +8 -2
@@ -947,6 +947,11 @@ static const struct drm_plane_helper_fun .atomic_disable = tegra_cursor_atomic_disable, }; +static const uint64_t linear_modifiers[] = { +DRM_FORMAT_MOD_LINEAR , +DRM_FORMAT_MOD_INVALID +}; +static struct drm_plane *tegra_dc_cursor_plane_create (struct drm_device *drm,struct tegra_dc *dc) {
@@ -975,7 +980,7 @@ static struct drm_plane *tegra_dc_cursor err =drm_universal_plane_init (drm, &plane->base, possible_crtcs, &tegra_plane_funcs, formats, - num_formats,NULL , + num_formats, linear_modifiers,DRM_PLANE_TYPE_CURSOR ,NULL );if (err <0 ) {kfree (plane);
@@ -1094,7 +1099,8 @@ static struct drm_plane *tegra_dc_overla err =drm_universal_plane_init (drm, &plane->base, possible_crtcs, &tegra_plane_funcs, formats, - num_formats,NULL , type,NULL ); + num_formats, linear_modifiers, + type,NULL );if (err <0 ) {kfree (plane);return ERR_PTR (err);
drivers/gpu/drm/tegra/drm.c +0 -2
@@ -1122,8 +1122,6 @@ static int host1x_drm_probe(struct host1 drm->mode_config.max_width =4096 ; drm->mode_config.max_height =4096 ; - drm->mode_config.allow_fb_modifiers = true; - drm->mode_config.normalize_zpos = true; drm->mode_config.funcs = &tegra_drm_mode_config_funcs;
Greg Kroah-Hartman
maintainerPATCH 178/242 drm/msm/mdp4: Fix modifier support enabling
In reply to Greg Kroah-HartmanFrom: Daniel Vetter <[email protected]>
commit 35cbb8c91e9cf310277d3dfb4d046df8edf2df33 upstream.
Setting the cap without the modifier list is very confusing to userspace. Fix that by listing the ones we support explicitly.
Stable backport so that userspace can rely on this working in a reasonable way, i.e. that the cap set implies IN_FORMATS is available.
--- drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c | 2 -- drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c | 8 +++++++- 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c +0 -2
@@ -88,8 +88,6 @@ static int mdp4_hw_init(struct msm_kms *if (mdp4_kms->rev >1 )mdp4_write (mdp4_kms,REG_MDP4_RESET_STATUS ,1 ); - dev->mode_config.allow_fb_modifiers = true; - out:pm_runtime_put_sync (dev->dev);
drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c +7 -1
@@ -347,6 +347,12 @@ enum mdp4_pipe mdp4_plane_pipe(struct drreturn mdp4_plane->pipe; } +static const uint64_t supported_format_modifiers[] = { +DRM_FORMAT_MOD_SAMSUNG_64_32_TILE , +DRM_FORMAT_MOD_LINEAR , +DRM_FORMAT_MOD_INVALID +}; +/* initialize plane */ struct drm_plane *mdp4_plane_init (struct drm_device *dev,enum mdp4_pipe pipe_id,bool private_plane)
@@ -375,7 +381,7 @@ struct drm_plane *mdp4_plane_init(struct type = private_plane ?DRM_PLANE_TYPE_PRIMARY :DRM_PLANE_TYPE_OVERLAY ; ret =drm_universal_plane_init (dev, plane,0xff , &mdp4_plane_funcs, mdp4_plane->formats, mdp4_plane->nformats, -NULL , type,NULL ); + supported_format_modifiers, type,NULL );if (ret) goto fail;
Greg Kroah-Hartman
maintainerPATCH 179/242 drm/arm/malidp: Always list modifiers
In reply to Greg Kroah-HartmanFrom: Daniel Vetter <[email protected]>
commit 26c3e7fd5a3499e408915dadae5d5360790aae9a upstream.
Even when all we support is linear, make that explicit. Otherwise the uapi is rather confusing.
--- drivers/gpu/drm/arm/malidp_planes.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/arm/malidp_planes.c +7 -2
@@ -922,6 +922,11 @@ static const struct drm_plane_helper_fun .atomic_disable = malidp_de_plane_disable, }; +static const uint64_t linear_only_modifiers[] = { +DRM_FORMAT_MOD_LINEAR , +DRM_FORMAT_MOD_INVALID +}; +int malidp_de_planes_init (struct drm_device *drm) {struct malidp_drm *malidp = drm->dev_private;
@@ -985,8 +990,8 @@ int malidp_de_planes_init(struct drm_dev*/ ret =drm_universal_plane_init (drm, &plane->base, crtcs, &malidp_de_plane_funcs, formats, n, - (id ==DE_SMART ) ?NULL : modifiers, plane_type, -NULL ); + (id ==DE_SMART ) ? linear_only_modifiers : modifiers, + plane_type,NULL );if (ret <0 ) goto cleanup;
Greg Kroah-Hartman
maintainerPATCH 180/242 drm/nouveau: Dont set allow_fb_modifiers explicitly
In reply to Greg Kroah-HartmanFrom: Daniel Vetter <[email protected]>
commit cee93c028288b9af02919f3bd8593ba61d1e610d upstream.
Since
commit 890880ddfdbe256083170866e49c87618b706ac7
Author: Paul Kocialkowski <[email protected]> Date: Fri Jan 4 09:56:10 2019 +0100
drm: Auto-set allow_fb_modifiers when given modifiers at plane init
this is done automatically as part of plane init, if drivers set the modifier list correctly. Which is the case here.
Note that this fixes an inconsistency: We've set the cap everywhere, but only nv50+ supports modifiers. Hence cc stable, but not further back then the patch from Paul.
--- drivers/gpu/drm/nouveau/nouveau_display.c | 1 - 1 file changed, 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_display.c +0 -1
@@ -700,7 +700,6 @@ nouveau_display_create(struct drm_device dev->mode_config.preferred_depth =24 ; dev->mode_config.prefer_shadow =1 ; - dev->mode_config.allow_fb_modifiers = true;if (drm->client.device.info.chipset <0x11 ) dev->mode_config.async_page_flip = false;
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
Greg Kroah-Hartman
maintainerPATCH 181/242 drm/ingenic: Switch IPU plane to type OVERLAY
In reply to Greg Kroah-HartmanFrom: Paul Cercueil <[email protected]>
commit 68b433fe6937cfa3f8975d18643d5956254edd6a upstream.
It should have been an OVERLAY from the beginning. The documentation stipulates that there should be an unique PRIMARY plane per CRTC.
--- drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 11 +++++------ drivers/gpu/drm/ingenic/ingenic-ipu.c | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-)
drivers/gpu/drm/ingenic/ingenic-drm-drv.c +5 -6
@@ -413,7 +413,7 @@ static void ingenic_drm_plane_enable(strunsigned int en_bit;if (priv->soc_info->has_osd) { -if (plane->type ==DRM_PLANE_TYPE_PRIMARY ) +if (plane != &priv->f0) en_bit =JZ_LCD_OSDC_F1EN ;else en_bit =JZ_LCD_OSDC_F0EN ;
@@ -428,7 +428,7 @@ void ingenic_drm_plane_disable(struct deunsigned int en_bit;if (priv->soc_info->has_osd) { -if (plane->type ==DRM_PLANE_TYPE_PRIMARY ) +if (plane != &priv->f0) en_bit =JZ_LCD_OSDC_F1EN ;else en_bit =JZ_LCD_OSDC_F0EN ;
@@ -455,8 +455,7 @@ void ingenic_drm_plane_config(struct devingenic_drm_plane_enable (priv, plane); -if (priv->soc_info->has_osd && - plane->type ==DRM_PLANE_TYPE_PRIMARY ) { +if (priv->soc_info->has_osd && plane != &priv->f0) {switch (fourcc) {case DRM_FORMAT_XRGB1555 : ctrl |=JZ_LCD_OSDCTRL_RGB555 ;
@@ -504,7 +503,7 @@ void ingenic_drm_plane_config(struct dev }if (priv->soc_info->has_osd) { -if (plane->type ==DRM_PLANE_TYPE_PRIMARY ) { +if (plane != &priv->f0) { xy_reg =JZ_REG_LCD_XYP1 ; size_reg =JZ_REG_LCD_SIZE1 ; }else {
@@ -554,7 +553,7 @@ static void ingenic_drm_plane_atomic_upd height = state->src_h >>16 ; cpp = state->fb->format->cpp[0 ]; -if (!priv->soc_info->has_osd || plane->type ==DRM_PLANE_TYPE_OVERLAY ) +if (!priv->soc_info->has_osd || plane == &priv->f0) hwdesc = &priv->dma_hwdescs->hwdesc_f0;else hwdesc = &priv->dma_hwdescs->hwdesc_f1;
drivers/gpu/drm/ingenic/ingenic-ipu.c +1 -1
@@ -760,7 +760,7 @@ static int ingenic_ipu_bind(struct devic err =drm_universal_plane_init (drm, plane,1 , &ingenic_ipu_plane_funcs, soc_info->formats, soc_info->num_formats, -NULL ,DRM_PLANE_TYPE_PRIMARY ,NULL ); +NULL ,DRM_PLANE_TYPE_OVERLAY ,NULL );if (err) {dev_err (dev,"Failed to init plane: %i\n" , err);return err;
Greg Kroah-Hartman
maintainerPATCH 182/242 drm/i915/display: Do not zero past infoframes.vsc
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
commit 07b72960d2b4a087ff2445e286159e69742069cc upstream.
intel_dp_vsc_sdp_unpack() was using a memset() size (36, struct dp_sdp) larger than the destination (24, struct drm_dp_vsc_sdp), clobbering fields in struct intel_crtc_state after infoframes.vsc. Use the actual target size for the memset().
--- drivers/gpu/drm/i915/display/intel_dp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_dp.c +1 -1
@@ -3913,7 +3913,7 @@ static int intel_dp_vsc_sdp_unpack(strucif (size <sizeof (struct dp_sdp ))return -EINVAL ; -memset (vsc,0 , size); +memset (vsc,0 ,sizeof (*vsc));if (sdp->sdp_header.HB0 !=0 )return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 183/242 mmc: sdhci-acpi: Disable write protect detection on Toshiba Encore 2 WT8-B
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
commit 94ee6782e045645abd9180ab9369b01293d862bd upstream.
On the Toshiba Encore 2 WT8-B the microSD slot always reports the card being write-protected even though microSD cards do not have a write-protect switch at all.
Add a new DMI_QUIRK_SD_NO_WRITE_PROTECT quirk entry to sdhci-acpi.c's DMI quirk table for this.
--- drivers/mmc/host/sdhci-acpi.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/mmc/host/sdhci-acpi.c +11 -0
@@ -820,6 +820,17 @@ static const struct dmi_system_id sdhci_ }, .driver_data = (void *)DMI_QUIRK_SD_NO_WRITE_PROTECT, }, + { + /* + * The Toshiba WT8-B's microSD slot always reports the card being + * write-protected. + */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), + DMI_MATCH(DMI_PRODUCT_NAME, "TOSHIBA ENCORE 2 WT8-B"), + }, + .driver_data = (void *)DMI_QUIRK_SD_NO_WRITE_PROTECT, + }, {} /* Terminating entry */ };
Greg Kroah-Hartman
maintainerPATCH 184/242 mmc: sdhci: Fix warning message when accessing RPMB in HS400 mode
In reply to Greg Kroah-HartmanFrom: Al Cooper <[email protected]>
commit d0244847f9fc5e20df8b7483c8a4717fe0432d38 upstream.
When an eMMC device is being run in HS400 mode, any access to the RPMB device will cause the error message "mmc1: Invalid UHS-I mode selected". This happens as a result of tuning being disabled before RPMB access and then re-enabled after the RPMB access is complete. When tuning is re-enabled, the system has to switch from HS400 to HS200 to do the tuning and then back to HS400. As part of sequence to switch from HS400 to HS200 the system is temporarily put into HS mode. When switching to HS mode, sdhci_get_preset_value() is called and does not have support for HS mode and prints the warning message and returns the preset for SDR12. The fix is to add support for MMC and SD HS modes to sdhci_get_preset_value().
This can be reproduced on any system running eMMC in HS400 mode (not HS400ES) by using the "mmc" utility to run the following
command: "mmc rpmb read-counter /dev/mmcblk0rpmb".
--- drivers/mmc/host/sdhci.c | 4 ++++ drivers/mmc/host/sdhci.h | 1 + 2 files changed, 5 insertions(+)
drivers/mmc/host/sdhci.c +4 -0
@@ -1812,6 +1812,10 @@ static u16 sdhci_get_preset_value(structu16 preset =0 ;switch (host->timing) { +case MMC_TIMING_MMC_HS : +case MMC_TIMING_SD_HS : + preset =sdhci_readw (host,SDHCI_PRESET_FOR_HIGH_SPEED ); +break ;case MMC_TIMING_UHS_SDR12 : preset =sdhci_readw (host,SDHCI_PRESET_FOR_SDR12 );break ;
drivers/mmc/host/sdhci.h +1 -0
@@ -253,6 +253,7 @@/* 60-FB reserved */ +#define SDHCI_PRESET_FOR_HIGH_SPEED 0x64#define SDHCI_PRESET_FOR_SDR12 0x66#define SDHCI_PRESET_FOR_SDR25 0x68#define SDHCI_PRESET_FOR_SDR50 0x6A
Greg Kroah-Hartman
maintainerPATCH 185/242 mmc: core: clear flags before allowing to retune
In reply to Greg Kroah-HartmanFrom: Wolfram Sang <[email protected]>
commit 77347eda64ed5c9383961d1de9165f9d0b7d8df6 upstream.
It might be that something goes wrong during tuning so the MMC core will immediately trigger a retune. In our case it was:
- we sent a tuning block
- there was an error so we need to send an abort cmd to the eMMC
- the abort cmd had a CRC error
- retune was set by the MMC core
This lead to a vicious circle causing a performance regression of 75%. So, clear retuning flags before we enable retuning to start with a known cleared state.
Reported-by Yoshihiro Shimoda <[email protected]>
--- drivers/mmc/core/core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/mmc/core/core.c +5 -2
@@ -937,11 +937,14 @@ int mmc_execute_tuning(struct mmc_card * err = host->ops->execute_tuning (host, opcode); -if (err) +if (err) {pr_err ("%s: tuning execution failed: %d\n" ,mmc_hostname (host), err); -else + }else { + host->retune_now =0 ; + host->need_retune =0 ;mmc_retune_enable (host); + }return err; }
Greg Kroah-Hartman
maintainerPATCH 186/242 mmc: core: Allow UHS-I voltage switch for SDSC cards if supported
In reply to Greg Kroah-HartmanFrom: Christian Löhle <[email protected]>
commit 09247e110b2efce3a104e57e887c373e0a57a412 upstream.
While initializing an UHS-I SD card, the mmc core first tries to switch to 1.8V I/O voltage, before it continues to change the settings for the bus speed mode.
However, the current behaviour in the mmc core is inconsistent and doesn't conform to the SD spec. More precisely, an SD card that supports UHS-I must set both the SD_OCR_CCS bit and the SD_OCR_S18R bit in the OCR register response. When switching to 1.8V I/O the mmc core correctly checks both of the bits, but only the SD_OCR_S18R bit when changing the settings for bus speed mode.
Rather than actually fixing the code to confirm to the SD spec, let's deliberately deviate from it by requiring only the SD_OCR_S18R bit for both parts. This enables us to support UHS-I for SDSC cards (outside spec), which is actually being supported by some existing SDSC cards. Moreover, this fixes the inconsistent behaviour.
--- drivers/mmc/core/sd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/mmc/core/sd.c +6 -4
@@ -847,11 +847,13 @@ try_again:return err;/* -* In case CCS and S18A in the response is set, start Signal Voltage -* Switch procedure. SPI mode doesn't support CMD11. +* In case the S18A bit is set in the response, let's start the signal +* voltage switch procedure. SPI mode doesn't support CMD11. +* Note that, according to the spec, the S18A bit is not valid unless +* the CCS bit is set as well. We deliberately deviate from the spec in +* regards to this, which allows UHS-I to be supported for SDSC cards. */ -if (!mmc_host_is_spi (host) && rocr && - ((*rocr &0x41000000 ) ==0x41000000 )) { +if (!mmc_host_is_spi (host) && rocr && (*rocr &0x01000000 )) { err =mmc_set_uhs_voltage (host, pocr);if (err == -EAGAIN ) { retries--;
Greg Kroah-Hartman
maintainerPATCH 187/242 docs: Makefile: Use CONFIG_SHELL not SHELL
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
commit 222a28edce38b62074a950fb243df621c602b4d3 upstream.
Fix think-o about which variable to find the Kbuild-configured shell. This has accidentally worked due to most shells setting $SHELL by default.
--- Documentation/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/Makefile +1 -1
@@ -76,7 +76,7 @@ quiet_cmd_sphinx = SPHINX $@ --> file:/ PYTHONDONTWRITEBYTECODE=1 \ BUILDDIR=$(abspath $(BUILDDIR)) SPHINX_CONF=$(abspath $(srctree)/$(src)/$5/$(SPHINX_CONF)) \ $(PYTHON3) $(srctree)/scripts/jobserver-exec \ - $(SHELL) $(srctree)/Documentation/sphinx/parallel-wrapper.sh \ + $(CONFIG_SHELL) $(srctree)/Documentation/sphinx/parallel-wrapper.sh \ $(SPHINXBUILD) \ -b $2 \ -c $(abspath $(srctree)/$(src)) \
Greg Kroah-Hartman
maintainerPATCH 188/242 ata: ahci_sunxi: Disable DIPM
In reply to Greg Kroah-HartmanFrom: Timo Sigurdsson <[email protected]>
commit f6bca4d91b2ea052e917cca3f9d866b5cc1d500a upstream.
DIPM is unsupported or broken on sunxi. Trying to enable the power management policy med_power_with_dipm on an Allwinner A20 SoC based board leads to immediate I/O errors and the attached SATA disk disappears from the /dev filesystem. A reset (power cycle) is required to make the SATA controller or disk work again. The A10 and A20 SoC data sheets and manuals don't mention DIPM at all [1], so it's fair to assume that it's simply not supported. But even if it was, it should be considered broken and best be disabled in the ahci_sunxi driver.
[1] https://github.com/allwinner-zh/documents/tree/master/
--- drivers/ata/ahci_sunxi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/ahci_sunxi.c +1 -1
@@ -200,7 +200,7 @@ static void ahci_sunxi_start_engine(stru }static const struct ata_port_info ahci_sunxi_port_info = { - .flags =AHCI_FLAG_COMMON |ATA_FLAG_NCQ , + .flags =AHCI_FLAG_COMMON |ATA_FLAG_NCQ |ATA_FLAG_NO_DIPM , .pio_mask =ATA_PIO4 , .udma_mask =ATA_UDMA6 , .port_ops = &ahci_platform_ops,
Greg Kroah-Hartman
maintainerPATCH 189/242 arm64: tlb: fix the TTL value of tlb_get_level
In reply to Greg Kroah-HartmanFrom: Zhenyu Ye <[email protected]>
commit 52218fcd61cb42bde0d301db4acb3ffdf3463cc7 upstream.
The TTL field indicates the level of page table walk holding the *leaf* entry for the address being invalidated. But currently, the TTL field may be set to an incorrent value in the following stack:
pte_free_tlb
__pte_free_tlb
tlb_remove_table
tlb_table_invalidate
tlb_flush_mmu_tlbonly
tlb_flushIn this case, we just want to flush a PTE page, but the tlb->cleared_pmds is set and we get tlb_level = 2 in the tlb_get_level() function. This may cause some unexpected problems.
This patch set the TTL field to 0 if tlb->freed_tables is set. The tlb->freed_tables indicates page table pages are freed, not the leaf entry.
--- arch/arm64/include/asm/tlb.h | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/include/asm/tlb.h +4 -0
@@ -28,6 +28,10 @@ static void tlb_flush(struct mmu_gather*/ static inline int tlb_get_level (struct mmu_gather *tlb) { +/* The TTL field is only valid for the leaf entry. */ +if (tlb->freed_tables) +return 0 ; +if (tlb->cleared_ptes && !(tlb->cleared_pmds || tlb->cleared_puds || tlb->cleared_p4ds))
Greg Kroah-Hartman
maintainerPATCH 190/242 cpu/hotplug: Cure the cpusets trainwreck
In reply to Greg Kroah-HartmanFrom: Thomas Gleixner <[email protected]>
commit b22afcdf04c96ca58327784e280e10288cfd3303 upstream.
Alexey and Joshua tried to solve a cpusets related hotplug problem which is user space visible and results in unexpected behaviour for some time after a CPU has been plugged in and the corresponding uevent was delivered.
cpusets delegate the hotplug work (rebuilding cpumasks etc.) to a workqueue. This is done because the cpusets code has already a lock nesting of cgroups_mutex -> cpu_hotplug_lock. A synchronous callback or waiting for the work to finish with cpu_hotplug_lock held can and will deadlock because that results in the reverse lock order.
As a consequence the uevent can be delivered before cpusets have consistent state which means that a user space invocation of sched_setaffinity() to move a task to the plugged CPU fails up to the point where the scheduled work has been processed.
The same is true for CPU unplug, but that does not create user observable failure (yet).
It's still inconsistent to claim that an operation is finished before it actually is and that's the real issue at hand. uevents just make it reliably observable.
Obviously the problem should be fixed in cpusets/cgroups, but untangling that is pretty much impossible because according to the changelog of the commit which introduced this 8 years ago:
3a5a6d0c2b03("cpuset: don't nest cgroup_mutex inside get_online_cpus()")
the lock order cgroups_mutex -> cpu_hotplug_lock is a design decision and the whole code is built around that.
So bite the bullet and invoke the relevant cpuset function, which waits for the work to finish, in _cpu_up/down() after dropping cpu_hotplug_lock and only when tasks are not frozen by suspend/hibernate because that would obviously wait forever.
Waiting there with cpu_add_remove_lock, which is protecting the present and possible CPU maps, held is not a problem at all because neither work queues nor cpusets/cgroups have any lockchains related to that lock.
Waiting in the hotplug machinery is not problematic either because there are already state callbacks which wait for hardware queues to drain. It makes the operations slightly slower, but hotplug is slow anyway.
This ensures that state is consistent before returning from a hotplug up/down operation. It's still inconsistent during the operation, but that's a different story.
Add a large comment which explains why this is done and why this is not a dump ground for the hack of the day to work around half thought out locking schemes. Document also the implications vs. hotplug operations and serialization or the lack of it.
Thanks to Alexy and Joshua for analyzing why this temporary sched_setaffinity() failure happened.
--- kernel/cpu.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
kernel/cpu.c +49 -0
@@ -32,6 +32,7 @@#include <linux/relay.h> #include <linux/slab.h> #include <linux/percpu-rwsem.h> +#include <linux/cpuset.h> #include <trace/events/power.h> #define CREATE_TRACE_POINTS
@@ -821,6 +822,52 @@ void __init cpuhp_threads_init(void)kthread_unpark (this_cpu_read (cpuhp_state.thread)); } +/* +* +* Serialize hotplug trainwrecks outside of the cpu_hotplug_lock +* protected region. +* +* The operation is still serialized against concurrent CPU hotplug via +* cpu_add_remove_lock, i.e. CPU map protection. But it is _not_ +* serialized against other hotplug related activity like adding or +* removing of state callbacks and state instances, which invoke either the +* startup or the teardown callback of the affected state. +* +* This is required for subsystems which are unfixable vs. CPU hotplug and +* evade lock inversion problems by scheduling work which has to be +* completed _before_ cpu_up()/_cpu_down() returns. +* +* Don't even think about adding anything to this for any new code or even +* drivers. It's only purpose is to keep existing lock order trainwrecks +* working. +* +* For cpu_down() there might be valid reasons to finish cleanups which are +* not required to be done under cpu_hotplug_lock, but that's a different +* story and would be not invoked via this. +*/ +static void cpu_up_down_serialize_trainwrecks (bool tasks_frozen) +{ +/* +* cpusets delegate hotplug operations to a worker to "solve" the +* lock order problems. Wait for the worker, but only if tasks are +* _not_ frozen (suspend, hibernate) as that would wait forever. +* +* The wait is required because otherwise the hotplug operation +* returns with inconsistent state, which could even be observed in +* user space when a new CPU is brought up. The CPU plug uevent +* would be delivered and user space reacting on it would fail to +* move tasks to the newly plugged CPU up to the point where the +* work has finished because up to that point the newly plugged CPU +* is not assignable in cpusets/cgroups. On unplug that's not +* necessarily a visible issue, but it is still inconsistent state, +* which is the real problem which needs to be "fixed". This can't +* prevent the transient state between scheduling the work and +* returning from waiting for it. +*/ +if (!tasks_frozen) +cpuset_wait_for_hotplug (); +} +#ifdef CONFIG_HOTPLUG_CPU #ifndef arch_clear_mm_cpumask_cpu#define arch_clear_mm_cpumask_cpu (cpu, mm) cpumask_clear_cpu(cpu, mm_cpumask(mm))
@@ -1058,6 +1105,7 @@ out:*/ lockup_detector_cleanup ();arch_smt_update (); +cpu_up_down_serialize_trainwrecks (tasks_frozen);return ret; }
@@ -1254,6 +1302,7 @@ static int _cpu_up(unsigned int cpu, int out:cpus_write_unlock ();arch_smt_update (); +cpu_up_down_serialize_trainwrecks (tasks_frozen);return ret; }
Greg Kroah-Hartman
maintainerPATCH 191/242 clocksource/arm_arch_timer: Improve Allwinner A64 timer workaround
In reply to Greg Kroah-HartmanFrom: Samuel Holland <[email protected]>
commit 8b33dfe0ba1c84c1aab2456590b38195837f1e6e upstream.
Bad counter reads are experienced sometimes when bit 10 or greater rolls over. Originally, testing showed that at least 10 lower bits would be set to the same value during these bad reads. However, some users still reported time skips.
Wider testing revealed that on some chips, occasionally only the lowest 9 bits would read as the anomalous value. During these reads (which still happen only when bit 10), bit 9 would read as the correct value.
Reduce the mask by one bit to cover these cases as well.
--- drivers/clocksource/arm_arch_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/arm_arch_timer.c +1 -1
@@ -352,7 +352,7 @@ static u64 notrace arm64_858921_read_cntdo { \ _val =read_sysreg (reg); \ _retries--; \ - }while (((_val +1 ) &GENMASK (9 ,0 )) <=1 && _retries); \ + }while (((_val +1 ) &GENMASK (8 ,0 )) <=1 && _retries); \ \WARN_ON_ONCE (!_retries); \ _val; \
Greg Kroah-Hartman
maintainerPATCH 192/242 fpga: stratix10-soc: Add missing fpga_mgr_free() call
In reply to Greg Kroah-HartmanFrom: Russ Weight <[email protected]>
commit d9ec9daa20eb8de1efe6abae78c9835ec8ed86f9 upstream.
The stratix10-soc driver uses fpga_mgr_create() function and is therefore responsible to call fpga_mgr_free() to release the class driver resources. Add a missing call to fpga_mgr_free in the s10_remove() function.
--- drivers/fpga/stratix10-soc.c | 1 + 1 file changed, 1 insertion(+)
drivers/fpga/stratix10-soc.c +1 -0
@@ -454,6 +454,7 @@ static int s10_remove(struct platform_destruct s10_priv *priv = mgr->priv;fpga_mgr_unregister (mgr); +fpga_mgr_free (mgr);stratix10_svc_free_channel (priv->chan);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 193/242 ASoC: tegra: Set driver_name=tegra for all machine drivers
In reply to Greg Kroah-HartmanFrom: Dmitry Osipenko <[email protected]>
commit f6eb84fa596abf28959fc7e0b626f925eb1196c7 upstream.
The driver_name="tegra" is now required by the newer ALSA UCMs, otherwise Tegra UCMs don't match by the path/name.
All Tegra machine drivers are specifying the card's name, but it has no effect if model name is specified in the device-tree since it overrides the card's name. We need to set the driver_name to "tegra" in order to get a usable lookup path for the updated ALSA UCMs. The new UCM lookup path has a form of driver_name/card_name.
The old lookup paths that are based on driver module name continue to work as before. Note that UCM matching never worked for Tegra ASoC drivers if they were compiled as built-in, this is fixed by supporting the new naming scheme.
--- sound/soc/tegra/tegra_alc5632.c | 1 + sound/soc/tegra/tegra_max98090.c | 1 + sound/soc/tegra/tegra_rt5640.c | 1 + sound/soc/tegra/tegra_rt5677.c | 1 + sound/soc/tegra/tegra_sgtl5000.c | 1 + sound/soc/tegra/tegra_wm8753.c | 1 + sound/soc/tegra/tegra_wm8903.c | 1 + sound/soc/tegra/tegra_wm9712.c | 1 + sound/soc/tegra/trimslice.c | 1 + 9 files changed, 9 insertions(+)
sound/soc/tegra/tegra_alc5632.c +1 -0
@@ -139,6 +139,7 @@ static struct snd_soc_dai_link tegra_alcstatic struct snd_soc_card snd_soc_tegra_alc5632 = { .name ="tegra-alc5632" , + .driver_name ="tegra" , .owner =THIS_MODULE , .dai_link = &tegra_alc5632_dai, .num_links =1 ,
sound/soc/tegra/tegra_max98090.c +1 -0
@@ -182,6 +182,7 @@ static struct snd_soc_dai_link tegra_maxstatic struct snd_soc_card snd_soc_tegra_max98090 = { .name ="tegra-max98090" , + .driver_name ="tegra" , .owner =THIS_MODULE , .dai_link = &tegra_max98090_dai, .num_links =1 ,
sound/soc/tegra/tegra_rt5640.c +1 -0
@@ -132,6 +132,7 @@ static struct snd_soc_dai_link tegra_rt5static struct snd_soc_card snd_soc_tegra_rt5640 = { .name ="tegra-rt5640" , + .driver_name ="tegra" , .owner =THIS_MODULE , .dai_link = &tegra_rt5640_dai, .num_links =1 ,
sound/soc/tegra/tegra_rt5677.c +1 -0
@@ -175,6 +175,7 @@ static struct snd_soc_dai_link tegra_rt5static struct snd_soc_card snd_soc_tegra_rt5677 = { .name ="tegra-rt5677" , + .driver_name ="tegra" , .owner =THIS_MODULE , .dai_link = &tegra_rt5677_dai, .num_links =1 ,
sound/soc/tegra/tegra_sgtl5000.c +1 -0
@@ -97,6 +97,7 @@ static struct snd_soc_dai_link tegra_sgtstatic struct snd_soc_card snd_soc_tegra_sgtl5000 = { .name ="tegra-sgtl5000" , + .driver_name ="tegra" , .owner =THIS_MODULE , .dai_link = &tegra_sgtl5000_dai, .num_links =1 ,
sound/soc/tegra/tegra_wm8753.c +1 -0
@@ -101,6 +101,7 @@ static struct snd_soc_dai_link tegra_wm8static struct snd_soc_card snd_soc_tegra_wm8753 = { .name ="tegra-wm8753" , + .driver_name ="tegra" , .owner =THIS_MODULE , .dai_link = &tegra_wm8753_dai, .num_links =1 ,
sound/soc/tegra/tegra_wm8903.c +1 -0
@@ -235,6 +235,7 @@ static struct snd_soc_dai_link tegra_wm8static struct snd_soc_card snd_soc_tegra_wm8903 = { .name ="tegra-wm8903" , + .driver_name ="tegra" , .owner =THIS_MODULE , .dai_link = &tegra_wm8903_dai, .num_links =1 ,
sound/soc/tegra/tegra_wm9712.c +1 -0
@@ -54,6 +54,7 @@ static struct snd_soc_dai_link tegra_wm9static struct snd_soc_card snd_soc_tegra_wm9712 = { .name ="tegra-wm9712" , + .driver_name ="tegra" , .owner =THIS_MODULE , .dai_link = &tegra_wm9712_dai, .num_links =1 ,
sound/soc/tegra/trimslice.c +1 -0
@@ -94,6 +94,7 @@ static struct snd_soc_dai_link trimslicestatic struct snd_soc_card snd_soc_trimslice = { .name ="tegra-trimslice" , + .driver_name ="tegra" , .owner =THIS_MODULE , .dai_link = &trimslice_tlv320aic23_dai, .num_links =1 ,
Greg Kroah-Hartman
maintainerPATCH 194/242 mwifiex: bring down link before deleting interface
In reply to Greg Kroah-HartmanFrom: Brian Norris <[email protected]>
commit 1f9482aa8d412b4ba06ce6ab8e333fb8ca29a06e upstream.
We can deadlock when rmmod'ing the driver or going through firmware reset, because the cfg80211_unregister_wdev() has to bring down the link for us, ... which then grab the same wiphy lock.
nl80211_del_interface() already handles a very similar case, with a nice description:
/*
* We hold RTNL, so this is safe, without RTNL opencount cannot
* reach 0, and thus the rdev cannot be deleted.
*
* We need to do it for the dev_close(), since that will call
* the netdev notifiers, and we need to acquire the mutex there
* but don't know if we get there from here or from some other
* place (e.g. "ip link set ... down").
*/
mutex_unlock(&rdev->wiphy.mtx);
...
Do similarly for mwifiex teardown, by ensuring we bring the link down first.
Sample deadlock trace:
[ 247.103516] INFO: task rmmod:2119 blocked for more than 123 seconds. [ 247.110630] Not tainted 5.12.4 #5 [ 247.115796] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [ 247.124557] task:rmmod state:D stack: 0 pid: 2119 ppid: 2114 flags:0x00400208 [ 247.133905] Call trace: [ 247.136644] __switch_to+0x130/0x170 [ 247.140643] __schedule+0x714/0xa0c [ 247.144548] schedule_preempt_disabled+0x88/0xf4 [ 247.149714] __mutex_lock_common+0x43c/0x750 [ 247.154496] mutex_lock_nested+0x5c/0x68 [ 247.158884] cfg80211_netdev_notifier_call+0x280/0x4e0 [cfg80211] [ 247.165769] raw_notifier_call_chain+0x4c/0x78 [ 247.170742] call_netdevice_notifiers_info+0x68/0xa4 [ 247.176305] __dev_close_many+0x7c/0x138 [ 247.180693] dev_close_many+0x7c/0x10c [ 247.184893] unregister_netdevice_many+0xfc/0x654 [ 247.190158] unregister_netdevice_queue+0xb4/0xe0 [ 247.195424] _cfg80211_unregister_wdev+0xa4/0x204 [cfg80211] [ 247.201816] cfg80211_unregister_wdev+0x20/0x2c [cfg80211] [ 247.208016] mwifiex_del_virtual_intf+0xc8/0x188 [mwifiex] [ 247.214174] mwifiex_uninit_sw+0x158/0x1b0 [mwifiex] [ 247.219747] mwifiex_remove_card+0x38/0xa0 [mwifiex] [ 247.225316] mwifiex_pcie_remove+0xd0/0xe0 [mwifiex_pcie] [ 247.231451] pci_device_remove+0x50/0xe0 [ 247.235849] device_release_driver_internal+0x110/0x1b0 [ 247.241701] driver_detach+0x5c/0x9c [ 247.245704] bus_remove_driver+0x84/0xb8 [ 247.250095] driver_unregister+0x3c/0x60 [ 247.254486] pci_unregister_driver+0x2c/0x90 [ 247.259267] cleanup_module+0x18/0xcdc [mwifiex_pcie]
--- drivers/net/wireless/marvell/mwifiex/main.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/net/wireless/marvell/mwifiex/main.c +10 -3
@@ -1445,11 +1445,18 @@ static void mwifiex_uninit_sw(struct mwiif (!priv)continue ;rtnl_lock (); -wiphy_lock (adapter->wiphy);if (priv->netdev && - priv->wdev.iftype !=NL80211_IFTYPE_UNSPECIFIED ) + priv->wdev.iftype !=NL80211_IFTYPE_UNSPECIFIED ) { +/* +* Close the netdev now, because if we do it later, the +* netdev notifiers will need to acquire the wiphy lock +* again --> deadlock. +*/ +dev_close (priv->wdev.netdev); +wiphy_lock (adapter->wiphy);mwifiex_del_virtual_intf (adapter->wiphy, &priv->wdev); -wiphy_unlock (adapter->wiphy); +wiphy_unlock (adapter->wiphy); + }rtnl_unlock (); }
Greg Kroah-Hartman
maintainerPATCH 195/242 i40e: fix PTP on 5Gb links
In reply to Greg Kroah-HartmanFrom: Jesse Brandeburg <[email protected]>
commit 26b0ce8dd3dd704393dbace4dc416adfeffe531f upstream.
As reported by Alex Sergeev, the i40e driver is incrementing the PTP clock at 40Gb speeds when linked at 5Gb. Fix this bug by making sure that the right multiplier is selected when linked at 5Gb.
--- drivers/net/ethernet/intel/i40e/i40e_ptp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_ptp.c +6 -2
@@ -11,13 +11,14 @@* operate with the nanosecond field directly without fear of overflow. * * Much like the 82599, the update period is dependent upon the link speed: -* At 40Gb link or no link, the period is 1.6ns. -* At 10Gb link, the period is multiplied by 2. (3.2ns) +* At 40Gb, 25Gb, or no link, the period is 1.6ns. +* At 10Gb or 5Gb link, the period is multiplied by 2. (3.2ns) * At 1Gb link, the period is multiplied by 20. (32ns) * 1588 functionality is not supported at 100Mbps. */ #define I40E_PTP_40GB_INCVAL 0x0199999999ULL#define I40E_PTP_10GB_INCVAL_MULT 2 +#define I40E_PTP_5GB_INCVAL_MULT 2#define I40E_PTP_1GB_INCVAL_MULT 20#define I40E_PRTTSYN_CTL1_TSYNTYPE_V1 BIT(I40E_PRTTSYN_CTL1_TSYNTYPE_SHIFT)
@@ -465,6 +466,9 @@ void i40e_ptp_set_increment(struct i40e_case I40E_LINK_SPEED_10GB : mult =I40E_PTP_10GB_INCVAL_MULT ;break ; +case I40E_LINK_SPEED_5GB : + mult =I40E_PTP_5GB_INCVAL_MULT ; +break ;case I40E_LINK_SPEED_1GB : mult =I40E_PTP_1GB_INCVAL_MULT ;break ;
Greg Kroah-Hartman
maintainerPATCH 196/242 qemu_fw_cfg: Make fw_cfg_rev_attr a proper kobj_attribute
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit fca41af18e10318e4de090db47d9fa7169e1bf2f upstream.
fw_cfg_showrev() is called by an indirect call in kobj_attr_show(), which violates clang's CFI checking because fw_cfg_showrev()'s second parameter is 'struct attribute', whereas the ->show() member of 'struct kobj_structure' expects the second parameter to be of type 'struct kobj_attribute'.
$ cat /sys/firmware/qemu_fw_cfg/rev 3
$ dmesg | grep "CFI failure" [ 26.016832] CFI failure (target: fw_cfg_showrev+0x0/0x8):
Fix this by converting fw_cfg_rev_attr to 'struct kobj_attribute' where this would have been caught automatically by the incompatible pointer types compiler warning. Update fw_cfg_showrev() accordingly.
--- drivers/firmware/qemu_fw_cfg.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/firmware/qemu_fw_cfg.c +3 -5
@@ -299,15 +299,13 @@ static int fw_cfg_do_platform_probe(strureturn 0 ; } -static ssize_t fw_cfg_showrev (struct kobject *k,struct attribute *a,char *buf) +static ssize_t fw_cfg_showrev (struct kobject *k,struct kobj_attribute *a, +char *buf) {return sprintf (buf,"%u\n" , fw_cfg_rev); } -static const struct { -struct attribute attr; -ssize_t (*show)(struct kobject *k,struct attribute *a,char *buf); -} fw_cfg_rev_attr = { +static const struct kobj_attribute fw_cfg_rev_attr = { .attr = { .name ="rev" , .mode =S_IRUSR }, .show = fw_cfg_showrev, };
Greg Kroah-Hartman
maintainerPATCH 197/242 ipmi/watchdog: Stop watchdog timer when the current action is none
In reply to Greg Kroah-HartmanFrom: Petr Pavlu <[email protected]>
commit 2253042d86f57d90a621ac2513a7a7a13afcf809 upstream.
When an IPMI watchdog timer is being stopped in ipmi_close() or ipmi_ioctl(WDIOS_DISABLECARD), the current watchdog action is updated to WDOG_TIMEOUT_NONE and _ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB) is called to install this action. The latter function ends up invoking __ipmi_set_timeout() which makes the actual 'Set Watchdog Timer' IPMI request.
For IPMI 1.0, this operation results in fully stopping the watchdog timer. For IPMI >= 1.5, function __ipmi_set_timeout() always specifies the "don't stop" flag in the prepared 'Set Watchdog Timer' IPMI request. This causes that the watchdog timer has its action correctly updated to 'none' but the timer continues to run. A problem is that IPMI firmware can then still log an expiration event when the configured timeout is reached, which is unexpected because the watchdog timer was requested to be stopped.
The patch fixes this problem by not setting the "don't stop" flag in __ipmi_set_timeout() when the current action is WDOG_TIMEOUT_NONE which results in stopping the watchdog timer. This makes the behaviour for IPMI >= 1.5 consistent with IPMI 1.0. It also matches the logic in __ipmi_heartbeat() which does not allow to reset the watchdog if the current action is WDOG_TIMEOUT_NONE as that would start the timer.
Message-Id: <[email protected]>
--- drivers/char/ipmi/ipmi_watchdog.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/char/ipmi/ipmi_watchdog.c +12 -10
@@ -371,16 +371,18 @@ static int __ipmi_set_timeout(struct ipm data[0 ] =0 ;WDOG_SET_TIMER_USE (data[0 ],WDOG_TIMER_USE_SMS_OS ); -if ((ipmi_version_major >1 ) - || ((ipmi_version_major ==1 ) && (ipmi_version_minor >=5 ))) { -/* This is an IPMI 1.5-only feature. */ - data[0 ] |=WDOG_DONT_STOP_ON_SET ; - }else if (ipmi_watchdog_state !=WDOG_TIMEOUT_NONE ) { -/* -* In ipmi 1.0, setting the timer stops the watchdog, we -* need to start it back up again. -*/ - hbnow =1 ; +if (ipmi_watchdog_state !=WDOG_TIMEOUT_NONE ) { +if ((ipmi_version_major >1 ) || + ((ipmi_version_major ==1 ) && (ipmi_version_minor >=5 ))) { +/* This is an IPMI 1.5-only feature. */ + data[0 ] |=WDOG_DONT_STOP_ON_SET ; + }else { +/* +* In ipmi 1.0, setting the timer stops the watchdog, we +* need to start it back up again. +*/ + hbnow =1 ; + } } data[1 ] =0 ;
Greg Kroah-Hartman
maintainerPATCH 198/242 xfrm: policy: Read seqcount outside of rcu-read side in xfrm_policy_lookup_bytype
In reply to Greg Kroah-HartmanFrom: Varad Gautam <[email protected]>
commit d7b0408934c749f546b01f2b33d07421a49b6f3e upstream.
xfrm_policy_lookup_bytype loops on seqcount mutex xfrm_policy_hash_generation within an RCU read side critical section. Although ill advised, this is fine if the loop is bounded.
xfrm_policy_hash_generation wraps mutex hash_resize_mutex, which is used to serialize writers (xfrm_hash_resize, xfrm_hash_rebuild). This is fine too.
On PREEMPT_RT=y, the read_seqcount_begin call within xfrm_policy_lookup_bytype emits a mutex lock/unlock for hash_resize_mutex. Mutex locking is fine, since RCU read side critical sections are allowed to sleep with PREEMPT_RT.
xfrm_hash_resize can, however, block on synchronize_rcu while holding hash_resize_mutex.
This leads to the following situation on PREEMPT_RT, where the writer is blocked on RCU grace period expiry, while the reader is blocked on a lock held by the writer:
Thead 1 (xfrm_hash_resize) Thread 2 (xfrm_policy_lookup_bytype)
rcu_read_lock(); mutex_lock(&hash_resize_mutex); read_seqcount_begin(&xfrm_policy_hash_generation); mutex_lock(&hash_resize_mutex); // block
xfrm_bydst_resize();synchronize_rcu(); // block
<RCU stalls in xfrm_policy_lookup_bytype>
Move the read_seqcount_begin call outside of the RCU read side critical section, and do an rcu_read_unlock/retry if we got stale data within the critical section.
On non-PREEMPT_RT, this shortens the time spent within RCU read side critical section in case the seqcount needs a retry, and avoids unbounded looping.
--- net/xfrm/xfrm_policy.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
net/xfrm/xfrm_policy.c +14 -7
@@ -2092,12 +2092,15 @@ static struct xfrm_policy *xfrm_policy_lif (unlikely (!daddr || !saddr))return NULL ; -rcu_read_lock (); retry: -do { - sequence =read_seqcount_begin (&xfrm_policy_hash_generation); - chain =policy_hash_direct (net, daddr, saddr, family, dir); - }while (read_seqcount_retry (&xfrm_policy_hash_generation, sequence)); + sequence =read_seqcount_begin (&xfrm_policy_hash_generation); +rcu_read_lock (); + + chain =policy_hash_direct (net, daddr, saddr, family, dir); +if (read_seqcount_retry (&xfrm_policy_hash_generation, sequence)) { +rcu_read_unlock (); + goto retry; + } ret =NULL ;hlist_for_each_entry_rcu (pol, chain, bydst) {
@@ -2128,11 +2131,15 @@ static struct xfrm_policy *xfrm_policy_l } skip_inexact: -if (read_seqcount_retry (&xfrm_policy_hash_generation, sequence)) +if (read_seqcount_retry (&xfrm_policy_hash_generation, sequence)) { +rcu_read_unlock (); goto retry; + } -if (ret && !xfrm_pol_hold_rcu (ret)) +if (ret && !xfrm_pol_hold_rcu (ret)) { +rcu_read_unlock (); goto retry; + } fail:rcu_read_unlock ();
Greg Kroah-Hartman
maintainerPATCH 199/242 thermal/drivers/int340x/processor_thermal: Fix tcc setting
In reply to Greg Kroah-HartmanFrom: Srinivas Pandruvada <[email protected]>
commit fe6a6de6692e7f7159c1ff42b07ecd737df712b4 upstream.
The following fixes are done for tcc sysfs interface:
- TCC is 6 bits only from bit 29-24
- TCC of 0 is valid
- When BIT(31) is set, this register is read only
- Check for invalid tcc value
- Error for negative values
--- drivers/thermal/intel/int340x_thermal/processor_thermal_device.c | 20 ++++++---- 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/thermal/intel/int340x_thermal/processor_thermal_device.c +12 -8
@@ -100,24 +100,27 @@ static ssize_t tcc_offset_degree_celsiusif (err)return err; - val = (val >>24 ) &0xff ; + val = (val >>24 ) &0x3f ;return sprintf (buf,"%d\n" , (int )val); } -static int tcc_offset_update (int tcc) +static int tcc_offset_update (unsigned int tcc) {u64 val;int err; -if (!tcc) +if (tcc >63 )return -EINVAL ; err =rdmsrl_safe (MSR_IA32_TEMPERATURE_TARGET , &val);if (err)return err; - val &= ~GENMASK_ULL (31 ,24 ); - val |= (tcc &0xff ) <<24 ; +if (val &BIT (31 )) +return -EPERM ; + + val &= ~GENMASK_ULL (29 ,24 ); + val |= (tcc &0x3f ) <<24 ; err =wrmsrl_safe (MSR_IA32_TEMPERATURE_TARGET , val);if (err)
@@ -126,14 +129,15 @@ static int tcc_offset_update(int tcc)return 0 ; } -static int tcc_offset_save; +static unsigned int tcc_offset_save;static ssize_t tcc_offset_degree_celsius_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) { +unsigned int tcc;u64 val; -int tcc, err; +int err; err =rdmsrl_safe (MSR_PLATFORM_INFO , &val);if (err)
@@ -142,7 +146,7 @@ static ssize_t tcc_offset_degree_celsiusif (!(val &BIT (30 )))return -EACCES ; -if (kstrtoint (buf,0 , &tcc)) +if (kstrtouint (buf,0 , &tcc))return -EINVAL ; err =tcc_offset_update (tcc);
Greg Kroah-Hartman
maintainerPATCH 200/242 ubifs: Fix races between xattr_{set|get} and listxattr operations
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit f4e3634a3b642225a530c292fdb1e8a4007507f5 upstream.
UBIFS may occur some problems with concurrent xattr_{set|get} and listxattr operations, such as assertion failure, memory corruption, stale xattr value[1].
Fix it by importing a new rw-lock in @ubifs_inode to serilize write operations on xattr, concurrent read operations are still effective, just like ext4.
[1] https://lore.kernel.org/linux-mtd/[email protected]
--- fs/ubifs/super.c | 1 + fs/ubifs/ubifs.h | 2 ++ fs/ubifs/xattr.c | 44 +++++++++++++++++++++++++++++++++----------- 3 files changed, 36 insertions(+), 11 deletions(-)
fs/ubifs/super.c +1 -0
@@ -275,6 +275,7 @@ static struct inode *ubifs_alloc_inode(smemset ((void *)ui +sizeof (struct inode ),0 ,sizeof (struct ubifs_inode ) -sizeof (struct inode ));mutex_init (&ui->ui_mutex); +init_rwsem (&ui->xattr_sem);spin_lock_init (&ui->ui_lock);return &ui->vfs_inode; };
fs/ubifs/ubifs.h +2 -0
@@ -356,6 +356,7 @@ struct ubifs_gced_idx_leb {* @ui_mutex: serializes inode write-back with the rest of VFS operations, * serializes "clean <-> dirty" state changes, serializes bulk-read, * protects @dirty, @bulk_read, @ui_size, and @xattr_size +* @xattr_sem: serilizes write operations (remove|set|create) on xattr * @ui_lock: protects @synced_i_size * @synced_i_size: synchronized size of inode, i.e. the value of inode size * currently stored on the flash; used only for regular file
@@ -409,6 +410,7 @@ struct ubifs_inode { unsigned int bulk_read:1; unsigned int compr_type:2;struct mutex ui_mutex; +struct rw_semaphore xattr_sem;spinlock_t ui_lock;loff_t synced_i_size;loff_t ui_size;
fs/ubifs/xattr.c +33 -11
146 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 201/242 power: supply: ab8500: Fix an old bug
In reply to Greg Kroah-HartmanFrom: Linus Walleij <[email protected]>
commit f1c74a6c07e76fcb31a4bcc1f437c4361a2674ce upstream.
Trying to get the AB8500 charging driver working I ran into a bit of bitrot: we haven't used the driver for a while so errors in refactorings won't be noticed.
This one is pretty self evident: use argument to the macro or we end up with a random pointer to something else.
--- include/linux/mfd/abx500/ux500_chargalg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mfd/abx500/ux500_chargalg.h +1 -1
@@ -15,7 +15,7 @@* - POWER_SUPPLY_TYPE_USB, * because only them store as drv_data pointer to struct ux500_charger. */ -#define psy_to_ux500_charger (x) power_supply_get_drvdata(psy) +#define psy_to_ux500_charger (x) power_supply_get_drvdata(x)/* Forward declaration */ struct ux500_charger ;
Greg Kroah-Hartman
maintainerPATCH 202/242 mfd: syscon: Free the allocated name field of struct regmap_config
In reply to Greg Kroah-HartmanFrom: Limeng <[email protected]>
commit 56a1188159cb2b87fbcb5a7a7afb38a4dd9db0c1 upstream.
The commit 529a1101212a("mfd: syscon: Don't free allocated name for regmap_config") doesn't free the allocated name field of struct regmap_config, but introduce a memory leak. There is another commit 94cc89eb8fa5("regmap: debugfs: Fix handling of name string for debugfs init delays") fixing this debugfs init issue from root cause. With this fixing, the name field in struct regmap_debugfs_node is removed. When initialize debugfs for syscon driver, the name field of struct regmap_config is not used anymore. So, the allocated name field of struct regmap_config is need to be freed directly after regmap initialization to avoid memory leak.
--- drivers/mfd/syscon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/syscon.c +1 -1
@@ -108,6 +108,7 @@ static struct syscon *of_syscon_register syscon_config.max_register =resource_size (&res) - reg_io_width; regmap =regmap_init_mmio (NULL , base, &syscon_config); +kfree (syscon_config.name);if (IS_ERR (regmap)) {pr_err ("regmap init failed\n" ); ret =PTR_ERR (regmap);
@@ -144,7 +145,6 @@ err_clk:regmap_exit (regmap); err_regmap:iounmap (base); -kfree (syscon_config.name); err_map:kfree (syscon);return ERR_PTR (ret);
Greg Kroah-Hartman
maintainerPATCH 203/242 nvmem: core: add a missing of_node_put
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
commit 63879e2964bceee2aa5bbe8b99ea58bba28bb64f upstream.
'for_each_child_of_node' performs an of_node_get on each iteration, so a return from the middle of the loop requires an of_node_put.
--- drivers/nvmem/core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/nvmem/core.c +6 -3
@@ -686,15 +686,17 @@ static int nvmem_add_cells_from_of(struccontinue ;if (len <2 *sizeof (u32)) {dev_err (dev,"nvmem: invalid reg on %pOF\n" , child); +of_node_put (child);return -EINVAL ; } cell =kzalloc (sizeof (*cell),GFP_KERNEL ); -if (!cell) +if (!cell) { +of_node_put (child);return -ENOMEM ; + } cell->nvmem = nvmem; - cell->np =of_node_get (child); cell->offset =be32_to_cpup (addr++); cell->bytes =be32_to_cpup (addr); cell->name =kasprintf (GFP_KERNEL ,"%pOFn" , child);
@@ -715,11 +717,12 @@ static int nvmem_add_cells_from_of(struc cell->name, nvmem->stride);/* Cells already added will be freed later. */ kfree_const (cell->name); -of_node_put (cell->np);kfree (cell); +of_node_put (child);return -EINVAL ; } + cell->np =of_node_get (child);nvmem_cell_add (cell); }
Greg Kroah-Hartman
maintainerPATCH 204/242 lkdtm/bugs: XFAIL UNALIGNED_LOAD_STORE_WRITE
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
commit a15676ac8f24a9ac5fd881cf17be4be13fa0910a upstream.
When built under CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS, this test is expected to fail (i.e. not trip an exception).
--- drivers/misc/lkdtm/bugs.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/misc/lkdtm/bugs.c +3 -0
@@ -144,6 +144,9 @@ void lkdtm_UNALIGNED_LOAD_STORE_WRITE(voif (*p ==0 ) val =0x87654321 ; *p = val; + +if (IS_ENABLED (CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS )) +pr_err ("XFAIL: arch has CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS\n" ); }void lkdtm_SOFTLOCKUP (void )
Greg Kroah-Hartman
maintainerPATCH 205/242 selftests/lkdtm: Fix expected text for CR4 pinning
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
commit c2eb472bbe25b3f360990f23b293b3fbadfa4bc0 upstream.
The error text for CR4 pinning changed. Update the test to match.
--- tools/testing/selftests/lkdtm/tests.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/lkdtm/tests.txt +1 -1
@@ -11,7 +11,7 @@ CORRUPT_LIST_ADD list_add corruption CORRUPT_LIST_DEL list_del corruption STACK_GUARD_PAGE_LEADING STACK_GUARD_PAGE_TRAILING -UNSET_SMEP CR4 bits went missing +UNSET_SMEP pinned CR4 bits changed: DOUBLE_FAULT CORRUPT_PAC UNALIGNED_LOAD_STORE_WRITE
Greg Kroah-Hartman
maintainerPATCH 206/242 extcon: intel-mrfld: Sync hardware and software state on init
In reply to Greg Kroah-HartmanFrom: Ferry Toth <[email protected]>
commit ecb5bdff901139850fb3ca3ae2d0cccac045bc52 upstream.
extcon driver for Basin Cove PMIC shadows the switch status used for dwc3 DRD to detect a change in the switch position. This change initializes the status at probe time.
--- drivers/extcon/extcon-intel-mrfld.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/extcon/extcon-intel-mrfld.c +9 -0
@@ -197,6 +197,7 @@ static int mrfld_extcon_probe(struct plastruct intel_soc_pmic *pmic =dev_get_drvdata (dev->parent);struct regmap *regmap = pmic->regmap;struct mrfld_extcon_data *data; +unsigned int status;unsigned int id;int irq, ret;
@@ -244,6 +245,14 @@ static int mrfld_extcon_probe(struct pla/* Get initial state */ mrfld_extcon_role_detect (data); +/* +* Cached status value is used for cable detection, see comments +* in mrfld_extcon_cable_detect(), we need to sync cached value +* with a real state of the hardware. +*/ +regmap_read (regmap,BCOVE_SCHGRIRQ1 , &status); + data->status = status; +mrfld_extcon_clear (data,BCOVE_MIRQLVL1 ,BCOVE_LVL1_CHGR );mrfld_extcon_clear (data,BCOVE_MCHGRIRQ1 ,BCOVE_CHGRIRQ_ALL );
Greg Kroah-Hartman
maintainerPATCH 207/242 lkdtm: Enable DOUBLE_FAULT on all architectures
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
commit f123c42bbeff26bfe8bdb08a01307e92d51eec39 upstream.
Where feasible, I prefer to have all tests visible on all architectures, but to have them wired to XFAIL. DOUBLE_FAIL was set up to XFAIL, but wasn't actually being added to the test list.
--- drivers/misc/lkdtm/core.c | 2 -- 1 file changed, 2 deletions(-)
drivers/misc/lkdtm/core.c +0 -2
@@ -176,9 +176,7 @@ static const struct crashtype crashtypesCRASHTYPE (STACKLEAK_ERASING ),CRASHTYPE (CFI_FORWARD_PROTO ),CRASHTYPE (FORTIFIED_STRSCPY ), -#ifdef CONFIG_X86_32CRASHTYPE (DOUBLE_FAULT ), -#endif #ifdef CONFIG_PPC_BOOK3S_64 CRASHTYPE(PPC_SLB_MULTIHIT), #endif
Greg Kroah-Hartman
maintainerPATCH 208/242 seq_buf: Fix overflow in seq_buf_putmem_hex()
In reply to Greg Kroah-HartmanFrom: Yun Zhou <[email protected]>
commit d3b16034a24a112bb83aeb669ac5b9b01f744bb7 upstream.
There's two variables being increased in that loop (i and j), and i follows the raw data, and j follows what is being written into the buffer. We should compare 'i' to MAX_MEMHEX_BYTES or compare 'j' to HEX_CHARS. Otherwise, if 'j' goes bigger than HEX_CHARS, it will overflow the destination buffer.
--- lib/seq_buf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
lib/seq_buf.c +3 -1
@@ -229,8 +229,10 @@ int seq_buf_putmem_hex(struct seq_buf *sWARN_ON (s->size ==0 ); +BUILD_BUG_ON (MAX_MEMHEX_BYTES *2 >=HEX_CHARS ); +while (len) { - start_len =min (len,HEX_CHARS -1 ); + start_len =min (len,MAX_MEMHEX_BYTES );#ifdef __BIG_ENDIANfor (i =0 , j =0 ; i < start_len; i++) {#else
Greg Kroah-Hartman
maintainerPATCH 209/242 rq-qos: fix missed wake-ups in rq_qos_throttle try two
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
commit 11c7aa0ddea8611007768d3e6b58d45dc60a19e1 upstream.
Commit 545fbd0775ba ("rq-qos: fix missed wake-ups in rq_qos_throttle") tried to fix a problem that a process could be sleeping in rq_qos_wait() without anyone to wake it up. However the fix is not complete and the following can still happen:
CPU1 (waiter1) CPU2 (waiter2) CPU3 (waker)rq_qos_wait() rq_qos_wait()
acquire_inflight_cb() -> fails
acquire_inflight_cb() -> fails completes IOs, inflight decreased prepare_to_wait_exclusive() prepare_to_wait_exclusive() has_sleeper = !wq_has_single_sleeper() -> true as there are two sleepers has_sleeper = !wq_has_single_sleeper() -> true
io_schedule() io_schedule()
Deadlock as now there's nobody to wakeup the two waiters. The logic automatically blocking when there are already sleepers is really subtle and the only way to make it work reliably is that we check whether there are some waiters in the queue when adding ourselves there. That way, we are guaranteed that at least the first process to enter the wait queue will recheck the waiting condition before going to sleep and thus guarantee forward progress.
--- block/blk-rq-qos.c | 4 ++-- include/linux/wait.h | 2 +- kernel/sched/wait.c | 9 +++++++-- 3 files changed, 10 insertions(+), 5 deletions(-)
block/blk-rq-qos.c +2 -2
@@ -266,8 +266,8 @@ void rq_qos_wait(struct rq_wait *rqw, voif (!has_sleeper &&acquire_inflight_cb (rqw, private_data))return ; -prepare_to_wait_exclusive (&rqw->wait, &data.wq,TASK_UNINTERRUPTIBLE ); - has_sleeper = !wq_has_single_sleeper (&rqw->wait); + has_sleeper = !prepare_to_wait_exclusive (&rqw->wait, &data.wq, +TASK_UNINTERRUPTIBLE ); do { /* The memory barrier in set_task_state saves us here. */ if (data.got_token)
include/linux/wait.h +1 -1
@@ -1136,7 +1136,7 @@ do { \* Waitqueues which are removed from the waitqueue_head at wakeup time */ void prepare_to_wait (struct wait_queue_head *wq_head,struct wait_queue_entry *wq_entry,int state); -void prepare_to_wait_exclusive (struct wait_queue_head *wq_head,struct wait_queue_entry *wq_entry,int state); +bool prepare_to_wait_exclusive (struct wait_queue_head *wq_head,struct wait_queue_entry *wq_entry,int state);long prepare_to_wait_event (struct wait_queue_head *wq_head,struct wait_queue_entry *wq_entry,int state);void finish_wait (struct wait_queue_head *wq_head,struct wait_queue_entry *wq_entry);long wait_woken (struct wait_queue_entry *wq_entry,unsigned mode,long timeout);
kernel/sched/wait.c +7 -2
@@ -264,17 +264,22 @@ prepare_to_wait(struct wait_queue_head * }EXPORT_SYMBOL (prepare_to_wait); -void +/* Returns true if we are the first waiter in the queue, false otherwise. */ +bool prepare_to_wait_exclusive (struct wait_queue_head *wq_head,struct wait_queue_entry *wq_entry,int state) {unsigned long flags; +bool was_empty = false; wq_entry->flags |=WQ_FLAG_EXCLUSIVE ;spin_lock_irqsave (&wq_head->lock, flags); -if (list_empty (&wq_entry->entry)) +if (list_empty (&wq_entry->entry)) { + was_empty =list_empty (&wq_head->head);__add_wait_queue_entry_tail (wq_head, wq_entry); + }set_current_state (state);spin_unlock_irqrestore (&wq_head->lock, flags); +return was_empty; }EXPORT_SYMBOL (prepare_to_wait_exclusive);
Greg Kroah-Hartman
maintainerPATCH 210/242 tracing: Simplify & fix saved_tgids logic
In reply to Greg Kroah-HartmanFrom: Paul Burton <[email protected]>
commit b81b3e959adb107cd5b36c7dc5ba1364bbd31eb2 upstream.
The tgid_map array records a mapping from pid to tgid, where the index of an entry within the array is the pid & the value stored at that index is the tgid.
The saved_tgids_next() function iterates over pointers into the tgid_map array & dereferences the pointers which results in the tgid, but then it passes that dereferenced value to trace_find_tgid() which treats it as a pid & does a further lookup within the tgid_map array. It seems likely that the intent here was to skip over entries in tgid_map for which the recorded tgid is zero, but instead we end up skipping over entries for which the thread group leader hasn't yet had its own tgid recorded in tgid_map.
A minimal fix would be to remove the call to trace_find_tgid, turning:
if (trace_find_tgid(*ptr))
into:
if (*ptr)
..but it seems like this logic can be much simpler if we simply let seq_read() iterate over the whole tgid_map array & filter out empty entries by returning SEQ_SKIP from saved_tgids_show(). Here we take that approach, removing the incorrect logic here entirely.
--- kernel/trace/trace.c | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-)
kernel/trace/trace.c +13 -25
@@ -5352,37 +5352,20 @@ static const struct file_operations tracstatic void *saved_tgids_next (struct seq_file *m,void *v,loff_t *pos) { -int *ptr = v; +int pid = ++(*pos); -if (*pos || m->count) - ptr++; - - (*pos)++; - -for (; ptr <= &tgid_map[PID_MAX_DEFAULT ]; ptr++) { -if (trace_find_tgid (*ptr)) -return ptr; - } +if (pid >PID_MAX_DEFAULT ) +return NULL ; -return NULL ; +return &tgid_map[pid]; }static void *saved_tgids_start (struct seq_file *m,loff_t *pos) { -void *v; -loff_t l =0 ; - -if (!tgid_map) +if (!tgid_map || *pos >PID_MAX_DEFAULT )return NULL ; - v = &tgid_map[0 ]; -while (l <= *pos) { - v =saved_tgids_next (m, v, &l); -if (!v) -return NULL ; - } - -return v; +return &tgid_map[*pos]; }static void saved_tgids_stop (struct seq_file *m,void *v)
@@ -5391,9 +5374,14 @@ static void saved_tgids_stop(struct seq_static int saved_tgids_show (struct seq_file *m,void *v) { -int pid = (int *)v - tgid_map; +int *entry = (int *)v; +int pid = entry - tgid_map; +int tgid = *entry; + +if (tgid ==0 ) +return SEQ_SKIP ; -seq_printf (m,"%d %d\n" , pid,trace_find_tgid (pid)); +seq_printf (m,"%d %d\n" , pid, tgid);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 211/242 tracing: Resize tgid_map to pid_max, not PID_MAX_DEFAULT
In reply to Greg Kroah-HartmanFrom: Paul Burton <[email protected]>
commit 4030a6e6a6a4a42ff8c18414c9e0c93e24cc70b8 upstream.
Currently tgid_map is sized at PID_MAX_DEFAULT entries, which means that on systems where pid_max is configured higher than PID_MAX_DEFAULT the ftrace record-tgid option doesn't work so well. Any tasks with PIDs higher than PID_MAX_DEFAULT are simply not recorded in tgid_map, and don't show up in the saved_tgids file.
In particular since systemd v243 & above configure pid_max to its highest possible 1<<22 value by default on 64 bit systems this renders the record-tgids option of little use.
Increase the size of tgid_map to the configured pid_max instead, allowing it to cover the full range of PIDs up to the maximum value of PID_MAX_LIMIT if the system is configured that way.
On 64 bit systems with pid_max == PID_MAX_LIMIT this will increase the size of tgid_map from 256KiB to 16MiB. Whilst this 64x increase in memory overhead sounds significant 64 bit systems are presumably best placed to accommodate it, and since tgid_map is only allocated when the record-tgid option is actually used presumably the user would rather it spends sufficient memory to actually record the tgids they expect.
The size of tgid_map could also increase for CONFIG_BASE_SMALL=y configurations, but these seem unlikely to be systems upon which people are both configuring a large pid_max and running ftrace with record-tgid anyway.
Of note is that we only allocate tgid_map once, the first time that the record-tgid option is enabled. Therefore its size is only set once, to the value of pid_max at the time the record-tgid option is first enabled. If a user increases pid_max after that point, the saved_tgids file will not contain entries for any tasks with pids beyond the earlier value of pid_max.
--- kernel/trace/trace.c | 63 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 16 deletions(-)
kernel/trace/trace.c +47 -16
@@ -2184,8 +2184,15 @@ void tracing_reset_all_online_cpus(void) } } +/* +* The tgid_map array maps from pid to tgid; i.e. the value stored at index i +* is the tgid last observed corresponding to pid=i. +*/ static int *tgid_map; +/* The maximum valid index into tgid_map. */ +static size_t tgid_map_max; +#define SAVED_CMDLINES_DEFAULT 128#define NO_CMDLINE_MAP UINT_MAXstatic arch_spinlock_t trace_cmdline_lock = __ARCH_SPIN_LOCK_UNLOCKED;
@@ -2458,24 +2465,41 @@ void trace_find_cmdline(int pid, char copreempt_enable (); } +static int *trace_find_tgid_ptr (int pid) +{ +/* +* Pairs with the smp_store_release in set_tracer_flag() to ensure that +* if we observe a non-NULL tgid_map then we also observe the correct +* tgid_map_max. +*/ +int *map =smp_load_acquire (&tgid_map); + +if (unlikely (!map || pid > tgid_map_max)) +return NULL ; + +return &map[pid]; +} +int trace_find_tgid (int pid) { -if (unlikely (!tgid_map || !pid || pid >PID_MAX_DEFAULT )) -return 0 ; +int *ptr =trace_find_tgid_ptr (pid); -return tgid_map[pid]; +return ptr ? *ptr :0 ; }static int trace_save_tgid (struct task_struct *tsk) { +int *ptr; +/* treat recording of idle task as a success */ if (!tsk->pid)return 1 ; -if (unlikely (!tgid_map || tsk->pid >PID_MAX_DEFAULT )) + ptr =trace_find_tgid_ptr (tsk->pid); +if (!ptr)return 0 ; - tgid_map[tsk->pid] = tsk->tgid; + *ptr = tsk->tgid;return 1 ; }
@@ -4915,6 +4939,8 @@ int trace_keep_overwrite(struct tracer *int set_tracer_flag (struct trace_array *tr,unsigned int mask,int enabled) { +int *map; +if ((mask ==TRACE_ITER_RECORD_TGID ) || (mask ==TRACE_ITER_RECORD_CMD ))lockdep_assert_held (&event_mutex);
@@ -4937,10 +4963,19 @@ int set_tracer_flag(struct trace_array *trace_event_enable_cmd_record (enabled);if (mask ==TRACE_ITER_RECORD_TGID ) { -if (!tgid_map) - tgid_map =kvcalloc (PID_MAX_DEFAULT +1 , -sizeof (*tgid_map), -GFP_KERNEL ); +if (!tgid_map) { + tgid_map_max = pid_max; + map =kvcalloc (tgid_map_max +1 ,sizeof (*tgid_map), +GFP_KERNEL ); + +/* +* Pairs with smp_load_acquire() in +* trace_find_tgid_ptr() to ensure that if it observes +* the tgid_map we just allocated then it also observes +* the corresponding tgid_map_max value. +*/ +smp_store_release (&tgid_map, map); + }if (!tgid_map) { tr->trace_flags &= ~TRACE_ITER_RECORD_TGID ;return -ENOMEM ;
@@ -5354,18 +5389,14 @@ static void *saved_tgids_next(struct seq {int pid = ++(*pos); -if (pid >PID_MAX_DEFAULT ) -return NULL ; - -return &tgid_map[pid]; +return trace_find_tgid_ptr (pid); }static void *saved_tgids_start (struct seq_file *m,loff_t *pos) { -if (!tgid_map || *pos >PID_MAX_DEFAULT ) -return NULL ; +int pid = *pos; -return &tgid_map[*pos]; +return trace_find_tgid_ptr (pid); }static void saved_tgids_stop (struct seq_file *m,void *v)
Greg Kroah-Hartman
maintainerPATCH 212/242 ipack/carriers/tpci200: Fix a double free in tpci200_pci_probe
In reply to Greg Kroah-HartmanFrom: Lv Yunlong <[email protected]>
commit 9272e5d0028d45a3b45b58c9255e6e0df53f7ad9 upstream.
In the out_err_bus_register error branch of tpci200_pci_probe, tpci200->info->cfg_regs is freed by tpci200_uninstall()-> tpci200_unregister()->pci_iounmap(..,tpci200->info->cfg_regs) in the first time.
But later, iounmap() is called to free tpci200->info->cfg_regs again.
My patch sets tpci200->info->cfg_regs to NULL after tpci200_uninstall() to avoid the double free.
--- drivers/ipack/carriers/tpci200.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/ipack/carriers/tpci200.c +4 -1
@@ -596,8 +596,11 @@ static int tpci200_pci_probe(struct pci_ out_err_bus_register:tpci200_uninstall (tpci200); +/* tpci200->info->cfg_regs is unmapped in tpci200_uninstall */ + tpci200->info->cfg_regs =NULL ; out_err_install: -iounmap (tpci200->info->cfg_regs); +if (tpci200->info->cfg_regs) +iounmap (tpci200->info->cfg_regs); out_err_ioremap:pci_release_region (pdev,TPCI200_CFG_MEM_BAR ); out_err_pci_request:
Greg Kroah-Hartman
maintainerPATCH 213/242 coresight: Propagate symlink failure
In reply to Greg Kroah-HartmanFrom: Jeremy Linton <[email protected]>
commit 51dd19a7e9f8fbbb7cd92b8a357091911eae7f78 upstream.
If the symlink is unable to be created, the driver goes ahead and continues device creation. Instead lets propagate the failure, and fail the probe.
--- drivers/hwtracing/coresight/coresight-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-core.c +1 -1
@@ -1367,7 +1367,7 @@ static int coresight_fixup_device_conns( } } -return 0 ; +return ret; }static int coresight_remove_match (struct device *dev,void *data)
Greg Kroah-Hartman
maintainerPATCH 214/242 coresight: tmc-etf: Fix global-out-of-bounds in tmc_update_etf_buffer()
In reply to Greg Kroah-HartmanFrom: Sai Prakash Ranjan <[email protected]>
commit 5fae8a946ac2df879caf3f79a193d4766d00239b upstream.
commit 6f755e85c332 ("coresight: Add helper for inserting synchronization packets") removed trailing '\0' from barrier_pkt array and updated the call sites like etb_update_buffer() to have proper checks for barrier_pkt size before read but missed updating tmc_update_etf_buffer() which still reads barrier_pkt past the array size resulting in KASAN out-of-bounds bug. Fix this by adding a check for barrier_pkt size before accessing like it is done in etb_update_buffer().
BUG: KASAN: global-out-of-bounds in tmc_update_etf_buffer+0x4b8/0x698
Read of size 4 at addr ffffffd05b7d1030 by task perf/2629
Call trace:
dump_backtrace+0x0/0x27c
show_stack+0x20/0x2c
dump_stack+0x11c/0x188
print_address_description+0x3c/0x4a4
__kasan_report+0x140/0x164
kasan_report+0x10/0x18
__asan_report_load4_noabort+0x1c/0x24
tmc_update_etf_buffer+0x4b8/0x698
etm_event_stop+0x248/0x2d8
etm_event_del+0x20/0x2c
event_sched_out+0x214/0x6f0
group_sched_out+0xd0/0x270
ctx_sched_out+0x2ec/0x518
__perf_event_task_sched_out+0x4fc/0xe6c
__schedule+0x1094/0x16a0
preempt_schedule_irq+0x88/0x170
arm64_preempt_schedule_irq+0xf0/0x18c
el1_irq+0xe8/0x180
perf_event_exec+0x4d8/0x56c
setup_new_exec+0x204/0x400
load_elf_binary+0x72c/0x18c0
search_binary_handler+0x13c/0x420
load_script+0x500/0x6c4
search_binary_handler+0x13c/0x420
exec_binprm+0x118/0x654
__do_execve_file+0x77c/0xba4
__arm64_compat_sys_execve+0x98/0xac
el0_svc_common+0x1f8/0x5e0
el0_svc_compat_handler+0x84/0xb0
el0_svc_compat+0x10/0x50
The buggy address belongs to the variable:
barrier_pkt+0x10/0x40
Memory state around the buggy address:
ffffffd05b7d0f00: fa fa fa fa 04 fa fa fa fa fa fa fa 00 00 00 00
ffffffd05b7d0f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffffffd05b7d1000: 00 00 00 00 00 00 fa fa fa fa fa fa 00 00 00 03
^
ffffffd05b7d1080: fa fa fa fa 00 02 fa fa fa fa fa fa 03 fa fa fa
ffffffd05b7d1100: fa fa fa fa 00 00 00 00 05 fa fa fa fa fa fa fa
==================================================================--- drivers/hwtracing/coresight/coresight-tmc-etf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-tmc-etf.c +1 -1
@@ -530,7 +530,7 @@ static unsigned long tmc_update_etf_buff buf_ptr = buf->data_pages[cur] + offset; *buf_ptr =readl_relaxed (drvdata->base +TMC_RRD ); -if (lost && *barrier) { +if (lost && i <CORESIGHT_BARRIER_PKT_SIZE ) { *buf_ptr = *barrier; barrier++; }
Greg Kroah-Hartman
maintainerPATCH 215/242 dm zoned: check zone capacity
In reply to Greg Kroah-HartmanFrom: Damien Le Moal <[email protected]>
commit bab68499428ed934f0493ac74197ed6f36204260 upstream.
The dm-zoned target cannot support zoned block devices with zones that have a capacity smaller than the zone size (e.g. NVMe zoned namespaces) due to the current chunk zone mapping implementation as it is assumed that zones and chunks have the same size with all blocks usable. If a zoned drive is found to have zones with a capacity different from the zone size, fail the target initialization.
--- drivers/md/dm-zoned-metadata.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/md/dm-zoned-metadata.c +7 -0
@@ -1390,6 +1390,13 @@ static int dmz_init_zone(struct blk_zonereturn -ENXIO ; } +/* +* Devices that have zones with a capacity smaller than the zone size +* (e.g. NVMe zoned namespaces) are not supported. +*/ +if (blkz->capacity != blkz->len) +return -ENXIO ; +switch (blkz->type) {case BLK_ZONE_TYPE_CONVENTIONAL :set_bit (DMZ_RND , &zone->flags);
Greg Kroah-Hartman
maintainerPATCH 216/242 dm writecache: flush origin device when writing and cache is full
In reply to Greg Kroah-HartmanFrom: Mikulas Patocka <[email protected]>
commit ee55b92a7391bf871939330f662651b54be51b73 upstream.
Commit d53f1fafec9d086f1c5166436abefdaef30e0363 ("dm writecache: do direct write if the cache is full") changed dm-writecache, so that it writes directly to the origin device if the cache is full. Unfortunately, it doesn't forward flush requests to the origin device, so that there is a bug where flushes are being ignored.
Fix this by adding missing flush forwarding.
For PMEM mode, we fix this bug by disabling direct writes to the origin device, because it performs better.
--- drivers/md/dm-writecache.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/md/dm-writecache.c +6 -2
@@ -1297,8 +1297,12 @@ static int writecache_map(struct dm_targwritecache_flush (wc);if (writecache_has_error (wc)) goto unlock_error; +if (unlikely (wc->cleaner)) + goto unlock_remap_origin; goto unlock_submit; }else { +if (dm_bio_get_target_bio_nr (bio)) + goto unlock_remap_origin;writecache_offload_bio (wc, bio); goto unlock_return; }
@@ -1377,7 +1381,7 @@ read_next_block: } e =writecache_pop_from_freelist (wc, (sector_t)-1 );if (unlikely (!e)) { -if (!found_entry) { +if (!WC_MODE_PMEM (wc) && !found_entry) { direct_write: e =writecache_find_entry (wc, bio->bi_iter.bi_sector,WFE_RETURN_FOLLOWING );if (e) {
@@ -2481,7 +2485,7 @@ overflow: goto bad; } - ti->num_flush_bios =1 ; + ti->num_flush_bios =WC_MODE_PMEM (wc) ?1 :2 ; ti->flush_supported = true; ti->num_discard_bios =1 ;
Greg Kroah-Hartman
maintainerPATCH 217/242 dm btree remove: assign new_root only when removal succeeds
In reply to Greg Kroah-HartmanFrom: Hou Tao <[email protected]>
commit b6e58b5466b2959f83034bead2e2e1395cca8aeb upstream.
remove_raw() in dm_btree_remove() may fail due to IO read error (e.g. read the content of origin block fails during shadowing), and the value of shadow_spine::root is uninitialized, but the uninitialized value is still assign to new_root in the end of dm_btree_remove().
For dm-thin, the value of pmd->details_root or pmd->root will become an uninitialized value, so if trying to read details_info tree again out-of-bound memory may occur as showed below:
general protection fault, probably for non-canonical address 0x3fdcb14c8d7520 CPU: 4 PID: 515 Comm: dmsetup Not tainted 5.13.0-rc6 Hardware name: QEMU Standard PC RIP: 0010:metadata_ll_load_ie+0x14/0x30 Call Trace: sm_metadata_count_is_more_than_one+0xb9/0xe0 dm_tm_shadow_block+0x52/0x1c0 shadow_step+0x59/0xf0 remove_raw+0xb2/0x170 dm_btree_remove+0xf4/0x1c0 dm_pool_delete_thin_device+0xc3/0x140 pool_message+0x218/0x2b0 target_message+0x251/0x290 ctl_ioctl+0x1c4/0x4d0 dm_ctl_ioctl+0xe/0x20 __x64_sys_ioctl+0x7b/0xb0 do_syscall_64+0x40/0xb0 entry_SYSCALL_64_after_hwframe+0x44/0xae
Fixing it by only assign new_root when removal succeeds
--- drivers/md/persistent-data/dm-btree-remove.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/persistent-data/dm-btree-remove.c +2 -1
@@ -549,7 +549,8 @@ int dm_btree_remove(struct dm_btree_infodelete_at (n, index); } - *new_root =shadow_root (&spine); +if (!r) + *new_root =shadow_root (&spine);exit_shadow_spine (&spine);return r;
Greg Kroah-Hartman
maintainerPATCH 218/242 PCI: Leave Apple Thunderbolt controllers on for s2idle or standby
In reply to Greg Kroah-HartmanFrom: Konstantin Kharlamov <[email protected]>
commit 4694ae373dc2114f9a82f6ae15737e65af0c6dea upstream.
On Macbook 2013, resuming from suspend-to-idle or standby resulted in the external monitor no longer being detected, a stacktrace, and errors like this in dmesg:
pcieport 0000:06:00.0: can't change power state from D3hot to D0 (config space inaccessible)
The reason is that we know how to turn power to the Thunderbolt controller *off* via the SXIO/SXFP/SXLF methods, but we don't know how to turn power back on. We have to rely on firmware to turn the power back on.
When going to the "suspend-to-idle" or "standby" system sleep states, firmware is not involved either on the suspend side or the resume side, so we can't use SXIO/SXFP/SXLF to turn the power off.
Skip SXIO/SXFP/SXLF when firmware isn't involved in suspend, e.g., when we're going to the "suspend-to-idle" or "standby" system sleep states.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=212767
--- drivers/pci/quirks.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/pci/quirks.c +11 -0
@@ -27,6 +27,7 @@#include <linux/nvme.h> #include <linux/platform_data/x86/apple.h> #include <linux/pm_runtime.h> +#include <linux/suspend.h> #include <linux/switchtec.h> #include <asm/dma.h> /* isa_dma_bridge_buggy */ #include "pci.h"
@@ -3668,6 +3669,16 @@ static void quirk_apple_poweroff_thunderreturn ;if (pci_pcie_type (dev) !=PCI_EXP_TYPE_UPSTREAM )return ; + +/* +* SXIO/SXFP/SXLF turns off power to the Thunderbolt controller. +* We don't know how to turn it back on again, but firmware does, +* so we can only use SXIO/SXFP/SXLF if we're suspending via +* firmware. +*/ +if (!pm_suspend_via_firmware ()) +return ; + bridge =ACPI_HANDLE (&dev->dev);if (!bridge)return ;
Greg Kroah-Hartman
maintainerPATCH 219/242 PCI: aardvark: Fix checking for PIO Non-posted Request
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
commit 8ceeac307a79f68c0d0c72d6e48b82fa424204ec upstream.
PIO_NON_POSTED_REQ for PIO_STAT register is incorrectly defined. Bit 10 in register PIO_STAT indicates the response is to a non-posted request.
--- drivers/pci/controller/pci-aardvark.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/pci-aardvark.c +1 -1
@@ -57,7 +57,7 @@#define PIO_COMPLETION_STATUS_UR 1#define PIO_COMPLETION_STATUS_CRS 2#define PIO_COMPLETION_STATUS_CA 4 -#define PIO_NON_POSTED_REQ BIT(0) +#define PIO_NON_POSTED_REQ BIT(10)#define PIO_ADDR_LS (PIO_BASE_ADDR + 0x8)#define PIO_ADDR_MS (PIO_BASE_ADDR + 0xc)#define PIO_WR_DATA (PIO_BASE_ADDR + 0x10)
Greg Kroah-Hartman
maintainerPATCH 220/242 PCI: aardvark: Implement workaround for the readback value of VEND_ID
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
commit 7f71a409fe3d9358da07c77f15bb5b7960f12253 upstream.
Marvell Armada 3700 Functional Errata, Guidelines, and Restrictions document describes in erratum 4.1 PCIe value of vendor ID (Ref #: 243):
The readback value of VEND_ID (RD0070000h [15:0]) is 1B4Bh, while it should read 11ABh.
The firmware can write the correct value, 11ABh, through VEND_ID (RD0076044h [15:0]).
Implement this workaround in aardvark driver for both PCI vendor id and PCI subsystem vendor id.
This change affects and fixes PCI vendor id of emulated PCIe root bridge. After this change emulated PCIe root bridge has correct vendor id.
--- drivers/pci/controller/pci-aardvark.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/pci/controller/pci-aardvark.c +11 -0
@@ -125,6 +125,7 @@#define LTSSM_MASK 0x3f#define LTSSM_L0 0x10#define RC_BAR_CONFIG 0x300 +#define VENDOR_ID_REG (LMI_BASE_ADDR + 0x44)/* PCIe core controller registers */ #define CTRL_CORE_BASE_ADDR 0x18000
@@ -385,6 +386,16 @@ static void advk_pcie_setup_hw(struct ad reg |= (IS_RC_MSK <<IS_RC_SHIFT );advk_writel (pcie, reg,PCIE_CORE_CTRL0_REG ); +/* +* Replace incorrect PCI vendor id value 0x1b4b by correct value 0x11ab. +* VENDOR_ID_REG contains vendor id in low 16 bits and subsystem vendor +* id in high 16 bits. Updating this register changes readback value of +* read-only vendor id bits in PCIE_CORE_DEV_ID_REG register. Workaround +* for erratum 4.1: "The value of device and vendor ID is incorrect". +*/ + reg = (PCI_VENDOR_ID_MARVELL <<16 ) |PCI_VENDOR_ID_MARVELL ; +advk_writel (pcie, reg,VENDOR_ID_REG ); +/* Set Advanced Error Capabilities and Control PF0 register */ reg =PCIE_CORE_ERR_CAPCTL_ECRC_CHK_TX | PCIE_CORE_ERR_CAPCTL_ECRC_CHK_TX_EN |
Greg Kroah-Hartman
maintainerPATCH 221/242 media: subdev: disallow ioctl for saa6588/davinci
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
commit 0a7790be182d32b9b332a37cb4206e24fe94b728 upstream.
The saa6588_ioctl() function expects to get called from other kernel functions with a 'saa6588_command' pointer, but I found nothing stops it from getting called from user space instead, which seems rather dangerous.
The same thing happens in the davinci vpbe driver with its VENC_GET_FLD command.
As a quick fix, add a separate .command() callback pointer for this driver and change the two callers over to that. This change can easily get backported to stable kernels if necessary, but since there are only two drivers, we may want to eventually replace this with a set of more specialized callbacks in the long run.
--- drivers/media/i2c/saa6588.c | 4 ++-- drivers/media/pci/bt8xx/bttv-driver.c | 6 +++--- drivers/media/pci/saa7134/saa7134-video.c | 6 +++--- drivers/media/platform/davinci/vpbe_display.c | 2 +- drivers/media/platform/davinci/vpbe_venc.c | 6 ++---- include/media/v4l2-subdev.h | 4 ++++ 6 files changed, 15 insertions(+), 13 deletions(-)
drivers/media/i2c/saa6588.c +2 -2
@@ -380,7 +380,7 @@ static void saa6588_configure(struct saa/* ---------------------------------------------------------------------- */ -static long saa6588_ioctl (struct v4l2_subdev *sd,unsigned int cmd,void *arg) +static long saa6588_command (struct v4l2_subdev *sd,unsigned int cmd,void *arg) {struct saa6588 *s =to_saa6588 (sd);struct saa6588_command *a = arg;
@@ -433,7 +433,7 @@ static int saa6588_s_tuner(struct v4l2_s/* ----------------------------------------------------------------------- */ static const struct v4l2_subdev_core_ops saa6588_core_ops = { - .ioctl = saa6588_ioctl, + .command = saa6588_command, };static const struct v4l2_subdev_tuner_ops saa6588_tuner_ops = {
drivers/media/pci/bt8xx/bttv-driver.c +3 -3
@@ -3179,7 +3179,7 @@ static int radio_release(struct file *fi btv->radio_user--; -bttv_call_all (btv, core, ioctl,SAA6588_CMD_CLOSE , &cmd); +bttv_call_all (btv, core, command,SAA6588_CMD_CLOSE , &cmd);if (btv->radio_user ==0 ) btv->has_radio_tuner =0 ;
@@ -3260,7 +3260,7 @@ static ssize_t radio_read(struct file *f cmd.result = -ENODEV ;radio_enable (btv); -bttv_call_all (btv, core, ioctl,SAA6588_CMD_READ , &cmd); +bttv_call_all (btv, core, command,SAA6588_CMD_READ , &cmd);return cmd.result; }
@@ -3281,7 +3281,7 @@ static __poll_t radio_poll(struct file * cmd.instance = file; cmd.event_list = wait; cmd.poll_mask = res; -bttv_call_all (btv, core, ioctl,SAA6588_CMD_POLL , &cmd); +bttv_call_all (btv, core, command,SAA6588_CMD_POLL , &cmd);return cmd.poll_mask; }
drivers/media/pci/saa7134/saa7134-video.c +3 -3
@@ -1181,7 +1181,7 @@ static int video_release(struct file *fisaa_call_all (dev, tuner, standby);if (vdev->vfl_type ==VFL_TYPE_RADIO ) -saa_call_all (dev, core, ioctl,SAA6588_CMD_CLOSE , &cmd); +saa_call_all (dev, core, command,SAA6588_CMD_CLOSE , &cmd);mutex_unlock (&dev->lock);return 0 ;
@@ -1200,7 +1200,7 @@ static ssize_t radio_read(struct file *f cmd.result = -ENODEV ;mutex_lock (&dev->lock); -saa_call_all (dev, core, ioctl,SAA6588_CMD_READ , &cmd); +saa_call_all (dev, core, command,SAA6588_CMD_READ , &cmd);mutex_unlock (&dev->lock);return cmd.result;
@@ -1216,7 +1216,7 @@ static __poll_t radio_poll(struct file * cmd.event_list = wait; cmd.poll_mask =0 ;mutex_lock (&dev->lock); -saa_call_all (dev, core, ioctl,SAA6588_CMD_POLL , &cmd); +saa_call_all (dev, core, command,SAA6588_CMD_POLL , &cmd);mutex_unlock (&dev->lock);return rc | cmd.poll_mask;
drivers/media/platform/davinci/vpbe_display.c +1 -1
@@ -47,7 +47,7 @@ static int venc_is_second_field(struct v ret =v4l2_subdev_call (vpbe_dev->venc, core, - ioctl, + command,VENC_GET_FLD , &val);if (ret <0 ) {
drivers/media/platform/davinci/vpbe_venc.c +2 -4
@@ -521,9 +521,7 @@ static int venc_s_routing(struct v4l2_sureturn ret; } -static long venc_ioctl (struct v4l2_subdev *sd, -unsigned int cmd, -void *arg) +static long venc_command (struct v4l2_subdev *sd,unsigned int cmd,void *arg) {u32 val;
@@ -542,7 +540,7 @@ static long venc_ioctl(struct v4l2_subde }static const struct v4l2_subdev_core_ops venc_core_ops = { - .ioctl = venc_ioctl, + .command = venc_command, };static const struct v4l2_subdev_video_ops venc_video_ops = {
include/media/v4l2-subdev.h +4 -0
@@ -162,6 +162,9 @@ struct v4l2_subdev_io_pin_config {* @s_gpio: set GPIO pins. Very simple right now, might need to be extended with * a direction argument if needed. * +* @command: called by in-kernel drivers in order to call functions internal +* to subdev drivers driver that have a separate callback. +* * @ioctl: called at the end of ioctl() syscall handler at the V4L2 core. * used to provide support for private ioctls used on the driver. *
@@ -193,6 +196,7 @@ struct v4l2_subdev_core_ops {int (*load_fw)(struct v4l2_subdev *sd);int (*reset)(struct v4l2_subdev *sd,u32 val);int (*s_gpio)(struct v4l2_subdev *sd,u32 val); +long (*command)(struct v4l2_subdev *sd,unsigned int cmd,void *arg);long (*ioctl)(struct v4l2_subdev *sd,unsigned int cmd,void *arg);#ifdef CONFIG_COMPAT long (*compat_ioctl32)(struct v4l2_subdev *sd, unsigned int cmd,
Greg Kroah-Hartman
maintainerPATCH 222/242 media: i2c: ccs-core: fix pm_runtime_get_sync() usage count
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
commit da3a1858c3a37c09446e1470c48352897d59d11b upstream.
The pm_runtime_get_sync() internally increments the dev->power.usage_count without decrementing it, even on errors.
There is a bug at ccs_pm_get_init(): when this function returns an error, the stream is not started, and RPM usage_count should not be incremented. However, if the calls to v4l2_ctrl_handler_setup() return errors, it will be kept incremented.
At ccs_suspend() the best is to replace it by the new pm_runtime_resume_and_get(), introduced by:
commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") in order to properly decrement the usage counter automatically,
in the case of errors.
--- drivers/media/i2c/ccs/ccs-core.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-)
drivers/media/i2c/ccs/ccs-core.c +22 -10
@@ -1880,21 +1880,33 @@ static int ccs_pm_get_init(struct ccs_sestruct i2c_client *client =v4l2_get_subdevdata (&sensor->src->sd);int rval; +/* +* It can't use pm_runtime_resume_and_get() here, as the driver +* relies at the returned value to detect if the device was already +* active or not. +*/ rval =pm_runtime_get_sync (&client->dev); -if (rval <0 ) { -pm_runtime_put_noidle (&client->dev); +if (rval <0 ) + goto error; -return rval; - }else if (!rval) { - rval =v4l2_ctrl_handler_setup (&sensor->pixel_array-> - ctrl_handler); -if (rval) -return rval; +/* Device was already active, so don't set controls */ +if (rval ==1 ) +return 0 ; -return v4l2_ctrl_handler_setup (&sensor->src->ctrl_handler); - } +/* Restore V4L2 controls to the previously suspended device */ + rval =v4l2_ctrl_handler_setup (&sensor->pixel_array->ctrl_handler); +if (rval) + goto error; + rval =v4l2_ctrl_handler_setup (&sensor->src->ctrl_handler); +if (rval) + goto error; + +/* Keep PM runtime usage_count incremented on success */ return 0 ; +error: +pm_runtime_put (&client->dev); +return rval; }static int ccs_set_stream (struct v4l2_subdev *subdev,int enable)
Greg Kroah-Hartman
maintainerPATCH 223/242 media: dtv5100: fix control-request directions
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 8c8b9a9be2afa8bd6a72ad1130532baab9fab89d upstream.
The direction of the pipe argument must match the request-type direction bit or control requests may fail depending on the host-controller-driver implementation.
Fix the control requests which erroneously used usb_rcvctrlpipe().
--- drivers/media/usb/dvb-usb/dtv5100.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/media/usb/dvb-usb/dtv5100.c +5 -2
@@ -26,6 +26,7 @@ static int dtv5100_i2c_msg(struct dvb_us u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen) { struct dtv5100_state *st = d->priv; +unsigned int pipe;u8 request;u8 type;u16 value;
@@ -34,6 +35,7 @@ static int dtv5100_i2c_msg(struct dvb_usswitch (wlen) {case 1 :/* write { reg }, read { value } */ + pipe =usb_rcvctrlpipe (d->udev,0 ); request = (addr ==DTV5100_DEMOD_ADDR ?DTV5100_DEMOD_READ :DTV5100_TUNER_READ ); type =USB_TYPE_VENDOR |USB_DIR_IN ;
@@ -41,6 +43,7 @@ static int dtv5100_i2c_msg(struct dvb_usbreak ;case 2 :/* write { reg, value } */ + pipe =usb_sndctrlpipe (d->udev,0 ); request = (addr ==DTV5100_DEMOD_ADDR ?DTV5100_DEMOD_WRITE :DTV5100_TUNER_WRITE ); type =USB_TYPE_VENDOR |USB_DIR_OUT ;
@@ -54,7 +57,7 @@ static int dtv5100_i2c_msg(struct dvb_usmemcpy (st->data, rbuf, rlen);msleep (1 );/* avoid I2C errors */ -return usb_control_msg (d->udev,usb_rcvctrlpipe (d->udev,0 ), request, +return usb_control_msg (d->udev, pipe, request, type, value, index, st->data, rlen,DTV5100_USB_TIMEOUT ); }
@@ -141,7 +144,7 @@ static int dtv5100_probe(struct usb_inte/* initialize non qt1010/zl10353 part? */ for (i =0 ; dtv5100_init[i].request; i++) { - ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), + ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), dtv5100_init[i].request, USB_TYPE_VENDOR | USB_DIR_OUT, dtv5100_init[i].value,
Greg Kroah-Hartman
maintainerPATCH 224/242 media: zr364xx: fix memory leak in zr364xx_start_readpipe
In reply to Greg Kroah-HartmanFrom: Pavel Skripkin <[email protected]>
commit 0a045eac8d0427b64577a24d74bb8347c905ac65 upstream.
syzbot reported memory leak in zr364xx driver.
The problem was in non-freed urb in case ofusb_submit_urb() fail.
backtrace:
[<ffffffff82baedf6>] kmalloc include/linux/slab.h:561 [inline] [<ffffffff82baedf6>] usb_alloc_urb+0x66/0xe0 drivers/usb/core/urb.c:74 [<ffffffff82f7cce8>] zr364xx_start_readpipe+0x78/0x130 drivers/media/usb/zr364xx/zr364xx.c:1022 [<ffffffff84251dfc>] zr364xx_board_init drivers/media/usb/zr364xx/zr364xx.c:1383 [inline] [<ffffffff84251dfc>] zr364xx_probe+0x6a3/0x851 drivers/media/usb/zr364xx/zr364xx.c:1516 [<ffffffff82bb6507>] usb_probe_interface+0x177/0x370 drivers/usb/core/driver.c:396 [<ffffffff826018a9>] really_probe+0x159/0x500 drivers/base/dd.c:576
--- drivers/media/usb/zr364xx/zr364xx.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/usb/zr364xx/zr364xx.c +1 -0
@@ -1032,6 +1032,7 @@ static int zr364xx_start_readpipe(structDBG ("submitting URB %p\n" , pipe_info->stream_urb); retval =usb_submit_urb (pipe_info->stream_urb,GFP_KERNEL );if (retval) { +usb_free_urb (pipe_info->stream_urb); printk(KERN_ERR KBUILD_MODNAME ": start read pipe failed\n");return retval; }
Greg Kroah-Hartman
maintainerPATCH 225/242 media: ccs: Fix the op_pll_multiplier address
In reply to Greg Kroah-HartmanFrom: Bernhard Wimmer <[email protected]>
commit 0e3e0c9369c822b7f1dd11504eeb98cfd4aabf24 upstream.
According to the CCS spec the op_pll_multiplier address is 0x030e, not 0x031e.
--- drivers/media/i2c/ccs/ccs-limits.c | 4 ++++ drivers/media/i2c/ccs/ccs-limits.h | 4 ++++ drivers/media/i2c/ccs/ccs-regs.h | 6 +++++- 3 files changed, 13 insertions(+), 1 deletion(-)
drivers/media/i2c/ccs/ccs-limits.c +4 -0
@@ -1,5 +1,9 @@// SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause /* Copyright (C) 2019--2020 Intel Corporation */ +/* +* Generated by Documentation/driver-api/media/drivers/ccs/mk-ccs-regs; +* do not modify. +*/ #include "ccs-limits.h" #include "ccs-regs.h"
drivers/media/i2c/ccs/ccs-limits.h +4 -0
@@ -1,5 +1,9 @@/* SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause */ /* Copyright (C) 2019--2020 Intel Corporation */ +/* +* Generated by Documentation/driver-api/media/drivers/ccs/mk-ccs-regs; +* do not modify. +*/ #ifndef __CCS_LIMITS_H__#define __CCS_LIMITS_H__
drivers/media/i2c/ccs/ccs-regs.h +5 -1
@@ -1,5 +1,9 @@/* SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause */ /* Copyright (C) 2019--2020 Intel Corporation */ +/* +* Generated by Documentation/driver-api/media/drivers/ccs/mk-ccs-regs; +* do not modify. +*/ #ifndef __CCS_REGS_H__#define __CCS_REGS_H__
@@ -202,7 +206,7 @@#define CCS_R_OP_PIX_CLK_DIV (0x0308 | CCS_FL_16BIT)#define CCS_R_OP_SYS_CLK_DIV (0x030a | CCS_FL_16BIT)#define CCS_R_OP_PRE_PLL_CLK_DIV (0x030c | CCS_FL_16BIT) -#define CCS_R_OP_PLL_MULTIPLIER (0x031e | CCS_FL_16BIT) +#define CCS_R_OP_PLL_MULTIPLIER (0x030e | CCS_FL_16BIT)#define CCS_R_PLL_MODE 0x0310#define CCS_PLL_MODE_SHIFT 0U#define CCS_PLL_MODE_MASK 0x1
Greg Kroah-Hartman
maintainerPATCH 226/242 media: gspca/sq905: fix control-request direction
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 53ae298fde7adcc4b1432bce2dbdf8dac54dfa72 upstream.
The direction of the pipe argument must match the request-type direction bit or control requests may fail depending on the host-controller-driver implementation.
Fix the USB_REQ_SYNCH_FRAME request which erroneously used usb_sndctrlpipe().
--- drivers/media/usb/gspca/sq905.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/gspca/sq905.c +1 -1
@@ -116,7 +116,7 @@ static int sq905_command(struct gspca_de } ret = usb_control_msg(gspca_dev->dev, - usb_sndctrlpipe(gspca_dev->dev, 0), + usb_rcvctrlpipe(gspca_dev->dev, 0), USB_REQ_SYNCH_FRAME, /* request */ USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, SQ905_PING, 0, gspca_dev->usb_buf, 1,
Greg Kroah-Hartman
maintainerPATCH 227/242 media: gspca/sunplus: fix zero-length control requests
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit b4bb4d425b7b02424afea2dfdcd77b3b4794175e upstream.
The direction of the pipe argument must match the request-type direction bit or control requests may fail depending on the host-controller-driver implementation.
Control transfers without a data stage are treated as OUT requests by the USB stack and should be using usb_sndctrlpipe(). Failing to do so will now trigger a warning.
Fix the single zero-length control request which was using the read-register helper, and update the helper so that zero-length reads fail with an error message instead.
--- drivers/media/usb/gspca/sunplus.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/media/usb/gspca/sunplus.c +6 -2
@@ -242,6 +242,10 @@ static void reg_r(struct gspca_dev *gspcgspca_err (gspca_dev,"reg_r: buffer overflow\n" );return ; } +if (len ==0 ) { +gspca_err (gspca_dev,"reg_r: zero-length read\n" ); +return ; + }if (gspca_dev->usb_err <0 )return ; ret = usb_control_msg(gspca_dev->dev,
@@ -250,7 +254,7 @@ static void reg_r(struct gspca_dev *gspcUSB_DIR_IN |USB_TYPE_VENDOR |USB_RECIP_DEVICE ,0 ,/* value */ index, - len ? gspca_dev->usb_buf :NULL , len, + gspca_dev->usb_buf, len, 500);if (ret <0 ) {pr_err ("reg_r err %d\n" , ret);
@@ -727,7 +731,7 @@ static int sd_start(struct gspca_dev *gscase MegaImageVI:reg_w_riv (gspca_dev,0xf0 ,0 ,0 );spca504B_WaitCmdStatus (gspca_dev); -reg_r (gspca_dev,0xf0 ,4 ,0 ); +reg_w_riv (gspca_dev,0xf0 ,4 ,0 );spca504B_WaitCmdStatus (gspca_dev);break ;default :
Greg Kroah-Hartman
maintainerPATCH 228/242 media: rtl28xxu: fix zero-length control request
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 25d5ce3a606a1eb23a9265d615a92a876ff9cb5f upstream.
The direction of the pipe argument must match the request-type direction bit or control requests may fail depending on the host-controller-driver implementation.
Control transfers without a data stage are treated as OUT requests by the USB stack and should be using usb_sndctrlpipe(). Failing to do so will now trigger a warning.
Fix the zero-length i2c-read request used for type detection by attempting to read a single byte instead.
--- drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/usb/dvb-usb-v2/rtl28xxu.c +2 -1
@@ -612,8 +612,9 @@ static int rtl28xxu_read_config(struct dstatic int rtl28xxu_identify_state (struct dvb_usb_device *d,const char **name) {struct rtl28xxu_dev *dev =d_to_priv (d); +u8 buf[1 ];int ret; -struct rtl28xxu_req req_demod_i2c = {0x0020 ,CMD_I2C_DA_RD ,0 ,NULL }; +struct rtl28xxu_req req_demod_i2c = {0x0020 ,CMD_I2C_DA_RD ,1 , buf};dev_dbg (&d->intf->dev,"\n" );
Greg Kroah-Hartman
maintainerPATCH 229/242 media: uvcvideo: Fix pixel format change for Elgato Cam Link 4K
In reply to Greg Kroah-HartmanFrom: Benjamin Drung <[email protected]>
commit 4c6e0976295add7f0ed94d276c04a3d6f1ea8f83 upstream.
The Elgato Cam Link 4K HDMI video capture card reports to support three different pixel formats, where the first format depends on the connected HDMI device.
``` $ v4l2-ctl -d /dev/video0 --list-formats-ext ioctl: VIDIOC_ENUM_FMT Type: Video Capture [0]: 'NV12' (Y/CbCr 4:2:0) Size: Discrete 3840x2160 Interval: Discrete 0.033s (29.970 fps) [1]: 'NV12' (Y/CbCr 4:2:0) Size: Discrete 3840x2160 Interval: Discrete 0.033s (29.970 fps) [2]: 'YU12' (Planar YUV 4:2:0) Size: Discrete 3840x2160 Interval: Discrete 0.033s (29.970 fps) ```
Changing the pixel format to anything besides the first pixel format does not work:
``` $ v4l2-ctl -d /dev/video0 --try-fmt-video pixelformat=YU12 Format Video Capture: Width/Height : 3840/2160 Pixel Format : 'NV12' (Y/CbCr 4:2:0) Field : None Bytes per Line : 3840 Size Image : 12441600 Colorspace : sRGB Transfer Function : Rec. 709 YCbCr/HSV Encoding: Rec. 709 Quantization : Default (maps to Limited Range) Flags : ```
User space applications like VLC might show an error message on the terminal in that case:
``` libv4l2: error set_fmt gave us a different result than try_fmt! ```
Depending on the error handling of the user space applications, they might display a distorted video, because they use the wrong pixel format for decoding the stream.
The Elgato Cam Link 4K responds to the USB video probe VS_PROBE_CONTROL/VS_COMMIT_CONTROL with a malformed data structure: The second byte contains bFormatIndex (instead of being the second byte of bmHint). The first byte is always zero. The third byte is always 1.
The firmware bug was reported to Elgato on 2020-12-01 and it was forwarded by the support team to the developers as feature request. There is no firmware update available since then. The latest firmware for Elgato Cam Link 4K as of 2021-03-23 has MCU 20.02.19 and FPGA 67.
Therefore correct the malformed data structure for this device. The change was successfully tested with VLC, OBS, and Chromium using different pixel formats (YUYV, NV12, YU12), resolutions (3840x2160, 1920x1080), and frame rates (29.970 and 59.940 fps).
--- drivers/media/usb/uvc/uvc_video.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
drivers/media/usb/uvc/uvc_video.c +27 -0
@@ -124,10 +124,37 @@ int uvc_query_ctrl(struct uvc_device *destatic void uvc_fixup_video_ctrl (struct uvc_streaming *stream,struct uvc_streaming_control *ctrl) { +static const struct usb_device_id elgato_cam_link_4k = { +USB_DEVICE (0x0fd9 ,0x0066 ) + };struct uvc_format *format =NULL ;struct uvc_frame *frame =NULL ;unsigned int i; +/* +* The response of the Elgato Cam Link 4K is incorrect: The second byte +* contains bFormatIndex (instead of being the second byte of bmHint). +* The first byte is always zero. The third byte is always 1. +* +* The UVC 1.5 class specification defines the first five bits in the +* bmHint bitfield. The remaining bits are reserved and should be zero. +* Therefore a valid bmHint will be less than 32. +* +* Latest Elgato Cam Link 4K firmware as of 2021-03-23 needs this fix. +* MCU: 20.02.19, FPGA: 67 +*/ +if (usb_match_one_id (stream->dev->intf, &elgato_cam_link_4k) && + ctrl->bmHint >255 ) { +u8 corrected_format_index = ctrl->bmHint >>8 ; + +uvc_dbg (stream->dev,VIDEO , +"Correct USB video probe response from {bmHint: 0x%04x, bFormatIndex: %u} to {bmHint: 0x%04x, bFormatIndex: %u}\n" , + ctrl->bmHint, ctrl->bFormatIndex, +1 , corrected_format_index); + ctrl->bmHint =1 ; + ctrl->bFormatIndex = corrected_format_index; + } +for (i =0 ; i < stream->nformats; ++i) {if (stream->format[i].index == ctrl->bFormatIndex) { format = &stream->format[i];
Greg Kroah-Hartman
maintainerPATCH 230/242 s390/vdso: always enable vdso
In reply to Greg Kroah-HartmanFrom: Sven Schnelle <[email protected]>
commit d57778feb9878aa6b79c615fd029c2112d40a747 upstream.
With the upcoming move of the svc sigreturn instruction from the signal frame to vdso we need to have vdso always enabled.
--- arch/s390/include/asm/elf.h | 11 ++++------- arch/s390/kernel/vdso.c | 21 ++++----------------- 2 files changed, 8 insertions(+), 24 deletions(-)
arch/s390/include/asm/elf.h +4 -7
@@ -146,8 +146,6 @@ typedef s390_compat_regs compat_elf_greg#include <asm/vdso.h> -extern unsigned int vdso_enabled; -/* * This is used to ensure we don't load something for the wrong architecture. */
@@ -268,11 +266,10 @@ do { \#define STACK_RND_MASK MMAP_RND_MASK/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */ -#define ARCH_DLINFO \ -do { \ - if (vdso_enabled) \ - NEW_AUX_ENT(AT_SYSINFO_EHDR, \ - (unsigned long)current->mm->context.vdso_base); \ +#define ARCH_DLINFO \ +do { \ + NEW_AUX_ENT(AT_SYSINFO_EHDR, \ + (unsigned long)current->mm->context.vdso_base); \ } while (0)struct linux_binprm ;
arch/s390/kernel/vdso.c +4 -17
@@ -37,18 +37,6 @@ enum vvar_pages { VVAR_NR_PAGES, }; -unsigned int __read_mostly vdso_enabled =1 ; - -static int __init vdso_setup (char *str) -{ -bool enabled; - -if (!kstrtobool (str, &enabled)) - vdso_enabled = enabled; -return 1 ; -} -__setup ("vdso=" , vdso_setup); -#ifdef CONFIG_TIME_NS struct vdso_data *arch_get_vdso_data (void *vvar_page) {
@@ -176,7 +164,7 @@ int arch_setup_additional_pages(struct lint rc;BUILD_BUG_ON (VVAR_NR_PAGES != __VVAR_PAGES); -if (!vdso_enabled ||is_compat_task ()) +if (is_compat_task ())return 0 ;if (mmap_write_lock_killable (mm))return -EINTR ;
@@ -218,10 +206,9 @@ static int __init vdso_init(void) vdso_pages = (vdso64_end - vdso64_start) >>PAGE_SHIFT ; pages =kcalloc (vdso_pages +1 ,sizeof (struct page *),GFP_KERNEL ); -if (!pages) { - vdso_enabled =0 ; -return -ENOMEM ; - } +if (!pages) +panic ("failed to allocate VDSO pages" ); +for (i =0 ; i < vdso_pages; i++) pages[i] =virt_to_page (vdso64_start + i *PAGE_SIZE ); pages[vdso_pages] =NULL ;
Greg Kroah-Hartman
maintainerPATCH 231/242 s390/vdso64: add sigreturn,rt_sigreturn and restart_syscall
In reply to Greg Kroah-HartmanFrom: Sven Schnelle <[email protected]>
commit 686341f2548b5a4c4ab1ee22427e046027ae1c9c upstream.
Add minimalistic trampolines to vdso64 so we can return from signal without using the stack which requires pgm check handler hacks when NX is enabled.
restart_syscall will be called from vdso to work around the architectural limitation that the syscall number might be encoded in the svc instruction, and therefore can not be changed.
--- arch/s390/kernel/vdso64/vdso64.lds.S | 3 +++ arch/s390/kernel/vdso64/vdso_user_wrapper.S | 17 +++++++++++++++++ 2 files changed, 20 insertions(+)
arch/s390/kernel/vdso64/vdso64.lds.S +3 -0
@@ -137,6 +137,9 @@ VERSION __kernel_clock_gettime; __kernel_clock_getres; __kernel_getcpu; + __kernel_restart_syscall; + __kernel_rt_sigreturn; + __kernel_sigreturn; local: *; }; }
arch/s390/kernel/vdso64/vdso_user_wrapper.S +17 -0
@@ -37,3 +37,20 @@ vdso_func gettimeofday vdso_func clock_getres vdso_func clock_gettime vdso_func getcpu + +.macro vdso_syscall func,syscall + .globl __kernel_\func + .type __kernel_\func,@function + .align 8 +__kernel_\func: + CFI_STARTPROC + svc \syscall + /* Make sure we notice when a syscall returns, which shouldn't happen */ + .word 0 + CFI_ENDPROC + .size __kernel_\func,.-__kernel_\func +.endm + +vdso_syscall restart_syscall,__NR_restart_syscall +vdso_syscall sigreturn,__NR_sigreturn +vdso_syscall rt_sigreturn,__NR_rt_sigreturn
Greg Kroah-Hartman
maintainerPATCH 232/242 s390/vdso: rename VDSO64_LBASE to VDSO_LBASE
In reply to Greg Kroah-HartmanFrom: Sven Schnelle <[email protected]>
commit 43e1f76b0b69b86b2175ef755243e61fe40c75db upstream.
Will be used by both vdso32 and vdso64, so change the name.
--- arch/s390/include/asm/vdso.h | 2 +- arch/s390/kernel/vdso64/vdso64.lds.S | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/s390/include/asm/vdso.h +1 -1
@@ -5,7 +5,7 @@#include <vdso/datapage.h> /* Default link address for the vDSO */ -#define VDSO64_LBASE 0 +#define VDSO_LBASE 0#define __VVAR_PAGES 2
arch/s390/kernel/vdso64/vdso64.lds.S +1 -1
@@ -17,7 +17,7 @@ SECTIONS #ifdef CONFIG_TIME_NS PROVIDE(_timens_data = _vdso_data + PAGE_SIZE); #endif - . = VDSO64_LBASE + SIZEOF_HEADERS; + . = VDSO_LBASE + SIZEOF_HEADERS; .hash : { *(.hash) } :text .gnu.hash : { *(.gnu.hash) }
Greg Kroah-Hartman
maintainerPATCH 233/242 s390/vdso: add minimal compat vdso
In reply to Greg Kroah-HartmanFrom: Sven Schnelle <[email protected]>
commit 779df2248739b6308c03b354c99e4c352141e3bc upstream.
Add a small vdso for 31 bit compat application that provides trampolines for calls to sigreturn,rt_sigreturn,syscall_restart. This is requird for moving these syscalls away from the signal frame to the vdso. Note that this patch effectively disables CONFIG_COMPAT when using clang to compile the kernel. clang doesn't support 31 bit mode.
We want to redirect sigreturn and restart_syscall to the vdso. However, the kernel cannot parse the ELF vdso file, so we need to generate header files which contain the offsets of the syscall instructions in the vdso page.
--- arch/s390/Kconfig | 1 arch/s390/Makefile | 13 ++ arch/s390/include/asm/elf.h | 2 arch/s390/include/asm/vdso.h | 27 +++-- arch/s390/include/asm/vdso/gettimeofday.h | 1 arch/s390/kernel/Makefile | 1 arch/s390/kernel/vdso.c | 50 ++++++--- arch/s390/kernel/vdso32/.gitignore | 2 arch/s390/kernel/vdso32/Makefile | 75 ++++++++++++++ arch/s390/kernel/vdso32/gen_vdso_offsets.sh | 15 ++ arch/s390/kernel/vdso32/note.S | 13 ++ arch/s390/kernel/vdso32/vdso32.lds.S | 141 ++++++++++++++++++++++++++++ arch/s390/kernel/vdso32/vdso32_wrapper.S | 15 ++ arch/s390/kernel/vdso32/vdso_user_wrapper.S | 21 ++++ arch/s390/kernel/vdso64/Makefile | 8 + arch/s390/kernel/vdso64/gen_vdso_offsets.sh | 15 ++ 16 files changed, 373 insertions(+), 27 deletions(-) create mode 100644 arch/s390/kernel/vdso32/.gitignore create mode 100644 arch/s390/kernel/vdso32/Makefile create mode 100755 arch/s390/kernel/vdso32/gen_vdso_offsets.sh create mode 100644 arch/s390/kernel/vdso32/note.S create mode 100644 arch/s390/kernel/vdso32/vdso32.lds.S create mode 100644 arch/s390/kernel/vdso32/vdso32_wrapper.S create mode 100644 arch/s390/kernel/vdso32/vdso_user_wrapper.S create mode 100755 arch/s390/kernel/vdso64/gen_vdso_offsets.sh
arch/s390/Kconfig +1 -0
@@ -434,6 +434,7 @@ config COMPAT select COMPAT_OLD_SIGACTION select HAVE_UID16 depends on MULTIUSER + depends on !CC_IS_CLANG help Select this option if you want to enable your system kernel to handle system-calls from ELF binaries for 31 bit ESA. This option
arch/s390/Makefile +13 -0
@@ -165,6 +165,19 @@ archheaders: archprepare: $(Q)$(MAKE) $(build)=$(syscalls) kapi $(Q)$(MAKE) $(build)=$(tools) kapi +ifeq ($(KBUILD_EXTMOD),) +# We need to generate vdso-offsets.h before compiling certain files in kernel/. +# In order to do that, we should use the archprepare target, but we can't since +# asm-offsets.h is included in some files used to generate vdso-offsets.h, and +# asm-offsets.h is built in prepare0, for which archprepare is a dependency. +# Therefore we need to generate the header after prepare0 has been made, hence +# this hack. +prepare: vdso_prepare +vdso_prepare: prepare0 + $(Q)$(MAKE) $(build)=arch/s390/kernel/vdso64 include/generated/vdso64-offsets.h + $(if $(CONFIG_COMPAT),$(Q)$(MAKE) \ + $(build)=arch/s390/kernel/vdso32 include/generated/vdso32-offsets.h) +endif # Don't use tabs in echo arguments define archhelp
arch/s390/include/asm/elf.h +0 -2
@@ -144,8 +144,6 @@ typedef s390_compat_regs compat_elf_greg#include <linux/sched/mm.h> /* for task_struct */ #include <asm/mmu_context.h> -#include <asm/vdso.h> -/* * This is used to ensure we don't load something for the wrong architecture. */
arch/s390/include/asm/vdso.h +20 -7
@@ -4,18 +4,31 @@#include <vdso/datapage.h> -/* Default link address for the vDSO */ -#define VDSO_LBASE 0 - -#define __VVAR_PAGES 2 - -#define VDSO_VERSION_STRING LINUX_2.6.29 -#ifndef __ASSEMBLY__ +#include <generated/vdso64-offsets.h> +#ifdef CONFIG_COMPAT +#include <generated/vdso32-offsets.h> +#endif + +#define VDSO64_SYMBOL (tsk, name) ((tsk)->mm->context.vdso_base + (vdso64_offset_##name)) +#ifdef CONFIG_COMPAT +#define VDSO32_SYMBOL (tsk, name) ((tsk)->mm->context.vdso_base + (vdso32_offset_##name)) +#else +#define VDSO32_SYMBOL (tsk, name) (-1UL) +#endif +extern struct vdso_data *vdso_data;int vdso_getcpu_init (void );#endif /* __ASSEMBLY__ */ + +/* Default link address for the vDSO */ +#define VDSO_LBASE 0 + +#define __VVAR_PAGES 2 + +#define VDSO_VERSION_STRING LINUX_2.6.29 +#endif /* __S390_VDSO_H__ */
arch/s390/include/asm/vdso/gettimeofday.h +0 -1
@@ -8,7 +8,6 @@#include <asm/timex.h> #include <asm/unistd.h> -#include <asm/vdso.h> #include <linux/compiler.h> #define vdso_calc_delta __arch_vdso_calc_delta
arch/s390/kernel/Makefile +1 -0
@@ -78,3 +78,4 @@ obj-$(findstring y, $(CONFIG_PROTECTED_V # vdso obj-y += vdso64/ +obj-$(CONFIG_COMPAT) += vdso32/
arch/s390/kernel/vdso.c +33 -17
90 lines not on this page · raw message
arch/s390/kernel/vdso32/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +vdso32.lds
arch/s390/kernel/vdso32/Makefile new file +75 -0
75 lines not on this page · raw message
arch/s390/kernel/vdso32/gen_vdso_offsets.sh new file +15 -0
@@ -0,0 +1,15 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +# +# Match symbols in the DSO that look like VDSO_*; produce a header file +# of constant offsets into the shared object. +# +# Doing this inside the Makefile will break the $(filter-out) function, +# causing Kbuild to rebuild the vdso-offsets header file every time. +# +# Inspired by arm64 version. +# + +LC_ALL=C +sed -n 's/\([0-9a-f]*\) . __kernel_compat_\(.*\)/\#define vdso32_offset_\2\t0x\1/p'
arch/s390/kernel/vdso32/note.S new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * This supplies .note.* sections to go into the PT_NOTE inside the vDSO text. + * Here we can supply some information useful to userland. + */ + +#include <linux/uts.h> +#include <linux/version.h> +#include <linux/elfnote.h> + +ELFNOTE_START(Linux, 0, "a") + .long LINUX_VERSION_CODE +ELFNOTE_END
arch/s390/kernel/vdso32/vdso32.lds.S new file +141 -0
141 lines not on this page · raw message
arch/s390/kernel/vdso32/vdso32_wrapper.S new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#include <linux/init.h> +#include <linux/linkage.h> +#include <asm/page.h> + + __PAGE_ALIGNED_DATA + + .globl vdso32_start, vdso32_end + .balign PAGE_SIZE +vdso32_start: + .incbin "arch/s390/kernel/vdso32/vdso32.so" + .balign PAGE_SIZE +vdso32_end: + + .previous
arch/s390/kernel/vdso32/vdso_user_wrapper.S new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#include <asm/unistd.h> +#include <asm/dwarf.h> + +.macro vdso_syscall func,syscall + .globl __kernel_compat_\func + .type __kernel_compat_\func,@function + .align 8 +__kernel_compat_\func: + CFI_STARTPROC + svc \syscall + /* Make sure we notice when a syscall returns, which shouldn't happen */ + .word 0 + CFI_ENDPROC + .size __kernel_compat_\func,.-__kernel_compat_\func +.endm + +vdso_syscall restart_syscall,__NR_restart_syscall +vdso_syscall sigreturn,__NR_sigreturn +vdso_syscall rt_sigreturn,__NR_rt_sigreturn
arch/s390/kernel/vdso64/Makefile +8 -0
@@ -74,3 +74,11 @@ vdso64.so: $(obj)/vdso64.so.dbg $(call cmd,vdso_install) vdso_install: vdso64.so + +# Generate VDSO offsets using helper script +gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh +quiet_cmd_vdsosym = VDSOSYM $@ + cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ + +include/generated/vdso64-offsets.h: $(obj)/vdso64.so.dbg FORCE + $(call if_changed,vdsosym)
arch/s390/kernel/vdso64/gen_vdso_offsets.sh new file +15 -0
@@ -0,0 +1,15 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +# +# Match symbols in the DSO that look like VDSO_*; produce a header file +# of constant offsets into the shared object. +# +# Doing this inside the Makefile will break the $(filter-out) function, +# causing Kbuild to rebuild the vdso-offsets header file every time. +# +# Inspired by arm64 version. +# + +LC_ALL=C +sed -n 's/\([0-9a-f]*\) . __kernel_\(.*\)/\#define vdso64_offset_\2\t0x\1/p'
Greg Kroah-Hartman
maintainerPATCH 234/242 s390/signal: switch to using vdso for sigreturn and syscall restart
In reply to Greg Kroah-HartmanFrom: Sven Schnelle <[email protected]>
commit df29a7440c4b5c65765c8f60396b3b13063e24e9 upstream.
with generic entry, there's a bug when it comes to restarting of signals. The failing sequence is:
a) a signal is coming in, and no handler is registered, so the lower part of arch_do_signal_or_restart() in arch/s390/kernel/signal.c sets PIF_SYSCALL_RESTART.
b) a second signal gets pending while the kernel is still in the exit loop, and for that one, a handler exists.
c) The first part of arch_do_signal_or_restart() is called. That part calls handle_signal(), which sets up stack + registers for handling the signal.
d) __do_syscall() in arch/s390/kernel/syscall.c checks for PIF_SYSCALL_RESTART right before leaving to userspace. If it is set, it restart's the syscall. However, the registers are already setup for handling a signal from c). The syscall is now restarted with the wrong arguments.
Change the code to:
- use vdso for syscall_restart() instead of PIF_SYSCALL_RESTART because we cannot rewind and go back to userspace on s390 because the system call number might be encoded in the svc instruction.
- for all other syscalls we rewind the PSW and return to userspace.
--- arch/s390/kernel/compat_signal.c | 13 +++---------- arch/s390/kernel/process.c | 6 ++++++ arch/s390/kernel/signal.c | 39 ++++++++++++++++++--------------------- arch/s390/kernel/syscall.c | 4 ++++ 4 files changed, 31 insertions(+), 31 deletions(-)
arch/s390/kernel/compat_signal.c +3 -10
@@ -28,6 +28,7 @@#include <linux/uaccess.h> #include <asm/lowcore.h> #include <asm/switch_to.h> +#include <asm/vdso.h> #include "compat_linux.h" #include "compat_ptrace.h" #include "entry.h"
@@ -118,7 +119,6 @@ static int restore_sigregs32(struct pt_rfpregs_load ((_s390_fp_regs *) &user_sregs.fpregs, ¤t->thread.fpu);clear_pt_regs_flag (regs,PIF_SYSCALL );/* No longer in a system call */ -clear_pt_regs_flag (regs,PIF_SYSCALL_RESTART );return 0 ; }
@@ -304,11 +304,7 @@ static int setup_frame32(struct ksignal restorer = (unsigned long __force ) ksig->ka.sa.sa_restorer |PSW32_ADDR_AMODE ; }else { -/* Signal frames without vectors registers are short ! */ -__u16 __user *svc = (void __user *) frame + frame_size -2 ; -if (__put_user (S390_SYSCALL_OPCODE | __NR_sigreturn, svc)) -return -EFAULT ; - restorer = (unsigned long __force ) svc |PSW32_ADDR_AMODE ; + restorer =VDSO32_SYMBOL (current, sigreturn); }/* Set up registers for signal handler */
@@ -371,10 +367,7 @@ static int setup_rt_frame32(struct ksign restorer = (unsigned long __force ) ksig->ka.sa.sa_restorer |PSW32_ADDR_AMODE ; }else { -__u16 __user *svc = &frame->svc_insn; -if (__put_user (S390_SYSCALL_OPCODE | __NR_rt_sigreturn, svc)) -return -EFAULT ; - restorer = (unsigned long __force ) svc |PSW32_ADDR_AMODE ; + restorer =VDSO32_SYMBOL (current, rt_sigreturn); }/* Create siginfo on the signal stack */
arch/s390/kernel/process.c +6 -0
@@ -166,6 +166,12 @@ int copy_thread(unsigned long clone_flag p->thread.acrs[1 ] = (unsigned int )tls; } } +/* +* s390 stores the svc return address in arch_data when calling +* sigreturn()/restart_syscall() via vdso. 1 means no valid address +* stored. +*/ + p->restart_block.arch_data =1 ;return 0 ; }
arch/s390/kernel/signal.c +18 -21
@@ -32,6 +32,7 @@#include <linux/uaccess.h> #include <asm/lowcore.h> #include <asm/switch_to.h> +#include <asm/vdso.h> #include "entry.h" /*
@@ -171,7 +172,6 @@ static int restore_sigregs(struct pt_regfpregs_load (&user_sregs.fpregs, ¤t->thread.fpu);clear_pt_regs_flag (regs,PIF_SYSCALL );/* No longer in a system call */ -clear_pt_regs_flag (regs,PIF_SYSCALL_RESTART );return 0 ; }
@@ -334,15 +334,10 @@ static int setup_frame(int sig, struct k/* Set up to return from userspace. If provided, use a stub already in userspace. */ -if (ka->sa.sa_flags &SA_RESTORER ) { +if (ka->sa.sa_flags &SA_RESTORER ) restorer = (unsigned long ) ka->sa.sa_restorer; - }else { -/* Signal frame without vector registers are short ! */ -__u16 __user *svc = (void __user *) frame + frame_size -2 ; -if (__put_user (S390_SYSCALL_OPCODE | __NR_sigreturn, svc)) -return -EFAULT ; - restorer = (unsigned long ) svc; - } +else + restorer =VDSO64_SYMBOL (current, sigreturn);/* Set up registers for signal handler */ regs->gprs[14 ] = restorer;
@@ -397,14 +392,10 @@ static int setup_rt_frame(struct ksignal/* Set up to return from userspace. If provided, use a stub already in userspace. */ -if (ksig->ka.sa.sa_flags &SA_RESTORER ) { +if (ksig->ka.sa.sa_flags &SA_RESTORER ) restorer = (unsigned long ) ksig->ka.sa.sa_restorer; - }else { -__u16 __user *svc = &frame->svc_insn; -if (__put_user (S390_SYSCALL_OPCODE | __NR_rt_sigreturn, svc)) -return -EFAULT ; - restorer = (unsigned long ) svc; - } +else + restorer =VDSO64_SYMBOL (current, rt_sigreturn);/* Create siginfo on the signal stack */ if (copy_siginfo_to_user (&frame->info, &ksig->info))
@@ -501,7 +492,7 @@ void arch_do_signal_or_restart(struct pt }/* No longer in a system call */ clear_pt_regs_flag (regs,PIF_SYSCALL ); -clear_pt_regs_flag (regs,PIF_SYSCALL_RESTART ); +rseq_signal_deliver (&ksig, regs);if (is_compat_task ())handle_signal32 (&ksig, oldset, regs);
@@ -517,14 +508,20 @@ void arch_do_signal_or_restart(struct ptswitch (regs->gprs[2 ]) {case -ERESTART_RESTARTBLOCK :/* Restart with sys_restart_syscall */ - regs->int_code = __NR_restart_syscall; - fallthrough; + regs->gprs[2 ] = regs->orig_gpr2; + current->restart_block.arch_data = regs->psw.addr; +if (is_compat_task ()) + regs->psw.addr =VDSO32_SYMBOL (current, restart_syscall); +else + regs->psw.addr =VDSO64_SYMBOL (current, restart_syscall); +if (test_thread_flag (TIF_SINGLE_STEP )) +clear_thread_flag (TIF_PER_TRAP ); +break ;case -ERESTARTNOHAND :case -ERESTARTSYS :case -ERESTARTNOINTR : -/* Restart system call with magic TIF bit. */ regs->gprs[2 ] = regs->orig_gpr2; -set_pt_regs_flag (regs,PIF_SYSCALL_RESTART ); + regs->psw.addr =__rewind_psw (regs->psw, regs->int_code >>16 );if (test_thread_flag (TIF_SINGLE_STEP ))clear_thread_flag (TIF_PER_TRAP );break ;
arch/s390/kernel/syscall.c +4 -0
@@ -121,6 +121,10 @@ void do_syscall(struct pt_regs *regs) regs->gprs[2 ] = nr; +if (nr == __NR_restart_syscall && !(current->restart_block.arch_data &1 )) { + regs->psw.addr = current->restart_block.arch_data; + current->restart_block.arch_data =1 ; + } nr =syscall_enter_from_user_mode_work (regs, nr);/*
Greg Kroah-Hartman
maintainerPATCH 235/242 dm writecache: write at least 4k when committing
In reply to Greg Kroah-HartmanFrom: Mikulas Patocka <[email protected]>
commit 867de40c4c23e6d7f89f9ce4272a5d1b1484c122 upstream.
SSDs perform badly with sub-4k writes (because they perfrorm read-modify-write internally), so make sure writecache writes at least 4k when committing.
--- drivers/md/dm-writecache.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/md/dm-writecache.c +5 -1
@@ -532,7 +532,11 @@ static void ssd_commit_superblock(struct region.bdev = wc->ssd_dev->bdev; region.sector =0 ; - region.count = wc->block_size >>SECTOR_SHIFT ; + region.count =max (4096U , wc->block_size) >>SECTOR_SHIFT ; + +if (unlikely (region.sector + region.count > wc->metadata_sectors)) + region.count = wc->metadata_sectors - region.sector; + region.sector += wc->start_sector; req.bi_op =REQ_OP_WRITE ;
Greg Kroah-Hartman
maintainerPATCH 236/242 pinctrl: mcp23s08: Fix missing unlock on error in mcp23s08_irq()
In reply to Greg Kroah-HartmanFrom: Zou Wei <[email protected]>
commit 884af72c90016cfccd5717439c86b48702cbf184 upstream.
Add the missing unlock before return from function mcp23s08_irq() in the error handling case.
v1-->v2:
remove the "return IRQ_HANDLED" line
--- drivers/pinctrl/pinctrl-mcp23s08.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/pinctrl-mcp23s08.c +1 -1
@@ -353,7 +353,7 @@ static irqreturn_t mcp23s08_irq(int irq,if (intf ==0 ) {/* There is no interrupt pending */ -return IRQ_HANDLED ; + goto unlock; }if (mcp_read (mcp,MCP_INTCAP , &intcap))
Greg Kroah-Hartman
maintainerPATCH 237/242 drm/ast: Remove reference to struct drm_device.pdev
In reply to Greg Kroah-HartmanFrom: Thomas Zimmermann <[email protected]>
commit 0ecb51824e838372e01330752503ddf9c0430ef7 upstream.
Using struct drm_device.pdev is deprecated. Upcast with to_pci_dev() from struct drm_device.dev to get the PCI device structure.
v9:
* fix remaining pdev references
--- drivers/gpu/drm/ast/ast_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/ast/ast_main.c +2 -3
@@ -411,7 +411,6 @@ struct ast_private *ast_device_create(coreturn ast; dev = &ast->base; - dev->pdev = pdev;pci_set_drvdata (pdev, dev); ast->regs =pcim_iomap (pdev,1 ,0 );
@@ -453,8 +452,8 @@ struct ast_private *ast_device_create(co/* map reserved buffer */ ast->dp501_fw_buf =NULL ; -if (dev->vram_mm->vram_size <pci_resource_len (dev->pdev,0 )) { - ast->dp501_fw_buf =pci_iomap_range (dev->pdev,0 , dev->vram_mm->vram_size,0 ); +if (dev->vram_mm->vram_size <pci_resource_len (pdev,0 )) { + ast->dp501_fw_buf =pci_iomap_range (pdev,0 , dev->vram_mm->vram_size,0 );if (!ast->dp501_fw_buf)drm_info (dev,"failed to map reserved buffer!\n" ); }
Re: [PATCH 5.12 237/242] drm/ast: Remove reference to struct drm_device.pdev
Quoted 37 lines · Greg Kroah-Hartman
From: Thomas Zimmermann <[email protected]>
commit
0ecb51824e838372e01330752503ddf9c0430ef7upstream.Using struct drm_device.pdev is deprecated. Upcast with
to_pci_dev()from struct drm_device.dev to get the PCI device structure.v9:
* fix remaining pdev referencesSigned-off-by Thomas Zimmermann <[email protected]>Reviewed-by Michael J. Ruhl <[email protected]>Fixes ba4e0339a6a3 ("drm/ast: Fixed CVE for DP501")Cc KuoHsiang Chou <[email protected]>Cc kernel test robot <[email protected]>Cc Thomas Zimmermann <[email protected]>Cc Dave Airlie <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/gpu/drm/ast/ast_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/gpu/drm/ast/ast_main.c +0
-1@@ -411,7 +411,6 @@ struct ast_private *ast_device_create(coreturn ast; dev = &ast->base; - dev->pdev = pdev;pci_set_drvdata (pdev, dev); ast->regs =pcim_iomap (pdev,1 ,0 );
drivers/gpu/drm/ast/ast_main.c struct ast_private *ast_device_create(co · line 459
Quoted 10 lines
drivers/gpu/drm/ast/ast_main.c +2
-2@@ -453,8 +452,8 @@ struct ast_private *ast_device_create(co/* map reserved buffer */ ast->dp501_fw_buf =NULL ; -if (dev->vram_mm->vram_size <pci_resource_len (dev->pdev,0 )) { - ast->dp501_fw_buf =pci_iomap_range (dev->pdev,0 , dev->vram_mm->vram_size,0 ); +if (dev->vram_mm->vram_size <pci_resource_len (pdev,0 )) { + ast->dp501_fw_buf =pci_iomap_range (pdev,0 , dev->vram_mm->vram_size,0 );if (!ast->dp501_fw_buf)drm_info (dev,"failed to map reserved buffer!\n" ); }
Hi Greg,
This backport is incomplete for 5.10 kernel, kernel is panicked
on RIP: ast_device_create+0x7d. When I look into the crash code, I found
struct ast_private *ast_device_create(struct drm_driver *drv,
struct pci_dev *pdev, unsigned long flags)
{
.......
dev->pdev = pdev; // This is removed
pci_set_drvdata(pdev, dev);
ast->regs = pcim_iomap(pdev, 1, 0);
if (!ast->regs)
return ERR_PTR(-EIO);
/*
* If we don't have IO space at all, use MMIO now and
* assume the chip has MMIO enabled by default (rev 0x20
* and higher).
*/
if (!(pci_resource_flags(dev->pdev, 2) & IORESOURCE_IO)) { //
dev->pdev is in used here.
drm_info(dev, "platform has no IO space, trying MMIO\n");
ast->ioregs = ast->regs + AST_IO_MM_OFFSET;
}
That's because commit 46fb883c3d0d8a823ef995ddb1f9b0817dea6882is not backported to 5.10 kernel.
Best Regards
Xiaotian
Greg Kroah-Hartman
maintainerRe: [PATCH 5.12 237/242] drm/ast: Remove reference to struct drm_device.pdev
Quoted 80 lines · Xiaotian Feng
Quoted 37 lines · Greg Kroah-Hartman
From: Thomas Zimmermann <[email protected]>
commit
0ecb51824e838372e01330752503ddf9c0430ef7upstream.Using struct drm_device.pdev is deprecated. Upcast with
to_pci_dev()from struct drm_device.dev to get the PCI device structure.v9:
* fix remaining pdev referencesSigned-off-by Thomas Zimmermann <[email protected]>Reviewed-by Michael J. Ruhl <[email protected]>Fixes ba4e0339a6a3 ("drm/ast: Fixed CVE for DP501")Cc KuoHsiang Chou <[email protected]>Cc kernel test robot <[email protected]>Cc Thomas Zimmermann <[email protected]>Cc Dave Airlie <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/gpu/drm/ast/ast_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/gpu/drm/ast/ast_main.c +0
-1@@ -411,7 +411,6 @@ struct ast_private *ast_device_create(coreturn ast; dev = &ast->base; - dev->pdev = pdev;pci_set_drvdata (pdev, dev); ast->regs =pcim_iomap (pdev,1 ,0 );drivers/gpu/drm/ast/ast_main.c struct ast_private *ast_device_create(co · line 459
Quoted 10 lines
drivers/gpu/drm/ast/ast_main.c +2
-2@@ -453,8 +452,8 @@ struct ast_private *ast_device_create(co/* map reserved buffer */ ast->dp501_fw_buf =NULL ; -if (dev->vram_mm->vram_size <pci_resource_len (dev->pdev,0 )) { - ast->dp501_fw_buf =pci_iomap_range (dev->pdev,0 , dev->vram_mm->vram_size,0 ); +if (dev->vram_mm->vram_size <pci_resource_len (pdev,0 )) { + ast->dp501_fw_buf =pci_iomap_range (pdev,0 , dev->vram_mm->vram_size,0 );if (!ast->dp501_fw_buf)drm_info (dev,"failed to map reserved buffer!\n" ); }Hi Greg,
This backport is incomplete for 5.10 kernel, kernel is panicked
on RIP:ast_device_create+0x7d. When I look into the crash code, I foundstruct
ast_private*ast_device_create(structdrm_driver*drv,
structpci_dev*pdev, unsigned long flags)
{
.......dev->pdev = pdev; // This is removed pci_set_drvdata(pdev, dev); ast->regs = pcim_iomap(pdev, 1, 0); if (!ast->regs) return ERR_PTR(-EIO); /* * If we don't have IO space at all, use MMIO now and * assume the chip has MMIO enabled by default (rev 0x20 * and higher). */ if (!(pci_resource_flags(dev->pdev, 2) & IORESOURCE_IO)) { // dev->pdev is in used here. drm_info(dev, "platform has no IO space, trying MMIO\n"); ast->ioregs = ast->regs + AST_IO_MM_OFFSET; } That's because commit 46fb883c3d0d8a823ef995ddb1f9b0817dea6882
Quoted 1 line
is not backported to 5.10 kernel.
So what should I do here? Backport that commit (was was not called out), or just revert this?
thanks,
greg k-h
Re: [PATCH 5.12 237/242] drm/ast: Remove reference to struct drm_device.pdev
Quoted 81 lines · Greg Kroah-Hartman
Quoted 79 lines · Xiaotian Feng
Quoted 37 lines · Greg Kroah-Hartman
From: Thomas Zimmermann <[email protected]>
commit
0ecb51824e838372e01330752503ddf9c0430ef7upstream.Using struct drm_device.pdev is deprecated. Upcast with
to_pci_dev()from struct drm_device.dev to get the PCI device structure.v9:
* fix remaining pdev referencesSigned-off-by Thomas Zimmermann <[email protected]>Reviewed-by Michael J. Ruhl <[email protected]>Fixes ba4e0339a6a3 ("drm/ast: Fixed CVE for DP501")Cc KuoHsiang Chou <[email protected]>Cc kernel test robot <[email protected]>Cc Thomas Zimmermann <[email protected]>Cc Dave Airlie <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/gpu/drm/ast/ast_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/gpu/drm/ast/ast_main.c +0
-1@@ -411,7 +411,6 @@ struct ast_private *ast_device_create(coreturn ast; dev = &ast->base; - dev->pdev = pdev;pci_set_drvdata (pdev, dev); ast->regs =pcim_iomap (pdev,1 ,0 );drivers/gpu/drm/ast/ast_main.c struct ast_private *ast_device_create(co · line 459
Quoted 10 lines
drivers/gpu/drm/ast/ast_main.c +2
-2@@ -453,8 +452,8 @@ struct ast_private *ast_device_create(co/* map reserved buffer */ ast->dp501_fw_buf =NULL ; -if (dev->vram_mm->vram_size <pci_resource_len (dev->pdev,0 )) { - ast->dp501_fw_buf =pci_iomap_range (dev->pdev,0 , dev->vram_mm->vram_size,0 ); +if (dev->vram_mm->vram_size <pci_resource_len (pdev,0 )) { + ast->dp501_fw_buf =pci_iomap_range (pdev,0 , dev->vram_mm->vram_size,0 );if (!ast->dp501_fw_buf)drm_info (dev,"failed to map reserved buffer!\n" ); }Hi Greg,
This backport is incomplete for 5.10 kernel, kernel is panicked
on RIP:ast_device_create+0x7d. When I look into the crash code, I foundstruct
ast_private*ast_device_create(structdrm_driver*drv,
structpci_dev*pdev, unsigned long flags)
{
.......dev->pdev = pdev; // This is removed pci_set_drvdata(pdev, dev); ast->regs = pcim_iomap(pdev, 1, 0); if (!ast->regs) return ERR_PTR(-EIO); /* * If we don't have IO space at all, use MMIO now and * assume the chip has MMIO enabled by default (rev 0x20 * and higher). */ if (!(pci_resource_flags(dev->pdev, 2) & IORESOURCE_IO)) { // dev->pdev is in used here. drm_info(dev, "platform has no IO space, trying MMIO\n"); ast->ioregs = ast->regs + AST_IO_MM_OFFSET; }
Quoted 6 lines
Quoted 2 lines
That's because commit 46fb883c3d0d8a823ef995ddb1f9b0817dea6882is not backported to 5.10 kernel.
So what should I do here? Backport that commit (was was not called out), or just revert this?
I think we can just simply revert the patch. Because commit 46fb883c removed drm_device.pdev usage,
then commit ba4e0339 used drm_device.pdev again. Since commit 46fb883c is not in 5.10.50 kernel,
it's not a stable fix.
Quoted 3 lines
thanks,
greg k-h
Greg Kroah-Hartman
maintainerRe: [PATCH 5.12 237/242] drm/ast: Remove reference to struct drm_device.pdev
Quoted 86 lines · Xiaotian Feng
Quoted 84 lines · Greg Kroah-Hartman
Quoted 81 lines · Xiaotian Feng
Quoted 37 lines · Greg Kroah-Hartman
From: Thomas Zimmermann <[email protected]>
commit
0ecb51824e838372e01330752503ddf9c0430ef7upstream.Using struct drm_device.pdev is deprecated. Upcast with
to_pci_dev()from struct drm_device.dev to get the PCI device structure.v9:
* fix remaining pdev referencesSigned-off-by Thomas Zimmermann <[email protected]>Reviewed-by Michael J. Ruhl <[email protected]>Fixes ba4e0339a6a3 ("drm/ast: Fixed CVE for DP501")Cc KuoHsiang Chou <[email protected]>Cc kernel test robot <[email protected]>Cc Thomas Zimmermann <[email protected]>Cc Dave Airlie <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/gpu/drm/ast/ast_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/gpu/drm/ast/ast_main.c +0
-1@@ -411,7 +411,6 @@ struct ast_private *ast_device_create(coreturn ast; dev = &ast->base; - dev->pdev = pdev;pci_set_drvdata (pdev, dev); ast->regs =pcim_iomap (pdev,1 ,0 );drivers/gpu/drm/ast/ast_main.c struct ast_private *ast_device_create(co · line 459
Quoted 10 lines
drivers/gpu/drm/ast/ast_main.c +2
-2@@ -453,8 +452,8 @@ struct ast_private *ast_device_create(co/* map reserved buffer */ ast->dp501_fw_buf =NULL ; -if (dev->vram_mm->vram_size <pci_resource_len (dev->pdev,0 )) { - ast->dp501_fw_buf =pci_iomap_range (dev->pdev,0 , dev->vram_mm->vram_size,0 ); +if (dev->vram_mm->vram_size <pci_resource_len (pdev,0 )) { + ast->dp501_fw_buf =pci_iomap_range (pdev,0 , dev->vram_mm->vram_size,0 );if (!ast->dp501_fw_buf)drm_info (dev,"failed to map reserved buffer!\n" ); }Hi Greg,
This backport is incomplete for 5.10 kernel, kernel is panicked
on RIP:ast_device_create+0x7d. When I look into the crash code, I foundstruct
ast_private*ast_device_create(structdrm_driver*drv,
structpci_dev*pdev, unsigned long flags)
{
.......dev->pdev = pdev; // This is removed pci_set_drvdata(pdev, dev); ast->regs = pcim_iomap(pdev, 1, 0); if (!ast->regs) return ERR_PTR(-EIO); /* * If we don't have IO space at all, use MMIO now and * assume the chip has MMIO enabled by default (rev 0x20 * and higher). */ if (!(pci_resource_flags(dev->pdev, 2) & IORESOURCE_IO)) { // dev->pdev is in used here. drm_info(dev, "platform has no IO space, trying MMIO\n"); ast->ioregs = ast->regs + AST_IO_MM_OFFSET; } That's because commit 46fb883c3d0d8a823ef995ddb1f9b0817dea6882is not backported to 5.10 kernel.
Quoted 8 lines
Quoted 3 lines
So what should I do here? Backport that commit (was was not called out), or just revert this?
I think we can just simply revert the patch. Because commit
46fb883cremoved drm_device.pdev usage,
then commitba4e0339used drm_device.pdev again. Since commit46fb883cis not in 5.10.50 kernel,
it's not a stable fix.
Now qropped, thanks.
greg k-h
Re: [PATCH 5.12 237/242] drm/ast: Remove reference to struct drm_device.pdev
In reply to Greg Kroah-Hartmanhi
Am 19.07.21 um 13:23 schrieb Greg Kroah-Hartman:
Quoted 80 lines · Xiaotian Feng
Quoted 79 lines
Quoted 37 lines · Greg Kroah-Hartman
From: Thomas Zimmermann <[email protected]>
commit
0ecb51824e838372e01330752503ddf9c0430ef7upstream.Using struct drm_device.pdev is deprecated. Upcast with
to_pci_dev()from struct drm_device.dev to get the PCI device structure.v9:
* fix remaining pdev referencesSigned-off-by Thomas Zimmermann <[email protected]>Reviewed-by Michael J. Ruhl <[email protected]>Fixes ba4e0339a6a3 ("drm/ast: Fixed CVE for DP501")Cc KuoHsiang Chou <[email protected]>Cc kernel test robot <[email protected]>Cc Thomas Zimmermann <[email protected]>Cc Dave Airlie <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/gpu/drm/ast/ast_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/gpu/drm/ast/ast_main.c +0
-1@@ -411,7 +411,6 @@ struct ast_private *ast_device_create(coreturn ast; dev = &ast->base; - dev->pdev = pdev;pci_set_drvdata (pdev, dev); ast->regs =pcim_iomap (pdev,1 ,0 );drivers/gpu/drm/ast/ast_main.c struct ast_private *ast_device_create(co · line 459
Quoted 10 lines
drivers/gpu/drm/ast/ast_main.c +2
-2@@ -453,8 +452,8 @@ struct ast_private *ast_device_create(co/* map reserved buffer */ ast->dp501_fw_buf =NULL ; -if (dev->vram_mm->vram_size <pci_resource_len (dev->pdev,0 )) { - ast->dp501_fw_buf =pci_iomap_range (dev->pdev,0 , dev->vram_mm->vram_size,0 ); +if (dev->vram_mm->vram_size <pci_resource_len (pdev,0 )) { + ast->dp501_fw_buf =pci_iomap_range (pdev,0 , dev->vram_mm->vram_size,0 );if (!ast->dp501_fw_buf)drm_info (dev,"failed to map reserved buffer!\n" ); }Hi Greg,
This backport is incomplete for 5.10 kernel, kernel is panicked
on RIP:ast_device_create+0x7d. When I look into the crash code, I foundstruct
ast_private*ast_device_create(structdrm_driver*drv,
structpci_dev*pdev, unsigned long flags)
{
.......dev->pdev = pdev; // This is removed pci_set_drvdata(pdev, dev); ast->regs = pcim_iomap(pdev, 1, 0); if (!ast->regs) return ERR_PTR(-EIO); /* * If we don't have IO space at all, use MMIO now and * assume the chip has MMIO enabled by default (rev 0x20 * and higher). */ if (!(pci_resource_flags(dev->pdev, 2) & IORESOURCE_IO)) { // dev->pdev is in used here. drm_info(dev, "platform has no IO space, trying MMIO\n"); ast->ioregs = ast->regs + AST_IO_MM_OFFSET; }
Quoted 5 lines
Quoted 2 lines
That's because commit 46fb883c3d0d8a823ef995ddb1f9b0817dea6882is not backported to 5.10 kernel.
So what should I do here? Backport that commit (was was not called out), or just revert this?
Best drop all these 'remove pdev' patches from stable. They are no bugfixes.
Best regards
Thomas
Quoted 5 lines
thanks,
greg k-h
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Felix Imendörffer
Greg Kroah-Hartman
maintainerRe: [PATCH 5.12 237/242] drm/ast: Remove reference to struct drm_device.pdev
Quoted 83 lines · Thomas Zimmermann
hi
Am 19.07.21 um 13:23 schrieb Greg Kroah-Hartman:
Quoted 80 lines · Xiaotian Feng
Quoted 79 lines
Quoted 37 lines · Greg Kroah-Hartman
From: Thomas Zimmermann <[email protected]>
commit
0ecb51824e838372e01330752503ddf9c0430ef7upstream.Using struct drm_device.pdev is deprecated. Upcast with
to_pci_dev()from struct drm_device.dev to get the PCI device structure.v9:
* fix remaining pdev referencesSigned-off-by Thomas Zimmermann <[email protected]>Reviewed-by Michael J. Ruhl <[email protected]>Fixes ba4e0339a6a3 ("drm/ast: Fixed CVE for DP501")Cc KuoHsiang Chou <[email protected]>Cc kernel test robot <[email protected]>Cc Thomas Zimmermann <[email protected]>Cc Dave Airlie <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/gpu/drm/ast/ast_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/gpu/drm/ast/ast_main.c +0
-1@@ -411,7 +411,6 @@ struct ast_private *ast_device_create(coreturn ast; dev = &ast->base; - dev->pdev = pdev;pci_set_drvdata (pdev, dev); ast->regs =pcim_iomap (pdev,1 ,0 );drivers/gpu/drm/ast/ast_main.c struct ast_private *ast_device_create(co · line 459
Quoted 10 lines
drivers/gpu/drm/ast/ast_main.c +2
-2@@ -453,8 +452,8 @@ struct ast_private *ast_device_create(co/* map reserved buffer */ ast->dp501_fw_buf =NULL ; -if (dev->vram_mm->vram_size <pci_resource_len (dev->pdev,0 )) { - ast->dp501_fw_buf =pci_iomap_range (dev->pdev,0 , dev->vram_mm->vram_size,0 ); +if (dev->vram_mm->vram_size <pci_resource_len (pdev,0 )) { + ast->dp501_fw_buf =pci_iomap_range (pdev,0 , dev->vram_mm->vram_size,0 );if (!ast->dp501_fw_buf)drm_info (dev,"failed to map reserved buffer!\n" ); }Hi Greg,
This backport is incomplete for 5.10 kernel, kernel is panicked
on RIP:ast_device_create+0x7d. When I look into the crash code, I foundstruct
ast_private*ast_device_create(structdrm_driver*drv,
structpci_dev*pdev, unsigned long flags)
{
.......dev->pdev = pdev; // This is removed pci_set_drvdata(pdev, dev); ast->regs = pcim_iomap(pdev, 1, 0); if (!ast->regs) return ERR_PTR(-EIO); /* * If we don't have IO space at all, use MMIO now and * assume the chip has MMIO enabled by default (rev 0x20 * and higher). */ if (!(pci_resource_flags(dev->pdev, 2) & IORESOURCE_IO)) { // dev->pdev is in used here. drm_info(dev, "platform has no IO space, trying MMIO\n"); ast->ioregs = ast->regs + AST_IO_MM_OFFSET; }
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
That's because commit 46fb883c3d0d8a823ef995ddb1f9b0817dea6882is not backported to 5.10 kernel.
So what should I do here? Backport that commit (was was not called out), or just revert this?
Best drop all these 'remove pdev' patches from stable. They are no bugfixes.
Which specific commits were they?
thanks,
greg k-h
Greg Kroah-Hartman
maintainerPATCH 238/242 jfs: fix GPF in diFree
In reply to Greg Kroah-HartmanFrom: Pavel Skripkin <[email protected]>
commit 9d574f985fe33efd6911f4d752de6f485a1ea732 upstream.
Avoid passing inode with
JFS_SBI(inode->i_sb)->ipimap == NULL to
diFree()[1]. GFP will appear:
struct inode *ipimap = JFS_SBI(ip->i_sb)->ipimap; struct inomap *imap = JFS_IP(ipimap)->i_imap;
JFS_IP() will return invalid pointer when ipimap == NULL
Call Trace: diFree+0x13d/0x2dc0 fs/jfs/jfs_imap.c:853 [1] jfs_evict_inode+0x2c9/0x370 fs/jfs/inode.c:154 evict+0x2ed/0x750 fs/inode.c:578 iput_final fs/inode.c:1654 [inline] iput.part.0+0x3fe/0x820 fs/inode.c:1680 iput+0x58/0x70 fs/inode.c:1670
--- fs/jfs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/jfs/inode.c +2 -1
@@ -151,7 +151,8 @@ void jfs_evict_inode(struct inode *inodeif (test_cflag (COMMIT_Freewmap, inode))jfs_free_zero_link (inode); -diFree (inode); +if (JFS_SBI (inode->i_sb)->ipimap) +diFree (inode);/* * Free the inode from the quota allocation.
Greg Kroah-Hartman
maintainerPATCH 239/242 media: v4l2-core: explicitly clear ioctl input data
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
commit 7b53cca764f9b291b7907fcd39d9e66ad728ee0b upstream.
As seen from a recent syzbot bug report, mistakes in the compat ioctl implementation can lead to uninitialized kernel stack data getting used as input for driver ioctl handlers.
The reported bug is now fixed, but it's possible that other related bugs are still present or get added in the future. As the drivers need to check user input already, the possible impact is fairly low, but it might still cause an information leak.
To be on the safe side, always clear the entire ioctl buffer before calling the conversion handler functions that are meant to initialize them.
--- drivers/media/v4l2-core/v4l2-ioctl.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/v4l2-core/v4l2-ioctl.c +2 -0
@@ -3166,8 +3166,10 @@ static int video_get_user(void __user *aif (copy_from_user (parg, (void __user *)arg, n)) err = -EFAULT ; }else if (in_compat_syscall ()) { +memset (parg,0 , n); err =v4l2_compat_get_user (arg, parg, cmd); }else { +memset (parg,0 , n);#if !defined(CONFIG_64BIT ) && defined(CONFIG_COMPAT_32BIT_TIME )switch (cmd) {case VIDIOC_QUERYBUF_TIME32 :
Greg Kroah-Hartman
maintainerPATCH 240/242 smackfs: restrict bytes count in smk_set_cipso()
In reply to Greg Kroah-HartmanFrom: Tetsuo Handa <[email protected]>
commit 49ec114a6e62d8d320037ce71c1aaf9650b3cafd upstream.
Oops, I failed to update subject line.
Quoted 1 line
From
07571157c91b98ce1a4aa70967531e64b78e8346Mon Sep 17 00:00:00 2001
From: Tetsuo Handa <[email protected]>
Date: Mon, 12 Apr 2021 22:25:06 +0900
Subject: [PATCH 5.12 240/242] smackfs: restrict bytes count in smk_set_cipso()
Commit 7ef4c19d245f3dc2 ("smackfs: restrict bytes count in smackfs write functions") missed that count > SMK_CIPSOMAX check applies to only format == SMK_FIXED24_FMT case.
--- security/smack/smackfs.c | 2 ++ 1 file changed, 2 insertions(+)
security/smack/smackfs.c +2 -0
@@ -855,6 +855,8 @@ static ssize_t smk_set_cipso(struct fileif (format ==SMK_FIXED24_FMT && (count <SMK_CIPSOMIN || count >SMK_CIPSOMAX ))return -EINVAL ; +if (count >PAGE_SIZE ) +return -EINVAL ; data =memdup_user_nul (buf, count);if (IS_ERR (data))
Greg Kroah-Hartman
maintainerPATCH 241/242 ext4: fix memory leak in ext4_fill_super
In reply to Greg Kroah-HartmanFrom: Pavel Skripkin <[email protected]>
commit 618f003199c6188e01472b03cdbba227f1dc5f24 upstream.
static int kthread(void *_create) will return -ENOMEM or -EINTR in case of internal failure or kthread_stop() call happens before threadfn call.
To prevent fancy error checking and make code more straightforward we moved all cleanup code out of kmmpd threadfn.
Also, dropped struct mmpd_data at all. Now struct super_block is a threadfn data and struct buffer_head embedded into struct ext4_sb_info.
--- fs/ext4/ext4.h | 4 ++++ fs/ext4/mmp.c | 28 +++++++++++++--------------- fs/ext4/super.c | 10 ++++------ 3 files changed, 21 insertions(+), 21 deletions(-)
fs/ext4/ext4.h +4 -0
@@ -1490,6 +1490,7 @@ struct ext4_sb_info {struct kobject s_kobj;struct completion s_kobj_unregister;struct super_block *s_sb; +struct buffer_head *s_mmp_bh;/* Journaling */ struct journal_s *s_journal;
@@ -3663,6 +3664,9 @@ extern struct ext4_io_end_vec *ext4_last/* mmp.c */ extern int ext4_multi_mount_protect (struct super_block *,ext4_fsblk_t ); +/* mmp.c */ +extern void ext4_stop_mmpd (struct ext4_sb_info *sbi); +/* verity.c */ extern const struct fsverity_operations ext4_verityops;
fs/ext4/mmp.c +13 -15
@@ -127,9 +127,9 @@ void __dump_mmp_msg(struct super_block **/ static int kmmpd (void *data) { -struct super_block *sb = ((struct mmpd_data *) data)->sb; -struct buffer_head *bh = ((struct mmpd_data *) data)->bh; +struct super_block *sb = (struct super_block *) data;struct ext4_super_block *es =EXT4_SB (sb)->s_es; +struct buffer_head *bh =EXT4_SB (sb)->s_mmp_bh;struct mmp_struct *mmp;ext4_fsblk_t mmp_block;u32 seq =0 ;
@@ -245,12 +245,18 @@ static int kmmpd(void *data) retval =write_mmp_block (sb, bh); exit_thread: -EXT4_SB (sb)->s_mmp_tsk =NULL ; -kfree (data); -brelse (bh);return retval; } +void ext4_stop_mmpd (struct ext4_sb_info *sbi) +{ +if (sbi->s_mmp_tsk) { +kthread_stop (sbi->s_mmp_tsk); +brelse (sbi->s_mmp_bh); + sbi->s_mmp_tsk =NULL ; + } +} +/* * Get a random new sequence number but make sure it is not greater than * EXT4_MMP_SEQ_MAX.
@@ -275,7 +281,6 @@ int ext4_multi_mount_protect(struct supestruct ext4_super_block *es =EXT4_SB (sb)->s_es;struct buffer_head *bh =NULL ;struct mmp_struct *mmp =NULL ; -struct mmpd_data *mmpd_data;u32 seq;unsigned int mmp_check_interval =le16_to_cpu (es->s_mmp_update_interval);unsigned int wait_time =0 ;
@@ -364,24 +369,17 @@ skip: goto failed; } - mmpd_data =kmalloc (sizeof (*mmpd_data),GFP_KERNEL ); -if (!mmpd_data) { -ext4_warning (sb,"not enough memory for mmpd_data" ); - goto failed; - } - mmpd_data->sb = sb; - mmpd_data->bh = bh; +EXT4_SB (sb)->s_mmp_bh = bh;/* * Start a kernel thread to update the MMP block periodically. */ -EXT4_SB (sb)->s_mmp_tsk =kthread_run (kmmpd, mmpd_data,"kmmpd-%.*s" , +EXT4_SB (sb)->s_mmp_tsk =kthread_run (kmmpd, sb,"kmmpd-%.*s" , (int )sizeof (mmp->mmp_bdevname),bdevname (bh->b_bdev, mmp->mmp_bdevname));if (IS_ERR (EXT4_SB (sb)->s_mmp_tsk)) {EXT4_SB (sb)->s_mmp_tsk =NULL ; -kfree (mmpd_data);ext4_warning (sb,"Unable to create kmmpd thread for %s." , sb->s_id); goto failed;
fs/ext4/super.c +4 -6
@@ -1245,8 +1245,8 @@ static void ext4_put_super(struct super_ext4_xattr_destroy_cache (sbi->s_ea_block_cache); sbi->s_ea_block_cache =NULL ; -if (sbi->s_mmp_tsk) -kthread_stop (sbi->s_mmp_tsk); +ext4_stop_mmpd (sbi); +brelse (sbi->s_sbh); sb->s_fs_info =NULL ;/*
@@ -5168,8 +5168,7 @@ failed_mount3a: failed_mount3:flush_work (&sbi->s_error_work);del_timer_sync (&sbi->s_err_report); -if (sbi->s_mmp_tsk) -kthread_stop (sbi->s_mmp_tsk); +ext4_stop_mmpd (sbi); failed_mount2:rcu_read_lock (); group_desc =rcu_dereference (sbi->s_group_desc);
@@ -5967,8 +5966,7 @@ static int ext4_remount(struct super_blo*/ ext4_mark_recovery_complete (sb, es); } -if (sbi->s_mmp_tsk) -kthread_stop (sbi->s_mmp_tsk); +ext4_stop_mmpd (sbi); }else {/* Make sure we can mount this feature set readwrite */ if (ext4_has_feature_readonly(sb) ||
Greg Kroah-Hartman
maintainerPATCH 242/242 f2fs: fix to avoid racing on fsync_entry_slab by multi filesystem instances
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
commit cad83c968c2ebe97905f900326988ed37146c347 upstream.
As syzbot reported, there is an use-after-free issue during f2fs recovery:
Use-after-free write at 0xffff88823bc16040 (in kfence-#10):
kmem_cache_destroy+0x1f/0x120 mm/slab_common.c:486 f2fs_recover_fsync_data+0x75b0/0x8380 fs/f2fs/recovery.c:869 f2fs_fill_super+0x9393/0xa420 fs/f2fs/super.c:3945 mount_bdev+0x26c/0x3a0 fs/super.c:1367 legacy_get_tree+0xea/0x180 fs/fs_context.c:592 vfs_get_tree+0x86/0x270 fs/super.c:1497 do_new_mount fs/namespace.c:2905 [inline] path_mount+0x196f/0x2be0 fs/namespace.c:3235 do_mount fs/namespace.c:3248 [inline] __do_sys_mount fs/namespace.c:3456 [inline] __se_sys_mount+0x2f9/0x3b0 fs/namespace.c:3433 do_syscall_64+0x3f/0xb0 arch/x86/entry/common.c:47 entry_SYSCALL_64_after_hwframe+0x44/0xae
The root cause is multi f2fs filesystem instances can race on accessing global fsync_entry_slab pointer, result in use-after-free issue of slab cache, fixes to init/destroy this slab cache only once during module init/destroy procedure to avoid this issue.
--- fs/f2fs/f2fs.h | 2 ++ fs/f2fs/recovery.c | 23 ++++++++++++++--------- fs/f2fs/super.c | 8 +++++++- 3 files changed, 23 insertions(+), 10 deletions(-)
fs/f2fs/f2fs.h +2 -0
@@ -3560,6 +3560,8 @@ void f2fs_destroy_garbage_collection_cac*/ int f2fs_recover_fsync_data (struct f2fs_sb_info *sbi,bool check_only);bool f2fs_space_for_roll_forward (struct f2fs_sb_info *sbi); +int __init f2fs_create_recovery_cache (void ); +void f2fs_destroy_recovery_cache (void );/* * debug.c
fs/f2fs/recovery.c +14 -9
@@ -787,13 +787,6 @@ int f2fs_recover_fsync_data(struct f2fs_ quota_enabled =f2fs_enable_quota_files (sbi, s_flags &SB_RDONLY );#endif - fsync_entry_slab =f2fs_kmem_cache_create ("f2fs_fsync_inode_entry" , -sizeof (struct fsync_inode_entry )); -if (!fsync_entry_slab) { - err = -ENOMEM ; - goto out; - } -INIT_LIST_HEAD (&inode_list);INIT_LIST_HEAD (&tmp_inode_list);INIT_LIST_HEAD (&dir_list);
@@ -866,8 +859,6 @@ skip: } } -kmem_cache_destroy (fsync_entry_slab); -out:#ifdef CONFIG_QUOTA /* Turn quotas off */ if (quota_enabled)
@@ -877,3 +868,17 @@ out:return ret ? ret: err; } + +int __init f2fs_create_recovery_cache (void ) +{ + fsync_entry_slab =f2fs_kmem_cache_create ("f2fs_fsync_inode_entry" , +sizeof (struct fsync_inode_entry )); +if (!fsync_entry_slab) +return -ENOMEM ; +return 0 ; +} + +void f2fs_destroy_recovery_cache (void ) +{ +kmem_cache_destroy (fsync_entry_slab); +}
fs/f2fs/super.c +7 -1
@@ -4187,9 +4187,12 @@ static int __init init_f2fs_fs(void) err =f2fs_create_checkpoint_caches ();if (err) goto free_segment_manager_caches; - err =f2fs_create_extent_cache (); + err =f2fs_create_recovery_cache ();if (err) goto free_checkpoint_caches; + err =f2fs_create_extent_cache (); +if (err) + goto free_recovery_cache; err =f2fs_create_garbage_collection_cache ();if (err) goto free_extent_cache;
@@ -4238,6 +4241,8 @@ free_garbage_collection_cache:f2fs_destroy_garbage_collection_cache (); free_extent_cache:f2fs_destroy_extent_cache (); +free_recovery_cache: +f2fs_destroy_recovery_cache (); free_checkpoint_caches:f2fs_destroy_checkpoint_caches (); free_segment_manager_caches:
@@ -4263,6 +4268,7 @@ static void __exit exit_f2fs_fs(void)f2fs_exit_sysfs ();f2fs_destroy_garbage_collection_cache ();f2fs_destroy_extent_cache (); +f2fs_destroy_recovery_cache ();f2fs_destroy_checkpoint_caches ();f2fs_destroy_segment_manager_caches ();f2fs_destroy_node_manager_caches ();
Hello!
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.12.18 release. There are 242 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 17 Jul 2021 18:21:07 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.12.18-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.12.y
and the diffstat can be found below.thanks,
greg k-h
Build regressions have been found on this release candidate (and on 5.13-rc).
## Regressions (compared to v5.12.17)
* s390, build
- clang-10-allnoconfig
- clang-10-defconfig
- clang-10-tinyconfig
- clang-11-allnoconfig
- clang-11-defconfig
- clang-11-tinyconfig
- clang-12-allnoconfig
- clang-12-defconfig
- clang-12-tinyconfig
- gcc-8-allnoconfig
- gcc-8-defconfig
- gcc-8-tinyconfig
- gcc-9-allnoconfig
- gcc-9-defconfig
- gcc-9-tinyconfig
- gcc-10-allnoconfig
- gcc-10-defconfig
- gcc-10-tinyconfig
[...]
Quoted 2 lines
Sven Schnelle <[email protected]>
s390/signal: switch to using vdso for sigreturn and syscall restart
[...]
Our bisections pointed to this commit. Reverting it made the build pass again.
Greetings!
Daniel Díaz
[email protected]
Greg Kroah-Hartman
maintainerQuoted 45 lines · Daniel Díaz
Hello!
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.12.18 release. There are 242 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 17 Jul 2021 18:21:07 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.12.18-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.12.y
and the diffstat can be found below.thanks,
greg k-h
Build regressions have been found on this release candidate (and on 5.13-rc).
## Regressions (compared to v5.12.17)
* s390, build
- clang-10-allnoconfig
- clang-10-defconfig
- clang-10-tinyconfig
- clang-11-allnoconfig
- clang-11-defconfig
- clang-11-tinyconfig
- clang-12-allnoconfig
- clang-12-defconfig
- clang-12-tinyconfig
- gcc-8-allnoconfig
- gcc-8-defconfig
- gcc-8-tinyconfig
- gcc-9-allnoconfig
- gcc-9-defconfig
- gcc-9-tinyconfig
- gcc-10-allnoconfig
- gcc-10-defconfig
- gcc-10-tinyconfig
Quoted 8 lines
[...]
Quoted 2 lines
Sven Schnelle <[email protected]>
s390/signal: switch to using vdso for sigreturn and syscall restart[...]
Our bisections pointed to this commit. Reverting it made the build pass again.
Will go drop this, thanks.
greg k-h
Hi Daniel,
Quoted 45 lines · Daniel Díaz
Hello!
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.12.18 release. There are 242 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 17 Jul 2021 18:21:07 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.12.18-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.12.y
and the diffstat can be found below.thanks,
greg k-h
Build regressions have been found on this release candidate (and on 5.13-rc).
## Regressions (compared to v5.12.17)
* s390, build
- clang-10-allnoconfig
- clang-10-defconfig
- clang-10-tinyconfig
- clang-11-allnoconfig
- clang-11-defconfig
- clang-11-tinyconfig
- clang-12-allnoconfig
- clang-12-defconfig
- clang-12-tinyconfig
- gcc-8-allnoconfig
- gcc-8-defconfig
- gcc-8-tinyconfig
- gcc-9-allnoconfig
- gcc-9-defconfig
- gcc-9-tinyconfig
- gcc-10-allnoconfig
- gcc-10-defconfig
- gcc-10-tinyconfig
Quoted 8 lines
[...]
Quoted 2 lines
Sven Schnelle <[email protected]>
s390/signal: switch to using vdso for sigreturn and syscall restart[...]
Our bisections pointed to this commit. Reverting it made the build pass again.
If https://gitlab.com/Linaro/lkft/mirrors/stable/linux-stable-rc/-/jobs/1428532107
is the logfile for this problem, than i see the following in the log:
make --silent --keep-going --jobs=8 O=/home/tuxbuild/.cache/tuxmake/builds/current ARCH=s390 CROSS_COMPILE=s390x-linux-gnu- 'CC=sccache s390x-linux-gnu-gcc' 'HOSTCC=sccache gcc' /bin/sh: 1: /builds/linux/arch/s390/kernel/vdso64/gen_vdso_offsets.sh: Permission denied
However, in the patch this script is 755, and other architecture are using this for a while now - can you check what the permission are when you're trying to build the kernel?
Thanks
Sven
Greg Kroah-Hartman
maintainerQuoted 61 lines · Sven Schnelle
Hi Daniel,
Quoted 45 lines · Daniel Díaz
Hello!
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.12.18 release. There are 242 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 17 Jul 2021 18:21:07 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.12.18-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.12.y
and the diffstat can be found below.thanks,
greg k-h
Build regressions have been found on this release candidate (and on 5.13-rc).
## Regressions (compared to v5.12.17)
* s390, build
- clang-10-allnoconfig
- clang-10-defconfig
- clang-10-tinyconfig
- clang-11-allnoconfig
- clang-11-defconfig
- clang-11-tinyconfig
- clang-12-allnoconfig
- clang-12-defconfig
- clang-12-tinyconfig
- gcc-8-allnoconfig
- gcc-8-defconfig
- gcc-8-tinyconfig
- gcc-9-allnoconfig
- gcc-9-defconfig
- gcc-9-tinyconfig
- gcc-10-allnoconfig
- gcc-10-defconfig
- gcc-10-tinyconfigQuoted 8 lines
[...]
Quoted 2 lines
Sven Schnelle <[email protected]>
s390/signal: switch to using vdso for sigreturn and syscall restart[...]
Our bisections pointed to this commit. Reverting it made the build pass again.
If https://gitlab.com/Linaro/lkft/mirrors/stable/linux-stable-rc/-/jobs/1428532107
is the logfile for this problem, than i see the following in the log:
Quoted 6 lines
make --silent --keep-going --jobs=8 O=/home/tuxbuild/.cache/tuxmake/builds/current ARCH=s390 CROSS_COMPILE=s390x-linux-gnu- 'CC=sccache s390x-linux-gnu-gcc' 'HOSTCC=sccache gcc'
/bin/sh: 1: /builds/linux/arch/s390/kernel/vdso64/gen_vdso_offsets.sh: Permission deniedHowever, in the patch this script is 755, and other architecture are using this for a while now - can you check what the permission are when you're trying to build the kernel?
Yes, the problem is that when handling patches, we can not change the permissions on files. That causes this file to not be added with execute permissions. This has generally been considered a bad thing anyway, and other scripts that relied on being executable have been changed over time to not be that way and be explicitly run by the calling script.
But it looks like th gen_vdso_offsets.sh script has not been changed on any arch to do that yet. It is one of the few hold outs.
Also, this feels like a HUGE change for a stable tree, adding new features like this, are you sure it's all needed?
thanks,
greg k-h
Hi Greg,
Quoted 11 lines · Greg Kroah-Hartman
Quoted 9 lines · Sven Schnelle
If https://gitlab.com/Linaro/lkft/mirrors/stable/linux-stable-rc/-/jobs/1428532107
is the logfile for this problem, than i see the following in the log:make --silent --keep-going --jobs=8 O=/home/tuxbuild/.cache/tuxmake/builds/current ARCH=s390 CROSS_COMPILE=s390x-linux-gnu- 'CC=sccache s390x-linux-gnu-gcc' 'HOSTCC=sccache gcc'
/bin/sh: 1: /builds/linux/arch/s390/kernel/vdso64/gen_vdso_offsets.sh: Permission deniedHowever, in the patch this script is 755, and other architecture are using this for a while now - can you check what the permission are when you're trying to build the kernel?
Quoted 6 lines
Yes, the problem is that when handling patches, we can not change the permissions on files. That causes this file to not be added with execute permissions. This has generally been considered a bad thing anyway, and other scripts that relied on being executable have been changed over time to not be that way and be explicitly run by the calling script.
Hmm, right. I didn't thought about patches. So i'll adjust the patch and sent it again. I guess prefixing it with $(CONFIG_SHELL) is then the way to do it, at least i see a lot of location doing it that way.
Quoted 5 lines
But it looks like th
gen_vdso_offsets.shscript has not been changed on any arch to do that yet. It is one of the few hold outs.Also, this feels like a HUGE change for a stable tree, adding new features like this, are you sure it's all needed?
Yes. This fixes syscall restarting in combination with signals coming in on s390, which is broken since the conversion to generic entry. There's no easy way to fix that, and we don't want to introduce another workaround that is userspace visible, as we would have to carry that forever.
Sven
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.12.18 release. There are 242 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 17 Jul 2021 18:21:07 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.12.18-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.12.y
and the diffstat can be found below.thanks,
greg k-h
On ARCH_BRCMSTB, using 32-bit and 64-bit ARM kernels:
Signature · 1 line
Florian
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.12.18 release. There are 242 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 17 Jul 2021 18:21:07 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.12.18-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.12.y
and the diffstat can be found below.thanks,
greg k-h
All tests passing for Tegra ...
Test results for stable-v5.12:
10 builds: 10 pass, 0 fail
28 boots: 28 pass, 0 fail
110 tests: 110 pass, 0 failLinux version: 5.12.18-rc1-g56ea26ce5c02
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,
tegra194-p2972-0000, tegra194-p3509-0000+p3668-0000,
tegra20-ventana, tegra210-p2371-2180,
tegra210-p3450-0000, tegra30-cardhu-a04Jon
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.12.18 release. There are 242 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 17 Jul 2021 18:21:07 +0000. Anything received after that time might be too late.
Building s390:defconfig ... failed
--------------
Error log:/bin/sh: arch/s390/kernel/vdso64/gen_vdso_offsets.sh: Permission denied /bin/sh: arch/s390/kernel/vdso32/gen_vdso_offsets.sh: Permission denied
...
Original commit:
arch/s390/kernel/vdso32/gen_vdso_offsets.sh new file +0 -0
^^^^^^
index 000000000000..9c4f951e227d
--- /dev/null
+++ b/arch/s390/kernel/vdso32/gen_vdso_offsets.sh
This commit:
arch/s390/kernel/vdso32/gen_vdso_offsets.sh new file +0 -0
^^^^^^
index 000000000000..9c4f951e227d
--- /dev/null
+++ b/arch/s390/kernel/vdso32/gen_vdso_offsets.sh
Same with v5.13.y.
Guenter
Greg Kroah-Hartman
maintainerQuoted 35 lines · Guenter Roeck
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.12.18 release. There are 242 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 17 Jul 2021 18:21:07 +0000. Anything received after that time might be too late.
Building s390:defconfig ... failed
--------------
Error log:/bin/sh:arch/s390/kernel/vdso64/gen_vdso_offsets.sh: Permission denied/bin/sh:arch/s390/kernel/vdso32/gen_vdso_offsets.sh: Permission denied
...Original commit:
arch/s390/kernel/vdso32/gen_vdso_offsets.sh new file +0
-0^^^^^^index 000000000000..9c4f951e227d
arch/s390/kernel/vdso32/gen_vdso_offsets.sh new file +0
-0This commit:
arch/s390/kernel/vdso32/gen_vdso_offsets.sh new file +0
-0^^^^^^index 000000000000..9c4f951e227d
arch/s390/kernel/vdso32/gen_vdso_offsets.sh new file +0
-0
Quoted 1 line
Same with v5.13.y.
Ah crap. Quilt does not handle permissions like this. And really, we shouldn't be doing that either in the kernel, I thought we fixed these all up so that the executable bit did not have to be set.
Let me go dig...
thanks,
greg k-h
Greg Kroah-Hartman
maintainerQuoted 35 lines · Guenter Roeck
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.12.18 release. There are 242 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 17 Jul 2021 18:21:07 +0000. Anything received after that time might be too late.
Building s390:defconfig ... failed
--------------
Error log:/bin/sh:arch/s390/kernel/vdso64/gen_vdso_offsets.sh: Permission denied/bin/sh:arch/s390/kernel/vdso32/gen_vdso_offsets.sh: Permission denied
...Original commit:
arch/s390/kernel/vdso32/gen_vdso_offsets.sh new file +0
-0^^^^^^index 000000000000..9c4f951e227d
arch/s390/kernel/vdso32/gen_vdso_offsets.sh new file +0
-0This commit:
arch/s390/kernel/vdso32/gen_vdso_offsets.sh new file +0
-0^^^^^^index 000000000000..9c4f951e227d
arch/s390/kernel/vdso32/gen_vdso_offsets.sh new file +0
-0
Quoted 1 line
Same with v5.13.y.
I'm just dropping these patches for now. thanks.
greg k-h