Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3437304pxj; Mon, 7 Jun 2021 10:32:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyw2S6+U4fLwigJ1nQvGaSJEm1qDA0Y3fCGf5VUiyaTWoz6SINj1eKu0Q9cIiRFpbgEs6oM X-Received: by 2002:a17:906:c0da:: with SMTP id bn26mr19150677ejb.437.1623087159522; Mon, 07 Jun 2021 10:32:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623087159; cv=none; d=google.com; s=arc-20160816; b=TK1UpTUQmd0li34IvE3YxGT53Bnb7Wxf7XSMXHzOhrKuJssJJZls4nzEO1NVao+PR2 D881zrd0TV02LwilVyLYMOwLdXe5GLINGcyoimqMFKaPL0lKRqJk+EJqKWj9i62o4lZW jsc1IwEX2Y5p3iF6Mbk8JFL2cvfJU8yUtDBQZMHxAg72eNSrDvSaFYM+Yq45/I2bs3ua qn8o10HTT+pNtoCOIuw23fQD39uCxXL+U5W6/7drontOeHm5O+5P/DeQsINY9wa+IdzP Vc2LnuWb1OY90xBHs7DHRsQikawOc1MszPYiL4cB0Vm7n5lHcZ5fPrteA1a0dsjUl4YC oHQw== 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=CDVD7M01wEBcqMQ1jQJ1wiIBy36JXvQyVTr33SbnrQA=; b=bQy/hqfIvJGzhs171/U/O6dHPiAMMM7I3hwbiIW97Rt8Xg3OZSBopEmA4myOLi+THf YtgQyLJW/wHLjLICv6ariaFCswwVTAx1iHx4jKxNttGeGpoA7j+ALdfyUBdDeyOsN4eT dogL0apuFEMW32P87OqFQUti6a+CwgeLSVjV2njxb8iwXi+Rq14KUhlb6OeaEyiK5uaa uyIC0SzEP+RV5aHU2z7B9a/XG0YrwEdEXOMPsZXHcqQPBWS0ByP3dSDrOOM1tBkNAfte Rpe4+8OgW7qgOYhzaBZxdTnrcPZsNCoBA0JEvW0Z/PFav2rPUYKTwB/rEvxbhs7FWopk V4lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=TCS+yIlP; 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 g3si4514777edb.1.2021.06.07.10.32.17; Mon, 07 Jun 2021 10:32:39 -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=TCS+yIlP; 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 S230252AbhFGRcq (ORCPT + 99 others); Mon, 7 Jun 2021 13:32:46 -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 Content-Type: text/plain 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-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, 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); } -- 2.17.1