Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9102084pxu; Mon, 28 Dec 2020 06:41:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJyy0FPaTAm1jE7KTBPnlY9BFsUpXvE8a33kwk7xXlTsbFLFPiHlG0j3AHb3OeZKxpNtYadS X-Received: by 2002:a17:906:7d98:: with SMTP id v24mr41954898ejo.129.1609166484249; Mon, 28 Dec 2020 06:41:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609166484; cv=none; d=google.com; s=arc-20160816; b=YPD7LWv6KOZ9biQl7QdXx/vgE1/Eqf8RK2oEBavTREY7nOAl+QZhS7LU+m7lBSL4xc CLOGNnf2WA6yJZXQHvrQ/MAStdTPgQ3FEi4d/b3UG9yHa7xfWcf0bvjsnhzvrpbFraHT uAhUGb+gQRvtmon8DjYM3xfIs9f5OIJvEX8ub9TVSlMuYb+S6dTOzDFtHtx3YI03w75M MHmIc6s9YjgLmLtK9qXbWBEK5txaZQwGlZWn3yR767E9iKxyO1sNp13+ST3GuJENb0yR 5Z432He8dnFugtHK+TG2sd6jvlMbyoulXTX97vxOSsYdKWG3e1Cj6+r/Ws5ykaEOA+gZ +sow== 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=VT2uo0wKunJplNVRzoQdpXHQXO2KwBTamMb9l9jOEwA=; b=dOGdXiRtcPH5alFHpjSw4B7addMV0XTlY/kHHVgG9goCGUpcFK1k6p1dt7nxGgVoch 9ixaUdLRHME/YI0B+xsyyu4k1TBRfPA+xa7PuioyjSYPRcOQ38dk/u1UhOFd/x6krXOs fwjDgjFvV2ImqT19aVKpHJsGMvcOvIv7q9e+hFWiQDfToxWYP1xKEkpatVUNIMYNfmr1 ci+iHRkAm90rl8sKfgXWQJSd2B46cTKcRJ/gC1+kbw+PI0dwvsDgmV5Ilb8FYeUdwKhR C9NCTWauY9zT30973MlAK2oy8Anc/y85jadr1T10AD5GflTgwAxm4LhdV0v4Ho6s1p70 llbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="bydR/I2B"; 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 s23si20650563eds.566.2020.12.28.06.41.00; Mon, 28 Dec 2020 06:41:24 -0800 (PST) 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="bydR/I2B"; 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 S2504660AbgL1OcU (ORCPT + 99 others); Mon, 28 Dec 2020 09:32:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:39626 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2504403AbgL1ObY (ORCPT ); Mon, 28 Dec 2020 09:31:24 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6BA0D22573; Mon, 28 Dec 2020 14:30:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165844; bh=1xvNz+z0lFAd+OY6z96kpeCbnLJPAUZvH3SSCJdjepc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bydR/I2BAjcFVSAAoPh2wYSiZAdiuvOLIFh3hJgCz1qd4DSeDxUHDIT6ZnHcYbwUZ mJGa+NZPx6El3r6SHMi5YoyzN4b7CUHN2JdxQ2DTtXSBhto2ZinmKyTt9riA8yMTA+ kN3vwM3+gSDF/Cw9JY+Cr/vSGOXXm7STvd2hyuLc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aleksa Sarai , Christian Brauner Subject: [PATCH 5.10 673/717] openat2: reject RESOLVE_BENEATH|RESOLVE_IN_ROOT Date: Mon, 28 Dec 2020 13:51:11 +0100 Message-Id: <20201228125053.220476023@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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: Aleksa Sarai commit 398840f8bb935d33c64df4ec4fed77a7d24c267d upstream. This was an oversight in the original implementation, as it makes no sense to specify both scoping flags to the same openat2(2) invocation (before this patch, the result of such an invocation was equivalent to RESOLVE_IN_ROOT being ignored). This is a userspace-visible ABI change, but the only user of openat2(2) at the moment is LXC which doesn't specify both flags and so no userspace programs will break as a result. Fixes: fddb5d430ad9 ("open: introduce openat2(2) syscall") Signed-off-by: Aleksa Sarai Acked-by: Christian Brauner Cc: # v5.6+ Link: https://lore.kernel.org/r/20201027235044.5240-2-cyphar@cyphar.com Signed-off-by: Christian Brauner Signed-off-by: Greg Kroah-Hartman --- fs/open.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/fs/open.c +++ b/fs/open.c @@ -1010,6 +1010,10 @@ inline int build_open_flags(const struct if (how->resolve & ~VALID_RESOLVE_FLAGS) return -EINVAL; + /* Scoping flags are mutually exclusive. */ + if ((how->resolve & RESOLVE_BENEATH) && (how->resolve & RESOLVE_IN_ROOT)) + return -EINVAL; + /* Deal with the mode. */ if (WILL_CREATE(flags)) { if (how->mode & ~S_IALLUGO)