Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1383209rdb; Wed, 24 Jan 2024 13:33:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IHCZ6wrrJb3sFV+ovKSQ2b927EMbRPm9OoFedmmSIMt6giawpBCWv0nyVTuERqVqJgpKM41 X-Received: by 2002:a9d:4d07:0:b0:6dd:ee4a:a5e3 with SMTP id n7-20020a9d4d07000000b006ddee4aa5e3mr2256576otf.44.1706132000285; Wed, 24 Jan 2024 13:33:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706132000; cv=pass; d=google.com; s=arc-20160816; b=AjIY2HPHDfHuLFc0+fM35ujtrRnEfKEelyxOo6Bta0Tme4nqL4GeIG0iAohkGR6iWq MzTBWLanvaPD5Y9usUJser7mjRExeHElvJa5OD9rRKPlUbnute3N67x4Pvq7tba72yAx XHPkOk00VE/CDAiVnMe8k3QJLbO29zDVGgYJ+3tMWj8YSOuBf2NYqC7KDRHmPRn2ptir hkTPQCa3U9TOnMg2Q+W6PPswRDFuLSW7BDRLDb8GjyRxSg3G/AL54kNsMR+36SnteI8O v1XfDAaTN0Yp24iZfLIfkegA/PG7pm2lBmwL/8pl0z3mVHjE9t0x7sVo5p7Wl2r1/rz9 jqEw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:autocrypt:references :in-reply-to:date:cc:to:from:subject:message-id:dkim-signature; bh=BRGUwnBOKwo7A613tUJV36SPqR5UjSV9OvLMtEXihEA=; fh=hMFoKiVYyK6bUerpUpWuT6EakSVl+k437e0r++K3Wqk=; b=JCNa5YmNBynhL4SDqrS4dMMlxKqV+b5luya9NGF4JHCj/qDz3n/eiJ9z40XjFb1yu1 90wFqfc1k8AhpRbNXPtUuVWtJvQCCXjiUKPFFB4TBipjyWfILxzgjXcfJYKcm8XQ3PLZ qXheVagByvCVOecw3F5p98V0YOHevsdxzd0e0r3sLd4Vw5qdrGP3JfqFAJzeZ/NPdgI/ LVy1vD9vMA7Zbr8Fk6CcR0gAQ++zW+pCqZuhuuU7C39yxsFuQumVJEDE5G6QJhvrYzD2 sYmda5Eu4moIrmOnflD8C9wqJ7KNLxc7dboDN4Jjz3RnvWNR0PJGmMIGN/86gaukMFsP XYRg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=jmoWAk0q; arc=pass (i=1 spf=pass spfdomain=xry111.site dkim=pass dkdomain=xry111.site dmarc=pass fromdomain=xry111.site); spf=pass (google.com: domain of linux-kernel+bounces-37697-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37697-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id m7-20020a632607000000b005d62f90cefdsi139742pgm.339.2024.01.24.13.33.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 13:33:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-37697-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=jmoWAk0q; arc=pass (i=1 spf=pass spfdomain=xry111.site dkim=pass dkdomain=xry111.site dmarc=pass fromdomain=xry111.site); spf=pass (google.com: domain of linux-kernel+bounces-37697-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37697-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6F1712845E1 for ; Wed, 24 Jan 2024 21:33:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D9BF71353F1; Wed, 24 Jan 2024 21:33:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xry111.site header.i=@xry111.site header.b="jmoWAk0q" Received: from xry111.site (xry111.site [89.208.246.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FF6613540E; Wed, 24 Jan 2024 21:33:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=89.208.246.23 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706131987; cv=none; b=X1q/k8WcY1nHaqOAcaF6blAPNTv/kHNNYDDgVKNr4rXmWIakTudIsYw6r78nmFmPKYJFQA1ttUelGgQtTY1BBkFfD+abRH0N87y2tJJRuMfdUxjHigyaKrXLbXUmKP/llmVdJD0c09wpkXHhqmkXsQS7hVyHQgUvILBmPpgM8uQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706131987; c=relaxed/simple; bh=ziTHwcQqcapg3pVzdE+ZardjAdUN8XTv3xGQCPYdaz4=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=lNjXWAwWHjSbdmwDI01Q65lh9X9f6rxExYoui5O3Z1Mq+eWeoVNSa4OIJPilQunS282tTbiF6cRo895g7qWZuO/joxOhL2p9STvdlvngI+ZxmROy88oSmQFXN7MdA+t4VW5jdxd9kcVShQa8BwrPZJScykebw6KZ1eKGRcPPahw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=xry111.site; spf=pass smtp.mailfrom=xry111.site; dkim=pass (1024-bit key) header.d=xry111.site header.i=@xry111.site header.b=jmoWAk0q; arc=none smtp.client-ip=89.208.246.23 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xry111.site DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1706131982; bh=ziTHwcQqcapg3pVzdE+ZardjAdUN8XTv3xGQCPYdaz4=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=jmoWAk0qhYPXnrmgEfpUhBIlc9h6qrS2t4yfbrlqa4zq9d2UhFbys18mSH7qZcRsI JzjseQtUzh4MjZZM/bdv10PK5EKZ32QN23xv9KDGZ/og2yUnlR/4Wsw5X8uk99DuKP teJsIFsYgSBB6Bt7d6KvF/fCL++xh0VnHxIQpzkk= Received: from [127.0.0.1] (unknown [IPv6:2001:470:683e::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 08FDE66A79; Wed, 24 Jan 2024 16:33:00 -0500 (EST) Message-ID: Subject: Re: Strange EFAULT on mips64el returned by syscall when another thread is forking From: Xi Ruoyao To: Andreas Schwab , Ben Hutchings Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Jiaxun Yang , Thomas Bogendoerfer , libc-alpha@sourceware.org, Linus Torvalds Date: Thu, 25 Jan 2024 05:32:59 +0800 In-Reply-To: <0be1203c9df55432548c92281c8392dfa2f7d6bf.camel@xry111.site> References: <75e9fd7b08562ad9b456a5bdaacb7cc220311cc9.camel@xry111.site> <9481b6d9d015aea25d8f2563bf7bd6f6462f758f.camel@xry111.site> <0be1203c9df55432548c92281c8392dfa2f7d6bf.camel@xry111.site> Autocrypt: addr=xry111@xry111.site; prefer-encrypt=mutual; keydata=mDMEYnkdPhYJKwYBBAHaRw8BAQdAsY+HvJs3EVKpwIu2gN89cQT/pnrbQtlvd6Yfq7egugi0HlhpIFJ1b3lhbyA8eHJ5MTExQHhyeTExMS5zaXRlPoiTBBMWCgA7FiEEkdD1djAfkk197dzorKrSDhnnEOMFAmJ5HT4CGwMFCwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4AACgkQrKrSDhnnEOPHFgD8D9vUToTd1MF5bng9uPJq5y3DfpcxDp+LD3joA3U2TmwA/jZtN9xLH7CGDHeClKZK/ZYELotWfJsqRcthOIGjsdAPuDgEYnkdPhIKKwYBBAGXVQEFAQEHQG+HnNiPZseiBkzYBHwq/nN638o0NPwgYwH70wlKMZhRAwEIB4h4BBgWCgAgFiEEkdD1djAfkk197dzorKrSDhnnEOMFAmJ5HT4CGwwACgkQrKrSDhnnEOPjXgD/euD64cxwqDIqckUaisT3VCst11RcnO5iRHm6meNIwj0BALLmWplyi7beKrOlqKfuZtCLbiAPywGfCNg8LOTt4iMD Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Thu, 2024-01-25 at 00:13 +0800, Xi Ruoyao wrote: > On Wed, 2024-01-24 at 20:49 +0800, Xi Ruoyao wrote: > > On Wed, 2024-01-24 at 12:59 +0100, Andreas Schwab wrote: > > > On Jan 24 2024, Xi Ruoyao wrote: > > >=20 > > > > Now I'm suspecting this might be a kernel bug.=C2=A0 Any pointer to= further > > > > triage? > > >=20 > > > Is this a regression? > >=20 > > Initially I guessed it was perhaps a Glibc regression related to the > > newly introduced clone3 usage on MIPS, but it fails with Glibc-2.35 too= . > >=20 > > Not sure if this is a kernel regression, I'll try different kernels in > > several hours (once I can physically access the system). >=20 > Not happening with kernel 5.18.1.=C2=A0 I can do a bisection but it will = take > several days, I guess. Hmm, not so time-consuming as I expected. 4bce37a68ff884e821a02a731897a8119e0c37b7 is the first bad commit commit 4bce37a68ff884e821a02a731897a8119e0c37b7 Author: Ben Hutchings Date: Thu Jun 22 18:47:40 2023 +0200 mips/mm: Convert to using lock_mm_and_find_vma() Re-posting the broken test case for Ben (I also added a waitpid call to prevent PID exhaustion): #include #include #include #include #include #include void * test_thread (void *) { char buf[16] =3D {}; int fd =3D open("/dev/zero", O_RDONLY); while (1) { ssize_t ret =3D read (fd, buf, 7); if (ret =3D=3D -1 && errno =3D=3D EFAULT) abort (); } } void * fork_thread (void *) { while (1) { pid_t p =3D fork (); if (!p) _exit (0); waitpid (p, NULL, 0); } } int main (void) { pthread_t test_th; pthread_t fork_th; pthread_create (&test_th, NULL, test_thread, NULL); pthread_create (&fork_th, NULL, fork_thread, NULL); pthread_join (test_th, NULL); pthread_join (fork_th, NULL); } and the context where this issue was detected: https://sourceware.org/glibc/wiki/Testing/Tests/stdlib/tst-arc4random-threa= d and the "interesting" aspects: 1. If I change the third parameter of "read" to any value >=3D 8, it no longer fails. But it fails with any integer in [1, 8). 2. It fails no matter if I initialize buf. 3. It does not fail on arm64 (the only other port using lock_mm_and_find_vma I have access to). --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University