X-Git-Url: https://git.karo-electronics.de/?a=blobdiff_plain;f=ipc%2Fmsg.c;h=31cd1bf6af271771e67bdf6e29eb306371d3d130;hb=f8966048c128eff4f57f7c9e7f71360ebd10e1a9;hp=950572f9d7963858d46e01998fea00e14024f26b;hpb=ad60a9333035f2323840b71ab8ad07bbab728faf;p=karo-tx-linux.git diff --git a/ipc/msg.c b/ipc/msg.c index 950572f9d796..31cd1bf6af27 100644 --- a/ipc/msg.c +++ b/ipc/msg.c @@ -820,15 +820,17 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp, struct msg_msg *copy = NULL; unsigned long copy_number = 0; + ns = current->nsproxy->ipc_ns; + if (msqid < 0 || (long) bufsz < 0) return -EINVAL; if (msgflg & MSG_COPY) { - copy = prepare_copy(buf, bufsz, msgflg, &msgtyp, ©_number); + copy = prepare_copy(buf, min_t(size_t, bufsz, ns->msg_ctlmax), + msgflg, &msgtyp, ©_number); if (IS_ERR(copy)) return PTR_ERR(copy); } mode = convert_mode(&msgtyp, msgflg); - ns = current->nsproxy->ipc_ns; msq = msg_lock_check(ns, msqid); if (IS_ERR(msq)) {