Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp6118913rdb; Mon, 18 Sep 2023 05:02:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF6iZQbroSECMZ8DAF6Q2wRyRl6F55OAeqV4fjOcZdImXKNTKA3811TFuZ0zk+xG4uNC9hi X-Received: by 2002:a05:6a00:2d21:b0:68c:3f2:6000 with SMTP id fa33-20020a056a002d2100b0068c03f26000mr12282732pfb.6.1695038533190; Mon, 18 Sep 2023 05:02:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695038533; cv=none; d=google.com; s=arc-20160816; b=DFm0mJ14WN0HQuRpd6FKl0o3dH81PhaTVFJeJY7bh+JWONVu/kenTaO9TsmvwpEY3t bCtMw6bmF6kNrOQni1MAkm4UUwam6uo58qJYEN8MD7OMxSP388GQSfZr0aUEmeZbedym jn/IvbmW6elloS8O49U9klSy5dfByGmuvNY1jnaaXCJy5Wx09j5ferHA8ZzEYDbeW+C+ gR7ET0YIoBikmqNwh6vr1KgUHgRCOK3q/AeJjjKjT+WXJe9U5ifI2yt4fUhHWILXTZ33 B60JT36UAFOu5iBUJOtuJ8Nr0S1boa8z+pK8pSB/2PT1NweADigcnqHHChyf9l1xYr6J WjxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=bHJH3dyMC9XQ0B/wqpE6xWX7DIRsvVcIcXhdiXVsMlo=; fh=k9A9Z+e7pN7t59Ij5mXb722ZCL+fBcJPP36fSYIuBao=; b=A/HLyOaqorxYo7l4AKxrT5zN8Ez/3jUnXLz0TDitByEha59V6zrHKnDcxXO6fRePs5 FXypqqFL+VNjkECTdL/OXv/EIIMJD+Kg5XdfdXRFsNYNaxkBqv4zhzMjy81DEmfAhIB7 uahCBNZOe2m+Gb3H7VjMoJQmWyu5L0flSKeMNA9BXISyuPEu/Gast8v0PAMrEBK1CciH qzrhrDs7vGcNoKdoIGWKdwkr3eyYkqtpqiJq5NBq9++vOgWdQi9Itav+gLHOf8G/Dw8u Yh9ODd2I5xdnJ0kKDmbGHq+C1aHE5SX8PGmp5FD0+jZgxOktb1Mxf6mQ601qBRqlRACL JUUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=L8oNNV1N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id m1-20020a656a01000000b0056a670ebd73si8389939pgu.498.2023.09.18.05.02.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 05:02:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=L8oNNV1N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id E5DDC80CE7F1; Mon, 18 Sep 2023 03:01:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240955AbjIRKAW (ORCPT + 99 others); Mon, 18 Sep 2023 06:00:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241056AbjIRJ76 (ORCPT ); Mon, 18 Sep 2023 05:59:58 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D52DAEA; Mon, 18 Sep 2023 02:59:51 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-9ad810be221so563289766b.2; Mon, 18 Sep 2023 02:59:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695031190; x=1695635990; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=bHJH3dyMC9XQ0B/wqpE6xWX7DIRsvVcIcXhdiXVsMlo=; b=L8oNNV1NX9q3zsO0Qtfp+Bz/Hb0UuIpEq0jR2wty7RmPyzubbJgFpkR9TrXWCTmnr9 X5GrVEwkEiLXJ2jmb6QOKMbkKQnsveMvcrq8V0g1FwgT5d9L1Y0dFVVuIQkjM5h3lvLM TYhCcb1j/hLRz9X0f35pQcTJYw57u3MF0wNYcVeVg7K0+tVnng5vBnzUsxRijwzQA3Sz Y12RhrUf5AT8ru2UG7CdIAMNV2lT3qaBQ1Nn8+QiSfvh0+DWi5d7sYu9yKNtoaHXrHfU imSK6J/2JLRNPZuAFjeMZpPrTs/tXzDuov+U/g+FXeAy1VTWFUY2SW9yO+556PwNiZ0x MP9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695031190; x=1695635990; h=in-reply-to:content-transfer-encoding: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=bHJH3dyMC9XQ0B/wqpE6xWX7DIRsvVcIcXhdiXVsMlo=; b=Ud8YVpgHTS8g13LrFSmiq7Dp8k6FpPSHapDMhIfA10uvgJg0wbXOF2crBsL8vgGGQ6 E5nq1tniHg8RvG1j2wHkPpXmgAAhfg1hvIzgEn9cuVYXT6NgcaTxfzRWBSdV0pNrDmm9 7LT60iRf0KEtVHUf4NyMNkdFqmD+EscNKoAnOm2Hw9EKoObfxiRNkR+G20Yi488vKXZN fj7vUgoAqCZ3sG7+Z+VsRujcsuhbVlz7WsBzw8OlEgt/Alb/IbCdWoq/Qda5BtnH9rhV vtXG1yNBTpCr70cPZf3uzQHtnfiYqu9orvRhx3lvvnpY1fyK4GmutGd88oYXrPDLfTzG RXuA== X-Gm-Message-State: AOJu0Yw7ETCxTO1LhMeeJnYBWHY+FzF58dttBa+KsaS6SV335K80207N 0XXnNiRRk5DY69N/YLiiUFeRc+rZCw== X-Received: by 2002:a17:906:300e:b0:9a1:cdf1:ba3 with SMTP id 14-20020a170906300e00b009a1cdf10ba3mr8373766ejz.27.1695031189942; Mon, 18 Sep 2023 02:59:49 -0700 (PDT) Received: from p183 ([46.53.249.126]) by smtp.gmail.com with ESMTPSA id vb1-20020a170907d04100b009adca8ada31sm5038695ejc.12.2023.09.18.02.59.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 02:59:49 -0700 (PDT) Date: Mon, 18 Sep 2023 12:59:47 +0300 From: Alexey Dobriyan To: =?utf-8?B?5byg5a2Q5YuLKFpoYW5nIFppeHVuKQ==?= Cc: "akpm@linux-foundation.org" , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: DoS in lseek inodes with proc_ops Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 18 Sep 2023 03:01:04 -0700 (PDT) On Mon, Sep 18, 2023 at 07:39:51AM +0000, 张子勋(Zhang Zixun) wrote: > Hi, > There is a null pointer dereference DoS issue when I use lseek syscall to inode with proc_ops. > I find the root cause is https://lore.kernel.org/all/YFYX0Bzwxlc7aBa%2F@localhost.localdomain/ . > In this patch, the lseek syscall is set to mandatory. So, if proc_lseek is not set in proc_ops, pde->proc_ops->proc_lseek will get a null pointer. > I want to know why all inode in proc need to set its own lseek, and why set default_llseek in pde_lseek isn’t a good idea? > By the way, although every inode need set a lseek to use lseek syscall, lseek to a inode without lseek should get a fail return and the kernel should’t panic. It removes 1 branch and make code smaller too. You can switch to nonseekable_open() if you don't need lseeks.