Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp954542ybv; Fri, 7 Feb 2020 11:32:26 -0800 (PST) X-Google-Smtp-Source: APXvYqzNVG3TOLnkReVkzop+SnZWOvsiX7zujuwcuedPNdVT2MD/6wqNuCMpTkZ93ndVhhOg5pBv X-Received: by 2002:a05:6808:b23:: with SMTP id t3mr3197594oij.88.1581103945882; Fri, 07 Feb 2020 11:32:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581103945; cv=none; d=google.com; s=arc-20160816; b=fjOjhYt56N1COkYRZUqFL98A+DObAG0JfCL+8j3mUFv5EPFCp4Ch3Pc+MW//ky5AhM ho31/AoqmBdXl5KWH2irdjlX1OkDRiWqQJp10WTGFh90ZTT7J9GcxgkoEDdtcASiEEGC 63uKxI8rKSjmFRuNG5YV4d7LN/jAu5ivXyRgmMPf4bvyOTd39Y7K7FeFQd+V4FzFZU8H GCNlFkxsMppR/Kxq/DUOyWoGbXsC/HcLRDsj9LjW+Rea/Xu2BlOfsxgNvFUfRteY4Tu9 9ctBQGZ8RhBQ1uZKu0pkw9Qu2M4yw+PM8Qyq6KSXIC9DTPip0dWLj27llW5lDQfu5vrD JT1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:date:from:dkim-signature; bh=ZkpXb/Mvw8qZyRJM76GkT3rnAFfUOKULtUPg4iPdeJU=; b=yLsopxDdCxuwlblepODtFjraxt5xY3/KtRvo45/1ZRaaBK5qDSVBmhTs9DrVDZteQT FODq1/KY8h9e6X57jyUuKTrt8FgaCpFC6vEe2OnfZhHtl1Go1pCH62hRMlD8KdNPOAg3 rVJ00zyC7I9OscAnlIleRnoTuJrBoFLFk/LskfuhYoutO9lMBOF/2CX+pkDqiGijL0RO u6B6+15VOj1LdwpfVOOeRrOW1YStkHsFt9S2svd7lhwJMCPAYKIf9nmeX4gIH3pH5Nk9 Toa49JOOB2GBkaTzgvH4EGmUnIxnB3ioXap2vttWyIcQIjkJPL7eslLXEE2lw4rejnM4 qFnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=CREEuByZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j15si4105268oii.163.2020.02.07.11.32.14; Fri, 07 Feb 2020 11:32:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=CREEuByZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727154AbgBGTbU (ORCPT + 99 others); Fri, 7 Feb 2020 14:31:20 -0500 Received: from mail-qk1-f193.google.com ([209.85.222.193]:39167 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726988AbgBGTbT (ORCPT ); Fri, 7 Feb 2020 14:31:19 -0500 Received: by mail-qk1-f193.google.com with SMTP id w15so211595qkf.6; Fri, 07 Feb 2020 11:31:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ZkpXb/Mvw8qZyRJM76GkT3rnAFfUOKULtUPg4iPdeJU=; b=CREEuByZvw6a7GdcLO3uMXiq/E3wUDW+KQRbosp7l0VVBD5NLfSK60uQKE5SB9q3no zKhlfLbHLIj4TR2SQpcpPtlPTEr47jEaxgDMdCbyAcXAOJ1fuYIwe+BnntP1HrhkemGn qG0K7J8ZiVCRPK5FsT3rCX/S5hLSfA3vZSNooF6UJ8EATZKijS3lT1QIuceiUzyC5PJI L53pt//TSTOGqs+SyRjZoo03alTjFDx+JBqbWs/rOUYYcRQhb5e4W/lOVOTeVzRdtct+ eW6RxdDLfsyPx2KHxYxwiE8GFY6Ivtsb/h6EoofuGU7URSsAjehav7ss5+//4lk3WSZu 8bew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:date:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=ZkpXb/Mvw8qZyRJM76GkT3rnAFfUOKULtUPg4iPdeJU=; b=maqgi1IWYQHWq10EQ+nDSeiK1oPCMbRNQmGeJSxKXBWjtNI63upu4i44YDiIb3NVoR sNwmoeXsy5oW8nhz/s+yPcjrpBsCri1VO80RFIWLMSoULAHjASswpZWDOZ30pjNhFoxI RX0e1wQoGvEpVRtU2pCLp+D9KgkJ3bIiN/p+QEWM3FzMS06+2QOlJaedyXRiQeh5h9OM dILrKDJztYhlQ0KZlxZUGxBiqixVpgYPQ2Ihmuge/xNIIqPMdxPDsSogc4WlAjp+WkZ7 gkf2Y37NHMH91bsdTY8gEegYlMgbEqwwLaik3+U+vt/rue0XcCewqJYQWrwAWeJrMmnm DoqA== X-Gm-Message-State: APjAAAVEbPOmxT8yEWAwG71Dflivf61gfhOI4wA3sDR4/0NbJP2KxvkB 6k7YWr8mINhNIUsOHDHqCUQ= X-Received: by 2002:a05:620a:9d9:: with SMTP id y25mr439287qky.41.1581103877782; Fri, 07 Feb 2020 11:31:17 -0800 (PST) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id k37sm1896821qtf.70.2020.02.07.11.31.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2020 11:31:17 -0800 (PST) From: Arvind Sankar X-Google-Original-From: Arvind Sankar Date: Fri, 7 Feb 2020 14:31:15 -0500 To: Kees Cook Cc: Masami Hiramatsu , Steven Rostedt , Ingo Molnar , Frank Rowand , Randy Dunlap , Namhyung Kim , Tim Bird , Jiri Olsa , Arnaldo Carvalho de Melo , Tom Zanussi , Rob Herring , Andrew Morton , Thomas Gleixner , Greg Kroah-Hartman , Alexey Dobriyan , Jonathan Corbet , Linus Torvalds , linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 08/22] bootconfig: init: Allow admin to use bootconfig for init command line Message-ID: <20200207193113.GA3438946@rani.riverdale.lan> References: <157867220019.17873.13377985653744804396.stgit@devnote2> <157867229521.17873.654222294326542349.stgit@devnote2> <202002070954.C18E7F58B@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <202002070954.C18E7F58B@keescook> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 07, 2020 at 10:03:16AM -0800, Kees Cook wrote: > > + > > + if (ilen) { > > + /* > > + * Append supplemental init boot args to saved_command_line > > + * so that user can check what command line options passed > > + * to init. > > + */ > > + len = strlen(saved_command_line); > > + if (!strstr(boot_command_line, " -- ")) { > > + strcpy(saved_command_line + len, " -- "); > > + len += 4; > > + } else > > + saved_command_line[len++] = ' '; > > + > > + strcpy(saved_command_line + len, extra_init_args); > > + } > > This isn't safe because it will destroy any argument with " -- " in > quotes and anything after it. For example, booting with: > > thing=on acpi_osi="! -- " other=setting > > will wreck acpi_osi's value and potentially overwrite "other=settings", > etc. > > (Yes, this seems very unlikely, but you can't treat " -- " as special, > the command line string must be correct parsed for double quotes, as > parse_args() does.) > I think it won't overwrite anything, it will just leave out the " -- " that should have been added? I wonder if this is necessary, though -- since commit b88c50ac304a ("log arguments and environment passed to init") the init arguments will be in the kernel log anyway.