Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3828794ioo; Wed, 25 May 2022 08:58:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7Ie4yYPBcnAvZ9qBOcD8xIdICa9CUt2ZWQbm6r0kOxdoLCt/m1WCZAcBjufUes86/Ewsr X-Received: by 2002:a17:906:58d2:b0:6fd:daa7:3a6e with SMTP id e18-20020a17090658d200b006fddaa73a6emr29740073ejs.0.1653494301247; Wed, 25 May 2022 08:58:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653494301; cv=none; d=google.com; s=arc-20160816; b=LqCuu7sWO0sIS+ZkcHMsgPvnxIiNQKGQe3u3xrmy2ZHTKIR2fAJBHueFHhxSRjuFfC sI+wDx7nqwuCq5ZJxUICrMfIpjZUJx4QKsewQUM/EWSwNJr6sdChbshgs5QQxdRi9Xoq JlxUmn7GkuD/oIBRVNoBV5sdmyr+7jd/h/rqe4VX2V7V3+8pUmPfPytQghgp9OKNdu+5 ZuGZbAJ2j391/4k5TeKJ5zA8ySpkoP+wvGWc8dt75oTgRzUT7V5uf4QDmg+NJx/TGHzv cRdWjIS1zr9txvm9CWi69FvIHDY/vvqRbRC5C+Hy+eT12/tVYqYlO3z87TstAjxp+etz VaPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=lGPxsnKdnKsfY2/ly0XOA1mv5n8j0KZZRTBIc9ftnt0=; b=dK53GS6tAx4ZSbmm8khKL8Cf013eaUAuuvSK9gCMOC7ZwYSWnIRK9NnkYC5hSfz3G8 Vkfw15+JoSjgVzPVzG1x2UPjnSsGF0Tt9mkH1PrTwlEj3e+qLkMXQLh/X6rGdT9PpGzn 7VbyJmfP42yhGrN1UCoXGzwkVn23w1f1SkItHTSadAaojAv+PAkdANP0RTTplIy/9Q9a 56G8tM4zVqpLgmOs5JouBiOJioyYMrU+vDcA4SUxhPRcrd1SOLc1vBvRcv94UWprwyVS 7ivhy6l9GS8ncQlL+RDrvRpNMeI9i/dlt47lb3l9ta8BDuXuT03DNqZ8zukDCkjjmnR5 uE+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=4MNdBYX+; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g15-20020a17090669cf00b006f3f6f1b7besi11825507ejs.640.2022.05.25.08.57.55; Wed, 25 May 2022 08:58:21 -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=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=4MNdBYX+; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234737AbiEYG20 (ORCPT + 99 others); Wed, 25 May 2022 02:28:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238669AbiEYG2Y (ORCPT ); Wed, 25 May 2022 02:28:24 -0400 Received: from mail-yb1-xb29.google.com (mail-yb1-xb29.google.com [IPv6:2607:f8b0:4864:20::b29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A33C313D70 for ; Tue, 24 May 2022 23:28:23 -0700 (PDT) Received: by mail-yb1-xb29.google.com with SMTP id v26so6306972ybd.2 for ; Tue, 24 May 2022 23:28:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lGPxsnKdnKsfY2/ly0XOA1mv5n8j0KZZRTBIc9ftnt0=; b=4MNdBYX+XgIEIqG6nn6cOEabHclXZtPvf3LN6UtsP24WXdn7mgPh7l9HU8hd2XBoDt x+yQh8ZWnHWHzrGiY+diy4pQ0hUV/Ozdoi2m2d38glFhgU3MLAcIUAx9L8iZjzZOuqz7 RsL5P250YCFBuAxpC6JsWZ762SmqcoCOtmlKyAnF32d6sZg+uZfDlczb/kaiiG2rakKf cNUPYZzj3EIYKPX/TEenSHTrFVmz6IXAwvmwssFWDbjkoPsXY8YAl3mGJge5cgaOqME6 EW9xxQPABuvCph73DOtlEe3iAjHua+1IvoT/EJWkaxPONptUUYDE+o+w8ZotdbK/k3m5 3KmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lGPxsnKdnKsfY2/ly0XOA1mv5n8j0KZZRTBIc9ftnt0=; b=bMRQF9rDLuMQ+3tfXKspEBS5lm5zpRtsKdDd+YMEBC3hetsH7n3B2V5FBKsIzGSvR5 d1WLreSL1lgm9SXYgT6pYgQkVK7I4xFJ3h1OCd/nH9o+lozFVXH+vVG5cvYgFtXCVsp2 U5tHQJsbPDWjIyRNa2mOeUJvhS4fFGBdQkTF1XOhTjm+IrBgk/I4xaeBMoLukzKNk7cJ irYcOov4PQo75/ZUHbR/RvFiCAOdESPBwUKxCPvpFUgg+LM0SsKKpKRzg/g5ulC1fFik otGQ1hgjiPeLtgI8PLZDoRSHzwIbRraNn1bWa3QUIQv1ysA+FdNQ81AZzapStcNiVVop 6O8Q== X-Gm-Message-State: AOAM533U89S/XUUTK4ae8r9arCzEWGlgJ4piL0J/J+OPJz5kke2tstvM o2yESxyqIl9ha7ONSv90qA3G339zwbulFUQO8b8/uA== X-Received: by 2002:a5b:dcd:0:b0:64e:2365:69a8 with SMTP id t13-20020a5b0dcd000000b0064e236569a8mr28474573ybr.254.1653460102896; Tue, 24 May 2022 23:28:22 -0700 (PDT) MIME-Version: 1.0 References: <20220522052624.21493-1-songmuchun@bytedance.com> In-Reply-To: From: Muchun Song Date: Wed, 25 May 2022 14:27:46 +0800 Message-ID: Subject: Re: [PATCH v2] sysctl: handle table->maxlen properly for proc_dobool To: Luis Chamberlain Cc: LKML , linux-fsdevel , Matthew Wilcox , Kees Cook , Iurii Zaikin Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Wed, May 25, 2022 at 12:20 AM Luis Chamberlain wrote: > > On Tue, May 24, 2022 at 10:30:01AM +0800, Muchun Song wrote: > > On Tue, May 24, 2022 at 1:27 AM Luis Chamberlain wrote: > > > > > > On Sun, May 22, 2022 at 01:26:24PM +0800, Muchun Song wrote: > > > > Setting ->proc_handler to proc_dobool at the same time setting ->maxlen > > > > to sizeof(int) is counter-intuitive, it is easy to make mistakes. For > > > > robustness, fix it by reimplementing proc_dobool() properly. > > > > > > > > Signed-off-by: Muchun Song > > > > Cc: Luis Chamberlain > > > > Cc: Kees Cook > > > > Cc: Iurii Zaikin > > > > --- > > > > > > Thanks for your patch Muchun! > > > > > > Does this fix an actualy issue? Because the comit log suggest so. > > > > Thanks for taking a look. > > > > I think it is an improvement not a real bug fix. > > Then please adjust the commit log accordingly. > > > When I first use > > proc_dobool in my driver, I assign sizeof(variable) to table->maxlen. > > Then I found it was wrong, it should be sizeof(int) which was > > counter-intuitive. So it is very easy to make mistakes. Should I add > > those into the commit log? > > Yes that is useful information when doing patch review as well. > Thanks. I'll update in v3.