Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4817733ybi; Tue, 30 Jul 2019 08:39:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZn7ciV8IcRm3CrvzgmSEYJYnn9+2qMrSBbMeEP3GdMG0Bv20DffbZAKf6YOASATEtom1A X-Received: by 2002:a63:5754:: with SMTP id h20mr68494885pgm.195.1564501176492; Tue, 30 Jul 2019 08:39:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564501176; cv=none; d=google.com; s=arc-20160816; b=sV3hlwAne+6PB42Q/EJkAEC7sQfIQrbuGmSs6BbiZGguKWMJZquEgqjc6bv6zq9v6t HpKFfVCdo+FYz67vF15K/TyME+fr/3fbL2UoWImfW75IZutKF56G9NyML6uEzerJhi1G wJpAuhKPje2nU0NKYZTUFe6HwBBaC/VqXNFLfa8MQH8BzVhrI3fqK0FhcYRcfWT/HH/L /ZH/3coBk4CAFA63S4jtMNxtQtChouR7KLk4MMROLYWNlS2RdUiyfB5Ts/xKQZp1Bmd/ k/dtae96ucm1Tc/nTnXEDlOShAFUZ0sJVREolQIiRSOE8RxAIKkXpU7LgXP8zN/l69Mh zyaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date; bh=nb+8+NbeBC8zmh3pcRLXh28OrVnxioU7Vp0w86gLNa0=; b=FDdlJLQ1fzVzzg+b8J+fny/d3jze0UKeUOyMr/3ujWQ+1KoL9H068pibOaGt7QHRJO Znk/zm5/3G0eQ/i3qQc2dG/SnQO//Ra9Y0pi8VNH1HAY1OsO9FT5iRvgmL3vfB+0tIdQ Vzx7+NTqK0AHL0DNbDt5g18XRzCFyj6TR80+iVIA8lBAEamlCTBbELiS/zBcfLbOSar3 XF2J1ikZwfXTdgs0HxQwi81WklsTdsT7t5QDiea1xM3I6/JCFxFzgP3M1s8EUA9okG4F E0URIlCZqC7dXOfL4XgfDA1fvj8xddCZMO0mM4FNAQ26T6Zq5fauks2qKngGQAxZvUzW iaYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v71si30230401pgd.468.2019.07.30.08.39.21; Tue, 30 Jul 2019 08:39:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731020AbfG3Jvm (ORCPT + 99 others); Tue, 30 Jul 2019 05:51:42 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:57681 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730901AbfG3Jvm (ORCPT ); Tue, 30 Jul 2019 05:51:42 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 9096E802A7; Tue, 30 Jul 2019 11:51:28 +0200 (CEST) Date: Tue, 30 Jul 2019 11:51:40 +0200 From: Pavel Machek To: yoshihiro.shimoda.uh@renesas.com, kishon@ti.com, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: cip-dev@lists.cip-project.org Subject: phy-rcar-gen3-usb2: wrong parsing of role in role_store? Message-ID: <20190730095140.GA29609@amd> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="XsQoSWH+UP9D9v3l" Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --XsQoSWH+UP9D9v3l Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! Code does strcmps, but does not actually check count. So AFAICT writing "host-I-don't-want-I-need-peripheral" into the file will succeed and turn it into host mode. Also data beyond count in buf are going to be accessed. Best regards, Pavel static ssize_t role_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct rcar_gen3_chan *ch =3D dev_get_drvdata(dev); bool is_b_device; enum phy_mode cur_mode, new_mode; if (!ch->is_otg_channel || !rcar_gen3_is_any_rphy_initialized(ch)) return -EIO; /* FIXME, this is wrong */ if (!strncmp(buf, "host", strlen("host"))) new_mode =3D PHY_MODE_USB_HOST; else if (!strncmp(buf, "peripheral", strlen("peripheral"))) new_mode =3D PHY_MODE_USB_DEVICE; else return -EINVAL; --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --XsQoSWH+UP9D9v3l Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAl1AEywACgkQMOfwapXb+vKz0wCeMEr6Xfbdu2izrD/k5LjebFz+ faEAoJnaRR88lf1ifgYIfsCDsbMWYSxQ =a5ET -----END PGP SIGNATURE----- --XsQoSWH+UP9D9v3l--