lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200422082400.GA30239@infradead.org>
Date:   Wed, 22 Apr 2020 01:24:00 -0700
From:   Christoph Hellwig <hch@...radead.org>
To:     Denis Efremov <efremov@...ux.com>
Cc:     Willy Tarreau <w@....eu>, Christoph Hellwig <hch@...radead.org>,
        linux-block@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/3] floppy: suppress UBSAN warning in setup_rw_floppy()

On Wed, Apr 22, 2020 at 11:20:23AM +0300, Denis Efremov wrote:
> What do you think about changing it this way?
> 
> struct floppy_raw_cmd {
>  
>         unsigned char rate;
>  
> -#define FD_RAW_CMD_SIZE 16
> +#define FD_RAW_CMD_SIZE 33
>  #define FD_RAW_REPLY_SIZE 16
>  
>         unsigned char cmd_count;
> -       unsigned char cmd[FD_RAW_CMD_SIZE];
> -       unsigned char reply_count;
> -       unsigned char reply[FD_RAW_REPLY_SIZE];
> +       union {
> +               struct {
> +                       unsigned char reserved[16];
> +                       unsigned char reply_count;
> +                       unsigned char reply[FD_RAW_REPLY_SIZE];
> +               };
> +               unsigned char cmd[FD_RAW_CMD_SIZE];
> +       };

I don't think we can just change FD_RAW_CMD_SIZE or cmd as that could
break userspace. But otherwise, yes something very much like that:

>  #define FD_RAW_CMD_SIZE 16
>  #define FD_RAW_REPLY_SIZE 16
> +#define FD_RAW_FULL_CMD_SIZE (FD_RAW_CMD_SIZE + 1 + FD_RAW_CMD_SIZE)
>  
>         unsigned char cmd_count;
> -       unsigned char cmd[FD_RAW_CMD_SIZE];
> -       unsigned char reply_count;
> -       unsigned char reply[FD_RAW_REPLY_SIZE];
> +       union {
> +               struct {
> +                       unsigned char cmd[FD_RAW_CMD_SIZE];
> +                       unsigned char reply_count;
> +                       unsigned char reply[FD_RAW_REPLY_SIZE];
> +               };
> +               unsigned char full_cmd[FD_RAW_FULL_CMD_SIZE];
> +       };

>         int track;
> 
> Denis
---end quoted text---

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