Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1150343pxk; Fri, 18 Sep 2020 05:16:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUBVXRYAuP+h638s7TT2t1++ZIWabwzAp7xn5wPHtTjJeNEHuIXog3l7W5IVS+arBmBKf6 X-Received: by 2002:a17:907:2141:: with SMTP id rk1mr35368813ejb.256.1600431411514; Fri, 18 Sep 2020 05:16:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600431411; cv=none; d=google.com; s=arc-20160816; b=f2h5XN5TZXrfi5g/gO8HZUdN2rS02ex8Xh3f9o7Etb6pQYr39YDfsLjpKjMsCv0OS+ u/IuerrvxrFVzWBSho+0Vg9wsXlDjwIY98kRNrhn1meWW4qkzook77VP2kecuMI1vaD8 jR9jHHcBigI+u3KSX2ghxInN+OhH1mXIbQqGA+uJDJGAAbYxkIFI6tmRzKeUufikc50a ek/0U8sjkNYOjVNYiaOHlYgKDc69ZzkFsQv3+HZ1c0mnMszNKSA8FfgIKhQrAsRNVbuU tdWRtFRdyeEvpXU7/2aO/eQV4V6mDsLz5HwYc3+4pyhsXcUYz+rnZN1V6aXZHWz54Mej D0Ag== 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=t/aXhqWiIrrJX5NNhaAEYok++HqGAIDlzevY0FDzWn0=; b=ggq8YEOG7qqKg1WArBPzYLA8E9vUPoArIkObBvaprNNdYH5nYxVXy6pzxNLPCF/Ap4 0YjlkAdcYdDyA0UDEFoyYUKxjfzxxyPFxeRHHcVQ/HlMKQdxEiOijN9b3RMoxja9d+1b FMXFaA9uOWkWQi51xomA6uhBcRk7jfbBOpfuFEajE2cguz5uaFn8z7QzGKwnBfmZE1OR /+k1qSdk7Shz1D73Liqpgm9s2D1yL7gKEEWlrV3dub1RasAVbkB13IGgPETgEjRXEaCM N1K7mAPxdt8WIh4J/UxsvS3CjrX583Dyx6/e+rLNOW6MzwcxsijnwFq8n/R9kXrETXBR P+XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=YQ6X4KEb; 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=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d11si1941701edu.492.2020.09.18.05.16.28; Fri, 18 Sep 2020 05:16:51 -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=@suse.com header.s=susede1 header.b=YQ6X4KEb; 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=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726469AbgIRMNo (ORCPT + 99 others); Fri, 18 Sep 2020 08:13:44 -0400 Received: from mx2.suse.de ([195.135.220.15]:52502 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726280AbgIRMNo (ORCPT ); Fri, 18 Sep 2020 08:13:44 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1600431223; 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: in-reply-to:in-reply-to:references:references; bh=t/aXhqWiIrrJX5NNhaAEYok++HqGAIDlzevY0FDzWn0=; b=YQ6X4KEbT5IFK6oEPNIcqG9nYm38yc4TyGjl+D1SfHpZ1VCmLeAyOVEhqC2vanA9hk8IBY Umgkdrh7T9+nrSgUF8ll6AiN7lpLO//3A+VRxBSPnyQItZhg0kmoeZ+OzS2cnnb5N0pnY+ 6lJhEcZZHxV4SUipyItL/YPl/+MH6ZY= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2AEF5AC2F; Fri, 18 Sep 2020 12:14:17 +0000 (UTC) Date: Fri, 18 Sep 2020 14:13:42 +0200 From: Petr Mladek To: Rasmus Villemoes Cc: John Ogness , Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , Greg Kroah-Hartman , Thomas Gleixner , kexec@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH printk 2/3] printk: move dictionary keys to dev_printk_info Message-ID: <20200918121342.GD14605@alley> References: <20200917131644.25838-1-john.ogness@linutronix.de> <20200917131644.25838-3-john.ogness@linutronix.de> <316cf147-0ae2-1c88-7375-07aedc58bd15@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <316cf147-0ae2-1c88-7375-07aedc58bd15@rasmusvillemoes.dk> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 2020-09-18 08:16:37, Rasmus Villemoes wrote: > On 17/09/2020 15.16, John Ogness wrote: > > > if (dev->class) > > subsys = dev->class->name; > > else if (dev->bus) > > subsys = dev->bus->name; > > else > > - return 0; > > + return; > > > > - pos += snprintf(hdr + pos, hdrlen - pos, "SUBSYSTEM=%s", subsys); > > - if (pos >= hdrlen) > > - goto overflow; > > + snprintf(dev_info->subsystem, sizeof(dev_info->subsystem), subsys); > > It's unlikely that subsys would contain a %, but this will be yet > another place to spend brain cycles ignoring if doing static analysis. > So can we not do this. Either of strXcpy() for X=s,l will do the same > thing, and likely faster. Good point! Better be on the safe size in a generic printk() API. Well, I am afraid that this would be only small drop in a huge lake. class->name and bus->name seems to be passed to %s in so many *print*() calls all over the kernel code. IMHO, this is not the right place to prevent the problem. Dangerous names must be prevented when a new bus, class, device is added. Best Rergards, Petr