Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1934641lql; Wed, 13 Mar 2024 12:17:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVQlMQ3lMs/nkmzzupDB8n8a0pFZuydvVN9fxow5w0NTSwNA03eUgRglwYIiE9Y7qH/fNaKFm3V1v1u17ALMG+mzZcukFkK+ZWlnAfPaQ== X-Google-Smtp-Source: AGHT+IHlZsfuyKXJEktYlDFUfj9+IWHjyUanxGOnI624fbFX+sgtPrAmTf3631bXTAYDkAclizO2 X-Received: by 2002:a2e:b88d:0:b0:2d4:31a0:6adf with SMTP id r13-20020a2eb88d000000b002d431a06adfmr4299125ljp.24.1710357449497; Wed, 13 Mar 2024 12:17:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710357449; cv=pass; d=google.com; s=arc-20160816; b=RX/bZ8ndFiuct4RRxFGiLsq71YQuVkaqbj2AZWPrMPSx3l2i/llkX8qXvP0oY6lKfE QFSocsdlLAE6ZAwavcXwKAfPaTTEJhNy0Gu5yaFZDsosqbJWEALat1iNMsVa1SjmSXsx EU0AoEzGngrEgbxWYwMLBKW/MJEWcAFlydzRKyny+VwWxjPJvM/doH/JrMWzarnlqwjA oM5zlGAnRjesZ3KGj2eZzDCbyICsSiuZpBQKEN4e0v6a7L/nVE/slAXUX6dQ2ZuQd/wU eGhf51tCTMYjMTxQDCg2KVegGxIaMQmknompIGSapQGIH1HGLw9vq2/0BfpVGHKO3imX FvOg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=5XAsXiIDC6OwZ+FdvxFgNYuLvw56oPhd3QbM/5nEMps=; fh=+MLXCEDSHGU2sN+s9598mwRT1YmQId/8/k31CbxM73o=; b=QPUoZfeezGcyWaX0lGsg7asdPb/qM/62gp5ZKOP0Bv3/Dh2RpCtiENYg/U619cIxFV 9AFPihQ4rEaxal/3aP8jPBKaXS0s5ObPzVDS5Ycd3GTGy4t2PjY+v/Dx+7Y0cM22DKjj clnJ9l9tE28Nhvaow2YQFNb1FA+WbMxfvXrwGZQn1Wen5yZwk75QH2MgkKBQx42fgR/i 0FCbz0I3NZF5LXORy95lOVCspxDrmPOg/SQ5mau9nsq66WKzLf0Is2ofk/vzYHLHtTGL eLUSegFwXt+DT5lBpYblgP+dQtRgiEKbWfye4WBjHqP2BVSPcEYAiovrNUyeYDlKGsmQ RMmg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lNilWqOq; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-102388-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102388-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i2-20020a0564020f0200b0056875133d58si1951596eda.558.2024.03.13.12.17.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 12:17:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-102388-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lNilWqOq; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-102388-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102388-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 35B671F21322 for ; Wed, 13 Mar 2024 19:17:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 43A7257863; Wed, 13 Mar 2024 18:56:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="lNilWqOq" Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E259556B64 for ; Wed, 13 Mar 2024 18:56:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710356177; cv=none; b=Lg4HpbD72+qwoDkl70N+0q4rOUI9QLpV8SiXsmPO5vrAS3Znl7/AJxroBBf12N9A1fF8A+NLly4iwxxPkFnwxOs7eR7Q3gypn5Lbovyvcf8xXNFo5T9feNPLIaUTkNknBbr2gJVsDs20CodlF8pWE846LdUmXkI1RkfjgTjC0n8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710356177; c=relaxed/simple; bh=SQS+ov8yIW6DEKRzVTZuSjdygsQnSqtlsD90R8giz/g=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=UC8z5Wqlci5LZdSPSQMw+FDY+wOCNPdqQlNGH+r8sMdRZzdC9eaZF8TBAHTodK3gvcDOGn4bTlyOjb7/59ThhPTCDoJqh3hDrB6qig8jD5yrK92fcmG7ykci5oJIvGtCHUQOVSR2Yxj8X97RB/r2BpAqqjiFPmh834gTMrHGA0I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=lNilWqOq; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6e6b22af648so1067959b3a.0 for ; Wed, 13 Mar 2024 11:56:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1710356175; x=1710960975; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=5XAsXiIDC6OwZ+FdvxFgNYuLvw56oPhd3QbM/5nEMps=; b=lNilWqOq79hDVuTSXdXMCtyCBN5Y44x1C3HI1ZG5tM+vaIi/TovEVpgV4HgpMyXMCq rFfPx/UcBaonZNS+uqlgFkL8ha9R7ZOsPDz2gF848r/N/IoyVNZBBjYlJNIeSARrqWqu AMpnOaqHZi3QhH9hVOU2sw6HRaSJmCE5Avrew= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710356175; x=1710960975; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5XAsXiIDC6OwZ+FdvxFgNYuLvw56oPhd3QbM/5nEMps=; b=w9yhaLTNKeh/oohUUBLALbv2KTmXHQvZrezS5TP3DEP7xEygHqcZ2vWL8XY0cyprpc LNr2xXG3cTG61h/pQOb5Pj5rRlQCkLsan3kAwoRqKa6LkelCFt7hKgAGMoYXpZJQjED+ +iW4blfjg1apPMcdpSvDhDn53Aw949v8QJRhOG8ZmKe5gXB431lsEu67zP1rbPr4dy+I gEcOlCD3oIMQ14niFlN+h+/jYYxVlvhMLi5H1E/PGXpnMjO1wgqUzvy9+QzyyUfp9Vr9 mv5fvm0ZP2BiBp3vmMP7wZ7w12Gkzt3auh4Kkee9WfwHHzn1o7DBMijLWYn6P9cORyDs hr8w== X-Forwarded-Encrypted: i=1; AJvYcCV38NyJU91jRa/Ugc4JfHj88PkOTEIzaZPgLLGFmHptdrn1ghc/UWBoUsVULz+qxYUF3Fyh4fgEqcQpipfgH6i581TEXU/45dlNXrZa X-Gm-Message-State: AOJu0YySo4Xc5mGoBQ5DceSZzI0+vvQNJHcpGd8sr0gFZY7ZH86XtIVS qxKQDpLR803/3NIhJbJDlL26nUoN8yeLFVXCte8ZzIMA4aFa744dIGx3Y4w8oA== X-Received: by 2002:a05:6a20:12c5:b0:1a1:87b5:4b28 with SMTP id v5-20020a056a2012c500b001a187b54b28mr4995408pzg.0.1710356175280; Wed, 13 Mar 2024 11:56:15 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id z3-20020aa79903000000b006e6b959b636sm1615689pff.53.2024.03.13.11.56.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 11:56:14 -0700 (PDT) From: Kees Cook To: Eric Biederman Cc: Kees Cook , Shuah Khan , Mark Brown , Muhammad Usama Anjum , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] selftests/exec: execveat: Improve debug reporting Date: Wed, 13 Mar 2024 11:56:10 -0700 Message-Id: <20240313185606.work.073-kees@kernel.org> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1980; i=keescook@chromium.org; h=from:subject:message-id; bh=SQS+ov8yIW6DEKRzVTZuSjdygsQnSqtlsD90R8giz/g=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBl8fbKt7Aicr2v1jL2D5Cbtq5T6AALRK5Ut0QjW yJY662adQiJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZfH2ygAKCRCJcvTf3G3A JhdZEACO826i+YbxlErFkdeBoatgCSeytNdOJhvq9RSnhz1h6CSrIOdrAzqhfHWtRFO1b/4Q4k/ bfZpBWeYDrreNjcB4+axQl0dBlBLpcvZD/XhhZWF/q2qXA8G4R8sL+IQgxvbC1SfY43m4voENz/ S11w3mMf4mhfsGrUCfSLJXUhkRSrw/uqmjZ2/158F5SiTU+x8c2QpqpXfd5nujAZQcLQefx3oji k68TQcM3f3oQeiAO0p011Bh9gHe92BSnjZB2Pfh3JJWeEOCOxR5/BEAQGF+Xwstsdc1gf5W2x47 maW249sTvbIujyJMudbFe6ADnOxYZzMxcNzsg8f7Xm67xyv/pUv3PMMisH/FC5a5xDuOcuM56NJ M7qkV5lAuGdGpFWQgrZ9vrPqSWsnE/fl0u44X6E9CTRaboDIU0if+uAm24IYm/e4HaXu5L31l+1 7OWMd0275j+zKuT5THdsQOMFsiP/Kl0jIChgbDt7IoViRJPOIsK2zLa6yzTrWCl85krYW/a2Gj5 YetE0h8hI10kXC8d/ynnF3syoaeTcRxOOd/CYVx6MfouycA3E5sMntsQGGqDvnxnQLh+ZoSDoaJ zqDad87A49h4QoM2nZYN1m5WfK4xlatrRK0ZHnPBwQYV8X7BzT8LEGyHaT6OCqDmfVsCdSPNfE3 cjjEus9 TFgxnctA== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit Children processes were reporting their status, duplicating the parent's. Remove that, and add some additional details about the test execution. Signed-off-by: Kees Cook --- Cc: Eric Biederman Cc: Shuah Khan Cc: Mark Brown Cc: Muhammad Usama Anjum Cc: linux-mm@kvack.org Cc: linux-kselftest@vger.kernel.org --- tools/testing/selftests/exec/execveat.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/exec/execveat.c b/tools/testing/selftests/exec/execveat.c index 0546ca24f2b2..6418ded40bdd 100644 --- a/tools/testing/selftests/exec/execveat.c +++ b/tools/testing/selftests/exec/execveat.c @@ -98,10 +98,9 @@ static int check_execveat_invoked_rc(int fd, const char *path, int flags, if (child == 0) { /* Child: do execveat(). */ rc = execveat_(fd, path, argv, envp, flags); - ksft_print_msg("execveat() failed, rc=%d errno=%d (%s)\n", + ksft_print_msg("child execveat() failed, rc=%d errno=%d (%s)\n", rc, errno, strerror(errno)); - ksft_test_result_fail("%s\n", test_name); - exit(1); /* should not reach here */ + exit(errno); } /* Parent: wait for & check child's exit status. */ rc = waitpid(child, &status, 0); @@ -226,11 +225,14 @@ static int check_execveat_pathmax(int root_dfd, const char *src, int is_script) * "If the command name is found, but it is not an executable utility, * the exit status shall be 126."), so allow either. */ - if (is_script) + if (is_script) { + ksft_print_msg("Invoke script via root_dfd and relative filename\n"); fail += check_execveat_invoked_rc(root_dfd, longpath + 1, 0, 127, 126); - else + } else { + ksft_print_msg("Invoke exec via root_dfd and relative filename\n"); fail += check_execveat(root_dfd, longpath + 1, 0); + } return fail; } -- 2.34.1