Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1677304pxj; Wed, 19 May 2021 11:14:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeko+7ZMSDFh6S/HPY2IGpu9zF+Xk67wlYgDoUG998tegv7XYGaQfV+51CwHeemTP2say/ X-Received: by 2002:a92:db0e:: with SMTP id b14mr249527iln.171.1621448070214; Wed, 19 May 2021 11:14:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621448070; cv=none; d=google.com; s=arc-20160816; b=jtglSwq8CofYnQnInj6FMSRHLTvEy2Iat8Ykurn+e0wMquBzNX0nUvbvHY0GIGqyxS 7NTO2vjB0bnYgXwLDAxEfwqBF8ZmT1dnt0SMn4bZ+Kj8SGo4UDkVxOfdf57rMM0w9oiV WS6cnd2F9XRoH5BiYylxwAey/Xu1VFjnKEA6VRa54IFVBSrVEB+3AdStx8Yn01Nkj0p3 qQ+DPQz7TA9gQrjptC1dCw6hVg9EutsCsrDcJp7CV7slVi0p/K8LJ9DJJMD5M1VOTnNq PcS6o2iyWNgOOL4esBCJxmCW6kMKtGIG8K0voX2QIbNI3cypHPbPSd9bmZxLPaBb9UDD rPLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=mK7d6oGFkXGXXI408kRUskU6kfH3r2iCF2LbWFRKjEo=; b=LCIRIpX/J6wbTqT9bOQA+NbVl2GPsl3Tiqb7qOOxmEd15aEPh16oE7x+WsKzOjGmEI /ETq0IeQN9jq1Wh9dsm+RYb375wF5pKXfv0qMB5H1Fuk0LVRLo/D7vr5Uj96V3prOtTq B2KJcfp0dPQMl73EJjIZGp8PmBRX+RCf6P/kLzrXTb7rt3FeoBqJ8hQdY5lBbeXpxxrh s/R16VATiiDYuj+hXgZzEHTip3ozMxChdolNd5YeHc3WkMwrgOXzYalstNGKBoovv1+7 GQdDHO8QeffrwLVn6Q8sbEDQ4jiXf5uMmIEnyd4Kuo20W7j6rJCU1/mozBlJZVPnm/NQ h7sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b="fG6R6/nJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chrisdown.name Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 17si281717ilj.19.2021.05.19.11.14.17; Wed, 19 May 2021 11:14:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b="fG6R6/nJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chrisdown.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349792AbhEROJN (ORCPT + 99 others); Tue, 18 May 2021 10:09:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349790AbhEROJF (ORCPT ); Tue, 18 May 2021 10:09:05 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6051EC061573 for ; Tue, 18 May 2021 07:07:46 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id r12so10410167wrp.1 for ; Tue, 18 May 2021 07:07:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=mK7d6oGFkXGXXI408kRUskU6kfH3r2iCF2LbWFRKjEo=; b=fG6R6/nJf0NcYu3xjatUO7NpsA+m68YbzkmBiOz4ECgF212/GaHRoNL/XMlRtgpa/5 LroRcJGSyjrdC6UUo/3tNtApVifURGqoJFbmelwWx7DYevwCS68GBCzwOzKGZDZTSxp9 2tcKutUpV4euvQHVCdQnK8rbJHdtNAfueRDC8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=mK7d6oGFkXGXXI408kRUskU6kfH3r2iCF2LbWFRKjEo=; b=evS1tUwKKdZZ39emPVW/GTjuIpuBzZ8EGZON/NcRhJzMs8R2WV4RfOFpwKqHXeoMqN wDS2Vqej/YrHQ/CaIEVkDgt0K4xzRpXvKSSLBi0t3sDTW77RSn2KEiSXVsYftNGb1Zdg ZeOEKCJipBDNCtqbocggnzLawTPq0MkTkZ4MGCCu2p3Rs3D4OUiPwgsfQANrh0eViypY TQnw/nPjJ+g2ejNwoYC4sDywGvjjYB2vcJ/VqodpVgakEiyobpJbVs1Nk+Bn9BPp0Do6 KTKlL1wvxGsPxzEBwU34nBK9BHWKtHfuOA0bgL6WBbXPV2L3g7mmntZ5k6RpNyFdicl+ iJOw== X-Gm-Message-State: AOAM530Gl3O9DKNuKx3KC4GgpE6AiQQjqGMYA2LNZ+hNaKn7kuIPYzX8 C5BZA3IBY29RV5L2D0CpXNkIxw== X-Received: by 2002:a5d:5049:: with SMTP id h9mr7428369wrt.24.1621346865098; Tue, 18 May 2021 07:07:45 -0700 (PDT) Received: from localhost ([2620:10d:c093:400::5:5c4a]) by smtp.gmail.com with ESMTPSA id o1sm2686082wmc.6.2021.05.18.07.07.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 07:07:44 -0700 (PDT) Date: Tue, 18 May 2021 15:07:44 +0100 From: Chris Down To: Andy Shevchenko Cc: linux-kernel@vger.kernel.org, Petr Mladek , Jessica Yu , Sergey Senozhatsky , John Ogness , Steven Rostedt , Greg Kroah-Hartman , Johannes Weiner , Kees Cook , Rasmus Villemoes , kernel-team@fb.com Subject: Re: [PATCH v6 3/4] printk: Userspace format indexing support Message-ID: References: <05d25c65d3f5149c1e8537f74041a7a46bd489d6.1621338324.git.chris@chrisdown.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.0.7 (481f3800) (2021-05-04) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hey Andy, Thanks for the detailed feedback! All points not explicitly replied to here are acked and will be improved. :-) Andy Shevchenko writes: >> +static const char *pi_get_module_name(struct module *mod) >> +{ >> + return mod ? mod->name : "vmlinux"; > >First of all, you have several occurrences of the "vmlinux" literal. >Second, can't you get it from somewhere else? Is it even guaranteed that the >name is always the same? Hmm, I don't know if it's guaranteed, but we already have similar logic in (as one example) livepatch, which seems to suggest it's not obviously wrong: % grep -R '"vmlinux"' kernel/livepatch/ kernel/livepatch/core.c: sympos, name, objname ? objname : "vmlinux"); kernel/livepatch/core.c: bool sec_vmlinux = !strcmp(sec_objname, "vmlinux"); kernel/livepatch/core.c: sym_vmlinux = !strcmp(sym_objname, "vmlinux"); kernel/livepatch/core.c: if (strcmp(objname ? objname : "vmlinux", sec_objname)) kernel/livepatch/core.c: name = klp_is_module(obj) ? obj->name : "vmlinux"; kernel/livepatch/core.c: klp_is_module(obj) ? obj->name : "vmlinux"); kernel/livepatch/core.c: klp_is_module(obj) ? obj->name : "vmlinux"); kernel/livepatch/core.c: if (!strcmp(mod->name, "vmlinux")) { Is there another name or method you'd prefer? :-) As for the literals, are you saying that you prefer that it's symbolised as a macro or static char, or do you know of an API where this kind of name can be canonically accessed? >> +#define seq_escape_printf_format(s, src) \ >> + seq_escape_str(s, src, ESCAPE_ANY | ESCAPE_NAP | ESCAPE_APPEND, "\"\\") > >Hmm... But after your ESCAPE_SPECIAL update why " is in @only? >Not sure about back slash either. Good question! It's because ESCAPE_NAP (used to reduce scope of ESCAPE_OCTAL) will cause double quote and backslash to be ignored for quoting otherwise, even with ESCAPE_SPECIAL from ESCAPE_ANY. I touched on this briefly in the changelog for the patch adding the quote to ESCAPE_SPECIAL: From "string_helpers: Escape double quotes in escape_special": > One can of course, alternatively, use ESCAPE_APPEND with a quote in > @only, but without this patch quotes are coerced into hex or octal which > can hurt readability quite significantly. Maybe you know of a more intuitive way to deal with this? :-) >> +static int __init pi_init(void) >> +{ >> + struct dentry *dfs_root = debugfs_create_dir("printk", NULL); >> + >> + dfs_index = debugfs_create_dir("index", dfs_root); >> + pi_setup_module_notifier(); >> + pi_create_file(NULL); >> + >> + return 0; >> +} > >No __exit? (There is a corresponding call for exit) Hmm, can't printk only be built in to the kernel, so it can't be unloaded? At least it looks that way from Kconfig. Maybe I'm missing something and there's some other way that might be invoked? Thanks a lot for the feedback! :-)