Are you using an EF lens on a digital EOS body that can take the EFS lenses? If you are then you need to change your lens hood.
A lens hood designed for a 24mm EF lens when attached to a full frame body is designed to shade the front element almost to the point of vignetting, (vignetting is when the corners or edges of the images start to darken due to the amount of light entering being reduced by obstruction).
On a DSLR with a cropped sensor (i.e D300-450 etc or 10D, 20D, 30D etc) a 24mm lens behaves like a 38mm lens on a cropped (1.6X /APC) sensor. The physics of this means that the light rays passing through an EF lens spread out beyond the surface of the sensor and the sensor only receives light from the middle two thirds of the lens. All of the light from the edges and the corners play no part in producing an image and are therefore totally unnecessary. This in turn increases the risk of flare and ghosting, so what can you do to limit the risk and improve the quality of your images?
Most of Canons bayonet mount lens hoods are interchangeable if they have the same diameter mount. If your lens has an EW-83 mount (83 is the diameter measurement and therefore the common factor) then any EW-83 D, E, H, J,K etc will fit. So your 17-40 f4 L lens really needs a lens hood designed for a 28mm lens and in practice many people use the lens hood from their 24-105 f4 L (EW-83H) which seems to work very well. Corespondingly the EW-83 J is an ideal replacement to the H for your 24-105 f4 L
If you are not sure what to change to then multiply the shortest focal length of your lens by 1.6 then use the next nearest but lowest standard focal length as your requirement (i.e 24mm, 28mm, 35mm). Now type into ebay the starting letters (EW /ET ) then - (Dash) followed by your lens hood diameter (i.e 83- the same number on your current lens hood 60 / 74 etc) then the appropriate alternatives will be shown, pick out the hood that is designed for your new focal length requirement.
Compatible lens hoods are available from a few pounds and genuine Canon items can be found at reduced prices from international sellers and are often available second hand on ebay.
Please press YES if you have read this and found it helpful. Thank you.