From patchwork Wed Oct 25 14:01:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 13436212 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 1F27028E01 for ; Wed, 25 Oct 2023 14:02:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ida6CPj0" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3478184 for ; Wed, 25 Oct 2023 07:02:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698242531; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=x1DYN7Za1uyLzcDLrfQjEDekO6UImwLBhsScIzlPerc=; b=ida6CPj06NiVQ4YlzG1C6SpEje8t/0LYfNy5xNVXOPIWgpxDXMZhteX3CD/Tp4EowHZoU+ L9nylfAoPFJseMx+ixJ/k/uNhwat+7OM2g8HodeganaIj8aQGCsivHU60btdQAogN+q1+4 hOXh7lwvBmTNHYpEPB0xfgu3A3SbckU= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-92-u5Dku-75Njmy8WjTo1N7Mw-1; Wed, 25 Oct 2023 10:02:10 -0400 X-MC-Unique: u5Dku-75Njmy8WjTo1N7Mw-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-9c797b497e8so308363766b.0 for ; Wed, 25 Oct 2023 07:02:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698242528; x=1698847328; 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=x1DYN7Za1uyLzcDLrfQjEDekO6UImwLBhsScIzlPerc=; b=F+vyEa1x5rTpGMV45fcriAqgs29ZLqhxoXOFY/oupWxSv3Rfs1yiO+G4/VSP4/n/Sx IrbGZ1BZOKRgseFf6BiRQayVCHMu/sBPAorYddMLN+nc3Pj+sv2HdThTh/tZ7ydrpv2Y QLIurTueeUWPJcllqktw2/pYD16HMNLTmlAjyvfJcti3HPXYJ52ZSt8nD/u9NiICHlH0 xM6D3gT7iw2LDo3uTPcnfcDMze9Pv0SkIB29+2nD11zG4oub3g8SeFsk4/6KQlNh5OGA 8yb0hLIq6IDQu+NFsjd2p/tWgvTdzrsV+Sl0Xo4sBx9vLfx4F4jBMu23TbRh+83CEdzX i81Q== X-Gm-Message-State: AOJu0YxqD1OLXRTcXUBN/YKAsXX9GRUr36rL3swjIykaVMhjuSvxENGv PT0wk+2yJjgt4m2HissLlQx1EDjj4BdwKiKnan47TqmlNYFPl60flKi9F8Cm5XV8ZD/MR0CszYx O8uu6lLFB61sbEwExwxM+nLH+R9ChykiifOtBNF2CfLU8K3y+eZKrIkspCrnwPoPXMeSfLPIaNt eg9VM4nGZq5Q== X-Received: by 2002:a17:906:c115:b0:9be:839a:3372 with SMTP id do21-20020a170906c11500b009be839a3372mr11884371ejc.59.1698242527958; Wed, 25 Oct 2023 07:02:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEWrkTOkCAZfzN3xYcXcvz5ivnltGcFS7nQ3UQVnKVXqNdwubssOqdk3o6zzAPGNGJ5035rSA== X-Received: by 2002:a17:906:c115:b0:9be:839a:3372 with SMTP id do21-20020a170906c11500b009be839a3372mr11884320ejc.59.1698242527362; Wed, 25 Oct 2023 07:02:07 -0700 (PDT) Received: from maszat.piliscsaba.szeredi.hu (92-249-235-200.pool.digikabel.hu. [92.249.235.200]) by smtp.gmail.com with ESMTPSA id vl9-20020a170907b60900b00989828a42e8sm9857073ejc.154.2023.10.25.07.02.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 07:02:06 -0700 (PDT) From: Miklos Szeredi To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-man@vger.kernel.org, linux-security-module@vger.kernel.org, Karel Zak , Ian Kent , David Howells , Linus Torvalds , Al Viro , Christian Brauner , Amir Goldstein , Matthew House , Florian Weimer , Arnd Bergmann Subject: [PATCH v4 0/6] querying mount attributes Date: Wed, 25 Oct 2023 16:01:58 +0200 Message-ID: <20231025140205.3586473-1-mszeredi@redhat.com> X-Mailer: git-send-email 2.41.0 Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Implement mount querying syscalls agreed on at LSF/MM 2023. Features: - statx-like want/got mask - allows returning ascii strings (fs type, root, mount point) - returned buffer is relocatable (no pointers) Still missing: - man pages - kselftest Please find the test utility at the end of this mail. Usage: statmnt [-l|-r] [-u] (mnt_id|path) Git tree: git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs.git#statmount-v4 Changes v3..v4: - incorporate patch moving list of mounts to an rbtree - wire up syscalls for all archs - add LISTMOUNT_RECURSIVE (depth first iteration of mount tree) - add LSMT_ROOT (list root instead of a specific mount ID) - list_for_each_entry_del() moved to a separate patchset Changes v1..v3: - rename statmnt(2) -> statmount(2) - rename listmnt(2) -> listmount(2) - make ABI 32bit compatible by passing 64bit args in a struct (tested on i386 and x32) - only accept new 64bit mount IDs - fix compile on !CONFIG_PROC_FS - call security_sb_statfs() in both syscalls - make lookup_mnt_in_ns() static - add LISTMOUNT_UNREACHABLE flag to listmnt() to explicitly ask for listing unreachable mounts - remove .sb_opts - remove subtype from .fs_type - return the number of bytes used (including strings) in .size - rename .mountpoint -> .mnt_point - point strings by an offset against char[] VLA at the end of the struct. E.g. printf("fs_type: %s\n", st->str + st->fs_type); - don't save string lengths - extend spare space in struct statmnt (complete size is now 512 bytes) Miklos Szeredi (6): add unique mount ID mounts: keep list of mounts in an rbtree namespace: extract show_path() helper add statmount(2) syscall add listmount(2) syscall wire up syscalls for statmount/listmount arch/alpha/kernel/syscalls/syscall.tbl | 3 + arch/arm/tools/syscall.tbl | 3 + arch/arm64/include/asm/unistd32.h | 4 + arch/ia64/kernel/syscalls/syscall.tbl | 3 + arch/m68k/kernel/syscalls/syscall.tbl | 3 + arch/microblaze/kernel/syscalls/syscall.tbl | 3 + arch/mips/kernel/syscalls/syscall_n32.tbl | 3 + arch/mips/kernel/syscalls/syscall_n64.tbl | 3 + arch/mips/kernel/syscalls/syscall_o32.tbl | 3 + arch/parisc/kernel/syscalls/syscall.tbl | 3 + arch/powerpc/kernel/syscalls/syscall.tbl | 3 + arch/s390/kernel/syscalls/syscall.tbl | 3 + arch/sh/kernel/syscalls/syscall.tbl | 3 + arch/sparc/kernel/syscalls/syscall.tbl | 3 + arch/x86/entry/syscalls/syscall_32.tbl | 3 + arch/x86/entry/syscalls/syscall_64.tbl | 2 + arch/xtensa/kernel/syscalls/syscall.tbl | 3 + fs/internal.h | 2 + fs/mount.h | 27 +- fs/namespace.c | 573 ++++++++++++++++---- fs/pnode.c | 2 +- fs/proc_namespace.c | 13 +- fs/stat.c | 9 +- include/linux/mount.h | 5 +- include/linux/syscalls.h | 8 + include/uapi/asm-generic/unistd.h | 8 +- include/uapi/linux/mount.h | 65 +++ include/uapi/linux/stat.h | 1 + 28 files changed, 635 insertions(+), 129 deletions(-) Reviewed-by: Ian Kent