From nobody Sun Feb 8 08:27:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1587137762; cv=none; d=zohomail.com; s=zohoarc; b=VV8tczm8cCWs/2sUhSRtkj2SptGgfSC+6RFfaROAwLWcH9aAisUafe8g4kiac5pn4y6a7amGsw71Ddw8MQvJzY+DUOyvATpKLbGTmHkzz8AFE4nMmRECmZF3lXaymIIrkISRgTRT21i1xqNhfAvqHQevQVa+nPccluJQOEvQYSw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587137762; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=kkCLmi9oWjBzkBGULATx+MJSyq22Wa4RJ0EZaDJRy5w=; b=dU9L7w4Xs+DVCB6RWCQhEEc3RpnGtxLATof31ojfgR1An6NlrD1LPSGWTzX8Rfoi/cJ+2OuphfHmM1fokVsGmIka+uCBUi/gHR2bjZPKJSwMH+EjE6ICTjVM2LjLMRNcsbZHxLnmkS2Xa3BXPt9B264dJjBpObtHWtQ8FgLDm00= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1587137762042289.15892050173306; Fri, 17 Apr 2020 08:36:02 -0700 (PDT) Received: from localhost ([::1]:48622 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jPT29-0005NE-70 for importer@patchew.org; Fri, 17 Apr 2020 11:36:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53423) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jPT1B-0004Ij-0i for qemu-devel@nongnu.org; Fri, 17 Apr 2020 11:35:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jPT19-0008B3-Iv for qemu-devel@nongnu.org; Fri, 17 Apr 2020 11:35:00 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:55016) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jPT19-0008AJ-AJ for qemu-devel@nongnu.org; Fri, 17 Apr 2020 11:34:59 -0400 Received: by mail-wm1-x341.google.com with SMTP id h2so3343283wmb.4 for ; Fri, 17 Apr 2020 08:34:59 -0700 (PDT) Received: from [192.168.1.199] (93-43-179-29.ip93.fastwebnet.it. [93.43.179.29]) by smtp.gmail.com with ESMTPSA id t63sm2738680wmt.37.2020.04.17.08.34.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Apr 2020 08:34:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=kkCLmi9oWjBzkBGULATx+MJSyq22Wa4RJ0EZaDJRy5w=; b=K9tgLHv/JApizKWcV3P8cHsOfW4snIrnooSzSj9xx6E+9vIh09hQa6E93zRo1ZnPvt 5hA1hNQPZo9NgcoMEqTdcunk4MQdVkE1D6//qiyGFtXMElYIDmSrdtSJesc6t/7RD6qu nntEEUSOAjzyktBBzySnFUn3FL2yXLzhIRjdFW7G3m7oU40j6Uwj73JBcvLgClBt5wwY 7XcK7X5TK+nKvZN5XuYT8Mkgvip2kGqKcRDGFl1yVo/u4T9wva6iCDMay/4ftyMQ+sPc GgFylIbZSKyxN2tEeap0yqyYq0zC4Q8E+NQ+mTgQxn/de7e5jdsUUgOd4orwpNkFTAjD R6ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=kkCLmi9oWjBzkBGULATx+MJSyq22Wa4RJ0EZaDJRy5w=; b=jOHTWPAScfWno9RIVByYuwG2AYHZ44nDeSYe0g8QKjpj/hhXoffQHbeI+25PxlOjsA U83ztkfLyvd6SuQU01qVHneQEOECpnx9vHwieZTNrWpLNZ1vUybutNaSLsgYTzKMdT+0 gIKUyMtaKmIgwRJAyYC0t9P86fKpQ7i8FhqUpX8xTtfnWwuwBg+StzF1lvoqL35bgCq+ eNBQIjVPgLMwtacsTvtnSE4eW+7jxdpu1BNYg+9gaHLpEN0vduwPumcS/7+4BfO9y43n zfcWmoR0fbjboX/puFzkkK2vq/8exaQPALluTlfXN+378rzMSbFKRvtfNJv51kC3K5kj 4qqg== X-Gm-Message-State: AGi0PuZqlUFni8mYnI8GW8sTYHIeciV4j1a2SLPUYQtDK2DQLgt+rxKp gpUlPBKxyw9ZPKzMBsQh+Bk= X-Google-Smtp-Source: APiQypJNuD/jykxSp/AiGq+uEbd9EcH7ayPUxYLINovnrPQCwpFXEmbYsuxZFvzL5AYgkGlZH8+9EQ== X-Received: by 2002:a1c:9891:: with SMTP id a139mr4235281wme.129.1587137696908; Fri, 17 Apr 2020 08:34:56 -0700 (PDT) To: qemu-devel@nongnu.org, Laurent Vivier From: LemonBoy Subject: [PATCH] linux-user: Prevent crash in epoll_ctl Message-ID: Date: Fri, 17 Apr 2020 17:34:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 Content-Language: en-US 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::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) Content-Type: text/plain; charset="utf-8" From 894bb5172705e46a3a04c93b4962c0f0cafee814 Mon Sep 17 00:00:00 2001 From: Giuseppe Musacchio Date: Fri, 17 Apr 2020 17:25:07 +0200 Subject: [PATCH] linux-user: Prevent crash in epoll_ctl The `event` parameter is ignored by the kernel if `op` is EPOLL_CTL_DEL, do the same and avoid returning EFAULT if garbage is passed instead of a valid pointer. Signed-off-by: Giuseppe Musacchio Reviewed-by: Laurent Vivier --- linux-user/syscall.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 674f70e70a..a51ff43f9b 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -12020,17 +12020,25 @@ static abi_long do_syscall1(void *cpu_env, int nu= m, abi_long arg1, struct epoll_event ep; struct epoll_event *epp =3D 0; if (arg4) { - struct target_epoll_event *target_ep; - if (!lock_user_struct(VERIFY_READ, target_ep, arg4, 1)) { - return -TARGET_EFAULT; + if (arg2 !=3D EPOLL_CTL_DEL) { + struct target_epoll_event *target_ep; + if (!lock_user_struct(VERIFY_READ, target_ep, arg4, 1)) { + return -TARGET_EFAULT; + } + ep.events =3D tswap32(target_ep->events); + /* + * The epoll_data_t union is just opaque data to the kerne= l, + * so we transfer all 64 bits across and need not worry wh= at + * actual data type it is. + */ + ep.data.u64 =3D tswap64(target_ep->data.u64); + unlock_user_struct(target_ep, arg4, 0); } - ep.events =3D tswap32(target_ep->events); - /* The epoll_data_t union is just opaque data to the kernel, - * so we transfer all 64 bits across and need not worry what - * actual data type it is. + /* + * before kernel 2.6.9, EPOLL_CTL_DEL operation required a + * non-null pointer, even though this argument is ignored. + * */ - ep.data.u64 =3D tswap64(target_ep->data.u64); - unlock_user_struct(target_ep, arg4, 0); epp =3D &ep; } return get_errno(epoll_ctl(arg1, arg2, arg3, epp)); --=20 2.20.1