Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1466844ybp; Fri, 4 Oct 2019 15:31:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzL4wKO+wksdeZYHcYED3hSMJTG92OTteUquXBnBGZHdpEMcKDrSDUZErmWgyXKJoAgjoVa X-Received: by 2002:a17:906:d154:: with SMTP id br20mr14526958ejb.79.1570228276789; Fri, 04 Oct 2019 15:31:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570228276; cv=none; d=google.com; s=arc-20160816; b=Yqe44VRWyfEgTO/KO9yRfSk13I7QlUigqSMmzsc2qhzUnn3pN5JfMe1G3RsmGqvNwU KvOEjGncJCY7qkhRudQkQPbheoc8z3kfVDV4CkNwU70cCfmqxq9TCjynu5ynCjwv1YY3 dq+OusmiUvnSZtKu3qUs2Ztd/2MbxaW9npU29NVRK82Ql8h739P8Z/DRUaQ1HLtm56i6 V2RsVEDCsQW3xLp36SKLlx7RQ+vecDUdql4yHGQDlpU+9Hzb3l5qpwL6u6W/p2siRxDL LyvQ0hKkbqwiumIQLz9C0Je/ZjcxG8VUNC3sDZsDkl44Pa6JyBbW16CjmwlYG5T8K6Jh iPuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=QoZQF1YbSGqv09dK0KDHECoZ26zQGdAXMaDDkqK/sak=; b=Td0sWGuRQ39AUW2QnaP42Tw6Z7ewPfAO3AgGxHjoqAdGtaIUsYcu5DcWYtvYTeSSJR qCjPbXoxOM7xqKBCA5YL49+ulv9xqJydTSSDYtxjZ3HK8lrBtKfyxtx7u1RFsaa+KKR3 C0GGYwX3YdwkEof2RO4aICwtIjKNcYSsws3+386A3JzdQiueg2Rk5pjWwgz+RWLoOM2b D5+YL8buqHVqTqM1QGGi/eL0/Im5eKvXMSM/esdeTetFRyMfTyyJ28N8Qn59ZStzeFwr KMLvbxCcMtWbrzgrrvY+loOTreQOB3UQD3QYYevVtpYuQToYekEZD2It1llAQ60ziaqw tJ+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N1pFmJEh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a54si4485990edc.333.2019.10.04.15.30.53; Fri, 04 Oct 2019 15:31:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N1pFmJEh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388037AbfJDW1N (ORCPT + 99 others); Fri, 4 Oct 2019 18:27:13 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:33527 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730542AbfJDW1M (ORCPT ); Fri, 4 Oct 2019 18:27:12 -0400 Received: by mail-pf1-f196.google.com with SMTP id q10so4769272pfl.0 for ; Fri, 04 Oct 2019 15:27:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QoZQF1YbSGqv09dK0KDHECoZ26zQGdAXMaDDkqK/sak=; b=N1pFmJEh2KW227rJpCbD4242buzzbOIiY6ERrMQ9gsicebzcXfJT8NECywRZ0N5/si Tgj4n3z6k0mSjwaGIY0Sb9m/zLKF/BcICGuTagr4Zg+Au/njphRbjvNov33jKsA/Vf7Q WJF7/x1LoGppiW4Sq9F1hFhlPoIgmJwkPdEhKkhquJh7jCC02RvlcZ/+T+2suX+sWsQ8 0Q8AeMHZ0ScKasmjlFy/MbZh+z5Sjc/tD3uKcmfU+yPdrkHQHmMgRhn7Z+AutgO8kms7 M657x4K//+keOT+lxrB83va5DmkQtIz+fN8gUJr1lTqf+wsnRlzemkuwmS866ClQ9M6O 2XDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QoZQF1YbSGqv09dK0KDHECoZ26zQGdAXMaDDkqK/sak=; b=PvWv2WAJK7JWYjilN66uY7bmCRi8BDRk9JvuJlwZ63gZVEhDRX2TeTzr8OqWDfDAN0 n1iBtEaAr1zc+5oLAGN5EyQVbeTks1rfDHc3TwZED0yeEpqd86ZIXxjlj7WVG8rWqWlw 3l+hO01I+qfW7lGeeUmWjwgRZLnDpym77KX+Dddhn6gFwMVb9M4KvJZPqy0UTcN64tBI Z3Jbad4I8090qCZjrsabX/GtoWA8ZCORRpTrysBgjSR+TEx4H0D3q5VMIKYpxyH6Cme6 qWFMkmDcKTCOrcfYd1X9lKXsMH2jeloQLE4KiP89sEcYg/0vZRYQg0A7pfE2zj1lO5P0 SzGw== X-Gm-Message-State: APjAAAWTwxNa8WsnXXVv3SbxHRBu2DdiSUL2Zod89OT5tqEFS81gFYRc 1FTH7380/U8W//XbcHhJn5Sncw== X-Received: by 2002:a63:1420:: with SMTP id u32mr2589745pgl.62.1570228031137; Fri, 04 Oct 2019 15:27:11 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id x37sm6328136pgl.18.2019.10.04.15.27.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Oct 2019 15:27:10 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 2/6] rpmsg: glink: Fix use after free in open_ack TIMEOUT case Date: Fri, 4 Oct 2019 15:26:58 -0700 Message-Id: <20191004222702.8632-3-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20191004222702.8632-1-bjorn.andersson@linaro.org> References: <20191004222702.8632-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arun Kumar Neelakantam Extra channel reference put when remote sending OPEN_ACK after timeout causes use-after-free while handling next remote CLOSE command. Remove extra reference put in timeout case to avoid use-after-free. Fixes: b4f8e52b89f6 ("rpmsg: Introduce Qualcomm RPM glink driver") Cc: stable@vger.kernel.org Tested-by: Srinivas Kandagatla Signed-off-by: Arun Kumar Neelakantam Signed-off-by: Bjorn Andersson --- Changes since v1: - None drivers/rpmsg/qcom_glink_native.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index 9355ce26fd98..72ed671f5dcd 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -1103,13 +1103,12 @@ static int qcom_glink_create_remote(struct qcom_glink *glink, close_link: /* * Send a close request to "undo" our open-ack. The close-ack will - * release the last reference. + * release qcom_glink_send_open_req() reference and the last reference + * will be relesed after receiving remote_close or transport unregister + * by calling qcom_glink_native_remove(). */ qcom_glink_send_close_req(glink, channel); - /* Release qcom_glink_send_open_req() reference */ - kref_put(&channel->refcount, qcom_glink_channel_release); - return ret; } -- 2.18.0