Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2919293rwb; Fri, 20 Jan 2023 08:55:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXvlYd6svwjBoz9q/gH8AbR7tSErWbGNXbtnb/2dkZZAxQ572alKkWMEfwdRYZaBxCJB3duH X-Received: by 2002:a05:6a20:e608:b0:b8:60ec:9dd5 with SMTP id my8-20020a056a20e60800b000b860ec9dd5mr15486053pzb.12.1674233749265; Fri, 20 Jan 2023 08:55:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674233749; cv=none; d=google.com; s=arc-20160816; b=IKgEO2kCenVf13akMteXFg+aOGcxl8clSh2ogTKHU79ogrUc8na64CbiYwxmm5tqrK 90W/X/mY1qmOVV2xcmEkfQppWzefONrVTDrfcJ0JsHyIeG3e0xxN3/A/N6ZeIIoPDP4g ZkqcZZDHjddYcggWDJ7mSCu0aHZje+fzUsDycqmGk86swrwP5H6M6COmdSNT0m/6xvez KomsyFedvpRK0puKXRN/WCZC3GnjYYDrmfYHRiSib1FQkO7PQL5N4kA7ih5R19dh0FBw 5fWfUgLfxtE/Dh2oQge4/iRAhns3K/QdHDiQ5XhlQqP6MD7BitseV6jHue/zmsFgqu47 K5ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=hjntZEfpFwJ8Y1nwbuuwBdJ7RLdR/QUwA2oNP7WBo9w=; b=Kktlg2VPfyxvKxJKlwYQ0D7UhDAAGN5H/70gqs3zj/N40r3YbuukLPgCqNjH+9amNQ 9tDg+21AX2Fa8Yp+OVXOVu2aZb1wLkjko0b03MraJ4zF/ProYSbSjZQMDz2nKXPCncAR ql4JZ3aLi1sSwWYFi6rqBs6s2tRlG5q0HEqc9EzbW32BdrOk6+UcMOG1Xra/jza1/IBF VywT5DA/GfFkQ9ftMdhp1VM3eXDeo7KtQjN9IaJkc+vq6GBdXYWrtPcTknJBcGCSltk2 tuBslFbxtYXHPXx3hmxrumntHDK5O2mq6nZP4HANByK5A+izIyiI97TdnxOE7Of9w0kq vmMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MR9xSx8W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w11-20020a63490b000000b0049148558226si44270825pga.681.2023.01.20.08.55.43; Fri, 20 Jan 2023 08:55:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MR9xSx8W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229808AbjATQlj (ORCPT + 50 others); Fri, 20 Jan 2023 11:41:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230365AbjATQlg (ORCPT ); Fri, 20 Jan 2023 11:41:36 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEF9E39CD5 for ; Fri, 20 Jan 2023 08:41:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674232891; x=1705768891; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=O6hXbtgh6Uq7IHfnbRaJzZU+JzJyUzqxHcKuTZ5XDnI=; b=MR9xSx8WwffASMSgUw6+0H1q4B4yrU5s+Ya2wSIG5Gs1+JOatdMbdKnr 9RNCqOs9QRYtywm32X8Rsn0sh3D1lzVWwRI5fueSocm2sO0yZTX7+jeSy BBg7GPC16c0R5K8X0WByYVFap5U8tDbWBeKkChHjDCwWjXiKW0sh/Z73M ry4wQ9gzeUUQWkq60nLKTn/0tQJKOuxIsViL0I0A88P3bSeaiOgl5LpAM QzrpNzXfvjJKsgzhEiGFR82FBPMK8hzc+BiLdg+XAVffrl7WzB+YsnMtp hDQai5EXsh2Bcz2WY2U4fJnIEM82tKnuK7lp2I6giSzjmNr3dpRC7J1Gq Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10596"; a="352874603" X-IronPort-AV: E=Sophos;i="5.97,232,1669104000"; d="scan'208";a="352874603" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2023 08:41:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10596"; a="906017161" X-IronPort-AV: E=Sophos;i="5.97,232,1669104000"; d="scan'208";a="906017161" Received: from ubik.fi.intel.com (HELO localhost) ([10.237.72.184]) by fmsmga006.fm.intel.com with ESMTP; 20 Jan 2023 08:41:28 -0800 From: Alexander Shishkin To: "Michael S. Tsirkin" , Greg Kroah-Hartman Cc: jasowang@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, elena.reshetova@intel.com, kirill.shutemov@linux.intel.com, Amit Shah , Arnd Bergmann , alexander.shishkin@linux.intel.com Subject: Re: [PATCH v1 4/6] virtio console: Harden control message handling In-Reply-To: <20230120074120-mutt-send-email-mst@kernel.org> References: <20230119135721.83345-1-alexander.shishkin@linux.intel.com> <20230119135721.83345-5-alexander.shishkin@linux.intel.com> <20230120074120-mutt-send-email-mst@kernel.org> Date: Fri, 20 Jan 2023 18:41:27 +0200 Message-ID: <87y1pxp39k.fsf@ubik.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "Michael S. Tsirkin" writes: > On Thu, Jan 19, 2023 at 04:22:09PM +0100, Greg Kroah-Hartman wrote: >> On Thu, Jan 19, 2023 at 03:57:19PM +0200, Alexander Shishkin wrote: >> > In handle_control_message(), we look at the ->event field twice, which >> > gives a malicious VMM a window in which to switch it from PORT_ADD to >> > PORT_REMOVE, triggering a null dereference further down the line: >> >> How is the other VMM have full control over the full message here? >> Shouldn't this all have been copied into our local memory if we are >> going to be poking around in it? Like I mentioned in my other review, >> copy it all once and then parse it. Don't try to mess with individual >> fields one at a time otherwise that way lies madness... >> >> thanks, >> >> greg k-h > > I agree and in fact, it is *already* copied since with malicious > device we generally use a bounce buffer. Right, but the code should probably be able to handle bad input on its own, or what do you think? > Having said that, the patch is actually a cleanup, e.g. it's clearer > to byte-swap only once. > Just don't oversell it as a security thing. Well, security was the original motivation, so that's what it said in the commit message. But we settled on [0] yesterday with Greg, which would replace this patch and 2/6. [0] https://lore.kernel.org/all/87a62eqo4h.fsf@ubik.fi.intel.com/ Regards, -- Alex