3 # Copyright (C) 2007-2009 Ksplice, Inc.
4 # Authors: Jeff Arnold, Anders Kaseorg, Tim Abbott
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License, version 2.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
21 use lib
'KSPLICE_DATA_DIR';
23 use Time
::HiRes
qw(usleep);
27 GetOptions
(@common_options,
29 "debugfile=s" => \
$debug) or pod2usage
(1);
31 pod2usage
(1) if($help || scalar(@ARGV) != 1);
32 $debugon = 1 if (defined($debug));
33 $debug = abs_path
($debug) if (defined $debug);
36 $kid =~ s/^ksplice[-_]//;
38 my $update = "ksplice_$kid";
39 my $nounload = runstr
("lsmod") =~ m/- $/m;
41 if (!update_loaded
($kid)) {
42 print "Ksplice id $kid is not present in the kernel\n";
46 chdir("/sys/module/");
47 set_debug_level
($kid, $debugon);
48 my $stage = get_stage
($kid);
49 if ($stage ne 'applied') {
50 print "Ksplice id $kid is not applied\n";
53 set_stage
($kid, "reversed");
56 $stage = get_stage
($kid);
58 $failed = 1 if ($stage ne 'reversed');
59 foreach my $module (glob("${update}_*")) {
60 if (!$nounload && runval_raw
('rmmod', $module) != 0) {
66 set_stage
($kid, "cleanup");
68 while (update_loaded
($kid) && $count < 5) {
73 if ($failed == 0 && -e
"/sys/module/$update") {
74 if (!$nounload && runval_raw
('rmmod', $update) != 0) {
79 unless($failed == 0) {
80 my $debugfile = get_debug_output
($kid, $debug);
81 print STDERR
"Error undoing Ksplice update $kid:\n";
82 my $abort_cause = get_abort_cause
($kid);
83 my $conflicts = get_conflicts
($kid);
84 print_error
($abort_cause);
85 if ($abort_cause eq 'code_busy') {
88 if($debugon && defined $debugfile) {
89 print("Debugging output saved to $debugfile\n");
93 rmtree
("/var/run/ksplice/updates/$kid");
99 "code_busy" => <<'END',
100 Ksplice has aborted the undo operation because it appears that the code that
101 you are trying to change is continuously in use by the system. More
102 specifically, Ksplice has been unable to find a moment when one or more of the
103 to-be-changed functions is not on a thread's kernel stack.
105 "module_busy" => <<'END',
106 Ksplice has aborted the undo operation because it appears that the Ksplice
107 update that you are trying to unload is in use by another module. You can find
108 out what module is using the Ksplice update using the lsmod command.
110 "unexpected_running_task" => <<'END',
111 Ksplice has aborted the undo operation because of an unexpected failure during
112 the kernel stack check. Please consider reporting a bug to PACKAGE_BUGREPORT.
114 "out_of_memory" => <<'END',
115 Ksplice has aborted the undo operation because the kernel ran out of memory.
117 "call_failed" => <<'END',
118 Ksplice has aborted the undo operation at the request of a one of the
119 pre-application hooks that were included as part of this Ksplice
120 update. This is likely the result of a bug in the patch used to
121 generate this update.
123 "cold_update_loaded" => <<'END',
124 Ksplice has aborted the undo operation because the update was applied using the
125 --partial option, and one of the modules that was changed by the update was loaded
126 since the update was applied. You must first unload that (cold patched) module
127 before you can undo this update.
129 "unexpected" => <<'END',
130 Ksplice has aborted because of an unexpected error.
131 Please consider reporting a bug to PACKAGE_BUGREPORT.
133 "UNKNOWN" => <<'END',
134 The Ksplice kernel component has returned an error code that this version of
135 ksplice-undo does not understand.
138 Ksplice has aborted the undo operation for unknown reasons.
139 Please consider reporting a bug to PACKAGE_BUGREPORT.
142 $error = "UNKNOWN" if (!exists $errors{$error});
143 print STDERR
"\n$errors{$error}\n";
148 ksplice-undo - Undo a Ksplice update that has been applied to the running kernel
152 B<ksplice-undo> [I<OPTIONS>] I<KSPLICE_ID>
156 B<ksplice-undo> takes as input a Ksplice identification tag, as reported by
157 L<ksplice-view(8)>, and it reverses that update within the running binary kernel.
165 Reverses the update with debugging output enabled. Recommended only for
168 =item B<--debugfile=>I<filename>
170 Sets the location where debugging output should be saved. Implies --debug.
176 L<ksplice-create(8)>, L<ksplice-apply(8)>, L<ksplice-view(8)>
180 Please report bugs to <PACKAGE_BUGREPORT>.
184 Jeff Arnold, Anders Kaseorg, and Tim Abbott
188 Copyright (C) 2007-2009 Ksplice, Inc.
190 This is free software and documentation. You can redistribute and/or modify it
191 under the terms of the GNU General Public License, version 2.