| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2017 Joe Lawrence <joe.lawrence@redhat.com> |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or |
|---|
| 5 | | - * modify it under the terms of the GNU General Public License |
|---|
| 6 | | - * as published by the Free Software Foundation; either version 2 |
|---|
| 7 | | - * of the License, or (at your option) any later version. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 10 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 | | - * GNU General Public License for more details. |
|---|
| 13 | | - * |
|---|
| 14 | | - * You should have received a copy of the GNU General Public License |
|---|
| 15 | | - * along with this program; if not, see <http://www.gnu.org/licenses/>. |
|---|
| 16 | 4 | */ |
|---|
| 17 | 5 | |
|---|
| 18 | 6 | /* |
|---|
| .. | .. |
|---|
| 50 | 38 | unsigned long jiffies_expire; |
|---|
| 51 | 39 | }; |
|---|
| 52 | 40 | |
|---|
| 53 | | -bool livepatch_fix2_dummy_check(struct dummy *d, unsigned long jiffies) |
|---|
| 41 | +static bool livepatch_fix2_dummy_check(struct dummy *d, unsigned long jiffies) |
|---|
| 54 | 42 | { |
|---|
| 55 | 43 | int *shadow_count; |
|---|
| 56 | 44 | |
|---|
| .. | .. |
|---|
| 71 | 59 | static void livepatch_fix2_dummy_leak_dtor(void *obj, void *shadow_data) |
|---|
| 72 | 60 | { |
|---|
| 73 | 61 | void *d = obj; |
|---|
| 74 | | - void **shadow_leak = shadow_data; |
|---|
| 62 | + int **shadow_leak = shadow_data; |
|---|
| 75 | 63 | |
|---|
| 76 | 64 | kfree(*shadow_leak); |
|---|
| 77 | 65 | pr_info("%s: dummy @ %p, prevented leak @ %p\n", |
|---|
| 78 | 66 | __func__, d, *shadow_leak); |
|---|
| 79 | 67 | } |
|---|
| 80 | 68 | |
|---|
| 81 | | -void livepatch_fix2_dummy_free(struct dummy *d) |
|---|
| 69 | +static void livepatch_fix2_dummy_free(struct dummy *d) |
|---|
| 82 | 70 | { |
|---|
| 83 | | - void **shadow_leak; |
|---|
| 71 | + int **shadow_leak; |
|---|
| 84 | 72 | int *shadow_count; |
|---|
| 85 | 73 | |
|---|
| 86 | 74 | /* Patch: copy the memory leak patch from the fix1 module. */ |
|---|
| .. | .. |
|---|
| 129 | 117 | |
|---|
| 130 | 118 | static int livepatch_shadow_fix2_init(void) |
|---|
| 131 | 119 | { |
|---|
| 132 | | - int ret; |
|---|
| 133 | | - |
|---|
| 134 | | - ret = klp_register_patch(&patch); |
|---|
| 135 | | - if (ret) |
|---|
| 136 | | - return ret; |
|---|
| 137 | | - ret = klp_enable_patch(&patch); |
|---|
| 138 | | - if (ret) { |
|---|
| 139 | | - WARN_ON(klp_unregister_patch(&patch)); |
|---|
| 140 | | - return ret; |
|---|
| 141 | | - } |
|---|
| 142 | | - return 0; |
|---|
| 120 | + return klp_enable_patch(&patch); |
|---|
| 143 | 121 | } |
|---|
| 144 | 122 | |
|---|
| 145 | 123 | static void livepatch_shadow_fix2_exit(void) |
|---|
| 146 | 124 | { |
|---|
| 147 | 125 | /* Cleanup any existing SV_COUNTER shadow variables */ |
|---|
| 148 | 126 | klp_shadow_free_all(SV_COUNTER, NULL); |
|---|
| 149 | | - |
|---|
| 150 | | - WARN_ON(klp_unregister_patch(&patch)); |
|---|
| 151 | 127 | } |
|---|
| 152 | 128 | |
|---|
| 153 | 129 | module_init(livepatch_shadow_fix2_init); |
|---|