This patch fixes https://github.com/apache/nuttx/issues/16237, where
cd'ing to a non-directory prefix of a procfs entry would succeed.
Signed-off-by: Pip Cet <pipcet@protonmail.com>
Because sync is a rather expensive operation.
While I'm here, improve the comment after the recent discussion
in https://github.com/apache/nuttx/pull/2913.
IMHO, we should not perform the sync even for O_TRUNC.
But I'm not going to propose the change for now.
Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com>
Some entries have the opendir function set to NULL, for example
g_mount_operations.
A null pointer dereference can be triggered by an
opendir("/proc/fs/blocks") for example.
Signed-off-by: Beat Küng <beat-kueng@gmx.net>
i couldn't find any documenation about this attribute.
this comment is purely based on my reading of the code.
Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com>
Add the noinstrument_function attribute to the poll_notify function
to avoid it being looped if -finstrument-functions is set to the
fs/vfs files.
Signed-off-by: Tiago Medicci Serrano <tiago.medicci@espressif.com>
examples:
There are two threads involved: thread A with a priority of 100 and
thread B with a priority of 101. Here's how they interact:
When thread A releases a semaphore, thread B is scheduled to execute
some code and may reacquire the semaphore. If no other tasks are ready,
thread A will be scheduled to run.
This continuous process can lead to a busy loop.
Thread A: Thread B:
while (nxsem_get_value(&priv->wait, &semcount) >= 0 && <---
semcount <= 0) | 2)context switch
{ 1)contex switch |
nxsem_post(&priv->wait); -------------> run some code and nxsem_wait again
}
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
Summary:
When the operating environment does not support virtio-9p and the virtio-9p server driver is not provided, -ENODEV should be returned for virtio-9p to avoid crash caused by continued execution.
Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
This fixes issue on Ubuntu 22.04 with cmake v3.22.1:
```
/usr/bin/arm-none-eabi-gcc -D-DLFS_ASSERT=DEBUGASSERT -D-DLFS_CONFIG=/home/yf/Projects/Nuttx/nuttx/fs/littlefs/lfs_vfs.h -D-DLFS_DEBUG=finfo -D-DLFS_ERROR=ferr -D-DLFS_TRACE=finfo -D-DLFS_WARN=fwarn -DLFS_ATTR_MAX=1022 -DLFS_FILE_MAX=2147483647 -DLFS_NAME_MAX=32 -D__KERNEL__ -D__NuttX__
```
It happeed when building `qemu-armv7a:rpproxy_ivshmem`.
Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
after below change merge to kernel, spin_lock() will turn off preemption by default,
but this change is not applicable to all scenarios. The locations in the kernel that
use spin_lock() extensively only require short critical sections and do not trigger
scheduling, which leads to serious performance degradation of NuttX in AMP mode.
In this PR, I try to expose similar problems and hope that each subsystem will carefully check the code coverage
https://github.com/apache/nuttx/pull/14578
|commit b69111d16a2a330fa272af8175c832e08881844b
|Author: hujun5 <hujun5@xiaomi.com>
|Date: Thu Jan 23 16:14:18 2025 +0800
|
| spinlock: add sched_lock to spin_lock_irqsave
|
| reason:
| We aim to replace big locks with smaller ones. So we will use spin_lock_irqsave extensively to
| replace enter_critical_section in the subsequent process. We imitate the implementation of Linux
| by adding sched_lock to spin_lock_irqsave in order to address scenarios where sem_post occurs
| within spin_lock_irqsave, which can lead to spinlock failures and deadlocks.
|
| Signed-off-by: hujun5 <hujun5@xiaomi.com>
Signed-off-by: chao an <anchao.archer@bytedance.com>
reason:
We decouple semcount from business logic
by using an independent counting variable,
which allows us to remove critical sections in many cases.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
* Make readv/writev implementations update struct uio
This can simplify partial result handling.
* change the error number on the overflow from EOVERFLOW to EINVAL
to match NetBSD
* add a commented out uio_offset field. I used "#if 0" here as
C comments can't nest.
* add a few helper functions
Note on uio_copyfrom/uio_copyto:
although i'm not quite happy with the "offset" functionality,
it's necessary to simplify the adaptation of some drivers like
drivers/serial/serial.c, which (ab)uses the user-supplied buffer
as a line-buffer.
Summary:
There are differences in different server implementations, so it is necessary to check whether the returned nwqid satisfies the requested number.
Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
Fixes an issue in kernel build where the user addresses passed
to accept() would be accessed when the wrong MMU mappings were
active. A crash would manifest when attempting to accept() on a
TCP server socket for instance under significant load. The accept
event handler would be called by the HP worker upon client
connection. At this point, accept_tcpsender() would attempt to
write to `addr` resulting in a page fault. Reproducibility would
depend on the current system load (num tasks or CPU stress) but
in loaded environments, it would crash almost 100% of the times.
It should be noted that Linux does this the other way around: it
operates on kernel stack allocated data and once done, it copies
them to user. This can also be a viable alternative, albeit with
one extra copy and a little extra memory.
Signed-off-by: George Poulios <gpoulios@census-labs.com>
reason:
The list->fl_files may be modified by files_extend.
If it is being modified, there will be a race condition for fl_files[l1][l2].
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Check fs_fatsecperclus' value when read from eMMC device. Return an error if it is zero.
Signed-off-by: Yinzhe Wu <Yinzhe.Wu@sony.com>
Reviewed-by: Jacky Cao <Jacky.Cao@sony.com>
Tested-by: Yinzhe Wu <Yinzhe.Wu@sony.com>
POSIX requires that the shm objects are zero-initialized. This has been broken
in some earlier commits (starting from 9af5fc5d09724a5d300bc07ce85b9ba5c01ffadd)
Also fix the flat build memory allocation to allocate both object data and payload
in the same chunk (as the comment also suggests). This saves allocations and memory
in a system with lots of shm objects.
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
Most of developers will not have the scenarios of open/close file descriptors in multi-threads,
The default option will incur additional code size overhead for such devices.
this PR will preserve the behavior before PR#13296 was introduced, and ensure that the default code size is not affected.
Note that this option will ensure the safety of access to the file
system from multi-tasks (Task A blocking rw(fd), then Task B close(fd)),
the disadvantage is that it will increase the amount of code-size,
there is no need to enable this option if the application could ensure
he file operations are safe.
Signed-off-by: chao an <anchao@lixiang.com>
After tcb is destroyed, it is very dangerous to back reference tcb through file.
This commit will perform file operations while ensuring the validity of tcb during
fsync, with will avoid tcb check in each subsystem.
Signed-off-by: chao an <anchao@lixiang.com>
Modify the kernel to use only atomic_xx and atomic64_xx interfaces,
avoiding the use of sizeof or typeof to determine the type of
atomic operations, thereby simplifying the kernel's atomic
interface operations.
Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
Because they are not expected to apply cleanly.
In that case, disable all features which require the local patches.
Note: lfs_util.patch is actually necessary regardless of
the littlefs version. It should be ok to drop it for the simplest
flat memory model configurations with a single heap though. I plan
to fix it once littlefs 2.9.4 is released.
Tested with esp32s3-devkitc:toywasm + CONFIG_FS_LITTLEFS_VERSION="v2.9.3".