From patchwork Mon Nov 6 15:32:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 741408 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp1151580wrr; Mon, 6 Nov 2023 07:33:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEko5F9mhd50RDain5oOpDDaqxuzomDtQ5L8jm17l5Hy5OVmEBEjDkO7ZR+rFGUPSJ60znr X-Received: by 2002:a05:620a:4686:b0:76f:2f7b:cf61 with SMTP id bq6-20020a05620a468600b0076f2f7bcf61mr34304773qkb.61.1699284829093; Mon, 06 Nov 2023 07:33:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699284829; cv=none; d=google.com; s=arc-20160816; b=boShB8JTKEvgYzEk3xIndcW511jCBK1PnfG0OeE+5tXdnD/Px9SH+1W9ehCIJRZGWy orgfmrqyQUevr5FxT0aU+n+CjFFPF1psvY0GlpsnvS6kgNbqH2VFI/TAXTEg3SP2LQTL NSeCAcZmYnO7Wfc0/97sxKUUqEHk1aTZ9sQ+T/4fRnIQioZJGVAZdrnqY9nwlnV9JReF RHOMXdKZjSg/70jK7i9kXGAx59yOmV7SKT0MLwcr9oi/r3WVu0WpHZD3koUCNenMg+PH r8uqzWn9qYnsZmAkEUyX2MpI/UNaB5cHau9/UN3sDsbqDuYzbftBqGs1a9+w7QhCvesk aidg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=QiKPJfj6026HtJyHgqnn8HlAlq2ojaeDiEbXyPDrg7Y=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=pHeooxjC8KspiJcqUnXp0FgdyIDNCxvBcuthQqdS2eI00cAC+sAIaIXbzU/DdsxLz/ zMCCGY0Ae5V25A64xDUCa2QJVhx9N7GWbWCqVLV/hRwrwUwU53UvMZITizjlUbZpLKGK oqEopfb9sF+yZPNl9h3JM2pHiP25zhWINxbIxAkHFsOb5+cLpmNibVCkIWTKDFAM5ml/ QkKlTwSQc0Op+GYpdqzP7XY/LCdGxMzQdUwqlRTaxRbkm9JDJV69CCoVKlvOKXFP+8yJ 8yYLWOa6z38Vzjyu3wkkvd779HPYAAxP9ASd4ZTUQyNv2Ut5rpuVfCOxrXYDqA0/5eU9 4oQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HFVPB0TM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h14-20020a37de0e000000b0076da64decfbsi5584039qkj.63.2023.11.06.07.33.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Nov 2023 07:33:49 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HFVPB0TM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r01b9-00007O-GR; Mon, 06 Nov 2023 10:33:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r01aw-00082U-RE for qemu-devel@nongnu.org; Mon, 06 Nov 2023 10:32:57 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r01ao-0004OU-Km for qemu-devel@nongnu.org; Mon, 06 Nov 2023 10:32:53 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-40837ebba42so29055415e9.0 for ; Mon, 06 Nov 2023 07:32:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699284764; x=1699889564; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=QiKPJfj6026HtJyHgqnn8HlAlq2ojaeDiEbXyPDrg7Y=; b=HFVPB0TMFU74PbywsMIr4XgMECKYpELpb1YXdtqsFqjzl6+kiiVwIYPV1DPfvUvn7T aQpmRTLECJwoT8RVcLfZhBBrBeDdabUxYpIyJ1lWLI+NaNi5v8EakMTvzEcDHbTlbQmA dqeVJXBBx4cjPVtgwigC8txWMiWGuU+xV4qWD496apX8Nw2l7PV1VWZHEeX8idK2bD7N kxZ3tge2o22k1zYxNW0eGLqEOlee2CZcpDN7uiWO6mlOTrs6yM83Q/RmbI6qkZIhl9F3 dFiB+KVQqinAS/ufwblB5JJIf0N1n1/bcYxBhlK69WmFUIEWXV8fOj9NRu+uXf7sKc+U Ma3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699284764; x=1699889564; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QiKPJfj6026HtJyHgqnn8HlAlq2ojaeDiEbXyPDrg7Y=; b=ejWOov+5mGef1L9b1uRytiwSkzueFRIpaUIPtI7V4slvgKHYgSv5yxv0Kqm5SyLyIl 0KenYAjtZUNEPq++vAU1mzdQun9/8nOgeFNpMZcZblR4Y1pTQ6712pi/RM/ZTtVR0DLr w8VVTQJfVNr/sv3I9e4wjYdK26DH868MnMpxsjYx/XW0xNQlZ4AARRPhQ60zOmGO/g1+ s8XiuKH36DMhPcAyZY1+ikfPTsvsVgGcxAH2qAywj4oIU7iWMs9o9IpXeOOUoxVK680R U4QmJk0q+FU6FbIseZtXcJdTsugUlLDLwU3FTbYxI4xbcff36S6DulWjHuMobcwssMnc tTNw== X-Gm-Message-State: AOJu0YwcBGHUKpOtRyIlM5GITueE2y7komq7/i8Szvr3DNG33IvMPWcv wBclW2dBRX/QDqOvJAo3o4CcFqohDMiTYsZYI24= X-Received: by 2002:a05:6000:4020:b0:32d:b06c:80b2 with SMTP id cp32-20020a056000402000b0032db06c80b2mr23849710wrb.0.1699284763905; Mon, 06 Nov 2023 07:32:43 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id d5-20020adff2c5000000b0032da6f17ffdsm9752176wrp.38.2023.11.06.07.32.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 07:32:43 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 10/12] io/channel-socket: qio_channel_socket_flush(): improve msg validation Date: Mon, 6 Nov 2023 15:32:36 +0000 Message-Id: <20231106153238.1426649-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231106153238.1426649-1-peter.maydell@linaro.org> References: <20231106153238.1426649-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Vladimir Sementsov-Ogievskiy For SO_EE_ORIGIN_ZEROCOPY the 32-bit notification range is encoded as [ee_info, ee_data] inclusively, so ee_info should be less or equal to ee_data. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Maksim Davydov Message-id: 20231017125941.810461-7-vsementsov@yandex-team.ru Signed-off-by: Peter Maydell --- io/channel-socket.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/io/channel-socket.c b/io/channel-socket.c index 02ffb51e995..3a899b06085 100644 --- a/io/channel-socket.c +++ b/io/channel-socket.c @@ -782,6 +782,11 @@ static int qio_channel_socket_flush(QIOChannel *ioc, "Error not from zero copy"); return -1; } + if (serr->ee_data < serr->ee_info) { + error_setg_errno(errp, serr->ee_origin, + "Wrong notification bounds"); + return -1; + } /* No errors, count successfully finished sendmsg()*/ sioc->zero_copy_sent += serr->ee_data - serr->ee_info + 1;