Home | History | Annotate | Download | only in nfs
History log of /src/sys/nfs/nfsm_subs.h
RevisionDateAuthorComments
 1.59  07-Dec-2024  riastradh sys/nfs/nfs: Add some missing includes and include guards.

Fix up some minor KNF issues while here.

No functional change intended (except to enable things to build that
might not have built before because of previously required #include
ordering).
 1.58  05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.57  23-Mar-2023  riastradh nfs: Use unsigned name lengths so we don't trip over negative ones.

- nfsm_strsiz is only used with uint32_t in callers, but let's not
leave it as a rake to step on.

- nfsm_srvnamesiz is abused with signed s. The internal conversion
to unsigned serves to reject both negative and too-large values in
such callers.

XXX Should make all callers use unsigned, rather than flipping back
and forth between signed and unsigned for name lengths.

XXX pullup-8
XXX pullup-9
XXX pullup-10
 1.56  23-Mar-2023  riastradh nfs: Use unsigned fhlen so we don't trip over negative values.

XXX pullup-8
XXX pullup-9
XXX pullup-10
 1.55  12-Aug-2021  andvar branches: 1.55.4;
s/directry/directory/
 1.54  04-Apr-2020  mlelstv NFSv2 is limited to use only 32bit in metadata. Prevent that larger
metadata values are simply truncated.

-> clamp filesystem block counts to signed 32bit.
-> clamp file sizes to signed 32bit (*)

Some NFSv2 clients also have problems to handle buffer sizes larger
than (signed) 16bit.
-> clamp buffer sizes to signed 16bit for better compatibility.

(*) This can lead to erroneous behaviour for files larger than 2GB
that NFSv2 cannot handle but it is still better than before.
An alternative would be to (partially) reject operations on files
larger than 2GB, but which causes other problems.
 1.53  14-Sep-2013  martin branches: 1.53.22; 1.53.30; 1.53.34;
Backout wildcard pragma to kill warnings and instead sprinkle a few dozen
__unused attributes.
Requested by joerg@
 1.52  14-Sep-2013  martin Silence gcc 4.8.1 warnings
 1.51  10-Apr-2009  bouyer PR kern/41158: nfs_rename() locking against myself
nfsrv_rename() can exit without calling genfs_renamelock_exit() because
the nfsm_reply() can do return (0) on error.
Change nfsm_reply to use 'error = 0; goto nfsmout' instead.
Fix a few place so it's safe to goto nfsmout from nfsm_reply, or other
macros calling it.
As a side effect it could fix a missing vrele(dirp) in various place where
nfsm_reply could return(0).
 1.50  04-Mar-2007  christos branches: 1.50.40; 1.50.50; 1.50.52; 1.50.56;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.49  22-Feb-2007  thorpej TRUE -> true, FALSE -> false
 1.48  21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.47  02-Sep-2006  yamt branches: 1.47.8;
nfsd: deal with variable-sized filehandles.
 1.46  08-Aug-2006  yamt nfsm_srvfhtom: ensure that padding bytes in nfsv2 file handles are zero.
 1.45  07-Jun-2006  kardel branches: 1.45.4;
merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html
 1.44  11-Dec-2005  christos branches: 1.44.4; 1.44.6; 1.44.8; 1.44.14;
merge ktrace-lwp.
 1.43  31-Oct-2005  thorpej Fix paste-o in the NFSV3SATTRTIME_TOSERVER case of mtime handing (need
to set va_mtime, not va_atime).
 1.42  01-Oct-2005  yamt branches: 1.42.2;
nfsm_srvsattr: use nanotime(9) rather than time(9) for NFSV3SATTRTIME_TOSERVER.
 1.41  29-May-2005  christos branches: 1.41.2;
- sprinkle const
- avoid shadowed variables
- mark bad const use with XXXUNCONST
 1.40  26-Feb-2005  perry nuke trailing whitespace
 1.39  19-Jan-2005  yamt branches: 1.39.2;
implement inaccurate mtime/ctime detection.
namely, if mtime or ctime are same between pre_op_attr and post_op_attr
when we expected them to be changed, don't trust the server.
 1.38  29-Sep-2004  yamt branches: 1.38.4;
g/c NFSMINOFF, which is unused and identical with MRESETDATA.
 1.37  10-May-2004  yamt don't do kludge for a reply to a retransmitted request
unless we actually retransmitted the request.
 1.36  05-Apr-2004  yamt nfsm_mtofh: handle the case that filehandle is exist but fattr is not.
 1.35  05-Apr-2004  yamt nfsm_wcc_data: update n_ctime and n_nctime if no one other than us
