3 # Copyright (C) 2007-2008 Jeffrey Brian Arnold <jbarnold@mit.edu>
4 # Copyright (C) 2008 Anders Kaseorg <andersk@mit.edu>,
5 # Tim Abbott <tabbott@mit.edu>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License, version 2.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
22 use lib
'KSPLICE_DATA_DIR';
24 use Time
::HiRes
qw(usleep);
28 GetOptions
(@common_options,
30 "debugfile=s" => \
$debug) or pod2usage
(1);
32 pod2usage
(1) if($help || scalar(@ARGV) != 1);
33 $debugon = 1 if (defined($debug));
34 $debug = abs_path
($debug) if (defined $debug);
37 $kid =~ s/^ksplice[-_]//;
39 my $update = "ksplice_$kid";
40 my $nounload = runstr
("lsmod") =~ m/- $/m;
42 if (!update_loaded
($kid)) {
43 print "Ksplice id $kid is not present in the kernel\n";
47 chdir("/sys/module/");
48 set_debug_level
($kid, $debugon);
49 my $stage = get_stage
($kid);
50 if ($stage ne 'applied') {
51 print "Ksplice id $kid is not applied\n";
54 set_stage
($kid, "reversed");
57 $stage = get_stage
($kid);
59 $failed = 1 if ($stage ne 'reversed');
60 foreach my $module (glob("${update}_*")) {
61 if (!$nounload && runval_raw
('rmmod', $module) != 0) {
67 set_stage
($kid, "cleanup");
69 while (update_loaded
($kid) && $count < 5) {
74 if ($failed == 0 && -e
"/sys/module/$update") {
75 if (!$nounload && runval_raw
('rmmod', $update) != 0) {
80 unless($failed == 0) {
81 my $debugfile = get_debug_output
($kid, $debug);
82 print STDERR
"Error undoing Ksplice update $kid:\n";
83 my $abort_cause = get_abort_cause
($kid);
84 my $conflicts = get_conflicts
($kid);
85 print_error
($abort_cause);
86 if ($abort_cause eq 'code_busy') {
89 if($debugon && defined $debugfile) {
90 print("Debugging output saved to $debugfile\n");
94 rmtree
("/var/run/ksplice/updates/$kid");
100 "code_busy" => <<'END',
101 Ksplice has aborted the undo operation because it appears that the code that
102 you are trying to change is continuously in use by the system. More
103 specifically, Ksplice has been unable to find a moment when one or more of the
104 to-be-changed functions is not on a thread's kernel stack.
106 "module_busy" => <<'END',
107 Ksplice has aborted the undo operation because it appears that the Ksplice
108 update that you are trying to unload is in use by another module. You can find
109 out what module is using the Ksplice update using the lsmod command.
111 "unexpected_running_task" => <<'END',
112 Ksplice has aborted the undo operation because of an unexpected failure during
113 the kernel stack check. Please consider reporting a bug to PACKAGE_BUGREPORT.
115 "out_of_memory" => <<'END',
116 Ksplice has aborted the undo operation because the kernel ran out of memory.
118 "call_failed" => <<'END',
119 Ksplice has aborted the undo operation at the request of a one of the
120 pre-application hooks that were included as part of this Ksplice
121 update. This is likely the result of a bug in the patch used to
122 generate this update.
124 "unexpected" => <<'END',
125 Ksplice has aborted because of an unexpected error.
126 Please consider reporting a bug to PACKAGE_BUGREPORT.
128 "UNKNOWN" => <<'END',
129 The Ksplice kernel component has returned an error code that this version of
130 ksplice-undo does not understand.
133 Ksplice has aborted the undo operation for unknown reasons.
134 Please consider reporting a bug to PACKAGE_BUGREPORT.
137 $error = "UNKNOWN" if (!exists $errors{$error});
138 print STDERR
"\n$errors{$error}\n";
143 ksplice-undo - Undo a Ksplice update that has been applied to the running kernel
147 B<ksplice-undo> I<KSPLICE_ID>
151 B<ksplice-undo> takes as input a Ksplice identification tag, as reported by
152 L<ksplice-view(8)>, and it reverses that update within the running binary kernel.
160 Reverses the update with debugging output enabled. Recommended only for
163 =item B<--debugfile=>I<filename>
165 Sets the location where debugging output should be saved. Implies --debug.
171 L<ksplice-create(8)>, L<ksplice-apply(8)>, L<ksplice-view(8)>
175 Please report bugs to <PACKAGE_BUGREPORT>.
179 Copyright (C) 2007-2008 Jeffrey Brian Arnold <jbarnold@mit.edu>
181 Copyright (C) 2008 Anders Kaseorg <andersk@mit.edu>,
182 Tim Abbott <tabbott@mit.edu>
184 This is free software and documentation. You can redistribute and/or modify it
185 under the terms of the GNU General Public License, version 2.