diff mbox

doc: botching-up-ioctls: Make it clearer why structs must be padded

Message ID 20180502075106.7476-1-daniel.vetter@ffwll.ch (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel Vetter May 2, 2018, 7:51 a.m. UTC
This came up in discussions when reviewing drm patches.

Cc: Eric Anholt <eric@anholt.net>
Cc: linux-doc@vger.kernel.org
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

--

Aside: I wonder whether we shouldn't move this to some other place and
rst-ify it? Any good suggestions?
-Daniel
---
 Documentation/ioctl/botching-up-ioctls.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Eric Anholt May 2, 2018, 4:56 p.m. UTC | #1
Daniel Vetter <daniel.vetter@ffwll.ch> writes:

> This came up in discussions when reviewing drm patches.
>
> Cc: Eric Anholt <eric@anholt.net>
> Cc: linux-doc@vger.kernel.org
> Cc: Jonathan Corbet <corbet@lwn.net>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
>
> --
>
> Aside: I wonder whether we shouldn't move this to some other place and
> rst-ify it? Any good suggestions?
> -Daniel
> ---
>  Documentation/ioctl/botching-up-ioctls.txt | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/ioctl/botching-up-ioctls.txt b/Documentation/ioctl/botching-up-ioctls.txt
> index d02cfb48901c..883fb034bd04 100644
> --- a/Documentation/ioctl/botching-up-ioctls.txt
> +++ b/Documentation/ioctl/botching-up-ioctls.txt
> @@ -73,7 +73,9 @@ will have a second iteration or at least an extension for any given interface.
>     future extensions is going right down the gutters since someone will submit
>     an ioctl struct with random stack garbage in the yet unused parts. Which
>     then bakes in the ABI that those fields can never be used for anything else
> -   but garbage.
> +   but garbage. This is also the reason why you must explicitly pad all
> +   structures, even if you never use them in an array - the padding the compiler
> +   might insert could contain garbage.

I hadn't realized that we had this document in git, or I probably would
have written this patch.  I think this makes it clear enough how I got
vc4 and v3d wrong.  Thanks!

Reviewed-by: Eric Anholt <eric@anholt.net>
diff mbox

Patch

diff --git a/Documentation/ioctl/botching-up-ioctls.txt b/Documentation/ioctl/botching-up-ioctls.txt
index d02cfb48901c..883fb034bd04 100644
--- a/Documentation/ioctl/botching-up-ioctls.txt
+++ b/Documentation/ioctl/botching-up-ioctls.txt
@@ -73,7 +73,9 @@  will have a second iteration or at least an extension for any given interface.
    future extensions is going right down the gutters since someone will submit
    an ioctl struct with random stack garbage in the yet unused parts. Which
    then bakes in the ABI that those fields can never be used for anything else
-   but garbage.
+   but garbage. This is also the reason why you must explicitly pad all
+   structures, even if you never use them in an array - the padding the compiler
+   might insert could contain garbage.
 
  * Have simple testcases for all of the above.