Re: ktrace: Allow appending to FIFOs
Klemens Nanni wrote: > I wanted to quickly debug some program without actually dumping to disk > by using FIFOs, however ktrace(2) wouldn't accept anything but regular > files. > > Are there any pitfalls or limitations I am currently not aware of that > justify this strict behaviour? oh, neat, i've actually really wanted something like this for a while. i was trying to find a way to make it an arbitrary fd, but this seems like a much smaller diff. i don't think there should be problems. i haven't checked the code recently, but it should already handle disk full, etc. situations, so if the reader stops it just means events get thrown away. the traced process shouldn't block. but that's something to confirm and test. > > $ ln -s some.file link > $ ktrace -a -f link echo foo > ktrace: link: Too many levels of symbolic links > > $ mkfifo fifo && cat fifo >/dev/null & > $ ktrace -a -f fifo echo foo > ktrace: fifo: Permission denied > > > With this tiny patch ktrace(2) allows appending to FIFOs, which enables > me to do the following: > > $ mkfifo ktrace.out && kdump -l & > $ ktrace -a echo foo > foo >1903 ktrace RET ktrace 0 >1903 ktrace CALL > execve(0x7f7e6d50,0x7f7e72e8,0x7f7e7300) > [...] > $ ktrace -a echo bar > bar >94065 ktrace RET ktrace 0 >94065 ktrace CALL > execve(0x7f7e2280,0x7f7e2818,0x7f7e2830) > [...] > > > Feedback? OK? > > Index: kern_ktrace.c > === > RCS file: /cvs/src/sys/kern/kern_ktrace.c,v > retrieving revision 1.91 > diff -u -p -r1.91 kern_ktrace.c > --- kern_ktrace.c 14 Feb 2017 10:31:15 - 1.91 > +++ kern_ktrace.c 20 Jun 2017 22:01:56 - > @@ -428,7 +428,7 @@ sys_ktrace(struct proc *p, void *v, regi > vp = nd.ni_vp; > > VOP_UNLOCK(vp, p); > - if (vp->v_type != VREG) { > + if (vp->v_type != VREG && vp->v_type != VFIFO) { > error = EACCES; > goto done; > } >
Re: Trapsleds
> 2. This patch also hits NOP sleds > 8 bytes on i386. We could also hit > the NOP sleds between 3 and 7 bytes if there are no objections. The attached diff implements the same trapsled mechanism for i386 and amd64 for all padding sequences between 3 and 15 bytes. I have put this through a kernel and base build on i386 without apparent ill effect, and the amd64 parts are unchanged from the last diff. Todd Index: gas/config/tc-i386.c === RCS file: /cvs/src/gnu/usr.bin/binutils-2.17/gas/config/tc-i386.c,v retrieving revision 1.7 diff -u -p -u -p -r1.7 tc-i386.c --- gas/config/tc-i386.c4 Jun 2017 20:26:18 - 1.7 +++ gas/config/tc-i386.c21 Jun 2017 00:43:14 - @@ -505,41 +505,9 @@ i386_align_code (fragP, count) {0x90};/* nop */ static const char f32_2[] = {0x89,0xf6}; /* movl %esi,%esi */ - static const char f32_3[] = -{0x8d,0x76,0x00}; /* leal 0(%esi),%esi*/ - static const char f32_4[] = -{0x8d,0x74,0x26,0x00}; /* leal 0(%esi,1),%esi */ - static const char f32_5[] = -{0x90, /* nop */ - 0x8d,0x74,0x26,0x00}; /* leal 0(%esi,1),%esi */ - static const char f32_6[] = -{0x8d,0xb6,0x00,0x00,0x00,0x00}; /* leal 0L(%esi),%esi */ - static const char f32_7[] = -{0x8d,0xb4,0x26,0x00,0x00,0x00,0x00}; /* leal 0L(%esi,1),%esi */ - static const char f32_8[] = -{0x90, /* nop */ - 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00}; /* leal 0L(%esi,1),%esi */ - static const char f32_9[] = -{0x89,0xf6,/* movl %esi,%esi */ - 0x8d,0xbc,0x27,0x00,0x00,0x00,0x00}; /* leal 0L(%edi,1),%edi */ - static const char f32_10[] = -{0x8d,0x76,0x00, /* leal 0(%esi),%esi*/ - 0x8d,0xbc,0x27,0x00,0x00,0x00,0x00}; /* leal 0L(%edi,1),%edi */ - static const char f32_11[] = -{0x8d,0x74,0x26,0x00, /* leal 0(%esi,1),%esi */ - 0x8d,0xbc,0x27,0x00,0x00,0x00,0x00}; /* leal 0L(%edi,1),%edi */ - static const char f32_12[] = -{0x8d,0xb6,0x00,0x00,0x00,0x00,/* leal 0L(%esi),%esi */ - 0x8d,0xbf,0x00,0x00,0x00,0x00}; /* leal 0L(%edi),%edi */ - static const char f32_13[] = -{0x8d,0xb6,0x00,0x00,0x00,0x00,/* leal 0L(%esi),%esi */ - 0x8d,0xbc,0x27,0x00,0x00,0x00,0x00}; /* leal 0L(%edi,1),%edi */ - static const char f32_14[] = -{0x8d,0xb4,0x26,0x00,0x00,0x00,0x00, /* leal 0L(%esi,1),%esi */ - 0x8d,0xbc,0x27,0x00,0x00,0x00,0x00}; /* leal 0L(%edi,1),%edi */ static const char f32_15[] = -{0xeb,0x0d,0x90,0x90,0x90,0x90,0x90, /* jmp .+15; lotsa nops */ - 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90}; +{0xeb,0x0d,0xCC,0xCC,0xCC,0xCC,0xCC, /* jmp .+15; lotsa int3 */ + 0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC}; static const char f16_3[] = {0x8d,0x74,0x00}; /* lea 0(%esi),%esi */ static const char f16_4[] = @@ -556,40 +524,31 @@ i386_align_code (fragP, count) static const char f16_8[] = {0x8d,0xb4,0x00,0x00, /* lea 0w(%si),%si */ 0x8d,0xbd,0x00,0x00}; /* lea 0w(%di),%di */ + static const char f64_2[] = +{0x66,0x90};/* data16, nop*/ static const char *const f32_patt[] = { -f32_1, f32_2, f32_3, f32_4, f32_5, f32_6, f32_7, f32_8, -f32_9, f32_10, f32_11, f32_12, f32_13, f32_14, f32_15 +f32_1, f32_2, f32_15, f32_15, f32_15, f32_15, f32_15, f32_15, +f32_15, f32_15, f32_15, f32_15, f32_15, f32_15, f32_15 }; static const char *const f16_patt[] = { f32_1, f32_2, f16_3, f16_4, f16_5, f16_6, f16_7, f16_8, f32_15, f32_15, f32_15, f32_15, f32_15, f32_15, f32_15 }; + static const char *const f64_patt[] = { +f32_1, f64_2, f32_15, f32_15, f32_15, f32_15, f32_15, f32_15, +f32_15, f32_15, f32_15, f32_15, f32_15, f32_15, f32_15 + }; if (count <= 0 || count > 15) return; - /* The recommended way to pad 64bit code is to use NOPs preceded by - maximally four 0x66 prefixes. Balance the size of nops. */ if (flag_code == CODE_64BIT) { - int i; - int nnops = (count + 3) / 4; - int len = count / nnops; - int remains = count - nnops * len; - int pos = 0; - - for (i = 0; i < remains; i++) - { - memset (fragP->fr_literal + fragP->fr_fix + pos, 0x66, len); - fragP->fr_literal[fragP->fr_fix + pos + len] = 0x90; - pos += len + 1; - } - for (; i < nnops; i++) - { - memset (fragP->fr_literal + fragP->fr_fix + pos, 0x66, len - 1); - fragP->fr_literal[fragP->fr_fix + pos
pf statekey inp assertion failed
Hi, I saw a crash on an OpenBSD 6.1 based system when a kassert in pf_state_key_unref() was triggert. kernel diagnostic assertion "(sk->inp == NULL) || (sk->inp->inp_pf_sk == NULL)" failed: file "../../../../../net/pf.c", line 7155 panic() at panic+0xfe __assert() at __assert+0x25 pf_state_key_unref() at pf_state_key_unref+0xc6 pf_pkt_unlink_state_key() at pf_pkt_unlink_state_key+0x15 m_free() at m_free+0xc0 soreceive() at soreceive+0xb5d recvit() at recvit+0x13a sys_recvmsg() at sys_recvmsg+0x107 syscall() at syscall+0x2df The problem is that setting the inp pointer in the statekey to NULL is delayed until the statekey refcounter reaches 0. So the inp could get linked to another statekey while the mbuf in the socket buffer was keeping the refcounter at 1. The sk->inp should be set to NULL immediately, then the kassert can get even stricter. ok? bluhm Index: net/pf.c === RCS file: /data/mirror/openbsd/cvs/src/sys/net/pf.c,v retrieving revision 1.1034 diff -u -p -r1.1034 pf.c --- net/pf.c5 Jun 2017 22:18:28 - 1.1034 +++ net/pf.c20 Jun 2017 22:37:43 - @@ -779,6 +779,7 @@ pf_state_key_detach(struct pf_state *s, sk->removed = 1; pf_state_key_unlink_reverse(sk); pf_inpcb_unlink_state_key(sk->inp); + sk->inp = NULL; pf_state_key_unref(sk); } } @@ -7147,8 +7148,7 @@ pf_state_key_unref(struct pf_state_key * /* state key must be unlinked from reverse key */ KASSERT(sk->reverse == NULL); /* state key must be unlinked from socket */ - KASSERT((sk->inp == NULL) || (sk->inp->inp_pf_sk == NULL)); - sk->inp = NULL; + KASSERT(sk->inp == NULL); pool_put(_state_key_pl, sk); } }
Re: pf statekey inp assertion failed
On Wed, Jun 21, 2017 at 01:21:50AM +0200, Alexander Bluhm wrote: > Hi, > > I saw a crash on an OpenBSD 6.1 based system when a kassert in > pf_state_key_unref() was triggert. > > kernel diagnostic assertion "(sk->inp == NULL) || (sk->inp->inp_pf_sk == > NULL)" > failed: file "../../../../../net/pf.c", line 7155 > > > panic() at panic+0xfe > > __assert() at __assert+0x25 > > pf_state_key_unref() at pf_state_key_unref+0xc6 > > pf_pkt_unlink_state_key() at pf_pkt_unlink_state_key+0x15 > > m_free() at m_free+0xc0 > > soreceive() at soreceive+0xb5d > > recvit() at recvit+0x13a > > sys_recvmsg() at sys_recvmsg+0x107 > > syscall() at syscall+0x2df > > > The problem is that setting the inp pointer in the statekey to NULL > is delayed until the statekey refcounter reaches 0. So the inp > could get linked to another statekey while the mbuf in the socket > buffer was keeping the refcounter at 1. > > The sk->inp should be set to NULL immediately, then the kassert can > get even stricter. > > ok? ok!! dhill@ I hit this too. See bugs@ archives :) > > bluhm > > Index: net/pf.c > === > RCS file: /data/mirror/openbsd/cvs/src/sys/net/pf.c,v > retrieving revision 1.1034 > diff -u -p -r1.1034 pf.c > --- net/pf.c 5 Jun 2017 22:18:28 - 1.1034 > +++ net/pf.c 20 Jun 2017 22:37:43 - > @@ -779,6 +779,7 @@ pf_state_key_detach(struct pf_state *s, > sk->removed = 1; > pf_state_key_unlink_reverse(sk); > pf_inpcb_unlink_state_key(sk->inp); > + sk->inp = NULL; > pf_state_key_unref(sk); > } > } > @@ -7147,8 +7148,7 @@ pf_state_key_unref(struct pf_state_key * > /* state key must be unlinked from reverse key */ > KASSERT(sk->reverse == NULL); > /* state key must be unlinked from socket */ > - KASSERT((sk->inp == NULL) || (sk->inp->inp_pf_sk == NULL)); > - sk->inp = NULL; > + KASSERT(sk->inp == NULL); > pool_put(_state_key_pl, sk); > } > } >
Re: ktrace: Allow appending to FIFOs
On Tue, Jun 20, 2017 at 09:10:17PM -0400, Ted Unangst wrote: Klemens Nanni wrote: I wanted to quickly debug some program without actually dumping to disk by using FIFOs, however ktrace(2) wouldn't accept anything but regular files. Are there any pitfalls or limitations I am currently not aware of that justify this strict behaviour? oh, neat, i've actually really wanted something like this for a while. i was trying to find a way to make it an arbitrary fd, but this seems like a much smaller diff. i don't think there should be problems. i haven't checked the code recently, but it should already handle disk full, etc. situations, so if the reader stops it just means events get thrown away. the traced process shouldn't block. but that's something to confirm and test. The motivation was not to prevent full disks but rather to have an more intuitive workflow; ideally something like 'ktrace | kdump' or even some unified way/tool. I'm just not that familiar with VFS yet, hence my question. If this is really it, I'd like update the diff to make symbolic links as well. Besides that, getting EACCES on "wrong" files was pretty irritating: I spent some minutes looking at the actual permissions before digging deeper into the code.
Re: vi(1): documenting :s
Hi, Jason McIntyre writes: > shouldn;t it be that we should show the suspend command as > > sus[pend] > > the shortest "s" matches "substitute", right. so we show it as > > s[ubstitute] > > i cannot find any text that describes what "su" *should* match though, > so i'm not sure. logically i'd expect it to match "substitute", since > that is first alphabetically. that's why i think it should be sus[pend], > not sub[stitute]. > > i don;t have any other versions of vi to compare how other systems do > this. Turns out there is no consistency anywhere. Original vi implements: s su[spend] sub[stitute] nvi (ours and others): s su[spend] elvis: s[ubstitute] (it documents sus[pend] but doesn't actually implement it) vim: s[ubstitute] sus[pend] It looks like nvi tried to mimic original vi at the beginning, but broke the functionality sometime between 1994 and 1996, and nobody noticed over the next 20 years. Seeing as POSIX is unclear and everybody's inconsistent anyway, I'm strongly inclined to just leave things as they are, commit the original diff that documents the current reality, and leave it at that. -- Anthony J. Bentley
Re: vi(1): documenting :s
On Tue, Jun 20, 2017 at 01:30:35AM -0600, Anthony J. Bentley wrote: > Hi, > > Jason McIntyre writes: > > shouldn;t it be that we should show the suspend command as > > > > sus[pend] > > > > the shortest "s" matches "substitute", right. so we show it as > > > > s[ubstitute] > > > > i cannot find any text that describes what "su" *should* match though, > > so i'm not sure. logically i'd expect it to match "substitute", since > > that is first alphabetically. that's why i think it should be sus[pend], > > not sub[stitute]. > > > > i don;t have any other versions of vi to compare how other systems do > > this. > > Turns out there is no consistency anywhere. > > Original vi implements: > s > su[spend] > sub[stitute] > > nvi (ours and others): > s > su[spend] > > elvis: > s[ubstitute] (it documents sus[pend] but doesn't actually implement it) > > vim: > s[ubstitute] > sus[pend] > > It looks like nvi tried to mimic original vi at the beginning, but > broke the functionality sometime between 1994 and 1996, and nobody > noticed over the next 20 years. > > Seeing as POSIX is unclear and everybody's inconsistent anyway, I'm > strongly inclined to just leave things as they are, commit the original > diff that documents the current reality, and leave it at that. > morning. i think that makes sense too. jmc
Re: switch libkvm bits from hand rolled RBT updates to proper RBT api use
> Date: Tue, 20 Jun 2017 11:04:58 +1000 > From: David Gwynne> > now RBT is in userland, we can actually use the API instead of hand > rolling the copying of the tree topology. > > ok? ok kettenis@ > Index: lib/libkvm/kvm_proc.c > === > RCS file: /cvs/src/lib/libkvm/kvm_proc.c,v > retrieving revision 1.58 > diff -u -p -r1.58 kvm_proc.c > --- lib/libkvm/kvm_proc.c 7 Nov 2016 00:26:33 - 1.58 > +++ lib/libkvm/kvm_proc.c 20 Jun 2017 01:03:05 - > @@ -77,6 +77,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -108,6 +109,9 @@ static intproc_verify(kvm_t *, const st > static void ps_str_a(struct ps_strings *, u_long *, int *); > static void ps_str_e(struct ps_strings *, u_long *, int *); > > +RBT_PROTOTYPE(uvm_map_addr, vm_map_entry, daddrs.addr_entry, > +uvm_mapentry_addrcmp); > + > static struct vm_anon * > _kvm_findanon(kvm_t *kd, struct vm_amap *amapp, int slot) > { > @@ -166,7 +170,6 @@ _kvm_ureadm(kvm_t *kd, const struct kinf > struct vm_anon *anonp, anon; > struct vm_map_entry vme; > struct vm_page pg; > - unsigned long rboff; > > if (kd->swapspc == 0) { > kd->swapspc = _kvm_malloc(kd, kd->nbpg); > @@ -174,26 +177,23 @@ _kvm_ureadm(kvm_t *kd, const struct kinf > return (NULL); > } > > - rboff = (unsigned long)_entry - (unsigned long) > - > /* >* Look through the address map for the memory object >* that corresponds to the given virtual address. >*/ > if (KREAD(kd, (u_long)p->p_vmspace, )) > return (NULL); > - addr = (u_long)_map.addr.rbh_root.rbt_root; > + addr = (u_long)RBT_ROOT(uvm_map_addr, _map.addr); > while (1) { > if (addr == 0) > return (NULL); > - addr -= rboff; > if (KREAD(kd, addr, )) > return (NULL); > > if (va < vme.start) > - addr = (u_long)vme.daddrs.addr_entry.rbt_left; > + addr = (u_long)RBT_LEFT(uvm_map_addr, ); > else if (va >= vme.end + vme.guard + vme.fspace) > - addr = (u_long)vme.daddrs.addr_entry.rbt_right; > + addr = (u_long)RBT_RIGHT(uvm_map_addr, ); > else if (va >= vme.end) > return (NULL); > else > @@ -543,3 +543,13 @@ kvm_ureadm(kvm_t *kd, const struct kinfo > } > return (ssize_t)(cp - buf); > } > + > +static inline int > +uvm_mapentry_addrcmp(const struct vm_map_entry *e1, > +const struct vm_map_entry *e2) > +{ > + return e1->start < e2->start ? -1 : e1->start > e2->start; > +} > + > +RBT_GENERATE(uvm_map_addr, vm_map_entry, daddrs.addr_entry, > +uvm_mapentry_addrcmp); > Index: lib/libkvm/shlib_version > === > RCS file: /cvs/src/lib/libkvm/shlib_version,v > retrieving revision 1.19 > diff -u -p -r1.19 shlib_version > --- lib/libkvm/shlib_version 2 Oct 2016 23:11:55 - 1.19 > +++ lib/libkvm/shlib_version 20 Jun 2017 01:03:05 - > @@ -1,2 +1,2 @@ > major=16 > -minor=2 > +minor=3 > Index: usr.sbin/procmap/procmap.c > === > RCS file: /cvs/src/usr.sbin/procmap/procmap.c,v > retrieving revision 1.63 > diff -u -p -r1.63 procmap.c > --- usr.sbin/procmap/procmap.c16 Sep 2016 04:45:35 - 1.63 > +++ usr.sbin/procmap/procmap.c20 Jun 2017 01:03:05 - > @@ -580,10 +580,10 @@ load_vm_map_entries(kvm_t *kd, struct vm > > /* RBTs point at rb_entries inside nodes */ > ld = load_vm_map_entries(kd, RBT_LEFT(uvm_map_addr, result), result); > - result->daddrs.addr_entry.rbt_left = >daddrs.addr_entry; > + RBT_SET_LEFT(uvm_map_addr, result, ld); > ld = load_vm_map_entries(kd, RBT_RIGHT(uvm_map_addr, result), result); > - result->daddrs.addr_entry.rbt_right = >daddrs.addr_entry; > - result->daddrs.addr_entry.rbt_parent = >daddrs.addr_entry; > + RBT_SET_RIGHT(uvm_map_addr, result, ld); > + RBT_SET_PARENT(uvm_map_addr, result, parent); > > return result; > } > >
Fix possible fault in sysctl_file()
Hi, file pointer may be incompletely initialized after falloc(). For example, sys_socket() initializes 'f_flag', 'f_type', and 'f_ops' but may sleep then in socreate() before assigning 'f_data'. That is why there is the FIF_LARVAL flag, that is check by the macro FILE_IS_USABLE(). Of the three different operations sysctl_file() implements, two of them (namely KERN_FILE_BYPID and KERN_FILE_BYUID) use the FILE_IS_USABLE() to keep hand off incomplete file pointers. Yet the third operation (KERN_FILE_BYFILE) doesn't. That can yield a fault when dereferencing fp->f_data. The fix is rather straightforward. Gerhard Index: sys/kern/kern_sysctl.c === RCS file: /cvs/src/sys/kern/kern_sysctl.c,v retrieving revision 1.328 diff -u -p -u -p -r1.328 kern_sysctl.c --- sys/kern/kern_sysctl.c 14 Jun 2017 03:00:40 - 1.328 +++ sys/kern/kern_sysctl.c 20 Jun 2017 11:31:40 - @@ -1327,6 +1327,7 @@ sysctl_file(int *name, u_int namelen, ch FREF(fp); do { if (fp->f_count > 1 && /* 0, +1 for our FREF() */ + FILE_IS_USABLE(fp) && (arg == 0 || fp->f_type == arg)) { int af, skip = 0; if (arg == DTYPE_SOCKET && fp->f_type == arg) {
Re: remove redundant flag from iwm(4)
On Mon, Jun 19, 2017 at 02:10:50PM +0200, Mark Kettenis wrote: > > Date: Mon, 19 Jun 2017 13:02:58 +0200 > > From: Stefan Sperling> > > > On Mon, Jun 19, 2017 at 11:57:36AM +0200, Mark Kettenis wrote: > > > > @@ -7450,7 +7444,7 @@ iwm_init_task(void *arg1) > > > > } > > > > s = splnet(); > > > > > > > > - if (sc->sc_flags & IWM_FLAG_HW_INITED) > > > > + if (sc->sc_flags & IFF_RUNNING) > > > > iwm_stop(ifp, 0); > > > > > > This looks wrong to me. > > > > Why? > > Because IFF_RUNNING is a flag for ifp->if_flags, not sc->sc_flags. Indeed, thanks for catching this mistake! This fixed diff matches what was intended, and it still works (tested switching between networks and suspend/resume). Index: sys/dev/pci/if_iwm.c === RCS file: /cvs/src/sys/dev/pci/if_iwm.c,v retrieving revision 1.197 diff -u -p -r1.197 if_iwm.c --- sys/dev/pci/if_iwm.c16 Jun 2017 08:45:34 - 1.197 +++ sys/dev/pci/if_iwm.c16 Jun 2017 11:47:09 - @@ -6106,9 +6106,6 @@ iwm_init(struct ifnet *ifp) struct ieee80211com *ic = >sc_ic; int err, generation; - if (sc->sc_flags & IWM_FLAG_HW_INITED) { - return 0; - } sc->sc_generation++; err = iwm_init_hw(sc); @@ -6135,8 +6132,6 @@ iwm_init(struct ifnet *ifp) return err; } while (ic->ic_state != IEEE80211_S_SCAN); - sc->sc_flags |= IWM_FLAG_HW_INITED; - return 0; } @@ -6214,7 +6209,6 @@ iwm_stop(struct ifnet *ifp, int disable) struct ieee80211com *ic = >sc_ic; struct iwm_node *in = (void *)ic->ic_bss; - sc->sc_flags &= ~IWM_FLAG_HW_INITED; sc->sc_generation++; ic->ic_scan_lock = IEEE80211_SCAN_UNLOCKED; ifp->if_flags &= ~IFF_RUNNING; @@ -7450,7 +7444,7 @@ iwm_init_task(void *arg1) } s = splnet(); - if (sc->sc_flags & IWM_FLAG_HW_INITED) + if (ifp->if_flags & IFF_RUNNING) iwm_stop(ifp, 0); if ((ifp->if_flags & (IFF_UP | IFF_RUNNING)) == IFF_UP) iwm_init(ifp); Index: sys/dev/pci/if_iwmvar.h === RCS file: /cvs/src/sys/dev/pci/if_iwmvar.h,v retrieving revision 1.28 diff -u -p -r1.28 if_iwmvar.h --- sys/dev/pci/if_iwmvar.h 14 Jun 2017 16:56:04 - 1.28 +++ sys/dev/pci/if_iwmvar.h 14 Jun 2017 19:17:23 - @@ -280,9 +280,8 @@ struct iwm_rx_ring { }; #define IWM_FLAG_USE_ICT 0x01 -#define IWM_FLAG_HW_INITED 0x02 -#define IWM_FLAG_RFKILL0x04 -#define IWM_FLAG_SCANNING 0x08 +#define IWM_FLAG_RFKILL0x02 +#define IWM_FLAG_SCANNING 0x04 struct iwm_ucode_status { uint32_t uc_error_event_table;
Re: remove redundant flag from iwm(4)
> Date: Tue, 20 Jun 2017 13:34:57 +0200 > From: Stefan Sperling> > This fixed diff matches what was intended, and it still works (tested > switching between networks and suspend/resume). ok kettenis@ > Index: sys/dev/pci/if_iwm.c > === > RCS file: /cvs/src/sys/dev/pci/if_iwm.c,v > retrieving revision 1.197 > diff -u -p -r1.197 if_iwm.c > --- sys/dev/pci/if_iwm.c 16 Jun 2017 08:45:34 - 1.197 > +++ sys/dev/pci/if_iwm.c 16 Jun 2017 11:47:09 - > @@ -6106,9 +6106,6 @@ iwm_init(struct ifnet *ifp) > struct ieee80211com *ic = >sc_ic; > int err, generation; > > - if (sc->sc_flags & IWM_FLAG_HW_INITED) { > - return 0; > - } > sc->sc_generation++; > > err = iwm_init_hw(sc); > @@ -6135,8 +6132,6 @@ iwm_init(struct ifnet *ifp) > return err; > } while (ic->ic_state != IEEE80211_S_SCAN); > > - sc->sc_flags |= IWM_FLAG_HW_INITED; > - > return 0; > } > > @@ -6214,7 +6209,6 @@ iwm_stop(struct ifnet *ifp, int disable) > struct ieee80211com *ic = >sc_ic; > struct iwm_node *in = (void *)ic->ic_bss; > > - sc->sc_flags &= ~IWM_FLAG_HW_INITED; > sc->sc_generation++; > ic->ic_scan_lock = IEEE80211_SCAN_UNLOCKED; > ifp->if_flags &= ~IFF_RUNNING; > @@ -7450,7 +7444,7 @@ iwm_init_task(void *arg1) > } > s = splnet(); > > - if (sc->sc_flags & IWM_FLAG_HW_INITED) > + if (ifp->if_flags & IFF_RUNNING) > iwm_stop(ifp, 0); > if ((ifp->if_flags & (IFF_UP | IFF_RUNNING)) == IFF_UP) > iwm_init(ifp); > Index: sys/dev/pci/if_iwmvar.h > === > RCS file: /cvs/src/sys/dev/pci/if_iwmvar.h,v > retrieving revision 1.28 > diff -u -p -r1.28 if_iwmvar.h > --- sys/dev/pci/if_iwmvar.h 14 Jun 2017 16:56:04 - 1.28 > +++ sys/dev/pci/if_iwmvar.h 14 Jun 2017 19:17:23 - > @@ -280,9 +280,8 @@ struct iwm_rx_ring { > }; > > #define IWM_FLAG_USE_ICT 0x01 > -#define IWM_FLAG_HW_INITED 0x02 > -#define IWM_FLAG_RFKILL 0x04 > -#define IWM_FLAG_SCANNING0x08 > +#define IWM_FLAG_RFKILL 0x02 > +#define IWM_FLAG_SCANNING0x04 > > struct iwm_ucode_status { > uint32_t uc_error_event_table; > >
Re: Fix possible fault in sysctl_file()
On Tue, Jun 20, 2017 at 01:51:07PM +0200, Gerhard Roth wrote: > The fix is rather straightforward. OK bluhm@ > Index: sys/kern/kern_sysctl.c > === > RCS file: /cvs/src/sys/kern/kern_sysctl.c,v > retrieving revision 1.328 > diff -u -p -u -p -r1.328 kern_sysctl.c > --- sys/kern/kern_sysctl.c14 Jun 2017 03:00:40 - 1.328 > +++ sys/kern/kern_sysctl.c20 Jun 2017 11:31:40 - > @@ -1327,6 +1327,7 @@ sysctl_file(int *name, u_int namelen, ch > FREF(fp); > do { > if (fp->f_count > 1 && /* 0, +1 for our FREF() */ > + FILE_IS_USABLE(fp) && > (arg == 0 || fp->f_type == arg)) { > int af, skip = 0; > if (arg == DTYPE_SOCKET && fp->f_type == arg) {
ktrace: Allow appending to FIFOs
I wanted to quickly debug some program without actually dumping to disk by using FIFOs, however ktrace(2) wouldn't accept anything but regular files. Are there any pitfalls or limitations I am currently not aware of that justify this strict behaviour? $ ln -s some.file link $ ktrace -a -f link echo foo ktrace: link: Too many levels of symbolic links $ mkfifo fifo && cat fifo >/dev/null & $ ktrace -a -f fifo echo foo ktrace: fifo: Permission denied With this tiny patch ktrace(2) allows appending to FIFOs, which enables me to do the following: $ mkfifo ktrace.out && kdump -l & $ ktrace -a echo foo foo 1903 ktrace RET ktrace 0 1903 ktrace CALL execve(0x7f7e6d50,0x7f7e72e8,0x7f7e7300) [...] $ ktrace -a echo bar bar 94065 ktrace RET ktrace 0 94065 ktrace CALL execve(0x7f7e2280,0x7f7e2818,0x7f7e2830) [...] Feedback? OK? Index: kern_ktrace.c === RCS file: /cvs/src/sys/kern/kern_ktrace.c,v retrieving revision 1.91 diff -u -p -r1.91 kern_ktrace.c --- kern_ktrace.c 14 Feb 2017 10:31:15 - 1.91 +++ kern_ktrace.c 20 Jun 2017 22:01:56 - @@ -428,7 +428,7 @@ sys_ktrace(struct proc *p, void *v, regi vp = nd.ni_vp; VOP_UNLOCK(vp, p); - if (vp->v_type != VREG) { + if (vp->v_type != VREG && vp->v_type != VFIFO) { error = EACCES; goto done; }
Re: locate/mklocatedb.sh: remove unused option
Bump. These scripts could use a little refreshing. On 22:34:57, 12.06.17, Michal Mazurek wrote: > This script has an option called -presort or -nosort, that appears to > never be used, so remove it. This makes the $sort* options unneeded, > remove them too. > > The script itself is used by updatedb and pkg_mklocatedb. > > Comments? OK? > > Index: usr.bin/locate/locate/mklocatedb.sh > === > RCS file: /cvs/src/usr.bin/locate/locate/mklocatedb.sh,v > retrieving revision 1.13 > diff -u -p -r1.13 mklocatedb.sh > --- usr.bin/locate/locate/mklocatedb.sh 18 Mar 2007 20:13:49 - > 1.13 > +++ usr.bin/locate/locate/mklocatedb.sh 12 Jun 2017 20:30:53 - > @@ -28,7 +28,7 @@ > # > # mklocatedb - build locate database > # > -# usage: mklocatedb [-presort] < filelist > database > +# usage: mklocatedb < filelist > database > # > # $Id: mklocatedb.sh,v 1.13 2007/03/18 20:13:49 otto Exp $ > > @@ -48,15 +48,6 @@ fi > # utilities to built locate database > : ${bigram=locate.bigram} > : ${code=locate.code} > -: ${sort=sort -H} > - > -sortopt="-u -T $TMPDIR" > -sortcmd="$sort" > - > -# Input already sorted > -case X"$1" in > - X-nosort|X-presort) sortcmd=cat; sortopt=;shift;; > -esac > > bigrams=`mktemp ${TMPDIR=/tmp}/_bigrams.XX` || exit 1 > trap 'rm -f $bigrams' 0 1 2 3 5 10 15 > @@ -66,8 +57,8 @@ filelist=`mktemp ${TMPDIR=/tmp}/_filelis > } > trap 'rm -f $bigrams $filelist' 0 1 2 3 5 10 15 > > -if $sortcmd $sortopt > $filelist; then > -$bigram < $filelist | $sort -nr | > +if sort -HuT "$TMPDIR" > $filelist; then > +$bigram < $filelist | sort -Hnr | > awk -Ft 'BEGIN { ORS = "" } NR <= 128 { print $2 }' > > $bigrams && > $code $bigrams < $filelist > else > > -- > Michal Mazurek -- Michal Mazurek
ksh ^T transpose-chars
In ksh(1), ^T is documented to be bounded to transpose-chars while in emacs mode, not "x_stuff". While here, remove these poorly described functions as well.. -Bryan. Index: emacs.c === RCS file: /cvs/src/bin/ksh/emacs.c,v retrieving revision 1.67 diff -u -p -u -r1.67 emacs.c --- emacs.c 12 May 2017 14:37:52 - 1.67 +++ emacs.c 20 Jun 2017 16:50:11 - @@ -185,8 +185,6 @@ static int x_search_char_forw(int); static int x_search_char_back(int); static int x_search_hist(int); static int x_set_mark(int); -static int x_stuff(int); -static int x_stuffreset(int); static int x_transpose(int); static int x_version(int); static int x_xchg_point_mark(int); @@ -244,8 +242,6 @@ static const struct x_ftab x_ftab[] = { { x_search_char_back, "search-character-backward",XF_ARG }, { x_search_hist,"search-history", 0 }, { x_set_mark, "set-mark-command", 0 }, - { x_stuff, "stuff",0 }, - { x_stuffreset, "stuff-reset", 0 }, { x_transpose, "transpose-chars", 0 }, { x_version,"version", 0 }, { x_xchg_point_mark,"exchange-point-and-mark", 0 }, @@ -1227,36 +1223,6 @@ x_error(int c) return KSTD; } -static int -x_stuffreset(int c) -{ -#ifdef TIOCSTI - (void)x_stuff(c); - return KINTR; -#else - x_zotc(c); - xlp = xcp = xep = xbp = xbuf; - xlp_valid = true; - *xcp = 0; - x_redraw(-1); - return KSTD; -#endif -} - -static int -x_stuff(int c) -{ -#ifdef TIOCSTI - charch = c; - boolsavmode = x_mode(false); - - (void)ioctl(TTY, TIOCSTI, ); - (void)x_mode(savmode); - x_redraw(-1); -#endif - return KSTD; -} - static char * kb_encode(const char *s) { @@ -1555,12 +1521,7 @@ x_init_emacs(void) kb_add(x_search_char_forw, NULL, CTRL(']'), 0); kb_add(x_search_hist, NULL, CTRL('R'), 0); kb_add(x_set_mark, NULL, CTRL('['), ' ', 0); -#if defined(TIOCSTI) - kb_add(x_stuff, NULL, CTRL('T'), 0); - /* stuff-reset */ -#else kb_add(x_transpose, NULL, CTRL('T'), 0); -#endif kb_add(x_prev_com, NULL, CTRL('P'), 0); kb_add(x_prev_com, NULL, CTRL('X'), 'A', 0); kb_add(x_fold_upper,NULL, CTRL('['), 'U', 0); Index: ksh.1 === RCS file: /cvs/src/bin/ksh/ksh.1,v retrieving revision 1.187 diff -u -p -u -r1.187 ksh.1 --- ksh.1 19 Feb 2017 22:09:18 - 1.187 +++ ksh.1 20 Jun 2017 16:50:11 - @@ -4912,14 +4912,6 @@ The history buffer retains only a finite are discarded as necessary. .It set-mark-command: ^[ Ns Aq space Set the mark at the cursor position. -.It stuff: -On systems supporting it, pushes the bound character back onto the terminal -input where it may receive special processing by the terminal handler. -This is useful for the BRL ^T mini-systat feature, for example. -.It stuff-reset: -Acts like -.Ic stuff , -then aborts input the same as an interrupt. .It transpose-chars: ^T If at the end of line, or if the .Ic gmacs
Re: ksh ^T transpose-chars
On Tue, Jun 20, 2017 at 12:51:38PM -0400, Bryan Steele wrote: > In ksh(1), ^T is documented to be bounded to transpose-chars while > in emacs mode, not "x_stuff". While here, remove these poorly > described functions as well.. This change would break any existing user defined binding to either stuff or stuff-reset (`bind key=stuff` in .kshrc for instance). However, I would like to move forward and completely zap those functions just like you proposed. ok anton@ > > -Bryan. > > Index: emacs.c > === > RCS file: /cvs/src/bin/ksh/emacs.c,v > retrieving revision 1.67 > diff -u -p -u -r1.67 emacs.c > --- emacs.c 12 May 2017 14:37:52 - 1.67 > +++ emacs.c 20 Jun 2017 16:50:11 - > @@ -185,8 +185,6 @@ static intx_search_char_forw(int); > static int x_search_char_back(int); > static int x_search_hist(int); > static int x_set_mark(int); > -static int x_stuff(int); > -static int x_stuffreset(int); > static int x_transpose(int); > static int x_version(int); > static int x_xchg_point_mark(int); > @@ -244,8 +242,6 @@ static const struct x_ftab x_ftab[] = { > { x_search_char_back, "search-character-backward",XF_ARG }, > { x_search_hist,"search-history", 0 }, > { x_set_mark, "set-mark-command", 0 }, > - { x_stuff, "stuff",0 }, > - { x_stuffreset, "stuff-reset", 0 }, > { x_transpose, "transpose-chars", 0 }, > { x_version,"version", 0 }, > { x_xchg_point_mark,"exchange-point-and-mark", 0 }, > @@ -1227,36 +1223,6 @@ x_error(int c) > return KSTD; > } > > -static int > -x_stuffreset(int c) > -{ > -#ifdef TIOCSTI > - (void)x_stuff(c); > - return KINTR; > -#else > - x_zotc(c); > - xlp = xcp = xep = xbp = xbuf; > - xlp_valid = true; > - *xcp = 0; > - x_redraw(-1); > - return KSTD; > -#endif > -} > - > -static int > -x_stuff(int c) > -{ > -#ifdef TIOCSTI > - charch = c; > - boolsavmode = x_mode(false); > - > - (void)ioctl(TTY, TIOCSTI, ); > - (void)x_mode(savmode); > - x_redraw(-1); > -#endif > - return KSTD; > -} > - > static char * > kb_encode(const char *s) > { > @@ -1555,12 +1521,7 @@ x_init_emacs(void) > kb_add(x_search_char_forw, NULL, CTRL(']'), 0); > kb_add(x_search_hist, NULL, CTRL('R'), 0); > kb_add(x_set_mark, NULL, CTRL('['), ' ', 0); > -#if defined(TIOCSTI) > - kb_add(x_stuff, NULL, CTRL('T'), 0); > - /* stuff-reset */ > -#else > kb_add(x_transpose, NULL, CTRL('T'), 0); > -#endif > kb_add(x_prev_com, NULL, CTRL('P'), 0); > kb_add(x_prev_com, NULL, CTRL('X'), 'A', 0); > kb_add(x_fold_upper,NULL, CTRL('['), 'U', 0); > Index: ksh.1 > === > RCS file: /cvs/src/bin/ksh/ksh.1,v > retrieving revision 1.187 > diff -u -p -u -r1.187 ksh.1 > --- ksh.1 19 Feb 2017 22:09:18 - 1.187 > +++ ksh.1 20 Jun 2017 16:50:11 - > @@ -4912,14 +4912,6 @@ The history buffer retains only a finite > are discarded as necessary. > .It set-mark-command: ^[ Ns Aq space > Set the mark at the cursor position. > -.It stuff: > -On systems supporting it, pushes the bound character back onto the terminal > -input where it may receive special processing by the terminal handler. > -This is useful for the BRL ^T mini-systat feature, for example. > -.It stuff-reset: > -Acts like > -.Ic stuff , > -then aborts input the same as an interrupt. > .It transpose-chars: ^T > If at the end of line, or if the > .Ic gmacs >