From patchwork Wed Mar 21 14:39:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 888886 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.com Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 405ssH4M86z9s0x for ; Thu, 22 Mar 2018 01:40:03 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 6EDBE3E767E for ; Wed, 21 Mar 2018 15:40:00 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [IPv6:2001:4b78:1:20::7]) by picard.linux.it (Postfix) with ESMTP id 0CD3B3E754F for ; Wed, 21 Mar 2018 15:39:49 +0100 (CET) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 66028200D38 for ; Wed, 21 Mar 2018 15:39:48 +0100 (CET) Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id DA602AF0A; Wed, 21 Mar 2018 14:39:47 +0000 (UTC) From: Richard Palethorpe To: ltp@lists.linux.it Date: Wed, 21 Mar 2018 15:39:25 +0100 Message-Id: <20180321143927.12156-2-rpalethorpe@suse.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180321143927.12156-1-rpalethorpe@suse.com> References: <20180321143927.12156-1-rpalethorpe@suse.com> X-Virus-Scanned: clamav-milter 0.99.2 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-7.smtp.seeweb.it Cc: Richard Palethorpe , nstange@suse.de, ebiggers@google.com Subject: [LTP] [PATCH v2 1/3] lib: Check received message was not truncated X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Richard Palethorpe --- lib/safe_net.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/safe_net.c b/lib/safe_net.c index 64e2cbcf6..ba38fc08e 100644 --- a/lib/safe_net.c +++ b/lib/safe_net.c @@ -240,8 +240,19 @@ ssize_t safe_recvmsg(const char *file, const int lineno, size_t len, file, lineno, sockfd, msg, flags, rval, len); } - return rval; + if (msg->msg_flags & MSG_TRUNC) { + tst_brkm(TBROK, NULL, + "%s:%d: recvmsg(%d, %p, %d): buffer is too small", + file, lineno, sockfd, msg, flags); + } + if (msg->msg_flags & MSG_CTRUNC) { + tst_brkm(TBROK, NULL, + "%s:%d: recvmsg(%d, %p, %d): control buffer is too small", + file, lineno, sockfd, msg, flags); + } + + return rval; } int safe_bind(const char *file, const int lineno, void (cleanup_fn)(void),