Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752579AbdLLQCy (ORCPT ); Tue, 12 Dec 2017 11:02:54 -0500 Received: from smtprelay0005.hostedemail.com ([216.40.44.5]:33729 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751999AbdLLQCv (ORCPT ); Tue, 12 Dec 2017 11:02:51 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:41:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:1801:2393:2553:2559:2562:2828:2895:3138:3139:3140:3141:3142:3355:3622:3865:3866:3867:3868:3870:3871:3872:3874:4321:4605:5007:6119:7903:10004:10226:10400:10848:10967:11026:11232:11658:11914:12295:12740:12760:12895:13439:14096:14097:14181:14659:14721:21080:21433:21434:21627:30003:30054:30070:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: view40_52d507437795a X-Filterd-Recvd-Size: 4089 Message-ID: <1513094567.3036.54.camel@perches.com> Subject: Re: [PATCH] tuners: tda8290: reduce stack usage with kasan From: Joe Perches To: Arnd Bergmann , Mauro Carvalho Chehab Cc: Michael Ira Krufky , linux-media , LKML Date: Tue, 12 Dec 2017 08:02:47 -0800 In-Reply-To: References: <20171211120612.3775893-1-arnd@arndb.de> <1513020868.3036.0.camel@perches.com> <1513078952.3036.36.camel@perches.com> <20171212104530.46ac4ffe@vento.lan> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.26.1-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2817 Lines: 78 On Tue, 2017-12-12 at 15:21 +0100, Arnd Bergmann wrote: > On Tue, Dec 12, 2017 at 1:45 PM, Mauro Carvalho Chehab > wrote: > > Em Tue, 12 Dec 2017 03:42:32 -0800 > > Joe Perches escreveu: > > > > > > I actually thought about marking them 'const' here before sending > > > > (without noticing the changelog text) and then ran into what must > > > > have led me to drop the 'const' originally: tuner_i2c_xfer_send() > > > > takes a non-const pointer. This can be fixed but it requires > > > > an ugly cast: > > > > > > Casting away const is always a horrible hack. > > > > > > Until it could be changed, my preference would > > > be to update the changelog and perhaps add to > > > the changelog the reason why it can not be const > > > as detailed below. > > > > > > ie: xfer_send and xfer_xend_recv both take a > > > non-const unsigned char * > > Ok. > > > Perhaps, on a separate changeset, we could change I2C routines to > > accept const unsigned char pointers. This is unrelated to tda8290 > > KASAN fixes. So, it should go via I2C tree, and, once accepted > > there, we can change V4L2 drivers (and other drivers) accordingly. > > I don't see how that would work unfortunately. i2c_msg contains > a pointer to the data, and that is used for both input and output, > including arrays like > > struct i2c_msg msgs[] = { > { > .addr = dvo->slave_addr, > .flags = 0, > .len = 1, > .buf = &addr, > }, > { > .addr = dvo->slave_addr, > .flags = I2C_M_RD, > .len = 1, > .buf = val, > } > }; > > that have one constant output pointer and one non-constant > input pointer. We could add an anonymous union for 'buf' > to make that two separate pointers, but that's barely any > better than the cast, and it would break the named initializers > in the example above, at least on older compilers. Adding > a second pointer to i2c_msg would add a bit of bloat and > also require tree-wide changes or ugly hacks. Perhaps add something like struct i2c_msg_set { __u16 addr; /* slave address */ __u16 flags; __u16 len; /* msg length */ const __u8 *buf; /* pointer to read-only msg data */ }; struct i2c_msg_get { __u16 addr; /* slave address */ __u16 flags; __u16 len; /* msg length */ __u8 *buf; /* pointer to writeable msg data */ }; to the uapi include and use that where appropriate but where a write then read is done via a single i2c_msg array, it's not really feasible either. Probably better to avoid any churn and just mark all these as static rather than static const.