xiaoxiang781216 commented on code in PR #20822:
URL: https://github.com/apache/nuttx/pull/20822#discussion_r4399261430


##########
fs/vfs/fs_fstat.c:
##########
@@ -252,10 +254,20 @@ int nx_fstat(int fd, FAR struct stat *buf)
   ret = file_get(fd, &filep);
   if (ret >= 0)
     {
-      /* Perform the fstat operation */
+      /* Perform the fstat operation on a local buffer.  Copy it to the
+       * caller's buffer after file_put(), so that a bad buffer faults with
+       * no file reference held.
+       */
+
+      /* Clear it first: a file system fills only some of the fields */
 
-      ret = file_fstat(filep, buf);
+      memset(&kbuf, 0, sizeof(kbuf));

Review Comment:
   why need memset?



##########
fs/vfs/fs_stat.c:
##########
@@ -202,9 +205,24 @@ int nx_stat(FAR const char *path, FAR struct stat *buf, 
int resolve)
 
   /* The perform the stat() operation on the path.  This is potentially
    * recursive if soft link support is enabled.
+   *
+   * Fill a local buffer and copy it to the caller's buffer at the end, when
+   * the inode and the path buffer are released.  A bad buffer then faults
+   * with nothing held.
+   */
+
+  /* Clear it first: a file system fills only some of the fields, and the
+   * others must not give the caller what the kernel stack held.
    */
 
-  return stat_recursive(path, buf, resolve);
+  memset(&kbuf, 0, sizeof(kbuf));

Review Comment:
   why need



##########
arch/arm64/src/common/arm64_fatal.c:
##########
@@ -73,6 +83,21 @@ struct fatal_handle_info
 static int default_debug_handler(uint64_t *regs, uint64_t far, uint64_t esr);
 static int default_fatal_handler(uint64_t *regs, uint64_t far, uint64_t esr);
 
+/****************************************************************************
+ * External Definitions
+ ****************************************************************************/
+
+#ifdef CONFIG_BUILD_KERNEL
+/* The code of memcpy() and memset() (libs/libc/machine/arm64).  They are
+ * not there if the C versions are in use.
+ */
+
+extern const char arm64_memcpy_start[] weak_data;

Review Comment:
   what's about strcpy/strlen



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to