Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1427355pxy; Thu, 29 Apr 2021 06:59:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwys3Z+afwKPGqrJvHgMqqfPEsjc+Obeh8o8ppJjEuIc8JmW6qTRvrMBXCRtGMaZ+tNNaTl X-Received: by 2002:a63:231c:: with SMTP id j28mr31992189pgj.165.1619704754839; Thu, 29 Apr 2021 06:59:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619704754; cv=none; d=google.com; s=arc-20160816; b=iAUPK0hWwpsIZcoRuE2oYtj2nWjhc1euHyndQY8eSx6Zcc6dr9piEVGPNLH/dBucRy 1WDJ7z1Hw3dtnP5vg3xmPop7BFUHQh1f1meF0xFbww5XAdaclzblsoRBQmhJOPkK/Ac3 4fWjMXes38P37UEVTR9vD2BkfgxHakaK6DWS8gfs/yIrFrbhoK5SEEhvMc2diH1dnT4F J/k4p4L4m/t77XxoGoND9qe0ewfaDXbET0tURJMiijo4CvRtZ2CP0pFsdjDeooN74OXx +e+F7zoYEGoXVKdN7ywAyeomO13UFqn7gqJja55jJE7M83+CXX0EhJwoiUJZO1V7OvyF 0T5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=J0cFxw2bH7guQXoSBusLpJz9QK10xZKZUYYlRpY60N4=; b=WXPQ3knlM1kVQoAzp7jLsIXKtQXNmIaGesgboggpKYfULTOXn/Eo7LP8joTW+sZWNj FnoUviuANdxNVSxitd00dB/JXBFLMiTJ1G0BBtZcV9JQH2G8jSfdGw2NSPAndBN1EExB WLUFbh0NhoIKlEJzlUVVbdZZHnc436CQT5V8Xdi+S7PoPbGdpdph6I5n7X3+rj1JJ9K0 UikZvowLcbem5KisTnnT3QvewPAuQhxMA5Kbt9v1pZywxpxI3jgJcTbd6Edqds+cs8eS ODXCEl1uR4Ud6A0mQGiEjbOpkWNdTQO/fnnHEW9EUjLe+R2qi9xqng8VgLtqVnxK4rHo Yx7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=1tuoEC4W; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g6si2966pgb.42.2021.04.29.06.59.01; Thu, 29 Apr 2021 06:59:14 -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; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=1tuoEC4W; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239741AbhD2N4o (ORCPT + 99 others); Thu, 29 Apr 2021 09:56:44 -0400 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:49283 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238957AbhD2N4d (ORCPT ); Thu, 29 Apr 2021 09:56:33 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 13TDqNHP015754; Thu, 29 Apr 2021 15:55:38 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=J0cFxw2bH7guQXoSBusLpJz9QK10xZKZUYYlRpY60N4=; b=1tuoEC4WBVtx1ElVYUBL1i7rYvax2QmzfEl20kwZqK2ys0KK0jM/ogKXSsspv5LlVSCc 4K/cOd7u+2Bv30MzuDOTMpKioK8R0l/pudVOBNb7ssPp3/IZF0+ynlV3PmHRMnn2pxUs u8TLR3JEzWXI12vxthiyrYCF1mU1096DXsQbjrqFDRaqMqIR0Hcgqs6FRFUVV4kHzsUW MSzeYeYW8s8qn8bXk6W1RObZHPxWEEz1rTjgdXcOqGZhKjpGAQ0Y0hvHjfzQY6pPuLCc uQG5Bw07DtMkSarxdP73bWs7hzNhlyKP2QXPL94Cn1vXmpD6+eHg2FkqezxvNoATNNoF 9w== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 387wnpr6b2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Apr 2021 15:55:38 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id BE8C810002A; Thu, 29 Apr 2021 15:55:37 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id B4DAB212FA0; Thu, 29 Apr 2021 15:55:37 +0200 (CEST) Received: from localhost (10.75.127.47) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 29 Apr 2021 15:55:37 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [PATCH v3 6/6] rpmsg: char: Return error if user tries to destroy a default endpoint. Date: Thu, 29 Apr 2021 15:55:07 +0200 Message-ID: <20210429135507.8264-7-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210429135507.8264-1-arnaud.pouliquen@foss.st.com> References: <20210429135507.8264-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG3NODE3.st.com (10.75.127.9) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-04-29_07:2021-04-28,2021-04-29 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Using the RPMSG_DESTROY_EPT_IOCTL control, user application can destroy an endpoint. This patch prevents to destroy a default endpoint associated to a channel. This update is needed to manage the "rpmsg-raw" channel. In this case a default endpoint is used and destroying it without the channel does not make sense. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_char.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index 9166454c1310..f1cb352a59ed 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -282,6 +282,10 @@ static long rpmsg_eptdev_ioctl(struct file *fp, unsigned int cmd, if (cmd != RPMSG_DESTROY_EPT_IOCTL) return -EINVAL; + /* Don't allow to destroy a default endpoint. */ + if (!eptdev->rpdev || eptdev->ept == eptdev->rpdev->ept) + return -EPERM; + return rpmsg_chrdev_eptdev_destroy(&eptdev->dev, NULL); } -- 2.17.1