Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F111309727
D36703.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D36703.diff
View Options
diff --git a/sys/fs/fuse/fuse_vnops.c b/sys/fs/fuse/fuse_vnops.c
--- a/sys/fs/fuse/fuse_vnops.c
+++ b/sys/fs/fuse/fuse_vnops.c
@@ -2248,6 +2248,9 @@
case VREG:
if (vfs_isrdonly(mp))
return (EROFS);
+ err = vn_rlimit_trunc(vap->va_size, td);
+ if (err)
+ return (err);
break;
default:
/*
diff --git a/tests/sys/fs/fusefs/setattr.cc b/tests/sys/fs/fusefs/setattr.cc
--- a/tests/sys/fs/fusefs/setattr.cc
+++ b/tests/sys/fs/fusefs/setattr.cc
@@ -31,10 +31,14 @@
*/
extern "C" {
+#include <sys/types.h>
+#include <sys/resource.h>
#include <sys/stat.h>
+#include <sys/time.h>
#include <fcntl.h>
#include <semaphore.h>
+#include <signal.h>
}
#include "mockfs.hh"
@@ -42,11 +46,15 @@
using namespace testing;
-class Setattr : public FuseTest {};
+class Setattr : public FuseTest {
+public:
+static sig_atomic_t s_sigxfsz;
+};
class RofsSetattr: public Setattr {
public:
virtual void SetUp() {
+ s_sigxfsz = 0;
m_ro = true;
Setattr::SetUp();
}
@@ -61,6 +69,12 @@
};
+sig_atomic_t Setattr::s_sigxfsz = 0;
+
+void sigxfsz_handler(int __unused sig) {
+ Setattr::s_sigxfsz = 1;
+}
+
/*
* If setattr returns a non-zero cache timeout, then subsequent VOP_GETATTRs
* should use the cached attributes, rather than query the daemon
@@ -553,6 +567,34 @@
leak(fd);
}
+/* truncate should fail if it would cause the file to exceed RLIMIT_FSIZE */
+TEST_F(Setattr, truncate_rlimit_rsize)
+{
+ const char FULLPATH[] = "mountpoint/some_file.txt";
+ const char RELPATH[] = "some_file.txt";
+ struct rlimit rl;
+ const uint64_t ino = 42;
+ const uint64_t oldsize = 0;
+ const uint64_t newsize = 100'000'000;
+
+ EXPECT_LOOKUP(FUSE_ROOT_ID, RELPATH)
+ .WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
+ SET_OUT_HEADER_LEN(out, entry);
+ out.body.entry.attr.mode = S_IFREG | 0644;
+ out.body.entry.nodeid = ino;
+ out.body.entry.attr.size = oldsize;
+ })));
+
+ rl.rlim_cur = newsize / 2;
+ rl.rlim_max = 10 * newsize;
+ ASSERT_EQ(0, setrlimit(RLIMIT_FSIZE, &rl)) << strerror(errno);
+ ASSERT_NE(SIG_ERR, signal(SIGXFSZ, sigxfsz_handler)) << strerror(errno);
+
+ EXPECT_EQ(-1, truncate(FULLPATH, newsize));
+ EXPECT_EQ(EFBIG, errno);
+ EXPECT_EQ(1, s_sigxfsz);
+}
+
/* Change a file's timestamps */
TEST_F(Setattr, utimensat) {
const char FULLPATH[] = "mountpoint/some_file.txt";
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Mar 3, 4:17 AM (2 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16939743
Default Alt Text
D36703.diff (2 KB)
Attached To
Mode
D36703: fusefs: better handling of RLIMIT_FSIZE
Attached
Detach File
Event Timeline
Log In to Comment