Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4203607pxf; Tue, 23 Mar 2021 05:32:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJRIADY/1/ub2SaR/FeGQbrCFYvtbbH8x0FIBgGh2/FRRgaAmhdIVPZ//KaStPIHve1d/4 X-Received: by 2002:aa7:d74d:: with SMTP id a13mr4555684eds.199.1616502734012; Tue, 23 Mar 2021 05:32:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616502734; cv=none; d=google.com; s=arc-20160816; b=lLBhp0l3tixxKz5ORBVPlcu1Ol8FFBWS0erH7k6N1I/wTf5JMo+HbgqAuFbCbTkn97 pRpgL0pn7vCoaCWBNqeQBH1DHAZ1LeoHA/SkFALSx/3ZSfuNM56lrdpXtMBEJm9bI5Zd bfqPp1+oBosclLZXYkTs8veXYuKaS4lFmL6FYUs5CIHCLSzaMWOGAn3dPTXdGVQrFF2k Bu9vXyY8/gHTlxTVMHbdxkbAPmcfORSvA30C//RURz+mO6h4ucGJUpWSpWsFrwDEO2Ix E0LCgUZP+RCqv2IWDcqIYLr15hUPbeCTcnebt/nyIWU34j4CkTW2BtE0n1efclJFAzCc Ar8Q== 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=OdCGnvZvsqW8L7Hiub86e4p9kdexa74S2YJuiSUbTQU=; b=outs1okqJbuqDJUEC1ZknoenAq9KzfLudLR8sBrUcD0AwwPzeq0HzaLzPvV4Jnx5WS M4EhH/U6aT0P4MBnoRTbDmc1Yt9/JPN2kLDrXC5sQzB4JyYuhLVU7/Pol9B/WrafekEB zTiYRFLtgOpco5npmCOUh2OWpboUcgBgP7SdYWGzvO1V4Qzeud4Tj5AfkjPEkKHcFYFq IpQfFsehw4DCS6YHhl+G5EZH7lDhyuLl4Gu+4KarZyVGIPReg+iei8vhyrL+5iB4puqH CntKsA/ywaOQdPMtqiBrWiqszl2Mwz+VesLvLU23eLm1oYnXj50vKBTATt+vAbleVX18 7Flw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=M0q+gOzp; 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 y1si12863718edp.405.2021.03.23.05.31.50; Tue, 23 Mar 2021 05:32: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=M0q+gOzp; 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 S231231AbhCWM3O (ORCPT + 99 others); Tue, 23 Mar 2021 08:29:14 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:57434 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229900AbhCWM2o (ORCPT ); Tue, 23 Mar 2021 08:28:44 -0400 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 12NCM2oU026276; Tue, 23 Mar 2021 13:28:40 +0100 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=OdCGnvZvsqW8L7Hiub86e4p9kdexa74S2YJuiSUbTQU=; b=M0q+gOzpfl4fZG8SPbCI0haLW3kSHcMQl1CqV4HmcBP0rI53Wv17C41kLVrvYFNVyw65 i/hrslDQ6cGs/xxAHlIh6dL60hpDz1GxxKkpZyyr7ahSKHvyzPr3wFkqIR6K3uAOeWgs 44xjKoQnUXYp5Mthf2yzqr4jdunfnsdjuErpP5P+m51GZ2spufcuESowQWM3gcTlontI 2wa72Z6/jQtT9UQW6iMbLScxaNayjBIP+hHwhMxG9qlcrh21D7EMHoe0YV0QIkhNybsd 0ChX7wUfYjS39ZPbvc4wCH15OE3JJbF3GZfwYb/7jNVJE6kqIq+YMksjNjDo6u1A5nw5 GQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 37d8tpfata-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Mar 2021 13:28:40 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2FD8010002A; Tue, 23 Mar 2021 13:28:40 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 1FFB124CF48; Tue, 23 Mar 2021 13:28:40 +0100 (CET) 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; Tue, 23 Mar 2021 13:28:39 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH 7/7] rpmsg: char: Return error if user try to destroy a default endpoint. Date: Tue, 23 Mar 2021 13:27:37 +0100 Message-ID: <20210323122737.23035-8-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210323122737.23035-1-arnaud.pouliquen@foss.st.com> References: <20210323122737.23035-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG2NODE2.st.com (10.75.127.5) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-03-23_06:2021-03-22,2021-03-23 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 8064244f8f18..08670e94714a 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_destroy_eptdev(&eptdev->dev, NULL); } -- 2.17.1