Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp666939ybg; Tue, 28 Jul 2020 16:00:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBnsEeD9Gb1rbKM10ruEOyYZ4RpjvwA2hd8MjpTjuY2lgUcW6asyL9vql9Nj+mdPUnUrYo X-Received: by 2002:a17:906:8417:: with SMTP id n23mr26945311ejx.192.1595977201761; Tue, 28 Jul 2020 16:00:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595977201; cv=none; d=google.com; s=arc-20160816; b=kK02hQjCN0+fFa+4C7DqQRPOyV9bFF+6QdQhOJJtkKurAbgwdL1ci6l680tq6Ybu/Y WUepwi7tOc90b6asOH550bG18/BbSBTCkbTdNIYH61j/QCODpDjW6WjQx4khQYTWdJGz pZfo2tnPBwm/jDbTAGrGehkM4E4Lr6Xm4+fGtWjK9b8w8xEJqa+ueHDerTtGupfwPomu CpycSICH2uKzBW700zpLIztUEcBV2o6htI6zlCTsvvFOn1LAQlc3w9epuKk+fMe8LKzu +Ez+0GaWmXFBtLnjNhJvYJf+1e3nvihiMhp73K5vjNG5ZbMOeJuphk1RMW401LKY+/dD z5Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=yOCraVChxa5ukNCcP2KC3ZnWUN5xoWQnnkAwH57jpBo=; b=vB9rXAmSb+qPa5HDGjbJi7OU4Mol3e7ai9yW4EWpYEgrx6jcnVOA3EhpYEhMRHf96X Pp+QYN3iSbkZA9eQVWLjNfzkUHW7OTVLpL3dcoDhDBcDanCVxlFAitq6v4vNp5nVLG0q bgM7OByNlHL3bB/PrPUPPA6FlRJAcBO547B6sRfnr8eacjPb3eJplqf3mGblIO+hihHj fVaXIeYGRFkYSVJRVRiHDKWq7UziP1eNJbhOMtxMrShtdIaJvTgsc8VA6Nbm3UV7esgk xCEurrSVoIEyXhR8+kUA5bCFxUu7LWCNy7+L7S9YDGyvi+m2szC6Cp1Lg3F930QcUT0w tZHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v7si128572edd.551.2020.07.28.15.59.39; Tue, 28 Jul 2020 16:00:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730318AbgG1W6X (ORCPT + 99 others); Tue, 28 Jul 2020 18:58:23 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:33769 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729991AbgG1W5f (ORCPT ); Tue, 28 Jul 2020 18:57:35 -0400 Received: by mail-qk1-f196.google.com with SMTP id l23so20499672qkk.0 for ; Tue, 28 Jul 2020 15:57:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yOCraVChxa5ukNCcP2KC3ZnWUN5xoWQnnkAwH57jpBo=; b=XOJ83zO01ae8ZPcpJJOpqDOFRGuTsoyEsEl97wMP7PbHdRQGH/xi55U49spYCQ3R3S AbC8eYVCkI9SJkvxMutHyjj/qMFcOM7RMgtWR3emDsJsEeAf2eks1VefmD/eKffRxVGF UvK4Sr2gwX4qMMIY9UUjIfZlafJcV/dFy7CNZzkqmirGjcWKDqNlinWTYH7GS7kGQgJz eqcb/AhUiyI8zfs88ptWMXx+Iv+C2XgS25MbukRrbL3KiVHClkfQ124CM56i7XdipA3+ F2OgultR4IWg6mO1QZ+h36DKL8aWk8lNUROdmPEIVvCF6MJZN0T2EuruitCVLC2M3yeH xscw== X-Gm-Message-State: AOAM532uoMSWTv4Re4fyjN/TW1PEP2ukbuolEWC2ix88dl1MHf0N+nZC jR553YHx8p6B3K+LIXjKkz03B8l7 X-Received: by 2002:a37:a6c6:: with SMTP id p189mr20083802qke.386.1595977054058; Tue, 28 Jul 2020 15:57:34 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id o187sm88118qkd.112.2020.07.28.15.57.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 15:57:33 -0700 (PDT) From: Arvind Sankar To: Kees Cook , x86@kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH v3 13/21] x86/kaslr: Drop test for command-line parameters before parsing Date: Tue, 28 Jul 2020 18:57:14 -0400 Message-Id: <20200728225722.67457-14-nivedita@alum.mit.edu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200727230801.3468620-1-nivedita@alum.mit.edu> References: <20200727230801.3468620-1-nivedita@alum.mit.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This check doesn't save anything. In the case when none of the parameters are present, each strstr will scan args twice (once to find the length and then for searching), six scans in total. Just going ahead and parsing the arguments only requires three scans: strlen, memcpy, and parsing. This will be the first malloc, so free will actually free up the memory, so the check doesn't save heap space either. Signed-off-by: Arvind Sankar --- arch/x86/boot/compressed/kaslr.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index 7fb699aae74e..7c69fc10a782 100644 --- a/arch/x86/boot/compressed/kaslr.c +++ b/arch/x86/boot/compressed/kaslr.c @@ -279,10 +279,6 @@ static void handle_mem_options(void) if (!args) return; - if (!strstr(args, "memmap=") && !strstr(args, "mem=") && - !strstr(args, "hugepages")) - return; - len = strlen(args); tmp_cmdline = malloc(len + 1); if (!tmp_cmdline) -- 2.26.2