Skip to content

Commit f2327dc

Browse files
committed
Merge tag 'for-linus-6.18-ofs1' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux
Pull orangefs updates from Mike Marshall: "Two cleanups and a bug fix: - Remove unused type in macro fill_default_sys_attrs (Zhen Ni) - Replace kzalloc + copy_from_user with memdup_user_nul (Thorsten Blum) - Fix xattr related buffer overflow... A message was forwarded to me from Disclosure <[email protected]> indicating a problem with a loop condition in our xattr code. When I fixed the problem it exposed a related memory leak problem, and I fixed that too" * tag 'for-linus-6.18-ofs1' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux: fs/orangefs: Replace kzalloc + copy_from_user with memdup_user_nul orangefs: fix xattr related buffer overflow... orangefs: Remove unused type in macro fill_default_sys_attrs
2 parents a9b3876 + 11f6bce commit f2327dc

File tree

4 files changed

+16
-19
lines changed

4 files changed

+16
-19
lines changed

fs/orangefs/namei.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ static int orangefs_create(struct mnt_idmap *idmap,
3838

3939
new_op->upcall.req.create.parent_refn = parent->refn;
4040

41-
fill_default_sys_attrs(new_op->upcall.req.create.attributes,
42-
ORANGEFS_TYPE_METAFILE, mode);
41+
fill_default_sys_attrs(new_op->upcall.req.create.attributes, mode);
4342

4443
strscpy(new_op->upcall.req.create.d_name, dentry->d_name.name);
4544

@@ -240,9 +239,7 @@ static int orangefs_symlink(struct mnt_idmap *idmap,
240239

241240
new_op->upcall.req.sym.parent_refn = parent->refn;
242241

243-
fill_default_sys_attrs(new_op->upcall.req.sym.attributes,
244-
ORANGEFS_TYPE_SYMLINK,
245-
mode);
242+
fill_default_sys_attrs(new_op->upcall.req.sym.attributes, mode);
246243

247244
strscpy(new_op->upcall.req.sym.entry_name, dentry->d_name.name);
248245
strscpy(new_op->upcall.req.sym.target, symname);
@@ -316,8 +313,7 @@ static struct dentry *orangefs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
316313

317314
new_op->upcall.req.mkdir.parent_refn = parent->refn;
318315

319-
fill_default_sys_attrs(new_op->upcall.req.mkdir.attributes,
320-
ORANGEFS_TYPE_DIRECTORY, mode);
316+
fill_default_sys_attrs(new_op->upcall.req.mkdir.attributes, mode);
321317

322318
strscpy(new_op->upcall.req.mkdir.d_name, dentry->d_name.name);
323319

fs/orangefs/orangefs-debugfs.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -440,14 +440,13 @@ static ssize_t orangefs_debug_write(struct file *file,
440440
count = ORANGEFS_MAX_DEBUG_STRING_LEN;
441441
}
442442

443-
buf = kzalloc(ORANGEFS_MAX_DEBUG_STRING_LEN, GFP_KERNEL);
444-
if (!buf)
445-
goto out;
446-
447-
if (copy_from_user(buf, ubuf, count - 1)) {
443+
buf = memdup_user_nul(ubuf, count - 1);
444+
if (IS_ERR(buf)) {
448445
gossip_debug(GOSSIP_DEBUGFS_DEBUG,
449-
"%s: copy_from_user failed!\n",
446+
"%s: memdup_user_nul failed!\n",
450447
__func__);
448+
rc = PTR_ERR(buf);
449+
buf = NULL;
451450
goto out;
452451
}
453452

fs/orangefs/orangefs-kernel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ int service_operation(struct orangefs_kernel_op_s *op,
462462
((ORANGEFS_SB(inode->i_sb)->flags & ORANGEFS_OPT_INTR) ? \
463463
ORANGEFS_OP_INTERRUPTIBLE : 0)
464464

465-
#define fill_default_sys_attrs(sys_attr, type, mode) \
465+
#define fill_default_sys_attrs(sys_attr, mode) \
466466
do { \
467467
sys_attr.owner = from_kuid(&init_user_ns, current_fsuid()); \
468468
sys_attr.group = from_kgid(&init_user_ns, current_fsgid()); \

fs/orangefs/xattr.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ static inline int convert_to_internal_xattr_flags(int setxattr_flags)
5454
static unsigned int xattr_key(const char *key)
5555
{
5656
unsigned int i = 0;
57-
while (key)
57+
if (!key)
58+
return 0;
59+
while (*key)
5860
i += *key++;
5961
return i % 16;
6062
}
@@ -175,8 +177,8 @@ ssize_t orangefs_inode_getxattr(struct inode *inode, const char *name,
175177
cx->length = -1;
176178
cx->timeout = jiffies +
177179
orangefs_getattr_timeout_msecs*HZ/1000;
178-
hash_add(orangefs_inode->xattr_cache, &cx->node,
179-
xattr_key(cx->key));
180+
hlist_add_head( &cx->node,
181+
&orangefs_inode->xattr_cache[xattr_key(cx->key)]);
180182
}
181183
}
182184
goto out_release_op;
@@ -229,8 +231,8 @@ ssize_t orangefs_inode_getxattr(struct inode *inode, const char *name,
229231
memcpy(cx->val, buffer, length);
230232
cx->length = length;
231233
cx->timeout = jiffies + HZ;
232-
hash_add(orangefs_inode->xattr_cache, &cx->node,
233-
xattr_key(cx->key));
234+
hlist_add_head(&cx->node,
235+
&orangefs_inode->xattr_cache[xattr_key(cx->key)]);
234236
}
235237
}
236238

0 commit comments

Comments
 (0)