Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3527397pxf; Mon, 15 Mar 2021 11:32:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3wTOQrH2YegnJfNedV9gMqyhI7p6RnHA4xGC45jRlLGLRDmpxHWEgVfpy86wsoWQe4ZgQ X-Received: by 2002:a17:906:2b46:: with SMTP id b6mr4459631ejg.521.1615833157907; Mon, 15 Mar 2021 11:32:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833157; cv=none; d=google.com; s=arc-20160816; b=m0GpIgldyjGc6UZfL/OtSrJW3lsDL3cdes0SSS+aHBSz+Ooe4hOvdhXlN2pOyIoVl+ G8oZiClNoaSUKiIuYBpqXp9whjzXMKlROs5Qn8BxCWgmCEfV0PChrbsJm/KmuZMCTuaS RJKkqEo7Z2tTVF9sucZM74JIdN6rZfHpXqIwguGDSKH7mPyNIUo7ioHIh+zLJZu+O5Ke 3YwyTYAlMRkIJjrOhMLnIY6AdRQpiuQv/nCNLvhA+yMA2lE3veoBvYEQZk0qSgym/vDT aGgDrtReCLoD0LbZhgv5L66oVhEvZhq8k6rfjjdKwQqSWF6+5MyBmkamQVA0fT5JG6Un cbhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KX5/TshHntxql7TPJPwSuSvumMX+KgPd/kK8Mdeis/k=; b=ECi8IRq6cNjPeCGfh2TqA42BMGyL7RZWlhHzLKM0MGw3RXvUvTVZYCVK/ZEbMpTQq0 /EC2zsUZNW+IQerUpIrcsQpnwsxIvXrBl6z/y8d6IPO0t/iHvZfiimKqYaVpktuWIngt pXjgu4jUFglvs1OpvhJ12Nej3EZqAaPGJDM7zZCVleN5iFrIcXr4JKQcsD2sxKj7kmOm 9SODpkivsQLLTu2c+loFDm6YKuwNC7oLSg8odkgbtiTtcNEiXAPUIuBtLWuAmwF2bWDN gsYrdIPKsZp84rCsRAA6WOijnsxLZo9xeR5DNkD20zWQdCWiW0XRZPffHZ2MGp0Ipud4 Poig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=K0ShNMpb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si4893620ejx.431.2021.03.15.11.32.14; Mon, 15 Mar 2021 11:32:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=K0ShNMpb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240393AbhCOOhv (ORCPT + 99 others); Mon, 15 Mar 2021 10:37:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:37632 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233349AbhCOOBd (ORCPT ); Mon, 15 Mar 2021 10:01:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 26CC164F71; Mon, 15 Mar 2021 14:00:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816859; bh=L15DI/G3qO9jKwXK/H7XDWSGeuDMvy2QI13LVQIQw1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K0ShNMpbaVsiUOiHLPm1ldxuhNMAbiFtymr8oGJMo9CENfiQmYwBhcDNfeRAYpqLP ChWUvCd16V78srREvwPVpt218TuNqYgHsTFmQs/hZ1QtPRPTF+Xn5L/YiIk9xQEa2+ 9LltsAOWG/4h1Ne6ZDGJwxqWz/biRuS73dknTsE8= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sasha Levin , Masahiro Yamada Subject: [PATCH 5.10 156/290] kbuild: clamp SUBLEVEL to 255 Date: Mon, 15 Mar 2021 14:54:09 +0100 Message-Id: <20210315135547.188981758@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman [ 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 7fdb78b48f55..56d375763b0d 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