/* * livepatch_main.c - kernel live patch main infrastructure * * Copyright (c) 2014 SUSE * Author: Miroslav Benes * * 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 . */ #include #include #include #include "uname_patch/livepatch_uname.h" /* Auto expanded KLP_PATCHES_INCLUDES: */ #include "bsc1235916/livepatch_bsc1235916.h" #include "bsc1236701/livepatch_bsc1236701.h" #include "bsc1238912/livepatch_bsc1238912.h" #include "bsc1239077/livepatch_bsc1239077.h" #include "bsc1239096/livepatch_bsc1239096.h" #include "bsc1241579/livepatch_bsc1241579.h" #include "bsc1245793/livepatch_bsc1245793.h" #include "bsc1245797/livepatch_bsc1245797.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 = __stringify(mptcp_established_options), .new_func = klpp_mptcp_established_options, }, { .old_name = __stringify(mac_partition), .new_func = klpp_mac_partition, }, { .old_name = __stringify(pfifo_tail_enqueue), .new_func = klpp_pfifo_tail_enqueue, }, { } } }, #if IS_ENABLED(CONFIG_BT) { .name = "bluetooth", .funcs = (struct klp_func[]) { { .old_name = __stringify(mgmt_remove_adv_monitor_complete), .new_func = klpp_mgmt_remove_adv_monitor_complete, }, { .old_name = __stringify(mgmt_remove_adv_monitor_sync), .new_func = klpp_mgmt_remove_adv_monitor_sync, }, { } } }, #endif { .name = "btrfs", .funcs = (struct klp_func[]) { { .old_name = __stringify(btrfs_create_pending_block_groups), .new_func = klpp_btrfs_create_pending_block_groups, }, { } } }, { .name = "pktgen", .funcs = (struct klp_func[]) { { .old_name = __stringify(pktgen_if_write), .new_func = klpp_pktgen_if_write, }, { } } }, { .name = "sch_hfsc", .funcs = (struct klp_func[]) { { .old_name = __stringify(hfsc_change_class), .new_func = klpp_hfsc_change_class, }, { } } }, { .name = "sch_sfq", .funcs = (struct klp_func[]) { { .old_name = __stringify(sfq_init), .new_func = klpp_sfq_init, }, { } } }, { } }; 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"); /* Auto expanded KLP_PATCHES_INIT_CALLS: */ retval = livepatch_bsc1235916_init(); if (retval) goto err_bsc1235916; retval = livepatch_bsc1236701_init(); if (retval) goto err_bsc1236701; retval = livepatch_bsc1238912_init(); if (retval) goto err_bsc1238912; retval = livepatch_bsc1239077_init(); if (retval) goto err_bsc1239077; retval = livepatch_bsc1239096_init(); if (retval) goto err_bsc1239096; retval = livepatch_bsc1241579_init(); if (retval) goto err_bsc1241579; retval = livepatch_bsc1245793_init(); if (retval) goto err_bsc1245793; retval = livepatch_bsc1245797_init(); if (retval) goto err_bsc1245797; retval = klp_enable_patch(&patch); if (!retval) return retval; /* Auto expanded KLP_PATCHES_INIT_ERR_HANDLERS: */ livepatch_bsc1245797_cleanup(); err_bsc1245797: livepatch_bsc1245793_cleanup(); err_bsc1245793: livepatch_bsc1241579_cleanup(); err_bsc1241579: livepatch_bsc1239096_cleanup(); err_bsc1239096: livepatch_bsc1239077_cleanup(); err_bsc1239077: livepatch_bsc1238912_cleanup(); err_bsc1238912: livepatch_bsc1236701_cleanup(); err_bsc1236701: livepatch_bsc1235916_cleanup(); err_bsc1235916: return retval; } static void __exit klp_patch_cleanup(void) { pr_info("livepatch: removed\n"); /* Auto expanded KLP_PATCHES_CLEANUP_CALLS: */ livepatch_bsc1235916_cleanup(); livepatch_bsc1236701_cleanup(); livepatch_bsc1238912_cleanup(); livepatch_bsc1239077_cleanup(); livepatch_bsc1239096_cleanup(); livepatch_bsc1241579_cleanup(); livepatch_bsc1245793_cleanup(); livepatch_bsc1245797_cleanup(); } module_init(klp_patch_init); module_exit(klp_patch_cleanup); MODULE_LICENSE("GPL"); MODULE_INFO(livepatch, "Y"); MODULE_INFO(klpgitrev, "40382421234531a046c87846bfa7d0d18421bf3a");