You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/06/17 11:34:45 UTC

[nuttx] branch master updated: rpmsg: support the fdsan feature for rpmsg dev/mtd/blk

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 940bbfc720 rpmsg: support the fdsan feature for rpmsg dev/mtd/blk
940bbfc720 is described below

commit 940bbfc7208e41e95dcb282707f20acbc3165c0f
Author: wangbowen6 <wa...@xiaomi.com>
AuthorDate: Wed Jun 7 12:02:20 2023 +0800

    rpmsg: support the fdsan feature for rpmsg dev/mtd/blk
    
    Directly return -ENOTTY in rpmsgxxx_ioctl() when the command is
    not supported to avoid fdsan command FIOC_SETTAG and FIOC_GETTAG
    pass to the rpmsg dev/mtd/blk server with CONFIG_FDSAN enabled.
    
    Signed-off-by: wangbowen6 <wa...@xiaomi.com>
---
 drivers/misc/rpmsgblk.c     | 13 +++++++++----
 drivers/misc/rpmsgdev.c     | 13 +++++++++----
 drivers/mtd/rpmsgmtd.c      | 13 +++++++++----
 fs/rpmsgfs/rpmsgfs_client.c | 11 ++++++++---
 4 files changed, 35 insertions(+), 15 deletions(-)

diff --git a/drivers/misc/rpmsgblk.c b/drivers/misc/rpmsgblk.c
index 0e8ea02bb8..d54b1ebf35 100644
--- a/drivers/misc/rpmsgblk.c
+++ b/drivers/misc/rpmsgblk.c
@@ -86,7 +86,7 @@ static ssize_t rpmsgblk_write(FAR struct inode *inode,
                               blkcnt_t start_sector, unsigned int nsectors);
 static int     rpmsgblk_geometry(FAR struct inode *inode,
                                  FAR struct geometry *geometry);
-static size_t  rpmsgblk_ioctl_arglen(int cmd);
+static ssize_t rpmsgblk_ioctl_arglen(int cmd);
 static int     rpmsgblk_ioctl(FAR struct inode *inode, int cmd,
                               unsigned long arg);
 #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
@@ -499,7 +499,7 @@ out:
  *
  ****************************************************************************/
 
-static size_t rpmsgblk_ioctl_arglen(int cmd)
+static ssize_t rpmsgblk_ioctl_arglen(int cmd)
 {
   switch (cmd)
     {
@@ -527,7 +527,7 @@ static size_t rpmsgblk_ioctl_arglen(int cmd)
       case BIOC_BLKSSZGET:
         return sizeof(blksize_t);
       default:
-        return 0;
+        return -ENOTTY;
     }
 }
 
