Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4961485ybi; Tue, 30 Jul 2019 11:12:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzt2415b/0UHC+gIQn08kF17PZlxrPJDT7/86Wozmhx9GnLVqsiOUVp8fGUbl9JPBBd05MG X-Received: by 2002:a65:690f:: with SMTP id s15mr103773830pgq.432.1564510333495; Tue, 30 Jul 2019 11:12:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564510333; cv=none; d=google.com; s=arc-20160816; b=r1LaA6gu9kbZs4Bdmh02QG+viTesJwT+O7lvKqJuqnwcNOC2qRq5LiSb57X6BkC+a9 v67FarNDUl2VsxqkF0Ec2Nl2I3tFCAZ0+7XINiSjsQZNzu8vdxlJgF5PEJlBi6Hq211C 75G7IqiJ2H0zYxUR25xVwpVKaQiiOXvU36ESp41wJpR7ylH7w4QrRD2dlGHa6rnHtPhd L6RtqTIRmUO9wwaIBRfLdQv8w2XKTKEAO7FMwX2aXAftKWp18sFfv09KcYefZqza/znO IaAcA32ccK0XYeEXq2kCvvauHXdffcrGALm1GGAPZugw1kPL9FWrSrBcP3rD1prFSpCo Y0gQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7bBFrWA52UIw86e3/QjeXJw/OCabcRoNRYCv3kxW+2M=; b=cSOrZf1ncwCXNE/E4oScNmuEcTzg+ZWRqmT2uRpDY7FQRrslZIs8HTipdOVbHQflr4 7BA5jgOgOlfge1sqNAKysteZvyED+bLckq0Y1as7oFfo9APJEJXDrlL4dL5V5SloqpRm fpPI1DxcscnSLuGCcaN/unSdiiqFIJwqHB81B2OwX7pUV4MdmCFPxScjOLgCDi/QH0FP m3nbcIh9Umi7Bxe8PWjK7tbQr+kOIRgAEdfbjeOrI1Flev4L+sqGtTmws3TtrnzF2TTy iT3/JW4SGXucS4Ssko71m6wxWcTZGFF6n+zNyKeJnbXVn0dlND4ygxQ4cju2seBGy/xd NX+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=LQii4Wie; 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 67si31682340plf.400.2019.07.30.11.11.58; Tue, 30 Jul 2019 11:12:13 -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=LQii4Wie; 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 S1730058AbfG3R3Q (ORCPT + 99 others); Tue, 30 Jul 2019 13:29:16 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:40400 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729255AbfG3R3P (ORCPT ); Tue, 30 Jul 2019 13:29:15 -0400 Received: by mail-pg1-f196.google.com with SMTP id w10so30422395pgj.7 for ; Tue, 30 Jul 2019 10:29:15 -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=7bBFrWA52UIw86e3/QjeXJw/OCabcRoNRYCv3kxW+2M=; b=LQii4WieS2MDafhUA+OlKsskPWxI5YTobLOu88Z4ddha0lABd53i4WCZ7OxuKqKL2U 5omu44FjkhueJ2p2uUdil676QfB8AaWwVo/GXXW/8lB4YmyRYBxcOsjW6V1awdSxUZSB S5AU+5wN2JXSiw2ydg0XA7DLFJwleT9jZGTST0FBaPEKPLfQwGq2MgyoDnSKXJR/rkKx MekG+GWbYUQc2Fpm1vkEBYmn8SmzE1t+nNaI1gtgMNxfPF2shyvZWiW7wlqsan36Vyu+ 5Q7Pyu7gadXlpV24vvL4Un7FQr9SLj87xvYjKzU7/8jllMYuwH9SRNdirD0t6Ps6QVAh /FbQ== 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=7bBFrWA52UIw86e3/QjeXJw/OCabcRoNRYCv3kxW+2M=; b=g1r9ihv4yWkaubQZ2HseKUC/k1tW3/ac9LrVLwDImqBbSAjjgtzqNBtC3iizni+LqE GUkttsVP7zFiWuK0f/KbD8bEAK6qB6u7btH+0Jt1j0Ni7cJ9Z4oMlZ5SLfV46fS1Wd9Q jUZZbuezAQoVU9yZ9atTlDpyOyzjlMeGfCQv8cLZTgidutpGBOUQuOaKI8OIvo7C7RPC +rU0oNoksQQQeA+44qPJxI6BX0G8s7E5DIqWn4ZP1Zz5KUJFBUYXIWpkuxQaMz3zyqPK y0hJ0Tjk1RQrRlD/8BQHiE+kueO9YSBO8ZuVtkfV7dhJc3LjwWh6GFGlXl94y18Ud4ss sNlw== X-Gm-Message-State: APjAAAU/XlAhbePw/we+IVjxqJ01m7hUZyA++nIhh8guE3tbaRvgT8qm cKsBg/VRUrebCESJmMp2jJLEF89z9uc= X-Received: by 2002:a63:6c46:: with SMTP id h67mr102026443pgc.248.1564507754414; Tue, 30 Jul 2019 10:29:14 -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.13 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 30 Jul 2019 10:29:13 -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 1/5] overlayfs: check CAP_DAC_READ_SEARCH before issuing exportfs_decode_fh Date: Tue, 30 Jul 2019 10:28:58 -0700 Message-Id: <20190730172904.79146-2-salyzyn@android.com> X-Mailer: git-send-email 2.22.0.770.g0f2c4a37fd-goog In-Reply-To: <20190730172904.79146-1-salyzyn@android.com> References: <20190730172904.79146-1-salyzyn@android.com> 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 Assumption never checked, should fail if the mounter creds are not sufficient. 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 Cc: kernel-team@android.com --- v11 + v12 - rebase v10: - return NULL rather than ERR_PTR(-EPERM) - did _not_ add it ovl_can_decode_fh() because of changes since last review, suspect needs to be added to ovl_lower_uuid_ok()? v8 + v9: - rebase v7: - This time for realz v6: - rebase v5: - dependency of "overlayfs: override_creds=off option bypass creator_cred" --- fs/overlayfs/namei.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c index e9717c2f7d45..9702f0d5309d 100644 --- a/fs/overlayfs/namei.c +++ b/fs/overlayfs/namei.c @@ -161,6 +161,9 @@ struct dentry *ovl_decode_real_fh(struct ovl_fh *fh, struct vfsmount *mnt, if (!uuid_equal(&fh->uuid, &mnt->mnt_sb->s_uuid)) return NULL; + if (!capable(CAP_DAC_READ_SEARCH)) + return NULL; + bytes = (fh->len - offsetof(struct ovl_fh, fid)); real = exportfs_decode_fh(mnt, (struct fid *)fh->fid, bytes >> 2, (int)fh->type, -- 2.22.0.770.g0f2c4a37fd-goog