Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp3219485rdd; Sun, 14 Jan 2024 00:07:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IEsD/LxzWI6YhwYPEWO5/4PRbc7c7CVrdMRCDWm3Yf/IH4MVDzdq5Vpg3M7LFWOX4km/FX+ X-Received: by 2002:a05:6a20:aa8a:b0:199:dcb2:8756 with SMTP id ck10-20020a056a20aa8a00b00199dcb28756mr3981091pzb.59.1705219659018; Sun, 14 Jan 2024 00:07:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705219659; cv=none; d=google.com; s=arc-20160816; b=l23E42mnYPwumNYgORmY230BqvrMms0UrLr+OSjbFBsn3k4C4+Vnw5T/7SII5ioKyq iKzz/oVVkjrb0ZQXV9lqN9QFVMAPGCJZmLKBvMyaOfOMK4GmBpsfl2t6NyXWYV0PIT+y K6s0UxA4ElUotkCSaciNLWxQ8rJ7D4uvc4ZddUPSiEIldrw5BQcNz1U/ALXpufFQ77tK cIvhyxYMUvdDhMVxJM/rOmdh8JkgVnLYKoXRVa9ZXgfknfjA35zpN2fOfAiKLAhHTokA yG6BKXwpfu+ulOsEcB56lCHN00B0iV6/M6pKHkr9U+WyC56F04M2Ju/gKajiqiuPMrlS jpRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ffLmMyOaklOqYbWQCeCLRdG1Ympe93V9wLE3GPAo5oQ=; fh=UtjiNYbYZwpSkQBvFYcjoqZCLQVWRkcJXV3l/BIBQoQ=; b=fCsNtaanb1+7JEVffSD+MsaP01tUrD44s+HgXgE8+S6BUXnhOVJsXlISCfDmwUgkDw KmJZvZfp77K0XnkzgwqTtScrFq7N/kBz/fBGM1pt5E9m1kWKB7OQlOLcOI6iB2lGP+Ev Ue9qiEU5GPWvIWHq1B3VgTAZVYfFiSY/1pXsIidKwZ6aWkmfo5EC5QqMwG0AEeaV5nwj rDO0oH5CHaMpq5QGHaYjgT38pYiJi8eI9yH3MGRcRLHobsJTiF5gXUFdVeC4rpEDPuHR W4vaJt8R6KTisfyCqq1DqTonbzWHceclr0ixutU5hlt4XP+h15Tk+HnTmSmydpA84BG7 lGNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=e+ldSfuf; spf=pass (google.com: domain of linux-kernel+bounces-25416-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25416-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 2-20020a630d42000000b005cf17ab8a61si6598803pgn.272.2024.01.14.00.07.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jan 2024 00:07:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25416-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=e+ldSfuf; spf=pass (google.com: domain of linux-kernel+bounces-25416-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25416-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id AB47E282777 for ; Sun, 14 Jan 2024 08:07:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B13BE1FA5; Sun, 14 Jan 2024 08:07:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="e+ldSfuf" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76F4D1869 for ; Sun, 14 Jan 2024 08:07:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705219650; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ffLmMyOaklOqYbWQCeCLRdG1Ympe93V9wLE3GPAo5oQ=; b=e+ldSfufjin0CVAMChYsspF+xlUMv9t+040jQBF1qQNgk8GMDJ3q498fAAgFkuQteiwUlF Dg5YWySYnbmdnANliLKrcbc2n/7pj9ktU6ZexSE+9ZgmjHJlq1EIvBND0N4IV6YdnseoO3 XjLJI8mLW9bOC98FxrGNchM2DMrfQw4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-621-TTVYK9QGOK6liqwc9JxW7w-1; Sun, 14 Jan 2024 03:07:26 -0500 X-MC-Unique: TTVYK9QGOK6liqwc9JxW7w-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9B3E683B7EF; Sun, 14 Jan 2024 08:07:25 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id 702331C066AE; Sun, 14 Jan 2024 08:07:23 +0000 (UTC) From: Jose Ignacio Tornos Martinez To: masahiroy@kernel.org Cc: dcavalca@meta.com, jtornosm@redhat.com, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, nathan@kernel.org, ndesaulniers@google.com, nicolas@fjasle.eu, stable@vger.kernel.org Subject: [PATCH V5 2/2] rpm-pkg: avoid install/remove the running kernel Date: Sun, 14 Jan 2024 09:07:11 +0100 Message-ID: <20240114080711.5109-1-jtornosm@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 Normally, upper tools and scripts are checking if we want to modify the running kernel but not always. Check install and remove operation that affect the running kernel to avoid possible issues. Tested with Fedora 38, Fedora 39, RHEL 9, Oracle Linux 9.3, openSUSE Tumbleweed and openMandrive ROME, using dnf/zypper and rpm tools. cc: stable@vger.kernel.org Signed-off-by: Jose Ignacio Tornos Martinez --- scripts/package/kernel.spec | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec index 74542af8cbfe..216514cbf5f6 100644 --- a/scripts/package/kernel.spec +++ b/scripts/package/kernel.spec @@ -69,6 +69,12 @@ ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEA %clean rm -rf %{buildroot} +%pre +if [ $(uname -r) == %{KERNELRELEASE} ];then +echo "same kernel release is running" > /dev/stderr +exit 1 +fi + %post if [ -x /usr/bin/kernel-install ]; then /usr/bin/kernel-install add %{KERNELRELEASE} /lib/modules/%{KERNELRELEASE}/vmlinuz @@ -85,6 +91,10 @@ fi done %preun +if [ $(uname -r) == %{KERNELRELEASE} ];then +echo "same kernel release is running" > /dev/stderr +exit 1 +fi if [ -x /sbin/new-kernel-pkg ]; then new-kernel-pkg --remove %{KERNELRELEASE} --rminitrd --initrdfile=/boot/initramfs-%{KERNELRELEASE}.img elif [ -x /usr/bin/kernel-install ]; then -- 2.43.0