CC: [email protected] CC: [email protected] TO: Trond Myklebust <[email protected]> CC: Chuck Lever <[email protected]>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: a0d54b4f5b219fb31f0776e9f53aa137e78ae431 commit: 2e19d10c1438241de32467637a2a411971547991 nfsd: Fix up nfsd to ensure that timeout errors don't result in ESTALE date: 5 weeks ago :::::: branch date: 4 hours ago :::::: commit date: 5 weeks ago config: x86_64-randconfig-m001-20210111 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> smatch warnings: fs/nfsd/nfsfh.c:277 nfsd_set_fh_dentry() warn: passing zero to 'PTR_ERR' vim +/PTR_ERR +277 fs/nfsd/nfsfh.c 03a816b46d7eba Steve Dickson 2009-09-09 147 ^1da177e4c3f41 Linus Torvalds 2005-04-16 148 /* 03550fac06c4f0 J. Bruce Fields 2008-03-14 149 * Use the given filehandle to look up the corresponding export and 03550fac06c4f0 J. Bruce Fields 2008-03-14 150 * dentry. On success, the results are used to set fh_export and 03550fac06c4f0 J. Bruce Fields 2008-03-14 151 * fh_dentry. ^1da177e4c3f41 Linus Torvalds 2005-04-16 152 */ 03550fac06c4f0 J. Bruce Fields 2008-03-14 153 static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp) ^1da177e4c3f41 Linus Torvalds 2005-04-16 154 { ^1da177e4c3f41 Linus Torvalds 2005-04-16 155 struct knfsd_fh *fh = &fhp->fh_handle; 6e91ea2bb0b6a3 Christoph Hellwig 2007-10-21 156 struct fid *fid = NULL, sfid; 03550fac06c4f0 J. Bruce Fields 2008-03-14 157 struct svc_export *exp; 03550fac06c4f0 J. Bruce Fields 2008-03-14 158 struct dentry *dentry; ^1da177e4c3f41 Linus Torvalds 2005-04-16 159 int fileid_type; ^1da177e4c3f41 Linus Torvalds 2005-04-16 160 int data_left = fh->fh_size/4; 03550fac06c4f0 J. Bruce Fields 2008-03-14 161 __be32 error; ^1da177e4c3f41 Linus Torvalds 2005-04-16 162 ^1da177e4c3f41 Linus Torvalds 2005-04-16 163 error = nfserr_stale; ^1da177e4c3f41 Linus Torvalds 2005-04-16 164 if (rqstp->rq_vers > 2) ^1da177e4c3f41 Linus Torvalds 2005-04-16 165 error = nfserr_badhandle; ^1da177e4c3f41 Linus Torvalds 2005-04-16 166 if (rqstp->rq_vers == 4 && fh->fh_size == 0) ^1da177e4c3f41 Linus Torvalds 2005-04-16 167 return nfserr_nofilehandle; ^1da177e4c3f41 Linus Torvalds 2005-04-16 168 ^1da177e4c3f41 Linus Torvalds 2005-04-16 169 if (fh->fh_version == 1) { ^1da177e4c3f41 Linus Torvalds 2005-04-16 170 int len; 03550fac06c4f0 J. Bruce Fields 2008-03-14 171 03550fac06c4f0 J. Bruce Fields 2008-03-14 172 if (--data_left < 0) 03550fac06c4f0 J. Bruce Fields 2008-03-14 173 return error; 03550fac06c4f0 J. Bruce Fields 2008-03-14 174 if (fh->fh_auth_type != 0) 03550fac06c4f0 J. Bruce Fields 2008-03-14 175 return error; ^1da177e4c3f41 Linus Torvalds 2005-04-16 176 len = key_len(fh->fh_fsid_type) / 4; 03550fac06c4f0 J. Bruce Fields 2008-03-14 177 if (len == 0) 03550fac06c4f0 J. Bruce Fields 2008-03-14 178 return error; af6a4e280e3ff4 NeilBrown 2007-02-14 179 if (fh->fh_fsid_type == FSID_MAJOR_MINOR) { ^1da177e4c3f41 Linus Torvalds 2005-04-16 180 /* deprecated, convert to type 3 */ af6a4e280e3ff4 NeilBrown 2007-02-14 181 len = key_len(FSID_ENCODE_DEV)/4; af6a4e280e3ff4 NeilBrown 2007-02-14 182 fh->fh_fsid_type = FSID_ENCODE_DEV; 94ec938b612eb8 Jeff Layton 2014-06-17 183 /* 94ec938b612eb8 Jeff Layton 2014-06-17 184 * struct knfsd_fh uses host-endian fields, which are 94ec938b612eb8 Jeff Layton 2014-06-17 185 * sometimes used to hold net-endian values. This 94ec938b612eb8 Jeff Layton 2014-06-17 186 * confuses sparse, so we must use __force here to 94ec938b612eb8 Jeff Layton 2014-06-17 187 * keep it from complaining. 94ec938b612eb8 Jeff Layton 2014-06-17 188 */ 94ec938b612eb8 Jeff Layton 2014-06-17 189 fh->fh_fsid[0] = new_encode_dev(MKDEV(ntohl((__force __be32)fh->fh_fsid[0]), 94ec938b612eb8 Jeff Layton 2014-06-17 190 ntohl((__force __be32)fh->fh_fsid[1]))); ^1da177e4c3f41 Linus Torvalds 2005-04-16 191 fh->fh_fsid[1] = fh->fh_fsid[2]; ^1da177e4c3f41 Linus Torvalds 2005-04-16 192 } 03550fac06c4f0 J. Bruce Fields 2008-03-14 193 data_left -= len; 03550fac06c4f0 J. Bruce Fields 2008-03-14 194 if (data_left < 0) 03550fac06c4f0 J. Bruce Fields 2008-03-14 195 return error; 5409e46f1bcf96 Christoph Hellwig 2014-05-07 196 exp = rqst_exp_find(rqstp, fh->fh_fsid_type, fh->fh_fsid); 5409e46f1bcf96 Christoph Hellwig 2014-05-07 197 fid = (struct fid *)(fh->fh_fsid + len); ^1da177e4c3f41 Linus Torvalds 2005-04-16 198 } else { 6e91ea2bb0b6a3 Christoph Hellwig 2007-10-21 199 __u32 tfh[2]; ^1da177e4c3f41 Linus Torvalds 2005-04-16 200 dev_t xdev; ^1da177e4c3f41 Linus Torvalds 2005-04-16 201 ino_t xino; 03550fac06c4f0 J. Bruce Fields 2008-03-14 202 ^1da177e4c3f41 Linus Torvalds 2005-04-16 203 if (fh->fh_size != NFS_FHSIZE) 03550fac06c4f0 J. Bruce Fields 2008-03-14 204 return error; ^1da177e4c3f41 Linus Torvalds 2005-04-16 205 /* assume old filehandle format */ ^1da177e4c3f41 Linus Torvalds 2005-04-16 206 xdev = old_decode_dev(fh->ofh_xdev); ^1da177e4c3f41 Linus Torvalds 2005-04-16 207 xino = u32_to_ino_t(fh->ofh_xino); af6a4e280e3ff4 NeilBrown 2007-02-14 208 mk_fsid(FSID_DEV, tfh, xdev, xino, 0, NULL); 0989a788969583 J. Bruce Fields 2007-07-17 209 exp = rqst_exp_find(rqstp, FSID_DEV, tfh); ^1da177e4c3f41 Linus Torvalds 2005-04-16 210 } ^1da177e4c3f41 Linus Torvalds 2005-04-16 211 2d3bb25209c1f9 J. Bruce Fields 2007-07-17 212 error = nfserr_stale; f01274a9335307 Trond Myklebust 2020-03-01 213 if (IS_ERR(exp)) { f01274a9335307 Trond Myklebust 2020-03-01 214 trace_nfsd_set_fh_dentry_badexport(rqstp, fhp, PTR_ERR(exp)); f01274a9335307 Trond Myklebust 2020-03-01 215 2d3bb25209c1f9 J. Bruce Fields 2007-07-17 216 if (PTR_ERR(exp) == -ENOENT) 03550fac06c4f0 J. Bruce Fields 2008-03-14 217 return error; ^1da177e4c3f41 Linus Torvalds 2005-04-16 218 03550fac06c4f0 J. Bruce Fields 2008-03-14 219 return nfserrno(PTR_ERR(exp)); f01274a9335307 Trond Myklebust 2020-03-01 220 } ^1da177e4c3f41 Linus Torvalds 2005-04-16 221 496d6c32d4d057 Neil Brown 2008-05-08 222 if (exp->ex_flags & NFSEXP_NOSUBTREECHECK) { 496d6c32d4d057 Neil Brown 2008-05-08 223 /* Elevate privileges so that the lack of 'r' or 'x' 496d6c32d4d057 Neil Brown 2008-05-08 224 * permission on some parent directory will 496d6c32d4d057 Neil Brown 2008-05-08 225 * not stop exportfs_decode_fh from being able 496d6c32d4d057 Neil Brown 2008-05-08 226 * to reconnect a directory into the dentry cache. 496d6c32d4d057 Neil Brown 2008-05-08 227 * The same problem can affect "SUBTREECHECK" exports, 496d6c32d4d057 Neil Brown 2008-05-08 228 * but as nfsd_acceptable depends on correct 496d6c32d4d057 Neil Brown 2008-05-08 229 * access control settings being in effect, we cannot 496d6c32d4d057 Neil Brown 2008-05-08 230 * fix that case easily. 496d6c32d4d057 Neil Brown 2008-05-08 231 */ d84f4f992cbd76 David Howells 2008-11-14 232 struct cred *new = prepare_creds(); 027bc41a3eb475 Kinglong Mee 2014-09-02 233 if (!new) { 027bc41a3eb475 Kinglong Mee 2014-09-02 234 error = nfserrno(-ENOMEM); 027bc41a3eb475 Kinglong Mee 2014-09-02 235 goto out; 027bc41a3eb475 Kinglong Mee 2014-09-02 236 } d84f4f992cbd76 David Howells 2008-11-14 237 new->cap_effective = d84f4f992cbd76 David Howells 2008-11-14 238 cap_raise_nfsd_set(new->cap_effective, d84f4f992cbd76 David Howells 2008-11-14 239 new->cap_permitted); d84f4f992cbd76 David Howells 2008-11-14 240 put_cred(override_creds(new)); d84f4f992cbd76 David Howells 2008-11-14 241 put_cred(new); 496d6c32d4d057 Neil Brown 2008-05-08 242 } else { 6fa02839bf9412 J. Bruce Fields 2007-11-12 243 error = nfsd_setuser_and_check_port(rqstp, exp); d1bbf14f37261c NeilBrown 2006-07-30 244 if (error) d1bbf14f37261c NeilBrown 2006-07-30 245 goto out; 496d6c32d4d057 Neil Brown 2008-05-08 246 } d1bbf14f37261c NeilBrown 2006-07-30 247 ^1da177e4c3f41 Linus Torvalds 2005-04-16 248 /* ^1da177e4c3f41 Linus Torvalds 2005-04-16 249 * Look up the dentry using the NFS file handle. ^1da177e4c3f41 Linus Torvalds 2005-04-16 250 */ ^1da177e4c3f41 Linus Torvalds 2005-04-16 251 error = nfserr_stale; ^1da177e4c3f41 Linus Torvalds 2005-04-16 252 if (rqstp->rq_vers > 2) ^1da177e4c3f41 Linus Torvalds 2005-04-16 253 error = nfserr_badhandle; ^1da177e4c3f41 Linus Torvalds 2005-04-16 254 ^1da177e4c3f41 Linus Torvalds 2005-04-16 255 if (fh->fh_version != 1) { 6e91ea2bb0b6a3 Christoph Hellwig 2007-10-21 256 sfid.i32.ino = fh->ofh_ino; 6e91ea2bb0b6a3 Christoph Hellwig 2007-10-21 257 sfid.i32.gen = fh->ofh_generation; 6e91ea2bb0b6a3 Christoph Hellwig 2007-10-21 258 sfid.i32.parent_ino = fh->ofh_dirino; 6e91ea2bb0b6a3 Christoph Hellwig 2007-10-21 259 fid = &sfid; ^1da177e4c3f41 Linus Torvalds 2005-04-16 260 data_left = 3; ^1da177e4c3f41 Linus Torvalds 2005-04-16 261 if (fh->ofh_dirino == 0) 6e91ea2bb0b6a3 Christoph Hellwig 2007-10-21 262 fileid_type = FILEID_INO32_GEN; ^1da177e4c3f41 Linus Torvalds 2005-04-16 263 else 6e91ea2bb0b6a3 Christoph Hellwig 2007-10-21 264 fileid_type = FILEID_INO32_GEN_PARENT; ^1da177e4c3f41 Linus Torvalds 2005-04-16 265 } else ^1da177e4c3f41 Linus Torvalds 2005-04-16 266 fileid_type = fh->fh_fileid_type; ^1da177e4c3f41 Linus Torvalds 2005-04-16 267 6e91ea2bb0b6a3 Christoph Hellwig 2007-10-21 268 if (fileid_type == FILEID_ROOT) 54775491614804 Jan Blunck 2008-02-14 269 dentry = dget(exp->ex_path.dentry); ^1da177e4c3f41 Linus Torvalds 2005-04-16 270 else { 2e19d10c143824 Trond Myklebust 2020-11-30 271 dentry = exportfs_decode_fh_raw(exp->ex_path.mnt, fid, d37065cd6d6bbe Christoph Hellwig 2007-07-17 272 data_left, fileid_type, ^1da177e4c3f41 Linus Torvalds 2005-04-16 273 nfsd_acceptable, exp); 2e19d10c143824 Trond Myklebust 2020-11-30 274 if (IS_ERR_OR_NULL(dentry)) { f01274a9335307 Trond Myklebust 2020-03-01 275 trace_nfsd_set_fh_dentry_badhandle(rqstp, fhp, f01274a9335307 Trond Myklebust 2020-03-01 276 dentry ? PTR_ERR(dentry) : -ESTALE); 2e19d10c143824 Trond Myklebust 2020-11-30 @277 switch (PTR_ERR(dentry)) { 2e19d10c143824 Trond Myklebust 2020-11-30 278 case -ENOMEM: 2e19d10c143824 Trond Myklebust 2020-11-30 279 case -ETIMEDOUT: 2e19d10c143824 Trond Myklebust 2020-11-30 280 break; 2e19d10c143824 Trond Myklebust 2020-11-30 281 default: 2e19d10c143824 Trond Myklebust 2020-11-30 282 dentry = ERR_PTR(-ESTALE); 2e19d10c143824 Trond Myklebust 2020-11-30 283 } 2e19d10c143824 Trond Myklebust 2020-11-30 284 } ^1da177e4c3f41 Linus Torvalds 2005-04-16 285 } ^1da177e4c3f41 Linus Torvalds 2005-04-16 286 if (dentry == NULL) ^1da177e4c3f41 Linus Torvalds 2005-04-16 287 goto out; ^1da177e4c3f41 Linus Torvalds 2005-04-16 288 if (IS_ERR(dentry)) { ^1da177e4c3f41 Linus Torvalds 2005-04-16 289 if (PTR_ERR(dentry) != -EINVAL) ^1da177e4c3f41 Linus Torvalds 2005-04-16 290 error = nfserrno(PTR_ERR(dentry)); ^1da177e4c3f41 Linus Torvalds 2005-04-16 291 goto out; ^1da177e4c3f41 Linus Torvalds 2005-04-16 292 } 34e9a63b4f3e16 NeilBrown 2007-01-29 293 e36cb0b89ce20b David Howells 2015-01-29 294 if (d_is_dir(dentry) && ^1da177e4c3f41 Linus Torvalds 2005-04-16 295 (dentry->d_flags & DCACHE_DISCONNECTED)) { 97e47fa11deae1 Al Viro 2013-09-16 296 printk("nfsd: find_fh_dentry returned a DISCONNECTED directory: %pd2\n", 97e47fa11deae1 Al Viro 2013-09-16 297 dentry); ^1da177e4c3f41 Linus Torvalds 2005-04-16 298 } ^1da177e4c3f41 Linus Torvalds 2005-04-16 299 ^1da177e4c3f41 Linus Torvalds 2005-04-16 300 fhp->fh_dentry = dentry; ^1da177e4c3f41 Linus Torvalds 2005-04-16 301 fhp->fh_export = exp; daab110e47f8d7 Jeff Layton 2020-11-30 302 daab110e47f8d7 Jeff Layton 2020-11-30 303 switch (rqstp->rq_vers) { daab110e47f8d7 Jeff Layton 2020-11-30 304 case 3: daab110e47f8d7 Jeff Layton 2020-11-30 305 if (dentry->d_sb->s_export_op->flags & EXPORT_OP_NOWCC) daab110e47f8d7 Jeff Layton 2020-11-30 306 fhp->fh_no_wcc = true; daab110e47f8d7 Jeff Layton 2020-11-30 307 break; daab110e47f8d7 Jeff Layton 2020-11-30 308 case 2: daab110e47f8d7 Jeff Layton 2020-11-30 309 fhp->fh_no_wcc = true; daab110e47f8d7 Jeff Layton 2020-11-30 310 } daab110e47f8d7 Jeff Layton 2020-11-30 311 03550fac06c4f0 J. Bruce Fields 2008-03-14 312 return 0; 03550fac06c4f0 J. Bruce Fields 2008-03-14 313 out: 03550fac06c4f0 J. Bruce Fields 2008-03-14 314 exp_put(exp); 03550fac06c4f0 J. Bruce Fields 2008-03-14 315 return error; 03550fac06c4f0 J. Bruce Fields 2008-03-14 316 } 03550fac06c4f0 J. Bruce Fields 2008-03-14 317 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/[email protected]
.config.gz
Description: application/gzip
_______________________________________________ kbuild mailing list -- [email protected] To unsubscribe send an email to [email protected]
