From patchwork Sun Nov 20 22:22:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 23472 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1287322wrr; Sun, 20 Nov 2022 14:24:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf6xYvzp6iVJZ2jIQ1L31wfo2/UHMxbI7BmxxRODAO62fXqkGQu/50W6YXtc1Z0Vg6PyDfMU X-Received: by 2002:a17:903:40c4:b0:188:4f86:e4ea with SMTP id t4-20020a17090340c400b001884f86e4eamr2060117pld.59.1668983057110; Sun, 20 Nov 2022 14:24:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668983057; cv=none; d=google.com; s=arc-20160816; b=BD7HSzfo7y11/fBcVsJ+nG5DpMsRDwjgO9k1R852u/iVQcgZso3nvWlzjLqb/I5CIi HH+XUMJ5bJZxTNaVDx7AjllrpRQC1lL8e9KMf6kVl0E7H/J25APr856jCz8IzilGDVhZ C/8P82QDRJnVXJZGNs0gF9tENby7crCvnsb+FRf8EzsxtQYzmVI5W3dlp8xBcVWAXoQO mKArYI4bMs2bXaHfqc6w+jA1e6lNiSTsfl3HoRktcE9BS2rn1pmMvV7uBSqWHIkcXi9V TQMuhj5qcHaLstJXkcKlgvrMeLfLi5RyxkCAhw9loMaQyR1JX8I/ovvksgBnpmM3msSd FRCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=H68GQeaf2XGUVFcEuy5695f5fl8n2LfBO8R3Gb9smTQ=; b=emKa4eO5q42QdkV28zfzPyWfZXm8DCpjuOSSSzGTGHycs6qcumjR8vVhbDcCW/sgat IP9P4NaX/vUtpehJzxh0FqCHq56dJ05JCSCSLWCtXHciJijiBCkfs+G2ToFb6osF9w/1 EAz/Dqpuv7oWm1pJENGgyiiQUiefYF92ALo3VxyKYhtdbVk3R+sIbXsoYkS8SYTTi5N0 t0mZsCg9AEJEtbvFgiFkxTsa2n33yU4gscT4Vc1QKCYpOaPHH0uHutr1q0fmLsVxJONF c7zwwr4RbPkJG2T/c639z65oKBrKHps51ynfyvsz/Wjevj4pH21mMt7R7VHSj+cgiltR cedA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@iokpp.de header.s=strato-dkim-0002 header.b=GRaTRL+m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 21-20020a631355000000b00476daceffc3si6061715pgt.278.2022.11.20.14.24.04; Sun, 20 Nov 2022 14:24:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@iokpp.de header.s=strato-dkim-0002 header.b=GRaTRL+m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229833AbiKTWWl (ORCPT + 99 others); Sun, 20 Nov 2022 17:22:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229558AbiKTWWf (ORCPT ); Sun, 20 Nov 2022 17:22:35 -0500 Received: from mo4-p03-ob.smtp.rzone.de (mo4-p03-ob.smtp.rzone.de [85.215.255.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 976509FC9; Sun, 20 Nov 2022 14:22:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1668982947; s=strato-dkim-0002; d=iokpp.de; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=H68GQeaf2XGUVFcEuy5695f5fl8n2LfBO8R3Gb9smTQ=; b=GRaTRL+m39mwlfhh3aUjy6NVfKgkJ0XiuJtLdJZ/jIZxkaNKI8GNpO1AIJkLsupVbt slhuaIFHP1StBq7HUEgf9LPdstYXV34588QxmNUK7gy7+fvK24aFbQrigLJfzOSnqMV8 +6EYVCypE/kRwpqJrznnqOxH6PuBQqMlzRWGWfD6wFCJ36zFxQntXLO1Ne3rp6dsQAWF 091Z8VuVRjieTUlkQZg86p0/9mcJ8SdA9pRIamlfD5IGYLelXUk1pHxTPlS26Z6x6ogM rBzFyL6b/StsDmCumBOCUb6Pt0OL9cPKPj6NAz+1hrmjqoruowa7jOzI/S8ikEqLRJoK Qy3w== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":LmkFe0i9dN8c2t4QQyGBB/NDXvjDB6pBSedrgBzPc9DUyubU4DD1QLj68UeUr1+U1RvWtIfZ/7Q8ZGqEBlwxF4QH61wYa9UK/y81Dg==" X-RZG-CLASS-ID: mo02 Received: from blinux.speedport.ip by smtp.strato.de (RZmta 48.2.1 AUTH) with ESMTPSA id z9cfbfyAKMMRWc5 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Sun, 20 Nov 2022 23:22:27 +0100 (CET) From: Bean Huo To: alim.akhtar@samsung.com, avri.altman@wdc.com, jejb@linux.ibm.com, martin.petersen@oracle.com, stanley.chu@mediatek.com, beanhuo@micron.com, bvanassche@acm.org, tomas.winkler@intel.com, daejun7.park@samsung.com, quic_cang@quicinc.com, quic_nguyenb@quicinc.com, quic_xiaosenh@quicinc.com, quic_richardp@quicinc.com, quic_asutoshd@quicinc.com, hare@suse.de Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/6] ufs: ufs_bsg: Remove unnecessary length checkup Date: Sun, 20 Nov 2022 23:22:12 +0100 Message-Id: <20221120222217.108492-2-beanhuo@iokpp.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221120222217.108492-1-beanhuo@iokpp.de> References: <20221120222217.108492-1-beanhuo@iokpp.de> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750055578217611007?= X-GMAIL-MSGID: =?utf-8?q?1750055578217611007?= From: Bean Huo Remove checks on job->request_len and job->reply_len because The following msgcode checks will rule out malicious requests. Signed-off-by: Bean Huo Acked-by: Avri Altman --- drivers/ufs/core/ufs_bsg.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/drivers/ufs/core/ufs_bsg.c b/drivers/ufs/core/ufs_bsg.c index b99e3f3dc4ef..9ac8204f1ee6 100644 --- a/drivers/ufs/core/ufs_bsg.c +++ b/drivers/ufs/core/ufs_bsg.c @@ -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) @@ -88,8 +73,6 @@ 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; @@ -97,10 +80,6 @@ static int ufs_bsg_request(struct bsg_job *job) 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);