Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp10949009rwd; Thu, 22 Jun 2023 07:01:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5OdUR6zZrbOcW/0xfyGPJ6QsGVvBtlfbFoaezY/oX6m3Sg60++7glGCERUAZC+Q+Uvsrst X-Received: by 2002:a17:90a:198:b0:25e:a1ae:16c6 with SMTP id 24-20020a17090a019800b0025ea1ae16c6mr13847697pjc.27.1687442474509; Thu, 22 Jun 2023 07:01:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687442474; cv=none; d=google.com; s=arc-20160816; b=O7RQJkkRsYb3ajdvDnDmA6kT3ef6vXJNQJnzMDzjKJSZbRoeuvE2hRdlXcDJJHwqPM PgE/bMVOoevDf/ueKRDGwKj2SINBpXUe27HF219O/tBq2X9MeMnu3bjHJK8+x3uggPIt f1x3RQJOYySbpHLt68Rar/0/w5ds5J6Gx3pl/mkNx/xO0aEPQvlEeLSyZZUMxw7Dzwzs fWe0WRBk9ABk68T/adjYOZzwKpVxFpfa5GbTiX3mBNBS6XN0wl1H6s2Gyyquy2Br4Ce5 kbWJwLzYpzdkMPZv0nR2G7btEO9TiSN88XINQB7YtOIC+oYyzBSjOmdjpBj5KNvoSHuw mpmw== 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:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:sender:dkim-signature; bh=U9uei6ikJRas22Hwp4mZTaUlT0qL8iBQnmHCBvfcXwE=; b=U/GL7CPsOuMmQyWE4ggZimStiIg6qZlu95bCFGT82LetS8X+Q1CFVoR3ja/jPiqTXH maIfNuPV19syBXPgPO87sz1NlNmvrxqj0seSSz3d6FRxn9pnK2XL0HZtFhR2kbLKhaF/ PI5q63L780ABWkjB6Jy6mmt87PIqrpeSobPYrdjn2Cxj3ySjnaoj4xyqpEvq4S1IC7B2 gxIUteQiMjKvMtnhoQPZDnELK5KBPp/XEyid1KuzJW7aaVm78JF91mNHcgA/+ZtBeM3L grirRSQGYZ+8XOULvReOwBS5kfs8bGfW9slS+2rLfO7gbD/lQA1//Ef+mGZWgKRG4mXY om1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Kw978Z23; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q10-20020a17090a2dca00b002568a675b65si14191721pjm.141.2023.06.22.07.01.01; Thu, 22 Jun 2023 07:01:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Kw978Z23; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230214AbjFVNys (ORCPT + 99 others); Thu, 22 Jun 2023 09:54:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230098AbjFVNyq (ORCPT ); Thu, 22 Jun 2023 09:54:46 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FF5A118; Thu, 22 Jun 2023 06:54:45 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-666e3b15370so4244516b3a.0; Thu, 22 Jun 2023 06:54:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687442085; x=1690034085; h=content-transfer-encoding:in-reply-to:subject:from:references:cc:to :content-language:user-agent:mime-version:date:message-id:sender :from:to:cc:subject:date:message-id:reply-to; bh=U9uei6ikJRas22Hwp4mZTaUlT0qL8iBQnmHCBvfcXwE=; b=Kw978Z23e+L9swbJ/qPhWDxzJV/G86Wx25DJn0cTKvNiYACrmzp7BPZctuPoub+e7A SzHfOnzp5yXISP7WfuVH7apwXlXoU8dBq93wopAFKfrK5PVe5ABShZf4FdHPVkf0G/5o oUto5fvdibM432uwNFHFOLEQuBPwhbRg5i/mBJQ/KO5gRMtcXB8nuNoNjx66SQoEjU5a qbvyJUojUiTFgAn3KuQ72WAr12vm3uPfSN57MMrQLtBsvX0b2Ao5XzzTJhV9gCwAqTaZ TdI7VmpmMdYjeY+FaqUxH/p8idBD432Qz3d9XcrxyTFIPn14OQGqUpU4mfg8+YmvwVt6 M6Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687442085; x=1690034085; h=content-transfer-encoding:in-reply-to:subject:from:references:cc:to :content-language:user-agent:mime-version:date:message-id:sender :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=U9uei6ikJRas22Hwp4mZTaUlT0qL8iBQnmHCBvfcXwE=; b=MrwfljWi+uDOTdgueB7tiSZ+aR3M7dE9X7NEe3E42KGzN6Kp1/f3+bzkVepf/yo0Pt t9eaUFWitU87/C6EaqQVrvan0xY8l9XJMRfL9tJBZqeJl1bYkPR1bdQlBYslKa2zCfnE ca/VQQIkkqyBDNSF9ABq+r4sgv2rFMvQi/Xp5rlkO2IaH3om5cmqTlVPDr1nehRCe4Xg tIGjk7oK0mAPkgu/BEZpU5M5i9iTf+8/e32R72X3yLYotSO/rdXumq17S+MPSqhgu0Yn 6sE/ONwMyG7SmN4YJW9zEWbKeDWH+mGKRNK4VMEUkyzSUKnVeDc8ze/mWHV066/Qju/1 sJuQ== X-Gm-Message-State: AC+VfDzYfhs5DrhT4SDorB7TfJ/BKH0gKmG7GcFoQMIlURa1HpEguw/B zP0J768rDf9S0FcErZMybuU= X-Received: by 2002:a05:6a00:b83:b0:668:6eed:7c1b with SMTP id g3-20020a056a000b8300b006686eed7c1bmr15157991pfj.14.1687442084782; Thu, 22 Jun 2023 06:54:44 -0700 (PDT) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id n4-20020a635904000000b00553b9e0510esm4778946pgb.60.2023.06.22.06.54.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Jun 2023 06:54:43 -0700 (PDT) Sender: Guenter Roeck Message-ID: <8e6c8365-5c2b-2bad-bf3c-df2d65cc8afa@roeck-us.net> Date: Thu, 22 Jun 2023 06:54:41 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Content-Language: en-US To: Christoph Hellwig Cc: Jens Axboe , Greg Kroah-Hartman , "Rafael J. Wysocki" , Mike Snitzer , Joern Engel , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Pavel Machek , dm-devel@redhat.com, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-mtd@lists.infradead.org, linux-pm@vger.kernel.org References: <20230523074535.249802-1-hch@lst.de> <20230523074535.249802-15-hch@lst.de> <8c1992bc-110a-4dad-8643-766c14bf6fd4@roeck-us.net> <20230622035149.GA4667@lst.de> <2205ef1e-9bb6-fb1e-9ca3-367c1afe12ac@roeck-us.net> <20230622060001.GA8351@lst.de> From: Guenter Roeck Subject: Re: [PATCH 14/24] init: clear root_wait on all invalid root= strings In-Reply-To: <20230622060001.GA8351@lst.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/21/23 23:00, Christoph Hellwig wrote: > Hi Guenter, > > can you try this patch? > > diff --git a/block/early-lookup.c b/block/early-lookup.c > index a5be3c68ed079c..66e4514d671179 100644 > --- a/block/early-lookup.c > +++ b/block/early-lookup.c > @@ -174,7 +174,7 @@ static int __init devt_from_devname(const char *name, dev_t *devt) > while (p > s && isdigit(p[-1])) > p--; > if (p == s || !*p || *p == '0') > - return -EINVAL; > + return -ENODEV; > > /* try disk name without */ > part = simple_strtoul(p, NULL, 10); Not completely. Tests with root=/dev/sda still fail. "name" passed to devt_from_devname() is "sda". for (p = s; *p; p++) { if (*p == '/') *p = '!'; } advances 'p' to the end of the string. while (p > s && isdigit(p[-1])) p--; moves it back to point to the first digit (if there is one). if (p == s || !*p || *p == '0') return -EINVAL; then fails because *p is 0. In other words, the function only accepts drive names with digits at the end (and the first digit must not be '0'). I don't recall how I hit the other condition earlier. I have various "/dev/mmcblkX" in my tests, where X can be any number including 0. Maybe those fail randomly as well. Overall I am not sure though what an "invalid" devicename is supposed to be in this context. I have "sda", "sr0", "vda", "mtdblkX", "nvme0n1", "mmcblkX", and "hda". Why would any of those not be eligible for "rootwait" ? In practice, everything not ending with a digit, or ending with '0', fails the first test. Everything ending with a digit > 0 fails the second test. But "humptydump3p4" passes all those tests. Guenter --- #include #include #include #include #define EINVAL1 1 #define EINVAL2 2 #define EINVAL3 3 #define ENODEV 4 static int devt_from_devname(const char *name) { int part; char s[32]; char *p; if (strlen(name) > 31) return EINVAL1; strcpy(s, name); for (p = s; *p; p++) { if (*p == '/') *p = '!'; } /* * Try non-existent, but valid partition, which may only exist after * opening the device, like partitioned md devices. */ while (p > s && isdigit(p[-1])) p--; if (p == s || !*p || *p == '0') { return EINVAL2; } /* try disk name without */ part = strtoul(p, NULL, 10); *p = '\0'; /* try disk name without p */ if (p < s + 2 || !isdigit(p[-2]) || p[-1] != 'p') { return EINVAL3; } return ENODEV; } char *devnames[] = { "sda", "sda1", "mmcblk0", "mmcblk1", "mtdblk0", "mtdblk1", "vda", "hda", "nvme0n1", "sr0", "sr1", "humptydump3p4", NULL }; int main(int argc, char **argv) { char *str; int i; for (i = 0, str = devnames[0]; str; str = devnames[++i]) { printf("%s: %d\n", str, devt_from_devname(str)); } }