Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp904236ioo; Sat, 21 May 2022 19:27:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzD8q0Fht9vH3DJ6AdC0lokUKSeZ5OZ51y8tE3/0/aMu1I7omA1cayMMWFUUCLekSxViSC X-Received: by 2002:a05:6a02:117:b0:3fa:de2:357a with SMTP id bg23-20020a056a02011700b003fa0de2357amr2946074pgb.169.1653186470528; Sat, 21 May 2022 19:27:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653186470; cv=none; d=google.com; s=arc-20160816; b=ufrDOJpS/34HwKNpixJT3hRQKCmliTpJdgSxCEIarUsczz6TiejElF0j6FoBm5Py56 2m/Hzcb/S906O8U+GpB10LWLTqpxL3yh5zHfDybVjA/fZdWBXOvbhH8y1T+J0i+w2dAU jLfTpS2s4YE+EfWJYRaKTSM9xjmMjex85atrUO1ORTTtd2u+/8+jIKJ6mG7D7UiMWwZV eXV8d+mJEnlMoBvC5NHHVuVTjXbsX7AEai0acp+5jdaI5XCfEYUnOohODu1tDEH2i8UD giK5cXthKPtAA17a55keQb0GuNDzgRIBEHybz+MJBE6Om3YWXo9/hKzKCcAx1oN+X3fk AX0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=vUv8v61VHIxh8esWamo0UaDA5N+0XE9YmKiSe8EzIBI=; b=Rh+nMfR7xeW6/aXjTDLCwGPLC5dLlS0eoeoy3rynAqNwzMObqXhg+0/YiREipYeLOQ bz/AkfoTbAX4hwFnYJkvi57RfoTy/EhxlOm2RoSzzdpQKJpFDbHC6mpOAzugbnDHDcyW T//U7ngGdeQYKB3r7MxGe80bYTyHBs4JRC9YJHOfUJld2yYtLAyo+5gfOvmtso8Hblc+ hviZtf0WlNeIWJwI3YwBmsMZ7S+EOMh0isPr21kwXnkTwkoNHI9bBK/yG3RKXVrJb5iM qEDivFOZHpyeDoapyJVNgDSdPmV9ZIqNTuOwKmKo88Hdgk4FTsIsL2wS27ujI4AuVmuP RogQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=V2Fl3DlO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 203-20020a6301d4000000b003db8bb89386si5306049pgb.36.2022.05.21.19.27.34; Sat, 21 May 2022 19:27:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=V2Fl3DlO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238490AbiESNJJ (ORCPT + 99 others); Thu, 19 May 2022 09:09:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238407AbiESNJG (ORCPT ); Thu, 19 May 2022 09:09:06 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8809BCE88; Thu, 19 May 2022 06:09:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=vUv8v61VHIxh8esWamo0UaDA5N+0XE9YmKiSe8EzIBI=; b=V2Fl3DlO7O+BQYAReJ1eydhaQX OE3S7WTEY2Qzsd0CCiqASt2DNhWsiYn3JSj27dYyFgp1En5pWHKV3jxjnc7y6Pl4jEPpChLx5s3in lf6oKRoy4hMI3Y1waomzUbgWqbZrzDMj9nZ+HeMRIpleGjCPo3Jvo73q4Qkb8PJjdRyVbQFecCxHq vFNthfMQvap+t+zNwI0XLnVnZSjeynAVR1V5y0j4DAOsBGQKMcMxTsBMF5QmyjMwzy5Wj81Hmo6xJ PFZxOqF1zUYeP/7/KA4ZuCnkw1Tp0huv4AXmrvF0cLYLL2DzmiMnrEC+Dw6Zl+L5ibdoQwY8erRTz D1p71MAA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrftl-00Ck60-Qd; Thu, 19 May 2022 13:09:01 +0000 Date: Thu, 19 May 2022 14:09:01 +0100 From: Matthew Wilcox To: Muchun Song Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, duanxiongchun@bytedance.com, smuchun@gmail.com, Luis Chamberlain , Kees Cook , Iurii Zaikin Subject: Re: [PATCH] sysctl: handle table->maxlen properly for proc_dobool Message-ID: References: <20220519125505.92400-1-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220519125505.92400-1-songmuchun@bytedance.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 19, 2022 at 08:55:05PM +0800, Muchun Song wrote: > @@ -428,6 +428,8 @@ static int do_proc_dobool_conv(bool *negp, unsigned long *lvalp, > int write, void *data) > { > if (write) { > + if (*negp || (*lvalp != 0 && *lvalp != 1)) > + return -EINVAL; > *(bool *)valp = *lvalp; > } else { > int val = *(bool *)valp; Is this the right approach? Or should we do as C does and interpret writing non-zero as true? ie: *(bool *)valp = (bool)*lvalp; (is that cast needed? It wouldn't be if it were an int, but bool is a bit weird)