From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,T_DKIMWL_WL_HIGH autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50075C28CC5 for ; Sat, 8 Jun 2019 12:55:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1E0F12168B for ; Sat, 8 Jun 2019 12:55:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559998536; bh=p2NCf0jMssirxVmY432skP1dkZI53iZ0AVyuUW1pQ9g=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-ID:From; b=eBQ9DO6Rlvf9RhJpLiKci+DCt1DoqnwnGESMhf3iHA+r6RM2Wm9KwqAWwGOturZP9 auylNg1GWnptuPF9Wd3ciXne45+XS6lsKGtSUb+B7HO5GVrWqn+bY2I+XUjLpiHyrl SjVdvLt9L3mPgjMVsoGJ9DBr55FrJgeNec4BJK3U= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726984AbfFHMzf (ORCPT ); Sat, 8 Jun 2019 08:55:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:44170 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726976AbfFHMzf (ORCPT ); Sat, 8 Jun 2019 08:55:35 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2E9A320693; Sat, 8 Jun 2019 12:55:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559998534; bh=p2NCf0jMssirxVmY432skP1dkZI53iZ0AVyuUW1pQ9g=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=mBmZZH2wSMUJkshP96rmxOVlLesKh2PKZ6cNWzVtGrUxcO4rMHyzuY/5V/sYAnswZ PutMmwsi2zGnF1u5pn/yXCla0FyQyjUq032DcCoavOireesd2LYC77CrDSdZgXEHQA LsVo/g4TK/RhLx5RafByQpTF3JJPK0iwoszAdMBs= Date: Sat, 8 Jun 2019 13:55:29 +0100 From: Jonathan Cameron To: "Ardelean, Alexandru" Cc: "linux-iio@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "knaack.h@gmx.de" , "92siuyang@gmail.com" <92siuyang@gmail.com>, "pmeerw@pmeerw.net" , "lars@metafoo.de" Subject: Re: [PATCH] iio:core: Fix bug in length of event info_mask and catch unhandled bits set in masks. Message-ID: <20190608135529.4d5fb4ef@archlinux> In-Reply-To: References: <1559652000-18333-1-git-send-email-92siuyang@gmail.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org On Thu, 6 Jun 2019 08:59:10 +0000 "Ardelean, Alexandru" wrote: > On Tue, 2019-06-04 at 20:40 +0800, Young Xiao wrote: > > [External] > > > > > > The incorrect limit for the for_each_set_bit loop was noticed whilst fixing > > this other case. Note that as we only have 3 possible entries a the moment > > and the value was set to 4, the bug would not have any effect currently. > > It will bite fairly soon though, so best fix it now. > > > > See commit ef4b4856593f ("iio:core: Fix bug in length of event info_mask and > > catch unhandled bits set in masks.") for details. > > > > Signed-off-by: Young Xiao <92siuyang@gmail.com> > > Reviewed-by: Alexandru Ardelean > > Thanks for this patch. > This fix is validated also by the fact that iio_device_add_info_mask_type() has this check on the same iteration. I don't think it is technically a bug, as the higher bits should never be set. Still it is a sensible bit of hardening so applied to the togreg branch of iio.git and pushed out as testing. Thanks Jonathan > > > > --- > > drivers/iio/industrialio-core.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c > > index f5a4581..dd8873a 100644 > > --- a/drivers/iio/industrialio-core.c > > +++ b/drivers/iio/industrialio-core.c > > @@ -1107,6 +1107,8 @@ static int iio_device_add_info_mask_type_avail(struct iio_dev *indio_dev, > > char *avail_postfix; > > > > for_each_set_bit(i, infomask, sizeof(*infomask) * 8) { > > + if (i >= ARRAY_SIZE(iio_chan_info_postfix)) > > + return -EINVAL; > > avail_postfix = kasprintf(GFP_KERNEL, > > "%s_available", > > iio_chan_info_postfix[i]); > > -- > > 2.7.4 > >