Pull misc fixes from Andrew Morton: "20 hotfixes. 17 are for MM. 12 are cc:stable and the remaining 8 address post-7.1 issues or aren't considered suitable for backporting. Two patches from SJ addresses a couple of quite old DAMON issues. And two patches from Yichong Chen fixes tools/virtio build issues. The remaining patches are singletons" * tag 'mm-hotfixes-stable-2026-07-06-17-49' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: tools/include: include stdint.h for SIZE_MAX in overflow.h tools/virtio: add missing compat definitions for vhost_net_test mm: do file ownership checks with the proper mount idmap samples/damon/mtier: fail early if address range parameters are invalid mm: a second pagecache maintainer mm/damon: add a kernel-doc comment for damon_ctx->rnd_state mm/damon: add a kernel-doc comment for damon_ctx->probes mailmap: add entries for Radu Rendec selftests/mm: hmm-tests: include linux/mman.h to access MADV_COLLAPSE selftests/mm: pagemap_ioctl: use the correct page size for transact_test() fs/proc: fix KPF_KSM reported for all anonymous pages mm: page_ext: add count limit to page_ext_iter_next to prevent invalid PFN access mm/damon/ops-common: handle extreme intervals in damon_hot_score() MAINTAINERS: add Lance as an rmap reviewer mm/compaction: handle free_pages_prepare() properly in compaction_free() mm/damon/sysfs-schemes: put stats for scheme_add_dirs() internal error mm/damon/sysfs-schemes: fix dir put orders in access_pattern_add_dirs() mm: shrinker: fix NULL pointer dereference in debugfs mm: shrinker: fix shrinker_info teardown race with expansion selftests/mm: fix ksft_process_madv.sh test category
Showing the changes to include/linux (3 of 25 files). Show all
Unified · Split
| @@ -843,11 +843,13 @@ struct damon_attrs { · 842 unmodified lines | ||
| 843 | 843 | * including damon_call() and damos_walk(). |
| 844 | 844 | * |
| 845 | 845 | * @ops: Set of monitoring operations for given use cases. |
| 846 | + * @probes: Head of probes (&damon_probe) list. | |
| 846 | 847 | * @addr_unit: Scale factor for core to ops address conversion. |
| 847 | 848 | * @min_region_sz: Minimum region size. |
| 848 | 849 | * @pause: Pause kdamond main loop. |
| 849 | 850 | * @adaptive_targets: Head of monitoring targets (&damon_target) list. |
| 850 | 851 | * @schemes: Head of schemes (&damos) list. |
| 852 | + * @rnd_state: Per-ctx PRNG state for damon_rand(). | |
| 851 | 853 | */ |
| 852 | 854 | struct damon_ctx { |
| 853 | 855 | struct damon_attrs attrs; |
| @@ -905,7 +907,6 @@ struct damon_ctx { · 51 unmodified lines | ||
| 905 | 907 | struct list_head adaptive_targets; |
| 906 | 908 | struct list_head schemes; |
| 907 | 909 | |
| 908 | − /* Per-ctx PRNG state for damon_rand(); kdamond is the sole consumer. */ | |
| 909 | 910 | struct rnd_state rnd_state; |
| 910 | 911 | }; |
| 911 | 912 | |
| @@ -1065,9 +1066,13 @@ static inline bool damon_target_has_pid(const struct damon_ctx *ctx) · 153 unmodified lines | ||
| 1065 | 1066 | |
| 1066 | 1067 | static inline unsigned int damon_max_nr_accesses(const struct damon_attrs *attrs) |
| 1067 | 1068 | { |
| 1068 | − /* {aggr,sample}_interval are unsigned long, hence could overflow */ | |
| 1069 | − return min(attrs->aggr_interval / attrs->sample_interval, | |
| 1069 | + unsigned long sample_interval; | |
| 1070 | + unsigned long max_nr_accesses; | |
| 1071 | + | |
| 1072 | + sample_interval = attrs->sample_interval ? : 1; | |
| 1073 | + max_nr_accesses = min(attrs->aggr_interval / sample_interval, | |
| 1070 | 1074 | (unsigned long)UINT_MAX); |
| 1075 | + return max_nr_accesses ? : 1; | |
| 1071 | 1076 | } |
| 1072 | 1077 | |
| 1073 | 1078 | |
| @@ -2444,6 +2444,11 @@ static inline struct mnt_idmap *file_mnt_idmap(const struct file *file) · 2443 unmodified lines | ||
| 2444 | 2444 | return mnt_idmap(file->f_path.mnt); |
| 2445 | 2445 | } |
| 2446 | 2446 | |
| 2447 | +static inline bool file_owner_or_capable(const struct file *file) | |
| 2448 | +{ | |
| 2449 | + return inode_owner_or_capable(file_mnt_idmap(file), file_inode(file)); | |
| 2450 | +} | |
| 2451 | + | |
| 2447 | 2452 | /** |
| 2448 | 2453 | * is_idmapped_mnt - check whether a mount is mapped |
| 2449 | 2454 | * @mnt: the mount to check |
| @@ -120,14 +120,18 @@ struct page_ext_iter { · 119 unmodified lines | ||
| 120 | 120 | * page_ext_iter_begin() - Prepare for iterating through page extensions. |
| 121 | 121 | * @iter: page extension iterator. |
| 122 | 122 | * @pfn: PFN of the page we're interested in. |
| 123 | + * @count: maximum number of page extensions to return. | |
| 123 | 124 | * |
| 124 | 125 | * Must be called with RCU read lock taken. |
| 125 | 126 | * |
| 126 | 127 | * Return: NULL if no page_ext exists for this page. |
| 127 | 128 | */ |
| 128 | 129 | static inline struct page_ext *page_ext_iter_begin(struct page_ext_iter *iter, |
| 129 | − unsigned long pfn) | |
| 130 | + unsigned long pfn, unsigned long count) | |
| 130 | 131 | { |
| 132 | + if (!count) | |
| 133 | + return NULL; | |
| 134 | + | |
| 131 | 135 | iter->index = 0; |
| 132 | 136 | iter->start_pfn = pfn; |
| 133 | 137 | iter->page_ext = page_ext_lookup(pfn); |
| @@ -138,19 +142,22 @@ static inline struct page_ext *page_ext_iter_begin(struct page_ext_iter *iter, · 4 unmodified lines | ||
| 138 | 142 | /** |
| 139 | 143 | * page_ext_iter_next() - Get next page extension |
| 140 | 144 | * @iter: page extension iterator. |
| 145 | + * @count: maximum number of page extensions to return. | |
| 141 | 146 | * |
| 142 | 147 | * Must be called with RCU read lock taken. |
| 143 | 148 | * |
| 144 | 149 | * Return: NULL if no next page_ext exists. |
| 145 | 150 | */ |
| 146 | −static inline struct page_ext *page_ext_iter_next(struct page_ext_iter *iter) | |
| 151 | +static inline struct page_ext *page_ext_iter_next(struct page_ext_iter *iter, | |
| 152 | + unsigned long count) | |
| 147 | 153 | { |
| 148 | 154 | unsigned long pfn; |
| 149 | 155 | |
| 150 | 156 | if (WARN_ON_ONCE(!iter->page_ext)) |
| 151 | 157 | return NULL; |
| 152 | 158 | |
| 153 | − iter->index++; | |
| 159 | + if (++iter->index >= count) | |
| 160 | + return NULL; | |
| 154 | 161 | pfn = iter->start_pfn + iter->index; |
| 155 | 162 | |
| 156 | 163 | if (page_ext_iter_next_fast_possible(pfn)) |
| @@ -183,9 +190,9 @@ static inline struct page_ext *page_ext_iter_get(const struct page_ext_iter *ite · 26 unmodified lines | ||
| 183 | 190 | * IMPORTANT: must be called with RCU read lock taken. |
| 184 | 191 | */ |
| 185 | 192 | #define for_each_page_ext(__page, __pgcount, __page_ext, __iter) \ |
| 186 | − for (__page_ext = page_ext_iter_begin(&__iter, page_to_pfn(__page));\ | |
| 187 | − __page_ext && __iter.index < __pgcount; \ | |
| 188 | − __page_ext = page_ext_iter_next(&__iter)) | |
| 193 | + for (__page_ext = page_ext_iter_begin(&__iter, page_to_pfn(__page), __pgcount); \ | |
| 194 | + __page_ext; \ | |
| 195 | + __page_ext = page_ext_iter_next(&__iter, __pgcount)) | |
| 189 | 196 | |
| 190 | 197 | #else /* !CONFIG_PAGE_EXTENSION */ |
| 191 | 198 | struct page_ext; |