From patchwork Mon Aug 3 11:44:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 6928831 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8683A9F358 for ; Mon, 3 Aug 2015 11:45:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CF33A205CB for ; Mon, 3 Aug 2015 11:45:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 889AB20481 for ; Mon, 3 Aug 2015 11:45:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753344AbbHCLpD (ORCPT ); Mon, 3 Aug 2015 07:45:03 -0400 Received: from mail-yk0-f173.google.com ([209.85.160.173]:36277 "EHLO mail-yk0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752488AbbHCLpC (ORCPT ); Mon, 3 Aug 2015 07:45:02 -0400 Received: by ykeo23 with SMTP id o23so10837124yke.3 for ; Mon, 03 Aug 2015 04:45:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=IN0OYAHRdYsNQdvxuockhoTGs/bRVHZt8fBhcOpx9G0=; b=RKbblMKTHlwFbp2AFIjbZTkyjz3Jqqt9hwOjW50jKHljLAeXfiV0Swg+a07Kzdf2+h DXBU/xY/YSwMZKbdySqc7t0hToN1TYIXLvhAdEK5Fj+Q3yrPZtT30OVcr2MYm4VrMnRz uw7ADELvml457OhVCbDcYENYhqU2SmG2CItPPg93mzPOvCE4Z/G1sWqjomHIqTRwKkoV vqYxDGYhAYCHDyR74jBqbYP66eYbRjVh1j6CzLIPin5uFmm6yxbaRs+8MUmfzjqAe0KA 5SxdIQjduUXF81d5w/gaPXGEUkKBoYtM1d49QY2+3lcJhCzpF/9fIT1AWE2jGlMvsZjT 039Q== X-Gm-Message-State: ALoCoQmQ58qXKTafRimgKyu0+HxIEmq6QOSc5B5D84+65tpONo8zTLrL6Vd2tuBUGFwrQzJkU4lN X-Received: by 10.129.124.139 with SMTP id x133mr11070708ywc.44.1438602302060; Mon, 03 Aug 2015 04:45:02 -0700 (PDT) Received: from tlielax.poochiereds.net ([2606:a000:1105:8e:3a60:77ff:fe93:a95d]) by smtp.googlemail.com with ESMTPSA id l68sm13720199ywd.49.2015.08.03.04.45.00 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Aug 2015 04:45:00 -0700 (PDT) From: Jeff Layton X-Google-Original-From: Jeff Layton To: trond.myklebust@primarydata.com Cc: Anna Schumaker , "J. Bruce Fields" , linux-nfs@vger.kernel.org Subject: [PATCH] sunrpc: increase UNX_MAXNODENAME from 32 to __NEW_UTS_LEN bytes Date: Mon, 3 Aug 2015 07:44:53 -0400 Message-Id: <1438602293-11730-1-git-send-email-jeff.layton@primarydata.com> X-Mailer: git-send-email 2.4.3 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The current limit of 32 bytes artificially limits the name string that we end up stuffing into NFSv4.x client ID blobs. If you have multiple hosts with long hostnames that only differ near the end, then this can cause NFSv4 client ID collisions. Linux nodenames are actually limited to __NEW_UTS_LEN bytes (64), so use that as the limit instead. Also, use XDR_QUADLEN to specify the slack length, just for clarity and in case someone in the future changes this to something not evenly divisible by 4. Reported-by: Michael Skralivetsky Signed-off-by: Jeff Layton --- include/linux/sunrpc/auth.h | 8 ++++++-- net/sunrpc/auth_unix.c | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/linux/sunrpc/auth.h b/include/linux/sunrpc/auth.h index a7cbb570cc5c..1ecf13e148b8 100644 --- a/include/linux/sunrpc/auth.h +++ b/include/linux/sunrpc/auth.h @@ -18,9 +18,13 @@ #include #include #include +#include -/* size of the nodename buffer */ -#define UNX_MAXNODENAME 32 +/* + * Size of the nodename buffer. RFC1831 specifies a hard limit of 255 bytes, + * but Linux hostnames are actually limited to __NEW_UTS_LEN bytes. + */ +#define UNX_MAXNODENAME __NEW_UTS_LEN struct rpcsec_gss_info; diff --git a/net/sunrpc/auth_unix.c b/net/sunrpc/auth_unix.c index 4feda2d0a833..548240dd15fc 100644 --- a/net/sunrpc/auth_unix.c +++ b/net/sunrpc/auth_unix.c @@ -23,7 +23,7 @@ struct unx_cred { }; #define uc_uid uc_base.cr_uid -#define UNX_WRITESLACK (21 + (UNX_MAXNODENAME >> 2)) +#define UNX_WRITESLACK (21 + XDR_QUADLEN(UNX_MAXNODENAME)) #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) # define RPCDBG_FACILITY RPCDBG_AUTH