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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41ACED41C27 for ; Wed, 13 Nov 2024 10:12:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CA0AD6B00A8; Wed, 13 Nov 2024 05:12:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C501C6B00AB; Wed, 13 Nov 2024 05:12:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF1DF6B00AC; Wed, 13 Nov 2024 05:12:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 8A6BB6B00A8 for ; Wed, 13 Nov 2024 05:12:32 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 4CC76C08F6 for ; Wed, 13 Nov 2024 10:12:32 +0000 (UTC) X-FDA: 82780656336.05.10D5BA0 Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) by imf01.hostedemail.com (Postfix) with ESMTP id 4680D40007 for ; Wed, 13 Nov 2024 10:11:57 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=IbQqPKEZ; spf=pass (imf01.hostedemail.com: domain of amir73il@gmail.com designates 209.85.219.172 as permitted sender) smtp.mailfrom=amir73il@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731492576; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=pPvCe20vqjW/9L206QUZNSC4KV6t+3WGN84L/k9zELI=; b=2J19bBrhkJywkQHsJXlWJJzlBtN/xjZSzDUqacs0C0Vtg5e/LaucAbiLvS9flhk0Sb4MiT WW7JjbZaym6/X2ffK1EUU0BQbHXmXxw3HcO4bpOhfnoo8qasNaKZlS+nj+BGdorsbFbCpa ays533x5yqJI0vnlrLRnrZYuQ0bSuLo= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=IbQqPKEZ; spf=pass (imf01.hostedemail.com: domain of amir73il@gmail.com designates 209.85.219.172 as permitted sender) smtp.mailfrom=amir73il@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731492576; a=rsa-sha256; cv=none; b=U7BPcRzHtibHJivJ/k0ry2OxFEoSeHQOumcaZw31tubrnu7RGPeU3AKo6VT0bk+EUl7v6H Vi/B0BRf8Vf5QDYrnt2yIUZ3ar607NvKIF5J2ydTdSzd8KH4YruwFgzFhZlbdS4WvJFQ8O bTe3wG9eMLTJac1GTBZ9axcQBDmiHQI= Received: by mail-yb1-f172.google.com with SMTP id 3f1490d57ef6-e30cef4ac5dso6434528276.0 for ; Wed, 13 Nov 2024 02:12:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731492749; x=1732097549; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=pPvCe20vqjW/9L206QUZNSC4KV6t+3WGN84L/k9zELI=; b=IbQqPKEZ+pUlOM+9cQ/7kQZ5Cul2tRudImlsOn2V/gKhaMwdh12ojy9LodQivm4hyh fqvHm55kxEsW7OCVzHQuZfdtFqJ1/7l8l+G6f9qSknLDWIkpGTOA8cSAerkb/R0mAwj0 6/cinqZYLVwqqMpODdMIh58R6XlP4nNIZbYlvCVbowahEwx+cSejaCGfDXVLhsGTxXDv da2PMlg1xektFyc8Vi5fTV+e47CArmoDMdhBWJyw5f+ngJmdKQuxQUnBSNVJ/EXmCkR3 ko/ifSLh36l9Qjm0eOtRew68THGcBHorw1+kA0Bit7iPk9Smt4wHhLbvfW9qPYJZGGMc cPSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731492749; x=1732097549; 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=pPvCe20vqjW/9L206QUZNSC4KV6t+3WGN84L/k9zELI=; b=vVtRTFDOyq3dUGCG4ZPytYoDDsXnjR5jo8i8AX34itg5aoKqTuscUFOtTq8CB+onq0 5veDK1O4DoJDOR1gFSVGcu9EjnEBDeYTMMfghG1qCFArkrHIS5Lw7EqoRrgvfOBK6UKj vC895Hj+IxVojBbWyhB72Y5FhPZSVN6XhTF36Kt8Anlx0zFCQeHudyHFsQZOoG2sPnpU IJz8L7tIgJwel06g/9p90tSkUT3zlQ29uRIsMLaypFV4NKhaQgJ4kTgar3AXuYzcUf+Q gaEy3zHnpX0Fe5mtjHBIJyYqrx98njROlGuDZLZpU+4IXS9CbD4JcxZZ50VyX5X2NfC4 u+lg== X-Forwarded-Encrypted: i=1; AJvYcCXDi7mPwu09hSPdM8VsfTP2VRfAiH2jrDb/G3wJ4AmLJaminIT2bPVRpJsg1W/SVHWNAqSQgnK56Q==@kvack.org X-Gm-Message-State: AOJu0YzGY2zq1FN5VC2qAiKzEKHWMc62rin5YvebowdpTQcVRwOSG94g 0jR/9Y+gRiFZ+Isd2MOJx//u+OcKqJspugr0EaWPxVcT+l8i9laeU8Uxjlvbu7841NGjf0QLdhk 3l2+VvbtHf4/l9QcHt61fkZhW2sg= X-Google-Smtp-Source: AGHT+IEgkmb6w5scqXSHLPCI0xBhSKcJTGnw+qItafp2JXkNGsrxVBU10S/9ET5y7RckoZUnXJjpqQFPE4B9dQa2O5g= X-Received: by 2002:a05:6902:1083:b0:e30:dc66:5877 with SMTP id 3f1490d57ef6-e35dc54772dmr5424408276.17.1731492749508; Wed, 13 Nov 2024 02:12:29 -0800 (PST) MIME-Version: 1.0 References: <60a2309da948dc81e4c66b9e5fe3f1e2faa2010e.1731433903.git.josef@toxicpanda.com> In-Reply-To: From: Amir Goldstein Date: Wed, 13 Nov 2024 11:12:18 +0100 Message-ID: Subject: Re: [PATCH v7 07/18] fsnotify: generate pre-content permission event on open To: Linus Torvalds Cc: Josef Bacik , kernel-team@fb.com, linux-fsdevel@vger.kernel.org, jack@suse.cz, brauner@kernel.org, linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-mm@kvack.org, linux-ext4@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 4680D40007 X-Stat-Signature: 51tnwxt8eqoo6jf5dgbcifep7bp7h3nw X-Rspam-User: X-HE-Tag: 1731492717-130251 X-HE-Meta: U2FsdGVkX18xOry+HrgwBUXfF5COk4nDFlh0bVEQMvwstWVhY/Oho+hdt+CinaFekJr2598yRVVnJU+l24vB43J9gbhw4c5dciwSCsoNjVYZdyHqb8jyItVj1HW8u1CGas9rpIzCpY9RfpsYllymW3citLak45K3BIFXmM+r/AciCBFD90GFnugGqsrh/AgJ0BnjU4Vz1Er9TYG7axAXybyESc30I49elU6MX+laP5hKxOzWvxU5IV5S8R/kJ+l0WWAJTYkXYwXLgG9CMmfwyg3TqvbQmIyEKzyBKVl5/6T0BDdwqjWVBGK6SqlPF4+6WGl4re5VVOOtCjkPPN7VuZJItd2azecS+FZK6rVh6pQ72XphhOseGbWXJRJonJOP9aRdeH3MRWEPUJZoBhTUh22JfRKYOZWuG1Qg6f2To4vtx5iNOx+5kGGTSDq8bqAA+gdqBsplb4amO/+oP+tRxt6AySvFvpfC6IcOCjqlHMMPV1yU0TqNHgoAWwxIviQ106H4RjOpsXkEX/eqZCEeOhIGWfb+s3eLU1qxz8qKqthc6vy8DEB0a4DkiM/5jGGXgPnLFKAwaTXcwWp4hq+J6hepLM6O3TQ/iMUJC/HTb7HsjvFgNFtTap3RweBMXWh96eXFOTmvXM22W+UIDDTfJQeMUF4hL6CbOp5EeddlZaT3uFjuWl3otoVm4Qhlj8DduenNud3IGbf0gIvkkoE0JNJjZHIrIR42X9rS+/uH/evuQZSn/kXVyBog57PmWA5K1dII4ftuQNu/OPuw2X/an5Yg2EBIZOJ/ot/kWvNG5/p3RjaJBWIAwsM+pscoQW5069aKqQI6GF1Jnb9Tf5BwTOERnzV8aBMK+3Y7mcIIGUInSKxyEIKVtycbQ0lXgFjMUWHoZ5t3+NfOsEykIXIOShK/JDdWEmVbUf9l3ksSvw1FLVn38Zp9T1XTNqI3dVjglqlvRo4wU5Vjlhng2Wp rFA8xRhr DhAwx/8BkVuBDPO6AW5MKUK7K/2yXuce4F5GcFRF6q09HMvJcWId9QxewSFmR90oBraNAadcQCI+PhOSs5iN21uY2f3jhB6oAS4ptzaFUCRthGxJ6w5qUO7N2OYbCUm/wla45RRfSI2cmzhiWhkSci+3X7N2Fu2zBFqsAkPfYihEcxrxWA2Usjrxaa4Ez7EEi8XurgPj0WjvvYgZPoiZoImmGZQRNlGhSU8G58Xf7cxI1CRfYzi+ed46rzvBRSoQJMiZobiXVma4MmkF7W11XfFYOmnfgybYW2tVHaGA5pFq46WSwCyLOv+hfTjSd0lpNwwSyohbvVhr3ACX9N5mnTdb57xJV8Nfcbm2pxsMmBS5KiQzcOZPoaYf6ZZ2eevMMgIdP/dC4/NqrmkpO7LMkILeutA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Nov 13, 2024 at 1:58=E2=80=AFAM Linus Torvalds wrote: > > On Tue, 12 Nov 2024 at 15:41, Amir Goldstein wrote: > > > > You wrote it should be called "in the open path" - that is ambiguous. > > pre-content hook must be called without sb_writers held, so current > > (in linux-next) location of fsnotify_open_perm() is not good in case of > > O_CREATE flag, so I am not sure where a good location is. > > Easier is to drop this patch. > > Dropping that patch obviously removes my objection. > > But since none of the whole "return errors" is valid with a truncate > or a new file creation anyway, isn't the whole thing kind of moot? > Not moot. It is needed for the case that open with O_CREAT finds an existing file and that file needs to be filled on open and anyway do_open() is also taking sb_writers for O_RDWR and O_WRONLY (not 100% sure why) not only for O_CREAT. Essentially, this means that the legacy FAN_OPEN_PERM event is not safe to be used by HSM, to fill file content on open. and while I can document that fact all over the internet, that won't stop people from using FAN_OPEN_PERM to implement a simple HSM. This is (the only) reason that I wanted to have a noticeable new event at open time that is documented as safe for use by HSM and inviting HSM developers to use the correct event. Very possible that this is not a good enough reason. > I guess do_open() could do it, but only inside a > > if (!error && !do_truncate && !(file->f_mode & FMODE_CREATED)) > error =3D fsnotify_opened_old(file); > > kind of thing. With a big comment about how this is a pre-read hook, > and not relevant for a new file or a truncate event since then it's > always empty anyway. Right. That would be good for what I wanted to achieve. > > But hey, if you don't absolutely need it in the first place, not > having it is *MUCH* preferable. > > It sounds like the whole point was to catch reads - not opens. So then > you should catch it at read() time, not at open() time. Yeh, for sure. Will drop this patch. Thanks, Amir.