From nobody Tue Feb 14 00:15:17 2023 X-Original-To: freebsd-arm@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 4PG1vD28Bfz3rD33 for ; Tue, 14 Feb 2023 00:15:36 +0000 (UTC) (envelope-from marklmi@yahoo.com) Received: from sonic317-21.consmr.mail.gq1.yahoo.com (sonic317-21.consmr.mail.gq1.yahoo.com [98.137.66.147]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4PG1vC5583z3kj3 for ; Tue, 14 Feb 2023 00:15:35 +0000 (UTC) (envelope-from marklmi@yahoo.com) Authentication-Results: mx1.freebsd.org; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1676333733; bh=ZQ45vFIIYYf7ESM2RuIj5zTUkAOdq9FSPWJYmJ6xopw=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From:Subject:Reply-To; b=RJSLY7K1fAQB+5tXjPojZIYBbJNF3zvT15kegFzZ3yp68Q2SVUnlqiI3gLoJhVuHmngsmik1BeGLFRPpOlGGw1uuct1sE4Wsu1DvlCcCnDObGKwxE4VfvNMsUKDNEIrx6Ol6F3e6XZ6uZI19YmRqIhty/oOg2cdPW/Kuz0ZfOF4crbgxKupxRzDCUml1agpHFyvWlYfF25He/5uetrkWUDz/VqXvBKiWF2G9OEfxnO0p4DGoruiMxWBQ5icPajmX7YR1CHSXXe8ifa3Q0JdwpETDweLOmnhQyzvjZdNVuYNZyzPY9u9M3Chu7V+tXalOPbFVL9OmyjdSz0J1oakSPw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1676333733; bh=UvKIXLOja5YsLwXWUrqEz8gv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qjzMvM0d5 8Kh3BdC1pntmK5Tu6wAlqUK3fNZXsoPiZdJakv_kbTlpac1BjH0qcWb10Su3rVniuf1FujdEfNQR Rg822x6I7JVSwr5x7hLqKvAMdI.enhuOjRi3hpQBXn4kF_x7lKlSAYgbtoum7Vcj6B9JQ_lLfHGs bx3.Fd.nHsi8PY_wZLVGCaUg8K.Og_mWk7brnadiYJ5OP7ydkLiCJ2prcAPQ8ewwsy2qY7bFy_EY .I1X5i5JOTWKHQcOzkLAIJWPIgZn.SLoJQZ9k9GUR5gDR3duapFmscFz6aaeaSvW0qGJCGQCOHPo 2cMLfL.b8eq8O.kZVRWRB03SAVZjWXnhGSHKxe_ae.JME9ZxIBSOH9fnkumITrqTebNnFRvZ1x6H 2jMa48NpDf4kuTWAShJo6ZaLi.3E4kmsWF4fuZS1sJLLvfxS_WDfyskAZSDB6c580t.I6SR7ON88 YS.ksB7jrE47huFgNlalq.iDzGsSu0HkWTVRbD5lrfCnldL8iFZPmrlj0oIF.W_ZFDIa0mt7trw_ N5t..dBo0dhIYtd79Jo0j9CR.IPdnlneJ4a_Bor8cf7Bg942Q21ytcSLr54H2LDSTG0QQI7tDbw- - X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic317.consmr.mail.gq1.yahoo.com with HTTP; Tue, 14 Feb 2023 00:15:33 +0000 Received: by hermes--production-bf1-57c96c66f6-hmvtp (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID ab98c74d4e8fd5730e632639f8f1af70; Tue, 14 Feb 2023 00:15:30 +0000 (UTC) Content-Type: text/plain; charset=us-ascii List-Id: Porting FreeBSD to ARM processors List-Archive: https://lists.freebsd.org/archives/freebsd-arm List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-arm@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.300.101.1.3\)) Subject: Re: fsck segfaults on rpi3 running 13-stable (and on 14-CURRENT analyzing the same file system that resulted from the 13-STABLE crash) From: Mark Millard In-Reply-To: <20230213232519.GD95670@funkthat.com> Date: Mon, 13 Feb 2023 16:15:17 -0800 Cc: bob prohaska , "mckusick@freebsd.org" , freebsd-arm@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20230211224057.GA17805@www.zefox.net> <9DC74DD9-9AA1-4822-B425-217AAC7DB3F5@yahoo.com> <20230212043524.GA19401@www.zefox.net> <984314A1-FF42-4F92-A212-6BC0D85CB630@yahoo.com> <20230212165333.GB19401@www.zefox.net> <20230212191308.GA21535@www.zefox.net> <20230212195324.GB21535@www.zefox.net> <03840D0B-13D4-4F22-BDAF-2887A4D78BED@yahoo.com> <20230213232519.GD95670@funkthat.com> To: John-Mark Gurney X-Mailer: Apple Mail (2.3731.300.101.1.3) X-Rspamd-Queue-Id: 4PG1vC5583z3kj3 X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:36647, ipnet:98.137.64.0/20, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N On Feb 13, 2023, at 15:25, John-Mark Gurney wrote: > Mark Millard wrote this message on Sun, Feb 12, 2023 at 13:25 -0800: >> [With a backtrace for the fsck_ffs SIGSEGV crash and some >> listing of code involved, I'm now including mckusick@FreeBSD.org = >> in the To: . Kirk M. likely would like you to preserve the >> problematical UFS file system that produces the fsck_ffs >> crashes, at least for now. For Kirk M.: The below is from/for >> the fsck_ffs attempted from 14-CURRENT.] >>=20 >> On Feb 12, 2023, at 11:53, bob prohaska wrote: >>=20 >>> On Sun, Feb 12, 2023 at 11:31:59AM -0800, Mark Millard wrote: >>>>=20 >>>> I'll note that another option is to run fsck_ffs from >>>> lldb in the first place.=20 >>>=20 >>> That seems more productive, yielding: >=20 > [...] >=20 >> So the code around /usr/main-src/sbin/fsck_ffs/inode.c:1314 looks >> like: (leading white space might not be preserved) >>=20 >> void >> prtinode(struct inode *ip) >> { >> char *p; >> union dinode *dp; >> struct passwd *pw; >> time_t t; >> dp =3D ip->i_dp; >> printf(" I=3D%lu ", (u_long)ip->i_number); >> if (ip->i_number < UFS_ROOTINO || ip->i_number > maxino) >> return; >> printf(" OWNER=3D"); >> if ((pw =3D getpwuid((int)DIP(dp, di_uid))) !=3D NULL) >> printf("%s ", pw->pw_name); >> else >> printf("%u ", (unsigned)DIP(dp, di_uid)); >> printf("MODE=3D%o\n", DIP(dp, di_mode)); >> if (preen) >> printf("%s: ", cdevname); >> printf("SIZE=3D%ju ", (uintmax_t)DIP(dp, di_size)); >> t =3D DIP(dp, di_mtime); >> p =3D ctime(&t); >> printf("MTIME=3D%12.12s %4.4s ", &p[4], &p[20]); >> } >=20 > [...] >=20 >> So far, I've not identified how the NULL pointer showed up >> that ended up being dereferenced. It does not look likely >> that I will identify such. >=20 > Ok, decided to run AFL on fsck, and this one was the first crash it > discovered. The problem is that ctime can return NULL, and the return > value isn't checked, because it then immediately does &p[4] which > results is printf and friends being passed 0x4. >=20 > Simple test program that demonstrates this problem: > #include > #include >=20 > int > main() > { > const char *p; > time_t t; >=20 > t =3D -5098919203113507862; >=20 > p =3D ctime(&t); >=20 > printf("MTIME=3D%12.12s %4.4s ", &p[4], &p[20]); >=20 > return 0; > } >=20 > I'm not sure what the correct fix is for when times are wildly out of > valid range. >=20 Thanks. Looks like C23 is making ctime and asctime deprecated, recommending strftime use. As for existing behavior vs. standards: C11, for example, just indicates that ctime(t) is equivalent to asctime(localtime(t)) . C11 also indicates that asctime goes to a "the behavior of the asctime function is undefined" status. NULL returns are only one of the possibilities as far as he language is concerned. POSIX indicates the more specific NULL return value handling for asctime (and, so, ctime too). =3D=3D=3D Mark Millard marklmi at yahoo.com