From nobody Tue Aug 30 15:52:41 2022 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 4MHBf11YXHz4ZmC7 for ; Tue, 30 Aug 2022 15:52:41 +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 4MHBf06kysz41B7 for ; Tue, 30 Aug 2022 15:52:40 +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 4MHBf05p10zq1d for ; Tue, 30 Aug 2022 15:52:40 +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 27UFqeF0014975 for ; Tue, 30 Aug 2022 15:52:40 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 27UFqeMY014974 for bugs@FreeBSD.org; Tue, 30 Aug 2022 15:52:40 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 266115] bad use of user pointer in cam_ioctl() CTL_PORT_REQ Date: Tue, 30 Aug 2022 15:52:41 +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=1661874760; 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=01i1OEBGOmIYc3m0UNAYP/7elD3+Ehm8qgAr4Bmky0I=; b=aHCGKuqJYF15XONcQnrToOwwOY2NoNW7axcad7YxCDg4tHMwfQdsjpJSH0c5SDavDSHn77 3q+EayYn5NpdVyp/AfhvarN2wAi9NCdYW9LtutJa5s+hvoTz01ZutocwAXjbo2eHUGb3Ec AZQRAYAsyIq0hOktLadbDq1rDenpmYQnQVgT3wKFhstW2UNp8UoKAegrMfC0f+bZ5lk4Ub fpP8KhzFsdHIx8SvJ2VTBTKfLsxCq1dhKwJtu3iWQRGqH9ggZIQ2IOGhgHYfS1emoK6fuZ G+AR1bRmXUu2Y3nw12EzVOig2g0bJj1P2ZwHVOUDlG42ml9BDsWLJB9K/rDKzQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1661874760; a=rsa-sha256; cv=none; b=sVj8K+DO9DnqUfBm/+3yi74Z3cn2BFYLWrouTfkAJqbRx2YTefWVsnWd6AYng7ris4pwnV +JOy71rry8O9VWyP3FmEuq9UBZPq+WduGGVXBx2J4WJ7G85XbjAQrqCMa5Z79TtBq13WRe DSsyLTz6R4jcCohIcH54CbduodT+z2w3jMOLZ1ayWzoCe3/B184TvUwj/KpCD4SX0ufCs5 bh9saYzak3/MVKjEi4tUYQtWe7wegwl0Z8yPHkU77tXxu6fV9sqfUWeF7cnZWl+42jL+rQ Q+IvXrVkwJ4VNp9gfsJ9ntxNGVMSc6jEEDdPw+PRiGkuUcX1IAwGrraoyoNC5Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D266115 Bug ID: 266115 Summary: bad use of user pointer in cam_ioctl() CTL_PORT_REQ 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 cam/ctl.c, ctl_ioctl(), for CTL_PORT_REQ, if user code passes in a non-null req->result_nvl, but a null req->result, and fe->ioctl is zero, then ctl_ioctl() calls nvlist_destroy() with the user-supplied req->result_nvl. Here's a demo: int main() { int fd =3D open("/dev/cam/ctl", 2); char buf[256]; memset(buf, 0, sizeof(buf)); strcpy(buf, "camtgt"); // driver *(unsigned long long *)(buf+72) =3D 0x8000000000000000; // result_nvl ioctl(fd, 0xc100e126, buf); // CTL_PORT_REQ } # uname -a FreeBSD 14.0-CURRENT FreeBSD 14.0-CURRENT #40 main-n250928-b8170f38ccc7-di= rty: Mon Aug 29 13:09:55 EDT 2022=20=20=20=20 rtm@xxx:/usr/obj/usr/rtm/symbsd/src/riscv.riscv64/sys/RTM riscv # cc x.c # ./a.out panic: Fatal page fault at 0xffffffc0000a9b16: 0x8000000000000000 panic() at panic+0x2a page_fault_handler() at page_fault_handler+0x1d6 do_trap_supervisor() at do_trap_supervisor+0x76 cpu_exception_handler_supervisor() at cpu_exception_handler_supervisor+0x70 --- exception 13, tval =3D 0x8000000000000000 nvlist_destroy() at nvlist_destroy+0x10 ctl_ioctl() at ctl_ioctl+0x183a devfs_ioctl() at devfs_ioctl+0xbe VOP_IOCTL_APV() at VOP_IOCTL_APV+0x30 VOP_IOCTL() at VOP_IOCTL+0x36 vn_ioctl() at vn_ioctl+0xba devfs_ioctl_f() at devfs_ioctl_f+0x20 fo_ioctl() at fo_ioctl+0xa kern_ioctl() at kern_ioctl+0x242 sys_ioctl() at sys_ioctl+0x120 syscallenter() at syscallenter+0xec ecall_handler() at ecall_handler+0x18 do_trap_user() at do_trap_user+0xea cpu_exception_handler_user() at cpu_exception_handler_user+0x72 --=20 You are receiving this mail because: You are the assignee for the bug.=