From patchwork Fri Nov 16 23:12:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Rees X-Patchwork-Id: 1757541 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 224DD3FCDE for ; Fri, 16 Nov 2012 23:12:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753641Ab2KPXMM (ORCPT ); Fri, 16 Nov 2012 18:12:12 -0500 Received: from mout.perfora.net ([74.208.4.195]:64180 "EHLO mout.perfora.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753626Ab2KPXML (ORCPT ); Fri, 16 Nov 2012 18:12:11 -0500 Received: from rees.org (74-126-0-171.static.123.net [74.126.0.171]) by mrelay.perfora.net (node=mrus2) with ESMTP (Nemesis) id 0MUYX5-1Thzel1Q03-00RCun; Fri, 16 Nov 2012 18:12:10 -0500 From: Jim Rees To: Trond Myklebust Cc: linux-nfs@vger.kernel.org Subject: [PATCH v2] NFS: Reduce stack use in encode_exchange_id() Date: Fri, 16 Nov 2012 18:12:06 -0500 Message-Id: <1353107526-25460-1-git-send-email-rees@umich.edu> X-Mailer: git-send-email 1.7.9.5 X-Provags-ID: V02:K0:UmFIRwDduvcj/KhhqxpArkz2+pvS1vvhRFWljDZb7au HccYTPK4jsNFCXhEm9Xa+3lfJZOUmWpP9O7yImKr9sOFau00mf 4dMtvTMK58/uPfwXAPLcGCwbMYJPmTlsEeAdxaLC9Jn1+fnbTt DBugXCPYMJxG9Rd45a+2A8GgpP2322QidMn2o+ASYS3DneUCWy CU3wAZV7JQ4ipLe/26fjWU4wx8Zu+JWDXfnjF0RRBxi7WpplRh 1PbTaH7v1xKIXbRluwjJRJbxN7qnDFgm08tIlI5RWc9trXSBYg ZjhGIQZemCG1eBLl4V2vjzTC3jU5RFgcsdwCkQyhy8BA9U7CMg Fyt4S/wmpEBt1Ieodw6GWHWXoKJG72mclCVTMUKnR Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org encode_exchange_id() uses more stack space than necessary, giving a compile time warning. Reduce the size of the static buffer for implementation name. Signed-off-by: Jim Rees Reviewed-by: "Adamson, Dros" --- fs/nfs/nfs4xdr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 672d9b0..cc2f8a9 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -270,6 +270,8 @@ static int nfs4_stat_to_errno(int); #if defined(CONFIG_NFS_V4_1) #define NFS4_MAX_MACHINE_NAME_LEN (64) +#define IMPL_NAME_LIMIT (sizeof(utsname()->sysname) + sizeof(utsname()->release) + \ + sizeof(utsname()->version) + sizeof(utsname()->machine) + 8) #define encode_exchange_id_maxsz (op_encode_hdr_maxsz + \ encode_verifier_maxsz + \ @@ -282,7 +284,7 @@ static int nfs4_stat_to_errno(int); 1 /* nii_domain */ + \ XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ 1 /* nii_name */ + \ - XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ + XDR_QUADLEN(IMPL_NAME_LIMIT) + \ 3 /* nii_date */) #define decode_exchange_id_maxsz (op_decode_hdr_maxsz + \ 2 /* eir_clientid */ + \ @@ -1711,7 +1713,7 @@ static void encode_exchange_id(struct xdr_stream *xdr, struct compound_hdr *hdr) { __be32 *p; - char impl_name[NFS4_OPAQUE_LIMIT]; + char impl_name[IMPL_NAME_LIMIT]; int len = 0; encode_op_hdr(xdr, OP_EXCHANGE_ID, decode_exchange_id_maxsz, hdr); @@ -1726,7 +1728,7 @@ static void encode_exchange_id(struct xdr_stream *xdr, if (send_implementation_id && sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) > 1 && sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) - <= NFS4_OPAQUE_LIMIT + 1) + <= sizeof(impl_name) + 1) len = snprintf(impl_name, sizeof(impl_name), "%s %s %s %s", utsname()->sysname, utsname()->release, utsname()->version, utsname()->machine);