aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/snp
Commit message (Collapse)AuthorAgeFilesLines
* MFC rev 1.101 and 1.102:Olivier Houchard2005-09-231-6/+15
| | | | | | | | | | | | | | | | | revision 1.101 date: 2005/09/18 19:23:35; author: cognet; state: Exp; lines: +14 -5 Slightly change the API for the SNPSTTY ioctl so that the userland now provides a file descriptor instead of a dev_t. revision 1.102 date: 2005/09/19 13:48:45; author: ru; state: Exp; lines: +5 -5 Restore the ability to detach from a tty via SIOCSTTY and document recent changes in a manpage. Approved by: re Notes: svn path=/stable/6/; revision=150494
* Merge two sets of changes relating to devfs device node cloning fromRobert Watson2005-08-131-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | HEAD to RELENG_6: changes to introduce a credentialed version of the clone event handler, and then changes to merge the regular and credentialed versions into a single interface (along with updates to existing consumers). With this merge, 6.x and 7.x are in sync. First batch merges devfs_devs.c:1.37, devfs_vnops.c:1.115, kern_conf.c:1.187, tty_pty.c:1.138, mac_vfs.c:1.109, mac_biba.c:1.36, mac_lomac.c:1.36, mac_mls.c:1.73, mac_stub.c:1.53, mac_test.c:1.61, conf.h:1.223, mac.h:1.68, mac_policy.h:1.67 from HEAD to RELENG_6: When devfs cloning takes place, provide access to the credential of the process that caused the clone event to take place for the device driver creating the device. This allows cloned device drivers to adapt the device node based on security aspects of the process, such as the uid, gid, and MAC label. - Add a cred reference to struct cdev, so that when a device node is instantiated as a vnode, the cloning credential can be exposed to MAC. - Add make_dev_cred(), a version of make_dev() that additionally accepts the credential to stick in the struct cdev. Implement it and make_dev() in terms of a back-end make_dev_credv(). - Add a new event handler, dev_clone_cred, which can be registered to receive the credential instead of dev_clone, if desired. - Modify the MAC entry point mac_create_devfs_device() to accept an optional credential pointer (may be NULL), so that MAC policies can inspect and act on the label or other elements of the credential when initializing the skeleton device protections. - Modify tty_pty.c to register clone_dev_cred and invoke make_dev_cred(), so that the pty clone credential is exposed to the MAC Framework. While currently primarily focussed on MAC policies, this change is also a prerequisite for changes to allow ptys to be instantiated with the UID of the process looking up the pty. This requires further changes to the pty driver -- in particular, to immediately recycle pty nodes on last close so that the credential-related state can be recreated on next lookup. Submitted by: Andrew Reisse <andrew.reisse@sparta.com> Obtained from: TrustedBSD Project Sponsored by: SPAWAR, SPARTA Second batch merges scsi_target.c:1.68, coda_fbsd.c:1.43, firewirereg.h:1.38, fwdev.c:1.47, nmdm.c:1.36, snp.c:1.100, dsp.c:1.82, mixer.c:1.45, vkbd.c:1.9, devfs_vnops.c:1.117, tty_pty.c:1.139, tty_tty.c:1.57, bpf.c:1.156, if_tap.c:1.56, if_tun.c:1.153, smb_dev.c:1.28, conf.h:1.224 from HEAD to RELENG_6: Merge the dev_clone and dev_clone_cred event handlers into a single event handler, dev_clone, which accepts a credential argument. Implementors of the event can ignore it if they're not interested, and most do. This avoids having multiple event handler types and fall-back/precedence logic in devfs. This changes the kernel API for /dev cloning, and may affect third party packages containg cloning kernel modules. Requested by: phk These changes modifies the kernel device driver API for device cloning, and might require minor modifications to third party device drivers that make use of devfs cloning. It will not be merged to RELENG_5. Approved by: re (scottl) Notes: svn path=/stable/6/; revision=149038
* Explicitly hold a reference to the cdev we have just cloned. ThisPoul-Henning Kamp2005-03-311-1/+3
| | | | | | | | closes the race where the cdev was reclaimed before it ever made it back to devfs lookup. Notes: svn path=/head/; revision=144389
* Disable two users of findcdev. They do the wrong thing now and willPoul-Henning Kamp2005-03-151-0/+4
| | | | | | | | need to be fixed. In both cases the API should be reengineered to do something (more) sensible. Notes: svn path=/head/; revision=143637
* Start each of the license/copyright comments with /*-, minor shuffle of linesWarner Losh2005-01-061-1/+1
| | | | Notes: svn path=/head/; revision=139749
* Include fcntl.h not vnode.h.Poul-Henning Kamp2004-12-221-2/+3
| | | | | | | | Include uio.h instead of relying on vnode.h to do so. Check O_NONBLOCK not IO_NDELAY. Notes: svn path=/head/; revision=139195
* Walk through the snp softc list instead of abusing tp->ts_c to find theOlivier Houchard2004-11-051-8/+17
| | | | | | | | snp attached to a tty. This fixes the panic that happens when using snp. Notes: svn path=/head/; revision=137265
* Hold thread reference while we frob cdevsw.Poul-Henning Kamp2004-09-241-3/+9
| | | | Notes: svn path=/head/; revision=135724
* Preparation commit for the tty cleanups that will follow in the nearPoul-Henning Kamp2004-07-151-1/+1
| | | | | | | | | | | | future: rename ttyopen() -> tty_open() and ttyclose() -> tty_close(). We need the ttyopen() and ttyclose() for the new generic cdevsw functions for tty devices in order to have consistent naming. Notes: svn path=/head/; revision=132226
* Do a pass over all modules in the kernel and make them return EOPNOTSUPPPoul-Henning Kamp2004-07-151-0/+1
| | | | | | | | | | | for unknown events. A number of modules return EINVAL in this instance, and I have left those alone for now and instead taught MOD_QUIESCE to accept this as "didn't do anything". Notes: svn path=/head/; revision=132199
* Switch snoop device to using C99 initialization for struct linesw.Robert Watson2004-07-141-2/+8
| | | | Notes: svn path=/head/; revision=132133
* Second half of the dev_t cleanup.Poul-Henning Kamp2004-06-171-7/+7
| | | | | | | | | | | | | | The big lines are: NODEV -> NULL NOUDEV -> NODEV udev_t -> dev_t udev2dev() -> findcdev() Various minor adjustments including handling of userland access to kernel space struct cdev etc. Notes: svn path=/head/; revision=130640
* Do the dreaded s/dev_t/struct cdev */Poul-Henning Kamp2004-06-161-12/+12
| | | | | | | Bump __FreeBSD_version accordingly. Notes: svn path=/head/; revision=130585
* Add missing <sys/module.h> includesPoul-Henning Kamp2004-05-301-0/+1
| | | | Notes: svn path=/head/; revision=129879
* Add clone_setup() function rather than rely on lazy initialization.Poul-Henning Kamp2004-03-111-0/+1
| | | | | | | Requested by: rwatson Notes: svn path=/head/; revision=126845
* Don't set d_flags twice. The second setting clobbered D_NOGIANT.Bruce Evans2004-02-241-2/+1
| | | | Notes: svn path=/head/; revision=126188
* Device megapatch 5/6:Poul-Henning Kamp2004-02-211-1/+1
| | | | | | | | | | | | | | | Remove the unused second argument from udev2dev(). Convert all remaining users of makedev() to use udev2dev(). The semantic difference is that udev2dev() will only locate a pre-existing dev_t, it will not line makedev() create a new one. Apart from the tiny well controlled windown in D_PSEUDO drivers, there should no longer be any "anonymous" dev_t's in the system now, only dev_t's created with make_dev() and make_dev_alias() Notes: svn path=/head/; revision=126081
* Device megapatch 4/6:Poul-Henning Kamp2004-02-211-0/+2
| | | | | | | | | | | Introduce d_version field in struct cdevsw, this must always be initialized to D_VERSION. Flip sense of D_NOGIANT flag to D_NEEDGIANT, this involves removing four D_NOGIANT flags and adding 145 D_NEEDGIANT flags. Notes: svn path=/head/; revision=126080
* Device megapatch 2/6:Poul-Henning Kamp2004-02-211-18/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds a couple of functions for pseudodrivers to use for implementing cloning in a manner we will be able to lock down (shortly). Basically what happens is that pseudo drivers get a way to ask for "give me the dev_t with this unit number" or alternatively "give me a dev_t with the lowest guaranteed free unit number" (there is unfortunately a lot of non-POLA in the exact numeric value of this number, just live with it for now) Managing the unit number space this way removes the need to use rman(9) to do so in the drivers this greatly simplifies the code in the drivers because even using rman(9) they still needed to manage their dev_t's anyway. I have taken the if_tun, if_tap, snp and nmdm drivers through the mill, partly because they (ab)used makedev(), but mostly because together they represent three different problems for device-cloning: if_tun and snp is the plain case: just give me a device. if_tap has two kinds of devices, with a flag for device type. nmdm has paired devices (ala pty) can you can clone either of them. Notes: svn path=/head/; revision=126077
* - Implement selwakeuppri() which allows raising the priority of aSeigo Tanimura2003-11-091-2/+2
| | | | | | | | | | | | | | | | thread being waken up. The thread waken up can run at a priority as high as after tsleep(). - Replace selwakeup()s with selwakeuppri()s and pass appropriate priorities. - Add cv_broadcastpri() which raises the priority of the broadcast threads. Used by selwakeuppri() if collision occurs. Not objected in: -arch, -current Notes: svn path=/head/; revision=122352
* Use __FBSDID().David E. O'Brien2003-08-241-1/+3
| | | | | | | Also some minor style cleanups. Notes: svn path=/head/; revision=119419
* Gigacommit to improve device-driver source compatibility betweenPoul-Henning Kamp2003-03-031-13/+8
| | | | | | | | | | | | | | | | branches: Initialize struct cdevsw using C99 sparse initializtion and remove all initializations to default values. This patch is automatically generated and has been tested by compiling LINT with all the fields in struct cdevsw in reverse order on alpha, sparc64 and i386. Approved by: re(scottl) Notes: svn path=/head/; revision=111815
* More low-hanging fruit: kill caddr_t in calls to wakeup(9) / [mt]sleep(9).Dag-Erling Smørgrav2003-03-021-3/+3
| | | | Notes: svn path=/head/; revision=111748
* msgPoul-Henning Kamp2003-02-261-2/+0
| | | | Notes: svn path=/head/; revision=111571
* Back out M_* changes, per decision of the TRB.Warner Losh2003-02-191-4/+4
| | | | | | | Approved by: trb Notes: svn path=/head/; revision=111119
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.Alfred Perlstein2003-01-211-4/+4
| | | | | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT. Notes: svn path=/head/; revision=109623
* Declare the snp ioctl()s to work on udev_t, since that is what theyThomas Moestl2002-11-111-1/+1
| | | | | | | | | | really do and dev_t is defined differently in kernel and userland. Return a correctly formed udev from SNPGTTY. Reviewed by: dd Notes: svn path=/head/; revision=106767
* Treat input on the snp device as an `unsigned char'. According to theDima Dorfman2002-04-101-1/+1
| | | | | | | | | | | submitter, this permits Russian (and probably other locales') characters to be entered via watch(8). PR: 35636 Submitted by: Gleb Smirnoff <glebius@rinet.ru> Notes: svn path=/head/; revision=94341
* Remove __P.Alfred Perlstein2002-03-201-7/+7
| | | | Notes: svn path=/head/; revision=92739
* Fixes to make select/poll mpsafe.Alfred Perlstein2002-03-141-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: selwakeup required calling pfind which would cause lock order reversals with the allproc_lock and the per-process filedesc lock. Solution: Instead of recording the pid of the select()'ing process into the selinfo structure, actually record a pointer to the thread. To avoid dereferencing a bad address all the selinfo structures that are in use by a thread are kept in a list hung off the thread (protected by sellock). When a selwakeup occurs the selinfo is removed from that threads list, it is also removed on the way out of select or poll where the thread will traverse its list removing all the selinfos from its own list. Problem: Previously the PROC_LOCK was used to provide the mutual exclusion needed to ensure proper locking, this couldn't work because there was a single condvar used for select and poll and condvars can only be used with a single mutex. Solution: Introduce a global mutex 'sellock' which is used to provide mutual exclusion when recording events to wait on as well as performing notification when an event occurs. Interesting note: schedlock is required to manipulate the per-thread TDF_SELECT flag, however if given its own field it would not need schedlock, also because TDF_SELECT is only manipulated under sellock one doesn't actually use schedlock for syncronization, only to protect against corruption. Proc locks are no longer used in select/poll. Portions contributed by: davidc Notes: svn path=/head/; revision=92252
* Make the diagnostics printfs less ugly.Dima Dorfman2002-03-111-4/+6
| | | | Notes: svn path=/head/; revision=92056
* Check the return value of tsleep() in snpread(). This may beDima Dorfman2001-11-241-1/+4
| | | | | | | | | | | important, since our sleep is interruptable (PCATCH flag). PR: 30985 Discovered by: Vladimir Jakovenko <vovik@lucky.net> Submitted by: Valentin Nechayev <netch@segfault.kiev.ua> Notes: svn path=/head/; revision=86861
* Return EBUSY if we try to attach to a tty that is already beingDima Dorfman2001-11-241-0/+2
| | | | | | | | | | | snooped on. This causes all kinds of Bad Things(tm) to happen since closing one session will clobber state that's needed for the other one. This could theoretically be supported if the code was careful, but until somebody implements that, preventing this will stop people from unknowingly shooting themselves in the foot. Notes: svn path=/head/; revision=86855
* Create a snpbasedev variable which holds a reference to the first snpDima Dorfman2001-11-241-3/+9
| | | | | | | | | | | | | | | | | | | device cloned, and assign all further devices to depend on it. This allows us to call dev_depends() on it at module unload time to get rid of /dev/snp* (in the devfs case, anyway). For this to work, we must not destroy the device at close time. [Idea stolen from if_tun.] The above has the following sideaffects: (a) The snp device used by watch(8) will remain after watch(8) exits. This is probably how it should have been all along, and how it was before devfs came along. (b) Module unload doesn't panic if there are any /dev/snp* devices which haven't been used (and thus previously destroyed). Thus, we can reenable the unload functionality disabled in rev. 1.65. PR: 32012 Notes: svn path=/head/; revision=86853
* 'error' is now unused, since its only purpose was to catch theRobert Watson2001-11-151-1/+0
| | | | | | | results of suser_td(). Notes: svn path=/head/; revision=86419
* Temporarily disable unloading, as it appears to be broken (read: causesRobert Watson2001-11-151-0/+2
| | | | | | | panics) Notes: svn path=/head/; revision=86417
* o Rely on /dev/snp* permissions, rather than using suser() in snpopen()Robert Watson2001-11-151-3/+0
| | | | | | | | | to prevent inappropriate use of the snoop device. This means that, with appropriate chmod'ing, arbitrary users may make use of the snoop device. Notes: svn path=/head/; revision=86413
* KSE Milestone 2Julian Elischer2001-09-121-11/+11
| | | | | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha Notes: svn path=/head/; revision=83366
* Don't allocate a 512 byte buffer on the stack in snplwrite. It'sDima Dorfman2001-08-161-5/+12
| | | | | | | | | | | probably harmless in this case, since the latter is called on tty input, which is usually a result of some system call, so we've got plenty of stack left. It's still nice to fix these things, though, in case somebody ever decides this driver is a good example of something (perhaps "what you probably shouldn't do"). Notes: svn path=/head/; revision=81747
* Move the kernel stuff out of snoop.h. It was only there because someDima Dorfman2001-07-251-0/+39
| | | | | | | | of the snp* functions needed to be called from tty.c, which is no longer the case. Notes: svn path=/head/; revision=80326
* Keep track of all "struct snoop"'s so that snp_modevent can fail withDima Dorfman2001-07-181-1/+9
| | | | | | | EBUSY if there's a device still open. Notes: svn path=/head/; revision=79864
* Add a line discipline close routine which restores some functionalityDima Dorfman2001-06-051-5/+21
| | | | | | | | I accidently nuked in rev. 1.54. Also rework the error handling in snplwrite a little. Notes: svn path=/head/; revision=77749
* Style and cosmetic cleanups. This driver is now reasonably stlye(9)Dima Dorfman2001-06-051-111/+127
| | | | | | | | | | | | compliant. All the variable definitions and function names are reasonably consistent, and the functions which should be static (i.e., all of them) are. Other assorted fixes were made. The majority of the delta is indentation fixes. Partially reviewed by: bde Notes: svn path=/head/; revision=77748
* Use the l_nullioctl exported from tty_conf.c rather than rolling our own.Dima Dorfman2001-06-041-10/+0
| | | | Notes: svn path=/head/; revision=77736
* Remove unused includes, use *min() inline functions rather than aDima Dorfman2001-06-031-26/+8
| | | | | | | | | | home-grown macro, rewrite a confusing conditional in snpdevtotty(), and change ibuf to 512 bytes instead of 1024 bytes in dsnwrite(). Reviewed by: bde Notes: svn path=/head/; revision=77648
* Convert this driver to (ab?)use line disciplines to get the input itDima Dorfman2001-05-221-17/+84
| | | | | | | | | | needs instead of relying on idiosyncratic hacks in the tty subsystem. Also add module code since this can now be compiled as a module. Silence by: -hackers, -audit Notes: svn path=/head/; revision=77016
* Make this driver play ball with devfs(5).Dima Dorfman2001-04-171-3/+19
| | | | | | | Reviewed by: brian Notes: svn path=/head/; revision=75633
* Send the remains (such as I have located) of "block major numbers" toPoul-Henning Kamp2001-03-261-1/+0
| | | | | | | the bit-bucket. Notes: svn path=/head/; revision=74810
* Remove unused #include "snp.h"Peter Wemm2001-01-291-1/+0
| | | | Notes: svn path=/head/; revision=71789
* Convert more malloc+bzero to malloc+M_ZERO.David Malone2000-12-081-2/+1
| | | | | | | | Submitted by: josh@zipperup.org Submitted by: Robert Drehmel <robd@gmx.net> Notes: svn path=/head/; revision=69781