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: 13436297 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3B30C0032E for ; Wed, 25 Oct 2023 14:39:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344724AbjJYODw (ORCPT ); Wed, 25 Oct 2023 10:03:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344192AbjJYODu (ORCPT ); Wed, 25 Oct 2023 10:03:50 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE4C91B5 for ; Wed, 25 Oct 2023 07:02:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698242544; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=x1DYN7Za1uyLzcDLrfQjEDekO6UImwLBhsScIzlPerc=; b=Ra5AKbkX0G3jTlb4xhI0Xf2wjv9uRXNwfwnLg+vWVKqa6rOtWPej5mZUJuuc9/Gdbmoso/ vUDQHokCU5LUoRgE5oQAFbhPpRB5DIQxW7QWk+zKfX352L051VCNKUDsDXNKB7MGpruk/E C8x5GXz1YTkYnr/Vnz3Y8f8oJW93RNw= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-591-04eRyCJsMp25A9TQgbX-1w-1; Wed, 25 Oct 2023 10:02:09 -0400 X-MC-Unique: 04eRyCJsMp25A9TQgbX-1w-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-9b2cf504e3aso374347366b.2 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=XL2P8cLIEVI5xBUvMNsMSGtXQL1PBGoiwVIv7VQrKybKocsjUEAT8HEtxPbo8f9+C5 RZ+G9jyjMn5xX+iScMAaTVy2F7gEKl56bgf3z4k+Rc9eLhBSOkW75tMpEhZXZ6PZvjt0 1ZhTLpU6SxG/G/RuhqKrkg+n4xs6wM8sXE+ltH4itEEpBxl29x4vhwGnICQCkalrofw1 VAG6/+7VK4e69SFgTlmdiPIcNKSOLpztk+1MDEl6QB71EqSKzTq0L3ZNyp2D30BC3M5/ psVDgzRabep19Oq+e/xolrpzvfLktGI6Q5VPj0xmZKbQGKxOmTAMT5oSG/19U2rgl0f/ RUKQ== X-Gm-Message-State: AOJu0YxE18KmCATsS19TIU2toLG5HpVLJIXhyihwg0aC0TT+XaN+U5dF HIZ6CxorKq89ncqnhoIktDnFsInjkC/vI/GrDVOpAv9YMBabUdKrKINu++EJoSQfYsWsB3H9sXG AeacHw36nVCcsYXtpmDkXqCrRad1QP2uCAMqN X-Received: by 2002:a17:906:c115:b0:9be:839a:3372 with SMTP id do21-20020a170906c11500b009be839a3372mr11884367ejc.59.1698242527909; 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 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: bulk List-ID: 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