Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3501405ybg; Sun, 20 Oct 2019 15:20:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqyE0vc0ygId+VN02iKJUfr9PSG2sayz7vrqyDduyVvX8XZcuH2erfk9dXkwcpR8nYfzZXSk X-Received: by 2002:a05:6402:1514:: with SMTP id f20mr22020275edw.35.1571610031635; Sun, 20 Oct 2019 15:20:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571610031; cv=none; d=google.com; s=arc-20160816; b=LIN8CummTpVOoBKtl49En4eLP3aAqYCenOnnX6EBeiDG7muSpftVURHG05K0UNIcy/ Z71TNq2QtQNtTYU14RYQV1xN+v5pYxkwqI2msH8Jhyq/Ei/k5qiLFqqKLodja/v8wsU0 isS5yRK87hZxCFxNrdXDyDrZMdzkIfJ70XoGOfLcZP5Lz8B+hrKbyrqLGeaGSyRxKdb7 TGa+Vw1n9ZeBCJNbK4XhX1XZ9RKkDGUonZvgNgZVEREZexcZW2fC0Mvt1xY1BeBfNRl2 DyyVwSz2ihCO8SNZT5lFOzYzSmL4n/gMPt+68zgKdd1qa4VoUxeHJeUdztpQ0BN6+xzd md5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ToBhWAEeBjIvJkh62QqZLUlNNUmIw5rQlwF9iuvC60U=; b=0VDFxXb9q2oNJReZSdvowi/pF0hiLJyhdUq9roVVYWgLvAips9nlnfw97kB/A6jFHX UTbWmDsMqy5smMgtIdOvWUHqkXg+qpk4VBfcrsrhl6uB1kumWUFsoPj4ILGpTNJai66V smvpVKUj8QUHQbsGJNd/AIfRJH1im3jyHU6sfb3SikJ+jjmEzi+tLufodIcLTut6laiY n86k0Sw9EqLHQZFkY8Ag1KmL6hPvJDAsEy/bsbEst0zlhPULwS5/wxu6y8fVIJKCh/g1 BlS+A1QvquZwsQOCVbnVp4eBFbtmmuPHK5LRLmRIboisUy6pwUGM/qoUKy/kFXj0Cswc 1e6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LGFNscPv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l9si7058654ejq.164.2019.10.20.15.20.06; Sun, 20 Oct 2019 15:20:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LGFNscPv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726665AbfJTWRv (ORCPT + 99 others); Sun, 20 Oct 2019 18:17:51 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:48078 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726374AbfJTWRv (ORCPT ); Sun, 20 Oct 2019 18:17:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571609870; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ToBhWAEeBjIvJkh62QqZLUlNNUmIw5rQlwF9iuvC60U=; b=LGFNscPv9IiXdrQR7Pi2U8qdCa9227JmNw+Rn/pN+bSbj7OK6aivA8XXjhBAU1VxNkCKfE dYIFPoBs6+DdDYJ6VhCi9o7q8pv+lgIXp39AfrpoUCWQ4OftSVojcwR9Fl1wH3pjC0WuMA 1g5lZ7eWuUzrKfeyK7CPuUdRIuv69G8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-96-OsNYrM9cMQuslhkGZX3JcA-1; Sun, 20 Oct 2019 18:17:48 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 444FE80183E; Sun, 20 Oct 2019 22:17:47 +0000 (UTC) Received: from jsavitz.bos.com (ovpn-121-29.rdu2.redhat.com [10.10.121.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 466E760A35; Sun, 20 Oct 2019 22:17:45 +0000 (UTC) From: Joel Savitz To: linux-kernel@vger.kernel.org Cc: Joel Savitz , Fabrizio D'Angelo , Alexey Dobriyan , Andrew Morton , Greg Kroah-Hartman , Thomas Gleixner , linux-fsdevel@vger.kernel.org, fedora-rpi@googlegroups.com Subject: [PATCH] fs: proc: Clarify warnings for invalid proc dir names Date: Sun, 20 Oct 2019 18:17:42 -0400 Message-Id: <20191020221742.5728-1-jsavitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: OsNYrM9cMQuslhkGZX3JcA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When one attempts to create a directory in /proc with an invalid name, such as one in a subdirectory that doesn't exist, one with a name beyond 256 characters, or a reserved name such as '.' or '..', the kernel throws a warning message that looks like this: =09[ 7913.252558] name 'invalid_name' This warning message is nearly the same for all invalid cases, including the removal of a nonexistent directory. This patch clarifies the warning message and differentiates the invalid creation/removal cases so as to allow the user to more quickly understand their mistake. Signed-off-by: Fabrizio D'Angelo Signed-off-by: Joel Savitz --- fs/proc/generic.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/proc/generic.c b/fs/proc/generic.c index 64e9ee1b129e..df04fd4f02af 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c @@ -173,7 +173,7 @@ static int __xlate_proc_name(const char *name, struct p= roc_dir_entry **ret, =09=09len =3D next - cp; =09=09de =3D pde_subdir_find(de, cp, len); =09=09if (!de) { -=09=09=09WARN(1, "name '%s'\n", name); +=09=09=09WARN(1, "invalid proc dir name '%s'\n", name); =09=09=09return -ENOENT; =09=09} =09=09cp +=3D len + 1; @@ -386,15 +386,15 @@ static struct proc_dir_entry *__proc_create(struct pr= oc_dir_entry **parent, =09qstr.name =3D fn; =09qstr.len =3D strlen(fn); =09if (qstr.len =3D=3D 0 || qstr.len >=3D 256) { -=09=09WARN(1, "name len %u\n", qstr.len); +=09=09WARN(1, "invalid proc dir name len %u\n", qstr.len); =09=09return NULL; =09} =09if (qstr.len =3D=3D 1 && fn[0] =3D=3D '.') { -=09=09WARN(1, "name '.'\n"); +=09=09WARN(1, "invalid proc dir name '.'\n"); =09=09return NULL; =09} =09if (qstr.len =3D=3D 2 && fn[0] =3D=3D '.' && fn[1] =3D=3D '.') { -=09=09WARN(1, "name '..'\n"); +=09=09WARN(1, "invalid proc dir name '..'\n"); =09=09return NULL; =09} =09if (*parent =3D=3D &proc_root && name_to_int(&qstr) !=3D ~0U) { @@ -402,7 +402,7 @@ static struct proc_dir_entry *__proc_create(struct proc= _dir_entry **parent, =09=09return NULL; =09} =09if (is_empty_pde(*parent)) { -=09=09WARN(1, "attempt to add to permanently empty directory"); +=09=09WARN(1, "attempt to add to permanently empty directory in proc"); =09=09return NULL; =09} =20 @@ -670,7 +670,7 @@ void remove_proc_entry(const char *name, struct proc_di= r_entry *parent) =09=09rb_erase(&de->subdir_node, &parent->subdir); =09write_unlock(&proc_subdir_lock); =09if (!de) { -=09=09WARN(1, "name '%s'\n", name); +=09=09WARN(1, "unable to remove nonexistent proc dir '%s'\n", name); =09=09return; =09} =20 --=20 2.23.0