Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\module.c Create Date:2022-07-28 10:59:22
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Allocate and load the module: note that size of section 0 is alwayszero, and we rely on this for optional sections.

Proto:static int load_module(struct load_info *info, const char __user *uargs, int flags)

Type:int

Parameter:

TypeParameterName
struct load_info *info
const char __user *uargs
intflags
3789  err = 0
3792  err = Sanity checks against invalid binaries, wrong arch, weird elf version.
3793  If err Then Go to free_copy
3796  err = Set up our basic convenience variables (pointers to section headers,* search for module section index etc), and do some basic section* verification.* Set info->mod to the temporary copy of the module in info->hdr. The final one
3797  If err Then Go to free_copy
3800  If blacklisted(name) Then
3801  err = -EPERM
3802  Go to free_copy
3805  err = module_sig_check(info, flags)
3806  If err Then Go to free_copy
3809  err = rewrite_section_headers(info, flags)
3810  If err Then Go to free_copy
3814  If Not check_modstruct_version(info, pointer to module in temporary copy, freed at end of load_module() ) Then
3815  err = -ENOEXEC
3816  Go to free_copy
3820  mod = layout_and_allocate(info, flags)
3821  If IS_ERR(mod) Then
3822  err = PTR_ERR(mod)
3823  Go to free_copy
3826  audit_log_kern_module( Unique handle for this module )
3829  err = We try to place it in the list now to make sure it's unique before* we dedicate too many resources. In particular, temporary percpu* memory exhaustion.
3830  If err Then Go to free_module
3844  err = percpu_modalloc(mod, info)
3845  If err Then Go to unlink_mod
3849  err = module_unload_init(mod)
3850  If err Then Go to unlink_mod
3853  init_param_lock(mod)
3857  err = find_module_sections(mod, info)
3858  If err Then Go to free_unload
3861  err = check_module_license_and_versions(mod)
3862  If err Then Go to free_unload
3866  setup_modinfo(mod, info)
3869  err = Change all symbols so that st_value encodes the pointer directly.
3870  If err < 0 Then Go to free_modinfo
3873  err = apply_relocations(mod, info)
3874  If err < 0 Then Go to free_modinfo
3877  err = post_relocation(mod, info)
3878  If err < 0 Then Go to free_modinfo
3881  flush_module_icache(mod)
3884  The command line arguments (may be mangled). People like keeping pointers to this stuff = We don't want strings.h stuff being used by user stuff by accident
3885  If IS_ERR( The command line arguments (may be mangled). People like keeping pointers to this stuff ) Then
3886  err = PTR_ERR( The command line arguments (may be mangled). People like keeping pointers to this stuff )
3887  Go to free_arch_cleanup
3890  dynamic_debug_setup(mod, debug, num_debug)
3893  ftrace_module_init(mod)
3896  err = complete_formation(mod, info)
3897  If err Then Go to ddebug_cleanup
3900  err = prepare_coming_module(mod)
3901  If err Then Go to bug_cleanup
3905  after_dashes = Args looks like "foo=bar,bar2 baz=fuz wiz".
3908  If IS_ERR(after_dashes) Then
3909  err = PTR_ERR(after_dashes)
3910  Go to coming_cleanup
3911  Else if after_dashes Then
3912  pr_warn("%s: parameters '%s' after `--' ignored\n", Unique handle for this module , after_dashes)
3917  err = /sys/module/foo/sections stuff* J. Corbet
3918  If err < 0 Then Go to coming_cleanup
3921  If is_livepatch_module(mod) Then
3922  err = Persist Elf information about a module. Copy the Elf header,* section header table, section string table, and symtab section* index from info to mod->klp_info.
3923  If err < 0 Then Go to sysfs_cleanup
3928  free_copy(info)
3931  trace_module_load(mod)
3933  Return This is where the real work happens.* Keep it uninlined to provide a reliable breakpoint target, e.g. for the gdb* helper command 'lx-symbols'.
3935  sysfs_cleanup :
3936  mod_sysfs_teardown(mod)
3937  coming_cleanup :
3938  state = Going away.
3939  destroy_params(kp, num_kp)
3940  blocking_notifier_call_chain( & module_notify_list, Going away. , mod)
3942  klp_module_going(mod)
3943  bug_cleanup :
3945  mutex_lock( & Mutex protects:* 1) List of modules (also safely readable with preempt_disable),* 2) module_use links,* 3) module_addr_min/module_addr_max.* (delete and add uses RCU list operations). )
3946  module_bug_cleanup(mod)
3947  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
3949  ddebug_cleanup :
3950  ftrace_release_mod(mod)
3951  dynamic_debug_remove(mod, debug)
3952  Wait for a grace period to elapse. But it is illegal to invoke* synchronize_rcu() from within an RCU read-side critical section.* Therefore, any legal call to synchronize_rcu() is a quiescent
3953  kfree( The command line arguments (may be mangled). People like keeping pointers to this stuff )
3954  free_arch_cleanup :
3955  module_arch_cleanup(mod)
3956  free_modinfo :
3957  free_modinfo(mod)
3958  free_unload :
3959  module_unload_free(mod)
3960  unlink_mod :
3961  mutex_lock( & Mutex protects:* 1) List of modules (also safely readable with preempt_disable),* 2) module_use links,* 3) module_addr_min/module_addr_max.* (delete and add uses RCU list operations). )
3963  list_del_rcu - deletes entry from list without re-initialization*@entry: the element to delete from the list
3964  mod_tree_remove(mod)
3965  wake_up_all( & Waiting for a module to finish initializing? )
3967  Wait for a grace period to elapse. But it is illegal to invoke* synchronize_rcu() from within an RCU read-side critical section.* Therefore, any legal call to synchronize_rcu() is a quiescent
3968  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
3969  free_module :
3971  lockdep_free_key_range( The actual code + data. , Total size. )
3973  mod is no longer valid after this!
3974  free_copy :
3975  free_copy(info)
3976  Return err
Caller
NameDescribe
SYSCALL_DEFINE3
SYSCALL_DEFINE3