mkinitrd unification across distributions
 help / color / mirror / Atom feed
From: Harald Hoyer <harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Guido Trentalancia
	<guido-D1bseh+SzQhuxeB9wqlrNw@public.gmane.org>,
	initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] dracut: 99base: do not mount /run with the "noexec" option
Date: Thu, 14 Apr 2016 12:33:33 +0200	[thread overview]
Message-ID: <570F71FD.3020101@redhat.com> (raw)
In-Reply-To: <1460472110.3152.14.camel-D1bseh+SzQhuxeB9wqlrNw@public.gmane.org>

On 12.04.2016 16:41, Guido Trentalancia wrote:
> On mar, 2016-04-12 at 16:24 +0200, Harald Hoyer wrote:
>> Am 12.04.2016 um 16:07 schrieb Guido Trentalancia:
>>> Do not mount the /run directory with the "noexec" option, otherwise
>>> the
>>> system bootup fails (no binary can be executed, everything fails
>>> with
>>> permission denied errors).
>>>
>>> The bug was introduced in version 042 (11 Jun 2015) and affects all
>>> versions up to 044 (latest) and including git checked out on 12 Apr
>>> 2016.
>>>
>>> Signed-off-by: Guido Trentalancia <guido-D1bseh+SzQhuxeB9wqlrNw@public.gmane.org>
>>> ---
>>>  modules.d/99base/init.sh |    2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> --- dracut-044/modules.d/99base/init.sh	2015-11-25
>>> 14:22:28.000000000 +0100
>>> +++ dracut-044-99base-init-should-mount-newrun-as-
>>> exec/modules.d/99base/init.sh	2016-04-12 15:37:44.163185387
>>> +0200
>>> @@ -64,7 +64,7 @@ fi
>>>  
>>>  if ! ismounted /run; then
>>>      mkdir -m 0755 /newrun
>>> -    mount -t tmpfs -o mode=0755,noexec,nosuid,nodev,strictatime
>>> tmpfs /newrun >/dev/null
>>> +    mount -t tmpfs -o mode=0755,nosuid,nodev,strictatime tmpfs
>>> /newrun >/dev/null
>>>      cp -a /run/* /newrun >/dev/null 2>&1
>>>      mount --move /newrun /run
>>>      rm -fr -- /newrun
>>>
>>
>> Which binary resides in /run ??
> 
> 
> The whole initram filesystem binaries, including (/run/initramfs)/bin,
> (/run/initramfs)/sbin, (/run/initramfs)/usr/bin and
> (/run/initramfs)/usr/sbin.
> 
> It starts to break immediately after mount at line 70 of 99base/init.sh
> (rm -fr -- /newrun) up to and including 99base/udevsettle() (loops the
> "permission denied" failure on execution of udevadm).
> 
> The patch has been tested and it works fine. Without the patch, dracut
> is unusable (the system cannot be booted).
> 
> Regards,
> 
> Guido

I would prefer something like this. Care to check, if that solves it?

diff --git a/modules.d/99base/init.sh b/modules.d/99base/init.sh
index bd7ef70..31126d6 100755
--- a/modules.d/99base/init.sh
+++ b/modules.d/99base/init.sh
@@ -64,7 +64,12 @@ fi

 if ! ismounted /run; then
     mkdir -m 0755 /newrun
-    mount -t tmpfs -o mode=0755,noexec,nosuid,nodev,strictatime tmpfs /newrun >/dev/null
+    if ! str_starts "$(readlink -f /bin/sh)" "/run"; then
+        mount -t tmpfs -o mode=0755,noexec,nosuid,nodev,strictatime tmpfs /newrun >/dev/null
+    else
+        # the initramfs is based in /run, so don't mount it with noexec
+        mount -t tmpfs -o mode=0755,nosuid,nodev,strictatime tmpfs /newrun >/dev/null
+    fi
     cp -a /run/* /newrun >/dev/null 2>&1
     mount --move /newrun /run
     rm -fr -- /newrun

  parent reply	other threads:[~2016-04-14 10:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-12 14:07 [PATCH] dracut: 99base: do not mount /run with the "noexec" option Guido Trentalancia
     [not found] ` <1460470060.3152.3.camel-D1bseh+SzQhuxeB9wqlrNw@public.gmane.org>
2016-04-12 14:24   ` Harald Hoyer
     [not found]     ` <570D0533.6070704-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-04-12 14:41       ` Guido Trentalancia
     [not found]         ` <1460472110.3152.14.camel-D1bseh+SzQhuxeB9wqlrNw@public.gmane.org>
2016-04-14 10:33           ` Harald Hoyer [this message]
     [not found]             ` <570F71FD.3020101-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-04-14 11:03               ` Dracut GitHub Import Bot
     [not found]                 ` <146063178363.23619.10614635055686320261.githubbot-QUxPd85Im3zrDilwLfPoKQ@public.gmane.org>
2016-04-14 11:46                   ` Guido Trentalancia
2016-04-14 11:18               ` Guido Trentalancia
     [not found]                 ` <1460632714.2782.3.camel-D1bseh+SzQhuxeB9wqlrNw@public.gmane.org>
2016-04-14 11:30                   ` Harald Hoyer
     [not found]                     ` <570F7F54.5050904-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-04-14 11:41                       ` [PATCH v2] " Guido Trentalancia
2016-04-12 15:07   ` [PATCH] " Guido Trentalancia

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=570F71FD.3020101@redhat.com \
    --to=harald-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=guido-D1bseh+SzQhuxeB9wqlrNw@public.gmane.org \
    --cc=initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.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