Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2272243rdb; Mon, 9 Oct 2023 20:51:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHzFHgz51T6q8rLzKhWZWciPSk+ute2lBzi74ztGoE/Us5xn14C/YUjNW9LZr4y65ofkKx2 X-Received: by 2002:a1f:4e46:0:b0:4a1:58e0:a0db with SMTP id c67-20020a1f4e46000000b004a158e0a0dbmr3051047vkb.11.1696909911583; Mon, 09 Oct 2023 20:51:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696909911; cv=none; d=google.com; s=arc-20160816; b=Hehin9GvCsgg/Dc3Z8DEy7dJiy73LproW1BxsVpNKh7mzIf6dqlRhrtIpPbPTkOGsI J6gSnh/8I+w+QYSYLDypiGW8AjrVRKPWx5JyuSRPZpeh5tShHp4x9CFx9pjO3L3BDiRq gK9lGT0WKiQYLlA9OY3IS0HZ3WYLon++rurGThhdn7eGGJ8skuERdpV7XBXd6NA4icRL dTrTvuQ0rScL0J9QYw/NbKuaca3pcXysjiBFFRvo1thvi0zMO341WNH+qeJ7guzq6Rri 0ExgSGnwWhhqD12fGqRkAir6JlAc7vWgDIlgorOKPSWdWFZD+E7dRG1pJx0TL6CFhbow SKGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=kCk2Dd10DyT125yTAbmsn3uzdcOg6z89wkyXK3RTGaY=; fh=O3ozv4yMoaOwbpLR1uUuIVUYIxF895zyyonEEQI136c=; b=ob9LHTmpHnftZsbLSS8G0PTigU8usDIBxlTiYsKm+++DrPTP50yWgbpffYjJHNtHdV KE/I6Xwo7zPtXKqce/UutQWhbe/rWGIVsxq+BJpqeZh4xt72N9M4+281umi3G5FDKh3p cMDQeYLPlr6mD64zRyyqA3BVFlUqdrNLt0DevP3lIKF1+B/qsAPnErCHcerR2nHoTQBD bgpXahc2AGg0dkFO9i1eY8gu+G4XXCCMlEHPblAm0GxUHw88JV8VGMg+bGu+hiMUbk1x 2Mn7zWXLbIPfeQTVty9E0c4HajONmimsF9JWKkP5CN2/cJKB1xt4azQGnyRoD2DQFh4g sfBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fY0LmTuC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id m1-20020a656a01000000b00585adc52bd5si12338977pgu.730.2023.10.09.20.51.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 20:51:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fY0LmTuC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id CDF8580BE3E7; Mon, 9 Oct 2023 20:51:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442073AbjJJDvl (ORCPT + 99 others); Mon, 9 Oct 2023 23:51:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1441973AbjJJDvk (ORCPT ); Mon, 9 Oct 2023 23:51:40 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BE339D; Mon, 9 Oct 2023 20:51:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696909898; x=1728445898; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=PF+Ay1nF3twFmCEuJZa/1bgtgTYEZ6w5+iXaFlgUOHU=; b=fY0LmTuCmSzdAw5MYsCuoryREJskeKWLWif3p1xShuDtQrCZLukTlJdp eEo64RWRJdXVXVW7MW704kpP7ETeXWQfLJEJqnMP6aGZnNZa3bVfuJRHX xahz3buwtdgmNqoNVyKB22MtZsxP4SdC8mS+OuZon0xt0liGAi6a3EFB5 JFFzwCI2oCERmoFAhBIGXRXre++IrgoYcvlNxn6AA0ImCIs3RzGRl9ll/ COzsN2UVqdoABFZvugPYs+N7uUL2tmZs7pYxLFBkucSSNYJxjnWMmNlpD Sum2OUL3VGp+tz6a2s7HVC3E2zsIZsgXiv8L7neiSVcQqqZu34vgcmV02 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10858"; a="5860875" X-IronPort-AV: E=Sophos;i="6.03,211,1694761200"; d="scan'208";a="5860875" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Oct 2023 20:51:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10858"; a="1084603772" X-IronPort-AV: E=Sophos;i="6.03,211,1694761200"; d="scan'208";a="1084603772" Received: from binbinwu-mobl.ccr.corp.intel.com (HELO [10.238.1.136]) ([10.238.1.136]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Oct 2023 20:51:34 -0700 Message-ID: <1793b780-cd15-b6a3-f951-c19a14a1310c@linux.intel.com> Date: Tue, 10 Oct 2023 11:51:32 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH] selftests/x86/lam: Zero out buffer for readlink() To: kirill.shutemov@linux.intel.com Cc: dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, shuah@kernel.org, linux-kselftest@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, weihong.zhang@intel.com References: <20230923233346.12726-1-binbin.wu@linux.intel.com> <20230927110219.b5n3fbbwrxtcwtzp@box.shutemov.name> From: Binbin Wu In-Reply-To: <20230927110219.b5n3fbbwrxtcwtzp@box.shutemov.name> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Mon, 09 Oct 2023 20:51:49 -0700 (PDT) On 9/27/2023 7:02 PM, kirill.shutemov@linux.intel.com wrote: > On Sun, Sep 24, 2023 at 07:33:46AM +0800, Binbin Wu wrote: >> Zero out the buffer for readlink() since readlink() does not append a >> terminating null byte to the buffer. >> >> Fixes: 833c12ce0f430 ("selftests/x86/lam: Add inherit test cases for linear-address masking") >> >> Signed-off-by: Binbin Wu >> --- >> tools/testing/selftests/x86/lam.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/tools/testing/selftests/x86/lam.c b/tools/testing/selftests/x86/lam.c >> index eb0e46905bf9..9f06942a8e25 100644 >> --- a/tools/testing/selftests/x86/lam.c >> +++ b/tools/testing/selftests/x86/lam.c >> @@ -680,7 +680,7 @@ static int handle_execve(struct testcases *test) >> perror("Fork failed."); >> ret = 1; >> } else if (pid == 0) { >> - char path[PATH_MAX]; >> + char path[PATH_MAX] = {0}; > Shouldn't it be PATH_MAX+1 to handle the case when readlink(2) stores > exactly PATH_MAX bytes into the buffer? According to the definition of PATH_MAX in include/uapi/linux/limits.h #define PATH_MAX        4096    /* # chars in a path name including nul */ IIUC, Linux limits the path length to 4095 and PATH_MAX includes the terminating nul. > >> >> /* Set LAM mode in parent process */ >> if (set_lam(lam) != 0) >> >> base-commit: ce9ecca0238b140b88f43859b211c9fdfd8e5b70 >> -- >> 2.25.1 >>