From patchwork Wed Apr 18 07:52:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 133600 Delivered-To: patch@linaro.org Received: by 10.46.84.18 with SMTP id i18csp5597960ljb; Wed, 18 Apr 2018 00:53:16 -0700 (PDT) X-Google-Smtp-Source: AIpwx48utBMeboaVUfMgvKSRh+H0hyviDRB16WhWVCi2VEIhccQGanxHfQHds3mztAOZmJOAH8oK X-Received: by 2002:a17:902:51ce:: with SMTP id y72-v6mr1080807plh.157.1524037996732; Wed, 18 Apr 2018 00:53:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524037996; cv=none; d=google.com; s=arc-20160816; b=fimsfhkFt7IUFBynPY9jPu9Cq2aKeUsE9BZgF4OEn7bS3aOouWN2/8F31oRQAMazp6 OOjzkjMtxn4bigTNVnRTGcgTdcD1ArcuXmiWTYLNIhxYmdfZip2kys0qJy+C0ygDcfm0 6i8luqfdNsiOlDAw7wgCqLBNltQIcxJMQy3tpuJm877jzjV89F4pK/LWHPTWlKQ9jcja QT41JhPjJQLrNr91Ks59tggwiaGt+hBb1RSolxr3JeCe1SC5rjBfoAeIeOq1zbYxMDHF sqHXoiBjEynrL2lvZ7J+UAp1RliKl9ShpCTGPSbJbTYJ+NRvh9Mj+5Xvr0xNTQooh9m/ OfPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=RH6QWvpiFcACysa31kTOJdcmJUwcntGcr6GmMV+k8BA=; b=I+qANt6X7l9DACgb1HnpYHvlvTMlx2ic8JsvAF3cDvA3UleaOTl6M/ym6rh61nzvVk K+9ljdzQz0UDJuwZuAdn+6DrqgC+N11Osbxh82CSIpZ48IzGYZs04m2J+BAxBFs0hqdM lTO3+9iPdxug/FfnaR5HZ1uZtxEg8mJc6NLnlEmoa65y+BIdyXrQq1A0OHTMkRgMSL0R WAdLK2DumQyWLLyRV8j5tAWkAKvo22eZpRNn2aNmvtEkhd+di6PnqDe0W5ilTVgOCaF1 fQ+mRyfsSzwgZd6udpVAXrjbpX8ZNU+JNMMzmL9IsqdL4RNquXzepkrW+vBtiAX3gfcw CbtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jBX3Z7Lk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si735419plj.247.2018.04.18.00.53.16; Wed, 18 Apr 2018 00:53:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jBX3Z7Lk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752712AbeDRHxN (ORCPT + 29 others); Wed, 18 Apr 2018 03:53:13 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:35278 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751444AbeDRHxL (ORCPT ); Wed, 18 Apr 2018 03:53:11 -0400 Received: by mail-lf0-f67.google.com with SMTP id r125-v6so1216333lfe.2 for ; Wed, 18 Apr 2018 00:53:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=RH6QWvpiFcACysa31kTOJdcmJUwcntGcr6GmMV+k8BA=; b=jBX3Z7LkX2pjwpThcDeju4LkAbak6IPdlkfal5plqas4d/in/CyP0nvnSmSJv2G3k1 Tcrla2TB6S/oYw+jqM187D3mgo9oMTdFPFKpYN7IHoLT5Ru9OYuBVsIsawXni0PpUF5k lHjA/bjsU27YtsQ5wBxBt8FFRFfWTdjUZlQa4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=RH6QWvpiFcACysa31kTOJdcmJUwcntGcr6GmMV+k8BA=; b=XZeM+TMqzap0ROSVYoTD7OeeNtyyePpwQEulY6dsZXV4RnIXFa0yCDW4Pzi1MeNfKy Vh1qtBSQAgPdqFiKJUKkPcmoWOs8dFg3tuzn8dT51ND+5J/r5XXv9sTqp7gw3SO8lAln dyyn/RwM4+yi/XvuhAaDzUr2Y9/mOPu+s9bb7Un/gehaD5jvgtLqJNVMtM1HEyD3I29J r2JcYe9Pwdc5x5AU8PE1MlcLWfSf4e015Vwb5OSQ8cIvkOEcoLllOFE5m2jhCQrkyKgC Iq0hIbJRblofXS7k7XEkPk0PO/WJWMKIyjPAqTpqPIkPLMNk+b94EhSmt89hmj7ZqK6X XUCg== X-Gm-Message-State: ALQs6tDEu6hMyaUfm39GqDgeJZpeVCI4hRdfccMIa/Sr+gb2FY+BX++q dtHM13WjAkbt93VKzc6LawNj3w== X-Received: by 2002:a19:519a:: with SMTP id g26-v6mr744144lfl.50.1524037989936; Wed, 18 Apr 2018 00:53:09 -0700 (PDT) Received: from localhost (c-4c3770d5.07-21-73746f28.cust.bredbandsbolaget.se. [213.112.55.76]) by smtp.gmail.com with ESMTPSA id v80-v6sm150596lfi.7.2018.04.18.00.53.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 18 Apr 2018 00:53:09 -0700 (PDT) From: Anders Roxell To: shuah@kernel.org, christian.brauner@ubuntu.com Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Anders Roxell Subject: [PATCH 1/2] selftests/filesystems: devpts_pts included wrong header Date: Wed, 18 Apr 2018 09:52:55 +0200 Message-Id: <20180418075256.300-1-anders.roxell@linaro.org> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We were picking up the wrong header should use asm/ioctls.h form the kernel and not the header from the system (sys/ioctl.h). In the current code we added the correct include and we added the kernel headers path to the CFLAGS. Fixes: ce290a19609d ("selftests: add devpts selftests") Signed-off-by: Anders Roxell --- Hi, I've been running devpts_pts on a mainline kernel (4.16+git0+60cc43fc88) and the verify_invalid_ptmx_bind_mount() test failes with this failure: root@intel-core2-32:~# ./devpts_pts Failed to perform TIOCGPTPEER ioctl However, I'm still confused why I'm not able to get the test to pass. Strace showes that -ENOENT return in the TIOCGPTPEER implementation in the kernel. I think the -ENOENT gets returned from this path devpts_mntget()->devpts_ptmx_path->path_pts(). See the strace issue below: root@intel-core2-32:~# strace ./devpts_pts execve("./devpts_pts", ["./devpts_pts"], [/* 17 vars */]) = 0 brk(NULL) = 0x5634e0092000 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f459d338000 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=16726, ...}) = 0 mmap(NULL, 16726, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f459d333000 close(3) = 0 open("/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3 read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260\3\2\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=1681056, ...}) = 0 mmap(NULL, 3787168, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f459cd7b000 mprotect(0x7f459cf0f000, 2093056, PROT_NONE) = 0 mmap(0x7f459d10e000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x193000) = 0x7f459d10e000 mmap(0x7f459d114000, 14752, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f459d114000 close(3) = 0 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f459d331000 arch_prctl(ARCH_SET_FS, 0x7f459d331700) = 0 mprotect(0x7f459d10e000, 16384, PROT_READ) = 0 mprotect(0x5634debe3000, 4096, PROT_READ) = 0 mprotect(0x7f459d33a000, 4096, PROT_READ) = 0 munmap(0x7f459d333000, 16726) = 0 ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0 unshare(CLONE_NEWNS) = 0 mount("", "/", NULL, MS_REC|MS_PRIVATE, NULL) = 0 mount("/dev/pts/ptmx", "/dev/ptmx", NULL, MS_BIND, NULL) = 0 open("/dev/ptmx", O_RDWR|O_NOCTTY|O_CLOEXEC) = 3 ioctl(3, TIOCSPTLCK, [0]) = 0 ioctl(3, _IOC(0, 0x54, 0x41, 0x00), 0x80102) = 4 clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f459d3319d0) = 4377 wait4(4377, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 4377 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=4377, si_uid=0, si_status=0, si_utime=0, si_stime=0} --- close(3) = 0 close(4) = 0 getpid() = 4376 open("/tmp/devpts_ptmx_Z6aEvy", O_RDWR|O_CREAT|O_EXCL, 0600) = 3 mount("/dev/pts/ptmx", "/tmp/devpts_ptmx_Z6aEvy", NULL, MS_BIND, NULL) = 0 close(3) = 0 open("/tmp/devpts_ptmx_Z6aEvy", O_RDWR|O_NOCTTY|O_CLOEXEC) = 3 ioctl(3, TIOCSPTLCK, [0]) = 0 ioctl(3, _IOC(0, 0x54, 0x41, 0x00), 0x80102) = -1 ENOENT (No such file or directory) write(2, "Failed to perform TIOCGPTPEER io"..., 36Failed to perform TIOCGPTPEER ioctl ) = 36 close(3) = 0 umount2("/dev/pts", 0) = 0 umount2("/dev/ptmx", 0) = 0 mkdir("/tmp/devpts_fs_w22bR6", 0700) = 0 mount("devpts", "/tmp/devpts_fs_w22bR6", "devpts", MS_NOSUID|MS_NOEXEC, "newinstance,ptmxmode=0666,mode=0"...) = 0 open("/tmp/devpts_fs_w22bR6/ptmx", O_RDWR|O_NOCTTY|O_CLOEXEC) = 3 ioctl(3, TIOCSPTLCK, [0]) = 0 ioctl(3, _IOC(0, 0x54, 0x41, 0x00), 0x80102) = 4 clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f459d3319d0) = 4378 wait4(4378, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 4378 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=4378, si_uid=0, si_status=0, si_utime=0, si_stime=0} --- close(3) = 0 close(4) = 0 unlink("/tmp/devpts_fs_w22bR6") = -1 EISDIR (Is a directory) exit_group(0) = ? +++ exited with 0 +++ root@intel-core2-32:~# tools/testing/selftests/filesystems/Makefile | 1 + tools/testing/selftests/filesystems/devpts_pts.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) -- 2.11.0 Acked-by: Christian Brauner diff --git a/tools/testing/selftests/filesystems/Makefile b/tools/testing/selftests/filesystems/Makefile index 4e6d09fb166f..427a401aae5c 100644 --- a/tools/testing/selftests/filesystems/Makefile +++ b/tools/testing/selftests/filesystems/Makefile @@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 TEST_PROGS := dnotify_test devpts_pts +CFLAGS += -I../../../../usr/include/ all: $(TEST_PROGS) include ../lib.mk diff --git a/tools/testing/selftests/filesystems/devpts_pts.c b/tools/testing/selftests/filesystems/devpts_pts.c index b9055e974289..79420b9d00c7 100644 --- a/tools/testing/selftests/filesystems/devpts_pts.c +++ b/tools/testing/selftests/filesystems/devpts_pts.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include