smcinvoke: Rename size_add to smci_size_add
Rename size_add api of smcivoke driver to smci_size_add, as smcinvoke's size_add is giving redefinition error with the size_add api recently added in upstream patch 'overflow: Implement size_t saturating arithmetic helpers'. cherry-pick hash 4dab23059f51e324451b8fe02debc3df8812afd8. Change-Id: I864c3065e63f53a3f4473edc24dc96d067dbfe60 Signed-off-by: Divisha Bisht <quic_divibish@quicinc.com>
This commit is contained in:
parent
a421f676d6
commit
a4b6b7079b
@ -585,30 +585,30 @@ static struct smcinvoke_cb_txn *find_cbtxn_locked(
|
||||
}
|
||||
|
||||
/*
|
||||
* size_add saturates at SIZE_MAX. If integer overflow is detected,
|
||||
* smci_size_add saturates at SIZE_MAX. If integer overflow is detected,
|
||||
* this function would return SIZE_MAX otherwise normal a+b is returned.
|
||||
*/
|
||||
static inline size_t size_add(size_t a, size_t b)
|
||||
static inline size_t smci_size_add(size_t a, size_t b)
|
||||
{
|
||||
return (b > (SIZE_MAX - a)) ? SIZE_MAX : a + b;
|
||||
}
|
||||
|
||||
/*
|
||||
* pad_size is used along with size_align to define a buffer overflow
|
||||
* smci_pad_size is used along with smci_size_align to define a buffer overflow
|
||||
* protected version of ALIGN
|
||||
*/
|
||||
static inline size_t pad_size(size_t a, size_t b)
|
||||
static inline size_t smci_pad_size(size_t a, size_t b)
|
||||
{
|
||||
return (~a + 1) % b;
|
||||
}
|
||||
|
||||
/*
|
||||
* size_align saturates at SIZE_MAX. If integer overflow is detected, this
|
||||
* smci_size_align saturates at SIZE_MAX. If integer overflow is detected, this
|
||||
* function would return SIZE_MAX otherwise next aligned size is returned.
|
||||
*/
|
||||
static inline size_t size_align(size_t a, size_t b)
|
||||
static inline size_t smci_size_align(size_t a, size_t b)
|
||||
{
|
||||
return size_add(a, pad_size(a, b));
|
||||
return smci_size_add(a, smci_pad_size(a, b));
|
||||
}
|
||||
|
||||
static uint16_t get_server_id(int cb_server_fd)
|
||||
@ -1404,9 +1404,9 @@ static size_t compute_in_msg_size(const struct smcinvoke_cmd_req *req,
|
||||
|
||||
/* each buffer has to be 8 bytes aligned */
|
||||
while (i < OBJECT_COUNTS_NUM_buffers(req->counts))
|
||||
total_size = size_add(total_size,
|
||||
size_align(args_buf[i++].b.size, SMCINVOKE_ARGS_ALIGN_SIZE));
|
||||
|
||||
total_size = smci_size_add(total_size,
|
||||
smci_size_align(args_buf[i++].b.size,
|
||||
SMCINVOKE_ARGS_ALIGN_SIZE));
|
||||
return PAGE_ALIGN(total_size);
|
||||
}
|
||||
|
||||
@ -1434,7 +1434,7 @@ static int marshal_in_invoke_req(const struct smcinvoke_cmd_req *req,
|
||||
return 0;
|
||||
|
||||
FOR_ARGS(i, req->counts, BI) {
|
||||
offset = size_align(offset, SMCINVOKE_ARGS_ALIGN_SIZE);
|
||||
offset = smci_size_align(offset, SMCINVOKE_ARGS_ALIGN_SIZE);
|
||||
if ((offset > buf_size) ||
|
||||
(args_buf[i].b.size > (buf_size - offset)))
|
||||
goto out;
|
||||
@ -1450,7 +1450,7 @@ static int marshal_in_invoke_req(const struct smcinvoke_cmd_req *req,
|
||||
offset += args_buf[i].b.size;
|
||||
}
|
||||
FOR_ARGS(i, req->counts, BO) {
|
||||
offset = size_align(offset, SMCINVOKE_ARGS_ALIGN_SIZE);
|
||||
offset = smci_size_align(offset, SMCINVOKE_ARGS_ALIGN_SIZE);
|
||||
if ((offset > buf_size) ||
|
||||
(args_buf[i].b.size > (buf_size - offset)))
|
||||
goto out;
|
||||
@ -1507,8 +1507,8 @@ static int marshal_in_tzcb_req(const struct smcinvoke_cb_txn *cb_txn,
|
||||
user_req->op, user_req->counts);
|
||||
|
||||
FOR_ARGS(i, tzcb_req->hdr.counts, BI) {
|
||||
user_req_buf_offset = size_align(user_req_buf_offset,
|
||||
SMCINVOKE_ARGS_ALIGN_SIZE);
|
||||
user_req_buf_offset = smci_size_align(user_req_buf_offset,
|
||||
SMCINVOKE_ARGS_ALIGN_SIZE);
|
||||
tmp_arg.b.size = tz_args[i].b.size;
|
||||
if ((tz_args[i].b.offset > tzcb_req_len) ||
|
||||
(tz_args[i].b.size > tzcb_req_len - tz_args[i].b.offset) ||
|
||||
@ -1533,8 +1533,8 @@ static int marshal_in_tzcb_req(const struct smcinvoke_cb_txn *cb_txn,
|
||||
user_req_buf_offset += tmp_arg.b.size;
|
||||
}
|
||||
FOR_ARGS(i, tzcb_req->hdr.counts, BO) {
|
||||
user_req_buf_offset = size_align(user_req_buf_offset,
|
||||
SMCINVOKE_ARGS_ALIGN_SIZE);
|
||||
user_req_buf_offset = smci_size_align(user_req_buf_offset,
|
||||
SMCINVOKE_ARGS_ALIGN_SIZE);
|
||||
|
||||
tmp_arg.b.size = tz_args[i].b.size;
|
||||
if ((user_req_buf_offset > user_req->buf_len) ||
|
||||
|
Loading…
Reference in New Issue
Block a user