diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2008-07-22 09:59:21 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2008-07-26 20:53:34 -0400 |
commit | 2d8f30380ab8c706f4e0a8f1aaa22b5886e9ac8a (patch) | |
tree | b798097fd831eab39f35c8c2e5a8ccfd7a850ef5 /fs/xattr.c | |
parent | 256984a83880ff7ac78055cb87baea48137f0b77 (diff) |
[PATCH] sanitize __user_walk_fd() et.al.
* do not pass nameidata; struct path is all the callers want.
* switch to new helpers:
user_path_at(dfd, pathname, flags, &path)
user_path(pathname, &path)
user_lpath(pathname, &path)
user_path_dir(pathname, &path) (fail if not a directory)
The last 3 are trivial macro wrappers for the first one.
* remove nameidata in callers.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/xattr.c')
-rw-r--r-- | fs/xattr.c | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/fs/xattr.c b/fs/xattr.c index b96222e05ba0..468377e66531 100644 --- a/fs/xattr.c +++ b/fs/xattr.c | |||
@@ -252,40 +252,40 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value, | |||
252 | } | 252 | } |
253 | 253 | ||
254 | asmlinkage long | 254 | asmlinkage long |
255 | sys_setxattr(const char __user *path, const char __user *name, | 255 | sys_setxattr(const char __user *pathname, const char __user *name, |
256 | const void __user *value, size_t size, int flags) | 256 | const void __user *value, size_t size, int flags) |
257 | { | 257 | { |
258 | struct nameidata nd; | 258 | struct path path; |
259 | int error; | 259 | int error; |
260 | 260 | ||
261 | error = user_path_walk(path, &nd); | 261 | error = user_path(pathname, &path); |
262 | if (error) | 262 | if (error) |
263 | return error; | 263 | return error; |
264 | error = mnt_want_write(nd.path.mnt); | 264 | error = mnt_want_write(path.mnt); |
265 | if (!error) { | 265 | if (!error) { |
266 | error = setxattr(nd.path.dentry, name, value, size, flags); | 266 | error = setxattr(path.dentry, name, value, size, flags); |
267 | mnt_drop_write(nd.path.mnt); | 267 | mnt_drop_write(path.mnt); |
268 | } | 268 | } |
269 | path_put(&nd.path); | 269 | path_put(&path); |
270 | return error; | 270 | return error; |
271 | } | 271 | } |
272 | 272 | ||
273 | asmlinkage long | 273 | asmlinkage long |
274 | sys_lsetxattr(const char __user *path, const char __user *name, | 274 | sys_lsetxattr(const char __user *pathname, const char __user *name, |
275 | const void __user *value, size_t size, int flags) | 275 | const void __user *value, size_t size, int flags) |
276 | { | 276 | { |
277 | struct nameidata nd; | 277 | struct path path; |
278 | int error; | 278 | int error; |
279 | 279 | ||
280 | error = user_path_walk_link(path, &nd); | 280 | error = user_lpath(pathname, &path); |
281 | if (error) | 281 | if (error) |
282 | return error; | 282 | return error; |
283 | error = mnt_want_write(nd.path.mnt); | 283 | error = mnt_want_write(path.mnt); |
284 | if (!error) { | 284 | if (!error) { |
285 | error = setxattr(nd.path.dentry, name, value, size, flags); | 285 | error = setxattr(path.dentry, name, value, size, flags); |
286 | mnt_drop_write(nd.path.mnt); | 286 | mnt_drop_write(path.mnt); |
287 | } | 287 | } |
288 | path_put(&nd.path); | 288 | path_put(&path); |
289 | return error; | 289 | return error; |
290 | } | 290 | } |
291 | 291 | ||
@@ -350,32 +350,32 @@ getxattr(struct dentry *d, const char __user *name, void __user *value, | |||
350 | } | 350 | } |
351 | 351 | ||
352 | asmlinkage ssize_t | 352 | asmlinkage ssize_t |
353 | sys_getxattr(const char __user *path, const char __user *name, | 353 | sys_getxattr(const char __user *pathname, const char __user *name, |
354 | void __user *value, size_t size) | 354 | void __user *value, size_t size) |
355 | { | 355 | { |
356 | struct nameidata nd; | 356 | struct path path; |
357 | ssize_t error; | 357 | ssize_t error; |
358 | 358 | ||
359 | error = user_path_walk(path, &nd); | 359 | error = user_path(pathname, &path); |
360 | if (error) | 360 | if (error) |
361 | return error; | 361 | return error; |
362 | error = getxattr(nd.path.dentry, name, value, size); | 362 | error = getxattr(path.dentry, name, value, size); |
363 | path_put(&nd.path); | 363 | path_put(&path); |
364 | return error; | 364 | return error; |
365 | } | 365 | } |
366 | 366 | ||
367 | asmlinkage ssize_t | 367 | asmlinkage ssize_t |
368 | sys_lgetxattr(const char __user *path, const char __user *name, void __user *value, | 368 | sys_lgetxattr(const char __user *pathname, const char __user *name, void __user *value, |
369 | size_t size) | 369 | size_t size) |
370 | { | 370 | { |
371 | struct nameidata nd; | 371 | struct path path; |
372 | ssize_t error; | 372 | ssize_t error; |
373 | 373 | ||
374 | error = user_path_walk_link(path, &nd); | 374 | error = user_lpath(pathname, &path); |
375 | if (error) | 375 | if (error) |
376 | return error; | 376 | return error; |
377 | error = getxattr(nd.path.dentry, name, value, size); | 377 | error = getxattr(path.dentry, name, value, size); |
378 | path_put(&nd.path); | 378 | path_put(&path); |
379 | return error; | 379 | return error; |
380 | } | 380 | } |
381 | 381 | ||
@@ -425,30 +425,30 @@ listxattr(struct dentry *d, char __user *list, size_t size) | |||
425 | } | 425 | } |
426 | 426 | ||
427 | asmlinkage ssize_t | 427 | asmlinkage ssize_t |
428 | sys_listxattr(const char __user *path, char __user *list, size_t size) | 428 | sys_listxattr(const char __user *pathname, char __user *list, size_t size) |
429 | { | 429 | { |
430 | struct nameidata nd; | 430 | struct path path; |
431 | ssize_t error; | 431 | ssize_t error; |
432 | 432 | ||
433 | error = user_path_walk(path, &nd); | 433 | error = user_path(pathname, &path); |
434 | if (error) | 434 | if (error) |
435 | return error; | 435 | return error; |
436 | error = listxattr(nd.path.dentry, list, size); | 436 | error = listxattr(path.dentry, list, size); |
437 | path_put(&nd.path); | 437 | path_put(&path); |
438 | return error; | 438 | return error; |
439 | } | 439 | } |
440 | 440 | ||
441 | asmlinkage ssize_t | 441 | asmlinkage ssize_t |
442 | sys_llistxattr(const char __user *path, char __user *list, size_t size) | 442 | sys_llistxattr(const char __user *pathname, char __user *list, size_t size) |
443 | { | 443 | { |
444 | struct nameidata nd; | 444 | struct path path; |
445 | ssize_t error; | 445 | ssize_t error; |
446 | 446 | ||
447 | error = user_path_walk_link(path, &nd); | 447 | error = user_lpath(pathname, &path); |
448 | if (error) | 448 | if (error) |
449 | return error; | 449 | return error; |
450 | error = listxattr(nd.path.dentry, list, size); | 450 | error = listxattr(path.dentry, list, size); |
451 | path_put(&nd.path); | 451 | path_put(&path); |
452 | return error; | 452 | return error; |
453 | } | 453 | } |
454 | 454 | ||
@@ -486,38 +486,38 @@ removexattr(struct dentry *d, const char __user *name) | |||
486 | } | 486 | } |
487 | 487 | ||
488 | asmlinkage long | 488 | asmlinkage long |
489 | sys_removexattr(const char __user *path, const char __user *name) | 489 | sys_removexattr(const char __user *pathname, const char __user *name) |
490 | { | 490 | { |
491 | struct nameidata nd; | 491 | struct path path; |
492 | int error; | 492 | int error; |
493 | 493 | ||
494 | error = user_path_walk(path, &nd); | 494 | error = user_path(pathname, &path); |
495 | if (error) | 495 | if (error) |
496 | return error; | 496 | return error; |
497 | error = mnt_want_write(nd.path.mnt); | 497 | error = mnt_want_write(path.mnt); |
498 | if (!error) { | 498 | if (!error) { |
499 | error = removexattr(nd.path.dentry, name); | 499 | error = removexattr(path.dentry, name); |
500 | mnt_drop_write(nd.path.mnt); | 500 | mnt_drop_write(path.mnt); |
501 | } | 501 | } |
502 | path_put(&nd.path); | 502 | path_put(&path); |
503 | return error; | 503 | return error; |
504 | } | 504 | } |
505 | 505 | ||
506 | asmlinkage long | 506 | asmlinkage long |
507 | sys_lremovexattr(const char __user *path, const char __user *name) | 507 | sys_lremovexattr(const char __user *pathname, const char __user *name) |
508 | { | 508 | { |
509 | struct nameidata nd; | 509 | struct path path; |
510 | int error; | 510 | int error; |
511 | 511 | ||
512 | error = user_path_walk_link(path, &nd); | 512 | error = user_lpath(pathname, &path); |
513 | if (error) | 513 | if (error) |
514 | return error; | 514 | return error; |
515 | error = mnt_want_write(nd.path.mnt); | 515 | error = mnt_want_write(path.mnt); |
516 | if (!error) { | 516 | if (!error) { |
517 | error = removexattr(nd.path.dentry, name); | 517 | error = removexattr(path.dentry, name); |
518 | mnt_drop_write(nd.path.mnt); | 518 | mnt_drop_write(path.mnt); |
519 | } | 519 | } |
520 | path_put(&nd.path); | 520 | path_put(&path); |
521 | return error; | 521 | return error; |
522 | } | 522 | } |
523 | 523 | ||