changed the file in the meantime so that we won't invalidate caches
unnecessarily due to our own activities.
 1.34  19-Mar-2004  yamt branches: 1.34.2;
comments on some nfsm_ macros.
 1.33  15-Mar-2004  yamt some comments on cryptic nfsm_ macros.
 1.32  26-Sep-2003  yamt change n_mtime from time_t to timespec in order to improve
cache consistency.
(1 second granularity is too loose these days.)
 1.31  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.30  29-Jun-2003  fvdl branches: 1.30.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.29  28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.28  09-Jun-2003  yamt rework zero padding of rpc reply.
- for READ procedure, don't send back more bytes than requested.
- don't have doubtful assumptions on mbuf chain structure.
- rename a function (nfsm_adj -> nfs_zeropad) to avoid confusion as
the semantics of the function was changed.
 1.27  06-May-2003  yamt remove nfsm_srvstrsiz as it's no longer used.
 1.26  24-Apr-2003  drochner Change some subordinate functions to take a "struct nfsnode" argument
instead of "struct vnode". This saves a number of pointer dereferences;
it sums up to about half a kB for me. And it paves the way for future
fixes.
While cleaning up, eliminate a write-only member of "struct nfsreq"
and a pointless assignment in the NFS_V2_ONLY case.
 1.25  28-Mar-2003  yamt reply ENAMETOOLONG properly instead of discarding request as BADRPC.
my own PR20791.
 1.24  26-Feb-2003  matt Fix typo.
 1.23  26-Feb-2003  matt Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.
 1.22  21-Oct-2002  yamt fix a page locking deadlock problem for nfs.

add a flag that specify if the file can be truncated safely or not
to nfsm_loadattr and friends. when it isn't safe, just mark the nfsnode
as "should be truncated later".

ok'ed by Frank van der Linden and Chuck Silvers.
close kern/18036.
 1.21  03-Apr-2002  wrstuden In the SETATTR code, if the changes to a & m time are exclusively
set via NFSV3SATTRTIME_TOSERVER and not NFSV3SATTRTIME_TOCLIENT,
add VA_UTIMES_NULL to the va_vflags. This reflects our policy
where we're much more liberal about who can set a & m times to 'now'
than we are about who can set them to a specific time.

Should close PR 15597 from Martin Husemann. Patch is based on the
one Matthias Drochner gave in the PR.
 1.20  29-May-1999  fvdl branches: 1.20.14; 1.20.16;
Be more correct with attribute structures for setattr RPCs and friends,
so that picky servers (e.g. Solaris 7) don't refuse our requests. Move
some code into a macro, and a bit of KNF. From OpenBSD.
 1.19  06-Mar-1999  fair branches: 1.19.2; 1.19.4; 1.19.6;
Snatch a patch from OpenBSD to fix PRs 6529 and 7074.
Adjust fxdr_hyper() and txdr_hyper() macros.
 1.18  09-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.17  14-Jul-1997  fvdl Don't assume that pointers into mbuf data remain valid across nfsm_dissect.
In readdirplus, don't keep such pointers but store the file attributes
in a variable instead until they are needed. Change nfsm_loadattr*
a bit so it can accept a direct pointer to an nfs_fattr structure.
 1.16  24-Jun-1997  fvdl Let nfsm_srvmtofh deal with the public filehandle, convert to all zeroes
for both v2 and v3 internally.
 1.15  27-Mar-1997  thorpej Don't assume mbuf external storage is MCLBYTES.
 1.14  24-Feb-1997  fvdl Use ALIGNED_POINTER to see whether mbuf data needs to be realigned.
 1.13  22-Feb-1997  fvdl Cast pointer to u_long, not int, when doing the alignment check.
Fixes warnings on the Alpha. Needs a better solution.
 1.12  22-Feb-1997  fvdl Fixes from BSDI (thanks go to Keith Bostic). Original RCS message:

date: 1997/02/10 18:41:15; author: cp; state: Exp; lines: +8 -2
Make nfs_realign go away on sparc and add functionality to nfsm_disct.

===
[XXX this introduces an ifdef __i386__, see the comment. Should be changed]
 1.11  25-Oct-1996  cgd branches: 1.11.4;
make the namei struct members ni_dirp and ni_next, and the componentname
struct member cn_nameptr 'const', since they should never be used to
modify the path name. (Only the pathname buffer, cn_pnbuf, should be
modified.) Propagate the const poisoning to code that uses the namei
and componentname structs.
 1.10  20-Mar-1996  fvdl Make sure not to free the reply mbuf twice. Should fix PR #2240
 1.9  18-Feb-1996  fvdl Bring in a merge of Rick Macklem's NFSv3 code from Lite2
 1.8  09-Feb-1996  christos nfs prototype changes
 1.7  19-Dec-1995  cgd changes to make this work on systems where pointers & longs are 64 bits.
