From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0E4AC433EF for ; Tue, 12 Jul 2022 20:04:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233718AbiGLUEM (ORCPT ); Tue, 12 Jul 2022 16:04:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234777AbiGLUEB (ORCPT ); Tue, 12 Jul 2022 16:04:01 -0400 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5CF424BC7 for ; Tue, 12 Jul 2022 13:03:59 -0700 (PDT) Received: by mail-qk1-x72e.google.com with SMTP id f12so7090007qka.12 for ; Tue, 12 Jul 2022 13:03:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=kMKOjmUBwk3DBwZ1wD2f24o16PRxuYbW1eYIePsbhDQ=; b=uQGQLOsiXfpZ86ny6CuWo3yx26LXTEUepV5jmzcZvl36GEwPxzTi2RzLe1oGZQDjlB 0f+NMH1L5ZLFMX+lqqiF1RFiICyIYlizzIPGUiFWXlns0eUckwQSkj/7YtubcCC03NIB rzUjuPBIq0R6vU98BdSDSW60O/ly9W1DuhjezEkBcj9O4qvddO8g9vrDXk+7hCwej20p uGocnGJk+s3DVX+60uLVOwkuhAKIcPi8AHSMz7KBN9nq6sumdwvefS18V1ezbJD/TuuM i7TQFXRYISI+K+cl3NL7nNKD7h1lxZ13jy+orCFFMW65c8kRNJyMw+IU06LQKBWATrvs 58hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=kMKOjmUBwk3DBwZ1wD2f24o16PRxuYbW1eYIePsbhDQ=; b=BOWCW/uYh0XNmVkHV0jCej/p/aIRt6IdlavB9jciVsKkdMFOfInbrA5uMuoxMQa+Ew 6acmkiYgFJc/0cYeZ3XOM1z55hadAafCkb7HiD9hwaSINOFnPcvwhklp9qOIhXDrpHBo Vu7NHce2D2fhcJmq3SpTsNSht/zivRi1/VqOAExcnkB/EBs5rPxIA4NvdoZjEznz3YtK l/4Dg+JRYjvz9FtV5GXO2mJ8nIifC/wx6pKZ0WHl0WcAIy2S9yeFKvOYdWBaj3A0oKL+ NMYuRIktwabzBoe0mMLV3MxHT7LndTAkQAnb6xCpAffYsfVxQwfdPTCYuWOJvKbBwm++ co+g== X-Gm-Message-State: AJIora8DYhKUOLmKSRYMfunEQY3cWYUjMbOUVAnU9HJGQgqzepMKjZto 6XdO7P8+wexsAG4EF18Uoe14CA== X-Google-Smtp-Source: AGRyM1tIYCEUQctCZmssJsI+cL7Kc7QBMgFp82gyvnI3n6+1CyNTLQF820YsTYkp+a5q7Jpfj6ZIPw== X-Received: by 2002:a05:620a:1d0d:b0:6b5:774e:9a27 with SMTP id dl13-20020a05620a1d0d00b006b5774e9a27mr11253608qkb.280.1657656238937; Tue, 12 Jul 2022 13:03:58 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id c73-20020ae9ed4c000000b006a37c908d33sm9583235qkg.28.2022.07.12.13.03.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 13:03:58 -0700 (PDT) Date: Tue, 12 Jul 2022 16:03:56 -0400 From: Josef Bacik To: Linus Torvalds Cc: ansgar.loesser@kom.tu-darmstadt.de, "Darrick J. Wong" , Christoph Hellwig , Amir Goldstein , Mark Fasheh , Matthew Wilcox , Miklos Szeredi , Al Viro , linux-fsdevel , Security Officers , Max Schlecht , =?iso-8859-1?Q?Bj=F6rn?= Scheuermann Subject: Re: Information Leak: FIDEDUPERANGE ioctl allows reading writeonly files Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Tue, Jul 12, 2022 at 12:07:46PM -0700, Linus Torvalds wrote: > On Tue, Jul 12, 2022 at 12:02 PM Josef Bacik wrote: > > > > > Any permission checks done at IO time are basically always buggy: > > > things may have changed since the 'open()', and those changes > > > explicitly should *not* matter for the IO. That's really fundamentally > > > how UNIX file permissions work. > > > > I don't think we should go this far, after all the normal > > write()/read() syscalls do the permission checking each time as well, > > No, they really don't. > > The permission check is ONLY DONE AT OPEN TIME. > > Really. Go look. > I did, I just misread what rw_verify_area was doing, it's just doing the security check, not a full POSIX permissions check, my mistake. > Anything else is a bug. If you open a file, and then change the > permissions of the file (or the ownership, or whatever) afterwards, > the open file descriptor is still supposed to be readable or writable. > > Doing IO time permission checks is not only wrong, it's ACTIVELY > BUGGY, and is a fairly common source of security problems (ie passing > a file descriptor off to a suid binary, and then using the suid > permissions to make changes that the original opener didn't have the > rights to do). > > So if you do permission checks at read/write time, you are a buggy > mess. It really is that simple. > > This is why read and write check FMODE_READ and FMODE_WRITE. That's > the *open* time check. > > The fact that dedupe does that inode_permission() check at IO time > really looks completely bogus and buggy. > Yeah I'm fine with removing the inode_permission(), I just want to make sure we're consistent across all of our IO related operations. It looks like at the very least we're getting security_*_permission on things like read/write/fallocate, so perhaps switch to that here and call it good enough? Thanks, Josef