Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2383559rdg; Mon, 16 Oct 2023 02:44:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1ABtDZGehX1CkEOn9jUmFgCMCWF/+uekFI0340FEvWVZ0LTnSPVePjdOPK3JKL5oUxd3r X-Received: by 2002:a17:90b:947:b0:27c:f486:3af8 with SMTP id dw7-20020a17090b094700b0027cf4863af8mr13821540pjb.39.1697449491168; Mon, 16 Oct 2023 02:44:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697449491; cv=none; d=google.com; s=arc-20160816; b=oj18PHiwnEEmdh/gnGwicIuEcfVo0oWIm3g2mRo2hqqTZ3fFrPj49pV9BJXb8LMakI 1toyIKKtAT+lMzDL0v4CiNuTSxLUcXiQXdi+67ybPUE5I07kxHjc03gWUUsJbetjkXLL NlkM6GSDcDpk7hCpaPJVl6ffHAvOlNIeDsHx1t2gFUFNf3obL/2bcCPjcweIXMSo0i0O CZin4cGkSVyUYQydPTsvL+G77AH+gOJR50k565wDM9pOI0QvJLxVN5Clvt1p+In10/IS vqsJcmee1J3je4bkwziO8mqLHEwwKeOjok8jsG5AW9hq8hImxGjiUBqv5gfF07eo7242 qvlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=XZ41LTcQ/jhuvm71U7Pu2C5REKXKw1uT35nBnDHvCi0=; fh=WlpeJ0+Nnj3aoV6/LWTyG7f1AXEbAan1Fl+nYwouLFY=; b=Apl6PgiYlz1AV0Exrvq9uNXqKxwXUuYXjqrsloqNxgOavjCHYr+sR6zPIpkp6oAUkM EbEvSE2BERxwMVQa7ld5Nl8x3JjArIOlTFqffMhQXQL1SY1BUqlByP7FJJeD3H5Lnva1 kkWgWg9EYzL8ZO+PLCR5iYVV5ta2/XpBRa+KDx8Up582hUoJYLPFslJp27U+y8ntc2dj /C6fNCPCq3gyu6IwGZLSYOAIEUkI/99z4K/0YMVguZzLuiEFQ/9oxOx02e44DyM7bIj6 LgI20p7wuAMTYmyAbwkXAaSDrBfc3PnW4rQoDO3HfuUi41kuBreVLXAKQAFGDVqyVrxI 9I6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=f8Sx9bhi; dkim=neutral (no key) header.i=@linutronix.de; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id my18-20020a17090b4c9200b0027cff4f35cbsi6311732pjb.73.2023.10.16.02.44.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 02:44: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=@linutronix.de header.s=2020 header.b=f8Sx9bhi; dkim=neutral (no key) header.i=@linutronix.de; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id ACAFE80AC8F9; Mon, 16 Oct 2023 02:44:48 -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 S231162AbjJPJok (ORCPT + 99 others); Mon, 16 Oct 2023 05:44:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229621AbjJPJoj (ORCPT ); Mon, 16 Oct 2023 05:44:39 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 485FD97; Mon, 16 Oct 2023 02:44:38 -0700 (PDT) Date: Mon, 16 Oct 2023 09:44:35 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1697449476; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XZ41LTcQ/jhuvm71U7Pu2C5REKXKw1uT35nBnDHvCi0=; b=f8Sx9bhieAcZyI5hq4fhl7cuSmF9vLGDtZFIINgWszInLTzC/pHyCgkrMWBt3YvHYri/UQ Zy+ihVWq7sm8tY/lFxgL+R61QVrH4Ho0xYabvvdNUCHIxRPP+rIy8QCTLxTl5Y7gLootYn HNxSd5qwqtc/QxFonAK9//XEUw8oXSFtElEsQiJZ8L6M8dPNOwldqr9JPTbHGmc6GmqYEt uc1XwEx+o4q831QoIu/bqREiUWx6qmZBCZbBTbh78lhh1d9XfAvUMAApIIwgx6hOiM53F6 Sz1uG8bA6sBUWd9ro6Vh8R9l9CLpKtPCUfmD8a2dbGXEn8aRthgLovnQPEvdgg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1697449476; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XZ41LTcQ/jhuvm71U7Pu2C5REKXKw1uT35nBnDHvCi0=; b=YOzmN1AeiqI03bRgedwEgMEnFx/eR/QGwRsv0tHSAPG0/kavTeLjFo7GnD967fJAU6Ns9z J21pziET1LAWDyAw== From: "tip-bot2 for Binbin Wu" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/mm] selftests/x86/lam: Zero out buffer for readlink() Cc: Binbin Wu , Ingo Molnar , "Kirill A. Shutemov" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231016062446.695-1-binbin.wu@linux.intel.com> References: <20231016062446.695-1-binbin.wu@linux.intel.com> MIME-Version: 1.0 Message-ID: <169744947512.3135.5098809828724848406.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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]); Mon, 16 Oct 2023 02:44:48 -0700 (PDT) The following commit has been merged into the x86/mm branch of tip: Commit-ID: 29060633411a02f6f2dd9d5245919385d69d81f0 Gitweb: https://git.kernel.org/tip/29060633411a02f6f2dd9d5245919385d69d81f0 Author: Binbin Wu AuthorDate: Mon, 16 Oct 2023 14:24:46 +08:00 Committer: Ingo Molnar CommitterDate: Mon, 16 Oct 2023 11:39:57 +02:00 selftests/x86/lam: Zero out buffer for readlink() Zero out the buffer for readlink() since readlink() does not append a terminating null byte to the buffer. Also change the buffer length passed to readlink() to 'PATH_MAX - 1' to ensure the resulting string is always null terminated. Fixes: 833c12ce0f430 ("selftests/x86/lam: Add inherit test cases for linear-address masking") Signed-off-by: Binbin Wu Signed-off-by: Ingo Molnar Reviewed-by: Kirill A. Shutemov Link: https://lore.kernel.org/r/20231016062446.695-1-binbin.wu@linux.intel.com --- tools/testing/selftests/x86/lam.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/x86/lam.c b/tools/testing/selftests/x86/lam.c index eb0e469..8f9b06d 100644 --- a/tools/testing/selftests/x86/lam.c +++ b/tools/testing/selftests/x86/lam.c @@ -573,7 +573,7 @@ int do_uring(unsigned long lam) char path[PATH_MAX] = {0}; /* get current process path */ - if (readlink("/proc/self/exe", path, PATH_MAX) <= 0) + if (readlink("/proc/self/exe", path, PATH_MAX - 1) <= 0) return 1; int file_fd = open(path, O_RDONLY); @@ -680,14 +680,14 @@ 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}; /* Set LAM mode in parent process */ if (set_lam(lam) != 0) return 1; /* Get current binary's path and the binary was run by execve */ - if (readlink("/proc/self/exe", path, PATH_MAX) <= 0) + if (readlink("/proc/self/exe", path, PATH_MAX - 1) <= 0) exit(-1); /* run binary to get LAM mode and return to parent process */