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=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 B948DC32751 for ; Wed, 31 Jul 2019 09:27:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9B42E20657 for ; Wed, 31 Jul 2019 09:27:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728868AbfGaJ1S (ORCPT ); Wed, 31 Jul 2019 05:27:18 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:44301 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727329AbfGaJ1Q (ORCPT ); Wed, 31 Jul 2019 05:27:16 -0400 Received: by mail-wr1-f68.google.com with SMTP id p17so68834040wrf.11; Wed, 31 Jul 2019 02:27:15 -0700 (PDT) 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=EGM5RKDve8/AJbKDylbWZIikdzuX+zEV16LFhW7u4Ok=; b=JENqiz9OBD+afpN0kpc5rEgo8xfGE/dhb+/OW82KY3olCKzgzUWt1SyBXdTVqc+vtY nA61KOD29bO52ZTQK0ZEI3EZvqdNcdwZWZb/b5nyLOIgJyAHpriptBPJWne79zqw6yCx FSO8CjpLkja/nlgItQ0CjtfJX5QePx3GaUbTGUbwuDkWp/TCfOhNsEy1EMZEdKk6rPMu pnC6SgdO7S+T7U1M2iROS0qAbNdvsN4bF4LaNA9HNt88p65qjLHCIHp/v6lRP1/xtQJN Wn7Dq4V9kKxd7UZeAvaQvNiIllmjqKAaJJib266b5cqaBpNH1L52eNFs9TifbLeVIgVz MWHA== X-Gm-Message-State: APjAAAW/WIcPPesnr1ArK7FBMbqd8ZcarpXBd7ib/cWoGYwxdOq0l0M3 NxMeZJWhwFH7FzYsDss1kqMfAvZElechUWSX8TpMoA== X-Google-Smtp-Source: APXvYqw9c9Q5GKDpsqV7MciNU/urisuCE7B3KXVQAFDBcKvBOEM0oVW1SwoqNTvYlQZ5w9O4vw30XmIutx+pqJr8X3M= X-Received: by 2002:a5d:630c:: with SMTP id i12mr45644695wru.312.1564565234591; Wed, 31 Jul 2019 02:27:14 -0700 (PDT) MIME-Version: 1.0 References: <1564563689-25863-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> In-Reply-To: <1564563689-25863-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> From: Geert Uytterhoeven Date: Wed, 31 Jul 2019 11:27:02 +0200 Message-ID: Subject: Re: [PATCH] phy: renesas: rcar-gen3-usb2: Fix sysfs interface of "role" To: Yoshihiro Shimoda Cc: Kishon Vijay Abraham I , Pavel Machek , Linux Kernel Mailing List , Linux-Renesas , stable Content-Type: text/plain; charset="UTF-8" Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Hi Shimoda-san, On Wed, Jul 31, 2019 at 11:04 AM Yoshihiro Shimoda wrote: > Since the role_store() uses strncmp(), it's possible to refer > out-of-memory if the sysfs data size is smaller than strlen("host"). > This patch fixes it by using sysfs_streq() instead of strncmp(). > > Reported-by: Pavel Machek > Fixes: 9bb86777fb71 ("phy: rcar-gen3-usb2: add sysfs for usb role swap") > Cc: # v4.10+ > Signed-off-by: Yoshihiro Shimoda Reviewed-by: Geert Uytterhoeven > --- > Just a record. The role_store() doesn't need to check the count because > the sysfs_streq() checks the first argument is NULL or not. Is that wat you mean? sysfs_streq() doesn't seem to check for NULL pointers. Isn't the real reason that sysfs (kernfs) guarantees that the passed buffer is NUL-terminated? Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds