Received: by 2002:a89:28c:0:b0:1ef:fe5e:92fe with SMTP id j12csp26819lqh; Sun, 17 Mar 2024 19:35:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUE+ZQ87+VUYTNYPwZb37P+oa3vNwvc21nzWhkvS6Ypxm6rPnCFBY/IKYT7qd6MvPU2gFLW44ExwoFwYDPDNNIAWVGbRjsVyKW9lLWjLw== X-Google-Smtp-Source: AGHT+IHwHmqQxScJWMgwPrIbiAlFfJ2yLy8D/Z/XvH5bXCoOp+9+NagBbtrz6n0JBEAFb3alyqP4 X-Received: by 2002:a05:6102:53a:b0:472:ad8b:e7e1 with SMTP id m26-20020a056102053a00b00472ad8be7e1mr9136078vsa.32.1710729314977; Sun, 17 Mar 2024 19:35:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710729314; cv=pass; d=google.com; s=arc-20160816; b=kEOS0Yf0TnlUAsNHgct7a5P2vd2kumksmYX/l4CqvLteocZMINv6HKxI2Ag/dFKwGO t0QiGfokeP27VbrsOmtMwBdXsOTkw2uLcQl22t8+e4pKC/ZkeJdb1TNP8OclVUgSlLyj YF1fMIwnG7Io0y01K3Y0PGufFLFWG+Qyam1PiMnQK8lRUjwRs6UKx74OyI8d12PcVRdw fnRwz5wY19ruNjkZO8zsEAfc1qcNcAQ+PRUQhf5cdyMm8tHSfRqKgCUowWUSE4JHIQD6 Amfr3EQM7PFzNB0FJp2cc2lqnuXGhCJJ58JcNYnkEnrPrm/r520v96q3y+LR3146bC79 5JsA== 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; bh=wuDr5CMaZE1P9RYRkopKW1FoVYR+A8VtmZJbLs7EA70=; fh=o5HERRNwoGGeHHOxpFXlVhiCYJAqoq1J160zepr2R0k=; b=wzmEHx2gY4nXQAbBYk441tYROHgNYIG3qGD7hwCSRd82ooFPi7ViTisF5LdAwc7Ghj LbDxpo0ZskeP+HE0sDoTgSJDY9uOJkVsymvlQyrMVXihGIVQjX+Wa0Tr2nshXi9YNt08 kyyHhre+63QDVplASyME3LvtRuXrkLDAflUs9TymdbHqiAiJDMEO8imdbEKxoQsqWIpC 7hrbPV2MFjS6M3Bi9VpwvuNii6gwFAiM+XtuoLSXwbzm68Nth6qhclVCNgK3aSNgAiJ3 GlvkYX61+JICFVLKFgKkCV5ftxYUgfh09QUNABx3Xbhns0PT17oXh7nMrcR4JCJa9i49 tbWQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=altlinux.org); spf=pass (google.com: domain of linux-kernel+bounces-105657-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-105657-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 9-20020ac84e89000000b0042f28e927a3si8322410qtp.36.2024.03.17.19.35.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 19:35:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-105657-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=altlinux.org); spf=pass (google.com: domain of linux-kernel+bounces-105657-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-105657-linux.lists.archive=gmail.com@vger.kernel.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 96E3E1C20B6B for ; Mon, 18 Mar 2024 02:35:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D7541BF3F; Mon, 18 Mar 2024 02:35:09 +0000 (UTC) Received: from vmicros1.altlinux.org (vmicros1.altlinux.org [194.107.17.57]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 74ECF17547; Mon, 18 Mar 2024 02:35:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.107.17.57 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710729308; cv=none; b=tRkJxhTEilTC8ARPtltVFEkzKl1QGOlvf8ZhWal1r6veBFZ3ozhLjtITzjYxGKUD2VeLej1JrJfTZrLvLlSf1T2hkiCMaDDjecTRFL4X3BDr6Z488cdqTfy7W8ohqMsozwo72bnJSbI9M48HIVBM+hrls6snOdzEwGRU8CXcasY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710729308; c=relaxed/simple; bh=3fvjQ3XM2dUSCoHrk4prb1GoygcuSIqrovfjGK/r3oA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=A21ZIJCwLsiQXpUrSPUo00iygoGH3bNR9tQzsgEcO/b2cIcTGRKE+MW0Qvw+q2cD+TkiBQiOmw1WCBCnc3ZANnsEdGKGypqCasMCWf+sjAX14D6PtmI8+uTyh9TWMSUc7V5fqH0vIIzNGUw2cvdG8sijfiE/HaL3VZXzgDimDXc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=altlinux.org; spf=pass smtp.mailfrom=altlinux.org; arc=none smtp.client-ip=194.107.17.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=altlinux.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=altlinux.org Received: from imap.altlinux.org (imap.altlinux.org [194.107.17.38]) by vmicros1.altlinux.org (Postfix) with ESMTP id B1C3E72C8F5; Mon, 18 Mar 2024 05:35:03 +0300 (MSK) Received: from beacon.altlinux.org (unknown [193.43.10.9]) by imap.altlinux.org (Postfix) with ESMTPSA id 9DA5836D015F; Mon, 18 Mar 2024 05:35:03 +0300 (MSK) From: Vitaly Chikunov To: Andrew Morton , Keith Busch , Yang Shi , Zi Yan , David Hildenbrand , Peter Xu , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vitaly Chikunov , Andrea Arcangeli , Nadav Amit , Shuah Khan Subject: [PATCH] selftests/mm: Fix build with _FORTIFY_SOURCE Date: Mon, 18 Mar 2024 05:34:44 +0300 Message-ID: <20240318023445.3192922-1-vt@altlinux.org> X-Mailer: git-send-email 2.42.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add missing flags argument to open(2) call with O_CREAT. Some tests fail to compile if _FORTIFY_SOURCE is defined (to any valid value) (together with -O), resulting in similar error messages such as: In file included from /usr/include/fcntl.h:342, from gup_test.c:1: In function 'open', inlined from 'main' at gup_test.c:206:10: /usr/include/bits/fcntl2.h:50:11: error: call to '__open_missing_mode' declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments 50 | __open_missing_mode (); | ^~~~~~~~~~~~~~~~~~~~~~ _FORTIFY_SOURCE is enabled by default in some distributions, so the tests are not built by default and are skipped. open(2) man-page warns about missing flags argument: "if it is not supplied, some arbitrary bytes from the stack will be applied as the file mode." Fixes: aeb85ed4f41a ("tools/testing/selftests/vm/gup_benchmark.c: allow user specified file") Fixes: fbe37501b252 ("mm: huge_memory: debugfs for file-backed THP split") Fixes: c942f5bd17b3 ("selftests: soft-dirty: add test for mprotect") Cc: Keith Busch Cc: Zi Yan Cc: Peter Xu Cc: Yang Shi Cc: Andrea Arcangeli Cc: Nadav Amit Cc: David Hildenbrand Cc: Andrew Morton Signed-off-by: Vitaly Chikunov --- tools/testing/selftests/mm/gup_test.c | 2 +- tools/testing/selftests/mm/soft-dirty.c | 2 +- tools/testing/selftests/mm/split_huge_page_test.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/mm/gup_test.c b/tools/testing/selftests/mm/gup_test.c index cbe99594d319..18a49c70d4c6 100644 --- a/tools/testing/selftests/mm/gup_test.c +++ b/tools/testing/selftests/mm/gup_test.c @@ -203,7 +203,7 @@ int main(int argc, char **argv) ksft_print_header(); ksft_set_plan(nthreads); - filed = open(file, O_RDWR|O_CREAT); + filed = open(file, O_RDWR|O_CREAT, 0664); if (filed < 0) ksft_exit_fail_msg("Unable to open %s: %s\n", file, strerror(errno)); diff --git a/tools/testing/selftests/mm/soft-dirty.c b/tools/testing/selftests/mm/soft-dirty.c index cc5f144430d4..7dbfa53d93a0 100644 --- a/tools/testing/selftests/mm/soft-dirty.c +++ b/tools/testing/selftests/mm/soft-dirty.c @@ -137,7 +137,7 @@ static void test_mprotect(int pagemap_fd, int pagesize, bool anon) if (!map) ksft_exit_fail_msg("anon mmap failed\n"); } else { - test_fd = open(fname, O_RDWR | O_CREAT); + test_fd = open(fname, O_RDWR | O_CREAT, 0664); if (test_fd < 0) { ksft_test_result_skip("Test %s open() file failed\n", __func__); return; diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c index 856662d2f87a..6c988bd2f335 100644 --- a/tools/testing/selftests/mm/split_huge_page_test.c +++ b/tools/testing/selftests/mm/split_huge_page_test.c @@ -223,7 +223,7 @@ void split_file_backed_thp(void) ksft_exit_fail_msg("Fail to create file-backed THP split testing file\n"); } - fd = open(testfile, O_CREAT|O_WRONLY); + fd = open(testfile, O_CREAT|O_WRONLY, 0664); if (fd == -1) { ksft_perror("Cannot open testing file"); goto cleanup; -- 2.42.1