-
Notifications
You must be signed in to change notification settings - Fork 0
/
probe.c
735 lines (679 loc) · 18.8 KB
/
probe.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
/*
* probe.c
*
* Copyright (C) 2010-2013 Tetsuo Handa <[email protected]>
*
* Functions in this file are doing runtime address resolution based on byte
* code comparison in order to allow LKM-based LSM modules to access built-in
* functions and variables which are not exported to LKMs.
* Since functions in this file are assuming that using identical source code,
* identical kernel config and identical compiler generates identical byte code
* output, functions in this file may not work on some architectures and/or
* environments.
*
* This file is used by AKARI and CaitSith. This file will become unnecessary
* when LKM-based LSM module comes back and TOMOYO 2.x becomes a LKM-based LSM
* module.
*/
#include "probe.h"
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) || LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 3)
/**
* probe_kernel_read - Wrapper for kernel_read().
*
* @file: Pointer to "struct file".
* @offset: Starting position.
* @addr: Buffer.
* @count: Size of @addr.
*
* Returns return value from kernel_read().
*/
static int __init probe_kernel_read(struct file *file, unsigned long offset,
char *addr, unsigned long count)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 8)
/*
* I can't use kernel_read() because seq_read() returns -EPIPE
* if &pos != &file->f_pos .
*/
mm_segment_t old_fs;
unsigned long pos = file->f_pos;
int result;
file->f_pos = offset;
old_fs = get_fs();
set_fs(get_ds());
result = vfs_read(file, (void __user *)addr, count, &file->f_pos);
set_fs(old_fs);
file->f_pos = pos;
return result;
#else
return kernel_read(file, offset, addr, count);
#endif
}
/**
* probe_find_symbol - Find function's address from /proc/kallsyms .
*
* @keyline: Function to find.
*
* Returns address of specified function on success, NULL otherwise.
*/
static void *__init probe_find_symbol(const char *keyline)
{
struct file *file = NULL;
char *buf;
unsigned long entry = 0;
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18)
struct file_system_type *fstype = get_fs_type("proc");
struct vfsmount *mnt = vfs_kern_mount(fstype, 0, "proc", NULL);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 8)
struct file_system_type *fstype = NULL;
struct vfsmount *mnt = do_kern_mount("proc", 0, "proc", NULL);
#else
struct file_system_type *fstype = get_fs_type("proc");
struct vfsmount *mnt = kern_mount(fstype);
#endif
struct dentry *root;
struct dentry *dentry;
/*
* We embed put_filesystem() here because it is not exported.
*/
if (fstype)
module_put(fstype->owner);
if (IS_ERR(mnt))
goto out;
root = dget(mnt->mnt_root);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16)
mutex_lock(&root->d_inode->i_mutex);
dentry = lookup_one_len("kallsyms", root, 8);
mutex_unlock(&root->d_inode->i_mutex);
#else
down(&root->d_inode->i_sem);
dentry = lookup_one_len("kallsyms", root, 8);
up(&root->d_inode->i_sem);
#endif
dput(root);
if (IS_ERR(dentry))
mntput(mnt);
else {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
struct path path = { mnt, dentry };
file = dentry_open(&path, O_RDONLY, current_cred());
#else
file = dentry_open(dentry, mnt, O_RDONLY
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
, current_cred()
#endif
);
#endif
}
}
if (IS_ERR(file) || !file)
goto out;
buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (buf) {
int len;
int offset = 0;
while ((len = probe_kernel_read(file, offset, buf,
PAGE_SIZE - 1)) > 0) {
char *cp;
buf[len] = '\0';
cp = strrchr(buf, '\n');
if (!cp)
break;
*(cp + 1) = '\0';
offset += strlen(buf);
cp = strstr(buf, keyline);
if (!cp)
continue;
*cp = '\0';
while (cp > buf && *(cp - 1) != '\n')
cp--;
entry = simple_strtoul(cp, NULL, 16);
break;
}
kfree(buf);
}
filp_close(file, NULL);
out:
return (void *) entry;
}
#endif
#if defined(CONFIG_SECURITY_COMPOSER_MAX)
/*
* Dummy variable for finding location of
* "struct list_head lsm_hooks[LSM_MAX_HOOKS]".
*/
struct list_head probe_lsm_hooks[LSM_MAX_HOOKS];
/**
* probe_security_bprm_committed_creds - Dummy function which does identical to security_bprm_committed_creds() in security/security.c.
*
* @bprm: Pointer to "struct linux_binprm".
*
* Returns nothing.
*/
void probe_security_bprm_committed_creds(struct linux_binprm *bprm)
{
do {
struct security_operations *sop;
list_for_each_entry(sop,
&probe_lsm_hooks[lsm_bprm_committed_creds],
list[lsm_bprm_committed_creds])
sop->bprm_committed_creds(bprm);
} while (0);
}
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
/*
* Dummy variable for finding address of
* "struct security_operations *security_ops".
*/
static struct security_operations *probe_dummy_security_ops;
/**
* probe_security_file_alloc - Dummy function which does identical to security_file_alloc() in security/security.c.
*
* @file: Pointer to "struct file".
*
* Returns return value from security_file_alloc().
*/
static int probe_security_file_alloc(struct file *file)
{
return probe_dummy_security_ops->file_alloc_security(file);
}
#if defined(CONFIG_ARM)
/**
* probe_security_ops_on_arm - Find security_ops on ARM.
*
* @base: Address of security_file_alloc().
*
* Returns address of security_ops on success, NULL otherwise.
*/
static void * __init probe_security_ops_on_arm(unsigned int *base)
{
static unsigned int *ip4ret;
int i;
const unsigned long addr = (unsigned long) &probe_dummy_security_ops;
unsigned int *ip = (unsigned int *) probe_security_file_alloc;
for (i = 0; i < 32; ip++, i++) {
if (*(ip + 2 + ((*ip & 0xFFF) >> 2)) != addr)
continue;
ip = base + i;
ip4ret = (unsigned int *) (*(ip + 2 + ((*ip & 0xFFF) >> 2)));
return &ip4ret;
}
ip = (unsigned int *) probe_security_file_alloc;
for (i = 0; i < 32; ip++, i++) {
/*
* Find
* ldr r3, [pc, #offset1]
* ldr r3, [r3, #offset2]
* sequence.
*/
if ((*ip & 0xFFFFF000) != 0xE59F3000 ||
(*(ip + 1) & 0xFFFFF000) != 0xE5933000)
continue;
ip4ret = (unsigned int *) (*(ip + 2 + ((*ip & 0xFFF) >> 2)));
ip4ret += (*(ip + 1) & 0xFFF) >> 2;
if ((unsigned long) ip4ret != addr)
continue;
ip = base + i;
ip4ret = (unsigned int *) (*(ip + 2 + ((*ip & 0xFFF) >> 2)));
ip4ret += (*(ip + 1) & 0xFFF) >> 2;
return &ip4ret;
}
return NULL;
}
#endif
#endif
#if defined(CONFIG_ARM) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
/**
* probe_find_vfsmount_lock_on_arm - Find vfsmount_lock spinlock on ARM.
*
* @ip: Address of dummy function's entry point.
* @addr: Address of the variable which is used within @function.
* @base: Address of function's entry point.
*
* Returns address of vfsmount_lock on success, NULL otherwise.
*/
static void * __init probe_find_vfsmount_lock_on_arm(unsigned int *ip,
unsigned long addr,
unsigned int *base)
{
int i;
for (i = 0; i < 32; ip++, i++) {
static unsigned int *ip4ret;
if (*(ip + 2 + ((*ip & 0xFFF) >> 2)) != addr)
continue;
ip = base + i;
ip4ret = (unsigned int *) (*(ip + 2 + ((*ip & 0xFFF) >> 2)));
return &ip4ret;
}
return NULL;
}
#endif
/**
* probe_find_variable - Find variable's address using dummy.
*
* @function: Pointer to dummy function's entry point.
* @addr: Address of the variable which is used within @function.
* @symbol: Name of symbol to resolve.
*
* This trick depends on below assumptions.
*
* (1) @addr is found within 128 bytes from @function, even if additional
* code (e.g. debug symbols) is added.
* (2) It is safe to read 128 bytes from @function.
* (3) @addr != Byte code except @addr.
*/
static void * __init probe_find_variable(void *function, unsigned long addr,
const char *symbol)
{
int i;
u8 *base;
u8 *cp = function;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) || LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 3)
if (*symbol == ' ')
base = probe_find_symbol(symbol);
else
#endif
base = __symbol_get(symbol);
if (!base)
return NULL;
#if defined(CONFIG_ARM) && LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) && !defined(CONFIG_SECURITY_COMPOSER_MAX)
if (function == probe_security_file_alloc)
return probe_security_ops_on_arm((unsigned int *) base);
#endif
#if defined(CONFIG_ARM) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
return probe_find_vfsmount_lock_on_arm(function, addr,
(unsigned int *) base);
#endif
/* First, assume absolute adressing mode is used. */
for (i = 0; i < 128; i++) {
if (*(unsigned long *) cp == addr)
return base + i;
cp++;
}
/* Next, assume PC-relative addressing mode is used. */
#if defined(CONFIG_S390)
cp = function;
for (i = 0; i < 128; i++) {
if ((unsigned long) (cp + (*(int *) cp) * 2 - 2) == addr) {
static void *cp4ret;
cp = base + i;
cp += (*(int *) cp) * 2 - 2;
cp4ret = cp;
return &cp4ret;
}
cp++;
}
#endif
cp = function;
for (i = 0; i < 128; i++) {
if ((unsigned long) (cp + sizeof(int) + *(int *) cp) == addr) {
static void *cp4ret;
cp = base + i;
cp += sizeof(int) + *(int *) cp;
cp4ret = cp;
return &cp4ret;
}
cp++;
}
cp = function;
for (i = 0; i < 128; i++) {
if ((unsigned long) (long) (*(int *) cp) == addr) {
static void *cp4ret;
cp = base + i;
cp = (void *) (long) (*(int *) cp);
cp4ret = cp;
return &cp4ret;
}
cp++;
}
return NULL;
}
#if defined(CONFIG_SECURITY_COMPOSER_MAX)
/**
* probe_lsm_hooks_list - Find address of "struct list_head lsm_hooks[LSM_MAX_HOOKS]".
*
* Returns pointer to "struct security_operations" on success, NULL otherwise.
*/
struct list_head * __init probe_lsm_hooks_list(void)
{
unsigned int offset = 0;
void *cp;
/* Guess "struct list_head lsm_hooks[LSM_MAX_HOOKS];". */
/* Try without offset. GCC 4.x seems to use this one. */
cp = probe_find_variable(probe_security_bprm_committed_creds,
(unsigned long) probe_lsm_hooks,
" security_bprm_committed_creds\n");
if (!cp) {
/* Retry with offset. GCC 3.x seems to use this one. */
offset = offsetof(struct security_operations,
list[lsm_bprm_committed_creds]);
cp = probe_find_variable(probe_security_bprm_committed_creds,
((unsigned long) probe_lsm_hooks)
+ offset,
" security_bprm_committed_creds\n");
}
if (!cp) {
printk(KERN_ERR
"Can't resolve security_bprm_committed_creds().\n");
goto out;
}
/* This should be "struct list_head lsm_hooks[LSM_MAX_HOOKS];". */
cp = (struct list_head *) (*(unsigned long *) cp);
if (!cp) {
printk(KERN_ERR "Can't resolve lsm_hooks array.\n");
goto out;
}
/* Adjust if offset is used. */
cp -= offset;
printk(KERN_INFO "lsm_hooks=%p\n", cp);
return cp;
out:
return NULL;
}
#else
/**
* probe_security_ops - Find address of "struct security_operations *security_ops".
*
* Returns pointer to "struct security_operations" on success, NULL otherwise.
*/
struct security_operations * __init probe_security_ops(void)
{
struct security_operations **ptr;
struct security_operations *ops;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
void *cp;
/* Guess "struct security_operations *security_ops;". */
cp = probe_find_variable(probe_security_file_alloc, (unsigned long)
&probe_dummy_security_ops,
" security_file_alloc\n");
if (!cp) {
printk(KERN_ERR "Can't resolve security_file_alloc().\n");
return NULL;
}
/* This should be "struct security_operations *security_ops;". */
ptr = *(struct security_operations ***) cp;
#else
/* This is "struct security_operations *security_ops;". */
ptr = (struct security_operations **) __symbol_get("security_ops");
#endif
if (!ptr) {
printk(KERN_ERR "Can't resolve security_ops structure.\n");
return NULL;
}
printk(KERN_INFO "security_ops=%p\n", ptr);
ops = *ptr;
if (!ops) {
printk(KERN_ERR "No security_operations registered.\n");
return NULL;
}
return ops;
}
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
/**
* probe_find_task_by_vpid - Find address of find_task_by_vpid().
*
* Returns address of find_task_by_vpid() on success, NULL otherwise.
*/
void * __init probe_find_task_by_vpid(void)
{
void *ptr;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)
ptr = probe_find_symbol(" find_task_by_vpid\n");
#else
ptr = __symbol_get("find_task_by_vpid");
#endif
if (!ptr) {
printk(KERN_ERR "Can't resolve find_task_by_vpid().\n");
return NULL;
}
printk(KERN_INFO "find_task_by_vpid=%p\n", ptr);
return ptr;
}
/**
* probe_find_task_by_pid_ns - Find address of find_task_by_pid().
*
* Returns address of find_task_by_pid_ns() on success, NULL otherwise.
*/
void * __init probe_find_task_by_pid_ns(void)
{
void *ptr;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)
ptr = probe_find_symbol(" find_task_by_pid_ns\n");
#else
ptr = __symbol_get("find_task_by_pid_ns");
#endif
if (!ptr) {
printk(KERN_ERR "Can't resolve find_task_by_pid_ns().\n");
return NULL;
}
printk(KERN_INFO "find_task_by_pid_ns=%p\n", ptr);
return ptr;
}
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 3)
/* Dummy variable for finding address of "spinlock_t vfsmount_lock". */
static spinlock_t probe_dummy_vfsmount_lock __cacheline_aligned_in_smp =
SPIN_LOCK_UNLOCKED;
static struct list_head *probe_mount_hashtable;
static int probe_hash_mask, probe_hash_bits;
/**
* hash - Copy of hash() in fs/namespace.c.
*
* @mnt: Pointer to "struct vfsmount".
* @dentry: Pointer to "struct dentry".
*
* Returns hash value.
*/
static inline unsigned long hash(struct vfsmount *mnt, struct dentry *dentry)
{
unsigned long tmp = ((unsigned long) mnt / L1_CACHE_BYTES);
tmp += ((unsigned long) dentry / L1_CACHE_BYTES);
tmp = tmp + (tmp >> probe_hash_bits);
return tmp & probe_hash_mask;
}
/**
* probe_lookup_mnt - Dummy function which does identical to lookup_mnt() in fs/namespace.c.
*
* @mnt: Pointer to "struct vfsmount".
* @dentry: Pointer to "struct dentry".
*
* Returns pointer to "struct vfsmount".
*/
static struct vfsmount *probe_lookup_mnt(struct vfsmount *mnt,
struct dentry *dentry)
{
struct list_head *head = probe_mount_hashtable + hash(mnt, dentry);
struct list_head *tmp = head;
struct vfsmount *p, *found = NULL;
spin_lock(&probe_dummy_vfsmount_lock);
for (;;) {
tmp = tmp->next;
p = NULL;
if (tmp == head)
break;
p = list_entry(tmp, struct vfsmount, mnt_hash);
if (p->mnt_parent == mnt && p->mnt_mountpoint == dentry) {
found = mntget(p);
break;
}
}
spin_unlock(&probe_dummy_vfsmount_lock);
return found;
}
/**
* probe_vfsmount_lock - Find address of "spinlock_t vfsmount_lock".
*
* Returns address of vfsmount_lock on success, NULL otherwise.
*/
void * __init probe_vfsmount_lock(void)
{
void *cp;
spinlock_t *ptr;
/* Guess "spinlock_t vfsmount_lock;". */
cp = probe_find_variable(probe_lookup_mnt, (unsigned long)
&probe_dummy_vfsmount_lock, " lookup_mnt\n");
if (!cp) {
printk(KERN_ERR "Can't resolve lookup_mnt().\n");
return NULL;
}
/* This should be "spinlock_t *vfsmount_lock;". */
ptr = *(spinlock_t **) cp;
if (!ptr) {
printk(KERN_ERR "Can't resolve vfsmount_lock .\n");
return NULL;
}
printk(KERN_INFO "vfsmount_lock=%p\n", ptr);
return ptr;
}
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 15)
/* Dummy variable for finding address of "spinlock_t vfsmount_lock". */
static spinlock_t probe_dummy_vfsmount_lock;
/**
* probe_follow_up - Dummy function which does identical to follow_up() in fs/namei.c.
*
* @mnt: Pointer to "struct vfsmount *".
* @dentry: Pointer to "struct dentry *".
*
* Returns 1 if followed up, 0 otehrwise.
*/
static int probe_follow_up(struct vfsmount **mnt, struct dentry **dentry)
{
struct vfsmount *parent;
struct dentry *mountpoint;
spin_lock(&probe_dummy_vfsmount_lock);
parent = (*mnt)->mnt_parent;
if (parent == *mnt) {
spin_unlock(&probe_dummy_vfsmount_lock);
return 0;
}
mntget(parent);
mountpoint = dget((*mnt)->mnt_mountpoint);
spin_unlock(&probe_dummy_vfsmount_lock);
dput(*dentry);
*dentry = mountpoint;
mntput(*mnt);
*mnt = parent;
return 1;
}
/**
* probe_vfsmount_lock - Find address of "spinlock_t vfsmount_lock".
*
* Returns address of vfsmount_lock on success, NULL otherwise.
*/
void * __init probe_vfsmount_lock(void)
{
void *cp;
spinlock_t *ptr;
/* Guess "spinlock_t vfsmount_lock;". */
cp = probe_find_variable(probe_follow_up, (unsigned long)
&probe_dummy_vfsmount_lock, "follow_up");
if (!cp) {
printk(KERN_ERR "Can't resolve follow_up().\n");
return NULL;
}
/* This should be "spinlock_t *vfsmount_lock;". */
ptr = *(spinlock_t **) cp;
if (!ptr) {
printk(KERN_ERR "Can't resolve vfsmount_lock .\n");
return NULL;
}
printk(KERN_INFO "vfsmount_lock=%p\n", ptr);
return ptr;
}
#else
/* Dummy variable for finding address of "spinlock_t vfsmount_lock". */
static spinlock_t probe_dummy_vfsmount_lock;
/**
* probe_mnt_pin - Dummy function which does identical to mnt_pin() in fs/namespace.c.
*
* @mnt: Pointer to "struct vfsmount".
*
* Returns nothing.
*/
static void probe_mnt_pin(struct vfsmount *mnt)
{
spin_lock(&probe_dummy_vfsmount_lock);
mnt->mnt_pinned++;
spin_unlock(&probe_dummy_vfsmount_lock);
}
/**
* probe_vfsmount_lock - Find address of "spinlock_t vfsmount_lock".
*
* Returns address of vfsmount_lock on success, NULL otherwise.
*/
void * __init probe_vfsmount_lock(void)
{
void *cp;
spinlock_t *ptr;
/* Guess "spinlock_t vfsmount_lock;". */
cp = probe_find_variable(probe_mnt_pin, (unsigned long)
&probe_dummy_vfsmount_lock, "mnt_pin");
if (!cp) {
printk(KERN_ERR "Can't resolve mnt_pin().\n");
return NULL;
}
/* This should be "spinlock_t *vfsmount_lock;". */
ptr = *(spinlock_t **) cp;
if (!ptr) {
printk(KERN_ERR "Can't resolve vfsmount_lock .\n");
return NULL;
}
printk(KERN_INFO "vfsmount_lock=%p\n", ptr);
return ptr;
}
#endif
#else
/*
* Never mark this variable as __initdata , for this variable might be accessed
* by caller of probe_find_vfsmount_lock().
*/
static spinlock_t probe_dummy_vfsmount_lock;
/**
* probe_vfsmount_lock - Find address of "spinlock_t vfsmount_lock".
*
* Returns address of vfsmount_lock.
*/
void * __init probe_vfsmount_lock(void)
{
return &probe_dummy_vfsmount_lock;
}
#endif
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) && LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0)
/**
* probe___d_path - Find address of "__d_path()".
*
* Returns address of __d_path() on success, NULL otherwise.
*/
void * __init probe___d_path(void)
{
void *ptr = probe_find_symbol(" __d_path\n");
if (!ptr) {
printk(KERN_ERR "Can't resolve __d_path().\n");
return NULL;
}
printk(KERN_INFO "__d_path=%p\n", ptr);
return ptr;
}
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)
/**
* probe_d_absolute_path - Find address of "d_absolute_path()".
*
* Returns address of d_absolute_path() on success, NULL otherwise.
*/
void * __init probe_d_absolute_path(void)
{
void *ptr = probe_find_symbol(" d_absolute_path\n");
if (!ptr) {
printk(KERN_ERR "Can't resolve d_absolute_path().\n");
return NULL;
}
printk(KERN_INFO "d_absolute_path=%p\n", ptr);
return ptr;
}
#endif