From nobody Sun Dec 19 16:30:58 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 61878190B127 for ; Sun, 19 Dec 2021 16:30:58 +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 4JH7WQ0J31z3hRk for ; Sun, 19 Dec 2021 16:30:58 +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 DFB2825AE9 for ; Sun, 19 Dec 2021 16:30:57 +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 1BJGUvax090620 for ; Sun, 19 Dec 2021 16:30:57 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 1BJGUvib090619 for bugs@FreeBSD.org; Sun, 19 Dec 2021 16:30:57 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 260546] nfsv4_loadattr() can pass huge sizes to malloc() Date: Sun, 19 Dec 2021 16:30:58 +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 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=1639931458; 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=84mB9zrqMxPhGAbLPHmNlrHriiTddVrJ3z2DCBul3Jg=; b=Un5nvxOrze70q8xVWnIv4QHIUW06PiysQs5wr/j44WMNuFttfCP/20BUQtPURM3bqQHsyR LxDIn2KeQYrdaoyCR0Cwom3T80byYCt8AJt4cwbgl4ykSpkM7kh8dVDrQ3NLU6U4WUPVFU aJX10FfVyqrgWIBAjG7TRKjcar0uYtxygWtA9sAeGVDtYn5NxFA/QoWaJIwWD8Fm34B/0J 35vmvHOBpx92lDbu1mpeWCnDDGFzjDte4+BWmGfkpa48P/QT01cHyPXu5hK/pZHVxffrHt Hp4F9S2q+zwONH3qIOW/xK+K6NligjidnONjEwIKMa64YRIr8tUa0O+RT/fiLQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639931458; a=rsa-sha256; cv=none; b=jBg8TUfhGwSIr7+flcM9q9rFVTiiZ3Fk61vPpIeUzACD/+QyfJ313bcUgb0CxMMef4ldwZ 2QgYxlzxsmmxaY4hywwC1EXr82Mreukb+TkZFcOmFdvEfrc3/Ln7UiZeXPtWutjN+Y+prj tYt/QqG1taM33R/luzaNlZ38F+tOO5BLzlnFKqGogdj51cHUknsoBRr3CdGwzSXy8n5QYE wHZmhB+r34LaXV6DPNNF+97wwUU7LAeUEhAQgMTbeFPHDbDswbuPzDG1xMtVOAuZsdQ1TJ cSnBnrCQuJTrkORmNaAfnuL002fa3VaPLmkmjIWc0bGcFkpYgjaKUhYF49qlsA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D260546 Bug ID: 260546 Summary: nfsv4_loadattr() can pass huge sizes to malloc() 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 In the NFSATTRBIT_OWNERGROUP code in nfsv4_loadattr(): NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); j =3D fxdr_unsigned(int, *tl); if (j < 0) { error =3D NFSERR_BADXDR; goto nfsmout; } attrsum +=3D (NFSX_UNSIGNED + NFSM_RNDUP(j)); if (j > NFSV4_SMALLSTR){ cp =3D malloc(j + 1, M_NFSSTRING, M_WAITOK); First, a big j can cause this code to allocate a few GB of memory, enough to cause my modest test machine to run out. Second, the "if (j < 0)" along with the "j + 1" means that if the RPC message contains j =3D 0x7fffffff, malloc will be called with (size_t)(j+1) =3D (size_t)(0x80000000)=20 which is 0xffffffff80000000 if size_t is unsigned and 64 bits. This seems to cause malloc() to never return on my machine. --=20 You are receiving this mail because: You are the assignee for the bug.=