Return-Path: linux-nfs-owner@vger.kernel.org Received: from mx12.netapp.com ([216.240.18.77]:56913 "EHLO mx12.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752553Ab3C0QR1 (ORCPT ); Wed, 27 Mar 2013 12:17:27 -0400 From: "Myklebust, Trond" To: fanchaoting CC: "bfields@fieldses.org" , "linux-nfs@vger.kernel.org" Subject: Re: [PATCH] nfs: nfs client decode fslocations oops if server cheating it Date: Wed, 27 Mar 2013 16:17:25 +0000 Message-ID: <1364401044.11071.21.camel@leira.trondhjem.org> References: <51502DB7.1010508@cn.fujitsu.com> In-Reply-To: <51502DB7.1010508@cn.fujitsu.com> Content-Type: multipart/mixed; boundary="_002_13644010441107121camelleiratrondhjemorg_" MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org List-ID: --_002_13644010441107121camelleiratrondhjemorg_ Content-Type: text/plain; charset="iso-8859-1" Content-ID: <6DE9D3508E0B9944A1E1AE9BEDB4995A@tahoe.netapp.com> Content-Transfer-Encoding: quoted-printable On Mon, 2013-03-25 at 18:57 +0800, fanchaoting wrote: > now nfs server will return wrong nlocations,nservers, ncomponents to the = client. These limits are imposed by the client. The server knows nothing about them as they are not part of the NFSv4 spec. > for example if the nlocations is NFS4_FS_LOCATIONS_MAXENTRIES, the nfs cl= ient > will decode oops when run "struct nfs4_fs_location *loc =3D &res->locatio= ns[res->nlocations]" Your patch means that instead of making a best effort attempt to decode what the server sends us, we end up decoding nothing at all and just reporting an error. How about something like the following instead? --=20 Trond Myklebust Linux NFS client maintainer NetApp Trond.Myklebust@netapp.com www.netapp.com --_002_13644010441107121camelleiratrondhjemorg_ Content-Type: text/x-patch; name="0001-NFSv4-Fix-Oopses-in-the-fs_locations-code.patch" Content-Description: 0001-NFSv4-Fix-Oopses-in-the-fs_locations-code.patch Content-Disposition: attachment; filename="0001-NFSv4-Fix-Oopses-in-the-fs_locations-code.patch"; size=3995; creation-date="Wed, 27 Mar 2013 16:17:24 GMT";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