From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49A67C433E0 for ; Tue, 2 Mar 2021 13:23:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E685064F20 for ; Tue, 2 Mar 2021 13:23:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1578232AbhCBNQL (ORCPT ); Tue, 2 Mar 2021 08:16:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:46390 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350240AbhCBMOO (ORCPT ); Tue, 2 Mar 2021 07:14:14 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id DD5A064F73; Tue, 2 Mar 2021 11:57:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614686251; bh=sV+0jxzMHLdVvX73z9/bfmOfp7Y/1hQS6IXemD7/Xdk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kWhun9Gtl/TGThqx46F58c62Ak9+dptjdfaCE18PUx4d8XCY5x/tidrK5xhdoQxr5 yVNDNyW9IsoKv0CJ16zhxK4bsvK5/xqn9t9Os1szd5tcuPrd+nzPd4oMpmywXEIPMT p2DGbGRnqo16NMowqXmo22BgfcPsJIdA1tH5XVS3COrz/v+A3O0P0TzOvvlJk5jlZs krZfwuMOt81MOYsF+7Rs6W/KPmVPGKD/S2OeVwZavHhGJsYg11qnZHlRoCK9YC7Dlw qLyGbOYdPLrlE/AxKJS7Nb6djZFu+l5A7txoNXKtSr0CPV+k6Q5mmqw9rhXa07s49q e6yl4+5w9hevw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sasha Levin , Masahiro Yamada , linux-kbuild@vger.kernel.org Subject: [PATCH AUTOSEL 5.10 36/47] kbuild: clamp SUBLEVEL to 255 Date: Tue, 2 Mar 2021 06:56:35 -0500 Message-Id: <20210302115646.62291-36-sashal@kernel.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210302115646.62291-1-sashal@kernel.org> References: <20210302115646.62291-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ 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 Signed-off-by: Masahiro Yamada Signed-off-by: Sasha Levin --- Makefile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index f700bdea626d..006011904269 100644 --- a/Makefile +++ b/Makefile @@ -1247,9 +1247,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 -- 2.30.1