arm: socfpga: mailbox: Fix off-by-one error on command length checking
Subsystems (3)
PATCH v4 1/1 arm: socfpga: mailbox: Fix off-by-one error on command length checking
A mailbox command contains 1-u32 header + arguments. The "len" variable only contains the length of the arguments, but not the 1-u32 header. Include the length of header when checking the ring buffer space to prevent off-by-one error.
---v3->v4:
- Change DWORD to u32 in commit message
- Add note len is in u32 unit in code
v2->v3:
- Update commit description.
--- arch/arm/mach-socfpga/mailbox_s10.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-socfpga/mailbox_s10.c +2 -2
@@ -55,11 +55,11 @@ static __always_inline int mbox_fill_cmd_circular_buff(u32 header, u32 len, cout =MBOX_READL (MBOX_COUT ) %MBOX_CMD_BUFFER_SIZE ;/* if command buffer is full or not enough free space -* to fit the data +* to fit the data. Note, len is in u32 unit. */ if (((cin +1 ) %MBOX_CMD_BUFFER_SIZE ) == cout || ((MBOX_CMD_BUFFER_SIZE - cin + cout -1 ) % -MBOX_CMD_BUFFER_SIZE ) < len) +MBOX_CMD_BUFFER_SIZE ) < (len +1 ))return -ENOMEM ;/* write header to circular buffer */
Signature · 1 line
2.19.0
PATCH v4 1/1 arm: socfpga: mailbox: Fix off-by-one error on command length checking
Ley Foon Tan <[email protected]> schrieb am Mi., 24. Apr. 2019, 07:21:
Quoted 8 lines
A mailbox command contains 1-u32 header + arguments. The "len" variable only contains the length of the arguments, but not the 1-u32 header. Include the length of header when checking the ring buffer space to prevent off-by-one error.
Signed-off-by Ley Foon Tan <[email protected]>Signed-off-by Chee Hong Ang <[email protected]>
---
Quoted 34 lines
v3->v4:
- Change DWORD to u32 in commit message
- Add note len is in u32 unit in code
v2->v3:
- Update commit description.--- arch/arm/mach-socfpga/mailbox_s10.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/arm/mach-socfpga/mailbox_s10.c +2
-2@@ -55,11 +55,11 @@ static __always_inline int mbox_fill_cmd_circular_buff(u32 header, u32 len, cout =MBOX_READL (MBOX_COUT ) %MBOX_CMD_BUFFER_SIZE ;/* if command buffer is full or not enough free space -* to fit the data +* to fit the data. Note, len is in u32 unit. */ if (((cin +1 ) %MBOX_CMD_BUFFER_SIZE ) == cout || ((MBOX_CMD_BUFFER_SIZE - cin + cout -1 ) % -MBOX_CMD_BUFFER_SIZE ) < len) +MBOX_CMD_BUFFER_SIZE ) < (len +1 ))return -ENOMEM ;/* write header to circular buffer */--
2.19.0
Marek Vasut
AppliedPATCH v4 1/1 arm: socfpga: mailbox: Fix off-by-one error on command length checking
In reply to Ley Foon TanQuoted 27 lines · Ley Foon Tan
A mailbox command contains 1-u32 header + arguments. The "len" variable only contains the length of the arguments, but not the 1-u32 header. Include the length of header when checking the ring buffer space to prevent off-by-one error.
Signed-off-by Ley Foon Tan <[email protected]>Signed-off-by Chee Hong Ang <[email protected]>---
v3->v4:
- Change DWORD to u32 in commit message
- Add note len is in u32 unit in code
v2->v3:
- Update commit description.--- arch/arm/mach-socfpga/mailbox_s10.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/arm/mach-socfpga/mailbox_s10.c +0
-0@@ -55,11 +55,11 @@ static __always_inline int mbox_fill_cmd_circular_buff(u32 header, u32 len, cout =MBOX_READL (MBOX_COUT ) %MBOX_CMD_BUFFER_SIZE ;/* if command buffer is full or not enough free space
arch/arm/mach-socfpga/mailbox_s10.c static __always_inline int mbox_fill_cmd_circular_buff(u32 header, u32 len, · line 65
Quoted 10 lines
arch/arm/mach-socfpga/mailbox_s10.c +2
-2-* to fit the data +* to fit the data. Note, len is in u32 unit. */ if (((cin +1 ) %MBOX_CMD_BUFFER_SIZE ) == cout || ((MBOX_CMD_BUFFER_SIZE - cin + cout -1 ) % -MBOX_CMD_BUFFER_SIZE ) < len) +MBOX_CMD_BUFFER_SIZE ) < (len +1 ))return -ENOMEM ;/* write header to circular buffer */
Applied, thanks.
Signature · 2 lines
Best regards, Marek Vasut