linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nvme-tcp: Fix implicit padding in struct nvme_tcp_term_pdu
@ 2023-03-20 11:21 Geert Uytterhoeven
  2023-03-20 15:34 ` Caleb Sander
  0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2023-03-20 11:21 UTC (permalink / raw)
  To: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg
  Cc: Arnd Bergmann, linux-nvme, linux-m68k, linux-kernel, Geert Uytterhoeven

On m68k:

    drivers/nvme/host/tcp.c: In function ‘nvme_tcp_init_module’:
    include/linux/compiler_types.h:397:38: error: call to ‘__compiletime_assert_723’ declared with attribute error: BUILD_BUG_ON failed: sizeof(struct nvme_tcp_term_pdu) != 24

Indeed, on m68k the minimum alignment is 2 bytes, not 4 bytes, thus
triggering the check added in commit 7e87965d3807ab1f ("nvme-tcp: add
nvme-tcp pdu size build protection"), and indicating that NVMe over
Fabrics TCP on m68k must be incompatible with other platforms.

Fix this by adding explicit padding.

Fixes: fc221d05447aa6db ("nvme-tcp: Add protocol header")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 include/linux/nvme-tcp.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/nvme-tcp.h b/include/linux/nvme-tcp.h
index 75470159a194d97f..ba8f82672e39730f 100644
--- a/include/linux/nvme-tcp.h
+++ b/include/linux/nvme-tcp.h
@@ -115,6 +115,7 @@ struct nvme_tcp_icresp_pdu {
 struct nvme_tcp_term_pdu {
 	struct nvme_tcp_hdr	hdr;
 	__le16			fes;
+	__u8			rsvd2[2];
 	__le32			fei;
 	__u8			rsvd[8];
 };
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] nvme-tcp: Fix implicit padding in struct nvme_tcp_term_pdu
  2023-03-20 11:21 [PATCH] nvme-tcp: Fix implicit padding in struct nvme_tcp_term_pdu Geert Uytterhoeven
@ 2023-03-20 15:34 ` Caleb Sander
  2023-03-20 15:39   ` Geert Uytterhoeven
  0 siblings, 1 reply; 3+ messages in thread
From: Caleb Sander @ 2023-03-20 15:34 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
	Arnd Bergmann, linux-nvme, linux-m68k, linux-kernel

The nvme_tcp_term_pdu definition needs to be updated anyways to match
the spec. FEI is at offset 10, so it isn't 4-byte-aligned. I think we
have gotten away with this so far because the NVMe/TCP driver never
sends H2CTermReq and doesn't interpret C2HTermReq.
Mirroring numdl/numdu in nvme_get_log_page_command, the definition
should look something like:
struct nvme_tcp_term_pdu {
        struct nvme_tcp_hdr hdr;
        __le16 fes;
        __le16 feil;
        __le16 feiu;
        __u8 rsvd[10];
};

Best,
Caleb

On Mon, Mar 20, 2023 at 4:29 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> On m68k:
>
>     drivers/nvme/host/tcp.c: In function ‘nvme_tcp_init_module’:
>     include/linux/compiler_types.h:397:38: error: call to ‘__compiletime_assert_723’ declared with attribute error: BUILD_BUG_ON failed: sizeof(struct nvme_tcp_term_pdu) != 24
>
> Indeed, on m68k the minimum alignment is 2 bytes, not 4 bytes, thus
> triggering the check added in commit 7e87965d3807ab1f ("nvme-tcp: add
> nvme-tcp pdu size build protection"), and indicating that NVMe over
> Fabrics TCP on m68k must be incompatible with other platforms.
>
> Fix this by adding explicit padding.
>
> Fixes: fc221d05447aa6db ("nvme-tcp: Add protocol header")
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
>  include/linux/nvme-tcp.h | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/include/linux/nvme-tcp.h b/include/linux/nvme-tcp.h
> index 75470159a194d97f..ba8f82672e39730f 100644
> --- a/include/linux/nvme-tcp.h
> +++ b/include/linux/nvme-tcp.h
> @@ -115,6 +115,7 @@ struct nvme_tcp_icresp_pdu {
>  struct nvme_tcp_term_pdu {
>         struct nvme_tcp_hdr     hdr;
>         __le16                  fes;
> +       __u8                    rsvd2[2];
>         __le32                  fei;
>         __u8                    rsvd[8];
>  };
> --
> 2.34.1
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] nvme-tcp: Fix implicit padding in struct nvme_tcp_term_pdu
  2023-03-20 15:34 ` Caleb Sander
@ 2023-03-20 15:39   ` Geert Uytterhoeven
  0 siblings, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2023-03-20 15:39 UTC (permalink / raw)
  To: Caleb Sander
  Cc: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
	Arnd Bergmann, linux-nvme, linux-m68k, linux-kernel

Hi Caleb,

On Mon, Mar 20, 2023 at 4:34 PM Caleb Sander <csander@purestorage.com> wrote:
> The nvme_tcp_term_pdu definition needs to be updated anyways to match
> the spec. FEI is at offset 10, so it isn't 4-byte-aligned. I think we
> have gotten away with this so far because the NVMe/TCP driver never
> sends H2CTermReq and doesn't interpret C2HTermReq.
> Mirroring numdl/numdu in nvme_get_log_page_command, the definition
> should look something like:
> struct nvme_tcp_term_pdu {
>         struct nvme_tcp_hdr hdr;
>         __le16 fes;
>         __le16 feil;
>         __le16 feiu;
>         __u8 rsvd[10];
> };

Great, so it was compliant only on m68k? ;-)

> On Mon, Mar 20, 2023 at 4:29 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> >
> > On m68k:
> >
> >     drivers/nvme/host/tcp.c: In function ‘nvme_tcp_init_module’:
> >     include/linux/compiler_types.h:397:38: error: call to ‘__compiletime_assert_723’ declared with attribute error: BUILD_BUG_ON failed: sizeof(struct nvme_tcp_term_pdu) != 24
> >
> > Indeed, on m68k the minimum alignment is 2 bytes, not 4 bytes, thus
> > triggering the check added in commit 7e87965d3807ab1f ("nvme-tcp: add
> > nvme-tcp pdu size build protection"), and indicating that NVMe over
> > Fabrics TCP on m68k must be incompatible with other platforms.
> >
> > Fix this by adding explicit padding.
> >
> > Fixes: fc221d05447aa6db ("nvme-tcp: Add protocol header")
> > Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> > ---
> >  include/linux/nvme-tcp.h | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/include/linux/nvme-tcp.h b/include/linux/nvme-tcp.h
> > index 75470159a194d97f..ba8f82672e39730f 100644
> > --- a/include/linux/nvme-tcp.h
> > +++ b/include/linux/nvme-tcp.h
> > @@ -115,6 +115,7 @@ struct nvme_tcp_icresp_pdu {
> >  struct nvme_tcp_term_pdu {
> >         struct nvme_tcp_hdr     hdr;
> >         __le16                  fes;
> > +       __u8                    rsvd2[2];
> >         __le32                  fei;
> >         __u8                    rsvd[8];
> >  };

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-20 15:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-20 11:21 [PATCH] nvme-tcp: Fix implicit padding in struct nvme_tcp_term_pdu Geert Uytterhoeven
2023-03-20 15:34 ` Caleb Sander
2023-03-20 15:39   ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).