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: 13447116 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 3E6A6C4332F for ; Mon, 6 Nov 2023 15:33:49 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IEsr5rVh7k45aW+bVkiTPIq1IYuFX9hCrjFFIJighT2uIfH9gzgMG+b/KHNCgB9aLvEXqtfWQ== 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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;