From nobody Thu Apr 2 09:42:24 2026 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 091392BE03C for ; Thu, 26 Feb 2026 12:50:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772110220; cv=none; b=UTC5E1Kp1MrdC5tCuLNzPb+Gc8usjt0KPrgXKN7Z5wxMq+WtuBGCEi2NZ37Y5KA9gl3VAMqjcOrkmT/daKfZ0yvHhJSEMCLnS9BIK7dRg0uP5ZCmaHrQ3kI14W6Fixsu7EKDdWaATASoN9lMyc2apEVn8bG7ap2K+Br1yri6gZY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772110220; c=relaxed/simple; bh=70hSkNsvLqkJRBWbDIHj65tDaM3EKJ2BXVr9m7vSzXw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=agNbLhrbzAJgShegeM1yxejp9QjYWV7CrfpW7/T6sQ3V2qXoW1hGBW4lMHX7bDHyfsGnEOoLEqVKoaIUu8NDSWWojlslmMP5nOPCQagyfcHiLUsCSYQx8eFwH+GinbM4QgxGue4Z3MGofhFNbRqKKyX7HYzu5STGyBndIRf2wQo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=QKvpjdVC; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="QKvpjdVC" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2ad617d5b80so4824755ad.1 for ; Thu, 26 Feb 2026 04:50:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1772110217; x=1772715017; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=fyIjJLPqWTAlsU9TtEHZSXx8eta5Q+FhX9SZdoxBFNw=; b=QKvpjdVCL6Ix94JhEoAqYlJLujYLIucDGezY/m4AE5zOWQQHuy5IUWWy+UIgI54dAt bXEgF/6P+H9gvQFEaASPo/zsoDzMIaDRBis5SPgu+k/CtU7jedHnpoTw7MY/hHNCm8pu fMVB5n6v6NPeIKw9w5s2+CTXWHigtL7/PzGBwP+tQ/pf2Sx9EUY+he0DKVa4G0PeLhVg L37vnLNPgu6R6rDM+pHA6Ge2UiDT0wsERdyi4/LG/v1KIbIaM736Epwhy2cPUh+hPpK7 CsdH6vO+Qhmm+ZnPSbvEBkY8PungkYs9t8u75ZrcoFFmeTy+zveuPvCOeREeMdhYBCPW UzrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772110217; x=1772715017; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=fyIjJLPqWTAlsU9TtEHZSXx8eta5Q+FhX9SZdoxBFNw=; b=hhknRy0l6QLTH1sbAfqf5OMRAY0cGyrCJund8lLp1w5hwo8nK+phbgszTcrwAzBYAM VhQ/fg0OpSwn7D6/30tfl0rx1RPfh6VgS1rwmdntt9tw63cH+hgz27lJvPOv5dbtV8fX 7BbQztHJsXoOJkkXmqPLTv4PqrDJcWhgVo3gNi5OV2AFhRK/7+CelBtmYr3on4wooRrI I2EmzfKF9i99QMsFBS6S1t9IDTYjlae7FxHew5/Uv7ZFgggOrg8qNAfWzPfITy8Pp41q Tx3Qs76qJOKgMuNusovhLBu7dw+OmrVc7HB5aamYanE8jJEXZbXVfpFKzgGWi0qQEONL XKsg== X-Forwarded-Encrypted: i=1; AJvYcCUP+Sz3InWpCTGorjw4UAURVk8pjfM7TDzY7KA0MAIyja37oX6nIs/QIt3ORD/8TXMDiNECBcwCQusA3Ks=@vger.kernel.org X-Gm-Message-State: AOJu0YzdtY+dyMW2Y4+5i0OkJDoZnRFgLZODbxX/O8PywzQI7zRe3PGv 1O6TJTZqKhzoptgilMap9yx+s6mBbvKjRcemnNwRfEiO9KhgsZX/HwmSDb5w9F4UEEU= X-Gm-Gg: ATEYQzyGHOzUAS9tohkPBOg9QGKVOYyvmxa+ccWmEVQSUwYoRZ5IBv/gs41nNIEnt6/ OeORdfMN/FTArq5G+14PDDe0Fm7P4MC3Iixk6alT0YElFyJtoKBRW0XZU+KQXyHeObmR41WA6yI z1cZX4kYbAxpaSFfXZt4NxVjvTdcNLZjYXy6Cv0t7D9KxJU/fzZgPiIrF7xVN+nwIEc4q6t/D9t mNpuqM+x6UdGxP5jZFPEyXBs+u+EijMhd6ObwkLlhrbHGPMYyJzPNl8f6Y2axkovUnkrNFvNaRZ fpCDDRnqcPTEozFKv6CsuhsaaVBYoGyYslUpgqPmholae/p3qt7uLiZAJtxDBeVhbjP4O3kRkts gjRCtOyM3P7nbz94xig22amFUOCBrfQsEj6GFZckOLF3H+kXWmO2AS1Uwl6qwvTB84Wc/HGski1 I9M022GcL1J5k4QL/9KfRnOsT88fE3ikyHPW/g1Rb9rIgFMbG+FYUyZJv6yD7zQrACGOEo X-Received: by 2002:a17:903:46c4:b0:29e:c2de:4ad with SMTP id d9443c01a7336-2ad74471022mr197131715ad.24.1772110217454; Thu, 26 Feb 2026 04:50:17 -0800 (PST) Received: from tianci-mac.bytedance.net ([61.213.176.14]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-359135ef1d7sm3468315a91.5.2026.02.26.04.50.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 26 Feb 2026 04:50:17 -0800 (PST) From: Zhang Tianci To: miklos@szeredi.hu Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, bernd@bsbernd.com, Zhang Tianci , Xie Yongji Subject: [PATCH v2] fuse: send forget req when lookup outarg is invalid Date: Thu, 26 Feb 2026 20:50:01 +0800 Message-ID: <20260226125001.16287-1-zhangtianci.1997@bytedance.com> X-Mailer: git-send-email 2.48.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" We shall send forget request if lookup/create/open success but returned outarg.attr is invalid, because FUSEdaemon had increase the lookup count Reported-by: Xie Yongji Signed-off-by: Zhang Tianci --- Changes in v2: - Fix wrong usage of goto label. [Bernd] - Link to v1: https://lore.kernel.org/lkml/20260202120023.74357-1-zhangtia= nci.1997@bytedance.com/ fs/fuse/dir.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 4b6b3d2758ff2..be25934b86105 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -578,8 +578,10 @@ int fuse_lookup_name(struct super_block *sb, u64 nodei= d, const struct qstr *name goto out_put_forget; =20 err =3D -EIO; - if (fuse_invalid_attr(&outarg->attr)) - goto out_put_forget; + if (fuse_invalid_attr(&outarg->attr)) { + fuse_queue_forget(fm->fc, forget, outarg->nodeid, 1); + goto out; + } if (outarg->nodeid =3D=3D FUSE_ROOT_ID && outarg->generation !=3D 0) { pr_warn_once("root generation should be zero\n"); outarg->generation =3D 0; @@ -878,14 +880,24 @@ static int fuse_create_open(struct mnt_idmap *idmap, = struct inode *dir, if (err) goto out_free_ff; =20 - err =3D -EIO; - if (!S_ISREG(outentry.attr.mode) || invalid_nodeid(outentry.nodeid) || - fuse_invalid_attr(&outentry.attr)) - goto out_free_ff; - ff->fh =3D outopenp->fh; ff->nodeid =3D outentry.nodeid; ff->open_flags =3D outopenp->open_flags; + + err =3D -EIO; + if (invalid_nodeid(outentry.nodeid)) { + flags &=3D ~(O_CREAT | O_EXCL | O_TRUNC); + fuse_sync_release(NULL, ff, flags); + goto out_put_forget_req; + } + + if (!S_ISREG(outentry.attr.mode) || fuse_invalid_attr(&outentry.attr)) { + flags &=3D ~(O_CREAT | O_EXCL | O_TRUNC); + fuse_sync_release(NULL, ff, flags); + fuse_queue_forget(fm->fc, forget, outentry.nodeid, 1); + goto out_err; + } + inode =3D fuse_iget(dir->i_sb, outentry.nodeid, outentry.generation, &outentry.attr, ATTR_TIMEOUT(&outentry), 0, 0); if (!inode) { @@ -1007,11 +1019,14 @@ static struct dentry *create_new_entry(struct mnt_i= dmap *idmap, struct fuse_moun goto out_put_forget_req; =20 err =3D -EIO; - if (invalid_nodeid(outarg.nodeid) || fuse_invalid_attr(&outarg.attr)) + if (invalid_nodeid(outarg.nodeid)) goto out_put_forget_req; =20 - if ((outarg.attr.mode ^ mode) & S_IFMT) - goto out_put_forget_req; + if (fuse_invalid_attr(&outarg.attr) || + ((outarg.attr.mode ^ mode) & S_IFMT)) { + fuse_queue_forget(fm->fc, forget, outarg.nodeid, 1); + goto out_err; + } =20 inode =3D fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, &outarg.attr, ATTR_TIMEOUT(&outarg), 0, 0); @@ -1040,6 +1055,7 @@ static struct dentry *create_new_entry(struct mnt_idm= ap *idmap, struct fuse_moun if (err =3D=3D -EEXIST) fuse_invalidate_entry(entry); kfree(forget); +out_err: return ERR_PTR(err); } =20 --=20 2.39.5