26
26
#include <linux/task_work.h>
27
27
#include <linux/shmem_fs.h>
28
28
#include <linux/khugepaged.h>
29
+ #include <linux/rcupdate_trace.h>
29
30
30
31
#include <linux/uprobes.h>
31
32
@@ -42,8 +43,6 @@ static struct rb_root uprobes_tree = RB_ROOT;
42
43
static DEFINE_RWLOCK (uprobes_treelock ); /* serialize rbtree access */
43
44
static seqcount_rwlock_t uprobes_seqcount = SEQCNT_RWLOCK_ZERO (uprobes_seqcount , & uprobes_treelock );
44
45
45
- DEFINE_STATIC_SRCU (uprobes_srcu );
46
-
47
46
#define UPROBES_HASH_SZ 13
48
47
/* serialize uprobe->pending_list */
49
48
static struct mutex uprobes_mmap_mutex [UPROBES_HASH_SZ ];
@@ -651,7 +650,7 @@ static void put_uprobe(struct uprobe *uprobe)
651
650
delayed_uprobe_remove (uprobe , NULL );
652
651
mutex_unlock (& delayed_uprobe_lock );
653
652
654
- call_srcu ( & uprobes_srcu , & uprobe -> rcu , uprobe_free_rcu );
653
+ call_rcu_tasks_trace ( & uprobe -> rcu , uprobe_free_rcu );
655
654
}
656
655
657
656
static __always_inline
@@ -706,7 +705,7 @@ static struct uprobe *find_uprobe_rcu(struct inode *inode, loff_t offset)
706
705
struct rb_node * node ;
707
706
unsigned int seq ;
708
707
709
- lockdep_assert (srcu_read_lock_held ( & uprobes_srcu ));
708
+ lockdep_assert (rcu_read_lock_trace_held ( ));
710
709
711
710
do {
712
711
seq = read_seqcount_begin (& uprobes_seqcount );
@@ -934,8 +933,7 @@ static bool filter_chain(struct uprobe *uprobe, struct mm_struct *mm)
934
933
bool ret = false;
935
934
936
935
down_read (& uprobe -> consumer_rwsem );
937
- list_for_each_entry_srcu (uc , & uprobe -> consumers , cons_node ,
938
- srcu_read_lock_held (& uprobes_srcu )) {
936
+ list_for_each_entry_rcu (uc , & uprobe -> consumers , cons_node , rcu_read_lock_trace_held ()) {
939
937
ret = consumer_filter (uc , mm );
940
938
if (ret )
941
939
break ;
@@ -1156,7 +1154,7 @@ void uprobe_unregister_sync(void)
1156
1154
* unlucky enough caller can free consumer's memory and cause
1157
1155
* handler_chain() or handle_uretprobe_chain() to do an use-after-free.
1158
1156
*/
1159
- synchronize_srcu ( & uprobes_srcu );
1157
+ synchronize_rcu_tasks_trace ( );
1160
1158
}
1161
1159
EXPORT_SYMBOL_GPL (uprobe_unregister_sync );
1162
1160
@@ -1240,19 +1238,18 @@ EXPORT_SYMBOL_GPL(uprobe_register);
1240
1238
int uprobe_apply (struct uprobe * uprobe , struct uprobe_consumer * uc , bool add )
1241
1239
{
1242
1240
struct uprobe_consumer * con ;
1243
- int ret = - ENOENT , srcu_idx ;
1241
+ int ret = - ENOENT ;
1244
1242
1245
1243
down_write (& uprobe -> register_rwsem );
1246
1244
1247
- srcu_idx = srcu_read_lock (& uprobes_srcu );
1248
- list_for_each_entry_srcu (con , & uprobe -> consumers , cons_node ,
1249
- srcu_read_lock_held (& uprobes_srcu )) {
1245
+ rcu_read_lock_trace ();
1246
+ list_for_each_entry_rcu (con , & uprobe -> consumers , cons_node , rcu_read_lock_trace_held ()) {
1250
1247
if (con == uc ) {
1251
1248
ret = register_for_each_vma (uprobe , add ? uc : NULL );
1252
1249
break ;
1253
1250
}
1254
1251
}
1255
- srcu_read_unlock ( & uprobes_srcu , srcu_idx );
1252
+ rcu_read_unlock_trace ( );
1256
1253
1257
1254
up_write (& uprobe -> register_rwsem );
1258
1255
@@ -2134,8 +2131,7 @@ static void handler_chain(struct uprobe *uprobe, struct pt_regs *regs)
2134
2131
2135
2132
current -> utask -> auprobe = & uprobe -> arch ;
2136
2133
2137
- list_for_each_entry_srcu (uc , & uprobe -> consumers , cons_node ,
2138
- srcu_read_lock_held (& uprobes_srcu )) {
2134
+ list_for_each_entry_rcu (uc , & uprobe -> consumers , cons_node , rcu_read_lock_trace_held ()) {
2139
2135
int rc = 0 ;
2140
2136
2141
2137
if (uc -> handler ) {
@@ -2173,15 +2169,13 @@ handle_uretprobe_chain(struct return_instance *ri, struct pt_regs *regs)
2173
2169
{
2174
2170
struct uprobe * uprobe = ri -> uprobe ;
2175
2171
struct uprobe_consumer * uc ;
2176
- int srcu_idx ;
2177
2172
2178
- srcu_idx = srcu_read_lock (& uprobes_srcu );
2179
- list_for_each_entry_srcu (uc , & uprobe -> consumers , cons_node ,
2180
- srcu_read_lock_held (& uprobes_srcu )) {
2173
+ rcu_read_lock_trace ();
2174
+ list_for_each_entry_rcu (uc , & uprobe -> consumers , cons_node , rcu_read_lock_trace_held ()) {
2181
2175
if (uc -> ret_handler )
2182
2176
uc -> ret_handler (uc , ri -> func , regs );
2183
2177
}
2184
- srcu_read_unlock ( & uprobes_srcu , srcu_idx );
2178
+ rcu_read_unlock_trace ( );
2185
2179
}
2186
2180
2187
2181
static struct return_instance * find_next_ret_chain (struct return_instance * ri )
@@ -2266,13 +2260,13 @@ static void handle_swbp(struct pt_regs *regs)
2266
2260
{
2267
2261
struct uprobe * uprobe ;
2268
2262
unsigned long bp_vaddr ;
2269
- int is_swbp , srcu_idx ;
2263
+ int is_swbp ;
2270
2264
2271
2265
bp_vaddr = uprobe_get_swbp_addr (regs );
2272
2266
if (bp_vaddr == uprobe_get_trampoline_vaddr ())
2273
2267
return uprobe_handle_trampoline (regs );
2274
2268
2275
- srcu_idx = srcu_read_lock ( & uprobes_srcu );
2269
+ rcu_read_lock_trace ( );
2276
2270
2277
2271
uprobe = find_active_uprobe_rcu (bp_vaddr , & is_swbp );
2278
2272
if (!uprobe ) {
@@ -2330,7 +2324,7 @@ static void handle_swbp(struct pt_regs *regs)
2330
2324
2331
2325
out :
2332
2326
/* arch_uprobe_skip_sstep() succeeded, or restart if can't singlestep */
2333
- srcu_read_unlock ( & uprobes_srcu , srcu_idx );
2327
+ rcu_read_unlock_trace ( );
2334
2328
}
2335
2329
2336
2330
/*
0 commit comments