From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Kishan Sandeep <sandeepkishan108@gmail.com>
Cc: netdev@vger.kernel.org, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH] netfilter: fix buffer null termination
Date: Wed, 15 Jun 2016 14:17:40 +0200 [thread overview]
Message-ID: <20160615121740.GA3088@salvia> (raw)
In-Reply-To: <CAJ3s=ND18x4g4gwVOb0G4cqRbAiF-6F341gWJK7_vumc2BLB0w@mail.gmail.com>
On Tue, Jun 14, 2016 at 09:52:49PM +0530, Kishan Sandeep wrote:
> Hi Pablo,
>
> On Tue, Jun 14, 2016 at 8:38 PM, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > Cc'ing netfilter-devel.
> >
> > On Tue, Jun 14, 2016 at 07:39:27PM +0530, Kishan Sandeep wrote:
> >> + netdev
> >>
> >> On Sat, Jun 11, 2016 at 10:18 AM, Kishan Sandeep
> >> <sandeepkishan108@gmail.com> wrote:
> >> > strncpy generally perferable fo non-terminated
> >> > fixed-width strings. For NULL termination strlcpy
> >> > is preferrable.
> >> >
> >> > Signed-off-by: Kishan Sandeep <sandeepkishan108@gmail.com>
> >> > ---
> >> > net/netfilter/xt_repldata.h | 2 +-
> >> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >> >
> >> > diff --git a/net/netfilter/xt_repldata.h b/net/netfilter/xt_repldata.h
> >> > index 8fd3241..a460211 100644
> >> > --- a/net/netfilter/xt_repldata.h
> >> > +++ b/net/netfilter/xt_repldata.h
> >> > @@ -28,7 +28,7 @@
> >> > if (tbl == NULL) \
> >> > return NULL; \
> >> > term = (struct type##_error *)&(((char *)tbl)[term_offset]); \
> >> > - strncpy(tbl->repl.name, info->name, sizeof(tbl->repl.name)); \
> >> > + strlcpy(tbl->repl.name, info->name, sizeof(tbl->repl.name)); \
> >
> > I don't think this is actually fixing anything. Tables in x_tables
> > have a known and fixed name that is defined from the kernel side, that
> > is always smaller that the buffer we have there. So are you observing
> > any real problem from there?
> >
> > Thanks.
>
> Not observed any real problem. Here the string is not NULL terminated with
> the use of strncpy - that is the problem. With the use of strlcpy we can make
> the string to terminated properly.
1) Table names set from the kernel codebase, so they are always
way smaller than that.
2) We're not expecting the addition of new tables in the future that
we result in the hypothetical problem that you indicate.
Thanks.
prev parent reply other threads:[~2016-06-15 12:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1465620484-5543-1-git-send-email-sandeepkishan108@gmail.com>
[not found] ` <CAJ3s=NBCvYnRaWcFb==vZqP1_YE6w=uKqbtBvESkCo1sED2CHg@mail.gmail.com>
2016-06-14 15:08 ` [PATCH] netfilter: fix buffer null termination Pablo Neira Ayuso
2016-06-14 16:22 ` Kishan Sandeep
2016-06-15 12:17 ` Pablo Neira Ayuso [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=20160615121740.GA3088@salvia \
--to=pablo@netfilter.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=sandeepkishan108@gmail.com \
/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).