Skip to content

Commit

Permalink
scsi: ufs: bsg: Remove unnecessary length checkup
Browse files Browse the repository at this point in the history
Remove checks on job->request_len and job->reply_len because msgcode checks
in a subseqent commit will rule out malicious requests.

Signed-off-by: Bean Huo <beanhuo@micron.com>
Acked-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Bean Huo authored and Martin K. Petersen committed Dec 30, 2022
1 parent 3f5145a commit 64d4864
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions drivers/ufs/core/ufs_bsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,6 @@ static int ufs_bsg_get_query_desc_size(struct ufs_hba *hba, int *desc_len,
return 0;
}

static int ufs_bsg_verify_query_size(struct ufs_hba *hba,
unsigned int request_len,
unsigned int reply_len)
{
int min_req_len = sizeof(struct ufs_bsg_request);
int min_rsp_len = sizeof(struct ufs_bsg_reply);

if (min_req_len > request_len || min_rsp_len > reply_len) {
dev_err(hba->dev, "not enough space assigned\n");
return -EINVAL;
}

return 0;
}

static int ufs_bsg_alloc_desc_buffer(struct ufs_hba *hba, struct bsg_job *job,
uint8_t **desc_buff, int *desc_len,
enum query_opcode desc_op)
Expand Down Expand Up @@ -88,19 +73,13 @@ static int ufs_bsg_request(struct bsg_job *job)
struct ufs_bsg_request *bsg_request = job->request;
struct ufs_bsg_reply *bsg_reply = job->reply;
struct ufs_hba *hba = shost_priv(dev_to_shost(job->dev->parent));
unsigned int req_len = job->request_len;
unsigned int reply_len = job->reply_len;
struct uic_command uc = {};
int msgcode;
uint8_t *desc_buff = NULL;
int desc_len = 0;
enum query_opcode desc_op = UPIU_QUERY_OPCODE_NOP;
int ret;

ret = ufs_bsg_verify_query_size(hba, req_len, reply_len);
if (ret)
goto out;

bsg_reply->reply_payload_rcv_len = 0;

ufshcd_rpm_get_sync(hba);
Expand Down

0 comments on commit 64d4864

Please sign in to comment.