[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3157734.8NJyI8pP3B@machine>
Date: Tue, 20 Oct 2020 15:05:44 +0200
From: Francis Laniel <laniel_francis@...vacyrequired.com>
To: Kees Cook <keescook@...omium.org>
Cc: Jakub Kicinski <kuba@...nel.org>, linux-hardening@...r.kernel.org,
davem@...emloft.net
Subject: Re: [RFC][PATCH v2 2/3] Modify return value of nla_strlcpy to match that of strscpy.
Le mardi 20 octobre 2020, 01:01:27 CEST Kees Cook a écrit :
> On Mon, Oct 19, 2020 at 09:43:55AM -0700, Jakub Kicinski wrote:
> > On Mon, 19 Oct 2020 17:23:30 +0200 laniel_francis@...vacyrequired.com
> >
> > wrote:
> > > -size_t nla_strlcpy(char *dst, const struct nlattr *nla, size_t dstsize)
> > > +ssize_t nla_strlcpy(char *dst, const struct nlattr *nla, size_t
> > > dstsize)
> > >
> > > {
> > >
> > > + size_t len;
> > > + ssize_t ret;
> > >
> > > size_t srclen = nla_len(nla);
> > > char *src = nla_data(nla);
> >
> > Sort local variables long to short.
>
> Specifically, "reverse christmas tree":
>
> size_t srclen = nla_len(nla);
> char *src = nla_data(nla);
> size_t len;
> ssize_t ret;
>
> > > diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
> > > index 41a55c6cbeb8..f0bf64393cbf 100644
> > > --- a/net/sched/cls_api.c
> > > +++ b/net/sched/cls_api.c
> > > @@ -223,7 +223,7 @@ static inline u32 tcf_auto_prio(struct tcf_proto
> > > *tp)
> > >
> > > static bool tcf_proto_check_kind(struct nlattr *kind, char *name)
> > > {
> > >
> > > if (kind)
> > >
> > > - return nla_strlcpy(name, kind, IFNAMSIZ) >= IFNAMSIZ;
> > > + return nla_strlcpy(name, kind, IFNAMSIZ) > 0;
> >
> > Bug.
> >
> > > memset(name, 0, IFNAMSIZ);
> > > return false;
> > >
> > > }
>
> Have you been able to exercise the changed code paths? (I would have
> expected this to immediately fail, for example.)
Unfortunately no...
As I said in the cover letter I only tested the modifications on char* and the
tcf_proto_check_kind function seems not to be called in my VM...
I will try to trigger it though!
Powered by blists - more mailing lists