From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C4EE4C7EE2E for ; Tue, 30 May 2023 08:07:11 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4QVlNt0fFkz3f6g for ; Tue, 30 May 2023 18:07:10 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=Ki27RLJO; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=suse.com (client-ip=2001:67c:2178:6::1c; helo=smtp-out1.suse.de; envelope-from=pmladek@suse.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=Ki27RLJO; dkim-atps=neutral Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4QVlMw4jKKz3cD5 for ; Tue, 30 May 2023 18:06:19 +1000 (AEST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 840A5219D0; Tue, 30 May 2023 08:06:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1685433969; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ukbl4q0oH8kV5ZgAOr0o4FI9d9WKzL+MxA+Kz6z5tX8=; b=Ki27RLJOVorsjFnZmsstxVVQLhIFGev9cVJFWAktH3fgZ0qOHDJ9BvIxzHbCJQy82azP4J ZU8IGGZx7BvXTz+b986cSjh9v5EdcOPRMy3+dezyb5lUdXdAsFq0U/0oz3Tipcf7TG2jIN R8qZHj8zF2i2u7kdJP0/H2YRf/vncdY= Received: from suse.cz (unknown [10.100.201.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 237672C141; Tue, 30 May 2023 08:06:08 +0000 (UTC) Date: Tue, 30 May 2023 10:06:07 +0200 From: Petr Mladek To: Miguel Ojeda Subject: Re: [PATCH 1/1] arch:hexagon/powerpc: use KSYM_NAME_LEN in array size Message-ID: References: <20230529052821.58175-1-maninder1.s@samsung.com> <20230529105707epcms5p1418eac680ebe1736196706b0db80dd39@epcms5p1> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "nathanl@linux.ibm.com" , "bcain@quicinc.com" , Wedson Almeida Filho , "keescook@chromium.org" , "gary@garyguo.net" , Onkarnath , "ustavoars@kernel.org" , "npiggin@gmail.com" , "linux-kernel@vger.kernel.org" , Steven Rostedt , "ojeda@kernel.org" , Masami Hiramatsu , "alex.gaynor@gmail.com" , "linux-hexagon@vger.kernel.org" , maninder1.s@samsung.com, "linuxppc-dev@lists.ozlabs.org" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Mon 2023-05-29 16:50:45, Miguel Ojeda wrote: > On Mon, May 29, 2023 at 1:08 PM Maninder Singh wrote: > > > > I Will add co-developed-by` tag. > > because this change was identified while we were working on kallsyms some time back. > > https://lore.kernel.org/lkml/YonTOL4zC4CytVrn@infradead.org/t/ > > > > this patch set is pending and we will start working on that again, so i thought better > > to send bugfix first. > > Sounds good to me! > > (Fixed Wedson's email address) > > > Yes, I think second buffer was not related to kallsyms, so I have not touched that. > > Kees: what is the current stance on `[static N]` parameters? Something like: > > const char *kallsyms_lookup(unsigned long addr, > unsigned long *symbolsize, > unsigned long *offset, > - char **modname, char *namebuf); > + char **modname, char namebuf[static > KSYM_NAME_LEN]); > > makes the compiler complain about cases like these (even if trivial): > > arch/powerpc/xmon/xmon.c:1711:10: error: array argument is too small; > contains 128 elements, callee requires at least 512 > [-Werror,-Warray-bounds] > name = kallsyms_lookup(pc, &size, &offset, NULL, tmpstr); > ^ ~~~~~~ > ./include/linux/kallsyms.h:86:29: note: callee declares array > parameter as static here > char **modname, char namebuf[static KSYM_NAME_LEN]); > ^ ~~~~~~~~~~~~~~~~~~~~~~ > > But I only see 2 files in the kernel using `[static N]` (from 2020 and > 2021). Should something else be used instead (e.g. `__counted_by`), > even if constexpr-sized?. > > Also, I went through the other callers to `kallsyms_lookup` to see > other issues -- one I am not sure about is `fetch_store_symstring` in > `kernel/trace/trace_probe_tmpl.h`. Steven/Masami: is that "with max > length" in the function docs enough? Is it 0xffff? The best solution would be to pass the buffer size as an extra parameter. Especially when some code passes buffers that are allocated/reserved dynamically. Sigh, I am not sure how many changes it would require in kallsyms API and all the callers. But it would be really appreciated, IMHO. Best Regards, Petr