[nfsv4] Re: knfsd related bug reported to FreeBSD

Pali Rohár <pali-ietf-nfsv4@ietf.pali.im> Wed, 18 December 2024 13:02 UTC

Return-Path: <pali-ietf-nfsv4@ietf.pali.im>
X-Original-To: nfsv4@ietfa.amsl.com
Delivered-To: nfsv4@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 2F39CC14CEE4 for <nfsv4@ietfa.amsl.com>; Wed, 18 Dec 2024 05:02:01 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.003
X-Spam-Level:
X-Spam-Status: No, score=-2.003 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_BLOCKED=0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_BLOCKED=0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=pali.im
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yOgJ8f6n1vS1 for <nfsv4@ietfa.amsl.com>; Wed, 18 Dec 2024 05:01:56 -0800 (PST)
Received: from pali.im (mail.pali.im [IPv6:2a02:2b88:6:5cc6::2a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 6B5F8C14F60E for <nfsv4@ietf.org>; Wed, 18 Dec 2024 05:01:55 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pali.im; s=mail; t=1734526904; i=@pali.im; bh=7cn6wWYJSBGOP+2F85QvXdcK7bWCKcTemDvdtt7lJPk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Bmhc51z3+Akt2jeQ3qYxljgKL6QZGn+3sVyG06lHbF429TElvT57kflVrnouBHOSq cZweammjqMndD7niFdzqo3ED1iEBz6YHzxupihIaFWBUV7+nXvV4a+dzjNlU0oLIqz C5lTV8JloDKApqzCfoZX0makF+VwEemFonLGyDlrkuspxpSTvHum4daHjdQZEyt6/M mbjcdaPfr5t8S98fF20C/WUrSKvjkYuSzxiBDunzPTM47bOk29uOwuERgNAkJK6gan m5r83dSS5e68QbF3goTR6ikC3sh8rhiV0Q+f9Am8GUVT36PHvdvRd0O8Glr3wDpi6v e9F/HmbggAOHg==
Received: by pali.im (Postfix) id 306215C0; Wed, 18 Dec 2024 14:01:44 +0100 (CET)
Date: Wed, 18 Dec 2024 14:01:44 +0100
From: Pali Rohár <pali-ietf-nfsv4@ietf.pali.im>
To: Rick Macklem <rick.macklem@gmail.com>
Message-ID: <20241218130144.ko5duotn66x72lzx@pali>
References: <CAM5tNy4q61V=JNB569wuFPpLVgvYkPMX=ENhwTpWanZkRFydAQ@mail.gmail.com> <20241214005858.k2jisy46njaegxkg@pali> <CAM5tNy6C9FRJ+rHXHbq+Ap+5rtZWnd33GOmXxZfjR_1X1hr01w@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <CAM5tNy6C9FRJ+rHXHbq+Ap+5rtZWnd33GOmXxZfjR_1X1hr01w@mail.gmail.com>
User-Agent: NeoMutt/20180716
Message-ID-Hash: 4FT6XVYW2CGWZMKLWBSKZHNY43TEKGG3
X-Message-ID-Hash: 4FT6XVYW2CGWZMKLWBSKZHNY43TEKGG3
X-MailFrom: pali-ietf-nfsv4@ietf.pali.im
X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-nfsv4.ietf.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header
CC: NFSv4 <nfsv4@ietf.org>
X-Mailman-Version: 3.3.9rc6
Precedence: list
Subject: [nfsv4] Re: knfsd related bug reported to FreeBSD
List-Id: NFSv4 Working Group <nfsv4.ietf.org>
Archived-At: <https://mailarchive.ietf.org/arch/msg/nfsv4/-KxtEtsaWtIXvD-Zi2CgMQFMNcs>
List-Archive: <https://mailarchive.ietf.org/arch/browse/nfsv4>
List-Help: <mailto:nfsv4-request@ietf.org?subject=help>
List-Owner: <mailto:nfsv4-owner@ietf.org>
List-Post: <mailto:nfsv4@ietf.org>
List-Subscribe: <mailto:nfsv4-join@ietf.org>
List-Unsubscribe: <mailto:nfsv4-leave@ietf.org>

On Friday 13 December 2024 17:02:17 Rick Macklem wrote:
> On Fri, Dec 13, 2024 at 4:59 PM Pali Rohár <pali-ietf-nfsv4@ietf.pali.im> wrote:
> >
> > Hello Rick,
> >
> > Just a quick reply. I have not looked at the pcap yet but I know that
> > wireshark incorrectly decodes some of NFS4 packets with GETATTR opcode.
> > I have my own modification of wireshark to fix this problem.
> >
> > So it could be possible that server is sending the correct reply and
> > just wireshark dissect it incorrect.
> >
> > I'm not saying that it is this case, just to be aware of it.
> In this case, I am looking at the hexadecimal for the on-the-wire
> packet and it does not look correct.
> 
> Also, FreeBSD fails the reply as incorrect XDR.
> 
> rick

Now I have looked at your pcap and I'm confirming that the packet #22 is
really incorrect. It is not possible to decode XDR buffer, as you wrote.

> >
> > Pali
> >
> > On Friday 13 December 2024 16:47:45 Rick Macklem wrote:
> > > Hi,
> > >
> > > The attached pcap file shows that the knfsd server generates
> > > bogus XDR for the reply to a GETATTR that follows a READDIR
> > > operation.
> > >
> > > More specifically, if you look at the pcap file in wireshark
> > > and go to packet#22 and then click on the operations and
> > > then "Opcode: GETATTR (9)", the start of
> > > the XDR for the GETATTR will be highlighted in the hexadecimal
> > > window.
> > > Now, if you look at what follows (in the hexadeciaml window),
> > > you'll see that the GETATTR reply looks like:
> > > - GETATTR (9)
> > > - NFS4_OK (0)
> > > - Length of bitmap (0) <-- Not (2)
> > > - 2 words of attribute bitmap
> > > - 98 (length of attributes in hex)
> > > - attribute values
> > >
> > > Everything looks ok, except the number of bitmap words is
> > > 0 and not 2.
> > >
> > > Since the knfsd does not do this normally, I'd guess it is
> > > some sort of runaway pointer or use after free type bug that
> > > causes this, maybe?
> > >
> > > Sofar, it only appears to happen when the GETATTR follows a
> > > READDIR operation.
> > >
> > > This was reported to me for a FreeBSD client mounting the following:
> > > Debian 12 w/kernel:
> > > $ uname -r
> > > 6.1.0-25-amd64
> > >
> > > > - what type of file system it exports
> > >
> > > ZFS:
> > >
> > > $ dpkg -l | fgrep libzfs4linux
> > > ii  libzfs4linux                    2.1.11-1
> > >                amd64
> > > I suspect that ZFS exports are not common for the Linux knfsd?
> > >
> > > Anyhow, I am not sure if you have seen such a problem before,
> > > but I thought I would at least report it.
> > > (I have cc'd the reporter, in case you have questions for him.)
> > >
> > > rick
> > > ps: If the pcap file does not make it through the mailing list, email and
> > >       I can send you a copy.
> 
> _______________________________________________
> nfsv4 mailing list -- nfsv4@ietf.org
> To unsubscribe send an email to nfsv4-leave@ietf.org