From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oa1-f42.google.com (mail-oa1-f42.google.com [209.85.160.42]) (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 A4B16428842 for ; Wed, 27 May 2026 16:30:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779899456; cv=none; b=qRDZyW1q+gD74A01/RY26CSrVwFPAOko61adlL3g6mCqGdRSNETEcfG2smwbJVYUIsjWiQWKftAOzVEQeVqCwY/Lo6zlppBjrGxWNB+qopdVsBiTG+pAo96jg1dMwm03VxXKZEdZD9kvHmfHVKUismQrejfUf4Sun51T89xzkfY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779899456; c=relaxed/simple; bh=fq1RxNL89gaa1wj5IiD/KH3yhOhugHwkF3eND9ymod0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=M+3mWUP/lycQVkJ+gudjXRuxqfUMn827f9EvZf7LkbXjYm3XZkdLNlQlvXhNRGI8otfQ1C2qNIRNRht/U+Tr/lSoZ1GPWKZ6VEaysqehC2jPblg9H8fmZKBF2czVHiEwn9vhiWuSZr2VLlKhdAgB9+Zu+n5/x/Hj36kEWKND078= 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=G6JF0cbf; arc=none smtp.client-ip=209.85.160.42 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="G6JF0cbf" Received: by mail-oa1-f42.google.com with SMTP id 586e51a60fabf-439712b3416so4167060fac.2 for ; Wed, 27 May 2026 09:30:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779899453; x=1780504253; 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=QvE27vjOj0oBAYN3EfYXrsSdY9/XabQfXIQ55p1R04c=; b=G6JF0cbfLAGNpAknp56cYrx8d0yZ0W6+2ZRrgm2h1fhS1bEDXypNccnMEGEJBMmhAh /dlomDt9uU+14rdzPII/HcD78q54TvbJbxCN/hycNjwcwrzt5jaK19YNvZ6eSH3L9vXE z7pdzkcJ27tf65tyMWHqs/Rwu3XFbHdZ08y+NpxER1To+QbYmrh36vdXJVOkhMfUEadF fslmken6+zNwvMbtkWfBULBVX35BJUDiituT+1wQS6dHIEX34Ny2FMat2emQo9/Etje9 vjABI8ymkfG2jyyNNoNfeX2yYoHJOlCeISSWNF2UUCu6ptWcTew15Wg5a5NA8ZiWd8v+ HPxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779899453; x=1780504253; 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=QvE27vjOj0oBAYN3EfYXrsSdY9/XabQfXIQ55p1R04c=; b=ny1Sk36S2IAhCLXhXyL74zVD+SGpWS3+3aOV8WwH7USjxFP3TJWKsYEEcBt9yw4Ksk OjKYgD7PqgPT0U1Zr5zx4Ft0sQLG318b/24VUKjfxB7xDS+UvphtGJ8udmEtAH+eQB1m floPZjVzanZR5jolQQwQEQvd/hdTDx+ModcwVlM3bn49xZPK9ylZi8Mg9ULe+XWvt5rX ZfgvGRVVi8gbWNjUCCU9kMbzVe4VNIfmz5ZxmzbzlEoH1ZgkVp9r3vn9OijEVVlIZa2v 0EFX8vAdycIEi1jERasObO+Ket7YLklVZhwFcAIPQ7ydqtXE8HCD9pfnti5Oy2EySSqN xKSw== X-Forwarded-Encrypted: i=1; AFNElJ+dtmOog613YdNBoYoQs/orXk7PgBfC/8VnNbxhwDk9a9NQ0e5JuPigtcZU6OnqwV0Jdt8AMTHXwM+iNug=@vger.kernel.org X-Gm-Message-State: AOJu0YzhBvGA44RKRnuGMEvPF5U3/ZgW/9rJGpOR4jZoxQ6fQPfm/Xkl EukTUbTvojytD0dYMlgbnh7RC3NvFR0oUj1ytvU05k9auOL47r8BpK1T X-Gm-Gg: Acq92OGmB8F6YLddJ/EPQx4jngXH/2h15ab5TAKFpMLpjIUw30Cq26Irub7eHCgnTVF 29Es/E73fFb5REgo+8XEKXfNCu9mvyXdp3Cu+zxD1BBzet5LvQRB2R6nNm+MmvCI2LBN3ORW9Dn Qvo22ONlRssvCe5dx2+OJLvIZN7C6KoVNItV0StucfgjrQI1EveYYy6R1KuSOcZU+ho+b30sobv lIF2Dn6ltnpFlUIskaudvtEvsrUq8qI9nxc/4fuD7AJhb/mWHcSaZ85mBUGGFeSwqoD/c3lUVij BwTsm9bJ0QGxcOIiosVif/jz1SWVxn9c1J4PSu5jJKZTyMFxbJ/HoTQHXqboM9pDQRW5qISdwXx 9nJHgIXs4cInW3N+z/D7Gc9ydzd2A6axDXgY2ttPi/aXmlOlPRlpxr6BbltF8jpC8mvz6pbQldS 34GOWX5gajg2P8/SIf/3c40beVOHipN76sD5kwi5EmRRBRbL0fvzdGPu6krMYBtqTAJzUyYdTqv XcS/4iudSE6CAsI1dtdQ0rlEO0gPh4/J02eRyX4N+g= X-Received: by 2002:a05:6820:4c08:b0:69d:521d:a4fc with SMTP id 006d021491bc7-69d7ead810amr12080874eaf.8.1779899453213; Wed, 27 May 2026 09:30:53 -0700 (PDT) Received: from server0.tail6e7dd.ts.net (c-68-48-65-54.hsd1.mi.comcast.net. [68.48.65.54]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8cc812e0413sm188819356d6.31.2026.05.27.09.30.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2026 09:30:52 -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 v2 0/2] NFSv4/pNFS: fix client kernel panic from malformed GETDEVICEINFO Date: Wed, 27 May 2026 12:30:34 -0400 Message-ID: <20260527163036.1524927-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. Changes in v2: - Carry the stripe_index provenance comment from filelayout.h to the new NFS4_PNFS_MAX_MULTI_CNT location in include/linux/nfs4.h, as Anna requested. 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 | 5 +++++ 5 files changed, 21 insertions(+), 7 deletions(-) base-commit: 0a0e44d91ce037ac5371b0d8dfbbfc5f693b27c7 -- 2.53.0