From nobody Mon Nov 29 11:18:59 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 4F47C18BFFC1 for ; Mon, 29 Nov 2021 11:18:59 +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 4J2jXg02Rkz3Qlk for ; Mon, 29 Nov 2021 11:18:59 +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 D528621839 for ; Mon, 29 Nov 2021 11:18:58 +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 1ATBIwvX029657 for ; Mon, 29 Nov 2021 11:18:58 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 1ATBIw49029655 for bugs@FreeBSD.org; Mon, 29 Nov 2021 11:18:58 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 260111] NFS v4 server crash due to ACL handling Date: Mon, 29 Nov 2021 11:18:59 +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=1638184739; 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=cdZhJt1a9ACJzyOY1TxYihNuw4dznxYLwP+q/dXtmU0=; b=cpg8dQXIxXVWtKQUSsj2pi29JaFHJFR4sp0eoPpp0LoxRLvE2l8icCtAHJjwlteKijiqif o/j48cuweE3NzRwNAfeZew/4fon1nCzPE96LshTb+4/i3hQ/UwfAPv6r9672TJTj1euzew 4ra7MNWZwy4/MX+QQUoK6GjjOXIiP24KkWFPq5HiM36iWgj5YtrDf5mJvJ3aX9nBNcH+iv mCQNHG5J+ap/c4q4pULj3eUh5HO1qadjJ42HrkvsFqoP/PiNPHBnaTXaglfjOly9a4zNv6 bAfJEAtJB3ZXV7QURClOPgFVLwSrcTWgtaHofNafhEACdxXyJPl4tE7ZA/szxA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638184739; a=rsa-sha256; cv=none; b=a/YC1yJBvejQghsW4zxoscEcyApKC0w4oHTRZQhvj0PtprfaNw0a0fHDidIIqbsGpahaGz Y53Bje1w5DUCG5VRjVSMrI2PeLN5R3rXEGg8Fb3ttRuc6McaLRXhykIdlMUByxqqTi/k/W ZUmy5xEr7qeJiwx7zu577/6hCWlhECI5m7+caXsR4kig/D4+oa1NdZ8/3BCV5wgFrXGDKK GPxV8kbrL7KVXpDmp3eQWpnMpwsKNCXXlgaiVU2CnxZvtghu6zyVY1CfoTqqh8o8reA7pP 4zMuCfJHKlDqXSvW/owkq/xBdAQQcpDaEnTeFSzRfU5pCHs9sZa7dCrq96p2xw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D260111 Bug ID: 260111 Summary: NFS v4 server crash due to ACL handling 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 #229786 text/plain mime type: Created attachment 229786 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D229786&action= =3Dedit Crash in NFS server's nfsm_advance() due to bad ACL attr. nfsrv_dissectacl() doesn't set *aclsizep if nfsrv_skipace() returns an error. But there are paths through the NFSATTRBIT_ACL code in nfsv4_loadattr() in which attrsum +=3D cnt despite nfsrv_dissectacl() returning an error -- in which case cnt is never initialized or contains junk from a previous attribute. As a result attrsum can end up negative, so that nfsv4_loadattr() calls nfsm_advance() at the end even though maybe it shouldn't. Further, when nfsv4_loadattr() is called due to a client's VERIFY, and the VERIFY contains an ACL attribute to compare, but the file has no ACL, nfsrv_dissectacl() calls nfsrv_skipace(). nfsrv_skipace() skips forward in the query by the client-supplied length of the "who" string. If client specifies a huge length, nfsrv_skipace()'s call to nfsm_advance() will leave nd->nd_md =3D=3D 0. Then the call to nfsm_advance() at the end of of nfsv4_loadattr() will crash when it tries to use nd->nd_md. I've attached a demo: # uname -a FreeBSD 14.0-CURRENT FreeBSD 14.0-CURRENT #109 main-n250904-c4c468281fb6-dirty: Sun Nov 28 06:24:00 EST 2021=20=20=20=20 rtm@xxx:/usr/obj/usr/rtm/symbsd/src/riscv.riscv64/sys/RTM riscv # cc fnfsd_7.c # ./a.out ... panic: Fatal page fault at 0xffffffc0002107a6: 0x00000000000010 cpuid =3D 0 time =3D 1638181422 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 0x10 nfsv4_loadattr() at nfsv4_loadattr+0x3efe nfsrvd_verify() at nfsrvd_verify+0xd6 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 --- exception 8, tval =3D 0 --=20 You are receiving this mail because: You are the assignee for the bug.=