Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3525229pxf; Mon, 15 Mar 2021 11:29:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXVrdCNmbHuJuwtJgjc2ZGUmRCQXdZUJTbfrupaAHPlAqWXh2kEx9FRdX68srlrWMxlhBZ X-Received: by 2002:a17:906:9888:: with SMTP id zc8mr25656668ejb.310.1615832986797; Mon, 15 Mar 2021 11:29:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832986; cv=none; d=google.com; s=arc-20160816; b=AzZ6rE5TEROrCGoze5YpXDXW/kh2LdpRgiUexjMJevm6SoB6QL+tp6NzkreFVoNO3R KZ/nGgvn4DzeEZ74X0O2qO/87RczS9MG8coxj7IVmK9qe1MyEElQK5yr+F5sehCDXH9k nNm0XhwS7zAM1l7uUS8gF142zEPq0x39x5/sk4bygPJIUhxoq0jQiIM7RUoG8ND0M+tI vFzajsrWE3rIioqHXSkbwZXdjLy3rKStfbITyi8SOe23Zh7zALL5a+P3GsgpdII6xB02 tLG9SAKwYiupCGZrqBpKB/f+4NkBAtAst7QLe4hpO8Kx04q4G9JRhioYIOggtmjhPcjt o+RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=88DkqqAYX1zCdYhMyBm6M192H6Dic+xyGqh9eXNewzA=; b=uIipD/ayWWilmEuQqmArqo8+zvejkUqgu8QDfTraoDkwlul8DlntK+reGx+gZWySk8 y7jn30AtJ63bnZTZ0hi6981GTMQ/9i/2cgRU8j4HEnGKVoXy+ftHpSy6gi3m9uwi2tr/ l/2xCkmjeYECKJcwSoXT2PPLWkqxF/cWuSPYROKUuRSWJ+lE16347+d7z5ItKS+kkUem DQ+Pjg1TR9XUYTXKMXVTZO9ASU3V10Z61TEG8qZM29IZaILlFDuT4lyG5upt+hoEN2Eg h1RbNk8g98TttAgpRuTRNI1ntp73uzLSR88+Az+uyHKOvHuJ8Irxfqq4mVaWq083+9Oa X8Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qGR8Q++A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c1si11211042edt.469.2021.03.15.11.29.20; Mon, 15 Mar 2021 11:29:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qGR8Q++A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236037AbhCOOeX (ORCPT + 99 others); Mon, 15 Mar 2021 10:34:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:37582 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233408AbhCOOBj (ORCPT ); Mon, 15 Mar 2021 10:01:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CAC4664E4D; Mon, 15 Mar 2021 14:01:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816874; bh=/Ddd2zPl42t0KPISs+Dxeg/qgBi4KA8gGxKbfY4SnUE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qGR8Q++AJpaR5qaqdBApDgqF1xdqnpbGcgzC3/XIdr+5+C8VIs7xJhbk/Kv7npEkK QbWpNaam60Y4ZvDdpE8Wrs1PH/AamD6zlC/MFgt5On1zIzXIQTonAz6jLfjEvj8DSt 3sGWSoGaNVMDkmL9PNxryOdQE5HTFiCITKqsQUJw= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Eric W. Biederman" Subject: [PATCH 5.11 177/306] Revert 95ebabde382c ("capabilities: Dont allow writing ambiguous v3 file capabilities") Date: Mon, 15 Mar 2021 14:54:00 +0100 Message-Id: <20210315135513.599831367@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Eric W. Biederman commit 3b0c2d3eaa83da259d7726192cf55a137769012f upstream. It turns out that there are in fact userspace implementations that care and this recent change caused a regression. https://github.com/containers/buildah/issues/3071 As the motivation for the original change was future development, and the impact is existing real world code just revert this change and allow the ambiguity in v3 file caps. Cc: stable@vger.kernel.org Fixes: 95ebabde382c ("capabilities: Don't allow writing ambiguous v3 file capabilities") Signed-off-by: Eric W. Biederman Signed-off-by: Greg Kroah-Hartman --- security/commoncap.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) --- a/security/commoncap.c +++ b/security/commoncap.c @@ -500,8 +500,7 @@ int cap_convert_nscap(struct dentry *den __u32 magic, nsmagic; struct inode *inode = d_backing_inode(dentry); struct user_namespace *task_ns = current_user_ns(), - *fs_ns = inode->i_sb->s_user_ns, - *ancestor; + *fs_ns = inode->i_sb->s_user_ns; kuid_t rootid; size_t newsize; @@ -524,15 +523,6 @@ int cap_convert_nscap(struct dentry *den if (nsrootid == -1) return -EINVAL; - /* - * Do not allow allow adding a v3 filesystem capability xattr - * if the rootid field is ambiguous. - */ - for (ancestor = task_ns->parent; ancestor; ancestor = ancestor->parent) { - if (from_kuid(ancestor, rootid) == 0) - return -EINVAL; - } - newsize = sizeof(struct vfs_ns_cap_data); nscap = kmalloc(newsize, GFP_ATOMIC); if (!nscap)