Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp153109rdb; Thu, 1 Feb 2024 05:05:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IEFum6VKl+bD1fmdXxoYoIc/X5L6iH1xuE5N21trWxwEMr6UJRPy0TaOsJcDmJyNQVcZena X-Received: by 2002:a05:6a21:7894:b0:19c:a1e0:bfab with SMTP id bf20-20020a056a21789400b0019ca1e0bfabmr5610324pzc.9.1706792744897; Thu, 01 Feb 2024 05:05:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706792744; cv=pass; d=google.com; s=arc-20160816; b=bKdTKjIS5YcJ+r0mATkYZH2Gk3sMeV+MwvNztpbgWzzCIdu6MoUc2PZL7sWQrlXdW2 rRj88HLhSXWA1fjGOaqSGSKa7son6WxgTTYj6s9qIOuSCv6yZVrDIDBf+B2CesNdE+g/ mo9xuW/uynqvaD2YFdur5AEr2iM2P1TvZVGRWf2BA4E+aCUVGtA+oxvYguqcFSEXOVCn 7H0RpNkeS6JieT9JBIgC2KRmB3J/pZ59qMKgqAOvlJFpgWLRNHxaE2vnA8gRPJB8Fyw1 pwwqvWHwwUeSMYYKFPVsywPNU5we52FVc+QsFMOWNSPXB4+fN22yUrXuDjJyKCBv20Vg 07jg== 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=7mcIanNF32GwazO1YeL2H9SsxSXNOFUxupp96fOV2YA=; fh=Q4CWEsRi+7Y2w+DtLy6ksUvfP8+jTP4Js/XR+KINyz0=; b=oRKvtPjHI36EozNe0oxMQy+/SLS+uPSzBiOqo0XXWtQaLblxhvcooX899yrFZXtJTr TXoSReVRWwh16kgAvC2MnSSz6cxLHZgy1Tp4szAplUczI4xdXEAUvFMCPczdTHQJfI6U y3U6j/apeW8NVGO6/7H/2+qsm9usluT0QgsnHZtm017IMTsCMrqOSj97KAA7rOZFD1co Jjj4JWX42FUYTd91nkDaI+T19bCJ40Cv874JrW9yR6ZH2x1B9AYTPrpuxhBo6jWOSqOi CUZRXl0+3x9lMLBJXXaHhqYvx27GReO2/7KT5fTA2j5R7HkMkX9NeMVw2FCUUOYR1GiH ExQA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=bp06Xi6v; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-48185-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48185-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com X-Forwarded-Encrypted: i=1; AJvYcCU5HTvbokF3VzTMTe1Ge3hCZRxDwy+fccCSyuL63ZY8TvAkQUKR5q1d4y94ISYEg9VYkJ+HDCnpEEUC78ZOhvaMzBMdENCMzyS21jrPxQ== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ei46-20020a056a0080ee00b006dddc5f6d72si11742234pfb.54.2024.02.01.05.05.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 05:05:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48185-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=@collabora.com header.s=mail header.b=bp06Xi6v; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-48185-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48185-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com 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 18B9A28743F for ; Thu, 1 Feb 2024 13:05:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 34F852134F; Thu, 1 Feb 2024 13:05:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="bp06Xi6v" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (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 DCA2D86645; Thu, 1 Feb 2024 13:05:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706792738; cv=none; b=NTd2lpx0ztARkaf5gDMqpUlm/b1/MG0Cwg8S7Cs+fpYpXYs9uuSQDyQNX8kAFt118W9tiVgt+9fx0oVRpeB2KemfLuDQqid761YUu50+/EOMj2BWlrfqCKZ81yxmPPubUJ8MZ5Jc5Z5Qt67Ngj/I7BBAOL9ZTcFr8MgMpG3hybA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706792738; c=relaxed/simple; bh=s4vhoRvfEvFZwOisdM2aMqjEVJFakRY46t1Nik7WI30=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=VTdszv/6vX34wiZpFPdDJu707qRkcga8Nfl7ZKCxpv3CKVqaf0oeayrgNFTcydEt9AlSRQz+29s5lOKC13Zl5N8lvnmf1d7vtqWjvZ4QUMhzY+ysfdoKGN1Nqfihc2Frts9Y38ntE6zzwPO/C3ywFmkcfTrSz0XZBIv6/OgC6Lg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=bp06Xi6v; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1706792735; bh=s4vhoRvfEvFZwOisdM2aMqjEVJFakRY46t1Nik7WI30=; h=From:To:Cc:Subject:Date:From; b=bp06Xi6v1KuIBWxidHRBmia8CUyfh5utC2lT8FJaXct0Fy0lE4hde7U/u7qCBDaYS 7oCMDDSOfk1vufGTLTFHBPVmHchkvHGHijgXWkKvfL/XT+/4o3dYq1X+5ZsJQU/15U wTJnPZ45xte/wvW1KTIwQU6+oWZdAvbmR9od12+3tLz8gdg2ZGmaw54726qxjRhBY8 YZQ5feLlratEx4yb2lh/SVs4wBEFkAKF5I+R+Z+hZBCaRj8boGPQcN5ttyHYCOt7E+ yEduhbGfhMSjG13psjRBy4M+6lRSuxiviI/uM2EK3CSeTCaZQT5Dl/Qw95CgMUHneE rNVJJQRP9RZqg== Received: from localhost.localdomain (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madrid.collaboradmins.com (Postfix) with ESMTPSA id D56C0378047F; Thu, 1 Feb 2024 13:05:32 +0000 (UTC) From: Muhammad Usama Anjum To: Andrew Morton , Shuah Khan , Muhammad Usama Anjum Cc: kernel@collabora.com, ryan.roberts@arm.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] selftests/mm: on-fault-limit: run test without root privileges otherwise skip Date: Thu, 1 Feb 2024 18:05:36 +0500 Message-ID: <20240201130538.1404897-1-usama.anjum@collabora.com> X-Mailer: git-send-email 2.42.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The mmap() respects rlimit only for normal users. This test should be run as normal user, without root privileges. Also add back the sudo -u nobody as run_vmtests.sh is run as root most of the times. Skip the test instead if sudo isn't present to lower the privileges. Fixes: b6221771d468 ("selftests/mm: run_vmtests: remove sudo and conform to tap") Signed-off-by: Muhammad Usama Anjum --- Please fold this patch in the Fixes patch if needed. --- tools/testing/selftests/mm/on-fault-limit.c | 6 +++--- tools/testing/selftests/mm/run_vmtests.sh | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/mm/on-fault-limit.c b/tools/testing/selftests/mm/on-fault-limit.c index 0ea98ffab3589..431c1277d83a1 100644 --- a/tools/testing/selftests/mm/on-fault-limit.c +++ b/tools/testing/selftests/mm/on-fault-limit.c @@ -21,7 +21,7 @@ static void test_limit(void) map = mmap(NULL, 2 * lims.rlim_max, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE, -1, 0); - ksft_test_result(map == MAP_FAILED, "Failed mmap\n"); + ksft_test_result(map == MAP_FAILED, "The map failed respecting mlock limits\n"); if (map != MAP_FAILED) munmap(map, 2 * lims.rlim_max); @@ -33,8 +33,8 @@ int main(int argc, char **argv) ksft_print_header(); ksft_set_plan(1); - if (getuid()) - ksft_test_result_skip("Require root privileges to run\n"); + if (!getuid()) + ksft_test_result_skip("The test must be run from a normal user\n"); else test_limit(); diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh index 55898d64e2ebf..edd73f871c79a 100755 --- a/tools/testing/selftests/mm/run_vmtests.sh +++ b/tools/testing/selftests/mm/run_vmtests.sh @@ -303,7 +303,12 @@ echo "$nr_hugepgs" > /proc/sys/vm/nr_hugepages CATEGORY="compaction" run_test ./compaction_test -CATEGORY="mlock" run_test ./on-fault-limit +if command -v sudo &> /dev/null; +then + CATEGORY="mlock" run_test sudo -u nobody ./on-fault-limit +else + echo "# SKIP ./on-fault-limit" +fi CATEGORY="mmap" run_test ./map_populate -- 2.42.0