I was trying to paste some pattern that I made inside another layer. But each time I pasted, it ended up on the layer selected instead of its layer mask even when mask was selected.
I have Photoshop CS5.
Graphic Design Stack Exchange is a question and answer site for Graphic Design professionals, students, and enthusiasts. It only takes a minute to sign up.Sign up to join this community
If you'd like to edit a layer's mask, the Channels Panel is a great place to do it.
Masks are stored in alpha channels. Masks and channels are grayscale images, so you can edit them like any other image with painting tools, editing tools and filters. Areas painted black on a mask are protected, and areas painted white are editable.
Adobe help: About masks and alpha channels
Bitmap layer masks are alpha channels, and they appear in the Channels Panel. You can edit them directly from the Layers Panel, but you see everything composited, so it can be a little trickier to understand what's going on.
It may be worth becoming familiar with Clipping Masks, too. They're very handy and allow for things that aren't easily possible with Layer Masks.
PSDTuts+: What is a Clipping Mask then?