Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp565672rdb; Thu, 2 Nov 2023 11:17:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHB64pZ6tR5s7M/ioz8iSr246nGmL1nd5cnBgkDiHKpD5tJNG/5MjSmmdYS0emKRHDjB9Yo X-Received: by 2002:a05:6a21:7185:b0:180:def9:20e1 with SMTP id wq5-20020a056a21718500b00180def920e1mr12253884pzb.22.1698949024858; Thu, 02 Nov 2023 11:17:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698949024; cv=none; d=google.com; s=arc-20160816; b=ygCuyfUdr8t/4JErBj2EQpEHv3QOBXxblk1f9+BJuQziev8zQle/c4rxBOKAAFQL2m ES2VNDNZqE5fn4RIx4UqdlUroFsIBKasTYmGp4M0vmnBZlyX/bW3p3S/QTWfv0Ab4hAg 4SHvMx8Mx+7nQrrZdmxFzokIqd/NTRSlm6kLEqlUZP07tiuwEm/4gr5SnWnXi+2myWIs U6uTs9PHa88dklSZQt+I7ZkLgr4jRoKKGUsEh1tTv0DLiErYYkp+fZ+7quwxkXERsB1X 34a1e2K4NGbp4+dSmelQVvGN/lUejKOgguS3mTjeH5VGN30VZRjShgL3dwE+l9l+xfn5 ujqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zgG3A5hpFrp+6V7xcOap0dfvpVeqP5J5h/8swybWPW8=; fh=Yg4Yo3fyKVS/k2prXTDaCuVPHXNqoRbCi1v3a+pHdPU=; b=MSgFKYtnloeGS3QUyxWrerU1Fo9krNrBtSnCu9TRaDGKlt1cXpFbn44/mchskmDW5k I9e5/Mjym6Mu2sZBvxOqM4xat7fcBX3RkRfaVMXz2M6p7f0xKA+iAicaZ5F2IoCFEwho p+Bu7m8FqyNKPSU3vxPfQg9Q7O1/QEwO7IIVxbBTUrv6+BfPlEc2YrWvYoCQ0mMoWnIP bkN/ShL5lFFT6sP/POvlq9+dRR+MMeHd4HPj515Y8WCWKOxUpU18st04NWUokU6YmX4H WDPgH19zbX3ldn6UPlk1Ba200Ur3WAWDl3++Q49ZfPRBjg07VeT8d8fK100gffixu6cJ VJoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AmKeNG6e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id bc14-20020a656d8e000000b0054fbd904b6dsi76625pgb.500.2023.11.02.11.17.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 11:17:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AmKeNG6e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 0DE7A82C92D8; Thu, 2 Nov 2023 11:17:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377190AbjKBSQ6 (ORCPT + 99 others); Thu, 2 Nov 2023 14:16:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235149AbjKBSQy (ORCPT ); Thu, 2 Nov 2023 14:16:54 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8556A194 for ; Thu, 2 Nov 2023 11:16:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698948964; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zgG3A5hpFrp+6V7xcOap0dfvpVeqP5J5h/8swybWPW8=; b=AmKeNG6e5TGAmov2bQOQ1EysZ4KQklR/7TXeewd+jGPyLxfPHn5T9d0BEEvy/xefL6F1MB IWHk/IoFW9gAe01jfrFvoNErDm+78E+A8DJSFnAFYrp26F4FlSjI3TQIH0A/hIrRhYjZ/9 4vak1+LpLGk/nmbSVc5rqCJqFyZPiAM= 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_256_GCM_SHA384) id us-mta-595-lGH64hU8O6e7uXzPjSK1ZA-1; Thu, 02 Nov 2023 14:16:03 -0400 X-MC-Unique: lGH64hU8O6e7uXzPjSK1ZA-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4083a0fb583so1417885e9.1 for ; Thu, 02 Nov 2023 11:16:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698948962; x=1699553762; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zgG3A5hpFrp+6V7xcOap0dfvpVeqP5J5h/8swybWPW8=; b=ZsgiLVjWAAudh31TEr8FuJaIMcBG1k8OSybA9I6RRMpqxWy5uLfGjeTwzRITe6Pcw+ GG99TEGdibRIqM8bnBGjdMYAI7TsLjIn7Td/w89pr7i38kU1OAtFpwvLYvZ3gHCPBWG+ J0eRKKdPeERK85Fl8Bf/pXVuHOjGmo2J4HZohrbye5v7I2Yy9Tt7WOFS7ob1o6KAoKEO grnh1aldEuhJSVEUbbaqbQIgEztwKC2nK2OjIbJP3w4pekWyyhyc5BHUZmuKyLR22qAI JpYK+yhcLgIYFk0+nk+t+ia0Gk6AztWMH63scv9gY4ZcVpCo69ak1SpOL/1PIAWQCbZJ eM4A== X-Gm-Message-State: AOJu0YxaBwGUWDcDLafm+WCRel6gUpOBcX6AtKhsMJ2xJtbZslK7vZlI 2fY9NkYT09CcKC4vYQmm8ikrxLfV8Z+z4G3qSZfufVR2Xv29xjL9ggrxQ9sFkEekylyn+H2iAfR he1zrOaJigBjGp3QV3WQQ1lbv X-Received: by 2002:a05:600c:510a:b0:405:1ba2:4fcf with SMTP id o10-20020a05600c510a00b004051ba24fcfmr15629793wms.4.1698948962009; Thu, 02 Nov 2023 11:16:02 -0700 (PDT) X-Received: by 2002:a05:600c:510a:b0:405:1ba2:4fcf with SMTP id o10-20020a05600c510a00b004051ba24fcfmr15629783wms.4.1698948961745; Thu, 02 Nov 2023 11:16:01 -0700 (PDT) Received: from pstanner-thinkpadt14sgen1.remote.csb ([2001:9e8:32c5:d600:227b:d2ff:fe26:2a7a]) by smtp.gmail.com with ESMTPSA id m28-20020a05600c3b1c00b004076f522058sm3879929wms.0.2023.11.02.11.16.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 11:16:01 -0700 (PDT) From: Philipp Stanner To: Christian Borntraeger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Sven Schnelle , Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, Philipp Stanner , Dave Airlie Subject: [PATCH 2/3] arch/s390/kvm: copy userspace-array safely Date: Thu, 2 Nov 2023 19:15:25 +0100 Message-ID: <20231102181526.43279-3-pstanner@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231102181526.43279-1-pstanner@redhat.com> References: <20231102181526.43279-1-pstanner@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 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_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 02 Nov 2023 11:17:03 -0700 (PDT) guestdbg.c utilizes memdup_user() to copy a userspace array. This, currently, does not check for an overflow. Use the new wrapper memdup_array_user() to copy the array more safely. Suggested-by: Dave Airlie Signed-off-by: Philipp Stanner --- arch/s390/kvm/guestdbg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/s390/kvm/guestdbg.c b/arch/s390/kvm/guestdbg.c index 3765c4223bf9..80879fc73c90 100644 --- a/arch/s390/kvm/guestdbg.c +++ b/arch/s390/kvm/guestdbg.c @@ -213,8 +213,8 @@ int kvm_s390_import_bp_data(struct kvm_vcpu *vcpu, else if (dbg->arch.nr_hw_bp > MAX_BP_COUNT) return -EINVAL; - bp_data = memdup_user(dbg->arch.hw_bp, - sizeof(*bp_data) * dbg->arch.nr_hw_bp); + bp_data = memdup_array_user(dbg->arch.hw_bp, dbg->arch.nr_hw_bp, + sizeof(*bp_data)); if (IS_ERR(bp_data)) return PTR_ERR(bp_data); -- 2.41.0