From nobody Wed Nov 24 09:47:47 2021 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 3B82018A0618 for ; Wed, 24 Nov 2021 09:47:48 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hzbll5N6Mz4rrl for ; Wed, 24 Nov 2021 09:47:47 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9554227B0F for ; Wed, 24 Nov 2021 09:47:47 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 1AO9llGZ050173 for ; Wed, 24 Nov 2021 09:47:47 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 1AO9ll2D050172 for bugs@FreeBSD.org; Wed, 24 Nov 2021 09:47:47 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 260012] NFS v4 client can crash server with a bad LAYOUTRETURN RPC Date: Wed, 24 Nov 2021 09:47:47 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: rtm@lcs.mit.edu X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.mimetype attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1637747267; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kP/M5zvTU/6sUqtbu7Vj22s2b4g1Pn1PfMHkikQCb7A=; b=GR33Sowi6NgQHY7fu8du4IxynbiF9K/ZIOXb2mtOV+P4Y2C2yK/j6C7gl90skOh6bwvhQF i3kR6xGIRnZpPrvHhRP9f8y0h5gyaxGT4ph5nKZfT/RF73mpySXohf+yoB69S+3prXclM0 UIdlpD3yjDL8SGBN6udu8lSttxdrEUPs2xsVCvkM2a3UcFkzvfFowwEBFXeQY8xITvaMox D8po4iHnhjvIxM1ESH91jrWF+H0Of514KudBlCmQ59ueVLgi5YBNLTsFwFiSCbCTuYu0sg 97dMoyetadKp7lo9DfCeNI9YtzSNdisIvES/fB54wNdEzn/aa4FbwmxV5DGYag== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1637747267; a=rsa-sha256; cv=none; b=fsMiVBQ+qSfJ4DJFVWUpV5Yl2gPp3aZd2tawUZ0tAHUz0YLrdbByCLn/IIzXObjoR5b76a F0Krwf3jHLfm7I83DVDVENnVS3IsoukB9b+TsP8sMY/a2KSn2j2DE3K/eJITAlJCRBXLLL 6KmPWY7PZ/3liPQd+dkQKqocvGJc59grV7GrFKfnhpmWNMqVhgdEWKD7o/9vfgvWuSiaZJ WaMif38d2LeE4vtokXyUFy471osoGk79Ec0/bXaIR6WGUVRH+EWtaxeA35bVJaVo8LhnkF /yu1djjXD8LD96mo2R4z5EtluYS0LhYTBdjTCCR/M2NX8MCRDStTTAiejue6sg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D260012 Bug ID: 260012 Summary: NFS v4 client can crash server with a bad LAYOUTRETURN RPC Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: rtm@lcs.mit.edu Attachment #229690 text/plain mime type: Created attachment 229690 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D229690&action= =3Dedit An NFS client that crashes the server with a bad LAYOUTRETURN. If an NFS v4 client sends a LAYOUTRETURN RPC with lr_returntype of NFSV4LAYOURRET_FILE and an lrf_body<> size <=3D 0, nfsrvd_layoutreturn() will pass a NULL layp to nfsrv_layoutreturn(). If the RPC also has layouttype=3D=3DNFSV4LAYOUT_FLEXFILE (4), nfsrv_layoutreturn() will call nfsrv_flexlayouterr(). The latter dereferences layp (as tl) without checking for NULL. I've attached a demo: # uname -a FreeBSD 14.0-CURRENT FreeBSD 14.0-CURRENT #96 main-n250901-77e3db078984-di= rty: Tue Nov 23 16:58:28 EST 2021=20=20=20=20 rtm@xxx:/usr/obj/usr/rtm/symbsd/src/riscv.riscv64/sys/RTM riscv # cc fnfsd_1.c # ./a.out ... nfsrv_layoutreturn: updatemdsattr failed=3D2 panic: Fatal page fault at 0xffffffc00025ce8e: 0000000000000000 cpuid =3D 0 time =3D 1637591542 KDB: stack backtrace: db_trace_self() at db_trace_self db_trace_self_wrapper() at db_trace_self_wrapper+0x38 kdb_backtrace() at kdb_backtrace+0x2c vpanic() at vpanic+0x154 panic() at panic+0x2a page_fault_handler() at page_fault_handler+0x1ee do_trap_supervisor() at do_trap_supervisor+0x76 cpu_exception_handler_supervisor() at cpu_exception_handler_supervisor+0x70 --- exception 13, tval =3D 0 nfsrv_layoutreturn() at nfsrv_layoutreturn+0xa6 nfsrvd_layoutreturn() at nfsrvd_layoutreturn+0x35c nfsrvd_dorpc() at nfsrvd_dorpc+0x154c nfssvc_program() at nfssvc_program+0x5a4 svc_run_internal() at svc_run_internal+0x808 svc_run() at svc_run+0x1a8 nfsrvd_nfsd() at nfsrvd_nfsd+0x30e nfssvc_nfsd() at nfssvc_nfsd+0x386 sys_nfssvc() at sys_nfssvc+0xd0 do_trap_user() at do_trap_user+0x206 cpu_exception_handler_user() at cpu_exception_handler_user+0x72 --=20 You are receiving this mail because: You are the assignee for the bug.=