OpenVZ Forum - RDF feed
type: channel
items: [PATCH v5 00/10] IPC: checkpoint/restore in userspace enhancements
items: [PATCH v5 01/10] ipc: remove forced assignment of selected message
items: [PATCH v5 02/10] ipc: &quot;use key as id&quot; functionality for resource get system call i
items: [PATCH v5 03/10] ipc: segment key change helper introduced
items: [PATCH v5 04/10] ipc: add new SHM_SET command for sys_shmctl() call
items: [PATCH v5 05/10] ipc: add new MSG_SET command for sys_msgctl() call
items: [PATCH v5 06/10] glge driver: rename internal SEM_SET macro to SEM_INIT
items: [PATCH v5 07/10] ipc: add new SEM_SET command for sys_semctl() call
items: [PATCH v5 08/10] IPC: message queue receive cleanup
items: [PATCH v5 09/10] IPC: message queue copy feature introduced
items: [PATCH v5 10/10] test: IPC message queue copy feture test
items: Re: [PATCH v5 01/10] ipc: remove forced assignment of selected message

[PATCH v5 00/10] IPC: checkpoint/restore in userspace enhancements
type: item
description: v5: 1) Several define-dependent compile bugs fixed 2) IPC message copy test updated 3) A couple of minor fixes. 4) Qlogic driver update: rename of its internal SEM_SET define into SEM_INIT (compile error). v4: 1) If MSG_COPY flag is specified, then "mtype" is not a type, but message number to copy. 2) MSG_SET_COPY logic for sys_msgctl() was removed. v3: 1) Copy messages to user-space under spinlock was replaced by allocation of dummy message before queue lock and then copy of desired message to the dummy one instead of unlinking it from queue list. I.e. the message queue copy logic was changed: messages can be retrived one by one (instead of receiving of the whole list at once). This patch set is aimed to provide additional functionality for all IPC objects, which is required for migration of these objects by user-space checkpoint/restore utils (CRIU). The main problem here was impossibility to set up object id. This patch set solves the problem in two steps: 1) Makes it possible to create new object (shared memory, semaphores set or messages queue) with ID, equal to passed key. 2) Makes it possible to change existent object key. Another problem was to peek messages from queues without deleting them. This was achived by introducing of new MSG_COPY flag for sys_msgrcv(). If MSG_COPY flag is set, then msgtyp is interpreted as message number. The following series implements... --- Stanislav Kinsbursky (10): ipc: remove forced assignment of selected message ipc: "use key as id" functionality for resource get system call introduced ipc: segment key change helper introduced ipc: add new SHM_SET command for sys_shmctl() call ipc: add new MSG_SET command for sys_msgctl() call glge driver: rename internal SEM_SET macro to SEM_INIT ipc: add new SEM_SET command for sys_semctl() call IPC: message queue receive cleanup IPC: message queue copy feature introduced test: IPC message queue copy feture test drivers/net/ethernet/qlogic/qlge/qlge.h | 4 drivers/net/ethernet/qlogic/qlge/q…
creator: Stanislav Kinsbursky
date: 2012-09-19T16:05:21-00:00

