From owner-svn-src-stable-11@freebsd.org Mon May 29 06:26:02 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0EF42C7DCE1; Mon, 29 May 2017 06:26:02 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DF07D818; Mon, 29 May 2017 06:26:01 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v4T6Q1iu028977; Mon, 29 May 2017 06:26:01 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v4T6Q1em028975; Mon, 29 May 2017 06:26:01 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201705290626.v4T6Q1em028975@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Mon, 29 May 2017 06:26:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r319095 - stable/11/contrib/netbsd-tests/lib/libc/sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 May 2017 06:26:02 -0000 Author: ngie Date: Mon May 29 06:26:00 2017 New Revision: 319095 URL: https://svnweb.freebsd.org/changeset/base/319095 Log: MFC r316179,r316180,r316181,r316260: r316179 (by cem): t_msgsnd: Use msgsnd()'s msgsz argument correctly to avoid overflow msgsnd's msgsz argument is the size of the message following the 'long' message type. Don't include the message type in the size of the message when invoking msgsnd(2). CID: 1368712 r316180 (by cem): Follow-up to r316179: More of the same CIDs: 1368705, 1368706, 1368707, 1368710 r316181 (by cem): t_msgctl: Fix the same msgsnd() misuse as t_msgsnd msgsnd(2)'s msgsz argument does not describe the full structure, only the message component. CIDs: 1368703, 1368711 r316260: Annotate all changes made in r316178-r316180 with __FreeBSD__ Restore the stock (upstream) code under an #else block, so it's easier for me to visualize and understand the code that needs to be upstreamed. Modified: stable/11/contrib/netbsd-tests/lib/libc/sys/t_msgctl.c stable/11/contrib/netbsd-tests/lib/libc/sys/t_msgsnd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/netbsd-tests/lib/libc/sys/t_msgctl.c ============================================================================== --- stable/11/contrib/netbsd-tests/lib/libc/sys/t_msgctl.c Mon May 29 06:25:59 2017 (r319094) +++ stable/11/contrib/netbsd-tests/lib/libc/sys/t_msgctl.c Mon May 29 06:26:00 2017 (r319095) @@ -203,7 +203,11 @@ ATF_TC_BODY(msgctl_pid, tc) if (pid == 0) { +#ifdef __FreeBSD__ + (void)msgsnd(id, &msg, sizeof(msg.buf), IPC_NOWAIT); +#else (void)msgsnd(id, &msg, sizeof(struct msg), IPC_NOWAIT); +#endif _exit(EXIT_SUCCESS); } @@ -314,7 +318,11 @@ ATF_TC_BODY(msgctl_time, tc) t = time(NULL); (void)memset(&msgds, 0, sizeof(struct msqid_ds)); +#ifdef __FreeBSD__ + (void)msgsnd(id, &msg, sizeof(msg.buf), IPC_NOWAIT); +#else (void)msgsnd(id, &msg, sizeof(struct msg), IPC_NOWAIT); +#endif (void)msgctl(id, IPC_STAT, &msgds); if (llabs(t - msgds.msg_stime) > 1) Modified: stable/11/contrib/netbsd-tests/lib/libc/sys/t_msgsnd.c ============================================================================== --- stable/11/contrib/netbsd-tests/lib/libc/sys/t_msgsnd.c Mon May 29 06:25:59 2017 (r319094) +++ stable/11/contrib/netbsd-tests/lib/libc/sys/t_msgsnd.c Mon May 29 06:26:00 2017 (r319095) @@ -98,7 +98,11 @@ ATF_TC_BODY(msgsnd_block, tc) */ for (;;) { +#ifdef __FreeBSD__ + if (msgsnd(id, &msg, sizeof(msg.buf), 0) < 0) +#else if (msgsnd(id, &msg, sizeof(struct msg), 0) < 0) +#endif _exit(EXIT_FAILURE); } } @@ -140,7 +144,11 @@ ATF_TC_BODY(msgsnd_count, tc) for (;;) { errno = 0; +#ifdef __FreeBSD__ + rv = msgsnd(id, &msg, sizeof(msg.buf), IPC_NOWAIT); +#else rv = msgsnd(id, &msg, sizeof(struct msg), IPC_NOWAIT); +#endif if (rv == 0) { i++; @@ -184,12 +192,20 @@ ATF_TC_BODY(msgsnd_err, tc) errno = 0; ATF_REQUIRE_ERRNO(EFAULT, msgsnd(id, (void *)-1, +#ifdef __FreeBSD__ + sizeof(msg.buf), IPC_NOWAIT) == -1); +#else sizeof(struct msg), IPC_NOWAIT) == -1); +#endif errno = 0; ATF_REQUIRE_ERRNO(EINVAL, msgsnd(-1, &msg, +#ifdef __FreeBSD__ + sizeof(msg.buf), IPC_NOWAIT) == -1); +#else sizeof(struct msg), IPC_NOWAIT) == -1); +#endif errno = 0; @@ -200,7 +216,11 @@ ATF_TC_BODY(msgsnd_err, tc) msg.mtype = 0; ATF_REQUIRE_ERRNO(EINVAL, msgsnd(id, &msg, +#ifdef __FreeBSD__ + sizeof(msg.buf), IPC_NOWAIT) == -1); +#else sizeof(struct msg), IPC_NOWAIT) == -1); +#endif ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0); } @@ -234,7 +254,11 @@ ATF_TC_BODY(msgsnd_nonblock, tc) for (;;) { errno = 0; +#ifdef __FreeBSD__ + rv = msgsnd(id, &msg, sizeof(msg.buf), IPC_NOWAIT); +#else rv = msgsnd(id, &msg, sizeof(struct msg), IPC_NOWAIT); +#endif if (rv == -1 && errno == EAGAIN) _exit(EXIT_SUCCESS); @@ -299,7 +323,11 @@ ATF_TC_BODY(msgsnd_perm, tc) errno = 0; +#ifdef __FreeBSD__ + if (msgsnd(id, &msg, sizeof(msg.buf), IPC_NOWAIT) == 0) +#else if (msgsnd(id, &msg, sizeof(struct msg), IPC_NOWAIT) == 0) +#endif _exit(EXIT_FAILURE); if (errno != EACCES)