Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp592205lqh; Sat, 4 May 2024 13:51:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUcTBpQTgDj+NZrexIJT9UfDwkAtsUeS5bynTOB05LFDr/dlZsQk2Ndj6xlEelT2RfiyQ8vi9MEWkptJRrnN266tyxKWJgJwEu3vda2iQ== X-Google-Smtp-Source: AGHT+IGZLO5JBOxk5usL6vl5yE6/6XrW/XiV1BsfufzEPBxRNYCjp+v7i/VkbJaY/w8dfkBL4GSI X-Received: by 2002:a17:906:7715:b0:a59:adb9:6c2a with SMTP id q21-20020a170906771500b00a59adb96c2amr1251740ejm.11.1714855881473; Sat, 04 May 2024 13:51:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714855881; cv=pass; d=google.com; s=arc-20160816; b=Di8R0+ojArSXY4LeQUitNfD2poai8yJhfufviwcY6vtU9BekE0firnMdG60QP0SZaN 0IZKZ2XrWsgQnLWOa+2hRvCWDge+5WJ7mEIUzv4HbbU+M8J/V1AWxqpp5gxKJ75MDTpk Oneb5yI5ES/bRFTmYw/0UkX5WP7Zz4R0WW1QOLGXZ48NCruGYxVKYXjIYXpPj6agOZAU ZXNCLTTfxXsjFYuduNatL4v+0KLyKtWHAOJ7l2tuaLruglA4vdcUwzbFUd5SU/Vk9f1l xB9MkDVtSz7KbVJAPfxBQO0yaLoph1710bS+63HtzTIrvmhabh1azlD+wQ1qg7KJi+mB lxXQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=cPCniJ/STVhyaGQN5FVTwiFqhAYGUie52dbeOASHZFo=; fh=4iRvGzRW/MNKWVq9fLw9zyL67LInZpth4SIe4OlHvwE=; b=OWUsSx+sCfMVhzTVZBun2+n+KO2Ny+kThz7N8Lzop84PlnWo3ociRGkm0Tis7ExCzw MGxcBXjNvS0hkji6RXRdPNb1S+2+gjOzqNYz0ySLO/jlsD95nQT0UogEz8MPFzbqdNyQ w9bQiowxQz0xvHj2G2AFBdN/yHvqi+HnGePWcOQBuNpxJRh7V3JIXggIHaHwwXpAeiuj 1pOuS6Uux6IpRSzRVyw0xxyZNMDAXT7lQhiujw4soh/ojO/gapYzN3FLTSxu6Pnr9k+V jYw67Y/0RTArvDfVZJQeTkLkuQrvPUr1HwDRkU2eHrVsEVK0f4LGCn/vIKsuS0RM/7eO z6xQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-168818-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168818-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=valtier.fr Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a20-20020a17090680d400b00a597cd27319si2585033ejx.1039.2024.05.04.13.51.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 May 2024 13:51:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168818-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-168818-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168818-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=valtier.fr Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0E55D1F2187E for ; Sat, 4 May 2024 20:51:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5056684A46; Sat, 4 May 2024 20:51:10 +0000 (UTC) Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 640561EB3A; Sat, 4 May 2024 20:51:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714855869; cv=none; b=tvdBguhFc/70ag5AFtRI9MjMNjOFYeRDv104oHxwFjF9sRYd1n8jsL7+JhI1GlhCoRoRQ6tQ+doyJS1S46pc3DjmDMucdXa71ooeXODWR3Vk4WQtPo02kD6bUe8OT5oD8IfBz6Wd8r7SzA8JIDKri4YldSQFSRf9L1whN3MvYSo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714855869; c=relaxed/simple; bh=9uJfWXMR03eNE2YUUTCfyyDgkZyNICSSak1xKBcsiBs=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=g1Yyv5KQ1okstqZ6cEu2FHGxxHelVHSZwqA2ZblGp0qT6FASL14DAzZnkQ07UuHmIwY+QzdYCK1BnWVUiMaSFdf+T53bXK+tKs2YSPd2RcKMbOqyJeqgLFKgu2IncTtwOPzg4l3awsbKMzEk39/VKuG/+ordpBjc/Z4rN824I/0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=valtier.fr; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.219.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=valtier.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yb1-f178.google.com with SMTP id 3f1490d57ef6-deb65b541faso446303276.0; Sat, 04 May 2024 13:51:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714855867; x=1715460667; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cPCniJ/STVhyaGQN5FVTwiFqhAYGUie52dbeOASHZFo=; b=l0MYLe+RWP9cDOr0UGDmLaIvteUUCsTe0hH5fxyrEC1KAxVf2e53j34ITV4BeDP+48 V49vEX5J/NMvESirG+SRBxKJLo3oeI5rpxmHZSrqERdFl+yVsPbvuY7skt8Kl0YAHw8A w4N9CXufLiQLHK1a7ybjFBgsb12lGT4UiXRJSLub8EHixEqSv3NBn0bgqBfwm4+79FGK fXWtpiWS1tAPSszNlBvdWLSOgZ/wUjN3IP5lmoi+llaRZ2fpwqvZExNm3ALU7eHZ+hwb I56x6h6isAFVV2Uq1oSINAMyQJ8h52Pqj1jnJg32KkGTM4ANHd4au/K6MEklxb45A7se swhw== X-Forwarded-Encrypted: i=1; AJvYcCUIaq6h9I6/IXp8RHWuJ2m0V6OY19qB8pwbiEkX5nTc8ikR6J53Bc6KHaskO0E9DoDpQM1orcCfssFuy7Bbss/OZ2mNSGgKoyDbjSpdgoey0aL8oetXcmuWeDylQOvKW9mbqeHZIObSGKZg7g== X-Gm-Message-State: AOJu0Yw/zci706T3BbvRpnMl4rjpT1LZu4P2KPzpBO2Xp+Vh31PMsE9i 3CsPK36CFhB/kgAcWTRLb+PWb0xGD3PGPcNb7PqM1fZz635AJa8xAYa73ePXbNWq940l9TWO+AT EAeuLGLJmelPEXn0LKPknQMZ8lDY= X-Received: by 2002:a25:d0c9:0:b0:dc3:7041:b81b with SMTP id h192-20020a25d0c9000000b00dc37041b81bmr6993350ybg.36.1714855867412; Sat, 04 May 2024 13:51:07 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: In-Reply-To: From: Hugo Valtier Date: Sat, 4 May 2024 22:50:35 +0200 Message-ID: Subject: Re: bug in may_dedupe_file allows to deduplicate files we aren't allowed to write to To: Amir Goldstein Cc: mfasheh@suse.de, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Christian Brauner Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > My guess is that not many users try to dedupe other users' files, > so this feature was never used and nobody complained. +1 Thx for the answer, I'm new to this to be sure I understood what you meant: > You should add an xfstest for this and include a > _fixed_by_kernel_commit and that will signal all the distros that > care to backport the fix. So right now I wait for 6.9 to be released soon enough then I then submit my patch which invert the condition. Once that is merged in some tree (fsdevel I guess ?) I submit a patch for xfstest which adds a regression test and has _fixed_by_kernel_commit mentioning the commit just merged in the fsdevel linux tree. Le sam. 4 mai 2024 =C3=A0 11:43, Amir Goldstein a =C3= =A9crit : > > On Sat, May 4, 2024 at 7:49=E2=80=AFAM Hugo Valtier wro= te: > > > > For context I am making a file based deduplication tool. > > > > I found that in this commit > > 5de4480ae7f8 ("vfs: allow dedupe of user owned read-only files") > > it states: > > > - the process could get write access > > > > However the behavior added in allow_file_dedupe now may_dedupe_file is = opposite: > > > + if (!inode_permission(file_inode(file), MAY_WRITE)) > > > + return true > > > > I've tested that I can create an other readonly file as root and have > > my unprivileged user deduplicate it however if I then make the file > > other writeable I cannot anymore*. > > It doesn't make sense to me why giving write permissions on a file > > should remove the permission to deduplicate*. > > True. Here is the discussion about adding "could have been opened w" > to allow dedupe: > https://lore.kernel.org/linux-fsdevel/20180517230150.GA28045@wotan.suse.d= e/ > > > > > I'm not sure on how to fix this, flipping the condition would work but > > that is a breaking change and idk if this is ok here. > > Adding a check to also users who have write access to the file would > > remove all the logic here since you would always be allowed to dedup > > FDs you managed to get your hands on. > > > > Any input on this welcome, thx > > My guess is that not many users try to dedupe other users' files, > so this feature was never used and nobody complained. > What use case do you think flipping the condition could break? > breaking uapi is not about theoretical use cases and in any > case this needs to be marked with Fixes: and can be backported > as far as anyone who cares wants to backport. > > You should add an xfstest for this and include a > _fixed_by_kernel_commit and that will signal all the distros that > care to backport the fix. > > Thanks, > Amir.