Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3783814pxb; Sun, 24 Oct 2021 10:59:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtr0gUjppacUUeX1+Bb0IXBtynWdiIhIvrQsCIkJxKO+uapgHq7IkHs2j+T29MhSL6XmZB X-Received: by 2002:a17:90a:39c5:: with SMTP id k5mr30069301pjf.211.1635098344400; Sun, 24 Oct 2021 10:59:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635098344; cv=none; d=google.com; s=arc-20160816; b=AFPWEWUV3C60GMm2xelIHbksS9oxpDsdLD8ha8iZVbNG+wRup8YutQEo6HEKWl+yV7 UuLZXqMROIwCAlQ9dHhn5KlB9ubiBLiQkqZWzNV+nqor4yEESjv9HDcxCNEGH386wHtI gpaqcGxXjII9xqYhO0FIDxg+Ib1NEc3YB0tejYmN05rapaaBfou7TiBuxBHvfS5hJ55J Uq7kwvGXmVU9IhTSxMxYvof/F4KxCcwnPgIr5BnxTPneRz2zaVCZPaN71DsHRBq6DPlU YM97X+SentxXrDDCTtm/2hQ6qD+gk0R9/5/InGvJt1AQFmkpVPNgkIMjn1dkAlTNd2JX d+dg== 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=1owrIlrp7QuBS7qUG1k8fP6sKZZoIWNREotivRjTego=; b=iuX2AhhZWtmIdqMa+kowpBwl0NlNG4GwbbQGD+4pMSvT2cdFNcQ61YAUnyxVOykLtR I+0XZ2bdTVh8JJ58s+L4RkNwSEZG5Lq9dPMXZgQPjl38KtWRho4+B55yKosT7VbuD64y Ym4HzK3wT2Aw+qqV40uxSgu54cBp78oSHGOfdMJGln6f58QvQV69jX8Q/d8puTsPK5kj sxuqU7CtFiWwGgzH6sNIiaJvjBK7YAOriN2WsVt2xa6glbajGc6yvzCjbwgnyTCe4IK4 F1h+ceQNmvdJ6pPwAXeeR8RKgkhRUIUxMNJ/ZkcERTaBHUKNMALiFt9Nu6fw6mZ0xOK1 gOTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=tDdrpGRD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 69si6889708pfx.244.2021.10.24.10.58.50; Sun, 24 Oct 2021 10:59:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=tDdrpGRD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231213AbhJXR7n (ORCPT + 99 others); Sun, 24 Oct 2021 13:59:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbhJXR7n (ORCPT ); Sun, 24 Oct 2021 13:59:43 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1643BC061745; Sun, 24 Oct 2021 10:57:22 -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=1owrIlrp7QuBS7qUG1k8fP6sKZZoIWNREotivRjTego=; b=tDdrpGRDcR2fZMb6A1NZfP2lzA 9nUukj1JE/B7h5Fhe7f9FPnNmROgMH/50L+iNfpN0ENPPMv245cfAKIIuEcVly86Dzt9TGGxEwEeh kJ+Jr6kEiAe3XTzHDsL5QAhSzUARKITsL9iR8fpil8ouiG9CgB2c+5qJ028+rhlz6klMQqnkBnKWk OtaFZKmJnx2TZRTTU9W1gUOFkXN0TEBY3aQU5xMV7IE0nsdozwtk//IX0qggMSYc0ZaB8h1u8H+BZ pYQtGH7xbBl7wabKs0BGUp0MBxQ1Uuypt3rovQANDhy7wIPm5sx1oZJL4WoFKwcVEBJZ8RjWIkZny 2IJCQhRw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mehiD-00FWjz-AL; Sun, 24 Oct 2021 17:55:52 +0000 Date: Sun, 24 Oct 2021 18:55:13 +0100 From: Matthew Wilcox To: Len Baker Cc: "Gustavo A. R. Silva" , Kees Cook , Luis Chamberlain , Iurii Zaikin , linux-hardening@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2][next] sysctl: Avoid open coded arithmetic in memory allocator functions Message-ID: References: <20211023105414.7316-1-len.baker@gmx.com> <20211024091328.GA2912@titan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211024091328.GA2912@titan> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Oct 24, 2021 at 11:13:28AM +0200, Len Baker wrote: > I think it is better to be defensive. IMHO I believe that if the > struct_size() helper could be used in this patch, it would be more > easy to ACK. But it is not possible due to the complex memory > layouts. I think it's better for code to be understandable. Your patch makes the code less readable in the name of "security", which is a poor justification. > However, there are a lot of code in the kernel that uses the > struct_size() helper for memory allocator arguments where we know > that it don't overflow. For example: Well, yes. That's because struct_size() actually makes code more readable as well as more secure. > As a last point I would like to know the opinion of Kees and > Gustavo since they are also working on this task. > > Kees and Gustavo, what do you think? You might want to check who was co-author on 610b15c50e86 before discarding my opinion.