From nobody Mon May 6 15:06:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541674827826999.2221666650789; Thu, 8 Nov 2018 03:00:27 -0800 (PST) Received: from localhost ([::1]:55888 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKi2q-00079x-Uu for importer@patchew.org; Thu, 08 Nov 2018 06:00:16 -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) 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) 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-Google-Smtp-Source: AJdET5c4lH3ZUZCv2+HWb46ldICLUKZPAH+zMVB6cfXnP3+w7baWkIkS6q2OobUu0NhefvIY1DfXqQ== X-Received: by 2002:adf:9dd1:: with SMTP id q17-v6mr3585127wre.12.1541674754989; Thu, 08 Nov 2018 02:59:14 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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?Alex=20Benn=C3=A9e?= , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e CC: qemu-trivial@nongnu.org --- linux-user/syscall.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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, uin= t8_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 =3D NULL; abi_long ret; int i; =20 @@ -4715,7 +4715,7 @@ static abi_long do_ioctl_rt(const IOCTLEntry *ie, uin= t8_t *buf_temp, unlock_user(argptr, arg, 0); =20 ret =3D get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); - if (*host_rt_dev_ptr !=3D 0) { + if (host_rt_dev_ptr && *host_rt_dev_ptr !=3D 0) { unlock_user((void *)*host_rt_dev_ptr, *target_rt_dev_ptr, 0); } --=20 2.17.1