Skip to content

Commit bb0ed3f

Browse files
committed
compat: redefine version constants for sublevel>=256
With the 4.4.256 and 4.9.256 kernels, the previous calculation for integer comparison overflowed. This commit redefines the broken constants to have more space for the sublevel. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
1 parent 897b4b9 commit bb0ed3f

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/compat/Kbuild.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
66

77
ccflags-y += -include $(kbuild-dir)/compat/compat.h
88
asflags-y += -include $(kbuild-dir)/compat/compat-asm.h
9+
LINUXINCLUDE := -DCOMPAT_VERSION=$(VERSION) -DCOMPAT_PATCHLEVEL=$(PATCHLEVEL) -DCOMPAT_SUBLEVEL=$(SUBLEVEL) -I$(kbuild-dir)/compat/version $(LINUXINCLUDE)
910

1011
ifeq ($(wildcard $(srctree)/include/linux/ptr_ring.h),)
1112
ccflags-y += -I$(kbuild-dir)/compat/ptr_ring/include

src/compat/version/linux/version.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Copyright (C) 2015-2021 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
4+
*/
5+
6+
#include_next <linux/version.h>
7+
#undef KERNEL_VERSION
8+
#define KERNEL_VERSION(a, b, c) (((a) << 24) + ((b) << 16) + (c))
9+
#undef LINUX_VERSION_CODE
10+
#define LINUX_VERSION_CODE KERNEL_VERSION(COMPAT_VERSION, COMPAT_PATCHLEVEL, COMPAT_SUBLEVEL)

0 commit comments

Comments
 (0)