[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210128132721.1111920-1-snovitoll@gmail.com>
Date: Thu, 28 Jan 2021 19:27:21 +0600
From: Sabyrzhan Tasbolatov <snovitoll@...il.com>
To: penguin-kernel@...ove.sakura.ne.jp
Cc: andreyknvl@...gle.com, casey@...aufler-ca.com, jmorris@...ei.org,
linux-kernel@...r.kernel.org,
linux-security-module@...r.kernel.org, mhocko@...e.com,
serge@...lyn.com, snovitoll@...il.com,
syzbot+a71a442385a0b2815497@...kaller.appspotmail.com
Subject: Re: [PATCH v2] smackfs: restrict bytes count in smackfs write functions
> > /*
> > + * No partial write.
> > * Enough data must be present.
> > */
> > if (*ppos != 0)
> > return -EINVAL;
> > + if (count == 0 || count > PAGE_SIZE)
> > + return -EINVAL;
> >
> > data = memdup_user_nul(buf, count);
> > if (IS_ERR(data))
> >
>
> Doesn't this change break legitimate requests like
>
> char buffer[20000];
>
> memset(buffer, ' ', sizeof(buffer));
> memcpy(buffer + sizeof(buffer) - 10, "foo", 3);
> write(fd, buffer, sizeof(buffer));
>
> ?
It does, in this case. Then I need to patch another version with
whitespace stripping before, after label. I just followed the same thing
that I see in security/selinux/selinuxfs.c sel_write_enforce() etc.
It has the same memdup_user_nul() and count >= PAGE_SIZE check prior to that.
Powered by blists - more mailing lists