Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp319794ybl; Thu, 30 Jan 2020 23:03:56 -0800 (PST) X-Google-Smtp-Source: APXvYqyQu81HqYcfxxBZDi4zu+qqLP9SeAMoesvoyd8SSpYY2V+EfgQlz1SlKqSNb1P2fels1LtJ X-Received: by 2002:a9d:7cd0:: with SMTP id r16mr6853306otn.50.1580454236243; Thu, 30 Jan 2020 23:03:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580454236; cv=none; d=google.com; s=arc-20160816; b=0FxG5E80wx0kKqV/F/sgnJbzduhjUALWWw00UeJfcTLrlZHPFLS4v9ubYF0RlEeAeq SSsibuk6uGQ3UJRh9xsQngMdQXjnPSCGg5SiYYO8cM84GFvwaiUT0+kg1j3ioMUU7pQD /bEjBpK7SJKL32IgkPYMi4gGBzangJA5Ojw/0H86pHbbf4mOoN7vu/x0XA99TX3Jk7qw o8BCh7ZEuLMLAvN3+PqWqcFxeedOwWB2lXEloP4rr/lBdrj4BF/6QjaEbxkwT+5a1jQt XsVN6KUZfmJdON+9S2wELYDyey6Pap/PNYkvd8Zua183uHyoFxhoj73XJMAKn1bHc8pV 3h4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=wOI7hqK3fz5FOatl+JgLstEmzwY5hPCxPwdC6f4htY0=; b=uZjoVJLiJqd+Ky3smZyyYNOUMiXBaSj7vSWte8yV2zZidRLdNo3pjPPHpEd6kemMLh saudyHiRYctNuDir0zPibxKY0O5yq6QsqRFCXtJxIEHiipR21ocgWoJdi+5N+2nwG6pk WXq3YNSuWtrcKuz2iNPDAjBrAPKKF2VFlYndG1pk7OPMg0pzKKHnXS7rPyDNquwOgw1j kT3ms1hkaXT/90PsUERCQXFc6lGH+IuKnuuwiWOBJo0YbcahagtQMcP9i6bAx9oPbJT3 gglFGtLjtUt5yGyeNPYZInQpi2oR1JJIoz7TPCqZYjh+Y9ZFTDtXwGTw5n48Q434IrRc qQ7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gcVYhGHF; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v14si4638890otn.293.2020.01.30.23.03.43; Thu, 30 Jan 2020 23:03:56 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=gcVYhGHF; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728097AbgAaHCm (ORCPT + 99 others); Fri, 31 Jan 2020 02:02:42 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:45462 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726127AbgAaHCm (ORCPT ); Fri, 31 Jan 2020 02:02:42 -0500 Received: by mail-pf1-f195.google.com with SMTP id 2so2820596pfg.12 for ; Thu, 30 Jan 2020 23:02:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=wOI7hqK3fz5FOatl+JgLstEmzwY5hPCxPwdC6f4htY0=; b=gcVYhGHFtpUbCqyKbhsgy051T79MxaD0OdnjtYqfqze1AvFsz1IsXJQLrWD0Gg4KOX J2DsQGRsQ6WoO3xOmJp2umB2AWLPJ5FR5KkAsAeBptRvLpxCvhvY9RKPjJCI8zskqw00 ZunZhSWNWIi9qFAqnip93r1/chopEhiogdWsuG1pCjMYTfbPF4irJTdGs1hC+qQpwGOl MWXzaWUcWmY/mJp4G/UUx/oGmcY0HMQI7ereUN7p4PQ7V15zj2M6k2/bhck2sfgBkC7S d7c2puw/9abml2Z4h87xT3hYJsSYYJa0hUBwmiHfDHwRQs4uUhg0ZT2WqI0XM2p8AqlP nV0A== 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=wOI7hqK3fz5FOatl+JgLstEmzwY5hPCxPwdC6f4htY0=; b=RHxJQo7I71q3iaxP52LkjJzMj9M8uJk+5adwWEioHAysHGJTDR9aV4njM3oXcLnE7w ZR9WUVIDbaqN7Lc+DcizgU38lympvqL+HLmCtEHsr5z8bDTi9NEh6/3TQKN4eauc5nDo g/qxuJ5v8C90EsDWpePmTwo6S8McHIcp+tJ/0QhRFd3VBgZNl1pDxvCguCloASN5pRZl VfsZ0Lhs6CycSg8x+z2WiJxgbOamCRm4gA5N3ruSexEYXwpk9+I3VlrwEVKn6r3pxkqW OHrzrToKwxoPEu+VRbdLReKZVLJEI9c4DOstRvymG5FSjYgIQxoKpiI9zfJPzHgc5VI+ ZChw== X-Gm-Message-State: APjAAAWahD37lwlMg0IzoZuhbFdj+xj6mjR7kZVGKKyQrKljyVEISSR5 6/Jg2wGvFcTUDymv0bQH4vE= X-Received: by 2002:a63:28a:: with SMTP id 132mr8654803pgc.165.1580454161600; Thu, 30 Jan 2020 23:02:41 -0800 (PST) Received: from localhost ([2401:fa00:8f:203:5bbb:c872:f2b1:f53b]) by smtp.gmail.com with ESMTPSA id gc1sm8305293pjb.20.2020.01.30.23.02.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2020 23:02:40 -0800 (PST) Date: Fri, 31 Jan 2020 16:02:37 +0900 From: Sergey Senozhatsky To: Nathan Chancellor Cc: Petr Mladek , Sergey Senozhatsky , Steven Rostedt , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: Re: [PATCH] printk: Convert a use of sprintf to snprintf in console_unlock Message-ID: <20200131070237.GB240941@google.com> References: <20200130221644.2273-1-natechancellor@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200130221644.2273-1-natechancellor@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (20/01/30 15:16), Nathan Chancellor wrote: > When CONFIG_PRINTK is disabled (e.g. when building allnoconfig), clang > warns: > > ../kernel/printk/printk.c:2416:10: warning: 'sprintf' will always > overflow; destination buffer has size 0, but format string expands to at > least 33 [-Wfortify-source] > len = sprintf(text, > ^ > 1 warning generated. > > It is not wrong; text has a zero size when CONFIG_PRINTK is disabled > because LOG_LINE_MAX and PREFIX_MAX are both zero. Change to snprintf so > that this case is explicitly handled without any risk of overflow. We probably can add a note here that for !CONFIG_PRINTK builds logbuf overflow is very unlikely. Otherwise, Reviewed-by: Sergey Senozhatsky -ss