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';
25 my ($help, $wantversion, $debug) = (0, 0, 0);
26 GetOptions
("help|?" => \
$help,
27 "version" => \
$wantversion,
28 "verbose|v:+" => \
$Verbose::level
,
29 "debug" => \
$debug) or pod2usage
(1);
35 pod2usage
(1) if($help || scalar(@ARGV) != 1);
38 $kid =~ s/^ksplice[-_]//;
40 my $update = "ksplice_$kid";
41 my $nounload = runstr
("lsmod") =~ m/- $/m;
43 if (!update_loaded
($kid)) {
44 print "Ksplice id $kid is not present in the kernel\n";
48 chdir("/sys/module/");
49 set_debug_level
($kid, $debug) if(defined($debug));
50 my $stage = get_stage
($kid);
51 if ($stage ne 'applied') {
52 print "Ksplice id $kid is not applied\n";
55 set_stage
($kid, "reversed");
59 foreach my $module (glob("${update}_*")) {
60 if (!$nounload && runval_raw
('rmmod', $module) != 0) {
65 if ($failed == 0 && -e
"/sys/module/$update") {
66 if (!$nounload && runval_raw
('rmmod', $update) != 0) {
71 unless($failed == 0) {
72 my ($debugfile, $debugout) = get_debug_output
($kid);
73 print STDERR
"Error undoing Ksplice update $kid:\n";
75 my $abort_cause = get_abort_cause
($kid);
76 my $conflicts = get_conflicts
($kid);
77 print_error
($abort_cause);
78 if ($abort_cause eq 'code_busy') {
81 if(defined $debugfile) {
83 print("Debugging output saved to $debugfile\n");
92 "code_busy" => <<'END',
93 Ksplice has aborted the undo operation because it appears that the code that
94 you are trying to change is continuously in use by the system. More
95 specifically, Ksplice has been unable to find a moment when one or more of the
96 to-be-changed functions is not on a thread's kernel stack.
98 "module_busy" => <<'END',
99 Ksplice has aborted the undo operation because it appears that the Ksplice
100 update that you are trying to unload is in use by another module. You can find
101 out what module is using the Ksplice update using the lsmod command.
103 "unexpected_running_task" => <<'END',
104 Ksplice has aborted the undo operation because of an unexpected failure during
105 the kernel stack check. Please consider reporting a bug to PACKAGE_BUGREPORT.
107 "out_of_memory" => <<'END',
108 Ksplice has aborted the undo operation because the kernel ran out of memory.
110 "unexpected" => <<'END',
111 Ksplice has aborted because of an unexpected error.
112 Please consider reporting a bug to PACKAGE_BUGREPORT.
114 "UNKNOWN" => <<'END',
115 The Ksplice kernel component has returned an error code that this version of
116 ksplice-undo does not understand.
119 Ksplice has aborted the undo operation for unknown reasons.
120 Please consider reporting a bug to PACKAGE_BUGREPORT.
123 $error = "UNKNOWN" if (!exists $errors{$error});
124 print STDERR
"\n$errors{$error}\n";
129 ksplice-undo - Undo a Ksplice update that has been applied to the running kernel
133 B<ksplice-undo> I<KSPLICE_ID>
137 B<ksplice-undo> takes as input a Ksplice identification tag, as reported by
138 L<ksplice-view(8)>, and it reverses that update within the running binary kernel.
146 Reverses the update with debugging output enabled. Recommended only for
153 L<ksplice-create(8)>, L<ksplice-apply(8)>, L<ksplice-view(8)>
157 Copyright (C) 2007-2008 Jeffrey Brian Arnold <jbarnold@mit.edu>
158 Copyright (C) 2008 Anders Kaseorg <andersk@mit.edu>,
159 Tim Abbott <tabbott@mit.edu>
161 This is free software and documentation. You can redistribute and/or modify it
162 under the terms of the GNU General Public License, version 2.