/** Handler for locking in a FAF open file. * @author Renaud Lottiaux * * @param from Node sending the request * @param msgIn Request message */ void handle_faf_flock(struct rpc_desc *desc, void *msgIn, size_t size) { struct faf_ctl_msg *msg = msgIn; const struct cred *old_cred; long r = -EINVAL; int err; old_cred = unpack_override_creds(desc); if (IS_ERR(old_cred)) goto cancel; r = remote_sleep_prepare(desc); if (r) { revert_creds(old_cred); goto cancel; } r = sys_flock (msg->server_fd, msg->cmd); remote_sleep_finish(); revert_creds(old_cred); err = rpc_pack_type(desc, r); if (err) goto cancel; return; cancel: rpc_cancel(desc); }
static int unpack_context(struct rpc_desc *desc, struct prev_root *prev_root, const struct cred **old_cred) { int err; *old_cred = unpack_override_creds(desc); if (IS_ERR(*old_cred)) return PTR_ERR(*old_cred); err = unpack_root_pwd(desc, prev_root); if (err) revert_creds(*old_cred); return err; }
/** Handler for doing an FCNTL64 in a FAF open file. * @author Renaud Lottiaux * * @param from Node sending the request * @param msgIn Request message */ void handle_faf_fcntl64 (struct rpc_desc* desc, void *msgIn, size_t size) { struct faf_ctl_msg *msg = msgIn; const struct cred *old_cred; unsigned long arg; long r; int err; if (msg->cmd == F_GETLK64 || msg->cmd == F_SETLK64 || msg->cmd == F_SETLKW64) arg = (unsigned long) &msg->flock64; else arg = msg->arg; old_cred = unpack_override_creds(desc); if (IS_ERR(old_cred)) goto cancel; err = remote_sleep_prepare(desc); if (err) { revert_creds(old_cred); goto cancel; } r = sys_fcntl64 (msg->server_fd, msg->cmd, arg); remote_sleep_finish(); revert_creds(old_cred); err = rpc_pack_type(desc, r); if (unlikely(err)) goto cancel; if (!r && msg->cmd == F_GETLK64) { err = rpc_pack_type(desc, msg->flock64); if (unlikely(err)) goto cancel; } return; cancel: rpc_cancel(desc); }
static void handle_get_appid_from_pid(struct rpc_desc *desc, void *_msg, size_t size) { struct getappid_request_msg *msg = _msg; long app_id; const struct cred *old_cred; int err; old_cred = unpack_override_creds(desc); if (IS_ERR(old_cred)) { err = PTR_ERR(old_cred); goto out; } app_id = __get_appid_from_local_pid(msg->pid); revert_creds(old_cred); err = rpc_pack_type(desc, app_id); out: if (err) rpc_cancel(desc); }
/** Handler for d_path in a FAF open file. * @author Renaud Lottiaux * * @param from Node sending the request * @param msgIn Request message */ void handle_faf_d_path (struct rpc_desc* desc, void *msgIn, size_t size) { struct faf_d_path_msg *msg = msgIn; char *buff, *file_name = NULL; struct file *file; struct prev_root prev_root; const struct cred *old_cred; bool deleted = false; int len; int err; old_cred = unpack_override_creds(desc); if (IS_ERR(old_cred)) { rpc_cancel(desc); return; } err = unpack_root(desc, &prev_root); if (err) { revert_creds(old_cred); rpc_cancel(desc); return; } buff = kmalloc (msg->count, GFP_KERNEL); file = fcheck_files (current->files, msg->server_fd); /* Remote caller holds a reference so it can't disappear. */ BUG_ON(!file); if (msg->deleted) file_name = d_path_check(&file->f_path, buff, msg->count, &deleted); else file_name = d_path(&file->f_path, buff, msg->count); if (IS_ERR(file_name)) len = PTR_ERR(file_name); else len = strlen(file_name) + 1; err = rpc_pack_type(desc, len); if (err) goto err_cancel; if (len >= 0) { err = rpc_pack(desc, 0, file_name, len); if (err) goto err_cancel; if (msg->deleted) { err = rpc_pack_type(desc, deleted); if (err) goto err_cancel; } } out: kfree (buff); chroot_to_prev_root(&prev_root); revert_creds(old_cred); return; err_cancel: rpc_cancel(desc); goto out; }