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';
26 GetOptions
(@common_options,
27 "debug" => \
$debug) or pod2usage
(1);
29 pod2usage
(1) if($help || scalar(@ARGV) != 1);
32 $kid =~ s/^ksplice[-_]//;
34 my $update = "ksplice_$kid";
35 my $nounload = runstr
("lsmod") =~ m/- $/m;
37 if (!update_loaded
($kid)) {
38 print "Ksplice id $kid is not present in the kernel\n";
42 chdir("/sys/module/");
43 set_debug_level
($kid, $debug) if(defined($debug));
44 my $stage = get_stage
($kid);
45 if ($stage ne 'applied') {
46 print "Ksplice id $kid is not applied\n";
49 set_stage
($kid, "reversed");
53 foreach my $module (glob("${update}_*")) {
54 if (!$nounload && runval_raw
('rmmod', $module) != 0) {
59 if ($failed == 0 && -e
"/sys/module/$update") {
60 if (!$nounload && runval_raw
('rmmod', $update) != 0) {
65 unless($failed == 0) {
66 my ($debugfile, $debugout) = get_debug_output
($kid);
67 print STDERR
"Error undoing Ksplice update $kid:\n";
69 my $abort_cause = get_abort_cause
($kid);
70 my $conflicts = get_conflicts
($kid);
71 print_error
($abort_cause);
72 if ($abort_cause eq 'code_busy') {
75 if(defined $debugfile) {
77 print("Debugging output saved to $debugfile\n");
86 "code_busy" => <<'END',
87 Ksplice has aborted the undo operation because it appears that the code that
88 you are trying to change is continuously in use by the system. More
89 specifically, Ksplice has been unable to find a moment when one or more of the
90 to-be-changed functions is not on a thread's kernel stack.
92 "module_busy" => <<'END',
93 Ksplice has aborted the undo operation because it appears that the Ksplice
94 update that you are trying to unload is in use by another module. You can find
95 out what module is using the Ksplice update using the lsmod command.
97 "unexpected_running_task" => <<'END',
98 Ksplice has aborted the undo operation because of an unexpected failure during
99 the kernel stack check. Please consider reporting a bug to PACKAGE_BUGREPORT.
101 "out_of_memory" => <<'END',
102 Ksplice has aborted the undo operation because the kernel ran out of memory.
104 "unexpected" => <<'END',
105 Ksplice has aborted because of an unexpected error.
106 Please consider reporting a bug to PACKAGE_BUGREPORT.
108 "UNKNOWN" => <<'END',
109 The Ksplice kernel component has returned an error code that this version of
110 ksplice-undo does not understand.
113 Ksplice has aborted the undo operation for unknown reasons.
114 Please consider reporting a bug to PACKAGE_BUGREPORT.
117 $error = "UNKNOWN" if (!exists $errors{$error});
118 print STDERR
"\n$errors{$error}\n";
123 ksplice-undo - Undo a Ksplice update that has been applied to the running kernel
127 B<ksplice-undo> I<KSPLICE_ID>
131 B<ksplice-undo> takes as input a Ksplice identification tag, as reported by
132 L<ksplice-view(8)>, and it reverses that update within the running binary kernel.
140 Reverses the update with debugging output enabled. Recommended only for
147 L<ksplice-create(8)>, L<ksplice-apply(8)>, L<ksplice-view(8)>
151 Copyright (C) 2007-2008 Jeffrey Brian Arnold <jbarnold@mit.edu>
152 Copyright (C) 2008 Anders Kaseorg <andersk@mit.edu>,
153 Tim Abbott <tabbott@mit.edu>
155 This is free software and documentation. You can redistribute and/or modify it
156 under the terms of the GNU General Public License, version 2.