Received: by 2002:ab2:687:0:b0:1f4:6588:b3a7 with SMTP id s7csp78192lqe; Tue, 9 Apr 2024 15:18:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXKXr2gIwJgFMjo0A7PMb3ipVQ8f2MSxjcRd3/bfhoUSaQpVLzxf1kuARv+Zt8v8RULs61cpY/VBQa6LbGL/Rv/hageC2poksmwNMyTug== X-Google-Smtp-Source: AGHT+IFE+JURjEWMk/zkb77Y+71wcGR/Yoit6ELmBhGPxaMfqYCCQNczdvvnT/+ftKjnpKsw7k3R X-Received: by 2002:a05:6214:c86:b0:69b:3661:6d39 with SMTP id r6-20020a0562140c8600b0069b36616d39mr871293qvr.24.1712701137420; Tue, 09 Apr 2024 15:18:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712701137; cv=pass; d=google.com; s=arc-20160816; b=eIYVItCaOJpsyq9TlCo8dyC43ZdxZxOqGpX/8SU44z7xgGAqvoPP5cH7pkixlz1gMF wbRtVC7se3w+/rnVpAN2ZX2b7HWsmn9SpkyRpSUlrL9+M51GsHpU6yK/2P3h1+P0gHFU 4/ScF5uLVzYZ+KZurjJ1txqfSyaYK23rE2E/DgpT5KOAvvIKMeoxC567M39rQAE1d41x bb6N4wniYdkl6iFMKsig4dT9uzPh/CpCti61epuLXKKOu0I1XYzBmHd1ftjfRW6L9Yyd x2Dc2qnY2YvkVmwyNHI6LDMJB6azzlNOn/6kgqRH5W7lN0gO7L0w4ikUWtCKmrqbo2up NTdA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=F+JyR7XVHoRHZc6sojXb4+4iOMxV4P55AJcvcX75Hlk=; fh=k4SlrlEGTrHOMVXoccoVazQgKvryFofHyZeMb03is4E=; b=Y2evuCMjrPrSY5vasF1cVvxWiMVkPNKbHftWXbpB5aE45VEpROfdoVlTy69NogVeI8 ROSpiAWzMRsUUX3+tm74W5rSRrYQbluai0oky6NzgB3nMHlqRgqSHtuqH0HzEvaiFiR/ rvH8oncGBWzLJcqpcQPRClC3RUxaMhEyDxSpgtUIulO7CKaDvPicJkxrF3ARexdUK6vC itZp4pl6LyHoAqFMS1xvJayiOgIQd9xtO5Ws4rNG9FPQImsv4WZDGtVUUpdQJJE+IfYW RG3fKO97VngpdkCTXW0xPK7egDcSV0VoVxUeNwxl/Kw2blp4twTaAgYzOc/UbmYM/scr nckA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OquFZMZg; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-137660-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137660-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id w6-20020a0cc246000000b0069b10f143aesi7227476qvh.412.2024.04.09.15.18.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 15:18:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137660-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OquFZMZg; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-137660-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137660-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2B0741C21CEF for ; Tue, 9 Apr 2024 22:18:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6B19B158D88; Tue, 9 Apr 2024 22:18:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="OquFZMZg" Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 180D615884B for ; Tue, 9 Apr 2024 22:18:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712701129; cv=none; b=SAqAfReWjxWRuEk8V4NwVxSO5tflic0muNi4wCzhqWfuqRdAML7k1N4d0AAWZ/6/6elDTkNOHC8gFoUALMIkSe06galDSpRlw71W0gBUVwWea7F4G9xkeopT+LwBnRk3WGrCV0fNh7OnoHrEbewyj6oND1ul6vVaxdnKIyLsvxw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712701129; c=relaxed/simple; bh=kQp/hvyGHh1SkSZ5gklhCTfn7rhxx+OeQkDZRYp1Nug=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=MXdoCzzigtftYoI5moU3hk7hImQq3k0CxHd/uxt1YCou1gBH9c2lQgxv/sd2Bd+ecGDLT6xJ3o5uOqA1gFBKcep4LwRzyDAh7mEXZyQuIOSbJsv/tv+ZCagwXKiLu7jsL9cflewHOCQrFA8pKggRh/B+axnMj/cURtvDMun0eLg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=OquFZMZg; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1e2232e30f4so54076985ad.2 for ; Tue, 09 Apr 2024 15:18:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1712701127; x=1713305927; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=F+JyR7XVHoRHZc6sojXb4+4iOMxV4P55AJcvcX75Hlk=; b=OquFZMZgTvKCVYELZbko8eqib+KvBGjts8jqA9LaDx87nJ2YlobYqxdYlxzsKAG5ze 8UbeUbiV8s7AIJ+n0O3HVeeBpGD+xiMDRHkXdaTIqndXq0uH3itZu1/WFBi9TfiuTv9n fBG9TYqEliAZDgHjxtrvoK2BzHb/P0Z5b9hI8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712701127; x=1713305927; h=in-reply-to: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=F+JyR7XVHoRHZc6sojXb4+4iOMxV4P55AJcvcX75Hlk=; b=KuiiBjDAm0mLRpTU0+193EdnjciFvPrRYDLuw29FvkvkExGXr8YWHqKEzIdjd4vJzQ ptw3SademoeW6xjC8tQB6X4NGfAw/SjGqILzvNmG6I9PIfrUWkPgJ3J5X7N7Nm6Khzgq T5q7Y68Ur/SGFtyli0csp2NjL4gZvnTsuC6p2upkM8ZgxPd2qsL90k7Azgqwvt/fYlAJ Tb/IN+ZhAeTWqhGa+QIzJAhOICNp0nm0VtU9Lu9yjZGNDdbZEAhOfhPwE/S6KTJPPSdF k2yrXNSIq4ImzgvOKMUVmu27XExncS/J9/03foD2G+7EC9/gd/nFrPjxkCKi/+3Djf2F ohnw== X-Gm-Message-State: AOJu0Yy4aStAj24vfs4dBH4EuqSYzu2I9IR5yAwi4OikVr6ZTopTEJsF FWXvaHBTsSWh5NijwSGze+b8eerD9XbYhN5RRc9T/rLcMxcoNOajjN/51zGFUw== X-Received: by 2002:a17:902:d4c1:b0:1e4:1873:843c with SMTP id o1-20020a170902d4c100b001e41873843cmr1191665plg.62.1712701127333; Tue, 09 Apr 2024 15:18:47 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id q12-20020a17090311cc00b001e223b9eb25sm9416376plh.153.2024.04.09.15.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 15:18:46 -0700 (PDT) Date: Tue, 9 Apr 2024 15:18:45 -0700 From: Kees Cook To: Steven Rostedt Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , "Liam R. Howlett" , Vlastimil Babka , Lorenzo Stoakes , linux-mm@kvack.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Tony Luck , "Guilherme G. Piccoli" , linux-hardening@vger.kernel.org, Guenter Roeck , Ross Zwisler , wklin@google.com, Vineeth Remanan Pillai , Joel Fernandes , Suleiman Souhlal , Linus Torvalds , Catalin Marinas , Will Deacon Subject: Re: [POC][RFC][PATCH 2/2] pstore/ramoops: Add ramoops.mem_name= command line option Message-ID: <202404091514.B97720B8@keescook> References: <20240409210254.660888920@goodmis.org> <20240409211351.234897475@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240409211351.234897475@goodmis.org> On Tue, Apr 09, 2024 at 05:02:56PM -0400, Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > Add a method to find a region specified by memmap=nn*align:name for > ramoops. Adding a kernel command line parameter: > > memmap=12M*4096:oops ramoops.mem_name=oops > > Will use the size and location defined by the memmap parameter where it > finds the memory and labels it "oops". The "oops" in the ramoops option > is used to search for it. > > This allows for arbitrary RAM to be used for ramoops if it is known that > the memory is not cleared on kernel crashes or soft reboots. > > Signed-off-by: Steven Rostedt (Google) > --- > fs/pstore/ram.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c > index b1a455f42e93..c200388399fb 100644 > --- a/fs/pstore/ram.c > +++ b/fs/pstore/ram.c > @@ -50,6 +50,11 @@ module_param_hw(mem_address, ullong, other, 0400); > MODULE_PARM_DESC(mem_address, > "start of reserved RAM used to store oops/panic logs"); > > +static char *mem_name; > +module_param_named(mem_name, mem_name, charp, 0400); > +MODULE_PARM_DESC(mem_name, > + "name of kernel param that holds addr (builtin only)"); > + > static ulong mem_size; > module_param(mem_size, ulong, 0400); > MODULE_PARM_DESC(mem_size, > @@ -914,6 +919,19 @@ static void __init ramoops_register_dummy(void) > { > struct ramoops_platform_data pdata; > > +#ifndef MODULE > + /* Only allowed when builtin */ Why only when builtin? > + if (mem_name) { > + u64 start; > + u64 size; > + > + if (memmap_named(mem_name, &start, &size)) { > + mem_address = start; > + mem_size = size; > + } > + } > +#endif Otherwise this looks good, though I'd prefer some comments about what's happening here. (And in retrospect, separately, I probably need to rename "dummy" to "commandline" or something, since it's gathering valid settings here...) -- Kees Cook