aboutsummaryrefslogtreecommitdiff
path: root/sys/netsmb
Commit message (Collapse)AuthorAgeFilesLines
* net: clean up empty lines in .c and .h filesMateusz Guzik2020-09-0113-29/+9
| | | | Notes: svn path=/head/; revision=365071
* Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)Pawel Biernacki2020-02-261-3/+6
| | | | | | | | | | | | | | | | | | | r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are still not MPSAFE (or already are but aren’t properly marked). Use it in preparation for a general review of all nodes. This is non-functional change that adds annotations to SYSCTL_NODE and SYSCTL_PROC nodes using one of the soon-to-be-required flags. Mark all obvious cases as MPSAFE. All entries that haven't been marked as MPSAFE before are by default marked as NEEDGIANT Approved by: kib (mentor, blanket) Commented by: kib, gallatin, melifaro Differential Revision: https://reviews.freebsd.org/D23718 Notes: svn path=/head/; revision=358333
* Stop using des_cblock * for arguments to DES functions.John Baldwin2019-08-261-2/+2
| | | | | | | | | | | | | | This amounts to a char ** since it is a char[8] *. Evil casts mostly resolved the fact that what was actually passed in were plain char *. Instead, change the DES functions to use 'unsigned char *' for keys and for input and output buffers. Reviewed by: cem, imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D21389 Notes: svn path=/head/; revision=351513
* Remove unused argument to priv_check_cred.Mateusz Guzik2018-12-111-1/+1
| | | | | | | | | | | | | | | | Patch mostly generated with cocinnelle: @@ expression E1,E2; @@ - priv_check_cred(E1,E2,0) + priv_check_cred(E1,E2) Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=341827
* Make timespecadd(3) and friends publicAlan Somers2018-07-302-8/+7
| | | | | | | | | | | | | | | | | | | | | | The timespecadd(3) family of macros were imported from NetBSD back in r35029. However, they were initially guarded by #ifdef _KERNEL. In the meantime, we have grown at least 28 syscalls that use timespecs in some way, leading many programs both inside and outside of the base system to redefine those macros. It's better just to make the definitions public. Our kernel currently defines two-argument versions of timespecadd and timespecsub. NetBSD, OpenBSD, and FreeDesktop.org's libbsd, however, define three-argument versions. Solaris also defines a three-argument version, but only in its kernel. This revision changes our definition to match the common three-argument version. Bump _FreeBSD_version due to the breaking KPI change. Discussed with: cem, jilles, ian, bde Differential Revision: https://reviews.freebsd.org/D14725 Notes: svn path=/head/; revision=336914
* Eliminate the overhead of gratuitous repeated reinitialization of cap_rightsMatt Macy2018-05-091-2/+1
| | | | | | | | | | | | | | | - Add macros to allow preinitialization of cap_rights_t. - Convert most commonly used code paths to use preinitialized cap_rights_t. A 3.6% speedup in fstat was measured with this change. Reported by: mjg Reviewed by: oshogbo Approved by: sbruno MFC after: 1 month Notes: svn path=/head/; revision=333425
* Unsign some values related to allocation.Pedro F. Giffuni2018-01-221-2/+2
| | | | | | | | | | | | | | When allocating memory through malloc(9), we always expect the amount of memory requested to be unsigned as a negative value would either stand for an error or an overflow. Unsign some values, found when considering the use of mallocarray(9), to avoid unnecessary casting. Also consider that indexes should be of at least the same size/type as the upper limit they pretend to index. MFC after: 3 weeks Notes: svn path=/head/; revision=328238
* sys: general adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-2716-0/+32
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. No functional change intended. Notes: svn path=/head/; revision=326272
* spdx: initial adoption of licensing ID tags.Pedro F. Giffuni2017-11-181-0/+2
| | | | | | | | | | | | | | | | | | | | The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Initially, only tag files that use BSD 4-Clause "Original" license. RelNotes: yes Differential Revision: https://reviews.freebsd.org/D13133 Notes: svn path=/head/; revision=325966
* netsmb: Fix buggy/racy smb_strdupin()Conrad Meyer2017-09-291-14/+3
| | | | | | | | | | | | | | | | | | | smb_strdupin() tried to roll a copyin() based strlen to allocate a buffer and then blindly copyin that size. Of course, a malicious user program could simultaneously manipulate the buffer, resulting in a non-terminated string being copied. Later assumptions in the code rely upon the string being nul-terminated. Just use copyinstr() and drop the racy sizing. PR: 222687 Reported by: Meng Xu <meng.xu AT gatech.edu> Security: possible local DoS Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=324102
* sys/net*: minor spelling fixes.Pedro F. Giffuni2016-05-031-1/+1
| | | | | | | No functional change. Notes: svn path=/head/; revision=298995
* Remove unused SMB_DIALECT_MAX macro.Pedro F. Giffuni2016-04-201-2/+0
| | | | | | | Found by: jhb Notes: svn path=/head/; revision=298375
* kernel: use our nitems() macro when it is available through param.h.Pedro F. Giffuni2016-04-191-1/+1
| | | | | | | | | No functional change, only trivial cases are done in this sweep, Discussed in: freebsd-current Notes: svn path=/head/; revision=298310
* Cleanup unnecessary semicolons from the kernel.Pedro F. Giffuni2016-04-101-1/+1
| | | | | | | Found with devel/coccinelle. Notes: svn path=/head/; revision=297793
* The problem report was for a crash that happened when smbfs wasRick Macklem2015-11-182-1/+6
| | | | | | | | | | | | | | | | | | | | trying to do a mount. Given the backtrace, it appears that the crash occurred when smb_vc_create() failed and then called smb_vc_put() with vcp->vc_iod == NULL. smb_vc_put() subsequently called smb_vc_disconnect() with vcp->vc_iod == NULL, causing the crash. This patch adds a check for vcp->vc_iod != NULL in smb_vc_disconnect() to avoid the crash. It also fixes the case in smb_vc_create() where kproc_create() fails so that it destroys the mutexes and sets vcp->vc_iod == NULL before free()'ing the iod structure. The person who reported the PR tested the patch, but was not able to reproduce the crash with or without the patch. PR: 201912 Reviewed by: jhb MFC after: 2 weeks Notes: svn path=/head/; revision=291035
* When the smbfs iod thread (smb_iod_thread()) is shutting down, smb_iod_destroy()Rick Macklem2015-11-161-3/+5
| | | | | | | | | | | | | | | | | | | | | | would call smb_iod_request(). This call could return as soon as the wakeup(evp) in smb_iod_main() call is done and then could destroy the mutexes. This caused a race with the rest of smb_iod_main()s use of these mutexes. A crash reported on freebsd-stable@ by Christian Kratzer was diagnosed as a use of one of these mutexes after it was destroyed. This patch moves destruction of the mutexes from smb_iod_destroy() to the end of smb_iod_thread(), so that they aren't destroyed before the thread is done with them. Christian comfirmed that the patch stopped the crashes from happening. Reported by: ck-lists@cksoft.de (Christian Kratzer) Tested by: ck-lists@cksoft.de (Christian Kratzer) Diagnosed by: jhb Reviewed by: jhb MFC after: 2 weeks Notes: svn path=/head/; revision=290959
* Remove redundant unlock.Andrey V. Elsukov2014-04-171-2/+0
| | | | | | | | | | | | This code was removed from the opensolaris and darwin's netsmb implementations, in DfBSD it also has been disabled. PR: 36566, 87859, 139407, 161579, 175557, 178412, 186652 MFC after: 2 weeks Sponsored by: Yandex LLC Notes: svn path=/head/; revision=264600
* Update kernel inclusions of capability.h to use capsicum.h instead; someRobert Watson2014-03-161-1/+1
| | | | | | | | | | | further refinement is required as some device drivers intended to be portable over FreeBSD versions rely on __FreeBSD_version to decide whether to include capability.h. MFC after: 3 weeks Notes: svn path=/head/; revision=263233
* Remove IPX support.Gleb Smirnoff2014-03-141-5/+1
| | | | | | | | | | | | | | IPX was a network transport protocol in Novell's NetWare network operating system from late 80s and then 90s. The NetWare itself switched to TCP/IP as default transport in 1998. Later, in this century the Novell Open Enterprise Server became successor of Novell NetWare. The last release that claimed to still support IPX was OES 2 in 2007. Routing equipment vendors (e.g. Cisco) discontinued support for IPX in 2011. Thus, IPX won't be supported in FreeBSD 11.0-RELEASE. Notes: svn path=/head/; revision=263140
* Catch up with sb_timeo type change in r255138. This fixesGleb Smirnoff2013-11-081-2/+2
| | | | | | | | | | smbfs operation. PR: kern/182963 Submitted by: Tomoaki AOKI <junchoon dec.sakura.ne.jp> Notes: svn path=/head/; revision=257841
* Change the cap_rights_t type from uint64_t to a structure that we can extendPawel Jakub Dawidek2013-09-051-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in the future in a backward compatible (API and ABI) way. The cap_rights_t represents capability rights. We used to use one bit to represent one right, but we are running out of spare bits. Currently the new structure provides place for 114 rights (so 50 more than the previous cap_rights_t), but it is possible to grow the structure to hold at least 285 rights, although we can make it even larger if 285 rights won't be enough. The structure definition looks like this: struct cap_rights { uint64_t cr_rights[CAP_RIGHTS_VERSION + 2]; }; The initial CAP_RIGHTS_VERSION is 0. The top two bits in the first element of the cr_rights[] array contain total number of elements in the array - 2. This means if those two bits are equal to 0, we have 2 array elements. The top two bits in all remaining array elements should be 0. The next five bits in all array elements contain array index. Only one bit is used and bit position in this five-bits range defines array index. This means there can be at most five array elements in the future. To define new right the CAPRIGHT() macro must be used. The macro takes two arguments - an array index and a bit to set, eg. #define CAP_PDKILL CAPRIGHT(1, 0x0000000000000800ULL) We still support aliases that combine few rights, but the rights have to belong to the same array element, eg: #define CAP_LOOKUP CAPRIGHT(0, 0x0000000000000400ULL) #define CAP_FCHMOD CAPRIGHT(0, 0x0000000000002000ULL) #define CAP_FCHMODAT (CAP_FCHMOD | CAP_LOOKUP) There is new API to manage the new cap_rights_t structure: cap_rights_t *cap_rights_init(cap_rights_t *rights, ...); void cap_rights_set(cap_rights_t *rights, ...); void cap_rights_clear(cap_rights_t *rights, ...); bool cap_rights_is_set(const cap_rights_t *rights, ...); bool cap_rights_is_valid(const cap_rights_t *rights); void cap_rights_merge(cap_rights_t *dst, const cap_rights_t *src); void cap_rights_remove(cap_rights_t *dst, const cap_rights_t *src); bool cap_rights_contains(const cap_rights_t *big, const cap_rights_t *little); Capability rights to the cap_rights_init(), cap_rights_set(), cap_rights_clear() and cap_rights_is_set() functions are provided by separating them with commas, eg: cap_rights_t rights; cap_rights_init(&rights, CAP_READ, CAP_WRITE, CAP_FSTAT); There is no need to terminate the list of rights, as those functions are actually macros that take care of the termination, eg: #define cap_rights_set(rights, ...) \ __cap_rights_set((rights), __VA_ARGS__, 0ULL) void __cap_rights_set(cap_rights_t *rights, ...); Thanks to using one bit as an array index we can assert in those functions that there are no two rights belonging to different array elements provided together. For example this is illegal and will be detected, because CAP_LOOKUP belongs to element 0 and CAP_PDKILL to element 1: cap_rights_init(&rights, CAP_LOOKUP | CAP_PDKILL); Providing several rights that belongs to the same array's element this way is correct, but is not advised. It should only be used for aliases definition. This commit also breaks compatibility with some existing Capsicum system calls, but I see no other way to do that. This should be fine as Capsicum is still experimental and this change is not going to 9.x. Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=255219
* Remove a reference to LK_DRAIN now that lockmgr(9) is gone from thisDavide Italiano2013-06-281-1/+0
| | | | | | | | | piece of code. Reported by: attilio Notes: svn path=/head/; revision=252354
* If the kernel is compiled with VMIMAGE support, the first attempt ofDavide Italiano2013-05-041-1/+10
| | | | | | | | | | | mounting smbfs share will cause a panic. Fix setting setting/restoring vnet context when needed. PR: kern/168077 Submitted by: dteske Notes: svn path=/head/; revision=250243
* Overhaul locking in netsmb, getting rid of the obsolete lockmgr() primitive.Davide Italiano2013-05-043-111/+164
| | | | | | | | | This solves a long standing LOR between smb_conn and smb_vc. Tested by: martymac, pho (previous version) Notes: svn path=/head/; revision=250237
* Completely rewrite the interface to smbdev switching from dev_cloneDavide Italiano2013-05-042-134/+107
| | | | | | | | | | | | to cdevpriv(9). This commit changes the semantic of mount_smbfs in userland as well, which now passes file descriptor in order to to mount a specific filesystem istance. Reviewed by: attilio, ed Tested by: martymac Notes: svn path=/head/; revision=250236
* Call make_dev_credf() rather than using the couple make_dev()/dev_ref().Davide Italiano2013-03-091-8/+3
| | | | | | | This closes a race with clone_cleanup(). Notes: svn path=/head/; revision=248109
* Merge Capsicum overhaul:Pawel Jakub Dawidek2013-03-021-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Capability is no longer separate descriptor type. Now every descriptor has set of its own capability rights. - The cap_new(2) system call is left, but it is no longer documented and should not be used in new code. - The new syscall cap_rights_limit(2) should be used instead of cap_new(2), which limits capability rights of the given descriptor without creating a new one. - The cap_getrights(2) syscall is renamed to cap_rights_get(2). - If CAP_IOCTL capability right is present we can further reduce allowed ioctls list with the new cap_ioctls_limit(2) syscall. List of allowed ioctls can be retrived with cap_ioctls_get(2) syscall. - If CAP_FCNTL capability right is present we can further reduce fcntls that can be used with the new cap_fcntls_limit(2) syscall and retrive them with cap_fcntls_get(2). - To support ioctl and fcntl white-listing the filedesc structure was heavly modified. - The audit subsystem, kdump and procstat tools were updated to recognize new syscalls. - Capability rights were revised and eventhough I tried hard to provide backward API and ABI compatibility there are some incompatible changes that are described in detail below: CAP_CREATE old behaviour: - Allow for openat(2)+O_CREAT. - Allow for linkat(2). - Allow for symlinkat(2). CAP_CREATE new behaviour: - Allow for openat(2)+O_CREAT. Added CAP_LINKAT: - Allow for linkat(2). ABI: Reuses CAP_RMDIR bit. - Allow to be target for renameat(2). Added CAP_SYMLINKAT: - Allow for symlinkat(2). Removed CAP_DELETE. Old behaviour: - Allow for unlinkat(2) when removing non-directory object. - Allow to be source for renameat(2). Removed CAP_RMDIR. Old behaviour: - Allow for unlinkat(2) when removing directory. Added CAP_RENAMEAT: - Required for source directory for the renameat(2) syscall. Added CAP_UNLINKAT (effectively it replaces CAP_DELETE and CAP_RMDIR): - Allow for unlinkat(2) on any object. - Required if target of renameat(2) exists and will be removed by this call. Removed CAP_MAPEXEC. CAP_MMAP old behaviour: - Allow for mmap(2) with any combination of PROT_NONE, PROT_READ and PROT_WRITE. CAP_MMAP new behaviour: - Allow for mmap(2)+PROT_NONE. Added CAP_MMAP_R: - Allow for mmap(PROT_READ). Added CAP_MMAP_W: - Allow for mmap(PROT_WRITE). Added CAP_MMAP_X: - Allow for mmap(PROT_EXEC). Added CAP_MMAP_RW: - Allow for mmap(PROT_READ | PROT_WRITE). Added CAP_MMAP_RX: - Allow for mmap(PROT_READ | PROT_EXEC). Added CAP_MMAP_WX: - Allow for mmap(PROT_WRITE | PROT_EXEC). Added CAP_MMAP_RWX: - Allow for mmap(PROT_READ | PROT_WRITE | PROT_EXEC). Renamed CAP_MKDIR to CAP_MKDIRAT. Renamed CAP_MKFIFO to CAP_MKFIFOAT. Renamed CAP_MKNODE to CAP_MKNODEAT. CAP_READ old behaviour: - Allow pread(2). - Disallow read(2), readv(2) (if there is no CAP_SEEK). CAP_READ new behaviour: - Allow read(2), readv(2). - Disallow pread(2) (CAP_SEEK was also required). CAP_WRITE old behaviour: - Allow pwrite(2). - Disallow write(2), writev(2) (if there is no CAP_SEEK). CAP_WRITE new behaviour: - Allow write(2), writev(2). - Disallow pwrite(2) (CAP_SEEK was also required). Added convinient defines: #define CAP_PREAD (CAP_SEEK | CAP_READ) #define CAP_PWRITE (CAP_SEEK | CAP_WRITE) #define CAP_MMAP_R (CAP_MMAP | CAP_SEEK | CAP_READ) #define CAP_MMAP_W (CAP_MMAP | CAP_SEEK | CAP_WRITE) #define CAP_MMAP_X (CAP_MMAP | CAP_SEEK | 0x0000000000000008ULL) #define CAP_MMAP_RW (CAP_MMAP_R | CAP_MMAP_W) #define CAP_MMAP_RX (CAP_MMAP_R | CAP_MMAP_X) #define CAP_MMAP_WX (CAP_MMAP_W | CAP_MMAP_X) #define CAP_MMAP_RWX (CAP_MMAP_R | CAP_MMAP_W | CAP_MMAP_X) #define CAP_RECV CAP_READ #define CAP_SEND CAP_WRITE #define CAP_SOCK_CLIENT \ (CAP_CONNECT | CAP_GETPEERNAME | CAP_GETSOCKNAME | CAP_GETSOCKOPT | \ CAP_PEELOFF | CAP_RECV | CAP_SEND | CAP_SETSOCKOPT | CAP_SHUTDOWN) #define CAP_SOCK_SERVER \ (CAP_ACCEPT | CAP_BIND | CAP_GETPEERNAME | CAP_GETSOCKNAME | \ CAP_GETSOCKOPT | CAP_LISTEN | CAP_PEELOFF | CAP_RECV | CAP_SEND | \ CAP_SETSOCKOPT | CAP_SHUTDOWN) Added defines for backward API compatibility: #define CAP_MAPEXEC CAP_MMAP_X #define CAP_DELETE CAP_UNLINKAT #define CAP_MKDIR CAP_MKDIRAT #define CAP_RMDIR CAP_UNLINKAT #define CAP_MKFIFO CAP_MKFIFOAT #define CAP_MKNOD CAP_MKNODAT #define CAP_SOCK_ALL (CAP_SOCK_CLIENT | CAP_SOCK_SERVER) Sponsored by: The FreeBSD Foundation Reviewed by: Christoph Mallon <christoph.mallon@gmx.de> Many aspects discussed with: rwatson, benl, jonathan ABI compatibility discussed with: kib Notes: svn path=/head/; revision=247602
* Mechanically substitute flags from historic mbuf allocator withGleb Smirnoff2012-12-053-3/+3
| | | | | | | | | | | | malloc(9) flags within sys. Exceptions: - sys/contrib not touched - sys/mbuf.h edited manually Notes: svn path=/head/; revision=243882
* Fix panic due to page faults while in kernel mode, under conditions ofDavide Italiano2012-10-314-51/+93
| | | | | | | | | | | | VM pressure. The reason is that in some codepaths pointers to stack variables were passed from one thread to another. In collaboration with: pho Reported by: pho's stress2 suite Sponsored by: iXsystems inc. Notes: svn path=/head/; revision=242386
* Change a duplicated check to clarify that we really want to set aChristian Brueffer2012-07-101-1/+3
| | | | | | | | | | | | reasonable default timeout. PR: 163135 Submitted by: Sascha Wildner <saw@online.de> Suggested by: bp Reviewed by: bp Notes: svn path=/head/; revision=238356
* When checking if file descriptor number is valid, explicitely check for 'fd'Pawel Jakub Dawidek2012-06-131-1/+1
| | | | | | | | | being less than 0 instead of using cast-to-unsigned hack. Today's commit was brought to you by the letters 'B', 'D' and 'E' :) Notes: svn path=/head/; revision=237036
* Add unicode support to msdosfs and smbfs; original pathes from imura,Kevin Lo2011-11-184-22/+84
| | | | | | | | | bug fixes by Kuan-Chung Chiu <buganini at gmail dot com>. Tested by me in production for several days at work. Notes: svn path=/head/; revision=227650
* Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs.Ed Schouten2011-11-073-4/+4
| | | | | | | This means that their use is restricted to a single C file. Notes: svn path=/head/; revision=227293
* Change some variables from int to size_t. This is more accurate sinceChristian S.J. Peron2011-01-083-14/+16
| | | | | | | | | | | | | | | these variables represent sizes in one capacity or another. There is no reason to allow negative numbers. Change userspace shared structure elements that get used for the modified functions from int to uint32_t, since it's not clear what userspace programs use these fields, and we do not want to break binary compatibility. This fixes a panic when corrupt or bogus data is passed into the kernel. Obtained from: NetBSD MFC after: 3 weeks Notes: svn path=/head/; revision=217174
* Switch to our preferred 2-clause BSD license.Joel Dahl2010-04-0716-101/+5
| | | | | | | Approved by: bp Notes: svn path=/head/; revision=206361
* Don't print out a message on loading a module. 'kldload -v' and 'kldstatNick Hibma2009-09-101-2/+0
| | | | | | | | | | | | | | | | | grep <modname>' can be used instead. Put a message behind bootverbose as ichwd0: <Intel ICH6M watchdog timer> on isa0 ichwd0: Intel ICH6M watchdog timer (ICH6 or equivalent) does not make a lot of sense. MFC after: 1 week Notes: svn path=/head/; revision=197072
* Rework socket upcalls to close some races with setup/teardown of upcalls.John Baldwin2009-06-011-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Each socket upcall is now invoked with the appropriate socket buffer locked. It is not permissible to call soisconnected() with this lock held; however, so socket upcalls now return an integer value. The two possible values are SU_OK and SU_ISCONNECTED. If an upcall returns SU_ISCONNECTED, then the soisconnected() will be invoked on the socket after the socket buffer lock is dropped. - A new API is provided for setting and clearing socket upcalls. The API consists of soupcall_set() and soupcall_clear(). - To simplify locking, each socket buffer now has a separate upcall. - When a socket upcall returns SU_ISCONNECTED, the upcall is cleared from the receive socket buffer automatically. Note that a SO_SND upcall should never return SU_ISCONNECTED. - All this means that accept filters should now return SU_ISCONNECTED instead of calling soisconnected() directly. They also no longer need to explicitly clear the upcall on the new socket. - The HTTP accept filter still uses soupcall_set() to manage its internal state machine, but other accept filters no longer have any explicit knowlege of socket upcall internals aside from their return value. - The various RPC client upcalls currently drop the socket buffer lock while invoking soreceive() as a temporary band-aid. The plan for the future is to add a new flag to allow soreceive() to be called with the socket buffer locked. - The AIO callback for socket I/O is now also invoked with the socket buffer locked. Previously sowakeup() would drop the socket buffer lock only to call aio_swake() which immediately re-acquired the socket buffer lock for the duration of the function call. Discussed with: rwatson, rmacklem Notes: svn path=/head/; revision=193272
* Implement device cloning for /dev/nsmb, the netsmb control pseudo-device.Robert Watson2008-11-031-7/+19
| | | | | | | | | | | | | The smb library in userspace already knows how to deal with this type of cloning. This also corrects a leak in which the netsmb kernel module could not be unloaded if device nodes had been stat'd but not open'd. Discussed with: kib Notes: svn path=/head/; revision=184592
* Catch up with netsmb locking: explicit thread arguments no longer required.Robert Watson2008-11-021-4/+4
| | | | Notes: svn path=/head/; revision=184572
* Catch up internal locking routines in netsmb with lockmgr changes --Robert Watson2008-11-022-57/+54
| | | | | | | explicit thread arguments are no longer required in many places. Notes: svn path=/head/; revision=184571
* smb_vc_put() requires that the passed vcp be locked, so lock it beforeRobert Watson2008-11-021-1/+3
| | | | | | | | | | | | | | | dropping the connection when the requested service isn't available, or we may try to release a lock that isn't locked. This prevents an assertion failure when trying to mount a non-present share using smbfs with INVARIANTS; a lock order reversal warning that immediately follows is not yet fixed. Reported by: attilio MFC after: 3 days Notes: svn path=/head/; revision=184568
* Retire the MALLOC and FREE macros. They are an abomination unto style(9).Dag-Erling Smørgrav2008-10-232-3/+3
| | | | | | | MFC after: 3 months Notes: svn path=/head/; revision=184205
* Replace all calls to minor() with dev2unit().Ed Schouten2008-09-271-2/+2
| | | | | | | | | | | | | | | | | | After I removed all the unit2minor()/minor2unit() calls from the kernel yesterday, I realised calling minor() everywhere is quite confusing. Character devices now only have the ability to store a unit number, not a minor number. Remove the confusion by using dev2unit() everywhere. This commit could also be considered as a bug fix. A lot of drivers call minor(), while they should actually be calling dev2unit(). In -CURRENT this isn't a problem, but it turns out we never had any problem reports related to that issue in the past. I suspect not many people connect more than 256 pieces of the same hardware. Reviewed by: kib Notes: svn path=/head/; revision=183397
* Remove unit2minor() use from kernel code.Ed Schouten2008-09-261-1/+1
| | | | | | | | | | | | | | | | | | When I changed kern_conf.c three months ago I made device unit numbers equal to (unneeded) device minor numbers. We used to require bitshifting, because there were eight bits in the middle that were reserved for a device major number. Not very long after I turned dev2unit(), minor(), unit2minor() and minor2unit() into macro's. The unit2minor() and minor2unit() macro's were no-ops. We'd better not remove these four macro's from the kernel, because there is a lot of (external) code that may still depend on them. For now it's harmless to remove all invocations of unit2minor() and minor2unit(). Reviewed by: kib Notes: svn path=/head/; revision=183381
* Really, smb_iod_main() is not totally MPSAFE, so just acquire and dropAttilio Rao2008-03-271-0/+3
| | | | | | | | | | Giant around it in order to assume MPSAFETY. Reported by: jhb, rwatson Pointy hat to: attilio Notes: svn path=/head/; revision=177654
* Replaced the misleading uses of a historical artefact M_TRYWAIT with M_WAIT.Ruslan Ermilov2008-03-253-8/+4
| | | | | | | | | | | | | Removed dead code that assumed that M_TRYWAIT can return NULL; it's not true since the advent of MBUMA. Reviewed by: arch There are ongoing disputes as to whether we want to switch to directly using UMA flags M_WAITOK/M_NOWAIT for mbuf(9) allocation. Notes: svn path=/head/; revision=177599
* Remove unused vc_tnode field from struct smb_vc.Robert Watson2008-03-101-1/+0
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=177031
* - Handle buffer lock waiters count directly in the buffer cache insteadAttilio Rao2008-03-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | than rely on the lockmgr support [1]: * bump the waiters only if the interlock is held * let brelvp() return the waiters count * rely on brelvp() instead than BUF_LOCKWAITERS() in order to check for the waiters number - Remove a namespace pollution introduced recently with lockmgr.h including lock.h by including lock.h directly in the consumers and making it mandatory for using lockmgr. - Modify flags accepted by lockinit(): * introduce LK_NOPROFILE which disables lock profiling for the specified lockmgr * introduce LK_QUIET which disables ktr tracing for the specified lockmgr [2] * disallow LK_SLEEPFAIL and LK_NOWAIT to be passed there so that it can only be used on a per-instance basis - Remove BUF_LOCKWAITERS() and lockwaiters() as they are no longer used This patch breaks KPI so __FreBSD_version will be bumped and manpages updated by further commits. Additively, 'struct buf' changes results in a disturbed ABI also. [2] Really, currently there is no ktr tracing in the lockmgr, but it will be added soon. [1] Submitted by: kib Tested by: pho, Andrea Barberio <insomniac at slackware dot it> Notes: svn path=/head/; revision=176708
* Remove a spourious Giant acquisition.Attilio Rao2008-02-251-3/+0
| | | | | | | | | | | | The code seems pretty MPSAFE and Giant is held over kproc_exit() which at lowel calls exit1(). exit1() requires Giant to be unowned so this opens a window for races. Reported by: Bryan Venteicher <bryanv at daemoninthecloset dot org> Tested by: Bryan Venteicher <bryanv at daemoninthecloset dot org> Notes: svn path=/head/; revision=176566
* Axe the 'thread' argument from VOP_ISLOCKED() and lockstatus() as it isAttilio Rao2008-02-251-1/+1
| | | | | | | | | | | | always curthread. As KPI gets broken by this patch, manpages and __FreeBSD_version will be updated by further commits. Tested by: Andrea Barberio <insomniac at slackware dot it> Notes: svn path=/head/; revision=176559