[PATCH v5 01/10] ipc: remove forced assignment of selected message
type: item
description: This is a cleanup patch. The assignment is redundant. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> --- ipc/msg.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/ipc/msg.c b/ipc/msg.c index 7385de2..f3bfbb8 100644 --- a/ipc/msg.c +++ b/ipc/msg.c @@ -787,7 +787,6 @@ long do_msgrcv(int msqid, long *pmtype, void __user *mtext, !security_msg_queue_msgrcv(msq, walk_msg, current, msgtyp, mode)) { - msg = walk_msg; if (mode == SEARCH_LESSEQUAL && walk_msg->m_type != 1) { msg = walk_msg;
creator: Stanislav Kinsbursky
date: 2012-09-19T16:05:31-00:00

[PATCH v5 02/10] ipc: &quot;use key as id&quot; functionality for resource get system call i
type: item
description: This patch introduces new IPC resource get request flag IPC_PRESET, which should be interpreted as a request to try to allocate IPC slot with number, starting from value resented by key. IOW, kernel will try allocate new segment in specified slot. Note: if desired slot is not emply, then next free slot will be used. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> --- include/linux/ipc.h | 1 + ipc/msg.c | 4 +++- ipc/sem.c | 4 +++- ipc/shm.c | 4 +++- ipc/util.c | 18 +++++++++++++++--- ipc/util.h | 3 ++- 6 files changed, 27 insertions(+), 7 deletions(-) diff --git a/include/linux/ipc.h b/include/linux/ipc.h index 30e8161..d7e5632 100644 --- a/include/linux/ipc.h +++ b/include/linux/ipc.h @@ -24,6 +24,7 @@ struct ipc_perm #define IPC_CREAT 00001000 /* create if key is nonexistent */ #define IPC_EXCL 00002000 /* fail if key exists */ #define IPC_NOWAIT 00004000 /* return error on wait */ +#define IPC_PRESET 00040000 /* use key as id */ /* these fields are used by the DIPC package so the kernel as standard should avoid using them if possible */ diff --git a/ipc/msg.c b/ipc/msg.c index f3bfbb8..1cecaf2 100644 --- a/ipc/msg.c +++ b/ipc/msg.c @@ -190,6 +190,7 @@ static int newque(struct ipc_namespace *ns, struct ipc_params *params) msq->q_perm.mode = msgflg & S_IRWXUGO; msq->q_perm.key = key; + msq->q_perm.id = (msgflg & IPC_PRESET) ? key : 0; msq->q_perm.security = NULL; retval = security_msg_queue_alloc(msq); @@ -201,7 +202,8 @@ static int newque(struct ipc_namespace *ns, struct ipc_params *params) /* * ipc_addid() locks msq */ - id = ipc_addid(&msg_ids(ns), &msq->q_perm, ns->msg_ctlmni); + id = ipc_addid(&msg_ids(ns), &msq->q_perm, ns->msg_ctlmni, + msgflg & IPC_PRESET); if (id < 0) { security_msg_queue_free(msq); ipc_rcu_putref(msq); diff --git a/ipc/sem.c b/ipc/sem.c index 5215a81..e89b90c 100644 --- a/ipc/sem.c +++ b/ipc/sem.c @@ -306,6 +306,7 @@ static int newary(struct ipc_namespace *ns, struct ipc_params *params) sma->sem_perm.mode = (semflg & S_IRWX…
creator: Stanislav Kinsbursky
date: 2012-09-19T16:05:37-00:00

[PATCH v5 03/10] ipc: segment key change helper introduced
type: item
description: This patch introduces existent segment key changing infrastructure. New function ipc_update_key() can be used change segment key, cuid, cgid values. It checks for that new key is not used (except IPC_PRIVATE) prior to set it on existent. To make this possible, added copying of this fields from user-space in __get_compat_ipc_perm() and __get_compat_ipc64_perm() functions. Also segment search by key and lock were splitted into different functions, because ipc_update_key() doesn't need to lock the segment during check that new key is not used. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> --- ipc/compat.c | 6 ++++++ ipc/util.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++--- ipc/util.h | 2 ++ 3 files changed, 56 insertions(+), 3 deletions(-) diff --git a/ipc/compat.c b/ipc/compat.c index ad9518e..af30d13 100644 --- a/ipc/compat.c +++ b/ipc/compat.c @@ -144,6 +144,9 @@ static inline int __get_compat_ipc64_perm(struct ipc64_perm *p64, err = __get_user(p64->uid, &up64->uid); err |= __get_user(p64->gid, &up64->gid); err |= __get_user(p64->mode, &up64->mode); + err |= __get_user(p64->cuid, &up64->cuid); + err |= __get_user(p64->cgid, &up64->cgid); + err |= __get_user(p64->key, &up64->key); return err; } @@ -155,6 +158,9 @@ static inline int __get_compat_ipc_perm(struct ipc64_perm *p, err = __get_user(p->uid, &up->uid); err |= __get_user(p->gid, &up->gid); err |= __get_user(p->mode, &up->mode); + err |= __get_user(p->cuid, &up->cuid); + err |= __get_user(p->cgid, &up->cgid); + err |= __get_user(p->key, &up->key); return err; } diff --git a/ipc/util.c b/ipc/util.c index 328abd1..1154245 100644 --- a/ipc/util.c +++ b/ipc/util.c @@ -173,7 +173,7 @@ void __init ipc_init_proc_interface(const char *path, const char *header, * @key: The key to find * * Requires ipc_ids.rw_mutex locked. - * Returns the LOCKED pointer to the ipc structure if found or NULL + * Returns the UNLOCKED pointer to the ipc structure if found or NULL * if not. * If key is found ipc p…
creator: Stanislav Kinsbursky
date: 2012-09-19T16:05:42-00:00

[PATCH v5 04/10] ipc: add new SHM_SET command for sys_shmctl() call
type: item
description: New SHM_SET command will be interpreted exactly as IPC_SET, but also will update key, cuid and cgid values. IOW, it allows to change existent key value. The fact, that key is not used is checked before update. Otherwise -EEXIST is returned. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> --- include/linux/shm.h | 1 + ipc/compat.c | 1 + ipc/shm.c | 13 +++++++++++-- security/selinux/hooks.c | 1 + security/smack/smack_lsm.c | 1 + 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/linux/shm.h b/include/linux/shm.h index edd0868..9a3e423 100644 --- a/include/linux/shm.h +++ b/include/linux/shm.h @@ -63,6 +63,7 @@ struct shmid_ds { /* ipcs ctl commands */ #define SHM_STAT 13 #define SHM_INFO 14 +#define SHM_SET 15 /* Obsolete, used only for backwards compatibility */ struct shminfo { diff --git a/ipc/compat.c b/ipc/compat.c index af30d13..35c750d 100644 --- a/ipc/compat.c +++ b/ipc/compat.c @@ -692,6 +692,7 @@ long compat_sys_shmctl(int first, int second, void __user *uptr) case IPC_SET: + case SHM_SET: if (version == IPC_64) { err = get_compat_shmid64_ds(&s64, uptr); } else { diff --git a/ipc/shm.c b/ipc/shm.c index 0088418..65c0c5c 100644 --- a/ipc/shm.c +++ b/ipc/shm.c @@ -636,6 +636,9 @@ copy_shmid_from_user(struct shmid64_ds *out, void __user *buf, int version) out->shm_perm.uid = tbuf_old.shm_perm.uid; out->shm_perm.gid = tbuf_old.shm_perm.gid; out->shm_perm.mode = tbuf_old.shm_perm.mode; + out->shm_perm.cuid = tbuf_old.shm_perm.cuid; + out->shm_perm.cgid = tbuf_old.shm_perm.cgid; + out->shm_perm.key = tbuf_old.shm_perm.key; return 0; } @@ -740,12 +743,13 @@ static int shmctl_down(struct ipc_namespace *ns, int shmid, int cmd, struct shmid_kernel *shp; int err; - if (cmd == IPC_SET) { + if (cmd == IPC_SET || cmd == SHM_SET) { if (copy_shmid_from_user(&shmid64, buf, version)) return -EFAULT; } - ipcp = ipcctl_pre_down(ns, &shm_ids(ns), shmid, cmd, + ipcp = ipcctl_pre_down(ns, &shm_ids(ns), shmid, + (cmd != SHM_SET) ? cmd : IPC_SET, …
creator: Stanislav Kinsbursky
date: 2012-09-19T16:05:48-00:00

[PATCH v5 05/10] ipc: add new MSG_SET command for sys_msgctl() call
type: item
description: New MSG_SET command will be interpreted exactly as IPC_SET, but also will update key, cuid and cgid values. IOW, it allows to change existent key value. The fact, that key is not used is checked before update. Otherwise -EEXIST is returned. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> --- include/linux/msg.h | 1 + ipc/compat.c | 1 + ipc/msg.c | 13 +++++++++++-- security/selinux/hooks.c | 1 + security/smack/smack_lsm.c | 1 + 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/linux/msg.h b/include/linux/msg.h index 56abf15..6689e73 100644 --- a/include/linux/msg.h +++ b/include/linux/msg.h @@ -6,6 +6,7 @@ /* ipcs ctl commands */ #define MSG_STAT 11 #define MSG_INFO 12 +#define MSG_SET 13 /* msgrcv options */ #define MSG_NOERROR 010000 /* no error if message is too big */ diff --git a/ipc/compat.c b/ipc/compat.c index 35c750d..9c70f9a 100644 --- a/ipc/compat.c +++ b/ipc/compat.c @@ -483,6 +483,7 @@ long compat_sys_msgctl(int first, int second, void __user *uptr) break; case IPC_SET: + case MSG_SET: if (version == IPC_64) { err = get_compat_msqid64(&m64, uptr); } else { diff --git a/ipc/msg.c b/ipc/msg.c index 1cecaf2..ef4f118 100644 --- a/ipc/msg.c +++ b/ipc/msg.c @@ -392,6 +392,9 @@ copy_msqid_from_user(struct msqid64_ds *out, void __user *buf, int version) out->msg_perm.uid = tbuf_old.msg_perm.uid; out->msg_perm.gid = tbuf_old.msg_perm.gid; out->msg_perm.mode = tbuf_old.msg_perm.mode; + out->msg_perm.cuid = tbuf_old.msg_perm.cuid; + out->msg_perm.cgid = tbuf_old.msg_perm.cgid; + out->msg_perm.key = tbuf_old.msg_perm.key; if (tbuf_old.msg_qbytes == 0) out->msg_qbytes = tbuf_old.msg_lqbytes; @@ -418,12 +421,13 @@ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd, struct msg_queue *msq; int err; - if (cmd == IPC_SET) { + if (cmd == IPC_SET || cmd == MSG_SET) { if (copy_msqid_from_user(&msqid64, buf, version)) return -EFAULT; } - ipcp = ipcctl_pre_down(ns, &msg_ids(ns), msqid, cmd, + ipcp = ipcctl_pre_down(ns, &msg…
creator: Stanislav Kinsbursky
date: 2012-09-19T16:05:54-00:00

[PATCH v5 06/10] glge driver: rename internal SEM_SET macro to SEM_INIT
type: item
description: The reason for shit patch is that SET_SET is desired to be a part of new part of API of IPC sys_semctl() system call. The name itself for IPC is quite natural, because all linux-specific commands names for IPC system calls are originally created by replacing "IPC_" part by "SEM_"("MSG_", "SHM_") part. So, I'm hoping, that this change doesn't really matters for "QLogic qlge NIC HBA Driver" developers, since it's just an internal define. --- drivers/net/ethernet/qlogic/qlge/qlge.h | 4 ++-- drivers/net/ethernet/qlogic/qlge/qlge_main.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qlge/qlge.h b/drivers/net/ethernet/qlogic/qlge/qlge.h index a131d7b..6f46ea5 100644 --- a/drivers/net/ethernet/qlogic/qlge/qlge.h +++ b/drivers/net/ethernet/qlogic/qlge/qlge.h @@ -347,10 +347,10 @@ enum { enum { /* * Example: - * reg = SEM_XGMAC0_MASK | (SEM_SET << SEM_XGMAC0_SHIFT) + * reg = SEM_XGMAC0_MASK | (SEM_INIT << SEM_XGMAC0_SHIFT) */ SEM_CLEAR = 0, - SEM_SET = 1, + SEM_INIT = 1, SEM_FORCE = 3, SEM_XGMAC0_SHIFT = 0, SEM_XGMAC1_SHIFT = 2, diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_main.c b/drivers/net/ethernet/qlogic/qlge/qlge_main.c index b53a3b6..18e0a0c 100644 --- a/drivers/net/ethernet/qlogic/qlge/qlge_main.c +++ b/drivers/net/ethernet/qlogic/qlge/qlge_main.c @@ -109,28 +109,28 @@ static int ql_sem_trylock(struct ql_adapter *qdev, u32 sem_mask) switch (sem_mask) { case SEM_XGMAC0_MASK: - sem_bits = SEM_SET << SEM_XGMAC0_SHIFT; + sem_bits = SEM_INIT << SEM_XGMAC0_SHIFT; break; case SEM_XGMAC1_MASK: - sem_bits = SEM_SET << SEM_XGMAC1_SHIFT; + sem_bits = SEM_INIT << SEM_XGMAC1_SHIFT; break; case SEM_ICB_MASK: - sem_bits = SEM_SET << SEM_ICB_SHIFT; + sem_bits = SEM_INIT << SEM_ICB_SHIFT; break; case SEM_MAC_ADDR_MASK: - sem_bits = SEM_SET << SEM_MAC_ADDR_SHIFT; + sem_bits = SEM_INIT << SEM_MAC_ADDR_SHIFT; break; case SEM_FLASH_MASK: - sem_bits = SEM_SET << SEM_FLASH_SHIFT; + sem_bits = SEM_INIT << SEM_FLASH_SHI…
creator: Stanislav Kinsbursky
date: 2012-09-19T16:05:59-00:00

[PATCH v5 07/10] ipc: add new SEM_SET command for sys_semctl() call
type: item
description: New SEM_SET command will be interpreted exactly as IPC_SET, but also will update key, cuid and cgid values. IOW, it allows to change existent key value. The fact, that key is not used is checked before update. Otherwise -EEXIST is returned. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> --- include/linux/sem.h | 1 + ipc/compat.c | 1 + ipc/sem.c | 10 ++++++++-- security/selinux/hooks.c | 1 + security/smack/smack_lsm.c | 1 + 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/linux/sem.h b/include/linux/sem.h index 10d6b22..c74b9b5 100644 --- a/include/linux/sem.h +++ b/include/linux/sem.h @@ -18,6 +18,7 @@ /* ipcs ctl cmds */ #define SEM_STAT 18 #define SEM_INFO 19 +#define SEM_SET 20 /* Obsolete, used only for backwards compatibility and libc5 compiles */ struct semid_ds { diff --git a/ipc/compat.c b/ipc/compat.c index 9c70f9a..84d8efd 100644 --- a/ipc/compat.c +++ b/ipc/compat.c @@ -290,6 +290,7 @@ static long do_compat_semctl(int first, int second, int third, u32 pad) break; case IPC_SET: + case SEM_SET: if (version == IPC_64) { err = get_compat_semid64_ds(&s64, compat_ptr(pad)); } else { diff --git a/ipc/sem.c b/ipc/sem.c index e89b90c..b4f80082 100644 --- a/ipc/sem.c +++ b/ipc/sem.c @@ -1085,12 +1085,13 @@ static int semctl_down(struct ipc_namespace *ns, int semid, struct semid64_ds semid64; struct kern_ipc_perm *ipcp; - if(cmd == IPC_SET) { + if (cmd == IPC_SET || cmd == SEM_SET) { if (copy_semid_from_user(&semid64, arg.buf, version)) return -EFAULT; } - ipcp = ipcctl_pre_down(ns, &sem_ids(ns), semid, cmd, + ipcp = ipcctl_pre_down(ns, &sem_ids(ns), semid, + (cmd != SEM_SET) ? cmd : IPC_SET, &semid64.sem_perm, 0); if (IS_ERR(ipcp)) return PTR_ERR(ipcp); @@ -1105,6 +1106,10 @@ static int semctl_down(struct ipc_namespace *ns, int semid, case IPC_RMID: freeary(ns, ipcp); goto out_up; + case SEM_SET: + err = ipc_update_key(&sem_ids(ns), &semid64.sem_perm, ipcp); + if (err) + break; case IPC_SET: ipc_update_perm(&semid64.sem_perm, …
creator: Stanislav Kinsbursky
date: 2012-09-19T16:06:05-00:00

[PATCH v5 08/10] IPC: message queue receive cleanup
type: item
description: This patch moves all message related manipulation into one function msg_fill(). Actually, two functions because of the compat one. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> --- include/linux/msg.h | 5 +++-- ipc/compat.c | 36 +++++++++++++++++++----------------- ipc/msg.c | 44 +++++++++++++++++++++++--------------------- 3 files changed, 45 insertions(+), 40 deletions(-) diff --git a/include/linux/msg.h b/include/linux/msg.h index 6689e73..9411b76 100644 --- a/include/linux/msg.h +++ b/include/linux/msg.h @@ -105,8 +105,9 @@ struct msg_queue { /* Helper routines for sys_msgsnd and sys_msgrcv */ extern long do_msgsnd(int msqid, long mtype, void __user *mtext, size_t msgsz, int msgflg); -extern long do_msgrcv(int msqid, long *pmtype, void __user *mtext, - size_t msgsz, long msgtyp, int msgflg); +extern long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp, + int msgflg, + long (*msg_fill)(void __user *, struct msg_msg *, size_t )); #endif /* __KERNEL__ */ diff --git a/ipc/compat.c b/ipc/compat.c index 84d8efd..b879d50 100644 --- a/ipc/compat.c +++ b/ipc/compat.c @@ -341,13 +341,23 @@ long compat_sys_msgsnd(int first, int second, int third, void __user *uptr) return do_msgsnd(first, type, up->mtext, second, third); } +long compat_do_msg_fill(void __user *dest, struct msg_msg *msg, size_t bufsz) +{ + struct compat_msgbuf __user *msgp = dest; + size_t msgsz; + + if (put_user(msg->m_type, &msgp->mtype)) + return -EFAULT; + + msgsz = (bufsz > msg->m_ts) ? msg->m_ts : bufsz; + if (store_msg(msgp->mtext, msg, msgsz)) + return -EFAULT; + return msgsz; +} + long compat_sys_msgrcv(int first, int second, int msgtyp, int third, int version, void __user *uptr) { - struct compat_msgbuf __user *up; - long type; - int err; - if (first < 0) return -EINVAL; if (second < 0) @@ -355,23 +365,14 @@ long compat_sys_msgrcv(int first, int second, int msgtyp, int third, if (!version) { struct compat_ipc_kludge ipck; - err = -EINVAL; if (!uptr) - goto out; -…
creator: Stanislav Kinsbursky
date: 2012-09-19T16:06:10-00:00

[PATCH v5 09/10] IPC: message queue copy feature introduced
type: item
description: This patch is required for checkpoint/restore in userspace. IOW, c/r requires some way to get all pending IPC messages without deleting them from the queue (checkpoint can fail and in this case tasks will be resumed, so queue have to be valid). To achive this, new operation flag MSG_COPY for sys_msgrcv() system call was introduced. If this flag was specified, then mtype is interpreted as number of the message to copy. If MSG_COPY is set, then kernel will allocate dummy message with passed size, and then use new copy_msg() helper function to copy desired message (instead of unlinking it from the queue). Notes: 1) Return -ENOSYS if MSG_COPY is specified, but CONFIG_CHECKPOINT_RESTORE is not set. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> --- include/linux/msg.h | 1 + ipc/msg.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- ipc/msgutil.c | 38 ++++++++++++++++++++++++++++++++++++++ ipc/util.h | 1 + 4 files changed, 88 insertions(+), 2 deletions(-) diff --git a/include/linux/msg.h b/include/linux/msg.h index 9411b76..4ca337f 100644 --- a/include/linux/msg.h +++ b/include/linux/msg.h @@ -11,6 +11,7 @@ /* msgrcv options */ #define MSG_NOERROR 010000 /* no error if message is too big */ #define MSG_EXCEPT 020000 /* recv any msg except of specified type.*/ +#define MSG_COPY 040000 /* copy (not remove) all queue messages */ /* Obsolete, used only for backwards compatibility and libc5 compiles */ struct msqid_ds { diff --git a/ipc/msg.c b/ipc/msg.c index d8168a7..0984f07 100644 --- a/ipc/msg.c +++ b/ipc/msg.c @@ -785,19 +785,48 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp, struct msg_msg *msg; int mode; struct ipc_namespace *ns; +#ifdef CONFIG_CHECKPOINT_RESTORE + struct msg_msg *copy = NULL; + unsigned long copy_number = 0; +#endif if (msqid < 0 || (long) bufsz < 0) return -EINVAL; + if (msgflg & MSG_COPY) { +#ifdef CONFIG_CHECKPOINT_RESTORE + + if (msgflg & MSG_COPY) { + copy_number = msgtyp; + msgtyp = 0; + } + + /* …
creator: Stanislav Kinsbursky
date: 2012-09-19T16:06:15-00:00

[PATCH v5 10/10] test: IPC message queue copy feture test
type: item
description: This test can be used to check wheither kernel supports IPC message queue copy and restore features (required by CRIU project). --- tools/testing/selftests/ipc/Makefile | 28 ++++ tools/testing/selftests/ipc/msgque.c | 251 ++++++++++++++++++++++++++++++++++ 2 files changed, 279 insertions(+), 0 deletions(-) create mode 100644 tools/testing/selftests/ipc/Makefile create mode 100644 tools/testing/selftests/ipc/msgque.c diff --git a/tools/testing/selftests/ipc/Makefile b/tools/testing/selftests/ipc/Makefile new file mode 100644 index 0000000..6c547bf --- /dev/null +++ b/tools/testing/selftests/ipc/Makefile @@ -0,0 +1,28 @@ +uname_M := $(shell uname -m 2>/dev/null || echo not) +ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/) +ifeq ($(ARCH),i386) + ARCH := X86 + CFLAGS := -DCONFIG_X86_32 -D__i386__ +endif +ifeq ($(ARCH),x86_64) + ARCH := X86 + CFLAGS := -DCONFIG_X86_64 -D__x86_64__ +endif + +CFLAGS += -I../../../../arch/x86/include/generated/ +CFLAGS += -I../../../../include/ +CFLAGS += -I../../../../usr/include/ +CFLAGS += -I../../../../arch/x86/include/ + +all: +ifeq ($(ARCH),X86) + gcc $(CFLAGS) msgque.c -o msgque_test +else + echo "Not an x86 target, can't build msgque selftest" +endif + +run_tests: all + ./msgque_test + +clean: + rm -fr ./msgque_test diff --git a/tools/testing/selftests/ipc/msgque.c b/tools/testing/selftests/ipc/msgque.c new file mode 100644 index 0000000..ffcc8b7 --- /dev/null +++ b/tools/testing/selftests/ipc/msgque.c @@ -0,0 +1,251 @@ +#include <stdio.h> +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/msg.h> +#include <errno.h> +#include <string.h> +#include <stdlib.h> + +#define MAX_MSG_SIZE 32 + +struct msg1 { + int msize; + long mtype; + char mtext[MAX_MSG_SIZE]; +}; + +#define TEST_STRING "Test sysv5 msg" +#define MSG_TYPE 1 + +#define ANOTHER_TEST_STRING "Yet another test sysv5 msg" +#define ANOTHER_MSG_TYPE 26538 + +#ifndef IPC_PRESET +#define IPC_PRESET 00040000 +#endif + +#ifndef MSG_COPY +#define MSG_COPY 040000 +#endi…
creator: Stanislav Kinsbursky
date: 2012-09-19T16:06:20-00:00

Re: [PATCH v5 01/10] ipc: remove forced assignment of selected message
type: item
description: Quoting Stanislav Kinsbursky (skinsbursky@parallels.com): > This is a cleanup patch. The assignment is redundant. > > Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> > --- > ipc/msg.c | 1 - > 1 files changed, 0 insertions(+), 1 deletions(-) > > diff --git a/ipc/msg.c b/ipc/msg.c > index 7385de2..f3bfbb8 100644 > --- a/ipc/msg.c > +++ b/ipc/msg.c > @@ -787,7 +787,6 @@ long do_msgrcv(int msqid, long *pmtype, void __user *mtext, > !security_msg_queue_msgrcv(msq, walk_msg, current, > msgtyp, mode)) { > > - msg = walk_msg; > if (mode == SEARCH_LESSEQUAL && > walk_msg->m_type != 1) { > msg = walk_msg; Perhaps your tree is different from mine, but it looks to me like it would be simpler to remove the 'msg = walk_msg' from both the 'if' and 'else', and keep them above the if/else?
creator: Serge E. Hallyn
date: 2012-09-26T17:37:18-00:00

Re: [PATCH v5 01/10] ipc: remove forced assignment of selected message
type: item
description: 26.09.2012 21:37, Serge Hallyn пишет: > Quoting Stanislav Kinsbursky (skinsbursky@parallels.com): >> This is a cleanup patch. The assignment is redundant. >> >> Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> >> --- >> ipc/msg.c | 1 - >> 1 files changed, 0 insertions(+), 1 deletions(-) >> >> diff --git a/ipc/msg.c b/ipc/msg.c >> index 7385de2..f3bfbb8 100644 >> --- a/ipc/msg.c >> +++ b/ipc/msg.c >> @@ -787,7 +787,6 @@ long do_msgrcv(int msqid, long *pmtype, void __user *mtext, >> !security_msg_queue_msgrcv(msq, walk_msg, current, >> msgtyp, mode)) { >> >> - msg = walk_msg; >> if (mode == SEARCH_LESSEQUAL && >> walk_msg->m_type != 1) { >> msg = walk_msg; > > Perhaps your tree is different from mine, but it looks to me like it would > be simpler to remove the 'msg = walk_msg' from both the 'if' and 'else', > and keep them above the if/else? > Yep, thanks. Will update. -- Best regards, Stanislav Kinsbursky
creator: Stanislav Kinsbursky
date: 2012-09-27T06:53:21-00:00