@@ -553,7 +553,7 @@ static int rpmsgblk_ioctl(FAR struct inode *inode, int cmd,
   FAR struct rpmsgblk_s *priv = (FAR struct rpmsgblk_s *)inode->i_private;
   FAR struct rpmsgblk_ioctl_s *msg;
   uint32_t space;
-  size_t arglen;
+  ssize_t arglen;
   size_t msglen;
 
   /* Sanity checks */
@@ -563,6 +563,11 @@ static int rpmsgblk_ioctl(FAR struct inode *inode, int cmd,
   /* Call our internal routine to perform the ioctl */
 
   arglen = rpmsgblk_ioctl_arglen(cmd);
+  if (arglen < 0)
+    {
+      return arglen;
+    }
+
   msglen = sizeof(*msg) + arglen - 1;
 
   msg = rpmsgblk_get_tx_payload_buffer(priv, &space);
diff --git a/drivers/misc/rpmsgdev.c b/drivers/misc/rpmsgdev.c
index a5fe49340c..3ed43a973c 100644
--- a/drivers/misc/rpmsgdev.c
+++ b/drivers/misc/rpmsgdev.c
@@ -96,7 +96,7 @@ static ssize_t rpmsgdev_write(FAR struct file *filep, FAR const char *buffer,
                               size_t buflen);
 static off_t   rpmsgdev_seek(FAR struct file *filep, off_t offset,
                              int whence);
-static size_t  rpmsgdev_ioctl_arglen(int cmd);
+static ssize_t rpmsgdev_ioctl_arglen(int cmd);
 static int     rpmsgdev_ioctl(FAR struct file *filep, int cmd,
                               unsigned long arg);
 static int     rpmsgdev_poll(FAR struct file *filep, FAR struct pollfd *fds,
@@ -616,7 +616,7 @@ static off_t rpmsgdev_seek(FAR struct file *filep, off_t offset, int whence)
  *
  ****************************************************************************/
 
-static size_t rpmsgdev_ioctl_arglen(int cmd)
+static ssize_t rpmsgdev_ioctl_arglen(int cmd)
 {
   switch (cmd)
     {
@@ -628,7 +628,7 @@ static size_t rpmsgdev_ioctl_arglen(int cmd)
       case FBIOGET_POWER:
         return sizeof(int);
       default:
-        return 0;
+        return -ENOTTY;
     }
 }
 
@@ -654,7 +654,7 @@ static int rpmsgdev_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
   FAR struct rpmsgdev_priv_s *priv;
   FAR struct rpmsgdev_ioctl_s *msg;
   uint32_t space;
-  size_t arglen;
+  ssize_t arglen;
   size_t msglen;
   int ret;
 
@@ -671,6 +671,11 @@ static int rpmsgdev_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
   /* Call our internal routine to perform the ioctl */
 
   arglen = rpmsgdev_ioctl_arglen(cmd);
+  if (arglen < 0)
+    {
+      return arglen;
+    }
+
   msglen = sizeof(*msg) + arglen - 1;
 
   msg = rpmsgdev_get_tx_payload_buffer(dev, &space);
diff --git a/drivers/mtd/rpmsgmtd.c b/drivers/mtd/rpmsgmtd.c
index 458dbd793a..a3889da490 100644
--- a/drivers/mtd/rpmsgmtd.c
+++ b/drivers/mtd/rpmsgmtd.c
@@ -85,7 +85,7 @@ static ssize_t rpmsgmtd_read(FAR struct mtd_dev_s *dev, off_t offset,
 static ssize_t rpmsgmtd_write(FAR struct mtd_dev_s *dev, off_t offset,
                               size_t nbytes, FAR const uint8_t *buffer);
 #endif
-static size_t  rpmsgmtd_ioctl_arglen(int cmd);
+static ssize_t rpmsgmtd_ioctl_arglen(int cmd);
 static int     rpmsgmtd_ioctl(FAR struct mtd_dev_s *dev, int cmd,
                               unsigned long arg);
 
@@ -548,7 +548,7 @@ out:
  *
  ****************************************************************************/
 
-static size_t rpmsgmtd_ioctl_arglen(int cmd)
+static ssize_t rpmsgmtd_ioctl_arglen(int cmd)
 {
   switch (cmd)
     {
@@ -558,7 +558,7 @@ static size_t rpmsgmtd_ioctl_arglen(int cmd)
       case MTDIOC_UNPROTECT:
         return sizeof(struct mtd_protect_s);
       default:
-        return 0;
+        return -ENOTTY;
     }
 }
 
@@ -584,7 +584,7 @@ static int rpmsgmtd_ioctl(FAR struct mtd_dev_s *dev, int cmd,
   FAR struct rpmsgmtd_s *priv = (FAR struct rpmsgmtd_s *)dev;
   FAR struct rpmsgmtd_ioctl_s *msg;
   uint32_t space;
-  size_t arglen;
+  ssize_t arglen;
   size_t msglen;
 
   /* Sanity checks */
@@ -594,6 +594,11 @@ static int rpmsgmtd_ioctl(FAR struct mtd_dev_s *dev, int cmd,
   /* Call our internal routine to perform the ioctl */
 
   arglen = rpmsgmtd_ioctl_arglen(cmd);
+  if (arglen < 0)
+    {
+      return arglen;
+    }
+
   msglen = sizeof(*msg) + arglen - 1;
 
   msg = rpmsgmtd_get_tx_payload_buffer(priv, &space);
diff --git a/fs/rpmsgfs/rpmsgfs_client.c b/fs/rpmsgfs/rpmsgfs_client.c
index d4c2d2bbf3..b2c65bbe89 100644
--- a/fs/rpmsgfs/rpmsgfs_client.c
+++ b/fs/rpmsgfs/rpmsgfs_client.c
@@ -380,7 +380,7 @@ fail:
   return ret;
 }
 
-static size_t rpmsgfs_ioctl_arglen(int cmd)
+static ssize_t rpmsgfs_ioctl_arglen(int cmd)
 {
   switch (cmd)
     {
@@ -389,7 +389,7 @@ static size_t rpmsgfs_ioctl_arglen(int cmd)
       case FIONREAD:
         return sizeof(int);
       default:
-        return 0;
+        return -ENOTTY;
     }
 }
 
@@ -567,12 +567,17 @@ off_t rpmsgfs_client_lseek(FAR void *handle, int fd,
 int rpmsgfs_client_ioctl(FAR void *handle, int fd,
                          int request, unsigned long arg)
 {
-  size_t arglen = rpmsgfs_ioctl_arglen(request);
+  ssize_t arglen = rpmsgfs_ioctl_arglen(request);
   FAR struct rpmsgfs_s *priv = handle;
   FAR struct rpmsgfs_ioctl_s *msg;
   uint32_t space;
   size_t len;
 
+  if (arglen < 0)
+    {
+      return arglen;
+    }
+
   len = sizeof(*msg) + arglen;
   msg = rpmsgfs_get_tx_payload_buffer(priv, &space);
   if (msg == NULL)