xfs_ioctl.c (5a3930e27ef95893f039b9ec127a48139fcc8ca5) | xfs_ioctl.c (d5f0f49a9bdd4206e941282dfd323c436331659b) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright (c) 2000-2005 Silicon Graphics, Inc. 4 * All Rights Reserved. 5 */ 6#include "xfs.h" 7#include "xfs_fs.h" 8#include "xfs_shared.h" --- 306 unchanged lines hidden (view full) --- 315 ASSERT(context->count >= 0); 316 ASSERT(context->count < (ATTR_MAX_VALUELEN/8)); 317 ASSERT(context->firstu >= sizeof(*alist)); 318 ASSERT(context->firstu <= context->bufsize); 319 320 /* 321 * Only list entries in the right namespace. 322 */ | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright (c) 2000-2005 Silicon Graphics, Inc. 4 * All Rights Reserved. 5 */ 6#include "xfs.h" 7#include "xfs_fs.h" 8#include "xfs_shared.h" --- 306 unchanged lines hidden (view full) --- 315 ASSERT(context->count >= 0); 316 ASSERT(context->count < (ATTR_MAX_VALUELEN/8)); 317 ASSERT(context->firstu >= sizeof(*alist)); 318 ASSERT(context->firstu <= context->bufsize); 319 320 /* 321 * Only list entries in the right namespace. 322 */ |
323 if (((context->flags & ATTR_SECURE) == 0) != 324 ((flags & XFS_ATTR_SECURE) == 0)) | 323 if (context->attr_filter != (flags & XFS_ATTR_NSP_ONDISK_MASK)) |
325 return; | 324 return; |
326 if (((context->flags & ATTR_ROOT) == 0) != 327 ((flags & XFS_ATTR_ROOT) == 0)) 328 return; | |
329 330 arraytop = sizeof(*alist) + 331 context->count * sizeof(alist->al_offset[0]); 332 333 /* decrement by the actual bytes used by the attr */ 334 context->firstu -= round_up(offsetof(struct xfs_attrlist_ent, a_name) + 335 namelen + 1, sizeof(uint32_t)); 336 if (context->firstu < arraytop) { --- 7 unchanged lines hidden (view full) --- 344 aep->a_valuelen = valuelen; 345 memcpy(aep->a_name, name, namelen); 346 aep->a_name[namelen] = 0; 347 alist->al_offset[context->count++] = context->firstu; 348 alist->al_count = context->count; 349 trace_xfs_attr_list_add(context); 350} 351 | 325 326 arraytop = sizeof(*alist) + 327 context->count * sizeof(alist->al_offset[0]); 328 329 /* decrement by the actual bytes used by the attr */ 330 context->firstu -= round_up(offsetof(struct xfs_attrlist_ent, a_name) + 331 namelen + 1, sizeof(uint32_t)); 332 if (context->firstu < arraytop) { --- 7 unchanged lines hidden (view full) --- 340 aep->a_valuelen = valuelen; 341 memcpy(aep->a_name, name, namelen); 342 aep->a_name[namelen] = 0; 343 alist->al_offset[context->count++] = context->firstu; 344 alist->al_count = context->count; 345 trace_xfs_attr_list_add(context); 346} 347 |
348static unsigned int 349xfs_attr_filter( 350 u32 ioc_flags) 351{ 352 if (ioc_flags & XFS_IOC_ATTR_ROOT) 353 return XFS_ATTR_ROOT; 354 if (ioc_flags & XFS_IOC_ATTR_SECURE) 355 return XFS_ATTR_SECURE; 356 return 0; 357} 358 359static unsigned int 360xfs_attr_flags( 361 u32 ioc_flags) 362{ 363 if (ioc_flags & XFS_IOC_ATTR_CREATE) 364 return XATTR_CREATE; 365 if (ioc_flags & XFS_IOC_ATTR_REPLACE) 366 return XATTR_REPLACE; 367 return 0; 368} 369 |
|
352int 353xfs_ioc_attr_list( 354 struct xfs_inode *dp, 355 void __user *ubuf, 356 int bufsize, 357 int flags, 358 struct xfs_attrlist_cursor __user *ucursor) 359{ --- 5 unchanged lines hidden (view full) --- 365 366 if (bufsize < sizeof(struct xfs_attrlist) || 367 bufsize > XFS_XATTR_LIST_MAX) 368 return -EINVAL; 369 370 /* 371 * Reject flags, only allow namespaces. 372 */ | 370int 371xfs_ioc_attr_list( 372 struct xfs_inode *dp, 373 void __user *ubuf, 374 int bufsize, 375 int flags, 376 struct xfs_attrlist_cursor __user *ucursor) 377{ --- 5 unchanged lines hidden (view full) --- 383 384 if (bufsize < sizeof(struct xfs_attrlist) || 385 bufsize > XFS_XATTR_LIST_MAX) 386 return -EINVAL; 387 388 /* 389 * Reject flags, only allow namespaces. 390 */ |
373 if (flags & ~(ATTR_ROOT | ATTR_SECURE)) | 391 if (flags & ~(XFS_IOC_ATTR_ROOT | XFS_IOC_ATTR_SECURE)) |
374 return -EINVAL; | 392 return -EINVAL; |
375 if (flags == (ATTR_ROOT | ATTR_SECURE)) | 393 if (flags == (XFS_IOC_ATTR_ROOT | XFS_IOC_ATTR_SECURE)) |
376 return -EINVAL; 377 378 /* 379 * Validate the cursor. 380 */ 381 if (copy_from_user(&cursor, ucursor, sizeof(cursor))) 382 return -EFAULT; 383 if (cursor.pad1 || cursor.pad2) --- 8 unchanged lines hidden (view full) --- 392 393 /* 394 * Initialize the output buffer. 395 */ 396 memset(&context, 0, sizeof(context)); 397 context.dp = dp; 398 context.cursor = &cursor; 399 context.resynch = 1; | 394 return -EINVAL; 395 396 /* 397 * Validate the cursor. 398 */ 399 if (copy_from_user(&cursor, ucursor, sizeof(cursor))) 400 return -EFAULT; 401 if (cursor.pad1 || cursor.pad2) --- 8 unchanged lines hidden (view full) --- 410 411 /* 412 * Initialize the output buffer. 413 */ 414 memset(&context, 0, sizeof(context)); 415 context.dp = dp; 416 context.cursor = &cursor; 417 context.resynch = 1; |
400 context.flags = flags; | 418 context.attr_filter = xfs_attr_filter(flags); |
401 context.buffer = buffer; 402 context.bufsize = (bufsize & ~(sizeof(int)-1)); /* align */ 403 context.firstu = context.bufsize; 404 context.put_listent = xfs_ioc_attr_put_listent; 405 406 alist = context.buffer; 407 alist->al_count = 0; 408 alist->al_more = 0; --- 40 unchanged lines hidden (view full) --- 449 struct inode *inode, 450 unsigned char *name, 451 unsigned char __user *ubuf, 452 uint32_t *len, 453 uint32_t flags) 454{ 455 struct xfs_da_args args = { 456 .dp = XFS_I(inode), | 419 context.buffer = buffer; 420 context.bufsize = (bufsize & ~(sizeof(int)-1)); /* align */ 421 context.firstu = context.bufsize; 422 context.put_listent = xfs_ioc_attr_put_listent; 423 424 alist = context.buffer; 425 alist->al_count = 0; 426 alist->al_more = 0; --- 40 unchanged lines hidden (view full) --- 467 struct inode *inode, 468 unsigned char *name, 469 unsigned char __user *ubuf, 470 uint32_t *len, 471 uint32_t flags) 472{ 473 struct xfs_da_args args = { 474 .dp = XFS_I(inode), |
457 .flags = flags, | 475 .attr_filter = xfs_attr_filter(flags), 476 .attr_flags = xfs_attr_flags(flags), |
458 .name = name, 459 .namelen = strlen(name), 460 .valuelen = *len, 461 }; 462 int error; 463 464 if (*len > XFS_XATTR_SIZE_MAX) 465 return -EINVAL; --- 20 unchanged lines hidden (view full) --- 486 struct inode *inode, 487 unsigned char *name, 488 const unsigned char __user *ubuf, 489 uint32_t len, 490 uint32_t flags) 491{ 492 struct xfs_da_args args = { 493 .dp = XFS_I(inode), | 477 .name = name, 478 .namelen = strlen(name), 479 .valuelen = *len, 480 }; 481 int error; 482 483 if (*len > XFS_XATTR_SIZE_MAX) 484 return -EINVAL; --- 20 unchanged lines hidden (view full) --- 505 struct inode *inode, 506 unsigned char *name, 507 const unsigned char __user *ubuf, 508 uint32_t len, 509 uint32_t flags) 510{ 511 struct xfs_da_args args = { 512 .dp = XFS_I(inode), |
494 .flags = flags, | 513 .attr_filter = xfs_attr_filter(flags), 514 .attr_flags = xfs_attr_flags(flags), |
495 .name = name, 496 .namelen = strlen(name), 497 }; 498 int error; 499 500 if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) 501 return -EPERM; 502 503 if (ubuf) { 504 if (len > XFS_XATTR_SIZE_MAX) 505 return -EINVAL; 506 args.value = memdup_user(ubuf, len); 507 if (IS_ERR(args.value)) 508 return PTR_ERR(args.value); 509 args.valuelen = len; 510 } 511 512 error = xfs_attr_set(&args); | 515 .name = name, 516 .namelen = strlen(name), 517 }; 518 int error; 519 520 if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) 521 return -EPERM; 522 523 if (ubuf) { 524 if (len > XFS_XATTR_SIZE_MAX) 525 return -EINVAL; 526 args.value = memdup_user(ubuf, len); 527 if (IS_ERR(args.value)) 528 return PTR_ERR(args.value); 529 args.valuelen = len; 530 } 531 532 error = xfs_attr_set(&args); |
513 if (!error && (flags & ATTR_ROOT)) | 533 if (!error && (flags & XFS_IOC_ATTR_ROOT)) |
514 xfs_forget_acl(inode, name); 515 kfree(args.value); 516 return error; 517} 518 519int 520xfs_ioc_attrmulti_one( 521 struct file *parfilp, 522 struct inode *inode, 523 uint32_t opcode, 524 void __user *uname, 525 void __user *value, 526 uint32_t *len, 527 uint32_t flags) 528{ 529 unsigned char *name; 530 int error; 531 | 534 xfs_forget_acl(inode, name); 535 kfree(args.value); 536 return error; 537} 538 539int 540xfs_ioc_attrmulti_one( 541 struct file *parfilp, 542 struct inode *inode, 543 uint32_t opcode, 544 void __user *uname, 545 void __user *value, 546 uint32_t *len, 547 uint32_t flags) 548{ 549 unsigned char *name; 550 int error; 551 |
532 if ((flags & ATTR_ROOT) && (flags & ATTR_SECURE)) | 552 if ((flags & XFS_IOC_ATTR_ROOT) && (flags & XFS_IOC_ATTR_SECURE)) |
533 return -EINVAL; 534 535 name = strndup_user(uname, MAXNAMELEN); 536 if (IS_ERR(name)) 537 return PTR_ERR(name); 538 539 switch (opcode) { 540 case ATTR_OP_GET: --- 1820 unchanged lines hidden --- | 553 return -EINVAL; 554 555 name = strndup_user(uname, MAXNAMELEN); 556 if (IS_ERR(name)) 557 return PTR_ERR(name); 558 559 switch (opcode) { 560 case ATTR_OP_GET: --- 1820 unchanged lines hidden --- |