From patchwork Wed Sep 4 02:24:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 1157417 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; 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.b="FkeQvs7K"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46NSMd15r0z9sDB for ; Wed, 4 Sep 2019 12:25:01 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727065AbfIDCZA (ORCPT ); Tue, 3 Sep 2019 22:25:00 -0400 Received: from mail-io1-f52.google.com ([209.85.166.52]:39247 "EHLO mail-io1-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726770AbfIDCZA (ORCPT ); Tue, 3 Sep 2019 22:25:00 -0400 Received: by mail-io1-f52.google.com with SMTP id d25so38195590iob.6 for ; Tue, 03 Sep 2019 19:24:59 -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=b9Oefijr97ob9N0SjnqspBlctoyErpMj+ykXifkNloY=; b=FkeQvs7KcaVc51+04eeuofL7499F1/wr3JIB7eZS+cvoo4U94YeqGsYrguYTg6QNcw QwfF/GQTj0hIYZZwVTy11m7E/V2HB99TdfcqxCXtdEB7vKFGYa0JccF3vLQvJG88q7Ew 1g8rXxGcb4nglxj86x8xnwmU1tOTEo2vAjQIBPQrhFmrBF+Xcixbu/IVSib2hSq/nf9i TIT6jCB56gi7W4FJay67Tm0ydUuD9rXWHU31qaq97m5dfRG5lZ8bn4t601Tjqx1gbQP/ KtkQRY7ITaYeGngwXJTdwEcq6UbnJ0Ma2pH6l7u6snZ3jg/u6z3oIF+4ubFA5JLoR7t5 rIrw== 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=b9Oefijr97ob9N0SjnqspBlctoyErpMj+ykXifkNloY=; b=FkbcKsSq/xD0puN4lEWqoKCtIpszrJ7Wk+SPppTlpDRe5fiMsCZI/ew+istYtlCIXj h5e0zhIlEqlW90T9dM/pzp0jxW2wwK2M/4fWA124p4HM8458eHARdzuTFgzGD38AxTjY a1TR+KhD5jCxS03NfUMmh9zV456uWeCF9h5Jdj9MwP337/3kOKJMlXG+YD7c2znYoZBE PzbT875yyD2q5agsqClel/F/qn0iiB07+KvheEqcfZpEQDrtIAk6IsEYX5tJ4xGRT/6A +iG2as7K5XQ4cp+KlvF964tg1QMBncC4EIbhAs5NSN5Ln1FXJcIbEPzb1LWzbtamY7gt tksA== X-Gm-Message-State: APjAAAV8O9oQq4SumnQ/eKGJ27fDsZMllL4p3UlD8zkdFWpDT3X1HTlK K1wHeBrnRC+ZJwl6u1T53RYTea6x0pNXr3oyZzwTPAqCZ4c= X-Google-Smtp-Source: APXvYqzUCmd/sl/b0IS9y7It6nY9Li3+OmD21RV72jJIVpaM7Sexh2xr770dZG1KDD2vaEPBqNVINnqK4ndY5KHenjQ= X-Received: by 2002:a02:7f49:: with SMTP id r70mr37272119jac.85.1567563898607; Tue, 03 Sep 2019 19:24:58 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Tue, 3 Sep 2019 21:24:47 -0500 Message-ID: Subject: [PATCH][SMB3] Allow skipping signing verification for perf sensitive use cases To: CIFS Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Add new mount option "signloosely" which enables signing but skips the sometimes expensive signing checks in the responses (signatures are calculated and sent correctly in the SMB2/SMB3 requests even with this mount option but skipped in the responses). Although weaker for security (and also data integrity in case a packet were corrupted), this can provide enough of a performance benefit (calculating the signature to verify a packet can be expensive especially for large packets) to be useful in some cases. From 2edfabcb6e31e3de543a066b3886f2db8d84ce47 Mon Sep 17 00:00:00 2001 From: Steve French Date: Tue, 3 Sep 2019 21:18:49 -0500 Subject: [PATCH] smb3: allow skipping signature verification for perf sensitive configurations Add new mount option "signloosely" which enables signing but skips the sometimes expensive signing checks in the responses (signatures are calculated and sent correctly in the SMB2/SMB3 requests even with this mount option but skipped in the responses). Although weaker for security (and also data integrity in case a packet were corrupted), this can provide enough of a performance benefit (calculating the signature to verify a packet can be expensive especially for large packets) to be useful in some cases. Signed-off-by: Steve French --- fs/cifs/cifsglob.h | 2 ++ fs/cifs/connect.c | 13 ++++++++++--- fs/cifs/smb2transport.c | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index fa5abe3a8514..ed31264feea3 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -542,6 +542,7 @@ struct smb_vol { umode_t dir_mode; enum securityEnum sectype; /* sectype requested via mnt opts */ bool sign; /* was signing requested via mnt opts? */ + bool ignore_signature; bool retry:1; bool intr:1; bool setuids:1; @@ -681,6 +682,7 @@ struct TCP_Server_Info { char server_GUID[16]; __u16 sec_mode; bool sign; /* is signing enabled on this connection? */ + bool ignore_signature; /* skip validation of signatures in SMB2/3 rsp */ bool session_estab; /* mark when very first sess is established */ int echo_credits; /* echo reserved slots */ int oplock_credits; /* oplock break reserved slots */ diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 85f8d943a05a..17882cede197 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -91,7 +91,7 @@ enum { Opt_serverino, Opt_noserverino, Opt_rwpidforward, Opt_cifsacl, Opt_nocifsacl, Opt_acl, Opt_noacl, Opt_locallease, - Opt_sign, Opt_seal, Opt_noac, + Opt_sign, Opt_ignore_signature, Opt_seal, Opt_noac, Opt_fsc, Opt_mfsymlinks, Opt_multiuser, Opt_sloppy, Opt_nosharesock, Opt_persistent, Opt_nopersistent, @@ -183,6 +183,7 @@ static const match_table_t cifs_mount_option_tokens = { { Opt_noacl, "noacl" }, { Opt_locallease, "locallease" }, { Opt_sign, "sign" }, + { Opt_ignore_signature, "signloosely" }, { Opt_seal, "seal" }, { Opt_noac, "noac" }, { Opt_fsc, "fsc" }, @@ -1877,6 +1878,10 @@ cifs_parse_mount_options(const char *mountdata, const char *devname, case Opt_sign: vol->sign = true; break; + case Opt_ignore_signature: + vol->sign = true; + vol->ignore_signature = true; + break; case Opt_seal: /* we do not do the following in secFlags because seal * is a per tree connection (mount) not a per socket @@ -2608,6 +2613,9 @@ static int match_server(struct TCP_Server_Info *server, struct smb_vol *vol) if (server->rdma != vol->rdma) return 0; + if (server->ignore_signature != vol->ignore_signature) + return 0; + return 1; } @@ -2785,7 +2793,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info) tcp_ses->tcpStatus = CifsNeedNegotiate; tcp_ses->nr_targets = 1; - + tcp_ses->ignore_signature = volume_info->ignore_signature; /* thread spawned, put it on the list */ spin_lock(&cifs_tcp_ses_lock); list_add(&tcp_ses->tcp_ses_list, &cifs_tcp_ses_list); @@ -3235,7 +3243,6 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info) ses->sectype = volume_info->sectype; ses->sign = volume_info->sign; - mutex_lock(&ses->session_mutex); rc = cifs_negotiate_protocol(xid, ses); if (!rc) diff --git a/fs/cifs/smb2transport.c b/fs/cifs/smb2transport.c index b02242eacb55..148d7942c796 100644 --- a/fs/cifs/smb2transport.c +++ b/fs/cifs/smb2transport.c @@ -522,6 +522,7 @@ smb2_verify_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) if ((shdr->Command == SMB2_NEGOTIATE) || (shdr->Command == SMB2_SESSION_SETUP) || (shdr->Command == SMB2_OPLOCK_BREAK) || + server->ignore_signature || (!server->session_estab)) return 0; -- 2.20.1