From nobody Mon Apr 27 14:52:55 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C1E2C433EF for ; Mon, 13 Jun 2022 23:33:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231671AbiFMXd4 (ORCPT ); Mon, 13 Jun 2022 19:33:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbiFMXdu (ORCPT ); Mon, 13 Jun 2022 19:33:50 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 801E43055C for ; Mon, 13 Jun 2022 16:33:49 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id h190-20020a636cc7000000b003fd5d5452cfso4059613pgc.8 for ; Mon, 13 Jun 2022 16:33:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=Lpl6bFxJI4CHRgZzmX1LV+v0qDroFLN/nvNicZhBWbk=; b=PBbqm2oEvfRdfqUL7Z30R+/pfa0TDaOZnOfFZ0FGkyyXTVfaeA859rqjWm5M1jgU4x x9JF9CHjapYA+Mh3kZOTZBfRwi95ukBYi4SdXiCXBziNv0P/HPw9E1dCWO6gbH+BcCKm tkhDkanIMftPysWbsqKlgR9QcfvPiyPBDZ/GSuklEWBnmW3oudZLo8ywT96P48LV6iA4 XmsVCsryoiDxhn+5j4mLRhSC2gJiFeyyEotYhoPswCKK6KwnReLTepOho7gwxE37W1Zi K/rIYy1sy8uQjBLmW9Eh+KI/HR8kZ34ztVrGSb3dFKCZ8WMgaXsxVEFfLfbbLSPqJGOj 6gTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=Lpl6bFxJI4CHRgZzmX1LV+v0qDroFLN/nvNicZhBWbk=; b=bMvAOz+Tnp76BMeN0cUjPaIQ0zTGpC2Th7CsWzPMP2v8BvtjphUi/Sh8rOzQ8g6wsC FelDTmIgNVZzvCtS4qbcofr6Iq+AbqWQRUIqd7nLY3SGge49RYQda5xM7tuvLgTXHqe0 M4yH9wCtDygADYuUn5JhE24XY2L86bNi5B+8ie02OP15ylVQ2w6gQpNYU/Rt518caeRm jLGSrcd9lv+6UjnVbDSqPKYakUQLkU3tFLUJ1sXsPw/v7TphD0aAYcIbP4k0D/86EI0w 3PK9SXonnfmMO8zT7rOd4fpgWpA4CYujZnDxSSZ8OwD5tgxaD0ImKfbc8Zvgg8UkMIvz ZpTQ== X-Gm-Message-State: AJIora8w13Mq+BrKZD4a0i8527KhMIP59W1XBCBgkyULf5Cr4I+PRlol ME0ZNnTo0DjalrcAANlQTegFoqfBfIA= X-Google-Smtp-Source: AGRyM1txbt+9NgJBywZye18wHMFrzrxDjzOEouzPoc8+gANuChnXlXGrxwM174nRDA4EmaMfxx9wSKZ3OXQ= X-Received: from edliaw.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:4be]) (user=edliaw job=sendgmr) by 2002:a17:90a:e7c8:b0:1e6:92fe:84c2 with SMTP id kb8-20020a17090ae7c800b001e692fe84c2mr1259645pjb.194.1655163228891; Mon, 13 Jun 2022 16:33:48 -0700 (PDT) Date: Mon, 13 Jun 2022 23:33:21 +0000 Message-Id: <20220613233321.431282-1-edliaw@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog Subject: [PATCH v1] userfaultfd: selftests: infinite loop in faulting_process From: Edward Liaw To: shuah@kernel.org Cc: axelrasmussen@google.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kernel-team@android.com, Edward Liaw Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On Android this test is getting stuck in an infinite loop due to indeterminate behavior: The local variables steps and signalled were being reset to 1 and 0 respectively after every jump back to sigsetjmp by siglongjmp in the signal handler. The test was incrementing them and expecting them to retain their incremented values. The documentation for siglongjmp says: All accessible objects have values as of the time sigsetjmp() was called, except that the values of objects of automatic storage duration which are local to the function containing the invocation of the corresponding sigsetjmp() which do not have volatile-qualified type and which are changed between the sigsetjmp() invocation and siglongjmp() call are indeterminate. Tagging steps and signalled with volatile enabled the test to pass. Signed-off-by: Edward Liaw Reviewed-by: Axel Rasmussen --- tools/testing/selftests/vm/userfaultfd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selft= ests/vm/userfaultfd.c index 0bdfc1955229..2b2a68722ae1 100644 --- a/tools/testing/selftests/vm/userfaultfd.c +++ b/tools/testing/selftests/vm/userfaultfd.c @@ -931,7 +931,7 @@ static int faulting_process(int signal_test) unsigned long split_nr_pages; unsigned long lastnr; struct sigaction act; - unsigned long signalled =3D 0; + volatile unsigned long signalled =3D 0; =20 split_nr_pages =3D (nr_pages + 1) / 2; =20 @@ -946,7 +946,7 @@ static int faulting_process(int signal_test) } =20 for (nr =3D 0; nr < split_nr_pages; nr++) { - int steps =3D 1; + volatile int steps =3D 1; unsigned long offset =3D nr * page_size; =20 if (signal_test) { --=20 2.36.1.476.g0c4daa206d-goog