Skip to content

Commit 0507ea2

Browse files
authored
Merge pull request dynup#1030 from joe-lawrence/verify-patch-files
kpatch-build: sanity check patched filenames
2 parents debf44a + e4525ce commit 0507ea2

File tree

2 files changed

+33
-16
lines changed

2 files changed

+33
-16
lines changed

README.md

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ sudo dnf install gcc kernel-devel-${UNAME%.*} elfutils elfutils-devel
4040
Install the dependencies for the "kpatch-build" command:
4141

4242
```bash
43-
sudo dnf install pesign yum-utils openssl wget numactl-devel
43+
sudo dnf install pesign yum-utils openssl wget numactl-devel patchutils
4444
sudo dnf builddep kernel-${UNAME%.*}
4545
sudo dnf debuginfo-install kernel-${UNAME%.*}
4646

@@ -50,9 +50,6 @@ sudo dnf install gcc-plugin-devel
5050
# optional, but highly recommended
5151
sudo dnf install ccache
5252
ccache --max-size=5G
53-
54-
# optional, for kpatch-test
55-
sudo dnf install patchutils
5653
```
5754

5855
#### RHEL 7
@@ -73,7 +70,8 @@ Install the dependencies for the "kpatch-build" command:
7370
sudo yum-config-manager --enable rhel-7-server-optional-rpms
7471
sudo yum install pesign yum-utils zlib-devel \
7572
binutils-devel newt-devel python-devel perl-ExtUtils-Embed \
76-
audit-libs-devel numactl-devel pciutils-devel bison ncurses-devel
73+
audit-libs-devel numactl-devel pciutils-devel bison ncurses-devel \
74+
patchutils
7775

7876
sudo yum-builddep kernel-${UNAME%.*}
7977
sudo debuginfo-install kernel-${UNAME%.*}
@@ -84,9 +82,6 @@ sudo yum install gcc-plugin-devel
8482
# optional, but highly recommended
8583
sudo yum install https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/c/ccache-3.3.4-1.el7.x86_64.rpm
8684
ccache --max-size=5G
87-
88-
# optional, for kpatch-test
89-
sudo yum install patchutils
9085
```
9186

9287
#### CentOS 7
@@ -106,7 +101,7 @@ Install the dependencies for the "kpatch-build" command:
106101
```bash
107102
sudo yum install pesign yum-utils zlib-devel \
108103
binutils-devel newt-devel python-devel perl-ExtUtils-Embed \
109-
audit-libs audit-libs-devel numactl-devel pciutils-devel bison
104+
audit-libs audit-libs-devel numactl-devel pciutils-devel bison patchutils
110105

111106
# enable CentOS 7 debug repo
112107
sudo yum-config-manager --enable debug
@@ -117,9 +112,6 @@ sudo debuginfo-install kernel-${UNAME%.*}
117112
# optional, but highly recommended - enable EPEL 7
118113
sudo yum install ccache
119114
ccache --max-size=5G
120-
121-
# optional, for kpatch-test
122-
sudo yum install patchutils
123115
```
124116

125117
#### Oracle Linux 7
@@ -139,7 +131,7 @@ Install the dependencies for the "kpatch-build" command:
139131
```bash
140132
sudo yum install pesign yum-utils zlib-devel \
141133
binutils-devel newt-devel python-devel perl-ExtUtils-Embed \
142-
audit-libs numactl-devel pciutils-devel bison
134+
audit-libs numactl-devel pciutils-devel bison patchutils
143135

144136
# enable ol7_optional_latest repo
145137
sudo yum-config-manager --enable ol7_optional_latest
@@ -153,9 +145,6 @@ rpm -ivh https://oss.oracle.com/ol7/debuginfo/kernel-debuginfo-common-x86_64-$(u
153145
# optional, but highly recommended - enable EPEL 7
154146
sudo yum install ccache
155147
ccache --max-size=5G
156-
157-
# optional, for kpatch-test
158-
sudo yum install patchutils
159148
```
160149

161150
#### Ubuntu

kpatch-build/kpatch-build

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,33 @@ logger() {
8888
fi
8989
}
9090

91+
verify_patch_files() {
92+
local path
93+
local dir
94+
local ret=0
95+
96+
for patch in "${PATCH_LIST[@]}"; do
97+
for path in $(lsdiff "$patch" 2>/dev/null); do
98+
99+
dir=$(dirname "$path")
100+
ext="${path##*.}"
101+
102+
if [[ "$dir" =~ ^lib$ ]] || [[ "$dir" =~ ^lib/ ]] ; then
103+
warn "$patch: unsupported patch to lib/: $path"
104+
ret=1
105+
fi
106+
107+
if [[ "$ext" == "S" ]] ; then
108+
warn "$patch: unsupported patch to assembly: $path"
109+
ret=1
110+
fi
111+
112+
done
113+
done
114+
115+
[[ $ret == 1 ]] && die "Unsupported changes detected"
116+
}
117+
91118
apply_patches() {
92119
local patch
93120

@@ -746,6 +773,7 @@ grep -q "CONFIG_GCC_PLUGIN_RANDSTRUCT=y" "$CONFIGFILE" && die "kernel option 'CO
746773

747774
echo "Testing patch file(s)"
748775
cd "$SRCDIR" || die
776+
verify_patch_files
749777
apply_patches
750778
remove_patches
751779

0 commit comments

Comments
 (0)