From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) (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 AAD8E1519B4 for ; Sat, 23 May 2026 01:40:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779500442; cv=none; b=VbpR5QwjjQmihrNt/xNxvANLCq8Qoa6Cvrd8PAURoWsfEGXmjuBdGVVuKkhbI6p1VhxbkKhD292fCRiJIp+wc6Eo8EM50I0sdb9sD7i3sg7HFbIAeE6RRiCFrHrXXicSnpSx3Qo2U9cZF56bKHike3p5Q7jgE1L/WRP0QLC4SdI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779500442; c=relaxed/simple; bh=Jrh2Ths5M2cZbexD4fdGj4nn4YBf8xzcRfAWuFjG/4M=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=oZdmYxBPw3iikPqpW0RYhwCbTSAdEdVlYx2S+5pkSJB+SaXVGgpDohmed6UtrUW2VriChF4VqRH8XzoHqXtzkPkoerscIfPVjdX4OJ1AE7jb4tc6viOLOEQQpJKvApYSORka4mr3oyDTIU5B0lLh8iUZDNnie8J3zp7YsaeP1JE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FkdwRd7d; arc=none smtp.client-ip=209.85.160.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FkdwRd7d" Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-50e614fdb42so62313791cf.3 for ; Fri, 22 May 2026 18:40:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779500439; x=1780105239; 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=NBkz8uk++9agYLdO2eZoJHgoe4NIS1dR5QrU5vkKjfM=; b=FkdwRd7dMfHEmCtqhjZSX2DvsA/hhKDiVAvWLOLwiKhuSNMSAVoaNWd3AFlxM/t/rQ dzAxDSAqmI0xidi0ns1U9pMSktGQw6ClL86D6qAM9GrRPlAVSdvkUslUZF6IP09bFUhU jdoTQSHeUhMkvKOAXRWT/py8zzZ8JiWPeYTD3i/Q7SBz8MrS1VKppM+ep52ZpB6LQSF8 J2PhoZs7F3SkGSw5Tl8KvdBNoJlLkKfHuwFjwpaGFj+lQjMBCYKxmMKH9KjA2HAB5N/0 3IqlM85o2RaqkDtqZenQP5byD2rtemsGfkt1o0obv8rqP9FSP24mJRtF+myfUAmXLyqw 19wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779500439; x=1780105239; 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=NBkz8uk++9agYLdO2eZoJHgoe4NIS1dR5QrU5vkKjfM=; b=as/ZdLBomfm0r+McjnerdzCr0pcNDesTViy/b1r+I+92ZKjM+O/yqA2EQYMcyD/DNX MAnZJ7elDmSbiVFX01/3itWGuiWwgRKErLK18F6SociKnoAfXnE3cUNL9fwpg2RVORXx nDgc0wxyZPDrg/3rtjBpChCpq+d83clX6bdtao+7Tlv2EEuUjl+uGj7QYD2/eXrBec1y M2v2ZKfrUoLf1IYAEAkZUFyNMutO8Fsg9UFzImCINR8nLjFmAliaj9YKLZuGqzbF3vqX ZHP7ma0JbGSFj0SPIYXOt5iTw2NDSKY0N/35M5nL1fUfA3XWZbC+BbCF6AN3LVmbN0oU ELww== X-Forwarded-Encrypted: i=1; AFNElJ8YjzGtHJ+KqcYc55aFdleNtKujb+PIVvoqiN6nm/6Gzm6ZX0lRrmiQ3uKLEJW1B0ZSKwMSyjbuOKQSaSs=@vger.kernel.org X-Gm-Message-State: AOJu0YxlReDfvTJ/YuW5iBMxjL565X3GFOHr6rnRX90kTjgVbR6oEYzE PwX//FWGegHS2YSQOsV/vWnslTFnm7LQGFbD/1ANzzqjHe4jWgjygm4b X-Gm-Gg: Acq92OEG4To2tC5gnZkwQzqzbkG/q4f477qX2Yn1su4/vKc+R21SYFSuxuuXAMcREa4 KMzgzv9akf5ZOVBN4thdLOoHxEzbBBwBfPDph5Sj5Khuo9ej1xMXd4HiZqS4LdUYs7TbcVebmXw Pm9eDL4gcwSMuAy1WCkkBK2ZtnrasY2V6tY7l8e8ri5HbxpbPcKyAAYGnxhBSBZpIxeiSKtAV8r IbgIfQpdLJVcRAfxqeFRJ9cx5tuqZu1SNLh4P2J7DLgfg+GWuvpnz7fxTpX9akkrBXYAP2JNnAT S3Q7fTmGb3xeWadA0y/voIh/gPRAZCUo12iSeTga5RVgPlb+uuQd4jDd754krEcdBK5pyVDPhcd 7lv2vVck9wK0wjpW0B/7KzOYPTlgpgAlPc4AaNqLOJ5UPEyzdM8Xv58gD+Vh700W5yf1vdKBDEN N6HLmnlJ9XYnpLm7o9bPOzrpJBlJFaj0R0l7kc1S5hG4uHCE13Ere3oBd0iKzjXTiRjVcJx/88R wTt8Zf3eMdYbPisvcyi X-Received: by 2002:a05:622a:6115:b0:516:51da:ae52 with SMTP id d75a77b69052e-516d43cb30amr84067831cf.33.1779500438698; Fri, 22 May 2026 18:40:38 -0700 (PDT) Received: from server0 (c-68-48-65-54.hsd1.mi.comcast.net. [68.48.65.54]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-516d8b247c4sm28559031cf.7.2026.05.22.18.40.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2026 18:40:38 -0700 (PDT) From: Michael Bommarito To: Trond Myklebust , Anna Schumaker Cc: Jeff Layton , Tom Haynes , Peng Tao , Kees Cook , Mike Snitzer , Tigran Mkrtchyan , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 0/2] NFSv4/pNFS: fix client kernel panic from malformed GETDEVICEINFO Date: Fri, 22 May 2026 21:40:31 -0400 Message-ID: <20260523014033.2459677-1-michael.bommarito@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit A malicious or compromised NFSv4.1+ pNFS metadata server can panic any pNFS-flexfile client by returning a GETDEVICEINFO body with a multipath-DS count of >= 3 and exactly one valid (netid, uaddr) pair. The unbounded inner loop in nfs4_ff_alloc_deviceid_node() (and the parallel site in nfs4_fl_alloc_deviceid_node() for the legacy file layout) keeps iterating after the first netaddr is decoded, consuming the trailing version_count / version / minor words of the body as opaque netid + uaddr pairs. Both come out as zero-length strings; xdr_stream_decode_string_dup() sets *str = NULL and returns 0; the caller in nfs4_decode_mp_ds_addr() only checks "< 0" and immediately calls strrchr(NULL, '.'). A QEMU/KASAN reproducer is described in the second patch. The shortest crashing GETDEVICEINFO body is 56 bytes, the panic is 5/5 deterministic at multipath_count = 10, and it fires before any user-level read can complete on the first pNFS file the client touches. Patch 1 closes the NULL dereference itself by changing the two xdr_stream_decode_string_dup() return-value checks in nfs4_decode_mp_ds_addr() from "< 0" to "<= 0". Patch 2 promotes NFS4_PNFS_MAX_MULTI_CNT to include/linux/nfs4.h so flexfile and the legacy file layout can share it, bounds the inner mp_count loop in both drivers against that cap, and breaks the loop on the first NULL return from nfs4_decode_mp_ds_addr() so a hostile server cannot drive the decoder past a single malformed entry. Either patch alone closes the panic; both together close the latent unbounded-decode class. The unbound on mp_count predates the flexfile driver: the same loop exists in the legacy file layout since 35124a0994fc ("Cleanup XDR parsing for LAYOUTGET, GETDEVICEINFO", 2011) and was carried into flexfile by d67ae825a59d ("pnfs/flexfiles: Add the FlexFile Layout Driver", 2014). The NULL-deref site was introduced by 6b7f3cf96364 ("nfs41: pull decode_ds_addr from file layout to generic pnfs") when the netaddr decode was unified. Stable backporting wanted for all three. Cc: stable@vger.kernel.org Michael Bommarito (2): NFSv4/pNFS: reject zero-length r_addr in nfs4_decode_mp_ds_addr NFSv4/flexfile,filelayout: bound multipath DS count in GETDEVICEINFO fs/nfs/filelayout/filelayout.h | 2 +- fs/nfs/filelayout/filelayoutdev.c | 7 +++++-- fs/nfs/flexfilelayout/flexfilelayoutdev.c | 10 ++++++++-- fs/nfs/pnfs_nfs.c | 4 ++-- include/linux/nfs4.h | 3 +++ 5 files changed, 19 insertions(+), 7 deletions(-) -- 2.47.3