stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
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	[thread overview]
Message-ID: <20240114080711.5109-1-jtornosm@redhat.com> (raw)
In-Reply-To: <CAK7LNAR_wgQBs-q9NH1icb_FPBoVMNEhQpvV8qzH2dFsrDS0pQ@mail.gmail.com>

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 <jtornosm@redhat.com>
---
 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


  parent reply	other threads:[~2024-01-14  8:07 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20231108000749.GA3723879@dev-arch.thelio-3990X>
2023-12-12 17:10 ` [PATCH v2] rpm-pkg: simplify installkernel %post Jose Ignacio Tornos Martinez
2023-12-12 19:19   ` Nathan Chancellor
2023-12-18 18:26   ` Masahiro Yamada
2023-12-19  8:43     ` Jose Ignacio Tornos Martinez
2023-12-19 15:56     ` [PATCH v3] " Jose Ignacio Tornos Martinez
2023-12-19 16:49       ` Masahiro Yamada
2023-12-19 20:17         ` [PATCH v4] " Jose Ignacio Tornos Martinez
2023-12-20 17:18           ` Nathan Chancellor
2023-12-26  4:02           ` Masahiro Yamada
2024-01-07 15:25             ` Jose Ignacio Tornos Martinez
2024-01-14  8:06             ` [PATCH V5 1/2] " Jose Ignacio Tornos Martinez
2024-01-17  1:29               ` Masahiro Yamada
2024-01-18 14:12                 ` Jose Ignacio Tornos Martinez
2024-01-21 17:32                   ` Masahiro Yamada
2024-01-22 18:22                     ` Jose Ignacio Tornos Martinez
2024-01-22 18:22                     ` [PATCH] " Jose Ignacio Tornos Martinez
2024-01-28  7:32                       ` Masahiro Yamada
2024-01-29  9:27                         ` Jose Ignacio Tornos Martinez
2024-01-29  9:28                         ` [PATCH v7] " Jose Ignacio Tornos Martinez
2024-01-31  1:48                           ` Masahiro Yamada
2024-01-14  8:07             ` Jose Ignacio Tornos Martinez [this message]
2024-01-17  1:32               ` [PATCH V5 2/2] rpm-pkg: avoid install/remove the running kernel Masahiro Yamada
2024-01-18 14:12                 ` Jose Ignacio Tornos Martinez
2024-01-21 17:33                   ` Masahiro Yamada
2024-01-22 15:53                     ` Jose Ignacio Tornos Martinez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240114080711.5109-1-jtornosm@redhat.com \
    --to=jtornosm@redhat.com \
    --cc=dcavalca@meta.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nicolas@fjasle.eu \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).