Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4915471pxu; Wed, 21 Oct 2020 08:24:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweadirhxHZAG8NQS7Oxbp0RR45vspMDbQ9zFja8x0RSXVBdrJwf/zMKP+L8DTK8cBR/QD/ X-Received: by 2002:a05:6402:1684:: with SMTP id a4mr3506102edv.79.1603293868270; Wed, 21 Oct 2020 08:24:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603293868; cv=none; d=google.com; s=arc-20160816; b=XsKE/slTeZDek/5gi2mrt3W7GmL1jVSTf5qG6DPFMi1+5xdh/zQS3Ueb314IgYNm25 lVCHesQPOhJLgEW+EozyPyKyn7cAQdLzfqY3lXkpBF8Ciix9V+3ePHECxcUAv1gHQ8qQ 9aGMFqo1BVDOTqYQDJ1qStW8uZ3ypkdv3Vgl7NyaRRZO3d34GLEMoYANshcuph/oJF8V lg2VGPzR20xu1GHpAVmriV0vRDaGmkawvgkJTSv/aVeUl6G6NUBLn8dGRQ8KpXEBBZYD Shs6AnjDI0W+NcWgYfivgnjAguG6dBdmxqyOnBKLqePEdUrgVY14SOfqpD5Z9p6uMavB AqBQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5hmO+mhbzoYH/GVwbytgH/sAwdgqzz47G17aTAhhRQ8=; b=f9V5ZlIJDDs9mZJR/WGkGdvYwk/DXv6jEJ7xPFEHrRYDAtyyghaJqgpVdVy/mcRNZo ls7aM/F90LlKB/CjDhrv2LXIA7RX7erxsIsSCyxLiTnpd+Q5AlpOY7IEIlMIjceAD6lr VaiUOHBRDlecAuaNhT2JICELvs6loMUxDgQJ+3TNuKBl4wKJIZNpxkAV+z/Xbd1gNirK Y9tu0sYnBEKJ8lyRBugWN+Rmzz0qiufVSi6x7j9eO+p+krz/VipIGIiUcX4ybT8lCToq zr5SFOj2vCVA33hrdqz3eec0mVHn4Omf1w2MhtJEEFUpHJFMmdzmeuuMZrL0fmp9G+V/ HRgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=Lg4SyFJr; 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 o24si1643778edq.185.2020.10.21.08.24.04; Wed, 21 Oct 2020 08:24:28 -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=Lg4SyFJr; 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 S2502438AbgJUPUP (ORCPT + 99 others); Wed, 21 Oct 2020 11:20:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502351AbgJUPT7 (ORCPT ); Wed, 21 Oct 2020 11:19:59 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8313C0613CF for ; Wed, 21 Oct 2020 08:19:58 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id m3so215596pjf.4 for ; Wed, 21 Oct 2020 08:19:58 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=5hmO+mhbzoYH/GVwbytgH/sAwdgqzz47G17aTAhhRQ8=; b=Lg4SyFJrAGKmMg6tKEON5sq5UQvRWRT9njDtU86HrhpkL0D0RdFN95O/iD+u7kC/4r ahEy6DJB22RvhcXOWtpd4G1oxyqNVqToJqGqqUs1YqCpH2pXiY1c5d/0pzhbzSnYT69M nqknNaLQF80VCLDCS9BeJ3heSe/9QtMbQljDx+DCvH0VNLMd/6p9Qqsw79r2qTLa69LX R/bAIsTRcvhLiUbCjOhNRPhWsBrblxRy6nLLJDIlIAzaR7RQCmbvWYcaM06CO7pnHIQI 4XcufkDp9mMo7ZlREAiInwPH2LB+50E15mLIPFIh/Q71X2Y7y1PHShJVIl54u4zodyis BSGQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=5hmO+mhbzoYH/GVwbytgH/sAwdgqzz47G17aTAhhRQ8=; b=feoYF444HkdQqVuMSlqV4Vr63J6nc3UBqw21XkB5/MN6Q5bdyh4aIYwl1B0KaDyKjD +DM5j3aEN9JEpjh9yGitwJp4qr28q/U33gO1zhOYBcDo9bPHrUCvNQ4hzS0wBB2Lw7tu Y8fZJDJCfvounNNihr/ld6A6x+aJUx5MTEMYJ03vdJwXfi2v+HgpIGMBAfpfrfvIBYSa xBzlOoqIFSQp1280/UgzLd5CvRx0XP3jD/TQr1Sf1aY+z2zs41vOtuVuPvCQkPvkOB2b jmHQ6Sii87Z5YeDH8TA9mH/a0thad6Sq4oIDTI3crEw2OtObInSW1tdCmOwxCWusoCPs KFPg== X-Gm-Message-State: AOAM533CwofA3HRlnLMk1jz7ttmjmRy1s6Cfzgeug4v5tjmVmp2Mknc8 +If0+ibzqRyLQ/AbcQY0BZ1Eoa9Pf+WHTw== X-Received: by 2002:a17:902:c24b:b029:d3:f3e6:1915 with SMTP id 11-20020a170902c24bb02900d3f3e61915mr4132119plg.56.1603293598087; Wed, 21 Oct 2020 08:19:58 -0700 (PDT) Received: from nebulus.mtv.corp.google.com ([2620:15c:211:200:4a0f:cfff:fe35:d61b]) by smtp.gmail.com with ESMTPSA id s10sm2409646pji.7.2020.10.21.08.19.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 08:19:57 -0700 (PDT) From: Mark Salyzyn To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, John Stultz , Mark Salyzyn , Stephen Smalley , linux-security-module@vger.kernel.org, selinux@vger.kernel.org Subject: [RESEND PATCH v18 4/4] overlayfs: inode_owner_or_capable called during execv Date: Wed, 21 Oct 2020 08:19:03 -0700 Message-Id: <20201021151903.652827-5-salyzyn@android.com> X-Mailer: git-send-email 2.29.0.rc1.297.gfa9743e501-goog In-Reply-To: <20201021151903.652827-1-salyzyn@android.com> References: <20201021151903.652827-1-salyzyn@android.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: John Stultz Using old_creds as an indication that we are not overriding the credentials, bypass call to inode_owner_or_capable. This solves a problem with all execv calls being blocked when using the caller's credentials. Signed-off-by: John Stultz Signed-off-by: Mark Salyzyn Fixes: 05acefb4872da ("ovl: check permission to open real file") C: linux-fsdevel@vger.kernel.org C: linux-unionfs@vger.kernel.org Cc: Stephen Smalley Cc: linux-kernel@vger.kernel.org Cc: linux-security-module@vger.kernel.org Cc: kernel-team@android.com Cc: selinux@vger.kernel.org v18 - rebase v17 - rebase v16 - introduced fix over rebased series --- fs/overlayfs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index b1357bb067d9..9ab9663b02d8 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -53,7 +53,7 @@ static struct file *ovl_open_realfile(const struct file *file, err = inode_permission(realinode, MAY_OPEN | acc_mode); if (err) { realfile = ERR_PTR(err); - } else if (!inode_owner_or_capable(realinode)) { + } else if (old_cred && !inode_owner_or_capable(realinode)) { realfile = ERR_PTR(-EPERM); } else { realfile = open_with_fake_path(&file->f_path, flags, realinode, -- 2.29.0.rc1.297.gfa9743e501-goog