Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp677406lqb; Wed, 29 May 2024 07:33:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVBgjUOihkUvxulFYRTTxaOM21V4/7NdJ1rgTaM5+ATTln/WL205EQt4p/iUCFiaZkqsGNPzFLP2nT+/2oD7ShlKjGNuSHAiq9H8gjW1g== X-Google-Smtp-Source: AGHT+IFdniTupMs3+JxwuZRojCOhfroI/ghQXoo8lzgGQDioFAJmddMwzlxZlS3BUEZ7e5h+kE2n X-Received: by 2002:a05:6a00:90a8:b0:6f8:b8d7:1123 with SMTP id d2e1a72fcca58-702029d689amr3678561b3a.1.1716993192423; Wed, 29 May 2024 07:33:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716993192; cv=pass; d=google.com; s=arc-20160816; b=FrKkymo8795NSbZNaNseGnOd1ifl3ULBCffv7AO0sHOvKEHOuHJx2RZ5/xIDC1Hlxr KSW5b82Lq1H23uchyarfa0TsCUI/HLYCPreKXvFIffXM3JPZLaVwPWTH5vzd31ZSylTW t+XwTbrNu3HNw0j8dh+7jQ8lqaPsfA3/sjgmTttUoWiILkxwxSN4DGLUguBHeXIK06PC sUO6XdsLBA8uQhGV94EEwOq+0HAl8VibPWttnAwQioJPHNrSl105Rr1wwkdfwvPUHvX5 7VZoRbEMwueL2V2BdwbQZBp91h2lklVB0WL7xzZ5TRJ889FZjt5WyJirDo1Xfsw0tUHl WtEw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=yhL9Q7EwnBs27v2LEV5NKZLimYfj6QTltIE7lVekQTA=; fh=7Fj4YMPkM28fIbf/Mpr3qNsdhx+RKTgABwPIiMQ5svw=; b=Wmz4JH0E7G4k9VCW+jJI/UqoI37Uh6Q+XM0Y3FsdMsfxCvnT0w738VO9iLH6Az9mtF 9TURzrfGIRu0tXsmVw1Mt+4XYdIrlwHht3/DUWTkIfFGukBC3tL5cy14SLuJ6XCHk+dI gAI3spj8a0Nq3r/sjjuVtzedj5l0MScjHznhvoW7WJ5kM+mUZkfHfgAEAE9lz/UOAGFo 59pcIhQ3w/kJaXHOtpSJuCFwvhrk14AMYO1mTSs9yWIbnIfqrQh5jeSkaE20AQ6zshLS T74I0Mc8UPH8kiMOQkhaM2uNAAf52PxEyu/Qf264ihRQG8wbus0kcDf3tnVQfitOExnn mo8g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QVPyv7hF; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-194275-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194275-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-702204f6cdcsi750951b3a.99.2024.05.29.07.33.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 07:33:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-194275-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QVPyv7hF; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-194275-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194275-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0ECA228808C for ; Wed, 29 May 2024 14:33:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6652815A4BC; Wed, 29 May 2024 14:32:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="QVPyv7hF" Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 082FE159912 for ; Wed, 29 May 2024 14:32:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716993173; cv=none; b=BobWypbRxO/XeOFGB8KbEwErKV+Mp+FH+eSC+StFwYLnAOGG1QpRzTkRMezgX0laqMjYhjNNDreBvcZZ0QeY4jQCCXpm+55j1La37aZwetkXxgu3wHkF4HWUblsEt2UTbRfERsORs8er3rqu5hM7oTv0Z7OByLbGSI6gt0rGKwo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716993173; c=relaxed/simple; bh=dVJ+EvwFT4Heb4Cx07/uQgdH1ZEbjDU3smi2K9tnUTg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jxeAsCkEfZryDhDO1xZQq6de8TXTFwwlL68kvXWwI9OBYM5q0tkdf/TzQM8Keiu43TQ7nsmAHpARz8WsDpI2llTi2a7LbMh/VTYdoTIG1Lx+T0Bhm7Sf7/vaAjszi8HvhzNcCcIE8ridRFYUESMTuWbg68uYHuDC+E2pET5CZ1Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=QVPyv7hF; arc=none smtp.client-ip=209.85.218.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a63036f2daaso269240166b.1 for ; Wed, 29 May 2024 07:32:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716993170; x=1717597970; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=yhL9Q7EwnBs27v2LEV5NKZLimYfj6QTltIE7lVekQTA=; b=QVPyv7hFYfdvAge+P1PhDzAXHKd+67lYDtTRoHHNdcF+875YFuFvobBl/b5gEBPuP6 RnS3xscoIzaN1GpPMq0ffn5DWQO62n2Uo46UY5cMb1wnPzcvohesmZLzud1bbHl0Bs9z fyN+0uK78T5qUfFyUaxUcKjY77cYlTvECJQcRJk7RuQIEBY29gRhBGgHEBI9ZhjwGnrk lJuLVktf1QXIWcKFxBXtLYEJn6H8DbwVYj8GMcE4lhPWOQpOlVy5v5NHGEsbiuDXYZYq qtdjGb4YDv0I7guJFg4eJmLyBx28JqfNwMVd2CrdXDcn3uMV+KXzZFyUjxM5oLucxaeM aQ/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716993170; x=1717597970; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=yhL9Q7EwnBs27v2LEV5NKZLimYfj6QTltIE7lVekQTA=; b=LgNMTNim3vBONO7D0OpCd0bCV9Si/diQyNQa4ccafPoEyO75JyngCJxbzjnUwbno36 D+iYFWrj95DCNplneP5lhxpA0NetbAM28xqGC0bEIa0a/5T5qADWVYUG0raYCuDxcpIM beDXpzw3Ryae1q5q9ayKJV6PkrDmPR/OMPnS+VD3gaLD7/06gkbulNnWPRM5lR3rFXVj Q811waEEiDbIqn6lrINBQhV+4GGWMPcmN5GkBPzJoRpolZWDXw81tWu6f4t2a3OHD3fm 0rxLhvgkug01RE75Ymb9eKCuAKy/SjAFJfdCHbbWGxry1CEp5Hn2ChbLojCIoNiuZmpI OFeA== X-Forwarded-Encrypted: i=1; AJvYcCWKXtjYljL80bkSgsDreODQ+B14y9v0CtbLzIikQsyj7TYrjCPT1BK7N+tFHeb8d9Bpj3mwpGt7c8gEL+VTPxNX4evMBPkhT5fT/sBt X-Gm-Message-State: AOJu0Yxg/Bgy/3Q2n55f//6mbcLs+qroWkeUC8HIOQPLe/NN//utxAc2 fgCpzNc7vE58Ut/06fQWFhVrl8z96n0iU/fAVWYrdlGVZahO5X6WxBhK0Tm7d3I= X-Received: by 2002:a17:906:379a:b0:a63:41d4:ca86 with SMTP id a640c23a62f3a-a6341d4cbe1mr320147166b.24.1716993170311; Wed, 29 May 2024 07:32:50 -0700 (PDT) Received: from localhost ([102.222.70.76]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6590d02e53sm40275466b.119.2024.05.29.07.32.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 07:32:50 -0700 (PDT) Date: Wed, 29 May 2024 17:32:46 +0300 From: Dan Carpenter To: Bartosz Golaszewski Cc: Kent Gibson , Linus Walleij , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: Re: [PATCH v7] gpio: virtuser: new virtual driver Message-ID: References: <20240527144054.155503-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240527144054.155503-1-brgl@bgdev.pl> On Mon, May 27, 2024 at 04:40:54PM +0200, Bartosz Golaszewski wrote: > +static ssize_t > +gpio_virtuser_sysfs_consumer_store(struct device *dev, > + struct device_attribute *attr, > + const char *buf, size_t len) > +{ > + struct gpio_virtuser_line_data *data = to_gpio_virtuser_data(attr); > + int ret; > + > + if (strlen(buf) > GPIO_CONSUMER_NAME_MAX_LEN) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This is off by one. strlen() doesn't count the NUL terminator. > + return -EINVAL; > + > + guard(mutex)(&data->consumer_lock); > + > + ret = gpiod_set_consumer_name(data->desc, buf); > + if (ret) > + return ret; > + > + sprintf(data->consumer, buf); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ It results in a buffer overflow here. > + > + return len; > +} regards, dan carpenter