From c02f4b604f2efbf528de5e6f12ea2beed60efafc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A5=D0=B8=D1=80=D0=B5=D1=86=D0=BA=D0=B8=D0=B9=20=D0=9C?= =?UTF-8?q?=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Tue, 1 Mar 2016 15:01:13 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=B7=D0=B0=D0=B2=D0=B8=D1=81=D0=B8=D0=BC=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D0=B8=20calculate-sources,=20=D0=BE=D0=B1=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D0=BB=D1=91=D0=BD=20=D0=BF=D0=B0=D1=82=D1=87=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20overlayfs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...nel-6.eclass => calculate-kernel-7.eclass} | 27 +++-- .../4.4/4300-overlayfs_whiteout.patch | 110 ++++++++++++++---- sys-kernel/calculate-sources/Manifest | 1 - .../calculate-sources-3.18.27.ebuild | 20 +--- .../calculate-sources-4.1.18.ebuild | 22 +--- .../calculate-sources-4.4.1.ebuild | 36 ------ .../calculate-sources-4.4.3.ebuild | 24 +--- 7 files changed, 118 insertions(+), 122 deletions(-) rename eclass/{calculate-kernel-6.eclass => calculate-kernel-7.eclass} (90%) delete mode 100644 sys-kernel/calculate-sources/calculate-sources-4.4.1.ebuild diff --git a/eclass/calculate-kernel-6.eclass b/eclass/calculate-kernel-7.eclass similarity index 90% rename from eclass/calculate-kernel-6.eclass rename to eclass/calculate-kernel-7.eclass index c63228c86..d7a6705fe 100644 --- a/eclass/calculate-kernel-6.eclass +++ b/eclass/calculate-kernel-7.eclass @@ -10,10 +10,21 @@ inherit calculate eutils kernel-2 EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst -IUSE="vmlinuz minimal" +IUSE="+vmlinuz minimal themes firmware +grub" -REQUIRED_USE="minimal? ( vmlinuz )" -RDEPEND="vmlinuz? ( sys-kernel/dracut app-arch/lz4 )" +REQUIRED_USE="minimal? ( vmlinuz ) + grub? ( vmlinuz )" + + +DEPEND="vmlinuz? ( || ( app-arch/xz-utils app-arch/lzma-utils ) + sys-apps/v86d + grub? ( sys-boot/grub ) + ) + firmware? ( sys-kernel/linux-firmware ) + themes? ( media-gfx/splash-themes-calculate ) + " + +RDEPEND="${DEPEND} vmlinuz? ( sys-kernel/dracut app-arch/lz4 )" detect_version detect_arch @@ -29,14 +40,14 @@ KV_FULL="${PV}${EXTRAVERSION}" S="${WORKDIR}/linux-${KV_FULL}" -calculate-kernel-6_pkg_setup() { +calculate-kernel-7_pkg_setup() { kernel-2_pkg_setup eqawarn "!!! WARNING !!! WARNING !!! WARNING !!! WARNING !!!" eqawarn "After the kernel assemble perform command to update modules:" eqawarn " emerge @modules-rebuild" } -calculate-kernel-6_src_unpack() { +calculate-kernel-7_src_unpack() { kernel-2_src_unpack cd ${S} local GENTOOARCH="${ARCH}" @@ -63,7 +74,7 @@ vmlinuz_src_compile() { ARCH="${GENTOOARCH}" } -calculate-kernel-6_src_compile() { +calculate-kernel-7_src_compile() { use vmlinuz && vmlinuz_src_compile } @@ -133,7 +144,7 @@ clean_for_minimal() { rm -r Documentation } -calculate-kernel-6_src_install() { +calculate-kernel-7_src_install() { use vmlinuz && vmlinuz_src_install use minimal && clean_for_minimal kernel-2_src_install @@ -159,7 +170,7 @@ vmlinuz_pkg_postinst() { calculate_update_modules } -calculate-kernel-6_pkg_postinst() { +calculate-kernel-7_pkg_postinst() { kernel-2_pkg_postinst KV_OUT_DIR=${ROOT}/usr/src/linux-${KV_FULL} diff --git a/profiles/templates/3.3/6_ac_install_patch/sys-kernel/calculate-sources/4.4/4300-overlayfs_whiteout.patch b/profiles/templates/3.3/6_ac_install_patch/sys-kernel/calculate-sources/4.4/4300-overlayfs_whiteout.patch index d9bf7decf..dc73bd84f 100644 --- a/profiles/templates/3.3/6_ac_install_patch/sys-kernel/calculate-sources/4.4/4300-overlayfs_whiteout.patch +++ b/profiles/templates/3.3/6_ac_install_patch/sys-kernel/calculate-sources/4.4/4300-overlayfs_whiteout.patch @@ -1,32 +1,94 @@ # Calculate format=diff +After rename file dentry still holds reference to lower dentry from +previous location. This doesn't matter for data access because data +cames from upper dentry. But this stale lower dentry taints dentry +at new location and turns it into non-pure upper. Such file leaves +visible whiteout entry after remove in directory which shouldn't +have whiteouts at all. + +Overlayfs already tracks pureness of file location in oe->opaque. +This patch just uses that for detecting actual path type. + +Comment from Vivek Goyal's patch: + +Here are the details of the problem. Do following. + +$ mkdir upper lower work merged upper/dir/ +$ touch lower/test +$ sudo mount -t overlay overlay -olowerdir=lower,upperdir=upper,workdir=work +merged +$ mv merged/test merged/dir/ +$ rm merged/dir/test +$ ls -l merged/dir/ +/usr/bin/ls: cannot access merged/dir/test: No such file or directory +total 0 +c????????? ? ? ? ? ? test +Basic problem seems to be that once a file has been unlinked, a +whiteout has been left behind which was not needed and hence it becomes +visible. + +whiteout is visible because parent dir is of not type MERGE, hence +od->is_real is set during ovl_dir_open(). And that means ovl_iterate() +passes on iterate handling directly to underlying fs. Underlying fs does +not know/filter whiteouts so it becomes visible to user. + +Why did we leave a whiteout to begin with when we should not have. +ovl_do_remove() checks for OVL_TYPE_PURE_UPPER() and does not leave +whiteout if file is pure upper. In this case file is not found to be +pure upper hence whiteout is left. + +So why file was not PURE_UPPER in this case? I think because dentry is +still carrying some leftover state which was valid before rename. For example, +od->numlower was set to 1 as it was a lower file. After rename, this state +is not valid anymore as there is no such file in lower. + +Signed-off-by: Konstantin Khlebnikov +Reported-by: Viktor Stanchev +Diagnosed-by: Vivek Goyal +Link: https://bugzilla.kernel.org/show_bug.cgi?id=109611 +--- + fs/overlayfs/dir.c | 7 +++++++ + fs/overlayfs/super.c | 12 +++++++----- + 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c -index 692ceda..a2fd06b 100644 +index ed95272d57a6..edf83f325bca 100644 --- a/fs/overlayfs/dir.c +++ b/fs/overlayfs/dir.c -@@ -637,7 +637,7 @@ static inline int ovl_check_sticky(struct dentry *dentry) +@@ -903,6 +903,13 @@ static int ovl_rename2(struct inode *olddir, struct dentry *old, + if (!overwrite && new_is_dir && !old_opaque && new_opaque) + ovl_remove_opaque(newdentry); - static int ovl_do_remove(struct dentry *dentry, bool is_dir) - { -- enum ovl_path_type type; -+ enum ovl_path_type type, parent_type; - int err; - - err = ovl_check_sticky(dentry); -@@ -653,7 +653,16 @@ static int ovl_do_remove(struct dentry *dentry, bool is_dir) - goto out_drop_write; - - type = ovl_path_type(dentry); -- if (OVL_TYPE_PURE_UPPER(type)) { -+ parent_type = ovl_path_type(dentry->d_parent); -+ + /* -+ * After rename if a file is removed, it could have out of sync -+ * numlower and forced "opaque" set which means file will not be -+ * categorized as pure upper. So if parent is not type merge, then -+ * it is not present in any of the lower so there should not be -+ * any need to leave whiteout. ++ * Old dentry now lives in different location. Dentries in ++ * lowerstack are stale. We cannot drop them here because ++ * access to them is lockless. This could be only pure upper ++ * or opaque directory - numlower is zero. Or upper non-dir ++ * entry - its pureness is tracked by flag opaque. + */ -+ if (OVL_TYPE_PURE_UPPER(type) || !OVL_TYPE_MERGE(parent_type)) { - err = ovl_remove_upper(dentry, is_dir); + if (old_opaque != new_opaque) { + ovl_dentry_set_opaque(old, new_opaque); + if (!overwrite) +diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c +index 8d826bd56b26..ba28b007005e 100644 +--- a/fs/overlayfs/super.c ++++ b/fs/overlayfs/super.c +@@ -76,12 +76,14 @@ enum ovl_path_type ovl_path_type(struct dentry *dentry) + if (oe->__upperdentry) { + type = __OVL_PATH_UPPER; + +- if (oe->numlower) { +- if (S_ISDIR(dentry->d_inode->i_mode)) +- type |= __OVL_PATH_MERGE; +- } else if (!oe->opaque) { ++ /* ++ * Non-dir dentry can hold lower dentry from previous ++ * location. Its purity depends only on opaque flag. ++ */ ++ if (oe->numlower && S_ISDIR(dentry->d_inode->i_mode)) ++ type |= __OVL_PATH_MERGE; ++ else if (!oe->opaque) + type |= __OVL_PATH_PURE; +- } } else { - const struct cred *old_cred; + if (oe->numlower > 1) + type |= __OVL_PATH_MERGE; diff --git a/sys-kernel/calculate-sources/Manifest b/sys-kernel/calculate-sources/Manifest index 3a1c11378..3b16d18b1 100644 --- a/sys-kernel/calculate-sources/Manifest +++ b/sys-kernel/calculate-sources/Manifest @@ -3,5 +3,4 @@ DIST linux-4.1.tar.xz 83017828 SHA256 caf51f085aac1e1cea4d00dbbf3093ead07b551fc0 DIST linux-4.4.tar.xz 87295988 SHA256 401d7c8fef594999a460d10c72c5a94e9c2e1022f16795ec51746b0d165418b2 SHA512 13c8459933a8b80608e226a1398e3d1848352ace84bcfb7e6a4a33cb230bbe1ab719d4b58e067283df91ce5311be6d2d595fc8c19e2ae6ecc652499415614b3e WHIRLPOOL 02abc203d867404b9934aaa4c1e5b5dcbb0b0021e91a03f3a7e7fd224eed106821d8b4949f32a590536db150e5a88c16fcde88538777a26d0c17900f0257b1bc DIST patch-3.18.27.xz 780340 SHA256 5ab0f1f24a494fc8d208d9d1efb2d7d516f99a320b05a3201fa39706fd33473e SHA512 a0ddeda9fe9905743afd3475dcb8eed6602d959afaa50684c585ba0e84a34ecd66a3cdeeebdbf61094c32b731cf3f98cd0e96904c3327ed8be20982a1bcc3208 WHIRLPOOL f75e9c2c678b4e8cb71a53b1c14774c454e4c2a941f9b597b27b09649ed8958bdef872a4b542096c9388283cd8722541acba03646ce2787c4e48c27d1e43009f DIST patch-4.1.18.xz 547140 SHA256 c69cbff479740d6bbd452d2264ba0afefa99ae51bb7ae52bfbde348ea8d8b20c SHA512 b95b82452206c2ef19e9fb1b01dcd6880c74f1b1fb9d8e1f209add734ba342d7c65401f3a4a2101eaa6b20b653b265ebc863052de71e01fa886ff7d7b1c1ad17 WHIRLPOOL 3a47222b9349ebfe8820e79b70c50c145283a31c01d3a63b6ae08ee0a008ee85a408c44aa1711fc1dd808d9c7ccf090fee35b23abe9d85bc34650e7db39986e7 -DIST patch-4.4.1.xz 23612 SHA256 c0218043e61da3921cd14579ae4a8774a6fdad91667a9fdb851d0a35f62edb48 SHA512 b117b6f88dd713a33691306e483d5c42bcf61091d91f7248e1537ac7f7b96380f5f7df81f399cecda13d9388ad7aa52ed2e6d46f7b27706d2f197b8e64c330b3 WHIRLPOOL 988a5cd6fc39577eda1baae93fda94deab93fa6d5245aa90f3c6ae032151b1a9e23458ee822d558643f23e0aabf1bd5962d36a72180a04bcecba74287ace776a DIST patch-4.4.3.xz 99576 SHA256 4a24c79c40b2cb820ce9f22d44f31edcbde5971432753ab0289772946ed05b7b SHA512 8477ecd07d06bc6c6d75dc95027920e1f41128fa8a6b382377d7a0a64ccbca719a464ef64397a3715e7ffe400640c6590ab5da691690472d1f9311ed82041d50 WHIRLPOOL 8f2c775d79731e32ed5ed3f50f3a5dd5a2a81e991a11e1d2234622bd20ccd9df3f8dcf1049f36f555238af7d7b457df738bb30e9766ff8ae5f3f4153e8078773 diff --git a/sys-kernel/calculate-sources/calculate-sources-3.18.27.ebuild b/sys-kernel/calculate-sources/calculate-sources-3.18.27.ebuild index f6a1deaee..bacb7052d 100644 --- a/sys-kernel/calculate-sources/calculate-sources-3.18.27.ebuild +++ b/sys-kernel/calculate-sources/calculate-sources-3.18.27.ebuild @@ -2,33 +2,21 @@ # Distributed under the terms of the GNU General Public License v2 # $Header: $ -EAPI=4 +EAPI=5 ETYPE="sources" -inherit calculate-kernel-6 eutils +inherit calculate-kernel-7 eutils DESCRIPTION="Calculate Linux kernel image" KEYWORDS="~amd64 ~x86" HOMEPAGE="http://www.calculate-linux.org" -IUSE="themes firmware" - -DEPEND="vmlinuz? ( || ( app-arch/xz-utils app-arch/lzma-utils ) - sys-apps/v86d - sys-boot/grub - ) - firmware? ( sys-kernel/linux-firmware ) - themes? ( media-gfx/splash-themes-calculate ) - " - -RDEPEND="${DEPEND}" - SRC_URI="${KERNEL_URI} ${ARCH_URI}" src_unpack() { - calculate-kernel-6_src_unpack + calculate-kernel-7_src_unpack } pkg_postinst() { - calculate-kernel-6_pkg_postinst + calculate-kernel-7_pkg_postinst } diff --git a/sys-kernel/calculate-sources/calculate-sources-4.1.18.ebuild b/sys-kernel/calculate-sources/calculate-sources-4.1.18.ebuild index d4d462fd4..bacb7052d 100644 --- a/sys-kernel/calculate-sources/calculate-sources-4.1.18.ebuild +++ b/sys-kernel/calculate-sources/calculate-sources-4.1.18.ebuild @@ -2,35 +2,21 @@ # Distributed under the terms of the GNU General Public License v2 # $Header: $ -EAPI=4 +EAPI=5 ETYPE="sources" -inherit calculate-kernel-6 eutils +inherit calculate-kernel-7 eutils DESCRIPTION="Calculate Linux kernel image" KEYWORDS="~amd64 ~x86" HOMEPAGE="http://www.calculate-linux.org" -IUSE="themes firmware" - -DEPEND="vmlinuz? ( || ( app-arch/xz-utils app-arch/lzma-utils ) - sys-apps/v86d - sys-boot/grub - ) - firmware? ( sys-kernel/linux-firmware ) - themes? ( media-gfx/splash-themes-calculate ) - " - -RDEPEND="${DEPEND} -!