lkml.org 
[lkml]   [2012]   [Aug]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] fs: Preserve error code in get_empty_filp()
From
Hi

On Tue, Aug 21, 2012 at 3:06 AM, Jan Engelhardt <jengelh@inai.de> wrote:
>
>
> On Wednesday 2012-08-01 20:19, anatol.pomozov@gmail.com wrote:
> >Allocating a file structure in function get_empty_filp() might fail
> > because
> >of several reasons:
> > - not enough memory for file structures
> > - operation is not allowed
> > - user is over its limit
> >
> >Currently the function returns NULL in all cases and we loose the exact
> >reason of the error. All callers of get_empty_filp() assume that the
> > function
> >can fail with ENFILE only.
> >
> >Return error through pointer. Change all callers to preserve this error
> > code.
>
> > percpu_counter_inc(&nr_files);
> > f->f_cred = get_cred(cred);
> >- if (security_file_alloc(f))
> >+ if (security_file_alloc(f)) {
> >+ error = -EPERM;
> > goto fail_sec;
> >+ }
>
> You are not preserving the error code from security_file_alloc here.
>
> In particular, apparmoar/lsm.c: file_alloc_security can return -ENOMEM,
> for example.

Yep, this was a bug in the first version of the patch. It the latest
version (from Aug 2) it is fixed, please review this version instead.


\
 
 \ /
  Last update: 2012-08-21 16:21    [W:0.078 / U:0.580 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site