cxl/mbox: Restore signedness to a mailbox payload variable
[email protected]
maintainerPATCH v2 1/1 cxl/mbox: Restore signedness to a mailbox payload variable
From: Alison Schofield <[email protected]>
A mailbox command output size value of (-1) means that a device may return a variable sized output to that command. The device defines a maximum payload size, so the driver will allocate enough memory to receive that maximum payload for variable size mailbox commands.
A recent code refactoring discarded the signedness on 'out_size' before checking it, thereby breaking the handling of mailbox commands with variable sized output. Pass along both in_size and out_size with signedness, and only discard the signedness when building the cxl_mbox_cmd structure.
Smatch warn: unsigned 'out_size' is never less than 0
ions")
---
Changes in v2:
- Pass the payload sizes as signed rather than move the check (Dan)
- Signedness is now discarded on ssize_t to size_t assignment.
- Update commit msg. Was 'Handle variable size output while still signed'
- Update commit log.
drivers/cxl/core/mbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cxl/core/mbox.c +1 -1
@@ -253,7 +253,7 @@ static bool cxl_payload_from_user_allowed(u16 opcode, void *payload_in)static int cxl_mbox_cmd_ctor (struct cxl_mbox_cmd *mbox,struct cxl_dev_state *cxlds,u16 opcode, -size_t in_size,size_t out_size,u64 in_payload) +ssize_t in_size,ssize_t out_size,u64 in_payload) { *mbox = (struct cxl_mbox_cmd ) { .opcode = opcode,
base-commit: 7dc1d11d7abae52aada5340fb98885f0ddbb7c37
Signature · 1 line
2.31.1
Quoted 14 lines · On 22-04-13 12:13:11, [email protected] wrote:
From: Alison Schofield <[email protected]>
A mailbox command output size value of (-1) means that a device may return a variable sized output to that command. The device defines a maximum payload size, so the driver will allocate enough memory to receive that maximum payload for variable size mailbox commands.
A recent code refactoring discarded the signedness on '
out_size' before checking it, thereby breaking the handling of mailbox commands with variable sized output. Pass along bothin_sizeandout_sizewith signedness, and only discard the signedness when building thecxl_mbox_cmdstructure.
Quoted 7 lines
Smatch warn: unsigned '
out_size' is never less than 0Fixes be0d0ce77aa3 ("cxl/mbox: Move build of user mailbox cmd to a helper functions")
Reported-by kernel test robot <[email protected]>Reported-by Dan Carpenter <[email protected]>Signed-off-by Alison Schofield <[email protected]>
Per internal discussion, do we want to change in_size also? I'm in favor of fixing the ABI.
[snip]
Alison Schofield
maintainerQuoted 17 lines · Ben Widawsky
Quoted 16 lines · On 22-04-13 12:13:11, [email protected] wrote:
From: Alison Schofield <[email protected]>
A mailbox command output size value of (-1) means that a device may return a variable sized output to that command. The device defines a maximum payload size, so the driver will allocate enough memory to receive that maximum payload for variable size mailbox commands.
A recent code refactoring discarded the signedness on '
out_size' before checking it, thereby breaking the handling of mailbox commands with variable sized output. Pass along bothin_sizeandout_sizewith signedness, and only discard the signedness when building thecxl_mbox_cmdstructure.Smatch warn: unsigned '
out_size' is never less than 0
Quoted 9 lines
Quoted 5 lines
Fixes be0d0ce77aa3 ("cxl/mbox: Move build of user mailbox cmd to a helper functions")
Reported-by kernel test robot <[email protected]>Reported-by Dan Carpenter <[email protected]>Signed-off-by Alison Schofield <[email protected]>Per internal discussion, do we want to change
in_sizealso? I'm in favor of fixing the ABI.
Thanks for reviewing!
OK - next version will removed the signedness from the ABI. Compare to UINT_MAX for the variable size option.
Quoted 2 lines
[snip]