Skip to contentSkip to conversation

IPA_STATUS_SIZE, commit b8dc7d0eea5a7709bb534f1b3ca70d2d7de0b42c

DISCUSSION Bert Karwatzki 3 participants 4 messages May 12, 2023 – May 26, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

commit b8dc7d0eea5a7709bb534f1b3ca70d2d7de0b42c

Author: Alex Elder <[email protected]>
Date:   Wed Jan 25 14:45:39 2023 -0600

net: ipa: stop using sizeof(status)

The IPA packet status structure changes in IPA v5.0 in ways that
are
difficult to represent cleanly. As a small step toward redefining it as a parsed block of data, use a constant to define its size, rather than the size of the IPA status structure type.

introduced the IPA_STATUS_SIZE constant as a replacent for sizeof(struct ipa_status). IPA_STATUS_SIZE is defined as sizeof(__le32[4]), but sizeof(struct ipa_status) = sizeof(__le32[8]) and the newly introducded ipa_status_extract operates on 8 __le32 words, so I wondered if IPA_STATUS_SIZE is correct.

Bert Karwatzki

#1 lore raw
Quoted 12 lines · Bert Karwatzki

commit b8dc7d0eea5a7709bb534f1b3ca70d2d7de0b42c

Author: Alex Elder <[email protected]>
Date:   Wed Jan 25 14:45:39 2023 -0600

net: ipa: stop using sizeof(status)

The IPA packet status structure changes in IPA v5.0 in ways that
are
difficult to represent cleanly. As a small step toward redefining it as a parsed block of data, use a constant to define its size, rather than the size of the IPA status structure type.

Quoted 8 lines

introduced the IPA_STATUS_SIZE constant as a replacent for sizeof(struct ipa_status). IPA_STATUS_SIZE is defined as sizeof(__le32[4]), but sizeof(struct ipa_status) = sizeof(__le32[8]) and the newly introducded ipa_status_extract operates on 8 __le32 words, so I wondered if IPA_STATUS_SIZE is correct.

You are right to wonder about this. I think you have identified a bug. It is a bug that most likely almost never matters (because the status size is always proper--and not too small), but it is a bug nevertheless.

Would you like to provide a patch to fix this? Otherwise I can do that, and I'll provide credit to you:

Please let me know. Thanks for inquiring about/reporting this.

-Alex

Quoted 2 lines

Bert Karwatzki

#2 lore raw

Am Mittwoch, dem 17.05.2023 um 16:35 -0500 schrieb Alex Elder:

Quoted 31 lines · Bert Karwatzki
Quoted 18 lines

commit b8dc7d0eea5a7709bb534f1b3ca70d2d7de0b42c
Author: Alex Elder <[email protected]>
Date:   Wed Jan 25 14:45:39 2023 -0600

     net: ipa: stop using sizeof(status)

     The IPA packet status structure changes in IPA v5.0 in ways that
are
     difficult to represent cleanly.  As a small step toward redefining
     it as a parsed block of data, use a constant to define its size,
     rather than the size of the IPA status structure type.

Quoted 6 lines

introduced the IPA_STATUS_SIZE constant as a replacent for sizeof(struct ipa_status). IPA_STATUS_SIZE is defined as sizeof(__le32[4]), but sizeof(struct ipa_status) = sizeof(__le32[8])
and the newly introducded ipa_status_extract operates on 8 __le32 words, so I wondered if IPA_STATUS_SIZE is correct.

You are right to wonder about this.  I think you have identified a bug.  It is a bug that most likely almost never matters (because the status size is always proper--and not too small), but it is a bug nevertheless.

Quoted 12 lines

Would you like to provide a patch to fix this?  Otherwise I can do that, and I'll provide credit to you:

Please let me know.  Thanks for inquiring about/reporting this.

                                        -Alex

Quoted 2 lines

Bert Karwatzki

Here's the patch that addresse the issue (if there's a > in front of the first From, that seems to be a quirk of evolution ...)

From 583f35b3d91f048d413fc4f6a3b9237fc9d7efb2 Mon Sep 17 00:00:00 2001
From: Bert Karwatzki <[email protected]>
Date: Fri, 19 May 2023 00:02:55 +0200
Subject: [PATCH] Make IPA_STATUS_SIZE equal to the size of the remove struct
ipa_status.

---
 drivers/net/ipa/ipa_endpoint.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/net/ipa/ipa_endpoint.c
index 2ee80ed140b7..afa1d56d9095 100644

drivers/net/ipa/ipa_endpoint.c +1 -1
@@ -119,7 +119,7 @@ enum ipa_status_field_id {
 };
 
 /* Size in bytes of an IPA packet status structure */
