From: Alexander Smirnov <asmirnov@ilbers.de>
To: Jan Kiszka <jan.kiszka@siemens.com>,
isar-users <isar-users@googlegroups.com>
Subject: Re: [PATCH 1/8] Mount devtmpfs read-only into chroot
Date: Tue, 20 Feb 2018 09:38:50 +0300 [thread overview]
Message-ID: <7e4d36c6-9556-6a69-9ffa-dfbc2e1744ba@ilbers.de> (raw)
In-Reply-To: <02a592150c34714e0729d4fc73f86ff031fee514.1518771143.git.jan.kiszka@siemens.com>
On 02/16/2018 11:52 AM, Jan Kiszka wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
>
> It's too easy to destroy the content of devtmpfs, which is shared with
> the host (including privileged container setups), by calling rm -rf on
> an output dir that still has devtmpfs mounted.
>
Just tested this:
builder@zbook:~/isar/build$ mkdir aaa
builder@zbook:~/isar/build$ mount -t devtmpfs -o mode=0755,nosuid,ro
devtmpfs aaa/
# Existing host /dev
[asmirnov@zbook patches]$ sudo rm /dev/ram16
OK
# RO mount point
builder@zbook:~/isar/build$ sudo rm aaa/ram15
rm: cannot remove ‘aaa/ram15’: Read-only file system
What I'm doing wrong?
BTW: started test build on server to check if problem with wheezy will go.
Alex
> To achieve write protection for device nodes, we can't mount devtmpfs
> directly in read-only mode as that will change all mounts to that mode.
> Luckily, doing a read-only bind-mount does the trick.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
> meta/classes/dpkg-base.bbclass | 2 +-
> meta/recipes-devtools/buildchroot/buildchroot.bb | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
> index 5eef11b..78709f9 100644
> --- a/meta/classes/dpkg-base.bbclass
> +++ b/meta/classes/dpkg-base.bbclass
> @@ -41,7 +41,7 @@ do_build() {
> if ! grep -q ${BUILDCHROOT_DIR}/isar-apt /proc/mounts; then \
> mount --bind ${DEPLOY_DIR_APT}/${DISTRO} ${BUILDCHROOT_DIR}/isar-apt; \
> mount --bind ${DL_DIR} ${BUILDCHROOT_DIR}/downloads; \
> - mount -t devtmpfs -o mode=0755,nosuid devtmpfs ${BUILDCHROOT_DIR}/dev; \
> + mount --bind -o ro /dev ${BUILDCHROOT_DIR}/dev; \
> mount -t proc none ${BUILDCHROOT_DIR}/proc; \
> fi'
>
> diff --git a/meta/recipes-devtools/buildchroot/buildchroot.bb b/meta/recipes-devtools/buildchroot/buildchroot.bb
> index 520daf9..1eca035 100644
> --- a/meta/recipes-devtools/buildchroot/buildchroot.bb
> +++ b/meta/recipes-devtools/buildchroot/buildchroot.bb
> @@ -66,7 +66,7 @@ do_build() {
> "${WORKDIR}/multistrap.conf.in" > "${WORKDIR}/multistrap.conf"
>
> sudo mount --bind ${DEPLOY_DIR_APT}/${DISTRO} ${BUILDCHROOT_DIR}/isar-apt
> - sudo mount -t devtmpfs -o mode=0755,nosuid devtmpfs ${BUILDCHROOT_DIR}/dev
> + sudo mount --bind -o ro /dev ${BUILDCHROOT_DIR}/dev
> sudo mount -t proc none ${BUILDCHROOT_DIR}/proc
>
> # Create root filesystem
>
--
With best regards,
Alexander Smirnov
ilbers GmbH
Baierbrunner Str. 28c
D-81379 Munich
+49 (89) 122 67 24-0
http://ilbers.de/
Commercial register Munich, HRB 214197
General manager: Baurzhan Ismagulov
next prev parent reply other threads:[~2018-02-20 6:38 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-16 8:52 [PATCH 0/8] Assorted patches Jan Kiszka
2018-02-16 8:52 ` [PATCH 1/8] Mount devtmpfs read-only into chroot Jan Kiszka
2018-02-19 10:09 ` Consolidate mounting in tasks (was Re: [PATCH 1/8] Mount devtmpfs read-only into chroot) Claudius Heine
2018-02-20 6:38 ` Alexander Smirnov [this message]
2018-02-20 7:02 ` [PATCH 1/8] Mount devtmpfs read-only into chroot Alexander Smirnov
2018-02-20 7:03 ` Jan Kiszka
2018-02-20 8:18 ` Claudius Heine
2018-02-16 8:52 ` [PATCH 2/8] isar-events: Wait for failing umounts Jan Kiszka
2018-02-19 9:45 ` Alexander Smirnov
2018-02-19 9:48 ` Jan Kiszka
2018-02-19 10:03 ` Alexander Smirnov
2018-02-19 11:10 ` Jan Kiszka
2018-02-16 8:52 ` [PATCH 3/8] isar-events: Do not match on distro and arch Jan Kiszka
2018-02-19 9:54 ` Alexander Smirnov
2018-02-19 11:08 ` Jan Kiszka
2018-02-16 8:52 ` [PATCH 4/8] Add Debian arm64 support to the core Jan Kiszka
2018-02-16 8:52 ` [PATCH 5/8] Add qemuarm64-stretch multiconfig Jan Kiszka
2018-02-19 10:23 ` Alexander Smirnov
2018-02-19 11:15 ` Jan Kiszka
2018-02-19 12:19 ` Alexander Smirnov
2018-02-19 12:36 ` Jan Kiszka
2018-02-16 8:52 ` [PATCH 6/8] Add qemuarm64-stretch to CI Jan Kiszka
2018-02-16 8:52 ` [PATCH 7/8] build-kernel.sh: Add copyright header Jan Kiszka
2018-02-16 8:52 ` [PATCH 8/8] Enhance credits Jan Kiszka
2018-02-19 13:56 ` [PATCH 0/8] Assorted patches Alexander Smirnov
2018-02-19 14:08 ` Jan Kiszka
2018-02-19 14:19 ` Alexander Smirnov
2018-02-20 11:19 ` Alexander Smirnov
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=7e4d36c6-9556-6a69-9ffa-dfbc2e1744ba@ilbers.de \
--to=asmirnov@ilbers.de \
--cc=isar-users@googlegroups.com \
--cc=jan.kiszka@siemens.com \
/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