Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1686977pxb; Mon, 20 Sep 2021 02:54:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsa5ihyoJk08gZim6lTzu1DjfkEGzdU79wyxMO5n3G5v8TligOfHAshpswrxdoDWcXk8na X-Received: by 2002:aa7:c0c7:: with SMTP id j7mr27746034edp.58.1632131669989; Mon, 20 Sep 2021 02:54:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632131669; cv=none; d=google.com; s=arc-20160816; b=q5+QcqVoR+p47xVw6XoJszS5qfxuvJCukwF91CaArugZNVc4JQ9Ve2BUgWju3nCyCJ 9hhK+TDVsPZS+K/IYKmVaOgjJQglF+YWxxvHduMq6Cqgj3PuvSCB2CmmaSi77VoJpvPm boBilMjNftg6SszbYfMDp2pElBSLEtoD13gRhE/ZOKN95OTMYf6vo5M7+4jtpKb3rsFW 2/OD7/2GOiukZw8D5fB72H+NZaEWGWGMMDv49ShHA5FLqdYEtq+ESjAd9R8hYblYh84q 1itd0W+7Wjd/TDXLQYiWS86xTB7AZGmCV5AXHwbVr+Io0kOhwbMy0GNDRftCYAhobdUT 99UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=+MULozikGaBPcOeryZOL268+uytDq59ztNyDr7BKyrA=; b=h2uA4isqGD0WVQZitCoIz7RovC5+P52cpaYeRyZM9QxgeW6Y9/GV/hG3NZRR7T0dxh Hf8gixxXRqlYt5A8XdPQs1AGGiZxjAgfq/oDjGtQWBThOp0R1IYszwKZYAK/pta9kEDk bV8WDClOZ1N0kaQHwC5b2Ywgklh2xgIJ4eU1IgMv2rn4WnAfqiFNhoPcouDyLsKlNxpV 4vZHAnv+0BGitEiyBQg35fkarheh13JABAGPuthYwqaSxpvgRUfibF8YEKEFiHn1fwAM BLLGns5QhYVe1EklXYs8gXccbM0WG1HKrPfrm5voBOeNZ8awPxMCc8nF9iEj52xHEHOj SVBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si18605113edr.61.2021.09.20.02.54.06; Mon, 20 Sep 2021 02:54:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235567AbhITIRN (ORCPT + 99 others); Mon, 20 Sep 2021 04:17:13 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:30134 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235596AbhITIRN (ORCPT ); Mon, 20 Sep 2021 04:17:13 -0400 Received: from ironmsg09-lv.qualcomm.com ([10.47.202.153]) by alexa-out.qualcomm.com with ESMTP; 20 Sep 2021 01:15:46 -0700 X-QCInternal: smtphost Received: from ironmsg01-blr.qualcomm.com ([10.86.208.130]) by ironmsg09-lv.qualcomm.com with ESMTP/TLS/AES256-SHA; 20 Sep 2021 01:15:45 -0700 X-QCInternal: smtphost Received: from ekangupt-linux.qualcomm.com ([10.204.67.11]) by ironmsg01-blr.qualcomm.com with ESMTP; 20 Sep 2021 13:45:34 +0530 Received: by ekangupt-linux.qualcomm.com (Postfix, from userid 2319895) id B23A642C4; Mon, 20 Sep 2021 13:45:33 +0530 (IST) From: Jeya R To: linux-arm-msm@vger.kernel.org, srinivas.kandagatla@linaro.org Cc: Jeya R , gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, fastrpc.upstream@qti.qualcomm.com Subject: [PATCH] misc: fastrpc: fix improper packet size calculation Date: Mon, 20 Sep 2021 13:45:31 +0530 Message-Id: <1632125731-18768-1-git-send-email-jeyr@codeaurora.org> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The buffer list is sorted and this is not being considered while calculating packet size. This would lead to improper copy length calculation for non-dmaheap buffers which would eventually cause sending improper buffers to DSP. Signed-off-by: Jeya R --- drivers/misc/fastrpc.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index beda610..a7e550f 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -719,16 +719,21 @@ static int fastrpc_get_meta_size(struct fastrpc_invoke_ctx *ctx) static u64 fastrpc_get_payload_size(struct fastrpc_invoke_ctx *ctx, int metalen) { u64 size = 0; - int i; + int oix = 0; size = ALIGN(metalen, FASTRPC_ALIGN); - for (i = 0; i < ctx->nscalars; i++) { + for (oix = 0; oix < ctx->nbufs; oix++) { + int i = ctx->olaps[oix].raix; + + if (ctx->args[i].length == 0) + continue; + if (ctx->args[i].fd == 0 || ctx->args[i].fd == -1) { - if (ctx->olaps[i].offset == 0) + if (ctx->olaps[oix].offset == 0) size = ALIGN(size, FASTRPC_ALIGN); - size += (ctx->olaps[i].mend - ctx->olaps[i].mstart); + size += (ctx->olaps[oix].mend - ctx->olaps[oix].mstart); } } -- 2.7.4