mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 05:16:47 +08:00
fs: dup3 should pass the fdcheck & fdsan
Signed-off-by: hujun5 <hujun5@xiaomi.com> Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
+30
-1
@@ -209,6 +209,13 @@ static int nx_dup3_from_tcb(FAR struct tcb_s *tcb, int fd1, int fd2,
|
|||||||
int flags)
|
int flags)
|
||||||
{
|
{
|
||||||
FAR struct filelist *list;
|
FAR struct filelist *list;
|
||||||
|
FAR struct file *filep;
|
||||||
|
#ifdef CONFIG_FDCHECK
|
||||||
|
uint8_t f_tag_fdcheck;
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_FDSAN
|
||||||
|
uint64_t f_tag_fdsan;
|
||||||
|
#endif
|
||||||
int count;
|
int count;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -241,14 +248,36 @@ static int nx_dup3_from_tcb(FAR struct tcb_s *tcb, int fd1, int fd2,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filep = files_fget(list, fd2);
|
||||||
|
if (filep == NULL)
|
||||||
|
{
|
||||||
|
return -EBADF;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_FDSAN
|
||||||
|
f_tag_fdsan = filep->f_tag_fdsan;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_FDCHECK
|
||||||
|
f_tag_fdcheck = filep->f_tag_fdcheck;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Perform the dup3 operation */
|
/* Perform the dup3 operation */
|
||||||
|
|
||||||
ret = file_dup3(files_fget(list, fd1), files_fget(list, fd2), flags);
|
ret = file_dup3(files_fget(list, fd1), filep, flags);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_FDSAN
|
||||||
|
filep->f_tag_fdsan = f_tag_fdsan;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_FDCHECK
|
||||||
|
filep->f_tag_fdcheck = f_tag_fdcheck;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_FDCHECK
|
#ifdef CONFIG_FDCHECK
|
||||||
return fdcheck_protect(fd2);
|
return fdcheck_protect(fd2);
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -164,6 +164,16 @@ int file_dup3(FAR struct file *filep1, FAR struct file *filep2, int flags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Copy tag */
|
||||||
|
|
||||||
|
#ifdef CONFIG_FDSAN
|
||||||
|
filep2->f_tag_fdsan = filep1->f_tag_fdsan;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_FDCHECK
|
||||||
|
filep2->f_tag_fdcheck = filep1->f_tag_fdcheck;
|
||||||
|
#endif
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user