Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp870187imu; Fri, 9 Nov 2018 07:24:35 -0800 (PST) X-Google-Smtp-Source: AJdET5coWPh7d4mXpPC+g8vwfJZuKulCRPPm4yHrgY7Kr4Z285d7Cd7Xn6tXPIrvRqR9zF+U043I X-Received: by 2002:a17:902:124:: with SMTP id 33-v6mr9408838plb.287.1541777075744; Fri, 09 Nov 2018 07:24:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541777075; cv=none; d=google.com; s=arc-20160816; b=yHhcBa1VMDeuZE/Z5r6W76LVfvqZSFekit45qP8UeT6g4xYes3YWM8/V4wrk17NKmx Nb/5sYF49feT51uUR5A631+zHm5jCPFDX8E8Pi6Yy13qJ5hcIr9jkqu9wb6OU52k56TZ MI9b8OUyQYrlAUsrA4YrEQ5JmkVXbsTJwXOdyDf7/nO/B7ikX8RUliXvU7bQsauPW31e 0vqR8mw3VxJJ6cFehKcH5kgBD3Ut5NJbXtt1sjh6mVwib/oDLYuZ433SKvhi+TLGr4Gf DFpuXLAu+XhgrybTmxcBR2M12FFgC9+XwidjOynlZKbPjBRbI5T4ISGajgfUUdJGUXdW i6Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=d/meds+HI03VXy0Uk1ONuza5phimoiRCYgyxf8rZtnM=; b=cekwfAKhw75YHviOe/mxEIsqeKb3KwnZBQ6vuYpEGTrm2Z+cDcNz/owANhZpFrVMEU 03eXc9NcNdf8sBcIuYDa9kourpYUObfrVuwLxMbTYcUYbbODrtudnx7dc9dWev0pD1x6 yZ2JzjFMhWfXXrt4gr4zvIJ1e+ZN4KZGmdRNt8/NyJMivEZx3s/yUqskXSEp0Vv+Nr14 2MoFs9goukOb6fxcEs0UPrHZr2TUp0siLhRZ42Q09i7FA8NReyZqg5inaARoVBIwz43k IJHNKyffFv65okoaXJnpLeCyCFiWnQHQZiA99D+c4NtQeOf5M21YOZwameCDNHsrTKHz iq3A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n5si6414395pgl.485.2018.11.09.07.23.21; Fri, 09 Nov 2018 07:24:35 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728358AbeKJBBn (ORCPT + 99 others); Fri, 9 Nov 2018 20:01:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50642 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727800AbeKJBBn (ORCPT ); Fri, 9 Nov 2018 20:01:43 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D22C585A07; Fri, 9 Nov 2018 15:20:41 +0000 (UTC) Received: from horse.redhat.com (unknown [10.18.25.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C1575D738; Fri, 9 Nov 2018 15:20:41 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 1AEA02239AE; Fri, 9 Nov 2018 10:20:41 -0500 (EST) Date: Fri, 9 Nov 2018 10:20:41 -0500 From: Vivek Goyal To: Mark Salyzyn Cc: linux-kernel@vger.kernel.org, Miklos Szeredi , Jonathan Corbet , "Eric W . Biederman" , Amir Goldstein , Randy Dunlap , Stephen Smalley , linux-unionfs@vger.kernel.org, linux-doc@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH v8 2/2] overlayfs: override_creds=off option bypass creator_cred Message-ID: <20181109152041.GC28565@redhat.com> References: <20181106230117.127616-1-salyzyn@android.com> <20181106230117.127616-2-salyzyn@android.com> <20181108200106.GB3663@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 09 Nov 2018 15:20:42 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 08, 2018 at 01:28:32PM -0800, Mark Salyzyn wrote: > On 11/08/2018 12:01 PM, Vivek Goyal wrote: > > On Tue, Nov 06, 2018 at 03:01:15PM -0800, Mark Salyzyn wrote: > > > 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. > > Ok, I am trying to think of scenarios where override_creds=off can > > provide any privilege escalation. How about following. > > > > $ mkdir lower lower/foo upper upper/foo work merged > > $ touch lower/foo/bar.txt > > $ chmod 700 lower/foo/ > > > > # Mount overlay with override_creds=off > > > > $ mount -t overlay -o > > lowerdir=lower,upperdir=upper,workdir=work,override_creds=off none merged > > > > # Try to read lower/foo as unpriviliged user. Say "test" > > # su test > > # ls merged/foo/ > > ls: cannot access 'merged/foo/': Operation not permitted > > > > # Now first try to do same operation as root and retry as test user. > > $ exit > > $ ls merged/foo > > bar.txt > > $ su test > > $ ls merged/foo > > bar.txt > > > > lower/foo/ is not readable by user "test". So it fails in first try. Later > > "root" accesses it and it populates cache in overlayfs. When test retries, > > it gets these entries from cache. > > > > With override_creds=on this is not a problem because overlay provides > > this as functionality as long as mounter as access to lower/foo/. > > > > But with override_creds=off, mounter is not providing any such > > functionality and we are exposing an issue where cache will make > > something available which is not normally available. > > > > I think it probably is a good idea to do something about it? > > > > Thanks > > Vivek > > > Good stuff. > > That sounds like a bug in cache (!) to not recheck caller's credentials. > Currently unsure how/where to force bypass of the cache (performance hit) as > it is wired in throughout the code without a clear off switch, or rechecking > of the credentials at access. This does need to be addressed to make this > 'feature' more useful/trusted for non-MAC controlled, use cases. DAC is just an example. There is no reason same issue will not happen with MAC? Proacess A with correct MAC priviliges will fill overlay cache and process B without correct MAC priviliges will still be able to get information about dentry. As Amir suggested, for now documenting this probably is fine. I can't think of any other good options either. May be Miklos has some ideas here. Thanks Vivek