From patchwork Sun Oct 9 13:31:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugene Syromyatnikov X-Patchwork-Id: 9369139 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B4B6560865 for ; Mon, 10 Oct 2016 08:33:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A72B929325 for ; Mon, 10 Oct 2016 08:33:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C3562932F; Mon, 10 Oct 2016 08:33:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 44AFD2933E for ; Mon, 10 Oct 2016 08:33:25 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u9A8Us1E013014; Mon, 10 Oct 2016 04:30:54 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u99DV8Z2016799 for ; Sun, 9 Oct 2016 09:31:08 -0400 Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u99DV8UE005649 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 9 Oct 2016 09:31:08 -0400 Received: from mail-lf0-f66.google.com (mail-lf0-f66.google.com [209.85.215.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C64A0201EA; Sun, 9 Oct 2016 13:31:06 +0000 (UTC) Received: by mail-lf0-f66.google.com with SMTP id p80so5475393lfp.1; Sun, 09 Oct 2016 06:31:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=w1F0WiQ8l8Bs4D2vBqZxStIQ9ZeAX0MMcQMMwMxCM9Y=; b=mm/v0a5FnilnbR7WnA2fRM4QCHUsbLL1/eyKu66EN2ejfc0ql15P67qDwMiFzaeF05 LrmkYNt0ny37gMRxEakVKdOQdn401r+g7O1rH1SMyoVVfanIgqKBeAlw1ognc1mnkVMU WCWVJElPX/Fe12AlhDgeK7JbOsGpyTQugqL5cuA0LlbZb4VLLNJfbzwvlzNK1wqw8JVP LFlIcFNm5B4thklJo9LLTXLAtPyHT4wxe8tspTCvm3MvvUbKyrYaFnCCO2a0V5EcrNUy TWcyggfzqxv4Sq4Z3xG4DNqapRWPRs8QXaIsCQ6yDCCiTCp/Hynfvo5SsYilc7V0c0sf Kz3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=w1F0WiQ8l8Bs4D2vBqZxStIQ9ZeAX0MMcQMMwMxCM9Y=; b=dH7h8tgBm9KC+dNsR9p57s1/q3HQQpMmaFcSHFZzbpfUeHRqRYes90T3F2J3kzfUz8 fYAsShq2/5WWh7Gy1xarY7GqL32YR9V1T7jH/1wOvizejgUA0A+xGZBN7J0lphtJWhKZ LJVPNVhF6034yfh1pLtZperJcYbPvqPQlyRJYzNbJjDGp7xqijHmYApmkVUDxjYDPicQ O+SCuJSoiqplxmEqzlLBVVDyuDiIwUBf1t5x55auwtYWd0JPI8kDSb8udrhP5myQOTA7 vW/PhWzUIASt8u/lcxOsMaYqsIT2w0xUCaMUEY2fivwO7ZT78MBMrupqnGH3YuIFe5NJ xYUw== X-Gm-Message-State: AA6/9Rmmc/RRnVuplGFYSoaIVlb8JaRycsy6YXkxZbtyODDMP5H/FiyeA9GqZdJqC1A3ig== X-Received: by 10.46.0.152 with SMTP id e24mr11402230lji.21.1476019865174; Sun, 09 Oct 2016 06:31:05 -0700 (PDT) Received: from obsidian (broadband-46-188-15-144.2com.net. [46.188.15.144]) by smtp.gmail.com with ESMTPSA id 197sm5186455ljj.0.2016.10.09.06.31.04 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Sun, 09 Oct 2016 06:31:04 -0700 (PDT) Date: Sun, 9 Oct 2016 16:31:02 +0300 From: Eugene Syromyatnikov To: strace-devel@lists.sourceforge.net Message-ID: <20161009133102.GA4014@obsidian> References: <20161005.192828.566127461630656590.yamato@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20161005.192828.566127461630656590.yamato@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Sun, 09 Oct 2016 13:31:07 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Sun, 09 Oct 2016 13:31:07 +0000 (UTC) for IP:'209.85.215.66' DOMAIN:'mail-lf0-f66.google.com' HELO:'mail-lf0-f66.google.com' FROM:'evgsyr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.17 * (BAYES_50, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, SPF_PASS) 209.85.215.66 mail-lf0-f66.google.com 209.85.215.66 mail-lf0-f66.google.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Mon, 10 Oct 2016 04:29:54 -0400 Cc: dm-devel@redhat.com, mpatocka@redhat.com, yamato@redhat.com Subject: [dm-devel] [PATCH 15/21] dm: Additional data_size/data_start checks X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Virus-Scanned: ClamAV using ClamSMTP --- dm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dm.c b/dm.c index 814d7d2..289bc0d 100644 --- a/dm.c +++ b/dm.c @@ -293,7 +293,8 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) if (!ioc) return 0; - if (umoven(tcp, arg, sizeof(*ioc) - sizeof(ioc->data), ioc) < 0) { + if ((umoven(tcp, arg, sizeof(*ioc) - sizeof(ioc->data), ioc) < 0) || + (ioc->data_size < offsetof(struct dm_ioctl, data_size))) { free(ioc); return 0; } @@ -335,6 +336,11 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) goto skip; } + if (ioc->data_size < (sizeof(*ioc) - sizeof(ioc->data))) { + tprints(", /* Incorrect data_size */ ..."); + goto skip; + } + dm_decode_device(code, ioc); dm_decode_values(tcp, code, ioc); dm_decode_flags(ioc);