Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4167819rdb; Mon, 11 Dec 2023 10:40:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IFoF5qH7FXX0lwRT4giPwG7q1Q+A4W+QnCAKNWD9Gla6wf/gF36oJAE6b0qnCAPuyXHgY+l X-Received: by 2002:a05:6358:c696:b0:170:67b3:6d97 with SMTP id fe22-20020a056358c69600b0017067b36d97mr5099255rwb.32.1702320037350; Mon, 11 Dec 2023 10:40:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702320037; cv=none; d=google.com; s=arc-20160816; b=07558CzWjetwR1yWGR4tLkU4ecyZEXSP74xajHwOfLH+HU2UVic7e26VAreR7Lt1R+ fLtr85IeUXnYcGpg+cfAt570u47k0B9fZbPEm2H8Z3+E5N/KgOyNJ/9fQs3zic/bm6Sr iSfPdIO7U2p52lFGpKYf8CBnNyF5FpCSEOZtzUFDb1PvZ/sW3UfXMc50qBQ26ixKPVsI UVUjL00zGdndyl3JErpZdxdJDe3F6R/18qRatnAeWGixvyga843+gfxgP6zVTUYTAGAG LubnHcVr24ZslnsGwWbblG7n7fMpmPPx6A5M4/bk3uAc1qE8JrPPvzfV0z8LtpK/boss tA0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MRRNuQONWClYR4eBG1E1+q5vj4Ilwq/AJXvmsCIPt34=; fh=9UkjxMLj03FYQ88GpzKLR/qQlPm1lk7HpDYVYQ3Btkc=; b=BrIQmCU8EtEKRAX9+iQM6XyzwHbxUY6x1V94AvEwklj5BFZQQdakTWl7YfWDZFF07a 0bsokJQ3pNyYJvHypbraNCe/FY1Dgm6K5J6zJ+9mTvFcDlzYdd0c4HfFyt8/tnSGfVAk n0oFpmXLyAnxHuTuo4gYUmoB6WvEekn0MWwY727vY+NkeFDldaH9dJDkkJaShQrMvb2w 7QS9QBStDgqZClP3EWq9Fo5395ZwQ1h3iNFIgNl+0SowCBJwrLbgBAlq5mw6LNR9l954 3jVBApbWp2l4L6wQUzYhU84T6MxcKWcr1CdtB4eEAkeakS8e25Bt6CI/cgjNDF7pEYpo 1fhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=TpTbgBZV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id k1-20020a63d841000000b005b935872b48si6257527pgj.537.2023.12.11.10.40.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 10:40:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=TpTbgBZV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id C6A7C8041302; Mon, 11 Dec 2023 10:40:33 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345363AbjLKSkQ (ORCPT + 99 others); Mon, 11 Dec 2023 13:40:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345340AbjLKSkP (ORCPT ); Mon, 11 Dec 2023 13:40:15 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41D72AC; Mon, 11 Dec 2023 10:40:20 -0800 (PST) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BBDsDtl001856; Mon, 11 Dec 2023 18:40:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=qcppdkim1; bh=MRRNuQONWClYR4eBG1E1+ q5vj4Ilwq/AJXvmsCIPt34=; b=TpTbgBZV02G9wloAMA/MpC3qVzdVI6IdPGdNK UZD6tP4og3gwEuqbZ6knulcUx7EI5JDXi88lbVUVD36k9foS/MLAOG0U4MFCOtkZ SfQjZJRmHO0wHM7YxuASCmNWclnLGNc6cnXa3aXl7AkeDvfv18qWejU6VvI52xKW SO3wYAp83geuA1uniGSPiJ+cOcv+cdyE2Y+cBe+ST9WgqkPI/BOVDfclOAFNZw4D 6zZAqBcNeBsu39hy6+1V1QrLhpABpLC83ZZo9oPo0IMAkzahhHA7KgO0qK0mwCoK JwPZvLVll7j3B4DgpoLNIsTV6ctVXSK8oafDcWXNnVFL77Vng== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3ux28s8wau-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Dec 2023 18:40:12 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3BBIeBgM014042 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Dec 2023 18:40:11 GMT Received: from hu-bjorande-lv.qualcomm.com (10.49.16.6) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Mon, 11 Dec 2023 10:40:11 -0800 Date: Mon, 11 Dec 2023 10:40:10 -0800 From: Bjorn Andersson To: Hardevsinh Palaniya CC: , , Konrad Dybcio , Mathieu Poirier , , , Subject: Re: [PATCH] rpmsg: glink: Fix buffer overflow Message-ID: <20231211184010.GM1766637@hu-bjorande-lv.qualcomm.com> References: <20231211160221.2843339-1-hardevsinh.palaniya@siliconsignals.io> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20231211160221.2843339-1-hardevsinh.palaniya@siliconsignals.io> X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01a.na.qualcomm.com (10.47.209.196) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: e8VfhhdK2sZICJzW7tRnNXJOMb_xuMQ5 X-Proofpoint-GUID: e8VfhhdK2sZICJzW7tRnNXJOMb_xuMQ5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_01,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 clxscore=1011 lowpriorityscore=0 suspectscore=0 adultscore=0 malwarescore=0 bulkscore=0 mlxscore=0 phishscore=0 spamscore=0 mlxlogscore=397 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312110154 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 11 Dec 2023 10:40:34 -0800 (PST) On Mon, Dec 11, 2023 at 09:32:20PM +0530, Hardevsinh Palaniya wrote: > In qcom_glink_send_open_req() remove error: strcpy() 'channel->name' > too large for 'req.name' (1010102 vs 32) > As far as I can tell, channel->name comes from the struct rpmsg_channel_info->name, which is a 32-byte array, and all code paths I can find either uses strscpy() or explicitly NUL-terminates this string. I'm curious to know which path took us here. > Signed-off-by: Hardevsinh Palaniya > > diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c > index 82d460ff4777..2d6a592e1c72 100644 > --- a/drivers/rpmsg/qcom_glink_native.c > +++ b/drivers/rpmsg/qcom_glink_native.c > @@ -479,7 +479,7 @@ static int qcom_glink_send_open_req(struct qcom_glink *glink, > req.msg.cmd = cpu_to_le16(GLINK_CMD_OPEN); > req.msg.param1 = cpu_to_le16(channel->lcid); > req.msg.param2 = cpu_to_le32(name_len); > - strcpy(req.name, channel->name); > + strscpy_pad(req.name, channel->name, sizeof(req.name)); I think this patch is incomplete. While it makes sure we don't overwrite the stack. name_len is strlen(channel->name) + 1 and the amount of data sent out is based on name_len. As such, if you can get here with a @name of arbitrary length, then you can control how much of the stack we're going to now leak to the recipient. Regards, Bjorn > > ret = qcom_glink_tx(glink, &req, req_len, NULL, 0, true); > if (ret) > -- > 2.25.1 > >