From patchwork Wed Nov 29 09:46:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Dobriyan X-Patchwork-Id: 171210 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp226843vqn; Wed, 29 Nov 2023 01:47:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IHiX3IXX1yUWsMI7sTUgC9j0Zlde9lLVpxCkQbOIwaw93L+u1DB5yuIDoGn+Ep0at2xXvsu X-Received: by 2002:a05:6808:1383:b0:3b8:97fe:7cfe with SMTP id c3-20020a056808138300b003b897fe7cfemr1007192oiw.9.1701251265283; 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=aYRx79YrU0GTiH5n3Wo+G3sYNzzJC+QaV/bkvK62Elm60ZJa6dLHMFVHtKSG2BKKmr cDuamDc4/6ghviIT+yRrstAGxAIZZ2S/sdcmeINoRT62MRyQ9nG74IvFB0m7xDimK6Cj qh1B0EFW4ZE0xjk6qD515CwSrqBdJMtOCW7ImEcK3ZPARrUfB3s9T7wpETPlZBhhkKfY N6dTwlBsqrMccxvHii39KJcpvhJeTgOSWTl+W2e1jUXYHcnwsFmgNkLxUwaMcHLyZJ7S N+nsUa8cL8TYWa29wkWyUXG7kQmwrUkbor7zv8ZT+5+OriJRKzX54zYc7dyVCWndCjQc Y7Xw== 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 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id l3-20020a63ba43000000b00578d3f8d4d4si13804442pgu.448.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 23.128.96.32 as permitted sender) client-ip=23.128.96.32; 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 23.128.96.32 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 7D8658045C63; Wed, 29 Nov 2023 01:47:17 -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-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:17 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783891246481779816 X-GMAIL-MSGID: 1783891246481779816 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))