From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (unknown [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 87112802A5 for ; Wed, 21 Oct 2026 16:59:16 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 69LGw1lL023086; Wed, 21 Oct 2026 19:58:02 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69LGw1lL023086 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="nMk4XO88" Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 69LGvNt0022969 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 21 Oct 2026 19:57:24 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69LGvNt0022969 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-48e17d30a79so665705f8f.3 for ; Wed, 21 Oct 2026 09:57:24 -0700 (PDT) X-Gm-Message-State: AFq9FYJv8FFczHAhtV24REpun0xs2l2UdOSPn9nRIpoH13DGGXBucXRP kWN3tQ+kM8POVgIYUvtrVrR9OLUC6H6SIqAKnMaW2eKbtn4uqTWOtCiFoCfY2rjcwOyat9yc7zh rhky5ju0EftsYJeSCgGEkTnTxr1u3+Q3+bytsepbrRkzBhOdBd+Wyaw== X-Gm-Gg: AYBFou1/sdByY47/mYKvflcMw+SDYizf1agxNctHJWwZStZvlmRuqSxviHCTN6QANxu Ug9lpZ830uc3exG4qBnBx7CwbJxDsQWj2PrSWi0292beN7OfMLArn5Rq4EndH3EaV8N0hD/kZwP wkzM7r97UEvmKsmZWZujZd1gka6ReNsWv4GXhBtNn73UuEWYkBD8GM2fHaRfbcd4W+Z+GFIvB3j mdJTIGENDnJ77OzHItSpIXR3nAEVYc749WPq4TIod9297UEPdMv2Bu7BFEZITV/WfYn4gGDWh7z hZWL1jibjG+vPxQWasgmb2SMNc0hbUK4iKCEFug+GfnuOwzj8r/MJqr+vcKEY+9T+o+DQe9rr3Y k2DPW0huDXWNzQvI/5w== X-Received: by 2002:a05:6000:4b08:b0:487:197a:5c1f with SMTP id ffacd0b85a97d-48e2650e70dmr6331385f8f.49.1792601843606; Wed, 21 Oct 2026 09:57:23 -0700 (PDT) X-Received: by 2002:a05:6000:4b08:b0:487:197a:5c1f with SMTP id ffacd0b85a97d-48e2650e70dmr6331314f8f.49.1792601843055; Wed, 21 Oct 2026 09:57:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1792601843; cv=none; d=google.com; s=arc-20260327; b=bP8PH/LDhK3KRKyGqPerbipq4uwMMy3zFUtjKy+zPTs80qsDh4kB3CXdp+fUpK3Y4h NPkb1ZvObwjSSJkxpJMpYohHqNS3J2UbG4pLuqE7neHewbhU5IhnO9elrqVMW9ZXmv9c 7FoYySAersII808ntB4NPgJK3i9dj91kx/8mXXiZmosIwwLeVN2Xx2xJCNSL/vX1AvSX IX6O3+jXHKiPytVBDUP4G4myNwIChmmgTWO8jIz9WiX9D2bCM9UCquraPYT1CDlt06FK 7xE7xb7kppn7sQ5Bhknb/TteBgO7SPoQX7YDsHXOPX8/hls/Rlj+dzO3nUAEJACII3PJ Sj1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=GoFJsCpCxAzpmDoUrXVxwcKRKjeJqmfoIOYQIBnw0DY=; fh=ORqO450YHYjnAvQVnHrQRoSXc/Ljts4WdUx12SqEe+w=; b=qg2JZ+O+Nd2psXXCSrPDoGq8pS8dulaxs+jpK3TyOn4D+P0dCBEH7IQ1lwlYYWDW3N e9oH7Q2grjfp5a3qVoylJNjE+xq25FYv8oRlaVsmjNv4Mx8Hzf9NaLoPWCfMJNHLKJEM uSl9YCFsQ02+EVpq3zZKWSrewgLfEqHVd1/iDEWO67kZRtO6L721h/2iVeD8BfWHI4qV 6drzs15IYwf0bOMjvMKiUTvopUYkuPyu/SLM/bvLvy9HtUdJhERDvubFX0AOzvm4opb+ 8EGkllAR7CZc9HnWm3hw3a1jfsGWILfJToEs9IQ8a83xLaKgz5wzvktGhCIwadOpBvH1 2lnA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=nMk4XO88; spf=pass (google.com: domain of khorenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=khorenko@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id ffacd0b85a97d-48e258638acsi6262443f8f.226.2026.10.21.09.57.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2026 09:57:23 -0700 (PDT) Received-SPF: pass (google.com: domain of khorenko@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=nMk4XO88; spf=pass (google.com: domain of khorenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=khorenko@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=Message-Id:Content-Type:MIME-Version:Subject:Date :From; bh=GoFJsCpCxAzpmDoUrXVxwcKRKjeJqmfoIOYQIBnw0DY=; b=nMk4XO88+8sQqJdK8Qt 38nSPsxj6HVMJ50iwXO5/1sLfnm1K9LBee0Ey+UfB+zHLJ7XXyzdC2cbI0V43YqnIcB8fyY9b/cOT J9x79Jx2lLVdLjadK0jt/iq7Hg2ySA/5IolbmQ8fJV556Z6MdyvbdA9BNEDvPnAENp5y3YkQ+hWe5 3GNkTwEDbFU5lxSJsrIdrOJNVjTbkAx/rOS8Ctf3yinZd0QsoHSRkCxqVw5BJyyTVugfn1JGHWO2I alvanCC+1lTiawrtb5casX+qEP47cJT0eSaLS3m1UNJ4Kd3+OkTtCTA98dOBN8jgJXGeN0toJ5yUy HTAKStupz7zbLWA==; Received: from ch-demo-asa.virtuozzo.com ([130.117.225.8] helo=f0.sw.ru) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1xJZZL-008y7H-02; Wed, 21 Oct 2026 18:57:21 +0200 From: Konstantin Khorenko Date: Wed, 21 Oct 2026 18:57:22 +0200 MIME-Version: 1.0 Message-Id: <20261021-b4-prep-khorenko-vstor-149847-5-doexec-selftests-v2-9-97dbb5c6e0ab@virtuozzo.com> References: <20261021-b4-prep-khorenko-vstor-149847-5-doexec-selftests-v2-0-97dbb5c6e0ab@virtuozzo.com> In-Reply-To: <20261021-b4-prep-khorenko-vstor-149847-5-doexec-selftests-v2-0-97dbb5c6e0ab@virtuozzo.com> To: Andrey Drobyshev , Pavel Tikhomirov , Vasileios Almpanis X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4142; i=khorenko@virtuozzo.com; h=from:subject:message-id; bh=zibusMsQ7L4wS9YmVCpXVPbTpY+Q/ADokdV/J6Zj4qg=; b=owEBbQKS/ZANAwAKAVGWCkf5YVwqAcsmYgBq2O7wk0w9i+78QUWbElksU9BYWGYEEHyBR7TZN XluiIFYU/yJAjMEAAEKAB0WIQRWD23IPcXT0GO9CCxRlgpH+WFcKgUCatju8AAKCRBRlgpH+WFc Kl6LD/97qjcwTgYgYtNUGIctuHS1oiXf9QRZ78MbG0V8jLMO8vksvA7O62vVcsg660yTAmoHEyj mIPztCAndZs9I0BdehpKhdAnzzbxT3E2n8P3FOC7XjABIYMPNUFbyb5ovssly67NlhhUwSoelHB denVVQtJcnD4mb4god+4vAeWkXTiml7F0rNfOCSufwr0AX1JmDs1KFY0IEd1K8kCo5FafJ3jUv2 rN/z6YZNYSBG650QUFvO37SRZNIdUeGBBSuSCNU7e0B0PTQgxzDz+WkBRtlopo5tRuhp1yHW/tp PaCFcT0DrdtJhralZ/v6v2p0S4C9RlPMCkpYESXB3AISUUh7epqJZ89CmVPr7baQNJHDDTE9NC2 I6K8u/1foqEcJLQuSoxPtEz7dVk43T+CDLPC63NtiCozi167r4I2Pd3edBmQQXCigVvqMvuCFh3 ml/L99aArvLevf7csonPNX5day6nU8OdG8nVYb1pxypT/3drf5lMnKxCEmI5nbOoNIWo95f8/C/ KAdMxBdteXMurgHpDeW2cbV+WNUnM2RApq7uXbemVCuwC17AB/8UAimfWYRUraqBDo1FTEa8Wu4 Gvq2ewxHqgfQQAVhCIj4w4LjxGPjecvbXgG+l8eVw5ph82OlKfi0JiivT+CBokWxS2E3dVQf59O x8D1cgF2UHYFRkg== X-Developer-Key: i=khorenko@virtuozzo.com; a=openpgp; fpr=560F6DC83DC5D3D063BD082C51960A47F9615C2A X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 v2 9/9] selftests/mm: do not lose doexec failures X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org Some doexec failures can go unreported: - write() results are ignored. The clone race reports a failure by writing to a pipe, so a failed write turns it into a pass, and a failed wake-up write leaves a shared-mm child blocked forever. glibc warns about these with _FORTIFY_SOURCE. - The allocation failure sweep prints the failing exec and calls _exit() without flushing stdout, so under a pipe the message is lost. - The writes that disarm fail-nth are not checked, so injection could still hit the checks that follow a failed disarm. Check every write(), abort when a race failure cannot be reported, and flush stdout before that _exit(). https://virtuozzo.atlassian.net/browse/VSTOR-150234 Feature: oracle/mm: MADV_DOEXEC madvise() flag Assisted-by: LLM Signed-off-by: Konstantin Khorenko --- tools/testing/selftests/mm/doexec.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/mm/doexec.c b/tools/testing/selftests/mm/doexec.c index 7e73a98e4ec2a..561e07b4444f0 100644 --- a/tools/testing/selftests/mm/doexec.c +++ b/tools/testing/selftests/mm/doexec.c @@ -441,7 +441,8 @@ static int shared_mm_exec(bool own_thread) if (pthread_create(&thread, NULL, blocked_thread, &pipe_fd[0])) return fail("pthread_create failed"); check_exec(ram, size, 1, false); - write(pipe_fd[1], "x", 1); + if (write(pipe_fd[1], "x", 1) != 1) + return fail_errno("write"); pthread_join(thread, NULL); return KSFT_FAIL; } @@ -460,7 +461,10 @@ static int shared_mm_exec(bool own_thread) } else { ret = check_bytes(ram, size, 0x31) ? fail("contents lost") : KSFT_PASS; } - write(pipe_fd[1], "x", 1); + if (write(pipe_fd[1], "x", 1) != 1) { + ret = fail_errno("write"); + kill(pid, SIGKILL); + } if (wait_child(pid)) ret = KSFT_FAIL; if (ret) @@ -966,6 +970,13 @@ struct clone_race { atomic_uint rounds; }; +/* A failure that cannot reach the supervisor must still fail the test. */ +static void report_failure(struct clone_race *race) +{ + if (write(race->report, "x", 1) != 1) + abort(); +} + static int clone_race_child(void *arg) { struct clone_race *race = arg; @@ -973,7 +984,7 @@ static int clone_race_child(void *arg) for (i = 0; i < 8; i++) { if (__atomic_load_n(race->ram, __ATOMIC_RELAXED) != 0x31) { - write(race->report, "x", 1); + report_failure(race); return KSFT_FAIL; } usleep(1000); @@ -989,7 +1000,7 @@ static void *clone_race_thread(void *arg) pid_t pid; if (stack == MAP_FAILED) { - write(race->report, "x", 1); + report_failure(race); atomic_store(&race->rounds, 4); return NULL; } @@ -998,9 +1009,9 @@ static void *clone_race_thread(void *arg) CLONE_VM | SIGCHLD, race); if (pid >= 0) { if (wait_child(pid)) - write(race->report, "x", 1); + report_failure(race); } else if (errno != EBUSY && errno != EINTR) { - write(race->report, "x", 1); + report_failure(race); } atomic_fetch_add(&race->rounds, 1); usleep(1000); @@ -1122,7 +1133,8 @@ static int allocation_failures(void) _exit(fail_errno("fail-nth setup")); err = check_exec_fd(exe, ram, size, stride); /* Disarm before checking mappings or exiting. */ - pwrite(fd, "0", 1, 0); + if (pwrite(fd, "0", 1, 0) != 1) + _exit(fail_errno("fail-nth disarm")); for (i = 0; i < size; i += stride) if (ram[i] != 0x31) _exit(fail("contents lost by a failed exec")); @@ -1135,6 +1147,7 @@ static int allocation_failures(void) err == E2BIG || err == ELIBBAD || err == EIO) _exit(10); ksft_print_msg("fail-nth %u: exec: %s\n", nth, strerror(err)); + fflush(stdout); _exit(KSFT_FAIL); } do { @@ -2395,7 +2408,8 @@ int main(int argc, char **argv) int fd = open("/proc/self/fail-nth", O_WRONLY); if (fd >= 0) { - write(fd, "0", 1); + if (write(fd, "0", 1) != 1) + return fail_errno("fail-nth disarm"); close(fd); } if (!range_mapped(ram, size)) -- 2.43.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel