Patch "kbuild: clamp SUBLEVEL to 255" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    kbuild: clamp SUBLEVEL to 255

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     kbuild-clamp-sublevel-to-255.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit c31a699421e23526bd9a584dc0bdb51eeec001a3
Author: Sasha Levin <sashal@xxxxxxxxxx>
Date:   Fri Feb 5 22:50:32 2021 -0500

    kbuild: clamp SUBLEVEL to 255
    
    [ Upstream commit 9b82f13e7ef316cdc0a8858f1349f4defce3f9e0 ]
    
    Right now if SUBLEVEL becomes larger than 255 it will overflow into the
    territory of PATCHLEVEL, causing havoc in userspace that tests for
    specific kernel version.
    
    While userspace code tests for MAJOR and PATCHLEVEL, it doesn't test
    SUBLEVEL at any point as ABI changes don't happen in the context of
    stable tree.
    
    Thus, to avoid overflows, simply clamp SUBLEVEL to it's maximum value in
    the context of LINUX_VERSION_CODE. This does not affect "make
    kernelversion" and such.
    
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
    Signed-off-by: Masahiro Yamada <masahiroy@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/Makefile b/Makefile
index e27d031f3241..00be167f9b13 100644
--- a/Makefile
+++ b/Makefile
@@ -1175,9 +1175,15 @@ define filechk_utsrelease.h
 endef
 
 define filechk_version.h
-	echo \#define LINUX_VERSION_CODE $(shell                         \
-	expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + 0$(SUBLEVEL)); \
-	echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))'
+	if [ $(SUBLEVEL) -gt 255 ]; then                                 \
+		echo \#define LINUX_VERSION_CODE $(shell                 \
+		expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + 255); \
+	else                                                             \
+		echo \#define LINUX_VERSION_CODE $(shell                 \
+		expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \
+	fi;                                                              \
+	echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) +  \
+	((c) > 255 ? 255 : (c)))'
 endef
 
 $(version_h): FORCE



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux