I started "doas ktrace -p <pid_of_pflogd>" after boot.

However, your clue about "...quotaon(8) could miss the trace file
vnode..." seems relevant here.  I did use "doas quotaoff /home" and
"doas quotaon -u /home" while proving to myself how the quota system
works.

The kernel didn't immediately panic after turning quotas on/off, so I
didn't think it was related.

I'd love to be able to help test/prove this patch, but I haven't been
able to reproduce it.  I've been running a script to
create/delete/modify files by the user with quota limits.  At the same
time, I've run another script to enable/disable quotas, hoping to
trigger the bug...but I haven't been able to reproduce at all.

In a perfect world, I'd have a solid repro, apply the patch, and
observe the patch prevents this... :)  In the absense of perfection
(!), I'll defer to you Visa, and others, as to this patch's efficacy.

Bryan

On Tue, Mar 31, 2020 at 3:57 PM Visa Hankala <[email protected]> wrote:
>
> On Tue, Mar 31, 2020 at 07:01:52AM +0000, Bryan Stenson wrote:
> > yes, but for an unrelated issue (lots of learning in these isolated times).
> >
> > On Tue, Mar 31, 2020 at 7:00 AM Theo de Raadt <[email protected]> wrote:
> > >
> > > Were you really performing a ktrac of pflogd?
> > >
> > > Bryan Stenson <[email protected]> wrote:
> > >
> > > > ok...found the panic call here: sys/ufs/ufs/ufs_quota.c:451.  From the
> > > > comment in the code: "On filesystems with quotas enabled, it is an
> > > > error for a file to change size and not to have a dquot structure
> > > > associated with it."
> > > >
> > > > I do have quotas enabled on /home, but limits are only set for a
> > > > single user (no groups).  Otherwise, I don't think I'm doing anything
> > > > crazy/out-of-the-ordinary.  Clearly, the kernel got here, but I'm not
> > > > sure how.
>
> How did you start ktracing pflodg? Was it done as part of the
> boot process? If so, quotaon(8) could miss the trace file vnode,
> causing the panic.
>
> The following diff might fix the bug. It makes sure that the trace file
> vnode has non-zero v_writecount. This should prevent the kernel from
> missing the vnode when turning on quotas (quotaon_vnode() skips vnodes
> whose v_writecount is zero).
>
> Index: kern/kern_ktrace.c
> ===================================================================
> RCS file: src/sys/kern/kern_ktrace.c,v
> retrieving revision 1.102
> diff -u -p -r1.102 kern_ktrace.c
> --- kern/kern_ktrace.c  23 Mar 2020 15:45:39 -0000      1.102
> +++ kern/kern_ktrace.c  31 Mar 2020 15:41:41 -0000
> @@ -83,6 +83,7 @@ ktrcleartrace(struct process *pr)
>                 pr->ps_tracevp = NULL;
>                 pr->ps_tracecred = NULL;
>
> +               vp->v_writecount--;
>                 vrele(vp);
>                 crfree(cred);
>         }
> @@ -109,6 +110,7 @@ ktrsettrace(struct process *pr, int facs
>
>         vref(newvp);
>         crhold(newcred);
> +       newvp->v_writecount++;
>
>         oldvp = pr->ps_tracevp;
>         oldcred = pr->ps_tracecred;

Reply via email to