-#define IPA_STATUS_SIZE			sizeof(__le32[4])
+#define IPA_STATUS_SIZE			sizeof(__le32[8])
 
 /* IPA status structure decoder; looks up field values for a structure

*/
static u32 ipa_status_extract(struct ipa *ipa, const void *data,

Signature · 3 lines
2.40.1

Bert Karwatzki
#3 lore raw
Quoted 39 lines · Bert Karwatzki

Am Mittwoch, dem 17.05.2023 um 16:35 -0500 schrieb Alex Elder:

Quoted 38 lines · Bert Karwatzki
Quoted 18 lines

commit b8dc7d0eea5a7709bb534f1b3ca70d2d7de0b42c
Author: Alex Elder <[email protected]>
Date:   Wed Jan 25 14:45:39 2023 -0600

     net: ipa: stop using sizeof(status)

     The IPA packet status structure changes in IPA v5.0 in ways
that
are
     difficult to represent cleanly.  As a small step toward
redefining
     it as a parsed block of data, use a constant to define its
size,
     rather than the size of the IPA status structure type.

Quoted 6 lines

introduced the IPA_STATUS_SIZE constant as a replacent for sizeof(struct ipa_status). IPA_STATUS_SIZE is defined as sizeof(__le32[4]), but sizeof(struct ipa_status) = sizeof(__le32[8])
and the newly introducded ipa_status_extract operates on 8 __le32 words, so I wondered if IPA_STATUS_SIZE is correct.

You are right to wonder about this.  I think you have identified a bug.  It is a bug that most likely almost never matters (because the status size is always proper--and not too small), but it is a bug nevertheless.

Would you like to provide a patch to fix this?  Otherwise I can do that, and I'll provide credit to you:

Please let me know.  Thanks for inquiring about/reporting this.

Quoted 8 lines
Quoted 5 lines

                                        -Alex

Quoted 2 lines

Bert Karwatzki

Here's the patch that addresse the issue (if there's a > in front of the first From, that seems to be a quirk of evolution ...)

Your patch looks correct, and again I really appreciate your finding and fixing it. Since the ipa_status structure is no longer defined, I might now suggest just defining the value as ((size_t)32), but that's not a big deal

To get your patch accepted, please re-send it, taking into account the following:
- Make sure your patch is based on the upstream "net" branch:
Remote: git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git
Branch: main
(For this trivial fix this might not be critical.)
- Update your subject line, something like:
[PATCH net] net: ipa: use proper value for IPA_STATUS_SIZE
Be sure to include the "net" part; it indicates that the patch is a bug fix and should be back-ported.
- Add a one or two sentence description in the patch header. Something like:
A recent commit introduced the IPA_STATUS_SIZE constant as a replacement for sizeof(struct ipa_status). IPA_STATUS_SIZE was defined as sizeof(__le32[4]) (16 bytes), which is incorrect. The actual size of that (since removed) structure was 32 bytes, or sizeof(__le32[8]). Correct the incorrect value.
- At the end, add your sign-off:

- And on the line directly above your sign-off, add a "Fixed" tag to indicate where the bug got introduced:

Fixes b8dc7d0eea5a ("net: ipa: stop using sizeof(status)")

- Address the patch message to the network maintainers, who can incorporate it into their current "net" branch, and arrange for the fix to be back-ported to older stable branches.
David S. Miller <[email protected]>
Eric Dumazet <[email protected]>
Jakub Kicinski <[email protected]>
Paolo Abeni <[email protected]>
- Carbon-copy me, and some mailing lists:
Alex Elder <[email protected]> [email protected] [email protected] [email protected]

Once I receive the updated patch (assuming everything is order), I will add my "Reviewed-by" and the network maintainers can merge it and begin the process to get it back-ported to earlier releases.

If you like, I can do all of this on your behalf. Provided you give me your sign-off (i.e., just send me a message that includes "Signed-off-by: Bert Karwatzki <[email protected]>") I can send it and will credit you for identifying the bug and sending the fix.

-Alex

Quoted 28 lines

From 583f35b3d91f048d413fc4f6a3b9237fc9d7efb2 Mon Sep 17 00:00:00 2001
From: Bert Karwatzki <[email protected]>
Date: Fri, 19 May 2023 00:02:55 +0200
Subject: [PATCH] Make IPA_STATUS_SIZE equal to the size of the remove struct
ipa_status.

---
  drivers/net/ipa/ipa_endpoint.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ipa/ipa_endpoint.c +1 -1
index 2ee80ed140b7..afa1d56d9095 100644
@@ -119,7 +119,7 @@ enum ipa_status_field_id {
  };
 
  /* Size in bytes of an IPA packet status structure */
-#define IPA_STATUS_SIZE			sizeof(__le32[4])
+#define IPA_STATUS_SIZE			sizeof(__le32[8])
 
  /* IPA status structure decoder; looks up field values for a structure
 */

static u32 ipa_status_extract(struct ipa *ipa, const void *data,