@@ -422,7 +422,7 @@ static bool each_symbol_in_section(const struct symsearch *arr,
422
422
}
423
423
424
424
/* Returns true as soon as fn returns true, otherwise false. */
425
- bool each_symbol_section (bool (* fn )(const struct symsearch * arr ,
425
+ static bool each_symbol_section (bool (* fn )(const struct symsearch * arr ,
426
426
struct module * owner ,
427
427
void * data ),
428
428
void * data )
@@ -484,7 +484,6 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
484
484
}
485
485
return false;
486
486
}
487
- EXPORT_SYMBOL_GPL (each_symbol_section );
488
487
489
488
struct find_symbol_arg {
490
489
/* Input */
@@ -496,6 +495,7 @@ struct find_symbol_arg {
496
495
struct module * owner ;
497
496
const s32 * crc ;
498
497
const struct kernel_symbol * sym ;
498
+ enum mod_license license ;
499
499
};
500
500
501
501
static bool check_exported_symbol (const struct symsearch * syms ,
@@ -505,9 +505,9 @@ static bool check_exported_symbol(const struct symsearch *syms,
505
505
struct find_symbol_arg * fsa = data ;
506
506
507
507
if (!fsa -> gplok ) {
508
- if (syms -> licence == GPL_ONLY )
508
+ if (syms -> license == GPL_ONLY )
509
509
return false;
510
- if (syms -> licence == WILL_BE_GPL_ONLY && fsa -> warn ) {
510
+ if (syms -> license == WILL_BE_GPL_ONLY && fsa -> warn ) {
511
511
pr_warn ("Symbol %s is being used by a non-GPL module, "
512
512
"which will not be allowed in the future\n" ,
513
513
fsa -> name );
@@ -529,6 +529,7 @@ static bool check_exported_symbol(const struct symsearch *syms,
529
529
fsa -> owner = owner ;
530
530
fsa -> crc = symversion (syms -> crcs , symnum );
531
531
fsa -> sym = & syms -> start [symnum ];
532
+ fsa -> license = syms -> license ;
532
533
return true;
533
534
}
534
535
@@ -585,9 +586,10 @@ static bool find_exported_symbol_in_section(const struct symsearch *syms,
585
586
586
587
/* Find an exported symbol and return it, along with, (optional) crc and
587
588
* (optional) module which owns it. Needs preempt disabled or module_mutex. */
588
- const struct kernel_symbol * find_symbol (const char * name ,
589
+ static const struct kernel_symbol * find_symbol (const char * name ,
589
590
struct module * * owner ,
590
591
const s32 * * crc ,
592
+ enum mod_license * license ,
591
593
bool gplok ,
592
594
bool warn )
593
595
{
@@ -602,13 +604,14 @@ const struct kernel_symbol *find_symbol(const char *name,
602
604
* owner = fsa .owner ;
603
605
if (crc )
604
606
* crc = fsa .crc ;
607
+ if (license )
608
+ * license = fsa .license ;
605
609
return fsa .sym ;
606
610
}
607
611
608
612
pr_debug ("Failed to find symbol %s\n" , name );
609
613
return NULL ;
610
614
}
611
- EXPORT_SYMBOL_GPL (find_symbol );
612
615
613
616
/*
614
617
* Search for module by name: must hold module_mutex (or preempt disabled
@@ -869,7 +872,7 @@ static int add_module_usage(struct module *a, struct module *b)
869
872
}
870
873
871
874
/* Module a uses b: caller needs module_mutex() */
872
- int ref_module (struct module * a , struct module * b )
875
+ static int ref_module (struct module * a , struct module * b )
873
876
{
874
877
int err ;
875
878
@@ -888,7 +891,6 @@ int ref_module(struct module *a, struct module *b)
888
891
}
889
892
return 0 ;
890
893
}
891
- EXPORT_SYMBOL_GPL (ref_module );
892
894
893
895
/* Clear the unload stuff of the module. */
894
896
static void module_unload_free (struct module * mod )
@@ -1077,7 +1079,7 @@ void __symbol_put(const char *symbol)
1077
1079
struct module * owner ;
1078
1080
1079
1081
preempt_disable ();
1080
- if (!find_symbol (symbol , & owner , NULL , true, false))
1082
+ if (!find_symbol (symbol , & owner , NULL , NULL , true, false))
1081
1083
BUG ();
1082
1084
module_put (owner );
1083
1085
preempt_enable ();
@@ -1169,11 +1171,10 @@ static inline void module_unload_free(struct module *mod)
1169
1171
{
1170
1172
}
1171
1173
1172
- int ref_module (struct module * a , struct module * b )
1174
+ static int ref_module (struct module * a , struct module * b )
1173
1175
{
1174
1176
return strong_try_module_get (b );
1175
1177
}
1176
- EXPORT_SYMBOL_GPL (ref_module );
1177
1178
1178
1179
static inline int module_unload_init (struct module * mod )
1179
1180
{
@@ -1356,7 +1357,7 @@ static inline int check_modstruct_version(const struct load_info *info,
1356
1357
* locking is necessary -- use preempt_disable() to placate lockdep.
1357
1358
*/
1358
1359
preempt_disable ();
1359
- if (!find_symbol ("module_layout" , NULL , & crc , true, false)) {
1360
+ if (!find_symbol ("module_layout" , NULL , & crc , NULL , true, false)) {
1360
1361
preempt_enable ();
1361
1362
BUG ();
1362
1363
}
@@ -1430,6 +1431,24 @@ static int verify_namespace_is_imported(const struct load_info *info,
1430
1431
return 0 ;
1431
1432
}
1432
1433
1434
+ static bool inherit_taint (struct module * mod , struct module * owner )
1435
+ {
1436
+ if (!owner || !test_bit (TAINT_PROPRIETARY_MODULE , & owner -> taints ))
1437
+ return true;
1438
+
1439
+ if (mod -> using_gplonly_symbols ) {
1440
+ pr_err ("%s: module using GPL-only symbols uses symbols from proprietary module %s.\n" ,
1441
+ mod -> name , owner -> name );
1442
+ return false;
1443
+ }
1444
+
1445
+ if (!test_bit (TAINT_PROPRIETARY_MODULE , & mod -> taints )) {
1446
+ pr_warn ("%s: module uses symbols from proprietary module %s, inheriting taint.\n" ,
1447
+ mod -> name , owner -> name );
1448
+ set_bit (TAINT_PROPRIETARY_MODULE , & mod -> taints );
1449
+ }
1450
+ return true;
1451
+ }
1433
1452
1434
1453
/* Resolve a symbol for this module. I.e. if we find one, record usage. */
1435
1454
static const struct kernel_symbol * resolve_symbol (struct module * mod ,
@@ -1440,6 +1459,7 @@ static const struct kernel_symbol *resolve_symbol(struct module *mod,
1440
1459
struct module * owner ;
1441
1460
const struct kernel_symbol * sym ;
1442
1461
const s32 * crc ;
1462
+ enum mod_license license ;
1443
1463
int err ;
1444
1464
1445
1465
/*
@@ -1449,11 +1469,19 @@ static const struct kernel_symbol *resolve_symbol(struct module *mod,
1449
1469
*/
1450
1470
sched_annotate_sleep ();
1451
1471
mutex_lock (& module_mutex );
1452
- sym = find_symbol (name , & owner , & crc ,
1472
+ sym = find_symbol (name , & owner , & crc , & license ,
1453
1473
!(mod -> taints & (1 << TAINT_PROPRIETARY_MODULE )), true);
1454
1474
if (!sym )
1455
1475
goto unlock ;
1456
1476
1477
+ if (license == GPL_ONLY )
1478
+ mod -> using_gplonly_symbols = true;
1479
+
1480
+ if (!inherit_taint (mod , owner )) {
1481
+ sym = NULL ;
1482
+ goto getname ;
1483
+ }
1484
+
1457
1485
if (!check_version (info , name , mod , crc )) {
1458
1486
sym = ERR_PTR (- EINVAL );
1459
1487
goto getname ;
@@ -2236,7 +2264,7 @@ void *__symbol_get(const char *symbol)
2236
2264
const struct kernel_symbol * sym ;
2237
2265
2238
2266
preempt_disable ();
2239
- sym = find_symbol (symbol , & owner , NULL , true, true);
2267
+ sym = find_symbol (symbol , & owner , NULL , NULL , true, true);
2240
2268
if (sym && strong_try_module_get (owner ))
2241
2269
sym = NULL ;
2242
2270
preempt_enable ();
@@ -2272,7 +2300,7 @@ static int verify_exported_symbols(struct module *mod)
2272
2300
for (i = 0 ; i < ARRAY_SIZE (arr ); i ++ ) {
2273
2301
for (s = arr [i ].sym ; s < arr [i ].sym + arr [i ].num ; s ++ ) {
2274
2302
if (find_symbol (kernel_symbol_name (s ), & owner , NULL ,
2275
- true, false)) {
2303
+ NULL , true, false)) {
2276
2304
pr_err ("%s: exports duplicate symbol %s"
2277
2305
" (owned by %s)\n" ,
2278
2306
mod -> name , kernel_symbol_name (s ),
@@ -4489,7 +4517,6 @@ struct module *__module_address(unsigned long addr)
4489
4517
}
4490
4518
return mod ;
4491
4519
}
4492
- EXPORT_SYMBOL_GPL (__module_address );
4493
4520
4494
4521
/*
4495
4522
* is_module_text_address - is this address inside module code?
@@ -4528,7 +4555,6 @@ struct module *__module_text_address(unsigned long addr)
4528
4555
}
4529
4556
return mod ;
4530
4557
}
4531
- EXPORT_SYMBOL_GPL (__module_text_address );
4532
4558
4533
4559
/* Don't grab lock, we're oopsing. */
4534
4560
void print_modules (void )
0 commit comments