Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp292290lqb; Tue, 28 May 2024 16:12:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUlAXg/HgttPt2b0dio3XAVujiebHHustKqkQ8iIO/vwrftT2/yPVwmrBldJ/aEj4ony1703JTIwmWRM6CbQ8yxc+x3xwaAiEtDFHSPZg== X-Google-Smtp-Source: AGHT+IG8mVwMGGGj2LxYbh/4U5mz3N9yKfVvrpvkLfGypXDL2Z6fNV/frM4VwlqNQ0iw9SJoIU1b X-Received: by 2002:a17:902:d50b:b0:1f4:768b:445e with SMTP id d9443c01a7336-1f4768b4768mr107062815ad.24.1716937921924; Tue, 28 May 2024 16:12:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716937921; cv=pass; d=google.com; s=arc-20160816; b=AP+1RT7qKQ8Con77RIUnBfQfAh+NKPQkei6ieemymmB7vnOmX0jHLAkVQIQVNIr6UK 8QhzQlBL0sb4bFnd3JksxxS7dTGbwH/9guEkoJLYhvmsUxHMeHg5t28HuFb13MHOOOMp UwyFA8cXcO0/fnjKMaQDE313O7piGzxgsQ0huzNABKQ+wYxwEosb9Jqs5rrYcpnHYcnb hA4MxvX9YcqXyWPayuojKvRxcW52W1cqb5FqTtG+L/zTy0WFWmObRExK5W77H5CxjZa2 uLdhZaApc2wUpd+IAac99vm3ZcdheCs8xJkIscGlSHsC/e71OcgP1P0TF5aBBSqR1Qaw 4e/w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:content-transfer-encoding :dkim-signature:dkim-signature:dkim-signature:dkim-signature; bh=d1xqmsHesKNSciEDfpS+I8mFJOg6lBIUMD8j40NmKSw=; fh=qXyISdtQqrsvym84kXSzt4h6iHWGZzof037wxWLuPAg=; b=z6j9OtH4h2MDWL7oqZmAOIdD9yi4aYl/y6FbYZIIiCbgC+IX7QCpMCVJtQZ9/v3fwa ME4aj8gmdYS+QHoeKUmRFDOJifNerTnNkx1JUNarnrxr8NPq1UJul1i3IcLkYOSw0J4P zJIEtcXfyfsOr4BAnbWA5Cow80WCXDO5aw8zu+JIrSn5w/pxwmglr664/PIkCrnzDgiK Vb6HsKAQIRApXNnX8t3SQSfBREY/meXVSgDOkCn3kZ4Vze22TP1tEMLXKK6iJjH9/DVe Uenu0V+oSf5inpDFUxthzz4lDeFKNmGUNPb1HqfiRg4vAlD9bFM/QXD/u6YUyWSvxUKI DEpA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="g/NYpOVj"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="g/NYpOVj"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=f3wWKC1P; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-nfs+bounces-3453-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3453-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f44c9aa814si85373725ad.425.2024.05.28.16.12.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 16:12:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-3453-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="g/NYpOVj"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="g/NYpOVj"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=f3wWKC1P; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-nfs+bounces-3453-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3453-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7FB94286DCB for ; Tue, 28 May 2024 23:11:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F4D517C6A; Tue, 28 May 2024 23:11:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="g/NYpOVj"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="f3wWKC1P"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="g/NYpOVj"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="f3wWKC1P" X-Original-To: linux-nfs@vger.kernel.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 BBBD313F439 for ; Tue, 28 May 2024 23:11:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716937911; cv=none; b=JiOf0esX+Rk3iXbrOwolARkuHgzychmsp/kBxkl8oI2ZjFKx8NzV6rHFrdtOa1q4aMJAu1gQzKBvBNSRKhxSDMDCR+vRPi1ieYR+qTV+Mt/HwXLfO6W30prZlOGR8fmaf1eAbgZdndpilEBbth+Yhp6v64nEYlR1OPm5URXadYc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716937911; c=relaxed/simple; bh=Pr/zuvVfu3WX5N1zSgvQXQLN458F0kD26XwV73Gktl8=; h=Content-Type:MIME-Version:From:To:Cc:Subject:Date:Message-id; b=KzvK9jKkdLqxheMCL8bpVlu3v7Q4BlZ5913IqwSVIRx8RzcVwIiVnPgFOiRm4fCQX9K4qznYdZ4+//sTAsCWiAJKQnNwu606LM1d3V7w7tC3FRN7LLhJW+dD9KSGpv3VtrUcDNihE+FkGFEK0vXQ7HpjpBXlG2lqa0A6fSANM6A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=g/NYpOVj; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=f3wWKC1P; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=g/NYpOVj; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=f3wWKC1P; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 798962048F; Tue, 28 May 2024 23:11:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1716937907; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=d1xqmsHesKNSciEDfpS+I8mFJOg6lBIUMD8j40NmKSw=; b=g/NYpOVjbrdfn4O6dgStOLYbVgetLazT5DM1EJUCgpLbUysPZ7wBW+d4fvBgp+eXq6DNe7 hFgT8lhXFyYBrJ6kohxi7LLPUjjJr3GhAvl6YE1WHABnyHtbO7pm8nN53Nptbc7LQ5fsc2 PRvSlFkfGQYu47wbO9bcXTDno1OsKqQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1716937907; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=d1xqmsHesKNSciEDfpS+I8mFJOg6lBIUMD8j40NmKSw=; b=f3wWKC1PnTSwhP34GDnKLrZunQI2LVxxGgyCJ97xfSjDdR0BJbo25EeGOOZssZFJJMIZ8x 3y1H3ozSRAWefPAA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="g/NYpOVj"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=f3wWKC1P DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1716937907; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=d1xqmsHesKNSciEDfpS+I8mFJOg6lBIUMD8j40NmKSw=; b=g/NYpOVjbrdfn4O6dgStOLYbVgetLazT5DM1EJUCgpLbUysPZ7wBW+d4fvBgp+eXq6DNe7 hFgT8lhXFyYBrJ6kohxi7LLPUjjJr3GhAvl6YE1WHABnyHtbO7pm8nN53Nptbc7LQ5fsc2 PRvSlFkfGQYu47wbO9bcXTDno1OsKqQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1716937907; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=d1xqmsHesKNSciEDfpS+I8mFJOg6lBIUMD8j40NmKSw=; b=f3wWKC1PnTSwhP34GDnKLrZunQI2LVxxGgyCJ97xfSjDdR0BJbo25EeGOOZssZFJJMIZ8x 3y1H3ozSRAWefPAA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 7CE4C13A6B; Tue, 28 May 2024 23:11:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id bC15CLBkVmZsAgAAD6G6ig (envelope-from ); Tue, 28 May 2024 23:11:44 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "NeilBrown" To: Trond Myklebust , Anna Schumaker Cc: james.clark@arm.com, ltp@lists.linux.it, broonie@kernel.org, Aishwarya.TCV@arm.com, linux-nfs@vger.kernel.org Subject: [PATCH] NFS: abort nfs_atomic_open_v23 if name is too long. Date: Wed, 29 May 2024 09:11:36 +1000 Message-id: <171693789645.27191.13475059024941012614@noble.neil.brown.name> X-Spam-Flag: NO X-Spam-Score: -4.51 X-Rspamd-Action: no action X-Rspamd-Queue-Id: 798962048F X-Spam-Level: X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[99.98%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; MISSING_XM_UA(0.00)[]; TO_DN_SOME(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; FUZZY_BLOCKED(0.00)[rspamd.com]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] An attempt to open a file with a name longer than NFS3_MAXNAMLEN will trigger a WARN_ON_ONCE in encode_filename3() because nfs_atomic_open_v23() doesn't have the test on ->d_name.len that nfs_atomic_open() has. So add that test. Reported-by: James Clark Closes: https://lore.kernel.org/all/20240528105249.69200-1-james.clark@arm.co= m/ Fixes: 7c6c5249f061 ("NFS: add atomic_open for NFSv3 to handle O_TRUNC correc= tly.") Signed-off-by: NeilBrown --- fs/nfs/dir.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 342930996226..2b09b5416ef1 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2255,6 +2255,9 @@ int nfs_atomic_open_v23(struct inode *dir, struct dentr= y *dentry, */ int error =3D 0; =20 + if (dentry->d_name.len > NFS_SERVER(dir)->namelen) + return -ENAMETOOLONG; + if (open_flags & O_CREAT) { file->f_mode |=3D FMODE_CREATED; error =3D nfs_do_create(dir, dentry, mode, open_flags); --=20 2.44.0