From patchwork Thu Nov 8 10:59:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 150499 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp675652ljp; Thu, 8 Nov 2018 02:59:41 -0800 (PST) X-Google-Smtp-Source: AJdET5fLwGGwVzZOvnuwf5XjsBROfVskvVVY2CSkHs6AOkiW0zBYBQ88mYK987BVomi3VwVMkVWF X-Received: by 2002:a37:86c5:: with SMTP id i188mr406102qkd.81.1541674780941; Thu, 08 Nov 2018 02:59:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541674780; cv=none; d=google.com; s=arc-20160816; b=f5Nj3/wdhuzp2oYZ304+arAxJ7TyTzEaaaSOna8W0zovGBuxJmMTN5RnyNChqN/R/G 1voCII9JloJYSp7lKS8r58V/T/8s+QfOkaU0wZM7dS4CqOG/p0HiitE6S0QN8RvsWwf9 ZU8WFea7J0TnvPxQSKpi4ABAEU05+D1KS1FfRdZv0P+8UelqeyiGgP3/gXUcHS/06qLz 7eUOdefyhTDk0lP3QYPJFI6tQwesNnvu1J7AaCJ4bKc6qCNd/MdKaHHHk19ZfKCLsOC6 3EWyVoyIh66MMcFQ8sTAsUX5oUAbHac3sZ3HCoXmquW2wSjFhE4mB9enn10i4ExLbqaz b5GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:message-id:date:to:from :dkim-signature; bh=vkt28YUk2b8VXkuvPjG4t57qv2BficVRMJGaBsWH6Vo=; b=p8kkZv+oNvTIKeUZEUuZutKNASsM1SjjG1NJ5vOMuGyA/jDELmLYUvDk0qaX3l5Jav TBKWIoWQYSVwdqQGroiJP5iHJCRNCAPrNSFICJQWkAeC+U+EXQyo+8NsGEbtcZycbpVz DJ1XVywPKrbpAv2QWp0P5tJqPoVH2TPOPp/dnQRg8E8+QEWIvPbsEXXVVBkF09Y5739H 8ximb24nlj5XRRQOlXpizmF570g+slrOwk29agVqVRysbUXvKLnbFn2lDkbqzzuPXtzD OE5eWQMotHDDg0/Zs1AZnHCn837mL5CiliN+LS/JRQ202bJhcywv5tItDtCYcNOUk8bj zPkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LBqRnont; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m93si2510756qtd.270.2018.11.08.02.59.40 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 08 Nov 2018 02:59:40 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LBqRnont; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55884 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKi2F-0006W0-SW for patch@linaro.org; Thu, 08 Nov 2018 05:59:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKi1x-0006Vq-6A for qemu-devel@nongnu.org; Thu, 08 Nov 2018 05:59:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKi1t-0003EP-Bu for qemu-devel@nongnu.org; Thu, 08 Nov 2018 05:59:20 -0500 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:42935) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gKi1t-0003Dl-3E for qemu-devel@nongnu.org; Thu, 08 Nov 2018 05:59:17 -0500 Received: by mail-wr1-x441.google.com with SMTP id y15-v6so20733086wru.9 for ; Thu, 08 Nov 2018 02:59:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vkt28YUk2b8VXkuvPjG4t57qv2BficVRMJGaBsWH6Vo=; b=LBqRnontum9mURNVGdWI7nL8/lezsV9/Uykrhe26LKKG8R9zsoKRwG7997Pztn96Lo q2TOxK4nIOxVQDqK4FnsE/Ct4ND9AbbC5F3Jb1Cxg641XtohVLTnl65jy9gbDDYMf2xZ 8YEGOSoxWkuihrsZMFWmO4JcfTRnVdCO0JMmc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vkt28YUk2b8VXkuvPjG4t57qv2BficVRMJGaBsWH6Vo=; b=aV/R0Z0gCfdmm7Kw3dySqNUZ6g9EUsRyyyGcIXQhlcqHTpivx+sr4txYR4Yc87oaOr Wz4G90Ee8kI1n5PKRFzQT5lORq8ssm5NB6OTlCs1B+dy6hu0UoIne6VTU4f4sneb7L4e 5GK+uaHG0hdeBiP5qmT+b+LAMsGSaHniez4ccVtIt42Jy/omawEtCT3TCsdf6Y0C1MY8 1b+rMqPKNEZRB6YWd6BvC1oM3/rgLSWr7j8cB0M4WPJJvTVYeZC8NKEwE4O7Bp/Q+3mE gzBVQuvRWVJZnUpNDcvIfc0mftlh9sqBFOPpg5hiRNSW5kseEcdEyAUwQUaSlOZtgapU sAqg== X-Gm-Message-State: AGRZ1gJ9gjP77TpcXsMADkCXY9IYvhQlg8lFHqpCtiCcEpx99088Pj2y SElG+sNo3wZpIovkqG0lkWELgg== X-Received: by 2002:adf:9dd1:: with SMTP id q17-v6mr3585127wre.12.1541674754989; Thu, 08 Nov 2018 02:59:14 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id y2-v6sm7774663wrh.53.2018.11.08.02.59.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Nov 2018 02:59:14 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id B7D083E009E; Thu, 8 Nov 2018 10:59:13 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Thu, 8 Nov 2018 10:59:04 +0000 Message-Id: <20181108105904.27980-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PATCH] linux-users/syscall: make do_ioctl_rt safer X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-trivial@nongnu.org, Riku Voipio , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" host_rt_dev_ptr is set while looping through a control structure. The compiler can not know that all structures passed to do_ioctl_rt will trigger the if clause so rightly complains with an --enable-sanitizers build. To keep the compiler happy we default the host_rt_dev_ptr and check it has been set before attempting to follow it. Signed-off-by: Alex Bennée CC: qemu-trivial@nongnu.org --- linux-user/syscall.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 810a58b704..3a942f1f4a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4669,7 +4669,7 @@ static abi_long do_ioctl_rt(const IOCTLEntry *ie, uint8_t *buf_temp, int target_size; void *argptr; abi_ulong *target_rt_dev_ptr; - unsigned long *host_rt_dev_ptr; + unsigned long *host_rt_dev_ptr = NULL; abi_long ret; int i; @@ -4715,7 +4715,7 @@ static abi_long do_ioctl_rt(const IOCTLEntry *ie, uint8_t *buf_temp, unlock_user(argptr, arg, 0); ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); - if (*host_rt_dev_ptr != 0) { + if (host_rt_dev_ptr && *host_rt_dev_ptr != 0) { unlock_user((void *)*host_rt_dev_ptr, *target_rt_dev_ptr, 0); }