Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4452427rdh; Wed, 29 Nov 2023 01:47:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IHXGegStt+MKqsEL7DDwF7w8K+TekoX5Rb9IUjQU2DEOwaMYh1Oh26xagv784UHhrGtAJNE X-Received: by 2002:a05:6808:14d0:b0:3b8:4406:c63 with SMTP id f16-20020a05680814d000b003b844060c63mr20630557oiw.41.1701251265342; Wed, 29 Nov 2023 01:47:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701251265; cv=none; d=google.com; s=arc-20160816; b=V5eRy5i5Rk4/QKGl4Yi0bfZ2tFL3kCz8pSCXswwG3Z0stFRj6wWyrpDLIV48Clp8sq vjuj6RTZopF3Ct+XDYdUxo3SSQpq3B0BwkOayaBZC9/c+bl6XCXdIhpNkPIAev+bsdCt dHIb4dg5kGokgWVuk9U3Zp37p0BQgA5sydpq1L/j7sn8Cjla+awwHKExVQG/oZxtf00O tYa8lJqrymioUY9L8yS4WmkBJZ2v1RjL8VOHuNRvb5IPT2mc2RJd+9OinXG1TZ6a8SWs 6XpYHq9IJNXMDWC6q3gvuKNvQAEaNOFOuUVf9RRnxlkWnskpelpHo1bOi1GoEF8neKyj x0xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=lkr8t9D0wxE4Z/I0QJxL5c6oDaDd0nklY7ppqyjUFtU=; fh=OsxpHFVO0TTWpkd9nz9iIoXNJG/cbfzAlmsmMnvz/wI=; b=Lr5piba7TjEEZWp63AIeLV8626K264KWf1u2VDZj2BYdBWRZfmajrpLA63rYWX400F yKogALiOe3bTAmjzIT08xmJZA40BL3F+xG22MlNnS6W2rug98EYhjBLSslVCxU8d1csb 9fg26mbLlMrrq2+N01ja/m0dXHcmFP0JQ36SxH6qkDvEn174Eh7YdI5d7rwkV3y6AbMt z3sG/zlsDz96aKxInUCELl/AueWhr7cwURJbIoQaeODjB9XwOopP3R4yoUw1h7GCn3Nu 6s4d0Fw4IIGaDcxgVAQLrDaM4nwYVrXlo/BRVNGDxF+PFaVqkIlxTg4ijRNsQIhvLjfb 0RJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=TQOiyCcj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id f23-20020a63de17000000b005c5e29ee770si3890595pgg.363.2023.11.29.01.47.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 01:47:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=TQOiyCcj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id F04828045C6E; Wed, 29 Nov 2023 01:47:20 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229601AbjK2Jq6 (ORCPT + 99 others); Wed, 29 Nov 2023 04:46:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbjK2Jq4 (ORCPT ); Wed, 29 Nov 2023 04:46:56 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE8ACD6C for ; Wed, 29 Nov 2023 01:47:01 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-9fd0059a967so133449566b.1 for ; Wed, 29 Nov 2023 01:47:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701251220; x=1701856020; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=lkr8t9D0wxE4Z/I0QJxL5c6oDaDd0nklY7ppqyjUFtU=; b=TQOiyCcjRGJnksqRkRqvqZhFDoqO4X5Wbg5ae7dhUUNBbwWrHggXVkOf9QYRCMUuPM nbcQ7V1JswKA78uXIVIkk56nqdxqFmoXhqr3AuZ3IwmzKjrmHfj9BdGewo6dEYhy2b3y oKwAGw/WhzvSK1uMLkZrLQuZtIbsyOjnwsEiTQDM4utvPwYaCQBuQ3HsrADM3fnQ6kCk Bb429IpiJYOHGMlwd3uj8wrkJHou7rRsJkDGNsFOW4tAgIe7Qgidnk4RRR7X81wXiiI1 ZZGuaIs9kPsHef9s9pOyvQvZcZs4/NnOnepMVFtyxmEgrCI7RLdiUtp6rTPvyXCqys2K ZVoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701251220; x=1701856020; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lkr8t9D0wxE4Z/I0QJxL5c6oDaDd0nklY7ppqyjUFtU=; b=u2maBBXo/buIpUZ9zaYvtaLeQADv6zPTOnmWbMmetOhRsJtzHi9X7t73rL8rAvWIrn OfUCTr3Tep7OGZGOkXqp+si9OWkhUnb+7ODOpUOI3nWlTDuzG9/nneJklhtpYUdiokrZ hdTcCGB3mW6XsFesmZ8G++IiEc9US1PeUahUb7FssplP5Bq8I+LUe4yreKJO3J+PsqSo lZcQrDQ6LM5kAgmO9eavdC4YRB7vqQSPDoJEkjsoniBuIbcqJ4/v8ENFspp044OkTOh5 qdbiXXd28WIEDVsXNqX9BjSt92ZSep2CSaOt0hK3jUmONstamC7owlslBhWOt4at54jW MC8A== X-Gm-Message-State: AOJu0YxHkTc+xrQl9Tf2iDCcT8g3cBZMphslIoyCss4cMxnUUD5p75R3 2feU/UlGWfsPZ8FpZTFk8RNhtrAiaw== X-Received: by 2002:a17:906:100e:b0:a0e:7e2:1b1e with SMTP id 14-20020a170906100e00b00a0e07e21b1emr10029624ejm.23.1701251219936; Wed, 29 Nov 2023 01:46:59 -0800 (PST) Received: from p183 ([46.53.250.67]) by smtp.gmail.com with ESMTPSA id 9-20020a170906218900b00a0988d69549sm6192529eju.189.2023.11.29.01.46.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 01:46:59 -0800 (PST) Date: Wed, 29 Nov 2023 12:46:57 +0300 From: Alexey Dobriyan To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH] proc: make struct proc_dir_entry::name const Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline 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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 29 Nov 2023 01:47:21 -0800 (PST) Multiply ::name into "mut_name" and "name" which is "const char*". PDE's name must not be mutated on live PDE, hint modules they should not do it. Many other members must not be mutated live as well, but start with obvious one. Signed-off-by: Alexey Dobriyan --- fs/proc/generic.c | 2 +- fs/proc/internal.h | 5 ++++- fs/proc/proc_net.c | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) --- a/fs/proc/generic.c +++ b/fs/proc/generic.c @@ -436,7 +436,7 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent, } } - memcpy(ent->name, fn, qstr.len + 1); + memcpy(ent->mut_name, fn, qstr.len + 1); ent->namelen = qstr.len; ent->mode = mode; ent->nlink = nlink; --- a/fs/proc/internal.h +++ b/fs/proc/internal.h @@ -59,7 +59,10 @@ struct proc_dir_entry { struct proc_dir_entry *parent; struct rb_root subdir; struct rb_node subdir_node; - char *name; + union { + const char *name; + char *mut_name; + }; umode_t mode; u8 flags; u8 namelen; --- a/fs/proc/proc_net.c +++ b/fs/proc/proc_net.c @@ -368,7 +368,7 @@ static __net_init int proc_net_ns_init(struct net *net) netd->namelen = 3; netd->parent = &proc_root; netd->name = netd->inline_name; - memcpy(netd->name, "net", 4); + memcpy(netd->mut_name, "net", 4); uid = make_kuid(net->user_ns, 0); if (!uid_valid(uid))