Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4961429ybi; Tue, 30 Jul 2019 11:12:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqy3j81jeUJ/dHCGRZi07hYE1lQIlhn8z7fobUvecsqER4y9MkuuBvGb7NqfR/aykkwb/ZJ3 X-Received: by 2002:a63:6888:: with SMTP id d130mr37320827pgc.197.1564510330541; Tue, 30 Jul 2019 11:12:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564510330; cv=none; d=google.com; s=arc-20160816; b=b3NwDO3pDmPV6a6F9vjKmsBOq8fRsHh6ivZbAhjZjpUyV5cwkBHH9H7YsCN+inHn1w dRAEyqgl/z70n+7ysEPGBemIKJ1K0FA0LmBtkb0D37/3WU5KEWcQ9JbCMffnnr3tW8sM mgFg75PWwAeh3bfeSSq+OaWxdSinu7nsTFbjAhstYMP7x/135kdD3kxhbEfPw86d4M/0 pPuNCseWYrYu86DVEGfLWm9qVEQK/huUDGul4+QGUchE7tOKBo5Z/+iPtV5Ull8ebA2R gyQDVxZTRyTJtY3tyu+4oOCZ+TBzlvluUzPbdSx6d4sOtVXok/eZk6wwDBe5teF6Z5WS Vf3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=4RdmJMzJpJkE1tpwAcBC2lO5tLyCjdp9GTuTXQPYwuU=; b=wCs3xTec9tKLjiMAH9gzZPj3f45PJBv5z9fVeeW9WzkymnoK3Mtpxl2wf6x95rj2d4 8Hhn364hN3ZDQUqocGpvRUVrRa4+xqg6gSy6QoKzIOnIWlvzx53ZdDgFO4s3dlzZVyTL Nwpx/bE9Ge6FvQQau5q2+NEpTmZ2ggdun/XtAZdCuYSBuTlnOIRJ0GnfXFT5REEa8Gkh U4Gzfz9UOrWenrJ0smbvvXtuVl+RV4yKqizXbGhcKymj8LdgpaAdbP1NPVu52uyaSo2N V8WB9UCOMZOu9UQdfXNazLpmj/7w97vNH7TFNlmlGuDvuWZ7NotSorCEx3c3Bjq2TKq9 PaCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=QAyuPC1x; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=android.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v8si27858779plo.384.2019.07.30.11.11.55; Tue, 30 Jul 2019 11:12:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=QAyuPC1x; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=android.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728974AbfG3R3M (ORCPT + 99 others); Tue, 30 Jul 2019 13:29:12 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:34998 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728271AbfG3R3M (ORCPT ); Tue, 30 Jul 2019 13:29:12 -0400 Received: by mail-pf1-f194.google.com with SMTP id u14so30218637pfn.2 for ; Tue, 30 Jul 2019 10:29:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4RdmJMzJpJkE1tpwAcBC2lO5tLyCjdp9GTuTXQPYwuU=; b=QAyuPC1xGgz2u4jqn8ZOqROMWt1+hlxJq/wFESXFu+V2ivcy4DD8nbNlM2uQeZLRPY DO05rDvTm4wx+czIKgMNOM5luBifS2uQyT89Mupk/c2+P0RBaUhdLM+McSHZfDPmGht6 OD6k7FOwQYA7OrVOa+0s0CPKSixxquxU38pOd6ZhNbzX7yfNkYEMPJXvsjK6DuaLRRfk bSFe6gvHEcaEJO2djvEuQqYkWI1HulSz4wNMhM7LWVsBBrbFdSJqjV62eGD8e1D/iF1R HQlzGPY0X6bzWvPfRVxr2vPlCU2AoHtLdkRwmlLaNoyBpz9KTQxRpm2zeiSWp8w/SECX X5pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4RdmJMzJpJkE1tpwAcBC2lO5tLyCjdp9GTuTXQPYwuU=; b=ti6O7lCwlIBOHolSl8cr7UsqjerGItO0kgRNojQ0ugUeBEc99RVPokQAFzf53HBNv7 yxrpPqvXhatA2ynH+dlB5U49eJA0dVkhrh67eG5gscwMJlUoZH9FwCL40dUzL9Cc9TzF 4xC8WWeuETZXVHnopcLQZCMGiV29d2eX2es5Wwahyxd16u5pl0RXXxxGe6XCLAZx62D8 MfFufJ+terGZDpan3tveCgta+QnwdUfeQEACHBsdypU5+N+IqpeuU6mlsZxmntiYAAPY qQroiZgZIeTJKc5dadYX+R0jCS+DThmr0T3QbVG27kD6nTOGgVRzKCKDgAERp6v/rc24 +VZg== X-Gm-Message-State: APjAAAV4DNl9vzGzy/yxxNmXK90PotgYRs834HTlB9YSiBEAtICFSnwJ PWgqFLImMkHbpIJNRMBHKPchZWbJ2s4= X-Received: by 2002:a63:c442:: with SMTP id m2mr111810644pgg.286.1564507750887; Tue, 30 Jul 2019 10:29:10 -0700 (PDT) Received: from nebulus.mtv.corp.google.com ([2620:15c:211:200:5404:91ba:59dc:9400]) by smtp.gmail.com with ESMTPSA id o129sm39856293pfg.1.2019.07.30.10.29.09 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 30 Jul 2019 10:29:10 -0700 (PDT) From: Mark Salyzyn To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, Mark Salyzyn , Miklos Szeredi , Jonathan Corbet , Vivek Goyal , "Eric W . Biederman" , Amir Goldstein , Randy Dunlap , Stephen Smalley , linux-unionfs@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v12 0/5] overlayfs override_creds=off Date: Tue, 30 Jul 2019 10:28:57 -0700 Message-Id: <20190730172904.79146-1-salyzyn@android.com> X-Mailer: git-send-email 2.22.0.770.g0f2c4a37fd-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Patch series: overlayfs: check CAP_DAC_READ_SEARCH before issuing exportfs_decode_fh Add flags option to get xattr method paired to __vfs_getxattr overlayfs: handle XATTR_NOSECURITY flag for get xattr method overlayfs: internal getxattr operations without sepolicy checking overlayfs: override_creds=off option bypass creator_cred The first four patches address fundamental security issues that should be solved regardless of the override_creds=off feature. on them). The fifth adds the feature depends on these other fixes. By default, all access to the upper, lower and work directories is the recorded mounter's MAC and DAC credentials. The incoming accesses are checked against the caller's credentials. If the principles of least privilege are applied for sepolicy, the mounter's credentials might not overlap the credentials of the caller's when accessing the overlayfs filesystem. For example, a file that a lower DAC privileged caller can execute, is MAC denied to the generally higher DAC privileged mounter, to prevent an attack vector. We add the option to turn off override_creds in the mount options; all subsequent operations after mount on the filesystem will be only the caller's credentials. The module boolean parameter and mount option override_creds is also added as a presence check for this "feature", existence of /sys/module/overlay/parameters/overlay_creds Signed-off-by: Mark Salyzyn Cc: Miklos Szeredi Cc: Jonathan Corbet Cc: Vivek Goyal Cc: Eric W. Biederman Cc: Amir Goldstein Cc: Randy Dunlap Cc: Stephen Smalley Cc: linux-unionfs@vger.kernel.org Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- v12: - Restore squished out patch 2 and 3 in the series, then change algorithm to add flags argument. Per-thread flag is a large security surface. v11: - Squish out v10 introduced patch 2 and 3 in the series, then and use per-thread flag instead for nesting. - Switch name to ovl_do_vds_getxattr for __vds_getxattr wrapper. - Add sb argument to ovl_revert_creds to match future work. v10: - Return NULL on CAP_DAC_READ_SEARCH - Add __get xattr method to solve sepolicy logging issue - Drop unnecessary sys_admin sepolicy checking for administrative driver internal xattr functions. v6: - Drop CONFIG_OVERLAY_FS_OVERRIDE_CREDS. - Do better with the documentation, drop rationalizations. - pr_warn message adjusted to report consequences. v5: - beefed up the caveats in the Documentation - Is dependent on "overlayfs: check CAP_DAC_READ_SEARCH before issuing exportfs_decode_fh" "overlayfs: check CAP_MKNOD before issuing vfs_whiteout" - Added prwarn when override_creds=off v4: - spelling and grammar errors in text v3: - Change name from caller_credentials / creator_credentials to the boolean override_creds. - Changed from creator to mounter credentials. - Updated and fortified the documentation. - Added CONFIG_OVERLAY_FS_OVERRIDE_CREDS v2: - Forward port changed attr to stat, resulting in a build error. - altered commit message.