From nobody Wed Dec 01 15:14:36 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 3562418AE3EA for ; Wed, 1 Dec 2021 15:14:37 +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 4J42gc5pB8z3G4w for ; Wed, 1 Dec 2021 15:14:36 +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 A8891407B for ; Wed, 1 Dec 2021 15:14:36 +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 1B1FEaQS066769 for ; Wed, 1 Dec 2021 15:14:36 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 1B1FEanr066768 for bugs@FreeBSD.org; Wed, 1 Dec 2021 15:14:36 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 260155] inadequate LAYOUTTYPE sanity check in nfsv4_loadattr() Date: Wed, 01 Dec 2021 15:14:36 +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=1638371676; 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=NeEOUhKPjCfC8FdwyTc8TsAZZQwrZ8peljkDqF4Nj5U=; b=F2z5TGFztlxWwjku3stpkd9JzLY0rZBQJwpsc/BUV52w7cpvQTuGJKgMQ3h5qMvvwdKKMX daC41sErpHvqqoYAsdNweBhZD3ztjfXJRbiwL6Q73ZZ2+Z+A6N/swB6mJS6Qm1h7W25t6R KjRdeaFtHtEhc/12Bd+NHFJZcPTrcwGraFj4pTbRBP+OQAJu89XykpRac3TXe4q40FPnGl Rj95y/0noc2fxprjKJLY0Xwn9pS56bi6prPEbYMqgxiteeqhPrB6gRR5sJzZkhGcx4NEkD muk35JXwjq40zmqIWyOe9uGuB94EMXFBXsd2bws4HSUOo/ozJnKxUVz/QYr2kg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638371676; a=rsa-sha256; cv=none; b=ZfCgsdL17tP83czgOpqgnakdqV67sHnqOmHS0KESjDQBNDH8xsU5tZ9srlayatooA8ZCQw N3q0y6sUVhHWo029XNfErtie0VWTUJMoLPIKLCUoNf7wUZZcXIpait7kwE8QEFlnYJ/0Cb SarG0KzJ0eIAFMV4N6mwIR/ZaoYPxXYWXqYGubN/Y9DaXcoPTHoxl5QiShrbD0eND4p6pE Pk4J0DEva+HabQ4wD5W4US5KKSUZYpHMvw4PcU81Gxbjxzsw6GceIwz1FQ+6ziyV/AEXOI BuojtBmCiIhSxErVQezPEnfuq7Ndcgs8/xfqAFZI7KhPjXcj6e4OmmVqvOA1YQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D260155 Bug ID: 260155 Summary: inadequate LAYOUTTYPE sanity check in nfsv4_loadattr() 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 #229829 text/plain mime type: Created attachment 229829 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D229829&action= =3Dedit Crash an NFS server with a broken LAYOUTTYPE attribute. In this nfsv4_loadattr() code: case NFSATTRBIT_FSLAYOUTTYPE: case NFSATTRBIT_LAYOUTTYPE: NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); attrsum +=3D NFSX_UNSIGNED; i =3D fxdr_unsigned(int, *tl); if (i > 0) { NFSM_DISSECT(tl, u_int32_t *, i * NFSX_UNSIGNED); If the RPC contains an i that is positive and big enough that i*NFSX_UNSIGNED is negative, the next attribute may experience a crash due to nd_dpos being wild. nfsm_dissect() and nfsm_dissct() are only able to prevent this if the siz is positive, not negative. I've attached a demo: # uname -a FreeBSD 14.0-CURRENT FreeBSD 14.0-CURRENT #120 main-n250906-d95bc6b0bf4c-dirty: Wed Dec 1 06:52:50 EST 2021=20=20=20=20 rtm@xxx:/usr/obj/usr/rtm/symbsd/src/riscv.riscv64/sys/RTM riscv # cc fnfsd_8.c # ./a.out ... panic: Fatal page fault at 0xffffffc000209adc: 0xffffffcf818ecbc0 --- exception 13, tval =3D 0xffffffcf818ecbc0 nfsv4_loadattr() at nfsv4_loadattr+0xef8 nfsrvd_verify() at nfsrvd_verify+0xb6 nfsrvd_dorpc() at nfsrvd_dorpc+0x147a nfssvc_program() at nfssvc_program+0x5a8 svc_run_internal() at svc_run_internal+0x810 svc_run() at svc_run+0x1a2 nfsrvd_nfsd() at nfsrvd_nfsd+0x30c nfssvc_nfsd() at nfssvc_nfsd+0x3ac sys_nfssvc() at sys_nfssvc+0xd0 do_trap_user() at do_trap_user+0x220 cpu_exception_handler_user() at cpu_exception_handler_user+0x72 --- exception 8, tval =3D 0x1c5816ef20 --=20 You are receiving this mail because: You are the assignee for the bug.=