From patchwork Fri Jul 10 11:58:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 11656303 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1337B13B4 for ; Fri, 10 Jul 2020 11:58:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EE4F62078D for ; Fri, 10 Jul 2020 11:58:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="J7ik3vDK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726912AbgGJL6M (ORCPT ); Fri, 10 Jul 2020 07:58:12 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:55431 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726757AbgGJL6L (ORCPT ); Fri, 10 Jul 2020 07:58:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594382290; 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=WrAUzsslcQ6587N6bpxNIRSuTpr2lTJ8ANwKcgAAxbY=; b=J7ik3vDKDwRTf5NEXx3+aFI3lcGl7YDCjrLLsJ6Lu55k0Xu07MLhFn5g+z3Aw8xzNc5sF6 OL8djkXWdTrvFNDMjbKnsW0J/uw0Hf2YZjmC7h0Q0lbHB31ZfxlMqLk6DENE6OqaFZg0+j kpgjKG4aL4GHWLaZS8rkyvCgOLEOTOw= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-11-7UFkL8X4OFC7qMuk69y4Fw-1; Fri, 10 Jul 2020 07:58:09 -0400 X-MC-Unique: 7UFkL8X4OFC7qMuk69y4Fw-1 Received: by mail-ed1-f71.google.com with SMTP id c25so6693839edr.5 for ; Fri, 10 Jul 2020 04:58:09 -0700 (PDT) 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:mime-version :content-transfer-encoding; bh=WrAUzsslcQ6587N6bpxNIRSuTpr2lTJ8ANwKcgAAxbY=; b=j15oIOR4wTtIj5ztaL0teIR0bNPd1TSX24kR32qpzOyVr4wVHZAH7KyIBa721MVUVS 5DpTy0RswIKF8kjTSVjOBKcRT+r0lG7l8UebUAf2vZth53wx1dwG0JTz+qOjZpuiYukr j2rVlUPPn0LKG/xuqss6klpFvtTf7U50CVHaifL5mxgGOsM253ibe0JJWGL5f21s1FN8 kOTdhhxsYTPkWq1hjwobKVTScX+uF+VLQFmOjmQgttUeqWr5dqMGXMrrpDzck9+uiyf9 u+reQqzeQUXlPacpCT69Sk1fYxflEzQHxk+OSQ8NYDCs2XUjZhg7iBr6IQ1p3eVQLXeg 8sOw== X-Gm-Message-State: AOAM532TgKCSNIh4UqKi9WVDnsk5cN1JxLUU2HtiqWi17DmcMLY6FS6i mfbt9pwaJZIw+HzSsux60Tm/gpmisxDWzRtrKuQ+RlyJ6zv/RknXgFn9pWVn+JS5BDCu7axuq3D qJUAAI6FhDYfadBYOrC6Rps5qEw== X-Received: by 2002:a17:906:69d3:: with SMTP id g19mr41788068ejs.402.1594382287934; Fri, 10 Jul 2020 04:58:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDuJCnhjKq7P41NLwcaIkbXSfBf3rS02RRzO4bSzyOQBnJMkwuSDs+EhrikFKVkS77vA9vUg== X-Received: by 2002:a17:906:69d3:: with SMTP id g19mr41788051ejs.402.1594382287748; Fri, 10 Jul 2020 04:58:07 -0700 (PDT) Received: from miu.piliscsaba.redhat.com (catv-212-96-48-140.catv.broadband.hu. [212.96.48.140]) by smtp.gmail.com with ESMTPSA id a8sm3536951ejp.51.2020.07.10.04.58.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2020 04:58:07 -0700 (PDT) From: Miklos Szeredi To: linux-fsdevel@vger.kernel.org Cc: Stefan Priebe , David Howells , stable@vger.kernel.org Subject: [PATCH 1/3] fuse: use ->reconfigure() instead of ->remount_fs() Date: Fri, 10 Jul 2020 13:58:03 +0200 Message-Id: <20200710115805.4478-1-mszeredi@redhat.com> X-Mailer: git-send-email 2.21.1 MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org s_op->remount_fs() is only called from legacy_reconfigure(), which is not used after being converted to the new API. Convert to using ->reconfigure(). This restores the previous behavior of syncing the filesystem and rejecting MS_MANDLOCK on remount. Fixes: c30da2e981a7 ("fuse: convert to use the new mount API") Cc: # v5.4 Signed-off-by: Miklos Szeredi --- fs/fuse/inode.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 5b4aebf5821f..be39dff57c28 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -121,10 +121,12 @@ static void fuse_evict_inode(struct inode *inode) } } -static int fuse_remount_fs(struct super_block *sb, int *flags, char *data) +static int fuse_reconfigure(struct fs_context *fc) { + struct super_block *sb = fc->root->d_sb; + sync_filesystem(sb); - if (*flags & SB_MANDLOCK) + if (fc->sb_flags & SB_MANDLOCK) return -EINVAL; return 0; @@ -817,7 +819,6 @@ static const struct super_operations fuse_super_operations = { .evict_inode = fuse_evict_inode, .write_inode = fuse_write_inode, .drop_inode = generic_delete_inode, - .remount_fs = fuse_remount_fs, .put_super = fuse_put_super, .umount_begin = fuse_umount_begin, .statfs = fuse_statfs, @@ -1296,6 +1297,7 @@ static int fuse_get_tree(struct fs_context *fc) static const struct fs_context_operations fuse_context_ops = { .free = fuse_free_fc, .parse_param = fuse_parse_param, + .reconfigure = fuse_reconfigure, .get_tree = fuse_get_tree, }; From patchwork Fri Jul 10 11:58:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 11656305 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1484313B6 for ; Fri, 10 Jul 2020 11:58:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF254207DF for ; Fri, 10 Jul 2020 11:58:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZiVc9Lrj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727066AbgGJL6O (ORCPT ); Fri, 10 Jul 2020 07:58:14 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:21140 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726757AbgGJL6N (ORCPT ); Fri, 10 Jul 2020 07:58:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594382291; 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: in-reply-to:in-reply-to:references:references; bh=nAOXmVWgoczSuOlfXxBAYA4BAGAkdUAmIONdRmDi7fU=; b=ZiVc9Lrjg7ReYJcQPsFmHve71fuCzEsGs+B3MvNkD9omQ2lO0VIr+Boelfg8aHuMjNzbb9 xAz+Zh33nauJlK2oQabo0JaHi+sOlOyfO52rjSVjiY0ypTOeYA4pr4r0Gssw1xHL90Lcqt RlJhasf4oxeySbebPOLfBINEnidhVis= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-381-8nB1mRDiO8yRCwWowf70Fw-1; Fri, 10 Jul 2020 07:58:10 -0400 X-MC-Unique: 8nB1mRDiO8yRCwWowf70Fw-1 Received: by mail-ej1-f72.google.com with SMTP id a26so6178667ejr.7 for ; Fri, 10 Jul 2020 04:58:10 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=nAOXmVWgoczSuOlfXxBAYA4BAGAkdUAmIONdRmDi7fU=; b=aPrAl563/dpGaUh6dIloBpPl/DhvUw+ySzEvSACPSlGxz4r/GdkJnu1b3DceqNkohq x/XyCV2h97+cr70giDxyAL3PPWTVqI/jxZgzEflNX4daXwMo1dViqlvAct+M26uZKyNb ZZeznoW9c2JIH8ZVAt+rbXgCO7KSMJiN4LhuI81qZ9harOGQExRg6gfe39qxm9nYv+4b gvGUvs3EnUCZ3ELj9NZ7JfU9NeYkeroNPp4fy1BTe8GavoXdSjeqDGewWn53nF1FoHcq m7ErMi/NcIdHEvGjFdmf/Czr4EybqzNXxfsYM3sCmLXMdYgvicScLGx2BmwJImZaTAX3 gzGg== X-Gm-Message-State: AOAM530NSgsf1MI8cvoGQed9iyKTnLoRUCNfinCeRZPGU0lgwoOyMdIZ ldWhhj8yrmqjs4rLo+Ttc4MbxnbMngqbiGaaaqwmO2Zu62+pCZHVle23T7rRpFyRSWo84covjl2 wwyOLSsbYdM+mkcA8qi1fm7ZibQ== X-Received: by 2002:a17:906:cd2:: with SMTP id l18mr63295734ejh.18.1594382288908; Fri, 10 Jul 2020 04:58:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTEnQRlfNnkfPFFldvYN1w1+dgGHdWpPHvYgpL+8iT4dpCcLKqV3BiLsKe2MEEqovgVDMfZQ== X-Received: by 2002:a17:906:cd2:: with SMTP id l18mr63295724ejh.18.1594382288749; Fri, 10 Jul 2020 04:58:08 -0700 (PDT) Received: from miu.piliscsaba.redhat.com (catv-212-96-48-140.catv.broadband.hu. [212.96.48.140]) by smtp.gmail.com with ESMTPSA id a8sm3536951ejp.51.2020.07.10.04.58.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2020 04:58:08 -0700 (PDT) From: Miklos Szeredi To: linux-fsdevel@vger.kernel.org Cc: Stefan Priebe , David Howells , stable@vger.kernel.org Subject: [PATCH 2/3] fuse: ignore 'data' argument of mount(..., MS_REMOUNT) Date: Fri, 10 Jul 2020 13:58:04 +0200 Message-Id: <20200710115805.4478-2-mszeredi@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200710115805.4478-1-mszeredi@redhat.com> References: <20200710115805.4478-1-mszeredi@redhat.com> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org The command mount -o remount -o unknownoption /mnt/fuse succeeds on kernel versions prior to v5.4 and fails on kernel version at or after. This is because fuse_parse_param() rejects any unrecognised options in case of FS_CONTEXT_FOR_RECONFIGURE, just as for FS_CONTEXT_FOR_MOUNT. This causes a regression in case the fuse filesystem is in fstab, since remount sends all options found there to the kernel; even ones that are meant for the initial mount and are consumed by the userspace fuse server. Fix this by ignoring mount options, just as fuse_remount_fs() did prior to the conversion to the new API. Reported-by: Stefan Priebe Fixes: c30da2e981a7 ("fuse: convert to use the new mount API") Cc: # v5.4 Signed-off-by: Miklos Szeredi --- fs/fuse/inode.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index be39dff57c28..ba201bf5ffad 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -477,6 +477,13 @@ static int fuse_parse_param(struct fs_context *fc, struct fs_parameter *param) struct fuse_fs_context *ctx = fc->fs_private; int opt; + /* + * Ignore options coming from mount(MS_REMOUNT) for backward + * compatibility. + */ + if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE) + return 0; + opt = fs_parse(fc, fuse_fs_parameters, param, &result); if (opt < 0) return opt; From patchwork Fri Jul 10 11:58:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 11656307 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A0CB92A for ; Fri, 10 Jul 2020 11:58:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 00D0D2078D for ; Fri, 10 Jul 2020 11:58:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iDMx2h81" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727033AbgGJL6R (ORCPT ); Fri, 10 Jul 2020 07:58:17 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:32589 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726840AbgGJL6O (ORCPT ); Fri, 10 Jul 2020 07:58:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594382293; 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: in-reply-to:in-reply-to:references:references; bh=peCjidKRwR+RBlxI7zYOYscaYD5oe5qhntPw14M0mLg=; b=iDMx2h81Y24Uxlqc+RmOcpegGMQF488fI6wyUVTg+l8/HRBLA1p8PA3DEwFLBN+TjeOCP/ tFbdTGYqnJtnJmQ5iZfiNpIOchhYQutXFUZpN3reFKutEB05q3eNsNT7cxVZdeWbvOstl8 ej8fij4NJpEhQrHdeKw9lwt3WoiA8qE= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-26-vM4nzDw_Pq-D9tQzAUrvcw-1; Fri, 10 Jul 2020 07:58:11 -0400 X-MC-Unique: vM4nzDw_Pq-D9tQzAUrvcw-1 Received: by mail-ej1-f70.google.com with SMTP id q11so6214408eja.3 for ; Fri, 10 Jul 2020 04:58:11 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=peCjidKRwR+RBlxI7zYOYscaYD5oe5qhntPw14M0mLg=; b=V/NiafQJwrRVugSSKK/0GXAZMyvnMRCKZwfgDVPznWOO/6KIrYsARuWbp8/6UeE03B Sr1QZ3j3tFqqLdHJMFXf1ASaXzajGy6qRWgdSLB8WBHwYoCfPnfIcRh/2vg01kmUXXt0 mnWBKl1JyzW9jr7VA9Pn/irJQNE8lvHFgXh35oqcICaSHkH7USzLeGFzAv5VT7uU6ps4 ls0XtTIVFxNYX3a9d0c92FLKBXtRLNnTNPcWx/+5VXarMyN4F57TCGqG8IT6DzMm0QxZ 2mjmKPIhdWdtxQMb/2oqhU/WvmdQsBXpy716JWO2wv5CN1Rb2rjf20KJxmNf93xxUQr3 dwTQ== X-Gm-Message-State: AOAM533XbT3C9BexAzbVfEd480fY5PvVqH+3bUM2w6GC14HDae80tjvc rdVCUKPcXAjiWrghVYCl6DWxrsSBNE09MxegLa1IAgqTotoBCtULy0LJaEdRPC6hGURA0DaKXpu 9LV9Sw5IMcsZk4WRwkWHMrMP8qg== X-Received: by 2002:a50:d6dd:: with SMTP id l29mr77839834edj.345.1594382290242; Fri, 10 Jul 2020 04:58:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQ1J1yGVzGiuAdROXz1nlPHbiIBzF9V3HelXSpltKIzf0uZeSzcg1mia0QOdMf27khar+V2g== X-Received: by 2002:a50:d6dd:: with SMTP id l29mr77839817edj.345.1594382290050; Fri, 10 Jul 2020 04:58:10 -0700 (PDT) Received: from miu.piliscsaba.redhat.com (catv-212-96-48-140.catv.broadband.hu. [212.96.48.140]) by smtp.gmail.com with ESMTPSA id a8sm3536951ejp.51.2020.07.10.04.58.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2020 04:58:09 -0700 (PDT) From: Miklos Szeredi To: linux-fsdevel@vger.kernel.org Cc: Stefan Priebe , David Howells Subject: [PATCH 3/3] fuse: reject options on reconfigure via fsconfig(2) Date: Fri, 10 Jul 2020 13:58:05 +0200 Message-Id: <20200710115805.4478-3-mszeredi@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200710115805.4478-1-mszeredi@redhat.com> References: <20200710115805.4478-1-mszeredi@redhat.com> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Previous patch changed handling of remount/reconfigure to ignore all options, including those that are unknown to the fuse kernel fs. This was done for backward compatibility, but this likely only affects the old mount(2) API. The new fsconfig(2) based reconfiguration could possibly be improved. This would make the new API less of a drop in replacement for the old, OTOH this is a good chance to get rid of some weirdnesses in the old API. Several other behaviors might make sense: 1) unknown options are rejected, known options are ignored 2) unknown options are rejected, known options are rejected if the value is changed, allowed otherwise 3) all options are rejected Prior to the backward compatibility fix to ignore all options all known options were accepted (1), even if they change the value of a mount parameter; fuse_reconfigure() does not look at the config values set by fuse_parse_param(). To fix that we'd need to verify that the value provided is the same as set in the initial configuration (2). The major drawback is that this is much more complex than just rejecting all attempts at changing options (3); i.e. all options signify initial configuration values and don't make sense on reconfigure. This patch opts for (3) with the rationale that no mount options are reconfigurable in fuse. Signed-off-by: Miklos Szeredi --- fs/fuse/inode.c | 16 ++++++++++------ fs/namespace.c | 1 + include/linux/fs_context.h | 1 + 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index ba201bf5ffad..bba747520e9b 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -477,12 +477,16 @@ static int fuse_parse_param(struct fs_context *fc, struct fs_parameter *param) struct fuse_fs_context *ctx = fc->fs_private; int opt; - /* - * Ignore options coming from mount(MS_REMOUNT) for backward - * compatibility. - */ - if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE) - return 0; + if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE) { + /* + * Ignore options coming from mount(MS_REMOUNT) for backward + * compatibility. + */ + if (fc->oldapi) + return 0; + + return invalfc(fc, "No changes allowed in reconfigure"); + } opt = fs_parse(fc, fuse_fs_parameters, param, &result); if (opt < 0) diff --git a/fs/namespace.c b/fs/namespace.c index f30ed401cc6d..4a0f600a3328 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2603,6 +2603,7 @@ static int do_remount(struct path *path, int ms_flags, int sb_flags, if (IS_ERR(fc)) return PTR_ERR(fc); + fc->oldapi = true; err = parse_monolithic_mount_data(fc, data); if (!err) { down_write(&sb->s_umount); diff --git a/include/linux/fs_context.h b/include/linux/fs_context.h index 5f24fcbfbfb4..37e1e8f7f08d 100644 --- a/include/linux/fs_context.h +++ b/include/linux/fs_context.h @@ -109,6 +109,7 @@ struct fs_context { enum fs_context_phase phase:8; /* The phase the context is in */ bool need_free:1; /* Need to call ops->free() */ bool global:1; /* Goes into &init_user_ns */ + bool oldapi:1; /* Coming from mount(2) */ }; struct fs_context_operations {