From patchwork Sun Oct 9 13:31:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugene Syromyatnikov X-Patchwork-Id: 9369125 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 4BF6060487 for ; Mon, 10 Oct 2016 08:33:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E6BF29325 for ; Mon, 10 Oct 2016 08:33:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 336C12933B; Mon, 10 Oct 2016 08:33:14 +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=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D3A7029325 for ; Mon, 10 Oct 2016 08:33:13 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9A8Umbt053216; Mon, 10 Oct 2016 04:30:48 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u99DVYNO017023 for ; Sun, 9 Oct 2016 09:31:34 -0400 Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u99DVY3f012946 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 9 Oct 2016 09:31:34 -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 53C168553C; Sun, 9 Oct 2016 13:31:33 +0000 (UTC) Received: by mail-lf0-f66.google.com with SMTP id x79so2030441lff.2; Sun, 09 Oct 2016 06:31:33 -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=mGU+QhLwNuticIEVw72Km0/lIAzjXm6A136wViHZWLo=; b=qzooi9J4+OFOfirPhWxp0qIutM6ZwvXkrgEsokFAVoe/bQxGvzdqxwlLmgbDR29Lcc Q6ZtKfkSzAaTGjBE0Iic8oYGKRpQPPb9dVDUvbQwIJ7+FtlQdYwaJtceGrWJYrMmjCpb qKcUwhZW1XvyeRnpBn0spdR+9GdOPdWkGcm/LR402eTCc6lVwk4vFZgFFCGPJ0suYuYA gb9nMYQyP4dOzQ0pdTFd5qTBhRQRXpPRJhB8aR+9Gj0daKh4E+DTLUoxt6vXO9JKKgDy o4peP0yJRXPCPr8SyzDslR6iBHfhoca/0vwWLC+jvVbpY/idOJNmESgxz+N7RHLWPUtL 45cg== 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=mGU+QhLwNuticIEVw72Km0/lIAzjXm6A136wViHZWLo=; b=enTsBYRLdG4zN+wwrGphoSnTfbYXJrHVekKBV58+CQJhnUvnAjv7lbLbsHBGDNxAIs 3X9/Fw/AIRoqnBA68hoFYWP6OOcdoDficutR02X7ObpVM4fNEwijr5fRqZkvQorPEuIX gdrWBAiCnJseSyVo8bs3mCZgumFM8mOAuSg+N6Nc08FoWsCMDQXZ/fAVUhDb9EQdeDme zkvKZv7e0qjjR0/uucw1OG/VGTPY7V1ugmTi36Do9tiaxH38nsKecgJz+4WzyV7f0Von aG4wgPp9N2Nl5fWhymc+AWYiPJrqOKN87OtS6XHEJIZffDwVhklGzOm1tHeN4ZYGNmRz sQOg== X-Gm-Message-State: AA6/9RmoPXxyN0jOd6IkPnwbLiaqzLh70/O7p2WOv3XFuPGe1KaBUZgjl02PFeXSxrwo5A== X-Received: by 10.25.139.86 with SMTP id n83mr25141lfd.72.1476019891684; Sun, 09 Oct 2016 06:31:31 -0700 (PDT) Received: from obsidian (broadband-46-188-15-144.2com.net. [46.188.15.144]) by smtp.gmail.com with ESMTPSA id n14sm5181466lfn.7.2016.10.09.06.31.30 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Sun, 09 Oct 2016 06:31:31 -0700 (PDT) Date: Sun, 9 Oct 2016 16:31:29 +0300 From: Eugene Syromyatnikov To: strace-devel@lists.sourceforge.net Message-ID: <20161009133129.GA4492@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.28]); Sun, 09 Oct 2016 13:31:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Sun, 09 Oct 2016 13:31:33 +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.22 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 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 19/21] dm: Add check whether command uses parameters 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 | 25 ++++++++++++++++++++++--- tests/ioctl_dm.c | 2 +- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/dm.c b/dm.c index caffc55..a48aa72 100644 --- a/dm.c +++ b/dm.c @@ -281,6 +281,23 @@ dm_decode_string(const struct dm_ioctl *ioc, const char *extra, } } +static inline bool +dm_ioctl_has_params(const unsigned int code) +{ + switch (code) { + case DM_VERSION: + case DM_REMOVE_ALL: + case DM_DEV_CREATE: + case DM_DEV_REMOVE: + case DM_DEV_SUSPEND: + case DM_DEV_STATUS: + case DM_TABLE_CLEAR: + return false; + } + + return true; +} + static int dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) { @@ -336,8 +353,10 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) goto skip; } - tprintf(", data_size=%u, data_start=%u", - ioc->data_size, ioc->data_start); + tprintf(", data_size=%u", ioc->data_size); + + if (dm_ioctl_has_params(code)) + tprintf(", data_start=%u", ioc->data_start); if (ioc->data_size < (sizeof(*ioc) - sizeof(ioc->data))) { tprints(", /* Incorrect data_size */ ..."); @@ -348,7 +367,7 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) dm_decode_values(tcp, code, ioc); dm_decode_flags(ioc); - if (ioc->data_size > sizeof(ioc)) { + if (dm_ioctl_has_params(code) && (ioc->data_size > sizeof(ioc))) { extra = malloc(ioc->data_size); if (extra) { extra_size = ioc->data_size; diff --git a/tests/ioctl_dm.c b/tests/ioctl_dm.c index c120ed2..6ad4ea9 100644 --- a/tests/ioctl_dm.c +++ b/tests/ioctl_dm.c @@ -40,7 +40,7 @@ main(void) init_s(&s.ioc, sizeof(s.ioc), 0); ioctl(-1, DM_VERSION, &s); printf("ioctl(-1, DM_VERSION, " - "{version=4.1.2, data_size=%zu, data_start=0, " + "{version=4.1.2, data_size=%zu, " "dev=makedev(18, 52), name=\"nnn\", uuid=\"uuu\", flags=0}) = " "-1 EBADF (%m)\n", sizeof(s.ioc));