Re: DoS with POSIX file locks?

Miklos Szeredi
2006-03-21T06:39:53Z

> > > > Things look fairly straightforward if the accounting is done in
> > > > files_struct instead of task_struct. At least for POSIX locks. I
> > > > haven't looked at flocks or leases yet.
> > >
> > > I was thinking that would work, yes. It might not be worth worrying
> > > about accounting for leases/flocks since each process can only have one
> > > of those per open file anyway.
> >
> > Here's a minimally tested patch. The only tricky part is when the
> > unlock splits an existing lock in two.
> >
> > Also the limit checking is sloppy when the lock is split, and in that
> > case allows the counter to go one above the limit.
>
> Do you need to handle blocks as well as applied locks?

I don't think so, because each task may only have at most one block at
a time.

Miklos