File livepatch_main.c of Package kernel-livepatch-SLE15-SP1_Update_0.14571
/*
* livepatch_main.c - kernel live patch main infrastructure
*
* Copyright (c) 2014 SUSE
* Author: Miroslav Benes <mbenes@suse.cz>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <linux/livepatch.h>
#include <linux/module.h>
#include <linux/types.h>
#include "uname_patch/livepatch_uname.h"
/* Auto expanded KLP_PATCHES_INCLUDES: */
#include "bsc1133191/livepatch_bsc1133191.h"
#include "bsc1136446/livepatch_bsc1136446.h"
#include "bsc1137597/livepatch_bsc1137597.h"
#include "bsc1138264/livepatch_bsc1138264.h"
#include "bsc1144502/livepatch_bsc1144502.h"
#include "bsc1151021/livepatch_bsc1151021.h"
#include "bsc1153108/livepatch_bsc1153108.h"
#include "bsc1153161/livepatch_bsc1153161.h"
#include "bsc1156321/livepatch_bsc1156321.h"
#include "bsc1159913/livepatch_bsc1159913.h"
#include "bsc1160467/livepatch_bsc1160467.h"
#include "bsc1165631/livepatch_bsc1165631.h"
static struct klp_object objs[] = {
/* Auto expanded KLP_PATCHES_OBJS: */
{
.name = NULL,
.funcs = (struct klp_func[]) {
{
.old_name = __stringify(KLP_SYSCALL_SYM(newuname)),
.new_func = KLP_SYSCALL_SYM(klp_newuname),
},
#ifdef KLP_ARCH_HAS_SYSCALL_COMPAT_STUBS
{
.old_name = __stringify(KLP_SYSCALL_COMPAT_STUB_SYM(newuname)),
.new_func = KLP_SYSCALL_COMPAT_STUB_SYM(klp_newuname),
},
#endif
{ .old_name = "follow_page_mask", .new_func = klp_follow_page_mask, },
{ .old_name = "__get_user_pages", .new_func = klp__get_user_pages, },
#if IS_ENABLED(CONFIG_PPC64)
{ .old_name = "__get_user_pages_fast", .new_func = klp__get_user_pages_fast, },
#endif
#if IS_ENABLED(CONFIG_X86_64)
{ .old_name = "gup_pte_range", .new_func = klp_gup_pte_range, },
{ .old_name = "gup_huge_pmd", .new_func = klp_gup_huge_pmd, },
{ .old_name = "gup_huge_pud", .new_func = klp_gup_huge_pud, },
#endif
{ .old_name = "SyS_splice", .new_func = SyS_klp_splice, },
{ .old_name = "SyS_tee", .new_func = SyS_klp_tee, },
{ .old_name = "tcp_sacktag_walk", .new_func = klp_tcp_sacktag_walk, },
{ .old_name = "tcp_fragment", .new_func = klp_tcp_fragment, },
{ .old_name = "__tcp_retransmit_skb", .new_func = klp__tcp_retransmit_skb, },
#if CONFIG_PPC64
{ .old_name = "init_new_context", .new_func = klp_init_new_context, },
#endif
#if CONFIG_X86_64
{ .old_name = "insn_get_seg_base", .new_func = klp_insn_get_seg_base, },
{ .old_name = "insn_get_code_seg_params", .new_func = klp_insn_get_code_seg_params, },
{ .old_name = "get_seg_base_limit", .new_func = klp_get_seg_base_limit, },
#endif
{ .old_name = "filldir", .new_func = klpp_filldir, },
{ .old_name = "filldir64", .new_func = klpp_filldir64, },
{ .old_name = "ptrace_attach", .new_func = klpp_ptrace_attach, },
{ .old_name = "ptrace_traceme", .new_func = klpp_ptrace_traceme, },
{ }
}
},
{
.name = "cfg80211",
.funcs = (struct klp_func[]) {
{ .old_name = "cfg80211_mgd_wext_giwessid", .new_func = klpp_cfg80211_mgd_wext_giwessid, },
{ }
}
},
{
.name = "fuse",
.funcs = (struct klp_func[]) {
{ .old_name = "fuse_dev_splice_write", .new_func = klp_fuse_dev_splice_write, },
{ }
}
},
{
.name = "geneve",
.funcs = (struct klp_func[]) {
{ .old_name = "geneve_get_v6_dst", .new_func = klpp_geneve_get_v6_dst, },
{ }
}
},
{
.name = "libertas",
.funcs = (struct klp_func[]) {
{ .old_name = "lbs_cfg_connect", .new_func = klpp_lbs_cfg_connect, },
{ .old_name = "lbs_ibss_join_existing", .new_func = klpp_lbs_ibss_join_existing, },
{ }
}
},
{
.name = "mac80211",
.funcs = (struct klp_func[]) {
{ .old_name = "ieee80211_add_station", .new_func = klpp_ieee80211_add_station, },
{ .old_name = "ieee80211_change_station", .new_func = klpp_ieee80211_change_station, },
{ .old_name = "sta_info_move_state", .new_func = klpp_sta_info_move_state, },
{ }
}
},
{
.name = "mwifiex",
.funcs = (struct klp_func[]) {
{ .old_name = "mwifiex_set_mgmt_ies", .new_func = klp_mwifiex_set_mgmt_ies, },
{ .old_name = "mwifiex_update_bss_desc_with_ie", .new_func = klp_mwifiex_update_bss_desc_with_ie, },
{ }
}
},
#if IS_ENABLED(CONFIG_RDMA_RXE)
{
.name = "rdma_rxe",
.funcs = (struct klp_func[]) {
{ .old_name = "rxe_find_route", .new_func = klpp_rxe_find_route, },
{ }
}
},
#endif
{
.name = "tipc",
.funcs = (struct klp_func[]) {
{ .old_name = "tipc_udp_send_msg", .new_func = klpp_tipc_udp_send_msg, },
{ }
}
},
{
.name = "vhost",
.funcs = (struct klp_func[]) {
{ .old_name = "vhost_get_vq_desc", .new_func = klpp_vhost_get_vq_desc, },
{ }
}
},
{
.name = "vxlan",
.funcs = (struct klp_func[]) {
{ .old_name = "vxlan_xmit_one", .new_func = klpp_vxlan_xmit_one, },
{ .old_name = "vxlan_fill_metadata_dst", .new_func = klpp_vxlan_fill_metadata_dst, },
{ }
}
},
{ }
};
static struct klp_patch patch = {
.mod = THIS_MODULE,
.objs = objs,
.replace = true,
};
static int __init klp_patch_init(void)
{
int retval;
pr_info("livepatch: initializing\n");
retval = klp_patch_uname_init();
if (retval)
return retval;
/* Auto expanded KLP_PATCHES_INIT_CALLS: */
retval = livepatch_bsc1133191_init();
if (retval)
goto err_bsc1133191;
retval = livepatch_bsc1136446_init();
if (retval)
goto err_bsc1136446;
retval = livepatch_bsc1137597_init();
if (retval)
goto err_bsc1137597;
retval = livepatch_bsc1138264_init();
if (retval)
goto err_bsc1138264;
retval = livepatch_bsc1144502_init();
if (retval)
goto err_bsc1144502;
retval = livepatch_bsc1151021_init();
if (retval)
goto err_bsc1151021;
retval = livepatch_bsc1153108_init();
if (retval)
goto err_bsc1153108;
retval = livepatch_bsc1153161_init();
if (retval)
goto err_bsc1153161;
retval = livepatch_bsc1156321_init();
if (retval)
goto err_bsc1156321;
retval = livepatch_bsc1159913_init();
if (retval)
goto err_bsc1159913;
retval = livepatch_bsc1160467_init();
if (retval)
goto err_bsc1160467;
retval = livepatch_bsc1165631_init();
if (retval)
goto err_bsc1165631;
#ifndef KLP_NOREG_API
retval = klp_register_patch(&patch);
if (retval)
goto err_patches_cleanup;
#endif
retval = klp_enable_patch(&patch);
if (!retval)
return retval;
#ifndef KLP_NOREG_API
WARN_ON(klp_unregister_patch(&patch));
#endif
err_patches_cleanup:
/* Auto expanded KLP_PATCHES_INIT_ERR_HANDLERS: */
livepatch_bsc1165631_cleanup();
err_bsc1165631:
livepatch_bsc1160467_cleanup();
err_bsc1160467:
livepatch_bsc1159913_cleanup();
err_bsc1159913:
livepatch_bsc1156321_cleanup();
err_bsc1156321:
livepatch_bsc1153161_cleanup();
err_bsc1153161:
livepatch_bsc1153108_cleanup();
err_bsc1153108:
livepatch_bsc1151021_cleanup();
err_bsc1151021:
livepatch_bsc1144502_cleanup();
err_bsc1144502:
livepatch_bsc1138264_cleanup();
err_bsc1138264:
livepatch_bsc1137597_cleanup();
err_bsc1137597:
livepatch_bsc1136446_cleanup();
err_bsc1136446:
livepatch_bsc1133191_cleanup();
err_bsc1133191:
return retval;
}
static void __exit klp_patch_cleanup(void)
{
pr_info("livepatch: removed\n");
/* Auto expanded KLP_PATCHES_CLEANUP_CALLS: */
livepatch_bsc1133191_cleanup();
livepatch_bsc1136446_cleanup();
livepatch_bsc1137597_cleanup();
livepatch_bsc1138264_cleanup();
livepatch_bsc1144502_cleanup();
livepatch_bsc1151021_cleanup();
livepatch_bsc1153108_cleanup();
livepatch_bsc1153161_cleanup();
livepatch_bsc1156321_cleanup();
livepatch_bsc1159913_cleanup();
livepatch_bsc1160467_cleanup();
livepatch_bsc1165631_cleanup();
#ifndef KLP_NOREG_API
WARN_ON(klp_unregister_patch(&patch));
#endif
}
module_init(klp_patch_init);
module_exit(klp_patch_cleanup);
MODULE_LICENSE("GPL");
MODULE_INFO(livepatch, "Y");