Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3516872pxf; Mon, 15 Mar 2021 11:17:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwF1YY7iJNhvzGrQFdRBkOqCUOMmXxmYkNqmMkBS823ZL+v6b4kVaqo7W4YWgs6hKA5DvoQ X-Received: by 2002:aa7:d954:: with SMTP id l20mr31513126eds.1.1615832239901; Mon, 15 Mar 2021 11:17:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832239; cv=none; d=google.com; s=arc-20160816; b=PNNRfeOQ8xyzq3AWKXaHp8qTnGgddjAEYElIqy+rQFgA4ZtvhDFxdanCC9ATdQKp5q wSkJV2fNwk4DB9REj5SYMVuxmkJiqQmNlVeHUV/ZWwEn0g8G26s3zJPyEKSGGmn7dk3s r+h0gc2C9DwdZVQamg3m4BZAnlqd6q8c+BQSOECYl09SVQ5DRpSgICrnsE2xtCBzP0sP HdWYJ9B04NiwOfQDj6WIUopPJXM0vXUAzIGtGauhLAV0/rNXBPMh6lcT2pLucH0W++S6 gWcU/dYW0+3C2mxK5vyrgXXBImydRHT63wvWQroU6lRH/gHtXPO9rTc6S0GyLPfzEBUk nrVQ== 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=68or5fxPmpNhapHGWhi2gZtg2ShDHZFGKxDpjrH2z50=; b=Y8jsgk0LMDWjhhKU7s6fcX03Ubk1pMtaunVwnrxG6oOskT1DKsLm4D7skJObbjbR34 moNEGoCmKUSahLEJ0LLcQwlPMtMCchpYzzkOYBSCY6m4FTnoW/UOF5D6Fxwa+urO5D4V umVgTzCFZw5NxjBZ7rwhyTDCUN4SV8MzACCEYh1hRWicER32h75QBTfcqHNLsotXzA9j S/pEYThO3oQwirie8xZOdv7ex4qWWRViYArGsirGVeFetrQPkQ36GJdPZa2kAVQR/35Q TiyevvFpluu8iBQWFwzv3SZH2UsI6bfLIV/u5O8ne9J+8UFnu7DrYX3cfC/zwYhEDDhk TUxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BKQCPBrp; 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 g3si11521561edp.527.2021.03.15.11.16.57; Mon, 15 Mar 2021 11:17:19 -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=BKQCPBrp; 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 S236892AbhCOOQV (ORCPT + 99 others); Mon, 15 Mar 2021 10:16:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:38284 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231588AbhCON71 (ORCPT ); Mon, 15 Mar 2021 09:59:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B135664F2D; Mon, 15 Mar 2021 13:59:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816742; bh=0KiJ5mnokOVvD5sEl1axOX46e0RnlfG0HeqRb906NkU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BKQCPBrpaUejd5DS+bH4p+W0zwAwBnuLN+bj4MuclBjBkdMHqJ0A8frbWkA34o67i +i2Iu3QJ6GUdLTnEJli0Wzc3xkVQcV04lBGVGe/xp0SLofLLX6b8+NMc7qhTFOPmt/ nrbDDEszWRKAa9HkWG7EtFR8RcOXFoHEGEsEHThw= 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.4 080/168] kbuild: clamp SUBLEVEL to 255 Date: Mon, 15 Mar 2021 14:55:12 +0100 Message-Id: <20210315135553.018784874@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135550.333963635@linuxfoundation.org> References: <20210315135550.333963635@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 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 -- 2.30.1