2019-05-19 13:08:55 +01:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-03-31 14:33:13 +11:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-19 12:46:40 +11:00
|
|
|
|
2016-11-14 16:30:21 +11:00
|
|
|
|
2009-03-31 14:33:13 +11:00
|
|
|
|
2017-10-10 17:02:41 -04:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2024-08-26 15:44:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-06-01 19:37:31 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
|
|
|
|
|
2009-09-23 18:06:44 +10:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-05-15 21:48:05 +08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-06-01 19:37:31 +10:00
|
|
|
|
2015-02-02 17:08:03 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-19 12:46:41 +11:00
|
|
|
|
2010-06-01 19:37:31 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2016-05-02 11:50:11 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-06-01 19:37:31 +10:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-03-19 12:46:41 +11:00
|
|
|
|
2010-06-01 19:37:31 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-06-01 19:37:31 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-19 12:46:41 +11:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:27 -07:00
|
|
|
|
|
|
|
|
|
2023-06-15 08:48:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-06-15 08:48:37 +02:00
|
|
|
|
|
|
|
|
|
2011-10-11 16:45:26 +11:00
|
|
|
|
2005-06-21 17:17:27 -07:00
|
|
|
|
2012-03-19 12:46:39 +11:00
|
|
|
|
2023-06-15 08:48:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-09-09 16:23:52 -07:00
|
|
|
|
|
|
|
|
|
2023-06-15 08:48:38 +02:00
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
2005-09-09 16:23:52 -07:00
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
2005-06-21 17:17:27 -07:00
|
|
|
|
|
|
|
|
|
2011-10-11 16:47:53 +11:00
|
|
|
|
2008-09-01 12:48:13 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-11 13:43:21 +11:00
|
|
|
|
2015-05-20 15:05:09 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-09-01 12:48:13 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-05-20 15:05:09 +10:00
|
|
|
|
2008-09-01 12:48:13 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-11 13:43:21 +11:00
|
|
|
|
2008-09-01 12:48:13 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-02-24 11:33:23 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-04-24 19:14:38 -06:00
|
|
|
|
2023-02-24 11:33:23 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-02-24 11:33:21 -07:00
|
|
|
|
2023-06-15 08:48:38 +02:00
|
|
|
|
2005-06-21 17:17:27 -07:00
|
|
|
|
2011-01-14 09:14:34 +11:00
|
|
|
|
2011-10-11 16:47:53 +11:00
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
md/md-bitmap: fix writing non bitmap pages
__write_sb_page() rounds up the io size to the optimal io size if it
doesn't exceed the data offset, but it doesn't check the final size
exceeds the bitmap length.
For example:
page count - 1
page size - 4K
data offset - 1M
optimal io size - 256K
The final io size would be 256K (64 pages) but md_bitmap_storage_alloc()
allocated 1 page, the IO would write 1 valid page and 63 pages that
happens to be allocated afterwards. This leaks memory to the raid device
superblock.
This issue caused a data transfer failure in nvme-tcp. The network
drivers checks the first page of an IO with sendpage_ok(), it returns
true if the page isn't a slabpage and refcount >= 1. If the page
!sendpage_ok() the network driver disables MSG_SPLICE_PAGES.
As of now the network layer assumes all the pages of the IO are
sendpage_ok() when MSG_SPLICE_PAGES is on.
The bitmap pages aren't slab pages, the first page of the IO is
sendpage_ok(), but the additional pages that happens to be allocated
after the bitmap pages might be !sendpage_ok(). That cause
skb_splice_from_iter() to stop the data transfer, in the case below it
hangs 'mdadm --create'.
The bug is reproducible, in order to reproduce we need nvme-over-tcp
controllers with optimal IO size bigger than PAGE_SIZE. Creating a raid
with bitmap over those devices reproduces the bug.
In order to simulate large optimal IO size you can use dm-stripe with a
single device.
Script to reproduce the issue on top of brd devices using dm-stripe is
attached below (will be added to blktest).
I have added some logs to test the theory:
...
md: created bitmap (1 pages) for device md127
__write_sb_page before md_super_write offset: 16, size: 262144. pfn: 0x53ee
=== __write_sb_page before md_super_write. logging pages ===
pfn: 0x53ee, slab: 0 <-- the only page that allocated for the bitmap
pfn: 0x53ef, slab: 1
pfn: 0x53f0, slab: 0
pfn: 0x53f1, slab: 0
pfn: 0x53f2, slab: 0
pfn: 0x53f3, slab: 1
...
nvme_tcp: sendpage_ok - pfn: 0x53ee, len: 262144, offset: 0
skbuff: before sendpage_ok() - pfn: 0x53ee
skbuff: before sendpage_ok() - pfn: 0x53ef
WARNING at net/core/skbuff.c:6848 skb_splice_from_iter+0x142/0x450
skbuff: !sendpage_ok - pfn: 0x53ef. is_slab: 1, page_count: 1
...
Cc: stable@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ofir Gal <ofir.gal@volumez.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20240607072748.3182199-1-ofir.gal@volumez.com
2024-06-07 10:27:44 +03:00
|
|
|
|
|
|
|
|
|
2023-04-24 19:14:38 -06:00
|
|
|
|
2023-06-15 08:48:38 +02:00
|
|
|
|
2023-02-24 11:33:22 -07:00
|
|
|
|
2023-02-24 11:33:23 -07:00
|
|
|
|
2023-06-15 08:48:38 +02:00
|
|
|
|
2005-06-21 17:17:27 -07:00
|
|
|
|
2023-02-24 11:33:21 -07:00
|
|
|
|
2024-02-23 20:11:28 +08:00
|
|
|
|
|
|
|
|
|
2023-02-24 11:33:22 -07:00
|
|
|
|
2011-01-14 09:14:34 +11:00
|
|
|
|
2023-02-24 11:33:21 -07:00
|
|
|
|
|
|
|
|
|
2023-02-24 11:33:23 -07:00
|
|
|
|
|
|
|
|
|
2008-09-01 12:48:13 +10:00
|
|
|
|
2005-06-21 17:17:27 -07:00
|
|
|
|
2023-02-24 11:33:22 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-02-24 11:33:21 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-02-24 11:33:22 -07:00
|
|
|
|
|
|
|
|
|
2023-02-24 11:33:21 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-02-24 11:33:23 -07:00
|
|
|
|
|
|
|
|
|
2023-02-24 11:33:21 -07:00
|
|
|
|
|
|
|
|
|
2008-07-21 17:05:25 +10:00
|
|
|
|
2023-02-24 11:33:22 -07:00
|
|
|
|
2023-02-24 11:33:21 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-02-24 11:33:23 -07:00
|
|
|
|
|
|
|
|
|
2023-02-24 11:33:21 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
md/md-bitmap: fix writing non bitmap pages
__write_sb_page() rounds up the io size to the optimal io size if it
doesn't exceed the data offset, but it doesn't check the final size
exceeds the bitmap length.
For example:
page count - 1
page size - 4K
data offset - 1M
optimal io size - 256K
The final io size would be 256K (64 pages) but md_bitmap_storage_alloc()
allocated 1 page, the IO would write 1 valid page and 63 pages that
happens to be allocated afterwards. This leaks memory to the raid device
superblock.
This issue caused a data transfer failure in nvme-tcp. The network
drivers checks the first page of an IO with sendpage_ok(), it returns
true if the page isn't a slabpage and refcount >= 1. If the page
!sendpage_ok() the network driver disables MSG_SPLICE_PAGES.
As of now the network layer assumes all the pages of the IO are
sendpage_ok() when MSG_SPLICE_PAGES is on.
The bitmap pages aren't slab pages, the first page of the IO is
sendpage_ok(), but the additional pages that happens to be allocated
after the bitmap pages might be !sendpage_ok(). That cause
skb_splice_from_iter() to stop the data transfer, in the case below it
hangs 'mdadm --create'.
The bug is reproducible, in order to reproduce we need nvme-over-tcp
controllers with optimal IO size bigger than PAGE_SIZE. Creating a raid
with bitmap over those devices reproduces the bug.
In order to simulate large optimal IO size you can use dm-stripe with a
single device.
Script to reproduce the issue on top of brd devices using dm-stripe is
attached below (will be added to blktest).
I have added some logs to test the theory:
...
md: created bitmap (1 pages) for device md127
__write_sb_page before md_super_write offset: 16, size: 262144. pfn: 0x53ee
=== __write_sb_page before md_super_write. logging pages ===
pfn: 0x53ee, slab: 0 <-- the only page that allocated for the bitmap
pfn: 0x53ef, slab: 1
pfn: 0x53f0, slab: 0
pfn: 0x53f1, slab: 0
pfn: 0x53f2, slab: 0
pfn: 0x53f3, slab: 1
...
nvme_tcp: sendpage_ok - pfn: 0x53ee, len: 262144, offset: 0
skbuff: before sendpage_ok() - pfn: 0x53ee
skbuff: before sendpage_ok() - pfn: 0x53ef
WARNING at net/core/skbuff.c:6848 skb_splice_from_iter+0x142/0x450
skbuff: !sendpage_ok - pfn: 0x53ef. is_slab: 1, page_count: 1
...
Cc: stable@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ofir Gal <ofir.gal@volumez.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20240607072748.3182199-1-ofir.gal@volumez.com
2024-06-07 10:27:44 +03:00
|
|
|
|
2023-02-24 11:33:21 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-06-15 08:48:38 +02:00
|
|
|
|
|
|
|
|
|
2023-02-24 11:33:21 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-06-15 08:48:30 +02:00
|
|
|
|
|
|
|
|
|
2023-02-24 11:33:21 -07:00
|
|
|
|
2023-06-15 08:48:38 +02:00
|
|
|
|
2023-06-15 08:48:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-02-24 11:33:21 -07:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:27 -07:00
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2023-06-15 08:48:33 +02:00
|
|
|
|
2023-06-15 08:48:39 +02:00
|
|
|
|
2023-06-15 08:48:33 +02:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2023-06-15 08:48:33 +02:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2023-06-15 08:48:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2023-06-15 08:48:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2006-06-26 00:27:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:15 +10:00
|
|
|
|
|
|
|
|
|
2006-06-26 00:27:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
2006-06-26 00:27:48 -07:00
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-06-26 00:27:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-06-01 21:47:42 -07:00
|
|
|
|
2006-06-26 00:27:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-06-15 08:48:34 +02:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
2013-01-23 17:07:38 -05:00
|
|
|
|
2006-06-26 00:27:48 -07:00
|
|
|
|
2020-01-09 14:30:41 +01:00
|
|
|
|
2020-08-18 13:42:06 +08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2011-10-07 14:23:17 +11:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2024-08-29 15:06:40 +02:00
|
|
|
|
2006-06-26 00:27:48 -07:00
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
2006-06-26 00:27:48 -07:00
|
|
|
|
|
|
|
|
|
2020-06-01 21:47:42 -07:00
|
|
|
|
2020-01-09 14:30:41 +01:00
|
|
|
|
2006-06-26 00:27:48 -07:00
|
|
|
|
2020-01-09 14:30:41 +01:00
|
|
|
|
|
|
|
|
|
2006-06-26 00:27:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-01-09 14:30:41 +01:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
2020-01-09 14:30:41 +01:00
|
|
|
|
2006-06-26 00:27:48 -07:00
|
|
|
|
|
|
|
|
|
2020-01-09 14:30:41 +01:00
|
|
|
|
|
|
|
|
|
2006-06-26 00:27:48 -07:00
|
|
|
|
2020-08-18 13:42:06 +08:00
|
|
|
|
2006-06-26 00:27:48 -07:00
|
|
|
|
|
|
|
|
|
2020-08-18 13:42:06 +08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2006-06-26 00:27:48 -07:00
|
|
|
|
|
|
|
|
|
2006-06-26 00:27:49 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-07-14 11:07:13 -07:00
|
|
|
|
2006-06-26 00:27:48 -07:00
|
|
|
|
2020-01-09 14:30:41 +01:00
|
|
|
|
2006-06-26 00:27:48 -07:00
|
|
|
|
|
|
|
|
|
2006-06-26 00:27:49 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:15 +10:00
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
2016-11-02 14:16:49 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2023-06-15 08:48:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-06-15 08:48:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-06-15 08:48:38 +02:00
|
|
|
|
|
|
|
|
|
2023-06-15 08:48:33 +02:00
|
|
|
|
2023-06-15 08:48:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-02-23 20:11:28 +08:00
|
|
|
|
|
|
|
|
|
2023-06-15 08:48:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-06-15 08:48:33 +02:00
|
|
|
|
|
|
|
|
|
2023-06-15 08:48:38 +02:00
|
|
|
|
2023-06-15 08:48:33 +02:00
|
|
|
|
|
|
|
|
|
2016-11-04 16:46:03 +11:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2016-11-04 16:46:03 +11:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2016-11-04 16:46:03 +11:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2016-11-04 16:46:03 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-11-18 16:16:11 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-11-04 16:46:03 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2024-08-26 15:44:52 +08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:52 +08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2007-07-17 04:06:13 -07:00
|
|
|
|
2009-12-14 12:49:56 +11:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
2007-07-17 04:06:13 -07:00
|
|
|
|
2025-01-08 11:21:30 -08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2011-05-11 14:26:30 +10:00
|
|
|
|
2008-06-28 08:31:22 +10:00
|
|
|
|
|
|
|
|
|
2011-05-11 14:26:30 +10:00
|
|
|
|
2017-11-06 10:11:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:26 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-29 10:20:02 -05:00
|
|
|
|
2012-05-22 13:55:34 +10:00
|
|
|
|
|
|
|
|
|
2025-01-08 11:21:30 -08:00
|
|
|
|
2023-06-15 08:48:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:27 +08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2025-01-08 11:21:30 -08:00
|
|
|
|
2016-11-02 14:16:49 +11:00
|
|
|
|
|
|
|
|
|
2022-10-25 09:37:05 +02:00
|
|
|
|
2016-11-02 14:16:49 +11:00
|
|
|
|
2019-04-04 18:56:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-11-02 14:16:49 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-10-25 09:37:05 +02:00
|
|
|
|
|
|
|
|
|
2016-11-02 14:16:49 +11:00
|
|
|
|
|
|
|
|
|
2022-10-25 09:37:05 +02:00
|
|
|
|
2025-01-08 11:21:30 -08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2011-06-08 17:59:30 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2011-06-08 17:59:30 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-07-22 12:09:17 -05:00
|
|
|
|
2012-10-11 13:45:36 +11:00
|
|
|
|
|
|
|
|
|
2023-06-15 08:48:38 +02:00
|
|
|
|
2011-06-08 17:59:30 -05:00
|
|
|
|
2025-01-08 11:21:30 -08:00
|
|
|
|
2011-06-08 17:59:30 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-08 11:21:30 -08:00
|
|
|
|
2016-11-02 14:16:49 +11:00
|
|
|
|
2011-06-08 17:59:30 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-03-07 12:01:05 +00:00
|
|
|
|
2016-11-02 14:16:49 +11:00
|
|
|
|
2011-06-08 17:59:30 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:15 +10:00
|
|
|
|
2012-05-22 13:55:14 +10:00
|
|
|
|
2011-06-08 17:59:30 -05:00
|
|
|
|
|
|
|
|
|
2015-07-22 12:09:17 -05:00
|
|
|
|
2011-06-08 17:59:30 -05:00
|
|
|
|
2025-01-08 11:21:30 -08:00
|
|
|
|
2011-06-08 17:59:30 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-09-09 16:23:47 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2014-03-29 10:20:02 -05:00
|
|
|
|
2012-05-22 13:55:34 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
2023-06-15 08:48:37 +02:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:15 +10:00
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
2014-06-06 11:50:56 -05:00
|
|
|
|
2014-06-06 12:43:49 -05:00
|
|
|
|
|
|
|
|
|
2015-03-03 13:35:31 +11:00
|
|
|
|
2014-06-06 12:43:49 -05:00
|
|
|
|
2020-10-06 00:00:23 +08:00
|
|
|
|
|
|
|
|
|
2015-03-24 11:29:05 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-03-02 17:02:29 +11:00
|
|
|
|
2023-06-15 08:48:37 +02:00
|
|
|
|
2016-11-02 14:16:49 +11:00
|
|
|
|
2015-07-01 12:19:56 +10:00
|
|
|
|
2014-06-06 12:43:49 -05:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
|
|
|
|
|
2007-01-26 00:57:03 -08:00
|
|
|
|
|
|
|
|
|
2023-06-15 08:48:34 +02:00
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
2007-01-26 00:57:03 -08:00
|
|
|
|
2023-06-15 08:48:37 +02:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:27 -07:00
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2014-06-06 11:50:56 -05:00
|
|
|
|
2025-01-08 11:21:30 -08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:53 +11:00
|
|
|
|
2005-09-09 16:23:47 -07:00
|
|
|
|
2012-05-22 13:55:34 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-11-08 21:39:32 -08:00
|
|
|
|
2015-08-19 07:35:54 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2009-03-31 14:27:02 +11:00
|
|
|
|
2006-01-06 00:20:39 -08:00
|
|
|
|
2011-06-08 18:01:10 -05:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2009-12-14 12:49:53 +11:00
|
|
|
|
2006-01-06 00:20:39 -08:00
|
|
|
|
2005-09-09 16:23:47 -07:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2016-11-02 14:16:49 +11:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-04-01 10:13:16 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-04-01 10:13:17 +08:00
|
|
|
|
2022-04-01 10:13:16 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-19 12:46:40 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-11-02 14:16:49 +11:00
|
|
|
|
|
|
|
|
|
2012-03-19 12:46:40 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-06-06 11:50:56 -05:00
|
|
|
|
2016-11-02 14:16:49 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:15 +10:00
|
|
|
|
2012-03-19 12:46:40 +11:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2006-10-21 10:24:09 -07:00
|
|
|
|
2005-11-08 21:39:32 -08:00
|
|
|
|
2012-05-22 13:55:15 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2014-06-06 11:50:56 -05:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2025-01-08 11:21:30 -08:00
|
|
|
|
2015-07-22 12:09:16 -05:00
|
|
|
|
2022-04-01 10:13:16 +08:00
|
|
|
|
|
|
|
|
|
2014-06-06 11:50:56 -05:00
|
|
|
|
|
|
|
|
|
2016-11-02 14:16:49 +11:00
|
|
|
|
|
|
|
|
|
2014-06-06 11:50:56 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
2022-04-01 10:13:16 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:27 +08:00
|
|
|
|
2014-06-06 12:43:49 -05:00
|
|
|
|
2014-06-06 11:50:56 -05:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:56 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
2009-12-14 12:49:56 +11:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
2009-12-14 12:49:56 +11:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
2011-07-27 11:00:37 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
2010-06-01 19:37:31 +10:00
|
|
|
|
2014-05-28 13:39:23 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:12 +10:00
|
|
|
|
2014-06-06 11:50:56 -05:00
|
|
|
|
2012-05-22 13:55:12 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-02 11:50:13 -04:00
|
|
|
|
2012-05-22 13:55:12 +10:00
|
|
|
|
treewide: kmalloc() -> kmalloc_array()
The kmalloc() function has a 2-factor argument form, kmalloc_array(). This
patch replaces cases of:
kmalloc(a * b, gfp)
with:
kmalloc_array(a * b, gfp)
as well as handling cases of:
kmalloc(a * b * c, gfp)
with:
kmalloc(array3_size(a, b, c), gfp)
as it's slightly less ugly than:
kmalloc_array(array_size(a, b), c, gfp)
This does, however, attempt to ignore constant size factors like:
kmalloc(4 * 1024, gfp)
though any constants defined via macros get caught up in the conversion.
Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.
The tools/ directory was manually excluded, since it has its own
implementation of kmalloc().
The Coccinelle script used for this was:
// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@
(
kmalloc(
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
, ...)
|
kmalloc(
- (sizeof(THING)) * E
+ sizeof(THING) * E
, ...)
)
// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@
(
kmalloc(
- sizeof(u8) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(__u8) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(char) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(unsigned char) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(u8) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(__u8) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(char) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(unsigned char) * COUNT
+ COUNT
, ...)
)
// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@
(
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (COUNT_ID)
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * COUNT_ID
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (COUNT_CONST)
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * COUNT_CONST
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (COUNT_ID)
+ COUNT_ID, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * COUNT_ID
+ COUNT_ID, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (COUNT_CONST)
+ COUNT_CONST, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * COUNT_CONST
+ COUNT_CONST, sizeof(THING)
, ...)
)
// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@
- kmalloc
+ kmalloc_array
(
- SIZE * COUNT
+ COUNT, SIZE
, ...)
// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@
(
kmalloc(
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
)
// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@
(
kmalloc(
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kmalloc(
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
)
// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@
(
kmalloc(
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
)
// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@
(
kmalloc(C1 * C2 * C3, ...)
|
kmalloc(
- (E1) * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- (E1) * (E2) * E3
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- (E1) * (E2) * (E3)
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
)
// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@
(
kmalloc(sizeof(THING) * C2, ...)
|
kmalloc(sizeof(TYPE) * C2, ...)
|
kmalloc(C1 * C2 * C3, ...)
|
kmalloc(C1 * C2, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (E2)
+ E2, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * E2
+ E2, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (E2)
+ E2, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * E2
+ E2, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- (E1) * E2
+ E1, E2
, ...)
|
- kmalloc
+ kmalloc_array
(
- (E1) * (E2)
+ E1, E2
, ...)
|
- kmalloc
+ kmalloc_array
(
- E1 * E2
+ E1, E2
, ...)
)
Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-12 13:55:00 -07:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:12 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:25 +10:00
|
|
|
|
2012-05-22 13:55:12 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-06-06 11:50:56 -05:00
|
|
|
|
2012-05-22 13:55:12 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-06-15 08:48:38 +02:00
|
|
|
|
2012-05-22 13:55:12 +10:00
|
|
|
|
2014-06-06 11:50:56 -05:00
|
|
|
|
2012-05-22 13:55:12 +10:00
|
|
|
|
2012-05-22 13:55:25 +10:00
|
|
|
|
2012-05-22 13:55:12 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2023-06-15 08:48:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:56 +11:00
|
|
|
|
2006-06-26 00:27:48 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:21 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2006-06-26 00:27:48 -07:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2006-06-26 00:27:48 -07:00
|
|
|
|
2013-01-23 17:07:38 -05:00
|
|
|
|
2007-02-10 01:45:39 -08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2006-06-26 00:27:48 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:15 +10:00
|
|
|
|
2024-08-26 15:44:28 +08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
2023-06-15 08:48:32 +02:00
|
|
|
|
|
|
|
|
|
2008-05-23 13:04:34 -07:00
|
|
|
|
2007-07-17 04:06:13 -07:00
|
|
|
|
2016-11-02 14:16:49 +11:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:27 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-06-01 19:37:31 +10:00
|
|
|
|
2011-09-21 15:37:46 +10:00
|
|
|
|
|
|
|
|
|
2010-06-01 19:37:31 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:09 +10:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:22 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:09 +10:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:22 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:22 +10:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:22 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2011-07-27 11:00:37 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2016-05-02 11:50:14 -04:00
|
|
|
|
2023-06-15 08:48:38 +02:00
|
|
|
|
2016-05-02 11:50:14 -04:00
|
|
|
|
|
|
|
|
|
2024-02-23 20:11:28 +08:00
|
|
|
|
2016-05-02 11:50:14 -04:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
2011-07-27 11:00:37 +10:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2011-07-27 11:00:37 +10:00
|
|
|
|
2025-01-08 11:21:30 -08:00
|
|
|
|
2012-05-22 13:55:15 +10:00
|
|
|
|
2011-07-27 11:00:37 +10:00
|
|
|
|
|
|
|
|
|
2013-04-24 11:42:41 +10:00
|
|
|
|
2025-01-08 11:21:30 -08:00
|
|
|
|
2023-06-15 08:48:38 +02:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2023-06-15 08:48:38 +02:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2016-05-02 11:50:14 -04:00
|
|
|
|
2023-06-15 08:48:38 +02:00
|
|
|
|
2016-05-02 11:50:14 -04:00
|
|
|
|
|
|
|
|
|
2024-02-23 20:11:28 +08:00
|
|
|
|
2016-05-02 11:50:14 -04:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
2025-01-08 11:21:30 -08:00
|
|
|
|
2012-05-22 13:55:15 +10:00
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
|
|
|
|
|
2013-04-24 11:42:41 +10:00
|
|
|
|
2025-01-08 11:21:30 -08:00
|
|
|
|
2023-06-15 08:48:38 +02:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2014-06-07 00:36:26 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-08 11:21:30 -08:00
|
|
|
|
2014-06-07 00:36:26 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-08 11:21:30 -08:00
|
|
|
|
2014-06-07 00:36:26 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:41 +08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:19 +10:00
|
|
|
|
2006-06-26 00:27:45 -07:00
|
|
|
|
2016-11-04 16:46:03 +11:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2024-08-26 15:44:51 +08:00
|
|
|
|
2007-07-17 04:06:13 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
2012-05-22 13:55:22 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-11-14 16:30:21 +11:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2024-03-03 07:01:41 -07:00
|
|
|
|
|
|
|
|
|
2016-11-14 16:30:21 +11:00
|
|
|
|
2012-05-22 13:55:09 +10:00
|
|
|
|
2023-06-15 08:48:38 +02:00
|
|
|
|
2016-11-04 16:46:03 +11:00
|
|
|
|
2012-05-22 13:55:22 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2016-11-04 16:46:03 +11:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2014-09-09 14:13:51 +10:00
|
|
|
|
2012-05-22 13:55:15 +10:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2023-05-29 21:11:04 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:41 +08:00
|
|
|
|
2023-05-29 21:11:04 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:41 +08:00
|
|
|
|
2023-05-29 21:11:04 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-11-05 21:01:05 +08:00
|
|
|
|
2023-05-29 21:11:04 +08:00
|
|
|
|
2024-08-26 15:44:41 +08:00
|
|
|
|
2024-08-26 15:44:42 +08:00
|
|
|
|
2024-08-26 15:44:41 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-05-29 21:11:04 +08:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2023-06-15 08:48:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-09-09 16:23:44 -07:00
|
|
|
|
|
|
|
|
|
2023-06-15 08:48:35 +02:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2023-06-15 08:48:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
2023-06-15 08:48:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2023-06-15 08:48:35 +02:00
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:12 +10:00
|
|
|
|
2016-11-02 14:16:49 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-06-15 08:48:35 +02:00
|
|
|
|
2007-07-17 04:06:13 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2005-06-21 17:17:17 -07:00
|
|
|
|
2023-06-15 08:48:35 +02:00
|
|
|
|
2014-06-06 11:50:56 -05:00
|
|
|
|
|
|
|
|
|
2023-06-15 08:48:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
2023-06-15 08:48:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:27 -07:00
|
|
|
|
2023-06-15 08:48:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-06-15 08:48:37 +02:00
|
|
|
|
|
|
|
|
|
2023-06-15 08:48:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2023-06-15 08:48:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-07-17 04:06:13 -07:00
|
|
|
|
2023-06-15 08:48:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-08 11:21:30 -08:00
|
|
|
|
2023-06-15 08:48:35 +02:00
|
|
|
|
2025-01-08 11:21:30 -08:00
|
|
|
|
2023-06-15 08:48:35 +02:00
|
|
|
|
2023-06-15 08:48:38 +02:00
|
|
|
|
2023-06-15 08:48:35 +02:00
|
|
|
|
2007-07-17 04:06:13 -07:00
|
|
|
|
2023-06-15 08:48:35 +02:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2023-06-15 08:48:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-08 11:21:30 -08:00
|
|
|
|
2012-05-22 13:55:15 +10:00
|
|
|
|
2023-06-15 08:48:35 +02:00
|
|
|
|
2005-11-08 21:39:32 -08:00
|
|
|
|
2023-06-15 08:48:35 +02:00
|
|
|
|
2025-01-08 11:21:30 -08:00
|
|
|
|
2023-06-15 08:48:35 +02:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2009-05-07 12:49:06 +10:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-11-02 14:16:49 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2007-07-17 04:06:13 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-11-02 14:16:49 +11:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:31 +08:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:27 -07:00
|
|
|
|
2006-06-26 00:27:45 -07:00
|
|
|
|
2024-08-26 15:44:31 +08:00
|
|
|
|
2005-06-21 17:17:27 -07:00
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
2024-08-26 15:44:31 +08:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
2024-08-26 15:44:31 +08:00
|
|
|
|
2011-09-21 15:37:46 +10:00
|
|
|
|
2005-06-21 17:17:27 -07:00
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-03-19 12:46:41 +11:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:06 +10:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2012-05-22 13:55:06 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
md/bitmap: factor out a helper to set timeout
Register/unregister 'mddev->thread' are both under 'reconfig_mutex',
however, some context didn't hold the mutex to access mddev->thread,
which can cause null-ptr-deference:
1) md_bitmap_daemon_work() can be called from md_check_recovery() where
'reconfig_mutex' is not held, deference 'mddev->thread' might cause
null-ptr-deference, because md_unregister_thread() reset the pointer
before stopping the thread.
2) timeout_store() access 'mddev->thread' multiple times,
null-ptr-deference can be triggered if 'mddev->thread' is reset in the
middle.
This patch factor out a helper to set timeout, the new helper always
check if 'mddev->thread' is null first, so that problem 1 can be fixed.
Now that this helper only access 'mddev->thread' once, but it's possible
that 'mddev->thread' can be freed while this helper is still in progress,
hence the problem is not fixed yet. Follow up patches will fix this by
protecting md_thread with rcu.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230523021017.3048783-5-yukuai1@huaweicloud.com
2023-05-23 10:10:16 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-05-23 10:10:17 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
md/bitmap: factor out a helper to set timeout
Register/unregister 'mddev->thread' are both under 'reconfig_mutex',
however, some context didn't hold the mutex to access mddev->thread,
which can cause null-ptr-deference:
1) md_bitmap_daemon_work() can be called from md_check_recovery() where
'reconfig_mutex' is not held, deference 'mddev->thread' might cause
null-ptr-deference, because md_unregister_thread() reset the pointer
before stopping the thread.
2) timeout_store() access 'mddev->thread' multiple times,
null-ptr-deference can be triggered if 'mddev->thread' is reset in the
middle.
This patch factor out a helper to set timeout, the new helper always
check if 'mddev->thread' is null first, so that problem 1 can be fixed.
Now that this helper only access 'mddev->thread' once, but it's possible
that 'mddev->thread' can be freed while this helper is still in progress,
hence the problem is not fixed yet. Follow up patches will fix this by
protecting md_thread with rcu.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230523021017.3048783-5-yukuai1@huaweicloud.com
2023-05-23 10:10:16 +08:00
|
|
|
|
|
|
|
|
|
2023-05-23 10:10:17 +08:00
|
|
|
|
md/bitmap: factor out a helper to set timeout
Register/unregister 'mddev->thread' are both under 'reconfig_mutex',
however, some context didn't hold the mutex to access mddev->thread,
which can cause null-ptr-deference:
1) md_bitmap_daemon_work() can be called from md_check_recovery() where
'reconfig_mutex' is not held, deference 'mddev->thread' might cause
null-ptr-deference, because md_unregister_thread() reset the pointer
before stopping the thread.
2) timeout_store() access 'mddev->thread' multiple times,
null-ptr-deference can be triggered if 'mddev->thread' is reset in the
middle.
This patch factor out a helper to set timeout, the new helper always
check if 'mddev->thread' is null first, so that problem 1 can be fixed.
Now that this helper only access 'mddev->thread' once, but it's possible
that 'mddev->thread' can be freed while this helper is still in progress,
hence the problem is not fixed yet. Follow up patches will fix this by
protecting md_thread with rcu.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230523021017.3048783-5-yukuai1@huaweicloud.com
2023-05-23 10:10:16 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-05-23 10:10:17 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
md/bitmap: factor out a helper to set timeout
Register/unregister 'mddev->thread' are both under 'reconfig_mutex',
however, some context didn't hold the mutex to access mddev->thread,
which can cause null-ptr-deference:
1) md_bitmap_daemon_work() can be called from md_check_recovery() where
'reconfig_mutex' is not held, deference 'mddev->thread' might cause
null-ptr-deference, because md_unregister_thread() reset the pointer
before stopping the thread.
2) timeout_store() access 'mddev->thread' multiple times,
null-ptr-deference can be triggered if 'mddev->thread' is reset in the
middle.
This patch factor out a helper to set timeout, the new helper always
check if 'mddev->thread' is null first, so that problem 1 can be fixed.
Now that this helper only access 'mddev->thread' once, but it's possible
that 'mddev->thread' can be freed while this helper is still in progress,
hence the problem is not fixed yet. Follow up patches will fix this by
protecting md_thread with rcu.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230523021017.3048783-5-yukuai1@huaweicloud.com
2023-05-23 10:10:16 +08:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:43 +08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2009-12-14 12:49:46 +11:00
|
|
|
|
2005-06-21 17:17:22 -07:00
|
|
|
|
2012-05-22 13:55:06 +10:00
|
|
|
|
2010-10-19 10:03:39 +11:00
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2009-12-14 12:49:46 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:52 +11:00
|
|
|
|
2009-12-14 12:49:46 +11:00
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:52 +11:00
|
|
|
|
2007-07-17 04:06:13 -07:00
|
|
|
|
2009-12-14 12:49:46 +11:00
|
|
|
|
2009-12-14 12:49:53 +11:00
|
|
|
|
2011-12-23 10:17:50 +11:00
|
|
|
|
2008-03-10 11:43:48 -07:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2008-03-04 14:29:30 -08:00
|
|
|
|
md/bitmap: factor out a helper to set timeout
Register/unregister 'mddev->thread' are both under 'reconfig_mutex',
however, some context didn't hold the mutex to access mddev->thread,
which can cause null-ptr-deference:
1) md_bitmap_daemon_work() can be called from md_check_recovery() where
'reconfig_mutex' is not held, deference 'mddev->thread' might cause
null-ptr-deference, because md_unregister_thread() reset the pointer
before stopping the thread.
2) timeout_store() access 'mddev->thread' multiple times,
null-ptr-deference can be triggered if 'mddev->thread' is reset in the
middle.
This patch factor out a helper to set timeout, the new helper always
check if 'mddev->thread' is null first, so that problem 1 can be fixed.
Now that this helper only access 'mddev->thread' once, but it's possible
that 'mddev->thread' can be freed while this helper is still in progress,
hence the problem is not fixed yet. Follow up patches will fix this by
protecting md_thread with rcu.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230523021017.3048783-5-yukuai1@huaweicloud.com
2023-05-23 10:10:16 +08:00
|
|
|
|
2009-12-14 12:49:46 +11:00
|
|
|
|
2008-03-04 14:29:30 -08:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2024-03-03 07:01:41 -07:00
|
|
|
|
2016-11-14 16:30:21 +11:00
|
|
|
|
2012-05-22 13:55:06 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
2012-05-22 13:55:22 +10:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:09 +10:00
|
|
|
|
2012-05-22 13:55:06 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
2025-01-08 11:21:30 -08:00
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
|
|
|
|
|
2025-01-08 11:21:30 -08:00
|
|
|
|
2012-05-22 13:55:09 +10:00
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:06 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:06 +10:00
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2011-07-27 11:00:37 +10:00
|
|
|
|
2012-05-22 13:55:06 +10:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2012-05-22 13:55:06 +10:00
|
|
|
|
2005-06-21 17:17:22 -07:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2012-05-22 13:55:06 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:06 +10:00
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2011-09-21 15:37:46 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2012-05-22 13:55:06 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:21 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:09 +10:00
|
|
|
|
2012-05-22 13:55:06 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-12-07 11:00:08 +08:00
|
|
|
|
|
|
|
|
|
2023-06-15 08:48:38 +02:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:06 +10:00
|
|
|
|
|
|
|
|
|
2008-03-10 11:43:48 -07:00
|
|
|
|
2008-03-04 14:29:30 -08:00
|
|
|
|
md/bitmap: factor out a helper to set timeout
Register/unregister 'mddev->thread' are both under 'reconfig_mutex',
however, some context didn't hold the mutex to access mddev->thread,
which can cause null-ptr-deference:
1) md_bitmap_daemon_work() can be called from md_check_recovery() where
'reconfig_mutex' is not held, deference 'mddev->thread' might cause
null-ptr-deference, because md_unregister_thread() reset the pointer
before stopping the thread.
2) timeout_store() access 'mddev->thread' multiple times,
null-ptr-deference can be triggered if 'mddev->thread' is reset in the
middle.
This patch factor out a helper to set timeout, the new helper always
check if 'mddev->thread' is null first, so that problem 1 can be fixed.
Now that this helper only access 'mddev->thread' once, but it's possible
that 'mddev->thread' can be freed while this helper is still in progress,
hence the problem is not fixed yet. Follow up patches will fix this by
protecting md_thread with rcu.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230523021017.3048783-5-yukuai1@huaweicloud.com
2023-05-23 10:10:16 +08:00
|
|
|
|
2009-12-14 12:49:52 +11:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-09-23 18:06:44 +10:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-19 12:46:41 +11:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2024-04-22 14:58:24 +08:00
|
|
|
|
2010-06-01 19:37:33 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2023-05-15 21:48:05 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-04-22 14:58:24 +08:00
|
|
|
|
2023-05-15 21:48:05 +08:00
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2010-06-01 19:37:33 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-19 12:46:41 +11:00
|
|
|
|
2020-10-06 00:00:24 +08:00
|
|
|
|
2024-04-22 14:58:24 +08:00
|
|
|
|
2010-06-01 19:37:33 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2010-06-01 19:37:33 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-06-01 19:37:33 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:33 +08:00
|
|
|
|
2025-01-09 09:51:41 +08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2024-08-26 15:44:33 +08:00
|
|
|
|
|
|
|
|
|
2010-06-01 19:37:31 +10:00
|
|
|
|
|
|
|
|
|
2005-09-09 16:23:47 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2010-10-19 10:03:39 +11:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-06-09 11:42:57 +10:00
|
|
|
|
2007-02-08 14:20:37 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2012-08-02 08:33:20 +10:00
|
|
|
|
2007-02-08 14:20:37 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-06-01 19:37:31 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
|
|
|
|
|
2020-08-23 17:36:59 -05:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-02-08 14:20:37 -08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-06-01 19:37:31 +10:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:34 +08:00
|
|
|
|
2025-01-09 09:51:42 +08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2024-08-26 15:44:34 +08:00
|
|
|
|
|
|
|
|
|
2010-06-01 19:37:31 +10:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:34 +08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2010-10-19 10:03:39 +11:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-09 09:51:42 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2025-01-09 09:51:42 +08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2011-06-09 11:42:57 +10:00
|
|
|
|
2007-02-08 14:20:37 -08:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2011-09-21 15:37:46 +10:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2011-09-21 15:37:46 +10:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-06-01 19:37:31 +10:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:35 +08:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:35 +08:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:35 +08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2024-08-26 15:44:35 +08:00
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-07-15 03:56:35 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2024-08-26 15:44:35 +08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:35 +08:00
|
|
|
|
|
|
|
|
|
2009-03-31 14:27:02 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:35 +08:00
|
|
|
|
2010-10-19 10:03:39 +11:00
|
|
|
|
2009-03-31 14:27:02 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:35 +08:00
|
|
|
|
2009-03-31 14:27:02 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:35 +08:00
|
|
|
|
2009-03-31 14:27:02 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:36 +08:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-06-01 19:37:31 +10:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-09-21 15:37:46 +10:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2011-09-21 15:37:46 +10:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:37 +08:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:36 +08:00
|
|
|
|
2024-08-26 15:44:37 +08:00
|
|
|
|
2024-08-26 15:44:36 +08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2024-08-26 15:44:38 +08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-10-19 10:03:39 +11:00
|
|
|
|
2024-08-26 15:44:38 +08:00
|
|
|
|
|
|
|
|
|
2008-02-06 01:39:50 -08:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:38 +08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2024-08-26 15:44:36 +08:00
|
|
|
|
2008-02-06 01:39:50 -08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:39 +08:00
|
|
|
|
|
|
|
|
|
2008-02-06 01:39:50 -08:00
|
|
|
|
|
|
|
|
|
2010-10-19 10:03:39 +11:00
|
|
|
|
2024-08-26 15:44:39 +08:00
|
|
|
|
2008-02-06 01:39:50 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-08-19 08:14:42 +10:00
|
|
|
|
2009-12-14 12:49:53 +11:00
|
|
|
|
2008-02-06 01:39:50 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-14 09:14:34 +11:00
|
|
|
|
2016-12-08 15:48:19 -08:00
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2008-02-06 01:39:50 -08:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:36 +08:00
|
|
|
|
2008-02-06 01:39:50 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-07-14 16:10:26 -07:00
|
|
|
|
2008-02-06 01:39:50 -08:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:40 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-02 11:50:12 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:36 +08:00
|
|
|
|
2016-05-02 11:50:12 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:35 +08:00
|
|
|
|
2016-05-02 11:50:12 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2005-08-04 12:53:33 -07:00
|
|
|
|
2010-10-19 10:03:39 +11:00
|
|
|
|
2005-08-04 12:53:33 -07:00
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2005-08-04 12:53:33 -07:00
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2005-08-04 12:53:33 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2010-06-01 19:37:31 +10:00
|
|
|
|
2014-06-07 00:36:26 -05:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
|
|
|
|
|
2011-09-21 15:37:46 +10:00
|
|
|
|
2005-08-04 12:53:33 -07:00
|
|
|
|
2014-06-07 00:36:26 -05:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2006-10-03 01:15:49 -07:00
|
|
|
|
2024-08-26 15:44:32 +08:00
|
|
|
|
|
|
|
|
|
2006-10-03 01:15:49 -07:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:32 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-10-03 01:15:49 -07:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2024-08-26 15:44:32 +08:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:56 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-10-03 01:15:49 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:26 +08:00
|
|
|
|
2005-08-04 12:53:35 -07:00
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:53 +11:00
|
|
|
|
2005-08-04 12:53:35 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:53 +11:00
|
|
|
|
2009-12-14 12:49:53 +11:00
|
|
|
|
2024-08-26 15:44:43 +08:00
|
|
|
|
2009-12-14 12:49:53 +11:00
|
|
|
|
2024-08-26 15:44:43 +08:00
|
|
|
|
2009-12-14 12:49:53 +11:00
|
|
|
|
2024-08-26 15:44:43 +08:00
|
|
|
|
2021-04-13 04:08:29 +00:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:28 +08:00
|
|
|
|
2005-08-04 12:53:35 -07:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:52 +08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:52 +08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-04-01 17:08:49 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-06-06 12:43:49 -05:00
|
|
|
|
|
|
|
|
|
2014-06-06 11:50:56 -05:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:21 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:46 +11:00
|
|
|
|
2025-01-09 09:51:41 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:50 +08:00
|
|
|
|
2017-03-14 09:40:20 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:25 +08:00
|
|
|
|
2005-09-09 16:23:50 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:50 +08:00
|
|
|
|
2019-12-23 10:49:00 +01:00
|
|
|
|
2023-10-10 23:19:53 +08:00
|
|
|
|
2017-03-14 09:40:20 +08:00
|
|
|
|
2009-12-14 12:49:52 +11:00
|
|
|
|
2014-12-15 12:56:58 +11:00
|
|
|
|
2005-09-09 16:23:50 -07:00
|
|
|
|
2014-12-15 12:56:58 +11:00
|
|
|
|
2009-12-14 12:49:52 +11:00
|
|
|
|
md/bitmap: factor out a helper to set timeout
Register/unregister 'mddev->thread' are both under 'reconfig_mutex',
however, some context didn't hold the mutex to access mddev->thread,
which can cause null-ptr-deference:
1) md_bitmap_daemon_work() can be called from md_check_recovery() where
'reconfig_mutex' is not held, deference 'mddev->thread' might cause
null-ptr-deference, because md_unregister_thread() reset the pointer
before stopping the thread.
2) timeout_store() access 'mddev->thread' multiple times,
null-ptr-deference can be triggered if 'mddev->thread' is reset in the
middle.
This patch factor out a helper to set timeout, the new helper always
check if 'mddev->thread' is null first, so that problem 1 can be fixed.
Now that this helper only access 'mddev->thread' once, but it's possible
that 'mddev->thread' can be freed while this helper is still in progress,
hence the problem is not fixed yet. Follow up patches will fix this by
protecting md_thread with rcu.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230523021017.3048783-5-yukuai1@huaweicloud.com
2023-05-23 10:10:16 +08:00
|
|
|
|
2005-09-09 16:23:50 -07:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2005-09-09 16:23:50 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-04-01 17:08:49 +08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2024-08-26 15:44:22 +08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2009-04-20 11:50:24 +10:00
|
|
|
|
2009-12-14 12:49:52 +11:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2013-12-11 14:11:53 -05:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2006-10-11 01:22:26 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2009-12-14 12:49:52 +11:00
|
|
|
|
2005-06-21 17:17:27 -07:00
|
|
|
|
2017-10-17 14:24:09 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-01-06 00:20:32 -08:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2014-06-06 12:43:49 -05:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2006-06-26 00:27:49 -07:00
|
|
|
|
|
|
|
|
|
2007-02-08 14:20:37 -08:00
|
|
|
|
2010-03-31 11:21:44 +11:00
|
|
|
|
2006-06-26 00:27:49 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2014-06-06 12:43:49 -05:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2010-06-01 19:37:32 +10:00
|
|
|
|
2013-09-11 23:19:13 -04:00
|
|
|
|
2009-12-14 12:49:56 +11:00
|
|
|
|
2013-09-11 23:19:13 -04:00
|
|
|
|
2009-12-14 12:49:56 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:10 +10:00
|
|
|
|
2006-06-26 00:27:49 -07:00
|
|
|
|
|
|
|
|
|
2009-10-16 15:56:01 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-03-22 17:32:25 +01:00
|
|
|
|
2006-06-26 00:27:49 -07:00
|
|
|
|
2009-12-14 12:49:53 +11:00
|
|
|
|
2011-06-08 17:59:30 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2011-06-08 17:59:30 -05:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2011-06-08 17:59:30 -05:00
|
|
|
|
2009-12-14 12:49:56 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2005-09-09 16:23:50 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2009-12-14 12:49:56 +11:00
|
|
|
|
2024-08-26 15:44:44 +08:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:25 +10:00
|
|
|
|
2005-09-09 16:23:50 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2016-11-02 14:16:49 +11:00
|
|
|
|
|
|
|
|
|
2010-06-01 19:37:35 +10:00
|
|
|
|
2014-06-06 12:43:49 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-06-01 19:37:35 +10:00
|
|
|
|
2014-06-06 12:43:49 -05:00
|
|
|
|
2010-06-01 19:37:35 +10:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2014-06-06 12:43:49 -05:00
|
|
|
|
2010-06-01 19:37:35 +10:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:23 +08:00
|
|
|
|
2024-08-26 15:44:22 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:24 +08:00
|
|
|
|
2010-06-01 19:37:35 +10:00
|
|
|
|
|
|
|
|
|
2011-07-27 11:00:37 +10:00
|
|
|
|
2010-06-01 19:37:35 +10:00
|
|
|
|
|
|
|
|
|
2019-06-14 17:10:38 +08:00
|
|
|
|
2010-06-01 19:37:35 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-06-14 17:10:38 +08:00
|
|
|
|
2023-10-10 23:19:53 +08:00
|
|
|
|
2019-06-14 17:10:38 +08:00
|
|
|
|
2016-05-04 02:17:09 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-06-01 19:37:35 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-10-19 10:03:39 +11:00
|
|
|
|
2024-08-26 15:44:35 +08:00
|
|
|
|
2010-06-01 19:37:35 +10:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:38 +08:00
|
|
|
|
2010-06-01 19:37:35 +10:00
|
|
|
|
2011-07-27 11:00:37 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-04-12 16:05:06 +10:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2012-04-12 16:05:06 +10:00
|
|
|
|
2010-06-01 19:37:35 +10:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
2010-06-01 19:37:35 +10:00
|
|
|
|
2012-05-22 13:55:15 +10:00
|
|
|
|
2012-05-22 13:55:08 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-09-09 16:23:50 -07:00
|
|
|
|
md/bitmap: factor out a helper to set timeout
Register/unregister 'mddev->thread' are both under 'reconfig_mutex',
however, some context didn't hold the mutex to access mddev->thread,
which can cause null-ptr-deference:
1) md_bitmap_daemon_work() can be called from md_check_recovery() where
'reconfig_mutex' is not held, deference 'mddev->thread' might cause
null-ptr-deference, because md_unregister_thread() reset the pointer
before stopping the thread.
2) timeout_store() access 'mddev->thread' multiple times,
null-ptr-deference can be triggered if 'mddev->thread' is reset in the
middle.
This patch factor out a helper to set timeout, the new helper always
check if 'mddev->thread' is null first, so that problem 1 can be fixed.
Now that this helper only access 'mddev->thread' once, but it's possible
that 'mddev->thread' can be freed while this helper is still in progress,
hence the problem is not fixed yet. Follow up patches will fix this by
protecting md_thread with rcu.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230523021017.3048783-5-yukuai1@huaweicloud.com
2023-05-23 10:10:16 +08:00
|
|
|
|
2009-12-14 12:49:54 +11:00
|
|
|
|
2006-01-06 00:20:16 -08:00
|
|
|
|
2024-08-26 15:44:28 +08:00
|
|
|
|
2007-07-17 04:06:13 -07:00
|
|
|
|
2012-05-22 13:55:15 +10:00
|
|
|
|
2010-06-01 19:37:35 +10:00
|
|
|
|
|
|
|
|
|
2005-09-09 16:23:50 -07:00
|
|
|
|
2005-06-21 17:17:14 -07:00
|
|
|
|
|
|
|
|
|
2020-09-27 13:40:13 +08:00
|
|
|
|
2024-08-26 15:44:52 +08:00
|
|
|
|
2017-03-01 16:42:39 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:22 +08:00
|
|
|
|
2017-03-01 16:42:39 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2017-03-01 16:42:39 +08:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2017-03-01 16:42:39 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-06-07 00:36:26 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:47 +08:00
|
|
|
|
|
|
|
|
|
2014-06-07 00:36:26 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-01 16:42:39 +08:00
|
|
|
|
2014-06-07 00:36:26 -05:00
|
|
|
|
2024-08-26 15:44:46 +08:00
|
|
|
|
2017-03-01 16:42:39 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-06-07 00:36:26 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2014-06-07 00:36:26 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-06-07 00:36:26 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-04-14 10:45:42 -05:00
|
|
|
|
2024-08-26 15:44:28 +08:00
|
|
|
|
2016-05-02 11:50:15 -04:00
|
|
|
|
|
|
|
|
|
2015-04-14 10:45:42 -05:00
|
|
|
|
2016-05-02 11:50:15 -04:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:41 +08:00
|
|
|
|
2015-04-14 10:45:42 -05:00
|
|
|
|
2024-08-26 15:44:41 +08:00
|
|
|
|
2014-06-07 00:36:26 -05:00
|
|
|
|
|
|
|
|
|
2020-09-27 13:40:13 +08:00
|
|
|
|
2017-03-01 16:42:39 +08:00
|
|
|
|
2014-06-07 00:36:26 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:52 +08:00
|
|
|
|
2012-03-19 12:46:40 +11:00
|
|
|
|
2024-08-26 15:44:52 +08:00
|
|
|
|
2012-03-19 12:46:40 +11:00
|
|
|
|
2024-08-26 15:44:20 +08:00
|
|
|
|
2012-03-19 12:46:40 +11:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:52 +08:00
|
|
|
|
2012-03-19 12:46:40 +11:00
|
|
|
|
2024-08-26 15:44:17 +08:00
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2024-08-26 15:44:52 +08:00
|
|
|
|
2024-08-26 15:44:16 +08:00
|
|
|
|
2012-03-19 12:46:40 +11:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:12 +08:00
|
|
|
|
2025-01-24 17:20:55 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:16 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2024-08-26 15:44:12 +08:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:14 +08:00
|
|
|
|
2024-08-26 15:44:17 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:24 +10:00
|
|
|
|
2024-08-26 15:44:18 +08:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:17 +08:00
|
|
|
|
2024-08-26 15:44:12 +08:00
|
|
|
|
2012-03-19 12:46:40 +11:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:44 +08:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:25 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-08-31 10:23:25 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:25 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-10-25 09:37:05 +02:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:25 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-31 10:19:00 +08:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2012-05-22 13:55:25 +10:00
|
|
|
|
2016-10-31 10:19:00 +08:00
|
|
|
|
2012-05-22 13:55:25 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
treewide: kzalloc() -> kcalloc()
The kzalloc() function has a 2-factor argument form, kcalloc(). This
patch replaces cases of:
kzalloc(a * b, gfp)
with:
kcalloc(a * b, gfp)
as well as handling cases of:
kzalloc(a * b * c, gfp)
with:
kzalloc(array3_size(a, b, c), gfp)
as it's slightly less ugly than:
kzalloc_array(array_size(a, b), c, gfp)
This does, however, attempt to ignore constant size factors like:
kzalloc(4 * 1024, gfp)
though any constants defined via macros get caught up in the conversion.
Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.
The Coccinelle script used for this was:
// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@
(
kzalloc(
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
, ...)
|
kzalloc(
- (sizeof(THING)) * E
+ sizeof(THING) * E
, ...)
)
// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@
(
kzalloc(
- sizeof(u8) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(__u8) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(char) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(unsigned char) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(u8) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(__u8) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(char) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(unsigned char) * COUNT
+ COUNT
, ...)
)
// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@
(
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (COUNT_ID)
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * COUNT_ID
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (COUNT_CONST)
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * COUNT_CONST
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (COUNT_ID)
+ COUNT_ID, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * COUNT_ID
+ COUNT_ID, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (COUNT_CONST)
+ COUNT_CONST, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * COUNT_CONST
+ COUNT_CONST, sizeof(THING)
, ...)
)
// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@
- kzalloc
+ kcalloc
(
- SIZE * COUNT
+ COUNT, SIZE
, ...)
// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@
(
kzalloc(
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
)
// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@
(
kzalloc(
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kzalloc(
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
)
// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@
(
kzalloc(
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
)
// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@
(
kzalloc(C1 * C2 * C3, ...)
|
kzalloc(
- (E1) * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- (E1) * (E2) * E3
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- (E1) * (E2) * (E3)
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
)
// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@
(
kzalloc(sizeof(THING) * C2, ...)
|
kzalloc(sizeof(TYPE) * C2, ...)
|
kzalloc(C1 * C2 * C3, ...)
|
kzalloc(C1 * C2, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (E2)
+ E2, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * E2
+ E2, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (E2)
+ E2, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * E2
+ E2, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- (E1) * E2
+ E1, E2
, ...)
|
- kzalloc
+ kcalloc
(
- (E1) * (E2)
+ E1, E2
, ...)
|
- kzalloc
+ kcalloc
(
- E1 * E2
+ E1, E2
, ...)
)
Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-12 14:03:40 -07:00
|
|
|
|
2012-05-22 13:55:25 +10:00
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2012-05-22 13:55:25 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-10-16 19:03:44 -07:00
|
|
|
|
md/bitmap: avoid race window between md_bitmap_resize and bitmap_file_clear_bit
We need to move "spin_lock_irq(&bitmap->counts.lock)" before unmap previous
storage, otherwise panic like belows could happen as follows.
[ 902.353802] sdl: detected capacity change from 1077936128 to 3221225472
[ 902.616948] general protection fault: 0000 [#1] SMP
[snip]
[ 902.618588] CPU: 12 PID: 33698 Comm: md0_raid1 Tainted: G O 4.14.144-1-pserver #4.14.144-1.1~deb10
[ 902.618870] Hardware name: Supermicro SBA-7142G-T4/BHQGE, BIOS 3.00 10/24/2012
[ 902.619120] task: ffff9ae1860fc600 task.stack: ffffb52e4c704000
[ 902.619301] RIP: 0010:bitmap_file_clear_bit+0x90/0xd0 [md_mod]
[ 902.619464] RSP: 0018:ffffb52e4c707d28 EFLAGS: 00010087
[ 902.619626] RAX: ffe8008b0d061000 RBX: ffff9ad078c87300 RCX: 0000000000000000
[ 902.619792] RDX: ffff9ad986341868 RSI: 0000000000000803 RDI: ffff9ad078c87300
[ 902.619986] RBP: ffff9ad0ed7a8000 R08: 0000000000000000 R09: 0000000000000000
[ 902.620154] R10: ffffb52e4c707ec0 R11: ffff9ad987d1ed44 R12: ffff9ad0ed7a8360
[ 902.620320] R13: 0000000000000003 R14: 0000000000060000 R15: 0000000000000800
[ 902.620487] FS: 0000000000000000(0000) GS:ffff9ad987d00000(0000) knlGS:0000000000000000
[ 902.620738] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 902.620901] CR2: 000055ff12aecec0 CR3: 0000001005207000 CR4: 00000000000406e0
[ 902.621068] Call Trace:
[ 902.621256] bitmap_daemon_work+0x2dd/0x360 [md_mod]
[ 902.621429] ? find_pers+0x70/0x70 [md_mod]
[ 902.621597] md_check_recovery+0x51/0x540 [md_mod]
[ 902.621762] raid1d+0x5c/0xeb0 [raid1]
[ 902.621939] ? try_to_del_timer_sync+0x4d/0x80
[ 902.622102] ? del_timer_sync+0x35/0x40
[ 902.622265] ? schedule_timeout+0x177/0x360
[ 902.622453] ? call_timer_fn+0x130/0x130
[ 902.622623] ? find_pers+0x70/0x70 [md_mod]
[ 902.622794] ? md_thread+0x94/0x150 [md_mod]
[ 902.622959] md_thread+0x94/0x150 [md_mod]
[ 902.623121] ? wait_woken+0x80/0x80
[ 902.623280] kthread+0x119/0x130
[ 902.623437] ? kthread_create_on_node+0x60/0x60
[ 902.623600] ret_from_fork+0x22/0x40
[ 902.624225] RIP: bitmap_file_clear_bit+0x90/0xd0 [md_mod] RSP: ffffb52e4c707d28
Because mdadm was running on another cpu to do resize, so bitmap_resize was
called to replace bitmap as below shows.
PID: 38801 TASK: ffff9ad074a90e00 CPU: 0 COMMAND: "mdadm"
[exception RIP: queued_spin_lock_slowpath+56]
[snip]
-- <NMI exception stack> --
#5 [ffffb52e60f17c58] queued_spin_lock_slowpath at ffffffff9c0b27b8
#6 [ffffb52e60f17c58] bitmap_resize at ffffffffc0399877 [md_mod]
#7 [ffffb52e60f17d30] raid1_resize at ffffffffc0285bf9 [raid1]
#8 [ffffb52e60f17d50] update_size at ffffffffc038a31a [md_mod]
#9 [ffffb52e60f17d70] md_ioctl at ffffffffc0395ca4 [md_mod]
And the procedure to keep resize bitmap safe is allocate new storage
space, then quiesce, copy bits, replace bitmap, and re-start.
However the daemon (bitmap_daemon_work) could happen even the array is
quiesced, which means when bitmap_file_clear_bit is triggered by raid1d,
then it thinks it should be fine to access store->filemap since
counts->lock is held, but resize could change the storage without the
protection of the lock.
Cc: Jack Wang <jinpu.wang@cloud.ionos.com>
Cc: NeilBrown <neilb@suse.com>
Signed-off-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
2019-09-26 13:53:50 +02:00
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2012-05-22 13:55:25 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-10-25 09:37:05 +02:00
|
|
|
|
2012-05-22 13:55:25 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-02 11:50:11 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2016-05-02 11:50:11 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-02 11:50:16 -04:00
|
|
|
|
2016-05-02 11:50:11 -04:00
|
|
|
|
2017-11-08 13:44:56 +01:00
|
|
|
|
2016-05-02 11:50:11 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-10-25 09:37:05 +02:00
|
|
|
|
|
|
|
|
|
2016-05-02 11:50:11 -04:00
|
|
|
|
2016-11-02 14:16:49 +11:00
|
|
|
|
2016-05-02 11:50:11 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:25 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2012-05-22 13:55:25 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2022-09-16 16:33:05 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:25 +10:00
|
|
|
|
2022-09-16 16:33:05 -07:00
|
|
|
|
2012-05-22 13:55:25 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-08 13:44:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:25 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
2012-05-22 13:55:25 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-01 15:20:50 -07:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:25 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:41 +08:00
|
|
|
|
2012-05-22 13:55:25 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:44 +08:00
|
|
|
|
2024-08-26 15:44:45 +08:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:25 +10:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
2011-10-11 16:47:53 +11:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
2010-06-01 19:37:31 +10:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
2010-06-01 19:37:31 +10:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
2010-06-01 19:37:31 +10:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-11 16:47:53 +11:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
2016-07-30 10:05:31 -07:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
2023-10-10 23:19:46 +08:00
|
|
|
|
2016-07-30 10:05:31 -07:00
|
|
|
|
|
|
|
|
|
2023-08-25 11:09:54 +08:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
2016-07-30 10:05:31 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-07-30 10:05:31 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 11:09:54 +08:00
|
|
|
|
2024-08-26 15:44:25 +08:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 11:09:54 +08:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-07-30 10:05:31 -07:00
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
2013-06-01 16:15:16 +09:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
2013-06-01 16:15:16 +09:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
2016-07-30 10:05:31 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:56 +11:00
|
|
|
|
|
|
|
|
|
2016-07-30 10:05:31 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 11:09:54 +08:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
2024-08-26 15:44:23 +08:00
|
|
|
|
2024-08-26 15:44:22 +08:00
|
|
|
|
2023-08-25 11:09:54 +08:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:24 +08:00
|
|
|
|
2023-08-25 11:09:54 +08:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:25 +08:00
|
|
|
|
2023-08-25 11:09:54 +08:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-12-08 15:48:19 -08:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
2016-07-30 10:05:31 -07:00
|
|
|
|
|
|
|
|
|
2023-10-10 23:19:46 +08:00
|
|
|
|
2016-07-30 10:05:31 -07:00
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:07 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:52 +08:00
|
|
|
|
2012-05-22 13:55:07 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:52 +08:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:07 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
2011-10-11 16:47:53 +11:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-06-01 19:37:31 +10:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-11 16:47:53 +11:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-05-23 10:10:15 +08:00
|
|
|
|
md/bitmap: factor out a helper to set timeout
Register/unregister 'mddev->thread' are both under 'reconfig_mutex',
however, some context didn't hold the mutex to access mddev->thread,
which can cause null-ptr-deference:
1) md_bitmap_daemon_work() can be called from md_check_recovery() where
'reconfig_mutex' is not held, deference 'mddev->thread' might cause
null-ptr-deference, because md_unregister_thread() reset the pointer
before stopping the thread.
2) timeout_store() access 'mddev->thread' multiple times,
null-ptr-deference can be triggered if 'mddev->thread' is reset in the
middle.
This patch factor out a helper to set timeout, the new helper always
check if 'mddev->thread' is null first, so that problem 1 can be fixed.
Now that this helper only access 'mddev->thread' once, but it's possible
that 'mddev->thread' can be freed while this helper is still in progress,
hence the problem is not fixed yet. Follow up patches will fix this by
protecting md_thread with rcu.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230523021017.3048783-5-yukuai1@huaweicloud.com
2023-05-23 10:10:16 +08:00
|
|
|
|
|
|
|
|
|
2023-05-23 10:10:15 +08:00
|
|
|
|
md/bitmap: factor out a helper to set timeout
Register/unregister 'mddev->thread' are both under 'reconfig_mutex',
however, some context didn't hold the mutex to access mddev->thread,
which can cause null-ptr-deference:
1) md_bitmap_daemon_work() can be called from md_check_recovery() where
'reconfig_mutex' is not held, deference 'mddev->thread' might cause
null-ptr-deference, because md_unregister_thread() reset the pointer
before stopping the thread.
2) timeout_store() access 'mddev->thread' multiple times,
null-ptr-deference can be triggered if 'mddev->thread' is reset in the
middle.
This patch factor out a helper to set timeout, the new helper always
check if 'mddev->thread' is null first, so that problem 1 can be fixed.
Now that this helper only access 'mddev->thread' once, but it's possible
that 'mddev->thread' can be freed while this helper is still in progress,
hence the problem is not fixed yet. Follow up patches will fix this by
protecting md_thread with rcu.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230523021017.3048783-5-yukuai1@huaweicloud.com
2023-05-23 10:10:16 +08:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-11 16:47:53 +11:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-11 16:47:53 +11:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
2019-06-14 17:10:37 +08:00
|
|
|
|
2021-10-17 21:50:17 +08:00
|
|
|
|
|
|
|
|
|
2013-06-01 16:15:16 +09:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-10-17 21:50:17 +08:00
|
|
|
|
2023-10-10 23:19:52 +08:00
|
|
|
|
2023-07-06 16:37:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-10-17 21:50:17 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-07-06 16:37:27 +08:00
|
|
|
|
2021-10-17 21:50:17 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
2019-12-23 10:48:53 +01:00
|
|
|
|
|
|
|
|
|
2019-12-23 10:49:00 +01:00
|
|
|
|
2023-10-10 23:19:53 +08:00
|
|
|
|
2019-12-23 10:48:53 +01:00
|
|
|
|
|
|
|
|
|
2019-06-14 17:10:37 +08:00
|
|
|
|
2023-10-10 23:19:53 +08:00
|
|
|
|
2019-06-14 17:10:37 +08:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:28 +08:00
|
|
|
|
2023-07-06 16:37:27 +08:00
|
|
|
|
2023-10-10 23:19:52 +08:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-11 16:47:53 +11:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-11 16:47:53 +11:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-06-01 16:15:16 +09:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-10-25 09:37:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-11 16:47:53 +11:00
|
|
|
|
2009-12-14 12:49:56 +11:00
|
|
|
|
2014-03-29 10:20:02 -05:00
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:56 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-11 16:47:53 +11:00
|
|
|
|
2009-12-14 12:49:56 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-29 10:20:02 -05:00
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:56 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-11 16:47:53 +11:00
|
|
|
|
2009-12-14 12:49:56 +11:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:52 +08:00
|
|
|
|
|
|
|
|
|
2014-12-15 12:56:59 +11:00
|
|
|
|
2024-08-26 15:44:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:56 +11:00
|
|
|
|
|
|
|
|
|
2014-12-15 12:56:59 +11:00
|
|
|
|
2009-12-14 12:49:56 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-11 16:47:53 +11:00
|
|
|
|
2009-12-14 12:49:56 +11:00
|
|
|
|
2024-08-26 15:44:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:56 +11:00
|
|
|
|
2024-08-26 15:44:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:56 +11:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:56 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-03-08 16:02:37 +11:00
|
|
|
|
2011-10-11 16:47:53 +11:00
|
|
|
|
2010-03-08 16:02:37 +11:00
|
|
|
|
2014-12-15 12:56:59 +11:00
|
|
|
|
2024-08-26 15:44:52 +08:00
|
|
|
|
|
|
|
|
|
2014-12-15 12:56:59 +11:00
|
|
|
|
2024-08-26 15:44:52 +08:00
|
|
|
|
|
|
|
|
|
2014-12-15 12:56:59 +11:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:52 +08:00
|
|
|
|
2014-12-15 12:56:59 +11:00
|
|
|
|
2024-08-26 15:44:52 +08:00
|
|
|
|
2014-12-15 12:56:59 +11:00
|
|
|
|
2010-03-08 16:02:37 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-11 16:47:53 +11:00
|
|
|
|
2010-03-08 16:02:37 +11:00
|
|
|
|
2024-08-26 15:44:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-03-08 16:02:37 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
2012-05-22 13:55:07 +10:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-14 12:49:56 +11:00
|
|
|
|
|
|
|
|
|
2010-03-08 16:02:37 +11:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
2021-05-29 12:30:49 +02:00
|
|
|
|
2009-12-14 12:49:55 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:21 +08:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:51 +08:00
|
|
|
|
2024-08-26 15:44:23 +08:00
|
|
|
|
2024-08-26 15:44:45 +08:00
|
|
|
|
2024-08-26 15:44:24 +08:00
|
|
|
|
2024-08-26 15:44:25 +08:00
|
|
|
|
2024-08-26 15:44:26 +08:00
|
|
|
|
2024-08-26 15:44:31 +08:00
|
|
|
|
2024-08-26 15:44:32 +08:00
|
|
|
|
2024-08-26 15:44:42 +08:00
|
|
|
|
2024-08-26 15:44:43 +08:00
|
|
|
|
2025-01-09 09:51:41 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:50 +08:00
|
|
|
|
2024-08-26 15:44:28 +08:00
|
|
|
|
2024-08-26 15:44:33 +08:00
|
|
|
|
2024-08-26 15:44:34 +08:00
|
|
|
|
2024-08-26 15:44:35 +08:00
|
|
|
|
2024-08-26 15:44:37 +08:00
|
|
|
|
2024-08-26 15:44:39 +08:00
|
|
|
|
2024-08-26 15:44:38 +08:00
|
|
|
|
2024-08-26 15:44:33 +08:00
|
|
|
|
2024-08-26 15:44:28 +08:00
|
|
|
|
2024-08-26 15:44:29 +08:00
|
|
|
|
2024-08-26 15:44:40 +08:00
|
|
|
|
|
|
|
|
|
2024-08-26 15:44:46 +08:00
|
|
|
|
2024-08-26 15:44:47 +08:00
|
|
|
|
2024-08-26 15:44:48 +08:00
|
|
|
|
2024-08-26 15:44:49 +08:00
|
|
|
|
2024-08-26 15:44:21 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|