From patchwork Mon Jun 7 17:30:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12304217 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6AE63C4743F for ; Mon, 7 Jun 2021 17:30:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E7BB61090 for ; Mon, 7 Jun 2021 17:30:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231493AbhFGRco (ORCPT ); Mon, 7 Jun 2021 13:32:44 -0400 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:51855 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230241AbhFGRcn (ORCPT ); Mon, 7 Jun 2021 13:32:43 -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 157HLm45016429; Mon, 7 Jun 2021 19:30:41 +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=CDVD7M01wEBcqMQ1jQJ1wiIBy36JXvQyVTr33SbnrQA=; b=TCS+yIlPZ3nZHhJ2ddQo5a2U9wsmio3ScCG4ItnrJ5iZFrdWREh0RrlxhvsgfX/zfaby 8ZU/1+jfQrcbQH81IrC4fA1VY+NVvM8ahWMU4HEe4ZiccuAHU9qvuTOsyZHAXoToabZ+ rBta0+2XLFzZywO7WM/zvq+X5N5bBSNumN8hJwVtAccpWbL+9uzhZlVA43FuSKXQqAvl RGJlHoHZRv1vAbyvtpVljHC+m3bIL42E76NwOEGL79u6YazMe+wGP40SkTkVdoPsO59G Kz+cgldl4UDvt5tp7/orOBIToCyhynO8wJlDsIpEsqylFY3l4gD7uYQaBop3bBRf/NLH 0w== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 391evfbb2a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 07 Jun 2021 19:30:41 +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 9E77C10002A; Mon, 7 Jun 2021 19:30:40 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 8585D2142B6; Mon, 7 Jun 2021 19:30:40 +0200 (CEST) Received: from localhost (10.75.127.49) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 7 Jun 2021 19:30:40 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , , Subject: [PATCH 4/4] rpmsg: char: Return error if user tries to destroy a default endpoint. Date: Mon, 7 Jun 2021 19:30:32 +0200 Message-ID: <20210607173032.30133-5-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210607173032.30133-1-arnaud.pouliquen@foss.st.com> References: <20210607173032.30133-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.49] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) 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-06-07_14:2021-06-04,2021-06-07 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@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, 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 3b850b218eb0..8c78a5a192c1 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -285,6 +285,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); }