Re: [PATCH 1/2] kernfs: Add option to enable user xattrs

From: Tejun Heo
Date: Wed Mar 04 2020 - 11:39:27 EST


Hello,

On Tue, Mar 03, 2020 at 11:37:28AM -0800, Daniel Xu wrote:
> It looks like in fs/xattr.c:setxattr, there is already:
>
> ...
> if (size) {
> if (size > XATTR_SIZE_MAX)
> return -E2BIG;
> ...
>
> where XATTR_SIZE_MAX is defined as 64k. Do you want it even smaller?

Oh, I missed that. Order 5 allocations can still be on the big side
tho. Ideally, something like the following?

* Total number of bytes limit as the primary limit so that we can say
that for a given cgroup user xattrs don't consume more than X bytes.
We can pick an arbitrary number which is large enough for most use
cases but not too big. e.g. 128k or whatever.

* Total number of xattrs limit. Again, some arbitrary not too low, not
too high limit.

* Switch to kvmalloc() for attr allocation so that we don't have to
worry about high order allocations.

Thanks.

--
tejun