Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp5690508rwi; Sun, 23 Oct 2022 10:08:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7bjMF9ttEY+RgCoriAXG5ErMMqRILvvxgnLHWFv5p4z1y7Zjuf0HDnBNGeOPj0YHjXDCt3 X-Received: by 2002:aa7:c6d9:0:b0:461:b431:9058 with SMTP id b25-20020aa7c6d9000000b00461b4319058mr2669893eds.208.1666544909829; Sun, 23 Oct 2022 10:08:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666544909; cv=none; d=google.com; s=arc-20160816; b=c8xWiY4wZ5lV70ud+GNMO6gRfk4q4Lm7OrqJPzgGVkUNHBeuY0A0uz0g0KW82v8lpg liZQBBh3U/Fm16+kFA+OnzsAmXettH1YXLLAzz9cCR+sCPWA5j7shrPv2qceYPedDJjE jAUeKNN+x67poSSsnDctpHT+SXLq6uDo+AfcqoVyPN30mI69hvoxTeFmnz08V4ZxZJFg nLLYqoMzWqMViACFLsSTftHJYQ2WeuIVfrujDX1aMez9pRBF7jzj5XKqBLH+JHcp4yCM dTOP3WfubD4HPtqLpJnqMil1A4xS3uBTYIVmePgnapQftAv5T5XNPIBNzuWlqEL/y21s yrpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PWdKBK100G137ePLJZr7SsyGe/cg6oRLKCkeoRrPIPo=; b=rYYaauWP637ze6QLZINxG5g2huuMCxrOob1cw6KHomIjUw2HWhbB0/lfO9GhaoRvYv 1ai3ntGCfzGAUxGVv4X6BXvm8SrqjSig++7J55moLEvxbzmmuprt6ZsCwOKFaID67q9M rLe3mHuNFCh0vdjH8hWQPOu8Zf/kWQVXRQez4cvIscGkQS0SyvP+WttFezldStWc8VJ7 hONe0zbnCsdZYSKGfMA5hG4XVGOXUugLf7xO5rAD+qWBucCvwESGKkfiYzk/OBsn4WhZ 046euvA6Rda2bUgPTfFLQ9W1dg3HvX2UqzBlkCbq9GA5th4XHdVzJu2TpI7uksjpA9FY lhdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Puu4zOrl; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w19-20020a056402129300b00461a3438b24si2176207edv.182.2022.10.23.10.08.04; Sun, 23 Oct 2022 10:08:29 -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=20210112 header.b=Puu4zOrl; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230437AbiJWQnZ (ORCPT + 99 others); Sun, 23 Oct 2022 12:43:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230161AbiJWQnX (ORCPT ); Sun, 23 Oct 2022 12:43:23 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBF036EF07; Sun, 23 Oct 2022 09:43:20 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id 20so6820047pgc.5; Sun, 23 Oct 2022 09:43:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PWdKBK100G137ePLJZr7SsyGe/cg6oRLKCkeoRrPIPo=; b=Puu4zOrlu1SOJ0TTr60mNTaYFimaMnCTlIQSpZ7MuZJNWOsz5B7Jnh5Q2iq5TZUvfU DmjvbVyZXk2MaWyEFn9L75XKoD+t90BrEe1aT6DD4lPZH9c9PSZug5sWCcK6bMdZGtBs yyqdqSUYiXHLG5UzRNNcJ6+A4MZR6jHm4fP6fWFT5/pqEqWHaaSuZPz3Fj7np9GUq/Wv S/uK20hEweG4pjIjqLLcF1WXZNwDnKI5Ll+EST/86aXTHs8c1PKa0SwJpu1IQiXeBCLt UaNcYKFldx8jp/z8zV6k8dIDlpDcZtd/2hej4RU2OtQDNK8xYpTqla8COuCs+mRzXN3p hgHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PWdKBK100G137ePLJZr7SsyGe/cg6oRLKCkeoRrPIPo=; b=SVm+NIAjzU5r5a788obpJ0NRIyMRCRocfIwEkhCyQ/8xqcctctnVh/UrC9XJjQ0MJU vg47NqEBwRRZYJnV0jiVc1yLBRjjP5pnQsKopLhwUZWsaotFceH17HswuMZaBpyGcgk4 XNjSFftNWI/gE7CNZQSjuhPHFlrNQEs2lPxnNsnE/aBsoHFSsJxpfL72HlNlTM4tgmYa Nj8cq0GcCK4mui5njSHJd2Xh01VUzTUNaLLJa8UkT5ADHutmT4+6NPcM44PqYCqEhUuS rSL7n4ZBPKfpxQZ/PNZGHLMZkxpYxQaCSWmtZi8pURsa0Iwgqm6irYLTs18qjjLrTn1w lN/g== X-Gm-Message-State: ACrzQf2P9bIQismigyuJDb6LIsNQ05+Ag+y5Y2Opdovw+qB5YAlZkPtN O+DOdK6Y6F4WcoDpwSBgRZ71gtZuzQTmLlNYPIE= X-Received: by 2002:a63:480e:0:b0:46e:b96c:4f89 with SMTP id v14-20020a63480e000000b0046eb96c4f89mr11199609pga.201.1666543399790; Sun, 23 Oct 2022 09:43:19 -0700 (PDT) Received: from localhost ([223.104.41.250]) by smtp.gmail.com with ESMTPSA id k76-20020a62844f000000b0056b91044485sm2688499pfd.133.2022.10.23.09.43.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 09:43:19 -0700 (PDT) From: Hawkins Jiawei To: yin31149@gmail.com Cc: 18801353760@163.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH -next 5/5] proc: fix possible null-ptr-deref when parsing param Date: Mon, 24 Oct 2022 00:39:51 +0800 Message-Id: <20221023163945.39920-6-yin31149@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221023163945.39920-1-yin31149@gmail.com> References: <20221023163945.39920-1-yin31149@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 According to commit "vfs: parse: deal with zero length string value", kernel will set the param->string to null pointer in vfs_parse_fs_string() if fs string has zero length. Yet the problem is that, proc_parse_param() will dereferences the param->string, without checking whether it is a null pointer, which may trigger a null-ptr-deref bug. This patch solves it by adding sanity check on param->string in proc_parse_param(). Signed-off-by: Hawkins Jiawei --- fs/proc/root.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/proc/root.c b/fs/proc/root.c index 3c2ee3eb1138..5346809dc3c3 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c @@ -130,6 +130,9 @@ static int proc_parse_param(struct fs_context *fc, struct fs_parameter *param) break; case Opt_subset: + if (!param->string) + return invalfc(fc, "Bad value '%s' for mount option '%s'\n", + param->string, param->key); if (proc_parse_subset_param(fc, param->string) < 0) return -EINVAL; break; -- 2.25.1