[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1c33b2c904f6055400817053504198e3bf3fad3d.camel@linux.intel.com>
Date: Tue, 18 Jun 2024 13:40:40 -0700
From: Tim Chen <tim.c.chen@...ux.intel.com>
To: Michal Hocko <mhocko@...e.com>
Cc: Mateusz Guzik <mjguzik@...il.com>, Yu Ma <yu.ma@...el.com>,
viro@...iv.linux.org.uk, brauner@...nel.org, jack@...e.cz,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
tim.c.chen@...el.com, pan.deng@...el.com, tianyou.li@...el.com
Subject: Re: [PATCH 3/3] fs/file.c: move sanity_check from alloc_fd() to
put_unused_fd()
On Tue, 2024-06-18 at 10:35 +0200, Michal Hocko wrote:
> On Mon 17-06-24 11:04:41, Tim Chen wrote:
> > diff --git a/kernel/sys.c b/kernel/sys.c
> > index 3a2df1bd9f64..b4e523728c3e 100644
> > --- a/kernel/sys.c
> > +++ b/kernel/sys.c
> > @@ -1471,6 +1471,7 @@ static int do_prlimit(struct task_struct *tsk, unsigned int resource,
> > return -EINVAL;
> > resource = array_index_nospec(resource, RLIM_NLIMITS);
> >
> > + task_lock(tsk->group_leader);
> > if (new_rlim) {
> > if (new_rlim->rlim_cur > new_rlim->rlim_max)
> > return -EINVAL;
>
> This is clearly broken as it leaves the lock behind on the error, no?
Thanks for pointing that out. Need unlock before return. I don't like
adding task_lock in alloc_fd path if there are multiple alloc_fd going
on causing contention.
The race with rlimit change should be a very rare thing. Should be
sufficient that patch one check for fd not going beyond the observed
rlimit.
Tim
Powered by blists - more mailing lists