From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965427AbdJRMlb (ORCPT ); Wed, 18 Oct 2017 08:41:31 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:47871 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934046AbdJRMla (ORCPT ); Wed, 18 Oct 2017 08:41:30 -0400 X-Google-Smtp-Source: ABhQp+SSGslYzAqky+LeQZluYe56PuDZwjHbOeOAXzL77FkID+DBAOHS85eGxgh9ZS4nXlM39A6a1Q== Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: [RFC PATCH 0/3] Introduce kernel small arrays (KSA) From: Ilya Matveychikov In-Reply-To: <1507130554.26687.8.camel@codethink.co.uk> Date: Wed, 18 Oct 2017 16:41:26 +0400 Cc: linux-kernel@vger.kernel.org Message-Id: References: <1507130554.26687.8.camel@codethink.co.uk> To: Ben Hutchings X-Mailer: Apple Mail (2.3273) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id v9ICfakP017336 > On Oct 4, 2017, at 7:22 PM, Ben Hutchings wrote: > > On Tue, 2017-09-19 at 12:30 +0400, Ilya Matveychikov wrote: >> Hi guys, >> >> Please review the approach of using small fixed-sized arrays to improve >> parsing of values like get_options() does. >> >> This comes to me after fixing an overflow in get_options(). See the thread >> for details: https://lkml.org/lkml/2017/5/22/581 >> >> If the approach is OK I’ll suggest to replace all of get_options() calls >> to ksa_parse_ints() and remove get_options() at all. > > You didn't cc the patches to me, and I can't find patch 3/3 at all. Thanks for you answer. I posted them on list, except the last one as what I wanted is to get the feedback first. I CC’d you as you found a problem with my patch for get_options() before (read out of bounds). > > don't think the KSA() macro should be casting its argument. Where the > cast is necessary, it ought to be explicit in the caller. KSA(x) it’s just a simple way to cast from custom-defined small array to generic one. Do you think that it’s better to use explicit casting: ksa_parse_foo(..., (struct ksmall_array *)&my_custom_ksa) Instead of: ksa_parse_foo(..., KSA(&my_custom_ksa)) Not sure... > > Similarly I think the BUILD_BUG_ON() in ksa_build_check() doesn't belong > there, but in whichever caller of ksa_parse_ints() requires struct > ksmall_array to have the same layout as a simple array of unsigned int. Not sure that I understand your point. The purpose of ksa_build_check() as I wrote it is to to do compile-time check for sizeof(struct ksmall_array) to fit sizeof(unsigned int). Note that ksmall_array{} is the header for any possible “small” array build by using the KSA_DECLARE() macro.