From patchwork Fri Mar 26 04:05:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zach Reizner X-Patchwork-Id: 1458639 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=uJlv6F1b; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4F6B1k3L12z9sRf for ; Fri, 26 Mar 2021 16:51:54 +1100 (AEDT) Received: from localhost ([::1]:36354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPfNw-0002A2-GT for incoming@patchwork.ozlabs.org; Fri, 26 Mar 2021 01:51:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47346) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPdjJ-0007Bm-JX for qemu-devel@nongnu.org; Fri, 26 Mar 2021 00:05:49 -0400 Received: from mail-io1-xd2a.google.com ([2607:f8b0:4864:20::d2a]:33720) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lPdjH-0000Gg-Tx for qemu-devel@nongnu.org; Fri, 26 Mar 2021 00:05:49 -0400 Received: by mail-io1-xd2a.google.com with SMTP id n198so4163484iod.0 for ; Thu, 25 Mar 2021 21:05:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=u2FSaFwHNbuIXo4Rj4KNZuMAQhbdV0hxmCSzZBy+Abc=; b=uJlv6F1bzZuMU7O7z7ZKRR3VLa1E/lFw6/pziakjv9dHI/9nrgPNgkRo8OkShfzuR2 TODAFOoNt47zs/1IsMC+HRqcvXN+MTHGd3o5kY8UPsYGv5XhFt4w4vbPyTcUcax9s9q4 MdyugdLSd8mLOcO1lleZs/4smzq59o7OAR8NdJyup3V2D7/k8uJg0CwsQoyGui8cAS37 DwHlDV/C5J8A89GB2tDMzzer0UWC9p3AEjMnNdILpgOtskPLbYDiLARP+qlLoh6uNII2 zFBoXaYo0zSeqD8WUQi6MnKJwLYMWAnLtfI93gU8UO8bQe/FNYNgImMBGGz3R9LpghF7 rZxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=u2FSaFwHNbuIXo4Rj4KNZuMAQhbdV0hxmCSzZBy+Abc=; b=Xbcj2kd9mt1vB9NCRp7JUwQykqXl8U+4msMyWFVywSIQSPm44wQKa9ik/7uLYcpqRH UJW2cu994b9N7ShXRK7avC2rc2Y9fpPfpQs4rg8ISjDUWhpVyHZhwfIBne/lXvnc/akP Lb2liUbGRQfNhR0nF08XM7s1TP/d8Ako4aG5zE4K2oV8rR2R7t8mF1+vGNXJRvI1SxiE DXW87ULaCJ2VSuytYwPNPvuLWy46/4qx6CqFBUUaJZSavZ6O5RHD/jS4+Y1I1a4yrfy+ N6EJ6bfv+ECmqyHiVmhlerDK25ElyptJCVyFoxK211YsN2QyBglOLKmtdGT5SSL8UpIB QYag== X-Gm-Message-State: AOAM530TSUgKm9Ntn/TBdu8obeNY87V7Zqc3uyqlm7L+PUuREHDOQLCb /BXD4CDlcKlvFWPx2DqO/Zsp3FjzpumcsuCSJzDpOEVHkbJfFw== X-Google-Smtp-Source: ABdhPJzS7G2z5aogWOTYicUWod36iElL2okpoxBLsQLhFIbTQREZWEN2kwalSOZnnVVhlSpgztN6OcnRAbku6lG115g= X-Received: by 2002:a5d:93ce:: with SMTP id j14mr9053470ioo.172.1616731545078; Thu, 25 Mar 2021 21:05:45 -0700 (PDT) MIME-Version: 1.0 From: Zach Reizner Date: Fri, 26 Mar 2021 00:05:29 -0400 Message-ID: Subject: [PATCH] linux-user: allow NULL msg in recvfrom To: qemu-devel@nongnu.org Cc: Laurent Vivier Received-SPF: pass client-ip=2607:f8b0:4864:20::d2a; envelope-from=zachr@google.com; helo=mail-io1-xd2a.google.com X-Spam_score_int: -175 X-Spam_score: -17.6 X-Spam_bar: ----------------- X-Spam_report: (-17.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5, USER_IN_DEF_SPF_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 26 Mar 2021 01:50:09 -0400 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The kernel allows a NULL msg in recvfrom so that he size of the next message may be queried before allocating a correctly sized buffer. This change allows the syscall translator to pass along the NULL msg pointer instead of returning early with EFAULT. Signed-off-by: Zach Reizner Reviewed-by: Laurent Vivier --- linux-user/syscall.c | 2 -- 1 file changed, 2 deletions(-) ret = -TARGET_EFAULT; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 1e508576c7..332544b43c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3680,8 +3680,6 @@ static abi_long do_recvfrom(int fd, abi_ulong msg, size_t len, int flags, abi_long ret; host_msg = lock_user(VERIFY_WRITE, msg, len, 0); - if (!host_msg) - return -TARGET_EFAULT; if (target_addr) { if (get_user_u32(addrlen, target_addrlen)) {