From: James Carter <jwcart2@gmail.com>
To: Jie Lu <lujie54@huawei.com>
Cc: selinux@vger.kernel.org
Subject: Re: [PATCH] libselinux:add check for malloc
Date: Fri, 16 Dec 2022 17:01:15 -0500 [thread overview]
Message-ID: <CAP+JOzTmd6Vqct2HVzKJ8N4DJXw8sg_0Fs6HWst56Ur=vLuvdQ@mail.gmail.com> (raw)
In-Reply-To: <CAP+JOzSa5KU90uwNt3d16WKQudo_zDDbruHaVzUa1d67-gtcVw@mail.gmail.com>
On Fri, Dec 16, 2022 at 9:15 AM James Carter <jwcart2@gmail.com> wrote:
>
> On Tue, Nov 29, 2022 at 9:45 AM Jie Lu <lujie54@huawei.com> wrote:
> >
> > Add return check for regex_data_create() to avoid NULL reference of regex_data
> >
> > (gdb) bt
> > #0 0x00007fbde5caec14 in pthread_mutex_init () from /usr/lib64/libc.so.6
> > #1 0x00007fbde5e3a489 in regex_data_create () at regex.c:260
> > #2 0x00007fbde5e3a4af in regex_prepare_data (regex=regex@entry=0x7fbde4613770, pattern_string=pattern_string@entry=0x563c6799a820 "^/home$", errordata=errordata@entry=0x7ffeb83fa950) at regex.c:76
> > #3 0x00007fbde5e32fe6 in compile_regex (errbuf=0x0, spec=0x7fbde4613748) at label_file.h:407
> > #4 lookup_all (key=0x563c679974e5 "/var/log/kadmind.log", type=<optimized out>, partial=partial@entry=false, match_count=match_count@entry=0x0, rec=<optimized out>, rec=<optimized out>)
> > at label_file.c:949
> > #5 0x00007fbde5e33350 in lookup (rec=<optimized out>, key=<optimized out>, type=<optimized out>) at label_file.c:1092
> > #6 0x00007fbde5e31878 in selabel_lookup_common (rec=0x563c67998cc0, translating=1, key=<optimized out>, type=<optimized out>) at label.c:167
> >
> > Signed-off-by: Jie Lu <lujie54@huawei.com>
>
> Acked-by: James Carter <jwcart2@gmail.com>
>
Merged.
Thanks,
Jim
> > ---
> > libselinux/src/regex.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/libselinux/src/regex.c b/libselinux/src/regex.c
> > index 73987d9f..149a7973 100644
> > --- a/libselinux/src/regex.c
> > +++ b/libselinux/src/regex.c
> > @@ -257,6 +257,9 @@ struct regex_data *regex_data_create(void)
> > {
> > struct regex_data *regex_data =
> > (struct regex_data *)calloc(1, sizeof(struct regex_data));
> > + if (!regex_data)
> > + return NULL;
> > +
> > __pthread_mutex_init(®ex_data->match_mutex, NULL);
> > return regex_data;
> > }
> > --
> > 2.27.0
> >
prev parent reply other threads:[~2022-12-16 22:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-29 12:00 [PATCH] libselinux:add check for malloc Jie Lu
2022-12-16 14:15 ` James Carter
2022-12-16 22:01 ` James Carter [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAP+JOzTmd6Vqct2HVzKJ8N4DJXw8sg_0Fs6HWst56Ur=vLuvdQ@mail.gmail.com' \
--to=jwcart2@gmail.com \
--cc=lujie54@huawei.com \
--cc=selinux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).