diff mbox

[2/6] crypto: img-hash - Fix hash request context

Message ID 1468229616-3888-3-git-send-email-will.thomas@imgtec.com (mailing list archive)
State Changes Requested
Delegated to: Herbert Xu
Headers show

Commit Message

Will Thomas July 11, 2016, 9:33 a.m. UTC
Move 0 length buffer to end of structure to stop overwriting
fallback request data. This doesn't cause a bug itself as the
buffer is never used alongside the fallback but should be
changed.

Signed-off-by: Will Thomas <will.thomas@imgtec.com>
Reviewed-by: James Hartley <james.hartley@imgtec.com>
---
 drivers/crypto/img-hash.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Herbert Xu July 12, 2016, 7:43 a.m. UTC | #1
Will Thomas <will.thomas@imgtec.com> wrote:
> Move 0 length buffer to end of structure to stop overwriting
> fallback request data. This doesn't cause a bug itself as the
> buffer is never used alongside the fallback but should be
> changed.
> 
> Signed-off-by: Will Thomas <will.thomas@imgtec.com>
> Reviewed-by: James Hartley <james.hartley@imgtec.com>

This points out another bug, the fallback can have its own ctx
following the request.

So the set_reqsize call needs to be adjusted to take that into
account.

Thanks,
Will Thomas July 13, 2016, 2:45 p.m. UTC | #2
On 12/07/16 08:43, Herbert Xu wrote:
> Will Thomas <will.thomas@imgtec.com> wrote:
>> Move 0 length buffer to end of structure to stop overwriting
>> fallback request data. This doesn't cause a bug itself as the
>> buffer is never used alongside the fallback but should be
>> changed.
>>
>> Signed-off-by: Will Thomas <will.thomas@imgtec.com>
>> Reviewed-by: James Hartley <james.hartley@imgtec.com>
> 
> This points out another bug, the fallback can have its own ctx
> following the request.
> 
> So the set_reqsize call needs to be adjusted to take that into
> account.

Will be an additional patch in v2 to fix this.

Thanks,
Will
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/crypto/img-hash.c b/drivers/crypto/img-hash.c
index a5f270b..7fa6aa4 100644
--- a/drivers/crypto/img-hash.c
+++ b/drivers/crypto/img-hash.c
@@ -102,8 +102,10 @@  struct img_hash_request_ctx {
 	unsigned long		op;
 
 	size_t			bufcnt;
-	u8 buffer[0] __aligned(sizeof(u32));
 	struct ahash_request	fallback_req;
+
+	/* Zero length buffer must remain last member of struct */
+	u8 buffer[0] __aligned(sizeof(u32));
 };
 
 struct img_hash_ctx {