Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3524081pxf; Mon, 15 Mar 2021 11:28:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyHb45e5mqoaeo6skohixKeesPZm+EcUjdghWdMUKyg7qMSBecCsdAUt7/BvYNCNfiZ10i X-Received: by 2002:a17:906:a44f:: with SMTP id cb15mr24778714ejb.420.1615832891391; Mon, 15 Mar 2021 11:28:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832891; cv=none; d=google.com; s=arc-20160816; b=EzzaIUTK0dwEAtTiyQkYNAvQJIF5V60nAOFMRl3vJn+L3BfTQh0aepsP1rkWXy7HUL RQ/wbaPg1JXZE8QptqegSw0tyjf0x5qVeCRSXrZbd3bUwGNQ987VAUoavK6W0DX+fOxn lD96vpXAN4GRV3hdaFL5Sts7YnnpXVvRy2aOSq4Gm3ua0becZUudwExGrUR/62DMzLUv H+o8L1LwyKJp8ug/AyWwwEQjtl06MHvQ1CytBZXnNbQv5RQ006MTsuSVW/7wzBtL31WW 7NXsynpBvughpL1F8V0zo20MtIrVJgFCh1I1lo2LvsS5dG+EyMErwEP3rKdSkccozJp5 C50w== 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=ft7hIlnXWBq2zmc9BJ2rfcLFEDWz4g4paJo5CKIeCaw=; b=KpRNI2WZGuVwiMLObQKipFP38n1/dRemJqR0vAlxo/qh7I9EAYGvuCULdZB2SqUErj P8lmaVa7bW6/eYdJBzCmW+2qC77/PlGBZtYVsYhycScEy4oNIsNPKlyuvg9Ysj04U+L/ mb2oveKhSWi1IY9YCunFmCM8+aMjD6XWa8g5KLpfTnWO+4X2g+hb810AGC1v0KuXg+Bq yuzbYFbkGSuVSnY1E8G0DYR3rML3XB8/vUO9NcTpbwcTrFbYAm6c67jwJYb0oWUUvrQU /f+nraQnkPX5xpkMtWpU9PzfM1Pn+y72yg2s9S7qMyF4PB/2Dn9xQwbme5gS6amw6yPv 3gDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QqMq2UmH; 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 x8si13679092edl.510.2021.03.15.11.27.42; Mon, 15 Mar 2021 11:28:11 -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=QqMq2UmH; 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 S234714AbhCOObF (ORCPT + 99 others); Mon, 15 Mar 2021 10:31:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:35610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231801AbhCOOAo (ORCPT ); Mon, 15 Mar 2021 10:00:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E324264F92; Mon, 15 Mar 2021 14:00:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816832; bh=bJjNUI3idUbK4NLt7cXok6JY935iaeyCKOy0SB3Pcm4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QqMq2UmHttwRPyCvbyCMVSfnWO1Qu6OQK1WW+vn4+c18yR628lZtu+Qr8Z73IoC9A ggrd4i+kxYcB0wCyKyQ2SJO/LKxTwBtqdjdm8BfuqlQs3MccXE/bvcc6GCQkJXe/yD VFYX17z1+I3uwo5l6nFsqHeNakcYijz1TavBTV+Q= 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.11 152/306] kbuild: clamp SUBLEVEL to 255 Date: Mon, 15 Mar 2021 14:53:35 +0100 Message-Id: <20210315135512.778484038@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@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 472136a7881e..80d166cadaa3 100644 --- a/Makefile +++ b/Makefile @@ -1246,9 +1246,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