{"action":"created","comment":{"url":"https://api.github.com/repos/dynup/kpatch/pulls/comments/179860815","pull_request_review_id":110190173,"id":179860815,"diff_hunk":"@@ -890,33 +892,63 @@ static int kpatch_module_notify(struct notifier_block *nb, unsigned long action,\n \tif (!found)\n \t\tgoto out;\n \n-\tret = kpatch_link_object(kpmod, object);\n-\tif (ret)\n-\t\tgoto out;\n+\tif (action == MODULE_STATE_COMING) {\n \n-\tBUG_ON(!object->mod);\n+\t\tret = kpatch_link_object(kpmod, object);\n+\t\tif (ret)\n+\t\t\tgoto coming_out;\n \n-\tpr_notice(\"patching newly loaded module '%s'\\n\", object->name);\n+\t\tBUG_ON(!object->mod);\n \n-\t/* run user-defined pre-patch callback */\n-\tret = pre_patch_callback(object);\n-\tif (ret) {\n-\t\tpr_err(\"pre-patch callback failed!\\n\");\n-\t\tgoto out;\t/* and WARN */\n-\t}\n+\t\tpr_notice(\"patching newly loaded module '%s'\\n\", object->name);\n \n-\t/* add to the global func hash */\n-\tlist_for_each_entry(func, &object->funcs, list)\n-\t\thash_add_rcu(kpatch_func_hash, &func->node, func->old_addr);\n+\t\t/* run user-defined pre-patch callback */\n+\t\tret = pre_patch_callback(object);\n+\t\tif (ret) {\n+\t\t\tpr_err(\"pre-patch callback failed!\\n\");\n+\t\t\tgoto coming_out;\t/* and WARN */\n+\t\t}\n+\n+\t\t/* add to the global func hash */\n+\t\tlist_for_each_entry(func, &object->funcs, list)\n+\t\t\thash_add_rcu(kpatch_func_hash, &func->node,\n+\t\t\t\t     func->old_addr);\n+\n+\t\t/* run user-defined post-patch callback */\n+\t\tpost_patch_callback(object);\n+coming_out:\n+\t\t/* no way to stop the module load on error */\n+\t\tWARN(ret, \"error (%d) patching newly loaded module '%s'\\n\", ret,\n+\t\t     object->name);\n+\n+\t} else if (action == MODULE_STATE_GOING) {\n+\n+\t\t/*\n+\t\t * This case handles the rare instance that a loading\n+\t\t * module has failed to initialize.  We need to invoke\n+\t\t * any unpatch callbacks, remove its functions from\n+\t\t * the kpatch_func_hash and unlink the object.\n+\t\t */\n+\n+\t\t/* run user-defined pre-unpatch callback */\n+\t\tpre_unpatch_callback(object);\n+\n+\t\t/* remove from the global func hash */\n+\t\tlist_for_each_entry(func, &object->funcs, list)\n+\t\t\thash_del_rcu(&func->node);\n+\n+\t\t/* run user-defined pre-unpatch callback */\n+\t\tpost_unpatch_callback(object);\n \n-\t/* run user-defined post-patch callback */\n-\tpost_patch_callback(object);\n+\t\t/*\n+\t\t * can't unlink an object that has been removed from the\n+\t\t * global hash, so just clear its mod pointer.\n+\t\t */\n+\t\tobject->mod = NULL;","path":"kmod/core/core.c","position":109,"original_position":109,"commit_id":"860dd075847672d4b37fd0903cf14021cea58aad","original_commit_id":"860dd075847672d4b37fd0903cf14021cea58aad","user":{"login":"joe-lawrence","id":6106009,"avatar_url":"https://avatars0.githubusercontent.com/u/6106009?v=4","gravatar_id":"","url":"https://api.github.com/users/joe-lawrence","html_url":"https://github.com/joe-lawrence","followers_url":"https://api.github.com/users/joe-lawrence/followers","following_url":"https://api.github.com/users/joe-lawrence/following{/other_user}","gists_url":"https://api.github.com/users/joe-lawrence/gists{/gist_id}","starred_url":"https://api.github.com/users/joe-lawrence/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joe-lawrence/subscriptions","organizations_url":"https://api.github.com/users/joe-lawrence/orgs","repos_url":"https://api.github.com/users/joe-lawrence/repos","events_url":"https://api.github.com/users/joe-lawrence/events{/privacy}","received_events_url":"https://api.github.com/users/joe-lawrence/received_events","type":"User","site_admin":false},"body":"Hmm, if I move this teardown code up into the module coming case (right after it runs the post-patch callback), it all runs w/o incident.  I suspect you're right that something external to kpatch is getting in the way here.  I'm looking through the `load_module()` and `do_init_module()` code now, though nothing is jumping out yet.","created_at":"2018-04-06T19:56:39Z","updated_at":"2018-04-06T19:56:40Z","html_url":"https://github.com/dynup/kpatch/pull/816#discussion_r179860815","pull_request_url":"https://api.github.com/repos/dynup/kpatch/pulls/816","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/dynup/kpatch/pulls/comments/179860815"},"html":{"href":"https://github.com/dynup/kpatch/pull/816#discussion_r179860815"},"pull_request":{"href":"https://api.github.com/repos/dynup/kpatch/pulls/816"}},"in_reply_to_id":179141716},"pull_request":{"url":"https://api.github.com/repos/dynup/kpatch/pulls/816","id":179390738,"html_url":"https://github.com/dynup/kpatch/pull/816","diff_url":"https://github.com/dynup/kpatch/pull/816.diff","patch_url":"https://github.com/dynup/kpatch/pull/816.patch","issue_url":"https://api.github.com/repos/dynup/kpatch/issues/816","number":816,"state":"open","locked":false,"title":"kmod/core: account for failing modules in notifier","user":{"login":"joe-lawrence","id":6106009,"avatar_url":"https://avatars0.githubusercontent.com/u/6106009?v=4","gravatar_id":"","url":"https://api.github.com/users/joe-lawrence","html_url":"https://github.com/joe-lawrence","followers_url":"https://api.github.com/users/joe-lawrence/followers","following_url":"https://api.github.com/users/joe-lawrence/following{/other_user}","gists_url":"https://api.github.com/users/joe-lawrence/gists{/gist_id}","starred_url":"https://api.github.com/users/joe-lawrence/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joe-lawrence/subscriptions","organizations_url":"https://api.github.com/users/joe-lawrence/orgs","repos_url":"https://api.github.com/users/joe-lawrence/repos","events_url":"https://api.github.com/users/joe-lawrence/events{/privacy}","received_events_url":"https://api.github.com/users/joe-lawrence/received_events","type":"User","site_admin":false},"body":"The module notifier currently only handles newly loaded modules in the\r\nMODULE_STATE_COMING state.  If target modules need to be unloaded, the\r\nany kpatch module that patches it must first be disabled, releasing\r\nmodule references held against the target module.  When the kpatch\r\nmodules are disabled, the target module is unpatched and the kpatch\r\ncore's data structures updated accordingly.\r\n\r\nIf a loading module happens to fail its init routine (missing hardware\r\nfor example), that module will not complete loading.  The kpatch core\r\ndoesn't properly account for this \"phantom\" target module, so when the\r\nkpatch patch module is removed, it spews out an ugly warning when\r\nattempting to remove a non-existing ftrace filter on the target module.\r\n\r\nIn the problematic case above, the module handler is notified of the\r\nfailing module in its MODULE_STATE_GOING state.  Add code to the handler\r\nto clear any ftrace filters, call pre and post unpatch callbacks, etc.\r\n\r\nFixes #699.\r\n\r\nSigned-off-by: Joe Lawrence <joe.lawrence@redhat.com>","created_at":"2018-04-04T13:29:36Z","updated_at":"2018-04-06T19:56:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"da79c3e6ae68d010329510e0dd0fa174019991a1","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/dynup/kpatch/pulls/816/commits","review_comments_url":"https://api.github.com/repos/dynup/kpatch/pulls/816/comments","review_comment_url":"https://api.github.com/repos/dynup/kpatch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dynup/kpatch/issues/816/comments","statuses_url":"https://api.github.com/repos/dynup/kpatch/statuses/860dd075847672d4b37fd0903cf14021cea58aad","head":{"label":"joe-lawrence:module-probe-failed","ref":"module-probe-failed","sha":"860dd075847672d4b37fd0903cf14021cea58aad","user":{"login":"joe-lawrence","id":6106009,"avatar_url":"https://avatars0.githubusercontent.com/u/6106009?v=4","gravatar_id":"","url":"https://api.github.com/users/joe-lawrence","html_url":"https://github.com/joe-lawrence","followers_url":"https://api.github.com/users/joe-lawrence/followers","following_url":"https://api.github.com/users/joe-lawrence/following{/other_user}","gists_url":"https://api.github.com/users/joe-lawrence/gists{/gist_id}","starred_url":"https://api.github.com/users/joe-lawrence/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joe-lawrence/subscriptions","organizations_url":"https://api.github.com/users/joe-lawrence/orgs","repos_url":"https://api.github.com/users/joe-lawrence/repos","events_url":"https://api.github.com/users/joe-lawrence/events{/privacy}","received_events_url":"https://api.github.com/users/joe-lawrence/received_events","type":"User","site_admin":false},"repo":{"id":69497657,"name":"kpatch","full_name":"joe-lawrence/kpatch","owner":{"login":"joe-lawrence","id":6106009,"avatar_url":"https://avatars0.githubusercontent.com/u/6106009?v=4","gravatar_id":"","url":"https://api.github.com/users/joe-lawrence","html_url":"https://github.com/joe-lawrence","followers_url":"https://api.github.com/users/joe-lawrence/followers","following_url":"https://api.github.com/users/joe-lawrence/following{/other_user}","gists_url":"https://api.github.com/users/joe-lawrence/gists{/gist_id}","starred_url":"https://api.github.com/users/joe-lawrence/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joe-lawrence/subscriptions","organizations_url":"https://api.github.com/users/joe-lawrence/orgs","repos_url":"https://api.github.com/users/joe-lawrence/repos","events_url":"https://api.github.com/users/joe-lawrence/events{/privacy}","received_events_url":"https://api.github.com/users/joe-lawrence/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/joe-lawrence/kpatch","description":"kpatch - dynamic kernel patching","fork":true,"url":"https://api.github.com/repos/joe-lawrence/kpatch","forks_url":"https://api.github.com/repos/joe-lawrence/kpatch/forks","keys_url":"https://api.github.com/repos/joe-lawrence/kpatch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/joe-lawrence/kpatch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/joe-lawrence/kpatch/teams","hooks_url":"https://api.github.com/repos/joe-lawrence/kpatch/hooks","issue_events_url":"https://api.github.com/repos/joe-lawrence/kpatch/issues/events{/number}","events_url":"https://api.github.com/repos/joe-lawrence/kpatch/events","assignees_url":"https://api.github.com/repos/joe-lawrence/kpatch/assignees{/user}","branches_url":"https://api.github.com/repos/joe-lawrence/kpatch/branches{/branch}","tags_url":"https://api.github.com/repos/joe-lawrence/kpatch/tags","blobs_url":"https://api.github.com/repos/joe-lawrence/kpatch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/joe-lawrence/kpatch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/joe-lawrence/kpatch/git/refs{/sha}","trees_url":"https://api.github.com/repos/joe-lawrence/kpatch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/joe-lawrence/kpatch/statuses/{sha}","languages_url":"https://api.github.com/repos/joe-lawrence/kpatch/languages","stargazers_url":"https://api.github.com/repos/joe-lawrence/kpatch/stargazers","contributors_url":"https://api.github.com/repos/joe-lawrence/kpatch/contributors","subscribers_url":"https://api.github.com/repos/joe-lawrence/kpatch/subscribers","subscription_url":"https://api.github.com/repos/joe-lawrence/kpatch/subscription","commits_url":"https://api.github.com/repos/joe-lawrence/kpatch/commits{/sha}","git_commits_url":"https://api.github.com/repos/joe-lawrence/kpatch/git/commits{/sha}","comments_url":"https://api.github.com/repos/joe-lawrence/kpatch/comments{/number}","issue_comment_url":"https://api.github.com/repos/joe-lawrence/kpatch/issues/comments{/number}","contents_url":"https://api.github.com/repos/joe-lawrence/kpatch/contents/{+path}","compare_url":"https://api.github.com/repos/joe-lawrence/kpatch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/joe-lawrence/kpatch/merges","archive_url":"https://api.github.com/repos/joe-lawrence/kpatch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/joe-lawrence/kpatch/downloads","issues_url":"https://api.github.com/repos/joe-lawrence/kpatch/issues{/number}","pulls_url":"https://api.github.com/repos/joe-lawrence/kpatch/pulls{/number}","milestones_url":"https://api.github.com/repos/joe-lawrence/kpatch/milestones{/number}","notifications_url":"https://api.github.com/repos/joe-lawrence/kpatch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/joe-lawrence/kpatch/labels{/name}","releases_url":"https://api.github.com/repos/joe-lawrence/kpatch/releases{/id}","deployments_url":"https://api.github.com/repos/joe-lawrence/kpatch/deployments","created_at":"2016-09-28T19:40:57Z","updated_at":"2016-09-28T19:40:59Z","pushed_at":"2018-04-03T20:59:25Z","git_url":"git://github.com/joe-lawrence/kpatch.git","ssh_url":"git@github.com:joe-lawrence/kpatch.git","clone_url":"https://github.com/joe-lawrence/kpatch.git","svn_url":"https://github.com/joe-lawrence/kpatch","homepage":null,"size":1642,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dynup:master","ref":"master","sha":"55650e16aff0862957ba809c1496cebc555118ab","user":{"login":"dynup","id":6643594,"avatar_url":"https://avatars3.githubusercontent.com/u/6643594?v=4","gravatar_id":"","url":"https://api.github.com/users/dynup","html_url":"https://github.com/dynup","followers_url":"https://api.github.com/users/dynup/followers","following_url":"https://api.github.com/users/dynup/following{/other_user}","gists_url":"https://api.github.com/users/dynup/gists{/gist_id}","starred_url":"https://api.github.com/users/dynup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dynup/subscriptions","organizations_url":"https://api.github.com/users/dynup/orgs","repos_url":"https://api.github.com/users/dynup/repos","events_url":"https://api.github.com/users/dynup/events{/privacy}","received_events_url":"https://api.github.com/users/dynup/received_events","type":"Organization","site_admin":false},"repo":{"id":16743039,"name":"kpatch","full_name":"dynup/kpatch","owner":{"login":"dynup","id":6643594,"avatar_url":"https://avatars3.githubusercontent.com/u/6643594?v=4","gravatar_id":"","url":"https://api.github.com/users/dynup","html_url":"https://github.com/dynup","followers_url":"https://api.github.com/users/dynup/followers","following_url":"https://api.github.com/users/dynup/following{/other_user}","gists_url":"https://api.github.com/users/dynup/gists{/gist_id}","starred_url":"https://api.github.com/users/dynup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dynup/subscriptions","organizations_url":"https://api.github.com/users/dynup/orgs","repos_url":"https://api.github.com/users/dynup/repos","events_url":"https://api.github.com/users/dynup/events{/privacy}","received_events_url":"https://api.github.com/users/dynup/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dynup/kpatch","description":"kpatch - live kernel patching","fork":false,"url":"https://api.github.com/repos/dynup/kpatch","forks_url":"https://api.github.com/repos/dynup/kpatch/forks","keys_url":"https://api.github.com/repos/dynup/kpatch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dynup/kpatch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dynup/kpatch/teams","hooks_url":"https://api.github.com/repos/dynup/kpatch/hooks","issue_events_url":"https://api.github.com/repos/dynup/kpatch/issues/events{/number}","events_url":"https://api.github.com/repos/dynup/kpatch/events","assignees_url":"https://api.github.com/repos/dynup/kpatch/assignees{/user}","branches_url":"https://api.github.com/repos/dynup/kpatch/branches{/branch}","tags_url":"https://api.github.com/repos/dynup/kpatch/tags","blobs_url":"https://api.github.com/repos/dynup/kpatch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dynup/kpatch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dynup/kpatch/git/refs{/sha}","trees_url":"https://api.github.com/repos/dynup/kpatch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dynup/kpatch/statuses/{sha}","languages_url":"https://api.github.com/repos/dynup/kpatch/languages","stargazers_url":"https://api.github.com/repos/dynup/kpatch/stargazers","contributors_url":"https://api.github.com/repos/dynup/kpatch/contributors","subscribers_url":"https://api.github.com/repos/dynup/kpatch/subscribers","subscription_url":"https://api.github.com/repos/dynup/kpatch/subscription","commits_url":"https://api.github.com/repos/dynup/kpatch/commits{/sha}","git_commits_url":"https://api.github.com/repos/dynup/kpatch/git/commits{/sha}","comments_url":"https://api.github.com/repos/dynup/kpatch/comments{/number}","issue_comment_url":"https://api.github.com/repos/dynup/kpatch/issues/comments{/number}","contents_url":"https://api.github.com/repos/dynup/kpatch/contents/{+path}","compare_url":"https://api.github.com/repos/dynup/kpatch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dynup/kpatch/merges","archive_url":"https://api.github.com/repos/dynup/kpatch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dynup/kpatch/downloads","issues_url":"https://api.github.com/repos/dynup/kpatch/issues{/number}","pulls_url":"https://api.github.com/repos/dynup/kpatch/pulls{/number}","milestones_url":"https://api.github.com/repos/dynup/kpatch/milestones{/number}","notifications_url":"https://api.github.com/repos/dynup/kpatch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dynup/kpatch/labels{/name}","releases_url":"https://api.github.com/repos/dynup/kpatch/releases{/id}","deployments_url":"https://api.github.com/repos/dynup/kpatch/deployments","created_at":"2014-02-11T19:47:52Z","updated_at":"2018-04-06T19:46:58Z","pushed_at":"2018-04-06T15:43:58Z","git_url":"git://github.com/dynup/kpatch.git","ssh_url":"git@github.com:dynup/kpatch.git","clone_url":"https://github.com/dynup/kpatch.git","svn_url":"https://github.com/dynup/kpatch","homepage":"","size":1559,"stargazers_count":611,"watchers_count":611,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":136,"mirror_url":null,"archived":false,"open_issues_count":37,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0"},"forks":136,"open_issues":37,"watchers":611,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dynup/kpatch/pulls/816"},"html":{"href":"https://github.com/dynup/kpatch/pull/816"},"issue":{"href":"https://api.github.com/repos/dynup/kpatch/issues/816"},"comments":{"href":"https://api.github.com/repos/dynup/kpatch/issues/816/comments"},"review_comments":{"href":"https://api.github.com/repos/dynup/kpatch/pulls/816/comments"},"review_comment":{"href":"https://api.github.com/repos/dynup/kpatch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dynup/kpatch/pulls/816/commits"},"statuses":{"href":"https://api.github.com/repos/dynup/kpatch/statuses/860dd075847672d4b37fd0903cf14021cea58aad"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"joe-lawrence"}}