This is mostly just changes to make the stuff that goes over the wire
use fixed-size types.
 1.6  23-May-1995  mycroft Remove gratuitous extra indirections.
 1.5  29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.4  08-Jun-1994  mycroft Update to 4.4-Lite fs code, with local changes.
 1.3  03-Jun-1993  cgd fix for macklem's bogus use of the va_flags field, supplied by
John Woods, jfwfrom: @ksr.com. also, fixes the following problems:
the va_gen field is in a similar position
(Suns are going to be reporting the change-date microseconds as their
"generation"), I've supplied my own set of diffs below for your inspection.
Note these aren't even compiled, but they're pretty similar to what I had
to do to our older version of OSF/1 here. (There's also an unrelated change
supplied for xdr_subs.h; the pointer types supplied to the fxdr_time() and
txdr_time() macros are not, in fact, both struct timevals. That turns out
to be one of many tips-of-the-iceberg facing those porting the (old) Berkeley
NFS code to 64-bit machines...)
 1.2  20-May-1993  cgd more rcs id adding and header cleanup. i like vi macros!
 1.1  20-Apr-1993  mycroft branches: 1.1.1;
Restore files lost during crash.
 1.1.1.2  01-Mar-1998  fvdl Import 4.4BSD-Lite2
 1.1.1.1  01-Mar-1998  fvdl Import 4.4BSD-Lite for reference
 1.11.4.1  12-Mar-1997  is Merge in changes from Trunk
 1.19.6.1  30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.19.4.1  21-Jun-1999  thorpej Sync w/ -current.
 1.19.2.1  22-Jun-1999  perry pullup 1.19->1.20 (fvdl): fix file creation with a Solaris 7 server
 1.20.16.1  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.20.14.2  22-Oct-2002  thorpej Sync with HEAD.
 1.20.14.1  17-Apr-2002  nathanw Catch up to -current.
 1.30.2.8  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.30.2.7  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.30.2.6  24-Jan-2005  skrll Sync with HEAD.
 1.30.2.5  19-Oct-2004  skrll Sync with HEAD
 1.30.2.4  21-Sep-2004  skrll Fix the sync with head I botched.
 1.30.2.3  18-Sep-2004  skrll Sync with HEAD.
 1.30.2.2  03-Aug-2004  skrll Sync with HEAD
 1.30.2.1  02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.34.2.3  11-Jan-2005  jmc Pullup patch (requested by yamy in ticket #1078)

Don't do kludge for a reply to a retransmitted request
unless we actually retransmitted the request.
 1.34.2.2  10-Jul-2004  tron branches: 1.34.2.2.2;
Pull up revision 1.36 (requested by tls in ticket #634):
nfsm_mtofh: handle the case that filehandle is exist but fattr is not.
 1.34.2.1  10-Jul-2004  tron Pull up revision 1.35 (requested by tls in ticket #634):
nfsm_wcc_data: update n_ctime and n_nctime if no one other than us
changed the file in the meantime so that we won't invalidate caches
unnecessarily due to our own activities.
 1.34.2.2.2.1  11-Jan-2005  jmc Pullup patch (requested by yamy in ticket #1078)

Don't do kludge for a reply to a retransmitted request
unless we actually retransmitted the request.
 1.38.4.1  29-Apr-2005  kent sync with -current
 1.39.2.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.41.2.4  03-Sep-2007  yamt sync with head.
 1.41.2.3  26-Feb-2007  yamt sync with head.
 1.41.2.2  30-Dec-2006  yamt sync with head.
 1.41.2.1  21-Jun-2006  yamt sync with head.
 1.42.2.1  02-Nov-2005  yamt sync with head.
 1.44.14.1  19-Jun-2006  chap Sync with head.
 1.44.8.3  03-Sep-2006  yamt sync with head.
 1.44.8.2  11-Aug-2006  yamt sync with head
 1.44.8.1  26-Jun-2006  yamt sync with head.
 1.44.6.1  04-Feb-2006  simonb Adapt for timecounters: mostly use get*time() and use "time_second"
instead of "time.tv_sec".
 1.44.4.1  09-Sep-2006  rpaulo sync with head
 1.45.4.1  16-Aug-2006  tron Pull up following revision(s) (requested by yamt in ticket #24):
sys/nfs/nfsm_subs.h: revision 1.46
nfsm_srvfhtom: ensure that padding bytes in nfsv2 file handles are zero.
 1.47.8.2  12-Mar-2007  rmind Sync with HEAD.
 1.47.8.1  28-Feb-2007  yamt sync with head. (somehow missed in the previous)
 1.50.56.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.50.52.1  13-Apr-2009  snj Pull up following revision(s) (requested by ad in ticket #700):
sys/nfs/nfs_serv.c: revision 1.144
sys/nfs/nfsm_subs.h: revision 1.51
PR kern/41158: nfs_rename() locking against myself
nfsrv_rename() can exit without calling genfs_renamelock_exit() because
the nfsm_reply() can do return (0) on error.
Change nfsm_reply to use 'error = 0; goto nfsmout' instead.
Fix a few place so it's safe to goto nfsmout from nfsm_reply, or other
macros calling it.
As a side effect it could fix a missing vrele(dirp) in various place where
nfsm_reply could return(0).
 1.50.50.1  28-Apr-2009  skrll Sync with HEAD.
 1.50.40.1  04-May-2009  yamt sync with head.
 1.53.34.1  30-Mar-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1617):

sys/nfs/nfs_serv.c: revision 1.184
sys/nfs/nfs_srvsubs.c: revision 1.17
sys/nfs/nfsm_subs.h: revision 1.56
sys/nfs/nfsm_subs.h: revision 1.57

nfs: Use unsigned fhlen so we don't trip over negative values.

nfs: Avoid integer overflow in nfs_namei bounds check.

nfs: Use unsigned name lengths so we don't trip over negative ones.
- nfsm_strsiz is only used with uint32_t in callers, but let's not
leave it as a rake to step on.
- nfsm_srvnamesiz is abused with signed s. The internal conversion
to unsigned serves to reject both negative and too-large values in
such callers.
XXX Should make all callers use unsigned, rather than flipping back
and forth between signed and unsigned for name lengths.

nfs: Avoid free of uninitialized on bad name size in create, mknod.
XXX These error branches are a nightmare and need to be more
systematically cleaned up. Even if they are correct now, they are
impossible to audit and extremely fragile in case anyone ever needs
to make other changes to them.
 1.53.30.1  08-Apr-2020  martin Merge changes from current as of 20200406
 1.53.22.1  30-Mar-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1810):

sys/nfs/nfs_serv.c: revision 1.184
sys/nfs/nfs_srvsubs.c: revision 1.17
sys/nfs/nfsm_subs.h: revision 1.56
sys/nfs/nfsm_subs.h: revision 1.57

nfs: Use unsigned fhlen so we don't trip over negative values.

nfs: Avoid integer overflow in nfs_namei bounds check.

nfs: Use unsigned name lengths so we don't trip over negative ones.
- nfsm_strsiz is only used with uint32_t in callers, but let's not
leave it as a rake to step on.
- nfsm_srvnamesiz is abused with signed s. The internal conversion
to unsigned serves to reject both negative and too-large values in
such callers.
XXX Should make all callers use unsigned, rather than flipping back
and forth between signed and unsigned for name lengths.

nfs: Avoid free of uninitialized on bad name size in create, mknod.
XXX These error branches are a nightmare and need to be more
systematically cleaned up. Even if they are correct now, they are
impossible to audit and extremely fragile in case anyone ever needs
to make other changes to them.
 1.55.4.1  30-Mar-2023  martin Pull up following revision(s) (requested by riastradh in ticket #134):

sys/nfs/nfs_serv.c: revision 1.184
sys/nfs/nfs_srvsubs.c: revision 1.17
sys/nfs/nfsm_subs.h: revision 1.56
sys/nfs/nfsm_subs.h: revision 1.57

nfs: Use unsigned fhlen so we don't trip over negative values.

nfs: Avoid integer overflow in nfs_namei bounds check.

nfs: Use unsigned name lengths so we don't trip over negative ones.
- nfsm_strsiz is only used with uint32_t in callers, but let's not
leave it as a rake to step on.
- nfsm_srvnamesiz is abused with signed s. The internal conversion
to unsigned serves to reject both negative and too-large values in
such callers.
XXX Should make all callers use unsigned, rather than flipping back
and forth between signed and unsigned for name lengths.

nfs: Avoid free of uninitialized on bad name size in create, mknod.
XXX These error branches are a nightmare and need to be more
systematically cleaned up. Even if they are correct now, they are
impossible to audit and extremely fragile in case anyone ever needs
to make other changes to them.

RSS XML Feed