Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2611693rwb; Fri, 20 Jan 2023 05:19:50 -0800 (PST) X-Google-Smtp-Source: AMrXdXu7TzZAd0q6uViq5c+8zbK07oPtsd2IFvJu+z9peg9z+DIlqeJ4kv5eMkKqCrU1YyJLnILI X-Received: by 2002:a17:906:4e54:b0:871:9359:3763 with SMTP id g20-20020a1709064e5400b0087193593763mr14313562ejw.40.1674220790007; Fri, 20 Jan 2023 05:19:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674220789; cv=none; d=google.com; s=arc-20160816; b=pV1YIv+wUoJ9kMxIt9qHmpVsrl4kbOAE8VePudwIqbi7GsncnTl6zygRk0SbONxFR3 UNCJRlKfa8fScN2iIC7ksI2CX9rxu6Wyf4BtMD7NwMPMHSlxJxXdQJla8gWFJ3P+DPjp Sx9NjXDVHZfm4330z+t+zNNY+F8j0S6u58SvR8w9YSReauQ3yyQ67w2MXD9p+xb3eOOq qxudrdEOZoDixNDxntpKoYtebv7HuMc7Xm7StoQCtU4c0wdquo6OobiwAaC26bj5prPq NmWHLw889zdDFGnmWCrdumQpouN9pnRuWpWd90+b7VbvBCCVEQBS12x5pVN8rNmFyMRe rrfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YWTNOPUOumy5aDePbdwVljMsaDB1wMCPYL0DgkBFZF8=; b=08UzT0l4EbG1WPRTm6G6c12C3X9QAImx71En2wR326t+Hrv+o5Xwsp9KZF4ITMrlQb t8xhKfbbT5Q5LNPGe1SmeaHznFQXwuR4sma/rjeKlHXF794npdk0a3pXlu+M0ut/JAZO wEmuGt8X2JpQ4mEitLmbbqnyHwhdXyeda8gl2242XoV1wxnmOI1v3P9p/DpwawD5I1Aj tH8pv8wGnJyaKioRibuC5rrMLG3gWtgKAqGyYknKfu9ZRPFWF5oSgtOc+ISQSHh17O2I PIRrBCgdNlo2H1RkCv2jQ5gXnRdhY49j1+DObPOyk0DeHEVWB7mPcdm0HlAKtyoVqavO kfgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=G3mVpUvh; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ds7-20020a170907724700b008775d59ce67si8432365ejc.217.2023.01.20.05.19.37; Fri, 20 Jan 2023 05:19: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=@redhat.com header.s=mimecast20190719 header.b=G3mVpUvh; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229882AbjATMqD (ORCPT + 49 others); Fri, 20 Jan 2023 07:46:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229540AbjATMqB (ORCPT ); Fri, 20 Jan 2023 07:46:01 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BC881BC2 for ; Fri, 20 Jan 2023 04:45:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674218714; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YWTNOPUOumy5aDePbdwVljMsaDB1wMCPYL0DgkBFZF8=; b=G3mVpUvhkhrnR8H6woWhYuC8ffGn8Vp/koQzqI77Cb+8D8slGPUsrSdu4rf/GtYrLd9Qnt 41ra1gKbD+5/cBFQ8thbdqYEhuLTXzuv1xtJKFE3RcCcTW8BBFvOcOvC3+7ekFZ2SVAR9Y nUAvN2XHVb3bvbb98VVqwkcBrq2oEDM= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-492-ZjrgSoRYM7uDCaxvK7uF-w-1; Fri, 20 Jan 2023 07:45:11 -0500 X-MC-Unique: ZjrgSoRYM7uDCaxvK7uF-w-1 Received: by mail-wm1-f69.google.com with SMTP id bg24-20020a05600c3c9800b003db0ddddb6fso2986639wmb.0 for ; Fri, 20 Jan 2023 04:45:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YWTNOPUOumy5aDePbdwVljMsaDB1wMCPYL0DgkBFZF8=; b=c2TrH1TnJsTgE/K7XFu/Z3y9YVXh01LXUY5y3zVwEPWGglG9fw6YBPtCVhtCWsB5Rr kEbhk4vne8tC8d/dTSIluy4QjZDBXYcP+pZOEa8k5hDr/89TN5T9LUmL1bq1nMbn8tCV 45EHmq4LwdjFPdTz5gWcggbIeQXMOWct3gZjjz+QwbXI9imKwziFgpC4bmus68JyVj6G HILCCPjFfc8Lj1VnE91HypZEDzqhi+Jlhccq1CG54p8uf3p6JrGr6WAmv1DiN5DpX/eD MNw5BZERniEIwmRDmwLaYze9HF6TiumIbbkBnr/lX5/7Rlmd1I5ByvpmYGFQqwu04AnY EFRQ== X-Gm-Message-State: AFqh2krXH8OUAYHayophD9sq5g110uwvjxZovjnG1puiaqhAjrqyg4lh 9s2uubjafsd/Bl7NywjiKdvCvffitAc1wVysmfPAoJSJ36Bhx4iyEjsWg85XcpECk9hI0FhVZrU 8THUMIhX66T7kGp6A8Fi4KgL6 X-Received: by 2002:a5d:5955:0:b0:2bd:e87c:e831 with SMTP id e21-20020a5d5955000000b002bde87ce831mr11862725wri.69.1674218709868; Fri, 20 Jan 2023 04:45:09 -0800 (PST) X-Received: by 2002:a5d:5955:0:b0:2bd:e87c:e831 with SMTP id e21-20020a5d5955000000b002bde87ce831mr11862700wri.69.1674218709503; Fri, 20 Jan 2023 04:45:09 -0800 (PST) Received: from redhat.com ([2.52.19.29]) by smtp.gmail.com with ESMTPSA id q17-20020a056000137100b002be4ff0c917sm2099412wrz.84.2023.01.20.04.45.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 04:45:08 -0800 (PST) Date: Fri, 20 Jan 2023 07:45:05 -0500 From: "Michael S. Tsirkin" To: Greg Kroah-Hartman Cc: Alexander Shishkin , 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 Subject: Re: [PATCH v1 4/6] virtio console: Harden control message handling Message-ID: <20230120074120-mutt-send-email-mst@kernel.org> References: <20230119135721.83345-1-alexander.shishkin@linux.intel.com> <20230119135721.83345-5-alexander.shishkin@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,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 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. 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. -- MST