From patchwork Wed Oct 21 19:25:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 1385733 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=azv24Kqo; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4CGgSF2v4cz9sSW for ; Thu, 22 Oct 2020 06:25:17 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2441998AbgJUTZQ (ORCPT ); Wed, 21 Oct 2020 15:25:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2441904AbgJUTZQ (ORCPT ); Wed, 21 Oct 2020 15:25:16 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C63DFC0613CE for ; Wed, 21 Oct 2020 12:25:15 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id h6so4590380lfj.3 for ; Wed, 21 Oct 2020 12:25:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=YscgVhrgX1n+qv6NeSw/SX7usg/IlZJJRICvXejuPZY=; b=azv24Kqo/SNpLAe0MEO6IwfV/dm163ZWFKtCD497hd7Z5T8n/8OzJKJGHdxiq9FpCd IBem/ZB6lMdjyjchbXC0TZfC4fQUCM2fYJGqU7662FqJqbtB/cFAUJMXr3qwXmbErMXe zfwTv6MvAgRM/YOxa8b6uJAJJiJESowgTI9RAUXNEMQ95+fgWKb0IEyelURaBscGnmet IZcxlafXGtq0Ol6M1uRk5aMmCRW6SK8kI8ln4CX8NxEbdGUq8poYNwAe9wNswEyDvsdI mjt+6B8I0dMUXOB3q+nwSuWjW3NxJT959urRYi5I4phgmoYfXdV4HDaZBx1sxS9hq5YP 2RrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=YscgVhrgX1n+qv6NeSw/SX7usg/IlZJJRICvXejuPZY=; b=NzzZD4AZg0AwtA3qOzGrNzf2j97Rm1UdQkeCylIBTOxagsKkMzpttsAJXs2i1XjqEH CywBG2W40NMmuSeQ9J7jjL4cRfmi3/UK+WOjsiB+3RmgQ9h0VbvPqe73fs3rOq2b4ATN a46or0fa7DwYrYz300rKsStCVWHcaux/teGApMF0BuQU/hX/sFijlAjVSyXRlBqmAXE/ uypP/tZxfZ/3aifoR9TYEKyWb9G38wXpsXQunBkoi16aZehXaUQB8VwdRodLPOnPoNL4 qJR9PHkDp/W32SMLQp1ZpXkRb4rM9RJXvBrAe7zdYIinKFoR63BpzgUC7+oSzD4rSD/s 6soA== X-Gm-Message-State: AOAM532jjVefcR2xsA2+4CNIN5zFOEkCSDhzCwvjuN7uxSc2bXB5UkMm zZBKG14gMUkwjr7rUHBya950xOPIq8gLc+kZuuk= X-Google-Smtp-Source: ABdhPJz0gzMCNX9hsplR9juau2n7UUggziRpcAlz3DMxAvmaAPnsruqRX6CWjAmut4Pn6CCpqP7oN4MgqiWvS4wNQXE= X-Received: by 2002:a19:c68a:: with SMTP id w132mr1720385lff.106.1603308312201; Wed, 21 Oct 2020 12:25:12 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Wed, 21 Oct 2020 14:25:01 -0500 Message-ID: Subject: Updated cifs new mount API prep patches To: =?utf-8?q?Aur=C3=A9lien_Aptel?= , David Howells , CIFS , ronnie sahlberg Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org As Aurelien and others had mentioned, shrinking fs/cifs/connect.c by moving mount related functions (to fs_context.c and fs_context.h) helps make fs/cifs/connect.c more readable (see attached patch series) but also will make it easier to review the future patches to move cifs.ko to the new API. These are low risk and will make the mount code easier to maintain. These four don't change any existing function. Reviewed-by: Aurelien Aptel From ea963ab78ae4e6bed8100032220a275b8f09e22d Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Wed, 21 Oct 2020 10:37:11 +1000 Subject: [PATCH 2/4] cifs: move security mount options into fs_context.ch This patch moves the parsing of security mount options into fs_context.ch. There are no changes to any logic. Signed-off-by: Ronnie Sahlberg Signed-off-by: Steve French --- fs/cifs/connect.c | 85 +------------------------------------------- fs/cifs/fs_context.c | 76 +++++++++++++++++++++++++++++++++++++++ fs/cifs/fs_context.h | 20 ++++++++++- 3 files changed, 96 insertions(+), 85 deletions(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 3a9980bf0d6e..c2a92e26fef4 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -61,6 +61,7 @@ #ifdef CONFIG_CIFS_DFS_UPCALL #include "dfs_cache.h" #endif +#include "fs_context.h" extern mempool_t *cifs_req_poolp; extern bool disable_legacy_dialects; @@ -279,33 +280,6 @@ static const match_table_t cifs_mount_option_tokens = { { Opt_err, NULL } }; -enum { - Opt_sec_krb5, Opt_sec_krb5i, Opt_sec_krb5p, - Opt_sec_ntlmsspi, Opt_sec_ntlmssp, - Opt_ntlm, Opt_sec_ntlmi, Opt_sec_ntlmv2, - Opt_sec_ntlmv2i, Opt_sec_lanman, - Opt_sec_none, - - Opt_sec_err -}; - -static const match_table_t cifs_secflavor_tokens = { - { Opt_sec_krb5, "krb5" }, - { Opt_sec_krb5i, "krb5i" }, - { Opt_sec_krb5p, "krb5p" }, - { Opt_sec_ntlmsspi, "ntlmsspi" }, - { Opt_sec_ntlmssp, "ntlmssp" }, - { Opt_ntlm, "ntlm" }, - { Opt_sec_ntlmi, "ntlmi" }, - { Opt_sec_ntlmv2, "nontlm" }, - { Opt_sec_ntlmv2, "ntlmv2" }, - { Opt_sec_ntlmv2i, "ntlmv2i" }, - { Opt_sec_lanman, "lanman" }, - { Opt_sec_none, "none" }, - - { Opt_sec_err, NULL } -}; - /* cache flavors */ enum { Opt_cache_loose, @@ -1372,63 +1346,6 @@ static int get_option_gid(substring_t args[], kgid_t *result) return 0; } -static int cifs_parse_security_flavors(char *value, - struct smb_vol *vol) -{ - - substring_t args[MAX_OPT_ARGS]; - - /* - * With mount options, the last one should win. Reset any existing - * settings back to default. - */ - vol->sectype = Unspecified; - vol->sign = false; - - switch (match_token(value, cifs_secflavor_tokens, args)) { - case Opt_sec_krb5p: - cifs_dbg(VFS, "sec=krb5p is not supported!\n"); - return 1; - case Opt_sec_krb5i: - vol->sign = true; - fallthrough; - case Opt_sec_krb5: - vol->sectype = Kerberos; - break; - case Opt_sec_ntlmsspi: - vol->sign = true; - fallthrough; - case Opt_sec_ntlmssp: - vol->sectype = RawNTLMSSP; - break; - case Opt_sec_ntlmi: - vol->sign = true; - fallthrough; - case Opt_ntlm: - vol->sectype = NTLM; - break; - case Opt_sec_ntlmv2i: - vol->sign = true; - fallthrough; - case Opt_sec_ntlmv2: - vol->sectype = NTLMv2; - break; -#ifdef CONFIG_CIFS_WEAK_PW_HASH - case Opt_sec_lanman: - vol->sectype = LANMAN; - break; -#endif - case Opt_sec_none: - vol->nullauth = 1; - break; - default: - cifs_dbg(VFS, "bad security option: %s\n", value); - return 1; - } - - return 0; -} - static int cifs_parse_cache_flavor(char *value, struct smb_vol *vol) { diff --git a/fs/cifs/fs_context.c b/fs/cifs/fs_context.c index f50dfc2d2e44..dd9da734e346 100644 --- a/fs/cifs/fs_context.c +++ b/fs/cifs/fs_context.c @@ -6,3 +6,79 @@ * David Howells */ +#include "cifsglob.h" +#include "cifs_debug.h" +#include "fs_context.h" + +static const match_table_t cifs_secflavor_tokens = { + { Opt_sec_krb5, "krb5" }, + { Opt_sec_krb5i, "krb5i" }, + { Opt_sec_krb5p, "krb5p" }, + { Opt_sec_ntlmsspi, "ntlmsspi" }, + { Opt_sec_ntlmssp, "ntlmssp" }, + { Opt_ntlm, "ntlm" }, + { Opt_sec_ntlmi, "ntlmi" }, + { Opt_sec_ntlmv2, "nontlm" }, + { Opt_sec_ntlmv2, "ntlmv2" }, + { Opt_sec_ntlmv2i, "ntlmv2i" }, + { Opt_sec_lanman, "lanman" }, + { Opt_sec_none, "none" }, + + { Opt_sec_err, NULL } +}; + +int cifs_parse_security_flavors(char *value, struct smb_vol *vol) +{ + + substring_t args[MAX_OPT_ARGS]; + + /* + * With mount options, the last one should win. Reset any existing + * settings back to default. + */ + vol->sectype = Unspecified; + vol->sign = false; + + switch (match_token(value, cifs_secflavor_tokens, args)) { + case Opt_sec_krb5p: + cifs_dbg(VFS, "sec=krb5p is not supported!\n"); + return 1; + case Opt_sec_krb5i: + vol->sign = true; + fallthrough; + case Opt_sec_krb5: + vol->sectype = Kerberos; + break; + case Opt_sec_ntlmsspi: + vol->sign = true; + fallthrough; + case Opt_sec_ntlmssp: + vol->sectype = RawNTLMSSP; + break; + case Opt_sec_ntlmi: + vol->sign = true; + fallthrough; + case Opt_ntlm: + vol->sectype = NTLM; + break; + case Opt_sec_ntlmv2i: + vol->sign = true; + fallthrough; + case Opt_sec_ntlmv2: + vol->sectype = NTLMv2; + break; +#ifdef CONFIG_CIFS_WEAK_PW_HASH + case Opt_sec_lanman: + vol->sectype = LANMAN; + break; +#endif + case Opt_sec_none: + vol->nullauth = 1; + break; + default: + cifs_dbg(VFS, "bad security option: %s\n", value); + return 1; + } + + return 0; +} diff --git a/fs/cifs/fs_context.h b/fs/cifs/fs_context.h index 082f286f923e..87747ef7a2d3 100644 --- a/fs/cifs/fs_context.h +++ b/fs/cifs/fs_context.h @@ -9,7 +9,25 @@ #ifndef _FS_CONTEXT_H #define _FS_CONTEXT_H +#include +#include "cifsglob.h" +enum cifs_sec_param { + Opt_sec_krb5, + Opt_sec_krb5i, + Opt_sec_krb5p, + Opt_sec_ntlmsspi, + Opt_sec_ntlmssp, + Opt_ntlm, + Opt_sec_ntlmi, + Opt_sec_ntlmv2, + Opt_sec_ntlmv2i, + Opt_sec_lanman, + Opt_sec_none, -#endif + Opt_sec_err +}; + +int cifs_parse_security_flavors(char *value, struct smb_vol *vol); +#endif -- 2.25.1