Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp764565rdg; Thu, 12 Oct 2023 23:30:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFcuQ5Lbf1geEqNHnQUdk19Kp2fTfcnoXeFD2J5TmUzTq1gnaUzYsDQ+NpaYyloPlggog9J X-Received: by 2002:a05:6830:1d90:b0:6b9:26ce:5e5c with SMTP id y16-20020a0568301d9000b006b926ce5e5cmr28388250oti.31.1697178651425; Thu, 12 Oct 2023 23:30:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697178651; cv=none; d=google.com; s=arc-20160816; b=ffAhSygUWX1ap57CInO8Wy2YujIOAxVZ0w1G6I2umAk4OBcMl3pJWtBpnUKtNIKKnl CAGrB7Dg9IX60mGd5s83u8NWmee/VY4qKO07+TCNGABpg30qIDbCMpGO4tYNaRkSE1d8 ZZx2L5L+dw27oAg4RLsnpPLLvRCLFlPIrmtvMSJ4Uub2oWBnoF+PxJaHoCzrEPjobIKi n1fpujet4E4zuHODMaTqANWvtOv4obpa6OdW1TOIBrbAfpnESpBZSI39yqrVgFntQJfh m0S1uU7dlizgEscjuEpuBAbnEpXyjKCjAdHoOf+94zDkXII4AQ+6/lyE4jLQmnAXUuIJ u44Q== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=VlsSN+I3I9LHiPwm/QKJMqlA+Ye2MfSqfYL2XdtaW2Y=; fh=6e8RY+i5VrFsRF2NC2DqjDXWmzfjrT2ho9DYwlFZr0w=; b=00CaP/ignZYBs4CnJ6cAUiMipfHvoQnlYgGfUAnNa9Ul4Lcm5E2T5GAoAi3usGUp4S P3Cays0lMISN10MDThO1emEJDIfoFP2MHktyNrYUSVM71ITAOcjkvXAxxyP9XoDNz99S qMozOyZLKqCJfmsicbPlsjD8atUfeM46wuLstJZQyGCkUooZeEHFT1yxqNTx0iqCGoOi SbqNqB4XwzSJe3ku878oH7W/xEFfRoIxbGAMrzEjddjP05pBODWpxHr+byuCjtuZnxSH X1l2bUgkzPmdCCCPpVUuyBMEGJQ972wAUUISot3YxiLIbhZsQcnsalV1ADc24i3eiLMX Cnig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=kmk531ri; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id k199-20020a6284d0000000b0068fe8cac913si376054pfd.324.2023.10.12.23.30.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 23:30:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=kmk531ri; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 6DB52802F6AE; Thu, 12 Oct 2023 23:30:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229726AbjJMGaK (ORCPT + 99 others); Fri, 13 Oct 2023 02:30:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbjJMGaJ (ORCPT ); Fri, 13 Oct 2023 02:30:09 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A975B7 for ; Thu, 12 Oct 2023 23:30:07 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-99c1c66876aso280253866b.2 for ; Thu, 12 Oct 2023 23:30:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1697178606; x=1697783406; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=VlsSN+I3I9LHiPwm/QKJMqlA+Ye2MfSqfYL2XdtaW2Y=; b=kmk531rilXQUitnIFp9+oUDcWEIFn3EkAiUTqjilzD+6skqrDBAFIkzuF2vbhRV3IY dYz+U3lQMXAuZN3p51mn8zPfmAd92XKcnORcVfDe21cOWVlUXYOQ80WTqEHG74OP38Er pXzeFsMe8OCfrK/mJrxfDA+65C18JRFAxbCeRFVvakpoiv9GGND+FfGAi16Gsv2Rlzb0 N8eNHMLj/Si1tYc7na9bsT4TapSI01jelyL0ciajLXTmusQWqjdwrg/xS3cOND335CeJ qbhpC5hh1BgXn5H7KKp1KXSROC3Yo22l8SDGSZFXyx/QBWJCh5z0a7c2XacBYdpWlAdb Sj+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697178606; x=1697783406; h=in-reply-to:content-transfer-encoding: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=VlsSN+I3I9LHiPwm/QKJMqlA+Ye2MfSqfYL2XdtaW2Y=; b=SE0Ddnz7Jy1KmZocVK31jj9WeqHfZpVZf3xfCUzFo6dyq0mCL4DYlec0PVRvVgFT4D z1y+80GG5OWpJjUI40wdQkfdectIuz51n/naRE+MT43D+aiNmHoXkwewDMzZo/JoBNaY ypn/w5AtvxGvYxwHiesqQPMJKe9UM1m89GQrh6EVhFXWBCzKXUlrB1Kk54eWV7Yl/jTX rEn7wZy1K2COMzAp9iL/zeK20XPO70xUAHkNtfvXtFxEPsEX+9plH92xRQPe7nJuy1ha E6zXTXitIu1+uA6JAjGbbSylMlvgEI6UR3br1kzAcmXaBHMyLuAI0JlX3NeeQWi/Aiof lKTw== X-Gm-Message-State: AOJu0YzIuult8g31HHu1EhRRo7DeCIBhzFQj7piREpwrNebOVxWCv3PV qzNUqkz3ZURSJEVC5U/FYOEOCw== X-Received: by 2002:a17:907:8b8c:b0:9a2:28dc:4166 with SMTP id tb12-20020a1709078b8c00b009a228dc4166mr24507418ejc.75.1697178605714; Thu, 12 Oct 2023 23:30:05 -0700 (PDT) Received: from localhost (cst2-173-16.cust.vodafone.cz. [31.30.173.16]) by smtp.gmail.com with ESMTPSA id kf24-20020a17090776d800b009b95787eb6dsm11882433ejc.48.2023.10.12.23.30.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 23:30:05 -0700 (PDT) Date: Fri, 13 Oct 2023 08:30:04 +0200 From: Andrew Jones To: Mark Brown Cc: Paolo Bonzini , Shuah Khan , Haibo Xu , Anup Patel , kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: selftests: Initialise dynamically allocated configuration names Message-ID: <20231013-0fb230037c78d2c397e691c7@orel> References: <20231013-kvm-get-reg-list-str-init-v1-1-034f370ff8ab@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231013-kvm-get-reg-list-str-init-v1-1-034f370ff8ab@kernel.org> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Thu, 12 Oct 2023 23:30:24 -0700 (PDT) On Fri, Oct 13, 2023 at 12:19:30AM +0100, Mark Brown wrote: > When we dynamically generate a name for a configuration in get-reg-list > we use strcat() to append to a buffer allocated using malloc() but we > never initialise that buffer. Since malloc() offers no guarantees > regarding the contents of the memory it returns this can lead to us > corrupting, and likely overflowing, the buffer: > > vregs: PASS > vregs+pmu: PASS > sve: PASS > sve+pmu: PASS > vregs+pauth_address+pauth_generic: PASS > X�vr+gspauth_addre+spauth_generi+pmu: PASS > > Initialise the buffer to an empty string to avoid this. > > Fixes: 17da79e009c37 ("KVM: arm64: selftests: Split get-reg-list test code") Doh, this is an embarrassing bug. But the patch above just moves the buggy code. I'm still guilty for the bug, but the fixes tag should be Fixes: 2f9ace5d4557 ("KVM: arm64: selftests: get-reg-list: Introduce vcpu configs") > Signed-off-by: Mark Brown > --- > tools/testing/selftests/kvm/get-reg-list.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/tools/testing/selftests/kvm/get-reg-list.c b/tools/testing/selftests/kvm/get-reg-list.c > index be7bf5224434..dd62a6976c0d 100644 > --- a/tools/testing/selftests/kvm/get-reg-list.c > +++ b/tools/testing/selftests/kvm/get-reg-list.c > @@ -67,6 +67,7 @@ static const char *config_name(struct vcpu_reg_list *c) > > c->name = malloc(len); > > + c->name[0] = '\0'; > len = 0; > for_each_sublist(c, s) { > if (!strcmp(s->name, "base")) > > --- > base-commit: 6465e260f48790807eef06b583b38ca9789b6072 > change-id: 20231012-kvm-get-reg-list-str-init-76c8ed4e19d6 > Other than the tag, Reviewed-by: Andrew Jones Thanks, drew