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 X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6904C433E7 for ; Wed, 14 Oct 2020 09:09:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 64EB020BED for ; Wed, 14 Oct 2020 09:09:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="KS6Legqv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729067AbgJNJJl (ORCPT ); Wed, 14 Oct 2020 05:09:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728044AbgJNJJh (ORCPT ); Wed, 14 Oct 2020 05:09:37 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 399F7C051105; Tue, 13 Oct 2020 23:40:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:To:Subject:Sender: Reply-To:Cc:Content-ID:Content-Description; bh=xUnuNzpryiSejko6+sY87CqK2i6+keSsRxr2GtYeLOk=; b=KS6Legqv6hpLpdcGkeH0ecCl3M QdwmltajTxpqPYEw6TCitQPifvqni9dgV47MAvRTowbErk4RZo6tVWG3R2Bp9R3aDkYYi46PVQyfk l0FSw3Glzhr8C33Z0jbUE209psECR1Qk0wdeKmbGX/iTR5BgIZUTPlqBNt4IFAHc89xHxt4z/qI7+ vmtg3zeLzHXXP5kBqQ9lgBXV52nxTMCVYumgP/T3Ii/t4pnReOhkOuWMCIQo9FJvKQmyOyf041TIA BvIaWj/OyWFOlB+uI1AZI2jHTYCi0hk6v2SkN6GUvFRx8+zG6PA8mNNymGR1SKPe2LvxlS3dLEEL5 j0ak+NCQ==; Received: from [2601:1c0:6280:3f0::9850] (helo=dragon.site) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kSaSe-0008EV-BP; Wed, 14 Oct 2020 06:40:32 +0000 Subject: Re: [RFC] openprom: Fix 'opiocnextprop'; ensure integer conversions; use string size To: Michael Witten , sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org References: From: Randy Dunlap Message-ID: Date: Tue, 13 Oct 2020 23:40:28 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 9/4/20 12:40 PM, Michael Witten wrote: > The following patch improves the quality and correctness of the openprom code. > > > --8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<-- > > --- > arch/sparc/include/asm/prom.h | 2 +- > arch/sparc/kernel/prom_common.c | 14 +-- > drivers/sbus/char/openprom.c | 263 ++++++++++++++++++++++++++++------------ > 3 files changed, 194 insertions(+), 85 deletions(-) > > diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c > index 30b9751aad30..9bc2877aa09a 100644 > --- a/drivers/sbus/char/openprom.c > +++ b/drivers/sbus/char/openprom.c > /* If the bufsize is too large, just limit it. > * Fix from Jason Rappleye. > */ The sparc cross-compiler that I am using does not like to see type casting in preprocessor lines. SIZE_MAX is #defined as (~(size_t)0) and for the #if line below, > + #if OPROMMAXPARAM > SIZE_MAX/2 > + if (bufsize > SIZE_MAX/2) > + return -EFAULT; > + #endif gcc (cpp) says: In file included from ../drivers/sbus/char/openprom.c:19: ../include/linux/limits.h:9:21: warning: "size_t" is not defined, evaluates to 0 [-Wundef] 9 | #define SIZE_MAX (~(size_t)0) | ^~~~~~ ../drivers/sbus/char/openprom.c:95:22: note: in expansion of macro 'SIZE_MAX' 95 | #if OPROMMAXPARAM > SIZE_MAX/2 | ^~~~~~~~ ../include/linux/limits.h:9:28: error: missing binary operator before token "0" 9 | #define SIZE_MAX (~(size_t)0) | ^ ../drivers/sbus/char/openprom.c:95:22: note: in expansion of macro 'SIZE_MAX' 95 | #if OPROMMAXPARAM > SIZE_MAX/2 | ^~~~~~~~ causing a build error. -- ~Randy