Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

NFSv4: Handle NFS4ERR_WRONGSEC outside of nfs4_handle_exception()

I only want to try other secflavors during an initial mount if
NFS4ERR_WRONGSEC is returned. nfs4_handle_exception() could
potentially map other errors to EPERM, so we should handle this
error specially for correctness.

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>

authored by

Bryan Schumaker and committed by
Trond Myklebust
fb8a5ba8 468f8613

+23 -5
+23 -5
fs/nfs/nfs4proc.c
··· 2186 2186 struct nfs4_exception exception = { }; 2187 2187 int err; 2188 2188 do { 2189 - err = nfs4_handle_exception(server, 2190 - _nfs4_lookup_root(server, fhandle, info), 2191 - &exception); 2189 + err = _nfs4_lookup_root(server, fhandle, info); 2190 + switch (err) { 2191 + case 0: 2192 + case -NFS4ERR_WRONGSEC: 2193 + break; 2194 + default: 2195 + err = nfs4_handle_exception(server, err, &exception); 2196 + } 2192 2197 } while (exception.retry); 2193 2198 return err; 2194 2199 } ··· 2226 2221 2227 2222 for (i = 0; i < len; i++) { 2228 2223 status = nfs4_lookup_root_sec(server, fhandle, info, flav_array[i]); 2229 - if (status == -EPERM || status == -EACCES) 2224 + if (status == -NFS4ERR_WRONGSEC || status == -EACCES) 2230 2225 continue; 2231 2226 break; 2232 2227 } 2228 + /* 2229 + * -EACCESS could mean that the user doesn't have correct permissions 2230 + * to access the mount. It could also mean that we tried to mount 2231 + * with a gss auth flavor, but rpc.gssd isn't running. Either way, 2232 + * existing mount programs don't handle -EACCES very well so it should 2233 + * be mapped to -EPERM instead. 2234 + */ 2235 + if (status == -EACCES) 2236 + status = -EPERM; 2233 2237 return status; 2234 2238 } 2235 2239 ··· 2249 2235 struct nfs_fsinfo *info) 2250 2236 { 2251 2237 int status = nfs4_lookup_root(server, fhandle, info); 2252 - if ((status == -EPERM) && !(server->flags & NFS_MOUNT_SECFLAVOUR)) 2238 + if ((status == -NFS4ERR_WRONGSEC) && !(server->flags & NFS_MOUNT_SECFLAVOUR)) 2239 + /* 2240 + * A status of -NFS4ERR_WRONGSEC will be mapped to -EPERM 2241 + * by nfs4_map_errors() as this function exits. 2242 + */ 2253 2243 status = nfs4_find_root_sec(server, fhandle, info); 2254 2244 if (status == 0) 2255 2245 status = nfs4_server_capabilities(server, fhandle);