Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1185220pxb; Wed, 10 Feb 2021 02:08:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+VCGQ3kLyzafjFuVq2SITqSm92IwVbc0TsD8hpBxZ7GuR4w4ad7ZCOT4plgJTWohNt87g X-Received: by 2002:a17:906:ad9:: with SMTP id z25mr2165768ejf.513.1612951696915; Wed, 10 Feb 2021 02:08:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612951696; cv=none; d=google.com; s=arc-20160816; b=LrThet3N5CiM2Hjrrsp82cOpgnpTwInB2wbRNMhMysorNYFHawqXEGaTFO8vs2iups 4TlIAceK3ZAzCuVUe5aDPG24f9ySBm33l/kywLZkXcppZopmiLk7DKAb2WQVG4ynVCIk 1vk0QxERGTc62pQpiUyufHJpojt6fHbZfAJQBop9FKRxAKjBKzGCOMqKvGIv1c55vFDM AELCnV7h1fkkqph6SqmubG6joGn0LYRwDEndDFCDxo1kLHyUVHVATZ8V7+5Cs5ryDzBV vx4rs8IbfcAG11fBdWoGczq4OnjGQT23sk1qBA04yQy6ObX0DceGCfUjgFcUQ5UTuFtB AxHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ihCVLM8wbPa6uVw1PsjcMBaBbOPs7zo6mYASTSqfzA8=; b=dTvUJVVzjnpiskxUYdr1piROLOC0zKaJefuubjPw7CMEa9bKOBzIV05hY+VxjFI2Kx WGygC68T9hj4LW7adIyi3l0Ym9NZB1GmHhX30XdMHUzrVrewDLFtytbsib4+zUVJVk6g 6TmMPCTyJGd4FdGtl1dPDdzK7lVPB6WSfanlk5QTeLGb9OimG186IJolhz08B2ED3BTH hIwN+SWciYbjzh90EvGTwXAKUvH1/EnrFfzbjdcKeIx/LBb+5VUHCo4TaR0kxVc5tOml 1pBOViI2kdrQP3j8PokI8X9dXLcpFjii0FUnEJqNwfYiW6Pp+kgSjexFXEAzxIzvB0wy QNkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TgPmxqUH; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f21si1149708edc.230.2021.02.10.02.07.52; Wed, 10 Feb 2021 02:08:16 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=TgPmxqUH; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229812AbhBJKEx (ORCPT + 99 others); Wed, 10 Feb 2021 05:04:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230412AbhBJKAT (ORCPT ); Wed, 10 Feb 2021 05:00:19 -0500 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B99AC061788; Wed, 10 Feb 2021 01:57:06 -0800 (PST) Received: by mail-pg1-x531.google.com with SMTP id m2so891855pgq.5; Wed, 10 Feb 2021 01:57:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ihCVLM8wbPa6uVw1PsjcMBaBbOPs7zo6mYASTSqfzA8=; b=TgPmxqUHIW5DCYehR/z+rrcAFpH8wGHP96YkwUesuJ/V0x8emrbmiCj9ZeWcXLDizh qTeYPBXJPdmQeVwV77TYy4tjQBJfYuuX4IpmohLFCO9kA46MQqpkhvsA3ZAJ31C6Exda 0CB3KUP9JCPAyl+lQtKUKNnH1XAoxbuOjKy9oOjBa7c7TTEPg6OdguAnhbMNfkssun1s vRYRPhrtECIlReln01IKk630sopMxpMgJSM3vD+OuQ6xT6BxVU28XzZND8UYJM4lfFT5 /2GJghHPJ0hnOzmnZXrS0mZ0W096uDDinL9+lySrhUrzIGGYUuF9w56yAPqjss3U+xCD fUig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ihCVLM8wbPa6uVw1PsjcMBaBbOPs7zo6mYASTSqfzA8=; b=umRSKyNEAgIyBOBLU/Dd4zAzSBReK8rYeHGq3vcICBFN4rjfk0BU/KNNPFV7SDM0nn 9WDvf/QC84PcXwRb7iNdADhR8vxsXHDZhgIeE/3glBiL4H7ZhrwSPR+63+hr9Cv7UJ3I cPqRZfctJx3vMU8aVggKBV6OUQcjjdT5adbH5CGKBVu6XQA1GJUvl6t1vPBGLAYh5UGY bO4B1jum9AZNN3FgtBziy6bOQc6S3jhpYhb45CyfpdsOZgj9rqI/9CxVMTYan4gdU5kG YGCK7dW3YeCFPkno54Tk+YLK8Nl0TwBuOlmYiUAFS9SPDo5aSGdhWIyNkZRrEwNcAxPr O+tQ== X-Gm-Message-State: AOAM533jQ8BlV4KqKZFHMCajC7wOP3xa3x6PKErwHrz8MXH3TLuLRMi6 ZOY75yZ1PAAWqkRirjBPlBCPLRFP3a7Vc7YTp6Q= X-Received: by 2002:a63:3d0:: with SMTP id 199mr2400502pgd.4.1612951025778; Wed, 10 Feb 2021 01:57:05 -0800 (PST) MIME-Version: 1.0 References: <20210210074946.155417-1-drew@beagleboard.org> <20210210074946.155417-3-drew@beagleboard.org> In-Reply-To: <20210210074946.155417-3-drew@beagleboard.org> From: Andy Shevchenko Date: Wed, 10 Feb 2021 11:56:49 +0200 Message-ID: Subject: Re: [PATCH v2 2/2] pinctrl: pinmux: Add pinmux-select debugfs file To: Drew Fustini Cc: Linus Walleij , "open list:GPIO SUBSYSTEM" , Linux Kernel Mailing List , Tony Lindgren , Alexandre Belloni , Geert Uytterhoeven , Pantelis Antoniou , Jason Kridner , Robert Nelson Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 10, 2021 at 9:50 AM Drew Fustini wrote: > > Add "pinmux-select" to debugfs which will activate a function and group > when 2 integers " " are written to > the file. The write operation pinmux_select() handles this by checking > if fsel and gsel are valid selectors and then calling ops->set_mux(). > > The existing "pinmux-functions" debugfs file lists the pin functions > registered for the pin controller. For example: > > function: pinmux-uart0, groups = [ pinmux-uart0-pins ] > function: pinmux-mmc0, groups = [ pinmux-mmc0-pins ] > function: pinmux-mmc1, groups = [ pinmux-mmc1-pins ] > function: pinmux-i2c0, groups = [ pinmux-i2c0-pins ] > function: pinmux-i2c1, groups = [ pinmux-i2c1-pins ] > function: pinmux-spi1, groups = [ pinmux-spi1-pins ] > > To activate function pinmux-i2c1 (fsel 4) and group pinmux-i2c1-pins > (gsel 4): > > echo '4 4' > pinmux-select ... > DEFINE_SHOW_ATTRIBUTE(pinmux_pins); > > + One blank line (existed) is enough. > +#define PINMUX_MAX_NAME 64 ... > + buf = devm_kzalloc(pctldev->dev, PINMUX_MAX_NAME * 2, GFP_KERNEL); You have to (re-)read documentation about Device Managed Resources. Keyword here is *device*! Pay attention to it. TL;DR: misuse of device managed resources here. Potentially memory exhausting (local DoS attack), but see below. > + if (!buf) > + return -ENOMEM; ... > + devm_kfree(pctldev->dev, buf); Calling devm_kfree() or other devm_*() release kinda APIs is a red flag in 99%. See above. -- With Best Regards, Andy Shevchenko