Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753931AbbEKVKB (ORCPT ); Mon, 11 May 2015 17:10:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53233 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753405AbbEKVJ7 (ORCPT ); Mon, 11 May 2015 17:09:59 -0400 Message-ID: <1431378580.2407.528.camel@redhat.com> Subject: Re: [PATCH] IB/ehca: use correct destination for memcpy From: Doug Ledford To: Nicholas Mc Guire Cc: Hoang-Nam Nguyen , Christoph Raisch , Sean Hefty , Hal Rosenstock , Dan Carpenter , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 11 May 2015 17:09:40 -0400 In-Reply-To: <1431355082-29290-1-git-send-email-hofrat@osadl.org> References: <1431355082-29290-1-git-send-email-hofrat@osadl.org> Organization: Red Hat, Inc. Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-URQORkTtxU0MNoDlv/TM" Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2529 Lines: 68 --=-URQORkTtxU0MNoDlv/TM Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, 2015-05-11 at 16:38 +0200, Nicholas Mc Guire wrote: > Using an element of a struct as the address for the memcpy of the whole > struct may introduce a buffer overflow and does not help readability eith= er > simply pass the real thing as first argument to memcpy. >=20 > Reported-by: Dan Carpenter > Signed-off-by: Nicholas Mc Guire > --- >=20 > passing the first element of a struct as destination triggers buffer=20 > overflows warnings in tools like Smatch.=20 > ./drivers/infiniband/hw/ehca/ehca_mcast.c:ehca_attach_mcast.80 WARNING: > memcpy copying entire struct to first element > ./drivers/infiniband/hw/ehca/ehca_mcast.c:ehca_detach_mcast.117 WARNING: > memcpy copying entire struct to first element >=20 > Simply use the structure rather than the first element (which could chang= e) > which also help readability. >=20 > Patch was only compile tested with ppc64_defconfig (implies > CONFIG_INFINIBAND_EHCA=3Dm) >=20 > Patch is against 4.1-rc3 (localversion-next is -next-20150511) Applied, thanks. --=20 Doug Ledford GPG KeyID: 0E572FDD --=-URQORkTtxU0MNoDlv/TM Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCAAGBQJVURqUAAoJELgmozMOVy/dcVEQAKZ2lsW+KePcS7G1nWsl2X6o IiEZ6M1UT0XHxEPNrxnBpFhMdRG6dlTWxVHaOEtjY1p1aESJG9If6x0Xz06wzGSH koPzcUxVDSPjI/91KpwZp5JN/fQLaSU1ukqpkeKcexKIJ8Wv9yJuVcEzxbe9sQSn TUSNq9lIN4DGrIDw4Qn9a74qSc4pThvuwblNaTyxJRG2s1oTVn6f+UgGvyfFVtBR NhfJYOPffmSt0rG8LnWIBaaEz98UuFJg29AlI7xQK1VFkShEXbGSGyZgOU0K0xOP gnVh9hVAzZyX8eySujMIqjsiXJmw960DaffYuBeifu9HwYt0CtvNFZgZW2qPn6QZ X8ZEWDgCcUtefK97CTRw6qRLPOuAbN5R2sdTrbYTcrm0UQ6V43uDgxGbyhwk6vz6 osMRvvUtlnxCFT2RqCOPe4IRrTtGbRGZ6pdCxjX1Wr029wtZVu0EJVUDLuETaWYv buWR81v3mqLJyf3+BlGayTYasi8WlQ26CJ9GyabCM+FYHKJO12kcrki9wC4L4IJF UuHY7EZMPffQwPVIy5FN6cf6vo0y+lovMi93g+hkOgFWzIJfsDXgCzZmZ/36SxLq cRR/Xl7c5HrgXROZuuTYd2JoouJvs+RL2M4nv+zurbULrVb5kw8RX5iGa6hq1+xP FhZrXEtYfG8tuNCR1H/E =OqHi -----END PGP SIGNATURE----- --=-URQORkTtxU0MNoDlv/TM-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/