Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1249803ybl; Thu, 12 Dec 2019 12:02:43 -0800 (PST) X-Google-Smtp-Source: APXvYqze2k8YcZbfLdjErqi0IltJBusI0Fy0J8yjEPSuq1pnDi4WlnjvoE0m1g4yMI7P66pIrskM X-Received: by 2002:aca:b9d6:: with SMTP id j205mr6216128oif.77.1576180963234; Thu, 12 Dec 2019 12:02:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576180963; cv=none; d=google.com; s=arc-20160816; b=gXzj3uCjKjQXzDRiQv1ZE0U9iF1PzU9Y9tbFaInEkp9i97uGaLs7ko665E8n08GBUK ifFCSGDvWL7puSst12PudGt+VKKIg6q0j9LHx6+zNzXPOFGk2wpGB+XoT2o9UXyUmY3B vlw06uEoji10fGQKFgnEFsxnx78kWyF3V0pEbxhEt6uVc+FosSck/rfl8VaBKr3SPRN9 6RjNT9z0PCcZrRL5H1wFhC0z/Pbnw9V3Ow0Mhr6hzz1C/AfWp1e07kUNOUtPMG0+axe5 lUrdNGzmxtrD4200IJgxAdQ8H7/KkxCGZhnTp+4H+mn6CklppjOkCSEISUDOpXXihGaB Vvqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=hb8TmGk+a9HjoYdlVzo58zXnc/ROW/PTOkZPr16nz2Q=; b=lNUe0gzIMwZvYXm/Rru214wkxqcZRtvPWzacsEuIMAIJS+oBdN3eGMK3gilWp12BJQ 2ms/1ycIdeAVkEm63yd11BGBHODIj3gs6RcKv5S0JR/qeNeHxN1Zzlk09TYniWrILqyf gCwlxVnryElgTWTxJwKLUGSZQOs2uGKU37dglzi9RuN1InVRzn7AByJeFpHA/RB4OgVP ZwEGVus5tW/cCuBk81bxOvtXib08NKu3aRjzccM8mRiT8D4k+khZH+511L/g3B2TPkN2 IlXLtMgC1MECKtH55g/UsqDPRpuvk++Sk+Gq4tPiKPjL6AWfw16CI8sH1PqVFY7/CA2S RroQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IaavmPRt; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v145si3721297oia.68.2019.12.12.12.02.30; Thu, 12 Dec 2019 12:02:43 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=IaavmPRt; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730772AbfLLUCD (ORCPT + 99 others); Thu, 12 Dec 2019 15:02:03 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:27770 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730707AbfLLUCC (ORCPT ); Thu, 12 Dec 2019 15:02:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576180920; 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: in-reply-to:in-reply-to:references:references; bh=hb8TmGk+a9HjoYdlVzo58zXnc/ROW/PTOkZPr16nz2Q=; b=IaavmPRt9zNg8iW4gvdsBXazkxV31bY8w4kWt4F8RAwDzahv/MaMYNybAzUihp+S709/7c CjKnS3e3gjvK8D0shsT7V4wS+DuUcR7JLja4AQD7koqgR6S8wG4fhPU0+unFyCs9L/9idh vLl8HfASEWU6rZ42Hhuml+T1x+JHR2s= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-188-Hfa1qo57NrWC3nFJUYHJHQ-1; Thu, 12 Dec 2019 15:01:59 -0500 X-MC-Unique: Hfa1qo57NrWC3nFJUYHJHQ-1 Received: by mail-qt1-f200.google.com with SMTP id v25so203432qtq.3 for ; Thu, 12 Dec 2019 12:01:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=hb8TmGk+a9HjoYdlVzo58zXnc/ROW/PTOkZPr16nz2Q=; b=AK+MV39VRbfEo+RlNsqwe1dLzi4R1dHcWVFSSMG75JygXLVysILXAZBYK9sHJY4ffA DURZP1+7l6Vno41LJ4i3tvNiPeBBt2oqumeFjl5MV/fEPRtXz0h6HI790VlyRgIPQO4i I0ylin4pVDrJ2ThD4LbgaEK70Ewmndb3HIUcd6+D4kpEoGMWQp8WpqSOg7eVHVyi5ItD HHbXJ11as5XrSAUH1k7iHVczZWbE4qKCnKkENLYC0ckunfIOBIfKB9qzmRQC8VZ1n4/z oB99Nl85nEPiyCJUhFfAn4thhGUabLNRPCKuHHz3LRgG8UFN6NaWOTwdo6ijWftSfmFM ykpw== X-Gm-Message-State: APjAAAWG1O5hPobNYo0FMA/auPAcvFbf+gikGoPIETYjBR7xsqQdZ5BB izAQsWkTDQw0ydlp4RbtQZd4Ef8K40qHVlyBqoSiYkOOEfbIPgdsOXVJcWWM7hYvmE2V8Myp5Og sZlokMelzVWKtuA2B37yQZP0O X-Received: by 2002:a37:65c8:: with SMTP id z191mr10018893qkb.176.1576180918868; Thu, 12 Dec 2019 12:01:58 -0800 (PST) X-Received: by 2002:a37:65c8:: with SMTP id z191mr10018819qkb.176.1576180918172; Thu, 12 Dec 2019 12:01:58 -0800 (PST) Received: from [192.168.1.157] (pool-96-235-39-235.pitbpa.fios.verizon.net. [96.235.39.235]) by smtp.gmail.com with ESMTPSA id f19sm2075294qkk.69.2019.12.12.12.01.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 Dec 2019 12:01:57 -0800 (PST) Subject: Re: [PATCH] vfs: Don't reject unknown parameters To: Linus Torvalds Cc: Ilya Dryomov , Al Viro , David Howells , Jeremi Piotrowski , Linux FS Devel , Phillip Lougher , LKML References: <20191212145042.12694-1-labbott@redhat.com> From: Laura Abbott Message-ID: Date: Thu, 12 Dec 2019 15:01:56 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/12/19 12:56 PM, Linus Torvalds wrote: > On Thu, Dec 12, 2019 at 9:47 AM Laura Abbott wrote: >> >> Good point, I think I missed how that code flow worked for printing >> out the error. I debated putting in a dummy parse_param but I >> figured that squashfs wouldn't be the only fs that didn't take >> arguments (it's in the minority but certainly not the only one). > > I think printing out the error part is actually fine - it would act as > a warning for invalid parameters like this. > > So I think a dummy parse_param that prints out a warning is likely the > right thing to do. > > Something like the attached, perhaps? Totally untested. > > Linus > That doesn't quite work. We can't just unconditionally return success because we rely on -ENOPARAM being returned to parse the source option back in vfs_parse_fs_param. I think ramfs may also be broken for the same reason right now as well from reading the code. We also rely on the fallback source parsing for file systems that do have ->parse_param. We could do all this in squashfs but given other file systems that don't have args will also hit this we could just make it generic. The following works for me (under commenting and poor name choices notwithstanding) diff --git a/fs/fs_parser.c b/fs/fs_parser.c index d1930adce68d..5e45e36d51e7 100644 --- a/fs/fs_parser.c +++ b/fs/fs_parser.c @@ -302,6 +302,50 @@ int fs_lookup_param(struct fs_context *fc, } EXPORT_SYMBOL(fs_lookup_param); +enum { + NO_OPT_SOURCE, +}; + +static const struct fs_parameter_spec no_opt_fs_param_specs[] = { + fsparam_string ("source", NO_OPT_SOURCE), + {} +}; + +const struct fs_parameter_description no_opt_fs_parameters = { + .name = "no_opt_fs", + .specs = no_opt_fs_param_specs, +}; + +int fs_no_opt_parse_param(struct fs_context *fc, struct fs_parameter *param) +{ + struct fs_parse_result result; + int opt; + + opt = fs_parse(fc, &no_opt_fs_parameters, param, &result); + if (opt < 0) { + /* Just log an error for backwards compatibility */ + errorf(fc, "%s: Unknown parameter '%s'", + fc->fs_type->name, param->key); + return 0; + } + + switch (opt) { + case NO_OPT_SOURCE: + if (param->type != fs_value_is_string) + return invalf(fc, "%s: Non-string source", + fc->fs_type->name); + if (fc->source) + return invalf(fc, "%s: Multiple sources specified", + fc->fs_type->name); + fc->source = param->string; + param->string = NULL; + break; + } + + return 0; +} +EXPORT_SYMBOL(fs_no_opt_parse_param); + #ifdef CONFIG_VALIDATE_FS_PARSER /** * validate_constant_table - Validate a constant table diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c index 0cc4ceec0562..07a9b38f7bf5 100644 --- a/fs/squashfs/super.c +++ b/fs/squashfs/super.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -358,6 +359,7 @@ static int squashfs_reconfigure(struct fs_context *fc) static const struct fs_context_operations squashfs_context_ops = { .get_tree = squashfs_get_tree, .reconfigure = squashfs_reconfigure, + .parse_param = fs_no_opt_parse_param, }; static int squashfs_init_fs_context(struct fs_context *fc) diff --git a/include/linux/fs_parser.h b/include/linux/fs_parser.h index dee140db6240..f67b2afcc491 100644 --- a/include/linux/fs_parser.h +++ b/include/linux/fs_parser.h @@ -106,6 +106,8 @@ static inline bool fs_validate_description(const struct fs_parameter_description { return true; } #endif +extern int fs_no_opt_parse_param(struct fs_context *fc, struct fs_parameter *param); + /* * Parameter type, name, index and flags element constructors. Use as: *