[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200402185320.GA8077@duo.ucw.cz>
Date: Thu, 2 Apr 2020 20:53:21 +0200
From: Pavel Machek <pavel@...x.de>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: linux-kernel@...r.kernel.org, stable@...r.kernel.org,
Maciej Żenczykowski <maze@...gle.com>,
John Stultz <john.stultz@...aro.org>,
Alexander Potapenko <glider@...gle.com>,
Alistair Delva <adelva@...gle.com>,
Daniel Borkmann <daniel@...earbox.net>,
Yonghong Song <yhs@...com>
Subject: Re: [PATCH 4.19 105/116] bpf: Explicitly memset the bpf_attr
structure
Hi!
> From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
>
> commit 8096f229421f7b22433775e928d506f0342e5907 upstream.
>
> For the bpf syscall, we are relying on the compiler to properly zero out
> the bpf_attr union that we copy userspace data into. Unfortunately that
> doesn't always work properly, padding and other oddities might not be
> correctly zeroed, and in some tests odd things have been found when the
> stack is pre-initialized to other values.
>
> Fix this by explicitly memsetting the structure to 0 before using
> it.
Is not that a gcc bug? I mean, that's seriously unhelpful behaviour
from security perspective.
Is there any reason to believe this is not causing problems elsewhere?
$ grep -ri "= {}" . | wc -l
2152
I'm pretty sure many of these are before return to userspace... I
picked one at random:
./drivers/media/cec/cec-api.c-static long cec_adap_g_caps(struct cec_adapter *adap,
./drivers/media/cec/cec-api.c- struct cec_caps __user *parg)
./drivers/media/cec/cec-api.c-{
./drivers/media/cec/cec-api.c: struct cec_caps caps = {};
./drivers/media/cec/cec-api.c-
./drivers/media/cec/cec-api.c- strscpy(caps.driver, adap->devnode.dev.parent->driver->name,
./drivers/media/cec/cec-api.c- sizeof(caps.driver));
./drivers/media/cec/cec-api.c- strscpy(caps.name, adap->name, sizeof(caps.name));
./drivers/media/cec/cec-api.c- caps.available_log_addrs = adap->available_log_addrs;
./drivers/media/cec/cec-api.c- caps.capabilities = adap->capabilities;
./drivers/media/cec/cec-api.c- caps.version = LINUX_VERSION_CODE;
./drivers/media/cec/cec-api.c- if (copy_to_user(parg, &caps, sizeof(caps)))
./drivers/media/cec/cec-api.c- return -EFAULT;
./drivers/media/cec/cec-api.c- return 0;
./drivers/media/cec/cec-api.c-}
Should we fix gcc, instead?
Best regards,
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Download attachment "signature.asc" of type "application/pgp-signature" (196 bytes)
Powered by blists - more mailing lists