From nobody Fri Dec 30 19:35:43 2022 X-Original-To: freebsd-fs@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 4NkFqB3cT4z2lQVr for ; Fri, 30 Dec 2022 19:35:50 +0000 (UTC) (envelope-from jfc@mit.edu) Received: from outgoing-exchange-5.mit.edu (outgoing-exchange-5.mit.edu [18.9.28.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.outgoing-exchange.mit.edu", Issuer "InCommon RSA Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NkFqB0Yl4z3PvJ for ; Fri, 30 Dec 2022 19:35:50 +0000 (UTC) (envelope-from jfc@mit.edu) Authentication-Results: mx1.freebsd.org; none Received: from oc11exedge2.exchange.mit.edu (OC11EXEDGE2.EXCHANGE.MIT.EDU [18.9.3.18]) by outgoing-exchange-5.mit.edu (8.14.7/8.12.4) with ESMTP id 2BUJZkmw017851; Fri, 30 Dec 2022 14:35:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=outgoing; t=1672428948; bh=36eN4/rVGU0M9HNBgtZxShJAD7IQ4+QFeaRO+G5vOX4=; h=From:To:CC:Subject:Date:References:In-Reply-To; b=j9jtgbNGa6r8bMFaEMkSuxU1w29dZF0igMvp+PgePxsdpxmeBjOrjwJxomNPLyedn VAv7nSkfxcY4pllb5stB73KBpNQOUvn9F3p7Wc2o4g+Hoo6xjtVOjm3fsCXAPiJrU6 t/uvtuWQId+edfNpExKlkcDi3XczqjW38HNlA6mYxcn9sbTlaj8CD86HJap0uRqK20 q7q9AbLWM38Zbvgwl3K++Yj/w1bQY/dzuPEZRlltQQvGamWOBMOBbqeOUA40/5YOZa sjtClu7JUXg9fSaTRaUBEObKQ/FGkGT3QbMixJYyy1I5iT6vZP3UTo+AvhU4HbJVCe DgFYHuGzzUjbQ== Received: from w92expo17.exchange.mit.edu (18.7.74.71) by oc11exedge2.exchange.mit.edu (18.9.3.18) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 30 Dec 2022 14:35:16 -0500 Received: from oc11exhyb5.exchange.mit.edu (18.9.1.110) by w92expo17.exchange.mit.edu (18.7.74.71) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 30 Dec 2022 14:35:46 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.46) by oc11exhyb5.exchange.mit.edu (18.9.1.110) with Microsoft SMTP Server (TLS) id 15.0.1497.42 via Frontend Transport; Fri, 30 Dec 2022 14:35:46 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LuYyDFQhVoe9E+jkPJNQPUb3uHDsq5lHgjFuyT+1m8FLutk30CqghcHLoj3rdB5ta+37hTTJrdJxPwoT1aELFiAo6CHF0gPN3nysESyV9WpRrt1spCrM/zpPwGZVwMce0uS61q9tmu44eO0RvVYnS9wsT7oAElvo2c09LR+398eunJw79veR3F+d0rxxHnO2jEMZZ/GridZvQ1+v0arwWGKyJgZ7mSKko8vCoVwnwygo3yKbuCG1sesedBaV4Cwozix6cAPv1ecaxGcowWS6OiCtTtvM49VQpElsxZqGgmg+mkVnwaPSEFA/bfKMptwd/8k4M0YKGTr/YrrIUzbArA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=36eN4/rVGU0M9HNBgtZxShJAD7IQ4+QFeaRO+G5vOX4=; b=MHr5PwG8qJUkx0/kv6eCx23utyGkkL7audJwxVDyQrJeUPvPa+n4sxaoeeT9xrKy50gbZ5C8PU6uOx2sucVH0HsbIlrcoX+cbkVJ5CvSj8IOUoKOpIRCSdgBgO7sY4DeNcgEyZifUg77abDCO06BO2bwrt/GhHQLNhxi/9zHLW1NpKcsZ7Ub6g62NgoVIceOXRqfhtfZ/9Kzn4qW5REFkSgTX2nFWW8g7YCC2cYIQ8CDTnMUSsPcxTPRpydrr+3R4q5pGTFAVnU3dcj96enO5Cu/XL8/HiSv1f97khTf6ioJh1NNNkwF7u2WoVqBKYYd/LVKytyyBMHt9txO6xdViA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mit.edu; dmarc=pass action=none header.from=mit.edu; dkim=pass header.d=mit.edu; arc=none Received: from DS7PR01MB7712.prod.exchangelabs.com (2603:10b6:8:7b::17) by BL0PR0102MB3410.prod.exchangelabs.com (2603:10b6:207:1d::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.13; Fri, 30 Dec 2022 19:35:43 +0000 Received: from DS7PR01MB7712.prod.exchangelabs.com ([fe80::b8dd:4b3b:3d80:500b]) by DS7PR01MB7712.prod.exchangelabs.com ([fe80::b8dd:4b3b:3d80:500b%6]) with mapi id 15.20.5944.016; Fri, 30 Dec 2022 19:35:43 +0000 From: John F Carr To: Hikmat Jafarli CC: "freebsd-fs@freebsd.org" Subject: Re: Trying to implement BFS, page fault at vfs_domount_first, how to debug? Thread-Topic: Trying to implement BFS, page fault at vfs_domount_first, how to debug? Thread-Index: AQHZHIM2ei2NZ3IY1keIHpEfCzDQDa6G0rwA Date: Fri, 30 Dec 2022 19:35:43 +0000 Message-ID: <23A1E4DF-320A-4BCB-ADB8-83FEFC3D7649@mit.edu> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DS7PR01MB7712:EE_|BL0PR0102MB3410:EE_ x-ms-office365-filtering-correlation-id: ba2c90dc-5bec-4741-433e-08daea9d0a60 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 3qBX0PDtYKfcLfMKQLiyJGQlVpO3XgaVGgGAeNKIHrd53a5BIsq4jObLrOS9K44ShgICxf3awlIfQzFIDMFLoL01+V4H74Kbwi1fp/4vpqmF22dQzkMsFdq8qUEFt3TYvvJotZ/lT419wV+TUKahsVHWwiwMetkVlK5IwPRaAGEjdJNfYTW3HTitYRLKNZxHXM1YR/8/1nkaVCQervYuLkm5dkT3M+7Ec47QVOY4/toL0ucM7eRLIc07onziTMyaltPhG1AxNwNKJD82RWMvaYUhzbX2Nxs4W8S17gWiO4V/sGOQ3oPKRdaUN2FTyQAJ+HiQgwpV8IUWMxk2BY5gILBBsr/Tcq6K+ZiYNyBFQYbSbjePF0zXLhanhV2cYSFmBy7yz2PsPiKtpyi5lKEkURN2cprdgnT21chatNbBz6SHXw8oLSvUORNpzd4/ZclN8UEqbIXivyUhSFk8PelDJu3attMarHjmTmFsMyOjDE9gGfn6kprRbEz8dDau8itGROXVQPMk/fezrugOLJXVoZ+qV8KimKqOcOGi70K3xc3Fv2j+aDDPvkaYQDz4JVCmW7EtPRaw2ZD85/UVbDJbSUfokVy8VtGHhr8Xep/blbkGzoup2fqZfxMpR9eS6oStkY2agO/1HWTIVptDctSU8E+V0sR4s6RPfXPFaF2fULTKLYR9QabT05g1Mg/+Dbk5cIqy5fPKZrtwiFKSzJ3HDNGUd97izaKltPsB7x2mk8Q= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR01MB7712.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(366004)(396003)(136003)(376002)(346002)(39860400002)(451199015)(2906002)(5660300002)(38100700002)(122000001)(38070700005)(41300700001)(75432002)(83380400001)(6506007)(71200400001)(8936002)(36756003)(66946007)(66556008)(91956017)(64756008)(66446008)(66476007)(8676002)(76116006)(4326008)(316002)(786003)(86362001)(33656002)(6512007)(2616005)(6916009)(26005)(53546011)(186003)(6486002)(966005)(478600001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?q/LFghnCnlVPIKj7KovX+ArQFOFHgbmHN7/rgM2LBAhNbfsaHvwt+xU1DWYY?= =?us-ascii?Q?/6+Mvnxi/XJUiP9ehHkGj4CeRtJpT+lZcSyMIkDY1FYBgSu+ThWN7F8osUnw?= =?us-ascii?Q?e/ruNfWTgkK24yPOFpQSWsEeBRiBjowUDYHRNXUMeaeFW2GUA2/IW4pCF4YD?= =?us-ascii?Q?3CRxlvoUTPFWjrS8k5OyDQpQPC2J4b1+pCBC0FHii6VLzxMsmuC4tLXHfeXH?= =?us-ascii?Q?MBBt02MC2D1J2cykRoj8loXoXegxDim8FQI1OIHZn8j3+1WuVIgWT0yI6lGH?= =?us-ascii?Q?svMHtvN3T5QE9qwLQB45WyEy19/Xi07sWYwI3zY2pzYoLzSdoB6yVOamFeXU?= =?us-ascii?Q?TnlfrrBNeF5wPaeTZwd/moU5lGPVOv0mFMeHwRgrmiZZ+3ViHJHJgO8GWmZh?= =?us-ascii?Q?tL+KAryc24KfhUN6JaZv2Z677X1vvSpoiFJpXS2cvMDu2do5zibHw3kXQjCX?= =?us-ascii?Q?KTi+sW2+CZnSbdtH5KUR0tSlSrO4iZA/+ccAHFg8i0Nc+deKNUFGmMLYGOb5?= =?us-ascii?Q?5iXmD9Pkcsccevcd9LfpjDVPXkVhZgTgTip8E69tWMxoetT98mgj7HIeoAq+?= =?us-ascii?Q?u211QigGMtiPQOUkxaozCEhRMKaqw8VisYU9tDcHdp5xrq51Xwv6mZYi101Z?= =?us-ascii?Q?eq/5WzRL1zBAdZPILWdNMS2/CzkZ10UE2F9Hw60BYfhQCm3tRWLCGPa/ZzTA?= =?us-ascii?Q?a3wFNCTep5nv7G/G92wgCsfxc5k4Ka892m1dQHwxrTKLs0U77N9hdiVgCfNa?= =?us-ascii?Q?5ZtcH8iWLVVh0BozL1PBF2q93lZ18DxqiDHjAdZzGM/e7lvhYH8tjH/rCSeu?= =?us-ascii?Q?dnP2AyAlfjMKugAxOt22X7mRYQxGACb2zZTKHnLu0DfVpP0txBNOSzfdbFqJ?= =?us-ascii?Q?JC7QAqFbkfEo5WtW/cU4fRBYlYbW69WiJvXvCRor5O4n9AHVrh9Dew1ZfV4H?= =?us-ascii?Q?GMwK/oUxeOdd5omShNzUM3IFG3ywcb5OP+UiqKFmuPsOybbrdBdMh1G4raQG?= =?us-ascii?Q?2FCwjb3jDst3/bQTKhHHXXbZxkbptE8Aqgst16p3i7ZhqncOY6v/L5DFWYbx?= =?us-ascii?Q?nyITGJVYJicky2Gd4o6MLdc4ao+NrZCrlRlHtEASQBB8t43nunXJ+FtI0CnP?= =?us-ascii?Q?voUQiGBFRCU1aTXm8SUTj3quZVS9+TjyvTgruWkcU64Ogq6b9X4hD+gAzx9l?= =?us-ascii?Q?cI7VR2k7TjuMaeJQzQO4Z059Epi70g3aUtO59jJu5/Uxs+MNYZ9XebxkdiNx?= =?us-ascii?Q?fLlwPzzsbIO+qtUs1xXipsrhGdnyQSsyyrTHn8+jUGLuP1R9WVcFS1XFXJHF?= =?us-ascii?Q?T+rpkMyNZMRcvj9olKA3PZ0uZS697O0JIuE96VV6GjG3yRyxLfaIpIm3JRqB?= =?us-ascii?Q?AyZV4kgKsQGPtYkcYj2G7gHAVg5xLHqJ9xPjmhqoc8TLZmthJqgl0e+Ybo5k?= =?us-ascii?Q?qUTDLfbAxc5V8RMOdZWl++52SM+pqwau4l3sow34ie9T6KdSQlC1lo3eDzZV?= =?us-ascii?Q?EoOsznCwk9oHDoTuKkWHW9f95f0xaOuNusZxBbLVOrqlzt1ry+NWNGA+xA4G?= =?us-ascii?Q?WK0NITNR/47wxYyt6ic=3D?= Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable List-Id: Filesystems List-Archive: https://lists.freebsd.org/archives/freebsd-fs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-fs@freebsd.org MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DS7PR01MB7712.prod.exchangelabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: ba2c90dc-5bec-4741-433e-08daea9d0a60 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Dec 2022 19:35:43.0880 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 64afd9ba-0ecf-4acf-bc36-935f6235ba8b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: r2Ktdp3Sxi47VvxdJptJl2Ec+7Y3AHQTXycfs7gJDecqgUh+ruWwnxiJWId105VP X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR0102MB3410 X-OriginatorOrg: mit.edu X-Rspamd-Queue-Id: 4NkFqB0Yl4z3PvJ X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:3, ipnet:18.9.0.0/16, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N > On Dec 30, 2022, at 14:13, Hikmat Jafarli wrote: >=20 > I'm trying to implement the BeOS filesystem (BFS) for FreeBSD. > The repository is here: https://github.com/jafarlihi/freebsd-bfs > (Please don't mind bad styling and all the copy-paste work, > I'll polish it later, I'm just trying to get to some PoC where it works) >=20 > Now when I try to mount a valid BFS partition (reported as BFS by `fstyp`= ) > it executes all the way to printf that logs "Either not a BFS volume or > corrupted" and then crashes with "page fault while in kernel mode" in > vfs_domount_first+0x271. Here's the log: > ``` > Either not a BFS volume or corrupted >=20 > Fatal trap 12: page fault while in kernel mode > cpuid =3D 0; apic id =3D 00 > fault virtual address =3D 0x18 > fault code =3D supervisor read data, page not present > instruction pointer =3D 0x20:0xffffffff82b2427b > stack pointer =3D 0x28:0xfffffe00df399ac0 > frame pointer =3D 0x28:0xfffffe00df399ac0 > code segment =3D base 0x0, limit 0xfffff, type 0x1b > =3D DPL 0, pres 1, long 1, def32 0, gran 1 > processor eflags =3D interrupt enabled, resume, IOPL =3D 0 > current process =3D 1208 (mount) > trap number =3D 12 > panic: page fault > cpuid =3D 0 > time =3D 1672414952 > KDB: stack backtrace: > #0 0xffffffff80c694a5 at kdb_backtrace+0x65 > #1 0xffffffff80c1bb5f at vpanic+0x17f > #2 0xffffffff80c1b9d3 at panic+0x43 > #3 0xffffffff810afdf5 at trap_fatal+0x385 > #4 0xffffffff810afe4f at trap_pfault+0x4f > #5 0xffffffff810875b8 at calltrap+0x8 > #6 0xffffffff80cf0651 at vfs_domount_first+0x271 > #7 0xffffffff80cece9d at vfs_domount+0x2ad > #8 0xffffffff80cec2d8 at vfs_donmount+0x8f8 > #9 0xffffffff80ceb9a9 at sys_nmount+0x69 > #10 0xffffffff810b06ec at amd64_syscall+0x10c > #11 0xffffffff81087ecb at fast_syscall_common+0xf8 > ``` >=20 > Now I'm trying to understand what exactly goes wrong here > and how to map 0x271 to the exact source line. >=20 > I'd appreciate it if someone could tell me how to debug this. >=20 > (Sorry for noob question, I already tried IRC and was directed here) Your BFS module tried to dereference a null pointer to structure. It's a null pointer dereference because of "fault virtual address =3D 0x18"= . That normally means you tried to access the fourth word of a structure b= ut the pointer to structure was null. It could be something else, but play= the odds. It's in your module because the instruction pointer address is far beyond t= he other kernel functions in the stack trace. Stack traces in crash report= s are misleading: they tend to omit the function that triggered the crash. = The address of vfs_domount_first is 0xffffffff80cf03e0 (0xffffffff80cf0651= - 0x271). That's the function that called your module. The address of th= e faulting instruction is 0xffffffff82b2427b. That's in your module.