Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4679373pxu; Wed, 21 Oct 2020 02:29:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPE1Fh+q6tVKqVTzkRqTcMyr2NwUuhea4LFq0a1PCJgPlj1f2AihvuNPKKhRz9lRS5B3ri X-Received: by 2002:a17:906:7e47:: with SMTP id z7mr2423627ejr.418.1603272578674; Wed, 21 Oct 2020 02:29:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603272578; cv=none; d=google.com; s=arc-20160816; b=ZGrjM5pjy4+7LCCxD7NhY0SS+nfZkuA/71RoVx+SLuFidEPF2gvUA+saXMjILNswzT G71vqJt+hb2uNKNI3KE9CqC9hcXZyDGhqYHFZGteRMpAjFn+YDYDl4F2hoYDTQoxukCg euxibDUW7n6nlRqrGgDnKA4pjpzuMUeJc0s13HGl0wLzwvadh+FJp3x/8EHe+3cvfVG6 06113jqnZZr+ayzLq+36VTvs83oHd7SpXndQ1cOnM8HypCjcl0+hSjQnem14Ngai/2J5 3ENomqfP6eWlAhNKyisY2iE0gWYyrWaf/mCfDVE13PBZaSb1WWbsKyUm2degPZDX6Nj3 lTMA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=40suxBClyF8Di6DQt+UKjev7N9m+bLbT6C7IbLRaEmQ=; b=FJcuPF7ji7YFOO+t+Cd2CWvO9QB2C1yZlr+6NaNWR41cq6AiRjWmN8YP46V5HyEcym aiIvBj+oHfxIUpFwQ4qr/PaVTt1TA95M24B3vVEGJlLIMOoGB0f5XYNtkWqz2yg2ONoG pCzuWmafBukKSuDC6CHtM5UpT2GtNOhxKDw0oB4e3EWzHIccSvtpm+N/ZahgITtNnjxF dCIpGfQL+i6TFIQT3lpZZLNCjBdtqtx8jYwhm6UHqes+SePzIrBJiioYCad00OtDqmxQ QoGt+EaCCZiE9YpEjvxSsEKFe2ieiKNT1pCsrSPhbu7pMmh2B1QjhzNZOxMyhAXbfnGd SgsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=fpmWyaUC; 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=REJECT sp=REJECT dis=NONE) header.from=android.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y9si921408ejq.143.2020.10.21.02.29.15; Wed, 21 Oct 2020 02:29:38 -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=@android.com header.s=20161025 header.b=fpmWyaUC; 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=REJECT sp=REJECT dis=NONE) header.from=android.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390945AbgJTTRr (ORCPT + 99 others); Tue, 20 Oct 2020 15:17:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390853AbgJTTRq (ORCPT ); Tue, 20 Oct 2020 15:17:46 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C749BC0613CE for ; Tue, 20 Oct 2020 12:17:46 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id gv6so1455938pjb.4 for ; Tue, 20 Oct 2020 12:17:46 -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=40suxBClyF8Di6DQt+UKjev7N9m+bLbT6C7IbLRaEmQ=; b=fpmWyaUCWWlb0Awn430c7GHDpZ4SNJ6+4xMApF0LtG5+rMmk6wV4PJR3pKTF3HhdvP /sRGVLnLXB54irACy7tkB1KrtKROemnUVp5kSRGLfS/vJTebcTp0ygQolXx/wUu7z9do zNOS9LmbOWmQEt+GXUE+Zp7qNGGDwU1LFzOWbLtyA9BZl5xeayTWp62ZajOQxZtjZl40 sNbZ5yenLsRqO+4fymtQq1u3vh+NUShe7xqrL7OoRzd3jVzsUDvmffwhMbutRatu8rhz 1+Ondnllvy/J2F8MyZUL8D61nERasqAOfalUXz5KqvmUfhqYFe0tnrVXkl1EIUizfed8 ax/Q== 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=40suxBClyF8Di6DQt+UKjev7N9m+bLbT6C7IbLRaEmQ=; b=SJ5hf6M2QOGvEa5z8vwvGrDCRDXy1inircuBctwI+X6PMsjdVaKOuL0u7NEwRfVULU ygzg3EtkTix2+HkaV1jqdsJ9ncL2CxAsoaXl2lEnjdvl+9I1HFG1OSQQ004kiVyq1WNC 94mYXohR3cXjepm0BpR1PqpfLvca5gChIkTkDDY/+q0T3UwoXtlGA1GziOaQF/H+udW6 3QeG0uFIaKvMOxc6Iutjt0WidZ+f+wf0I0SqobzJYER7Hr1k4PEf4NBN7DcM33Wmbcsm yeUalujAa/xvXG66zMFs1K3lKI/MbJwus2zS417EpYtxoCMdub+lRd+clIf8qCIR4y7+ vOew== X-Gm-Message-State: AOAM531SuzrDpaAlr37v/XHpNvHMEGzD0zekTpcP9/S+OpnxPSoORqJs qa72nq8JS/65jjLpessrlT+ATnpk/gJ31A== X-Received: by 2002:a17:90a:ce8b:: with SMTP id g11mr4048979pju.94.1603221465962; Tue, 20 Oct 2020 12:17:45 -0700 (PDT) Received: from nebulus.mtv.corp.google.com ([2620:15c:211:200:4a0f:cfff:fe35:d61b]) by smtp.gmail.com with ESMTPSA id 204sm2855995pfz.74.2020.10.20.12.17.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 12:17:45 -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 , John Stultz , linux-doc@vger.kernel.org, linux-security-module@vger.kernel.org Subject: [PATCH v17 0/4] overlayfs override_creds=off & nested get xattr fix Date: Tue, 20 Oct 2020 12:17:28 -0700 Message-Id: <20201020191732.4049987-1-salyzyn@android.com> X-Mailer: git-send-email 2.29.0.rc1.297.gfa9743e501-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Mark Salyzyn (3): Add flags option to get xattr method paired to __vfs_getxattr overlayfs: handle XATTR_NOSECURITY flag for get xattr method overlayfs: override_creds=off option bypass creator_cred Mark Salyzyn + John Stultz (1): overlayfs: inode_owner_or_capable called during execv The first three patches address fundamental security issues that should be solved regardless of the override_creds=off feature. The fourth 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: John Stultz Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org To: linux-fsdevel@vger.kernel.org To: linux-unionfs@vger.kernel.org Cc: linux-security-module@vger.kernel.org Cc: kernel-team@android.com --- v17 - correct some zero-day build failrues - fix up documentation v16 - rebase and merge of two patches. - add adjustment to deal with execv when overrides is off. v15 - Revert back to v4 with fixes from on the way from v5-v14. The single structure argument passing to address the complaints about too many arguments was rejected by the community. - Drop the udner discussion fix for an additional CAP_DAC_READ_SEARCH check. Can address that independently. - ToDo: upstream test frame for thes security fixes (currently testing is all in Android). v14: - Rejoin, rebase and a few adjustments. v13: - Pull out first patch and try to get it in alone feedback, some Acks, and then because people forgot why we were doing i. 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. Documentation/filesystems/locking.rst | 2 +- Documentation/filesystems/overlayfs.rst | 26 +++++++++++++++++- fs/9p/acl.c | 3 ++- fs/9p/xattr.c | 3 ++- fs/afs/xattr.c | 10 +++---- fs/btrfs/xattr.c | 3 ++- fs/ceph/xattr.c | 3 ++- fs/cifs/xattr.c | 2 +- fs/ecryptfs/inode.c | 6 +++-- fs/ecryptfs/mmap.c | 2 +- fs/erofs/xattr.c | 3 ++- fs/ext2/xattr_security.c | 2 +- fs/ext2/xattr_trusted.c | 2 +- fs/ext2/xattr_user.c | 2 +- fs/ext4/xattr_hurd.c | 2 +- fs/ext4/xattr_security.c | 2 +- fs/ext4/xattr_trusted.c | 2 +- fs/ext4/xattr_user.c | 2 +- fs/f2fs/xattr.c | 4 +-- fs/fuse/xattr.c | 4 +-- fs/gfs2/xattr.c | 3 ++- fs/hfs/attr.c | 2 +- fs/hfsplus/xattr.c | 3 ++- fs/hfsplus/xattr_security.c | 3 ++- fs/hfsplus/xattr_trusted.c | 3 ++- fs/hfsplus/xattr_user.c | 3 ++- fs/jffs2/security.c | 3 ++- fs/jffs2/xattr_trusted.c | 3 ++- fs/jffs2/xattr_user.c | 3 ++- fs/jfs/xattr.c | 5 ++-- fs/kernfs/inode.c | 3 ++- fs/nfs/nfs4proc.c | 9 ++++--- fs/ocfs2/xattr.c | 9 ++++--- fs/orangefs/xattr.c | 3 ++- fs/overlayfs/copy_up.c | 2 +- fs/overlayfs/dir.c | 17 +++++++----- fs/overlayfs/file.c | 26 +++++++++--------- fs/overlayfs/inode.c | 23 ++++++++-------- fs/overlayfs/namei.c | 6 ++--- fs/overlayfs/overlayfs.h | 7 +++-- fs/overlayfs/ovl_entry.h | 1 + fs/overlayfs/readdir.c | 8 +++--- fs/overlayfs/super.c | 34 ++++++++++++++++++----- fs/overlayfs/util.c | 13 +++++++-- fs/posix_acl.c | 2 +- fs/reiserfs/xattr_security.c | 3 ++- fs/reiserfs/xattr_trusted.c | 3 ++- fs/reiserfs/xattr_user.c | 3 ++- fs/squashfs/xattr.c | 2 +- fs/ubifs/xattr.c | 3 ++- fs/xattr.c | 36 ++++++++++++------------- fs/xfs/xfs_xattr.c | 3 ++- include/linux/xattr.h | 9 ++++--- include/uapi/linux/xattr.h | 7 +++-- mm/shmem.c | 3 ++- net/socket.c | 3 ++- security/commoncap.c | 6 +++-- security/integrity/evm/evm_main.c | 3 ++- security/selinux/hooks.c | 11 +++++--- security/smack/smack_lsm.c | 5 ++-- 60 files changed, 242 insertions(+), 137 deletions(-) -- 2.29.0.rc1.297.gfa9743e501-goog