From patchwork Thu Sep 28 13:01:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 13402969 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 88C6AE732C8 for ; Thu, 28 Sep 2023 13:02:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232420AbjI1NCo (ORCPT ); Thu, 28 Sep 2023 09:02:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232582AbjI1NCn (ORCPT ); Thu, 28 Sep 2023 09:02:43 -0400 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 003501A2 for ; Thu, 28 Sep 2023 06:01:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695906115; 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=SAsGsjUp2akFOXe3NzL6P0KjpNsT5cDYxfpTwl+LFa4=; b=XQVJQhVohpfhQ5fI/iDUKOAmbrMY5HcK9rtCinfOJ6YX33lDERels137CZ35fKVjurIALN 2F4m4PWMRotks6TdNreldwPaQRj2WpjlypEHiSWGlnZjNIv2nS9Pdi+6DlX+tB2cfZM//w Vg0bZPj2toGOCHGThqECy7/sIH4nqow= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-114-hBWdQdNEPsyh2L20HTTogg-1; Thu, 28 Sep 2023 09:01:53 -0400 X-MC-Unique: hBWdQdNEPsyh2L20HTTogg-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-9ae686dafedso1100619066b.3 for ; Thu, 28 Sep 2023 06:01:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695906111; x=1696510911; 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=SAsGsjUp2akFOXe3NzL6P0KjpNsT5cDYxfpTwl+LFa4=; b=EiMgQpbiiopGwv7ohmsNNp8t/PjmxP1x4A/VN8jT8rczBU/XHyq9+W4FDdKBXkC4dr tRbMrLY8HQkqTBbg6WJZhVMQjWZHssR9iutNpgKJ7ivlkP2sC7i1DU10i4DwLlbRg1wT Z1DFZ9TlAUPHUoqQd9l7NgDC89PDjcLpZbipq0cI9e9EBD705xryCKE74vt68SZPBNjQ g+obDeBSVb05SwxPTEslRSbo9VZtPZ27I+AMfxjnWS2qbBkhK4+da11Hmd86HHsO+Is/ tcElx4MJtD85bZpirz6HYBrU4JkSmwIydeDRv30UQv2T1Adx6dQkMQEtToihVlySYUco 096g== X-Gm-Message-State: AOJu0YyQ+JBmqXyCGySrSwrJVPg6Trxdz7AO8VMBcE0kHEpgskmAcS9i HDv8KI/41rStX7FKuhNUuvvSvuP0GER23SWJ4W8fyI0YUMANMYskLeHfuPLnoS5lKyuQuz0KAwp FYHG9QLUlaUSE2QSZAM4zUTatMHc25d0Qe5zIXUpWBPAQnbzm/FGVSbsyZBdPs1/qTDhJtDr1rd 5JMuJ5I0ZiFw== X-Received: by 2002:a17:906:4d2:b0:9a2:1e03:1572 with SMTP id g18-20020a17090604d200b009a21e031572mr1101954eja.19.1695906110863; Thu, 28 Sep 2023 06:01:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFbkaqxJ9P/J0/LxrJDvMMLHi+yyUi9xLnBaJSvjWu4NDQEasTuE+Qb7BbbAr66wxOa1CBnPA== X-Received: by 2002:a17:906:4d2:b0:9a2:1e03:1572 with SMTP id g18-20020a17090604d200b009a21e031572mr1101898eja.19.1695906110228; Thu, 28 Sep 2023 06:01:50 -0700 (PDT) Received: from maszat.piliscsaba.szeredi.hu (94-21-53-31.pool.digikabel.hu. [94.21.53.31]) by smtp.gmail.com with ESMTPSA id v6-20020a170906380600b0099c53c4407dsm10784863ejc.78.2023.09.28.06.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 06:01:49 -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 v3 0/4] querying mount attributes Date: Thu, 28 Sep 2023 15:01:42 +0200 Message-ID: <20230928130147.564503-1-mszeredi@redhat.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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 - syscalls on non-x86 archs Please find the test utility at the end of this mail. Usage: statmnt [-l] (mnt_id|path) Git tree: git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs.git#statmount-v3 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 (4): add unique mount ID namespace: extract show_path() helper add statmount(2) syscall add listmount(2) syscall arch/x86/entry/syscalls/syscall_32.tbl | 2 + arch/x86/entry/syscalls/syscall_64.tbl | 2 + fs/internal.h | 2 + fs/mount.h | 3 +- fs/namespace.c | 365 +++++++++++++++++++++++++ fs/proc_namespace.c | 10 +- fs/stat.c | 9 +- fs/statfs.c | 1 + include/linux/syscalls.h | 8 + include/uapi/asm-generic/unistd.h | 8 +- include/uapi/linux/mount.h | 59 ++++ include/uapi/linux/stat.h | 1 + 12 files changed, 459 insertions(+), 11 deletions(-)